Subversion Repositories SmartDukaan

Rev

Rev 28473 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28473 Rev 30220
Line 1... Line 1...
1
package com.spice.profitmandi.service;
1
package com.spice.profitmandi.service;
2
 
2
 
-
 
3
import com.spice.profitmandi.common.model.*;
-
 
4
import org.springframework.stereotype.Component;
-
 
5
 
3
import java.time.LocalDate;
6
import java.time.LocalDate;
4
import java.time.LocalDateTime;
7
import java.time.LocalDateTime;
5
import java.time.format.DateTimeFormatter;
8
import java.time.format.DateTimeFormatter;
6
import java.util.ArrayList;
9
import java.util.ArrayList;
7
import java.util.LinkedHashSet;
10
import java.util.LinkedHashSet;
8
import java.util.List;
11
import java.util.List;
9
import java.util.Map;
12
import java.util.Map;
10
import java.util.Map.Entry;
13
import java.util.Map.Entry;
11
 
14
 
12
import org.springframework.stereotype.Component;
-
 
13
 
-
 
14
import com.spice.profitmandi.common.model.ChartModel;
-
 
15
import com.spice.profitmandi.common.model.DataModel;
-
 
16
import com.spice.profitmandi.common.model.DatasetModel;
-
 
17
import com.spice.profitmandi.common.model.HoverModel;
-
 
18
import com.spice.profitmandi.common.model.LegendModel;
-
 
19
import com.spice.profitmandi.common.model.OptionsModel;
-
 
20
import com.spice.profitmandi.common.model.TitleModel;
-
 
21
import com.spice.profitmandi.common.model.Tooltips;
-
 
22
 
-
 
23
@Component
15
@Component
24
public class ChartServiceImpl implements ChartService {
16
public class ChartServiceImpl implements ChartService {
25
 
17
 
26
	@Override
18
	@Override
27
	public ChartModel createChart(int monthValue, Map<String, List<Double>> sortedBrandValue, List<String> colorList,
19
	public ChartModel createChart(int monthValue, Map<String, List<Double>> sortedBrandValue, List<String> colorList,
28
			List<String> borderList, String title) {
20
								  List<String> borderList, String title) {
29
 
21
 
30
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
22
		LocalDateTime curDate = LocalDate.now().atStartOfDay();
31
 
23
 
32
		LinkedHashSet<String> labels = new LinkedHashSet<String>();
24
		LinkedHashSet<String> labels = new LinkedHashSet<String>();
33
 
25
 
34
		for (int i = monthValue; i >= 0; i--) {
26
		for (int i = monthValue; i >= 0; i--) {
35
 
27
 
36
			LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
28
			LocalDateTime startMonth = curDate.withDayOfMonth(1).minusMonths(i);
37
			labels.add(startMonth.format(DateTimeFormatter.ofPattern("MMM''uu")).toString());
29
			labels.add(startMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
38
		}
30
		}
39
 
31
 
-
 
32
		return createChartWithLabels(labels, sortedBrandValue, colorList,
-
 
33
				borderList, title);
-
 
34
 
-
 
35
	}
-
 
36
 
-
 
37
	@Override
-
 
38
	public ChartModel createChartWithLabels(LinkedHashSet<String> labels, Map<String, List<Double>> sortedBrandValue, List<String> colorList, List<String> borderList, String title) {
-
 
39
 
40
		List<DatasetModel> datasets = new ArrayList<>();
40
		List<DatasetModel> datasets = new ArrayList<>();
41
 
41
 
42
		int i = 0;
42
		int i = 0;
43
 
43
 
44
		for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {
44
		for (Entry<String, List<Double>> brandValue : sortedBrandValue.entrySet()) {