Skip to content

Commit 5b74fe4

Browse files
committed
adjust performance chart, move data to service
1 parent d6a73a3 commit 5b74fe4

File tree

4 files changed

+26
-65
lines changed

4 files changed

+26
-65
lines changed

src/app/controllers/PerformanceController.js

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@
99
function PerformanceController(performanceService, $q) {
1010
var vm = this;
1111

12-
13-
vm.performanceChartData = performanceFunction;
14-
15-
function performanceFunction() {
16-
var sin = [];
17-
for (var i = 0; i < 100; i++) {
18-
sin.push({x: i, y: Math.abs(Math.cos(i/10) *0.25*i + 0.9 - 0.4*i)});
19-
}
20-
return [ { values: sin, color: 'rgb(0, 150, 136)', area: true } ];
21-
}
22-
2312
vm.chartOptions = {
2413
chart: {
2514
type: 'stackedAreaChart',
@@ -32,37 +21,13 @@
3221
title: 'Over 9K',
3322
showYAxis: false,
3423
showXAxis: false,
24+
color: ['rgb(0, 150, 136)', 'rgb(204, 203, 203)', 'rgb(149, 149, 149)', 'rgb(44, 44, 44)'],
3525
tooltip: { contentGenerator: function (d) { return '<div class="custom-tooltip">' + d.point.y + '%</div>' + '<div class="custom-tooltip">' + d.series[0].key + '</div>' } },
3626
showControls: false
3727
}
3828
};
3929

40-
vm.performanceData = {};
41-
vm.performanceChartData = [
42-
43-
44-
// TODO: move data to service, implement period switching
45-
{
46-
"key" : 'Middleware' ,
47-
"values" : [ [1,13], [2,14], [3,24], [4,18], [5,16], [6,14], [7,11], [8, 13], [9,15], [10,11], [11,18], [12,16], [13,28], [14,11], [15,12], [16,13], [17,12], [18,20], [19, 22], [20, 18], [21,11], [22,10], [23,18], [24, 20], [25,9], [26,14], [27,10], [28,11], [29,17] ]
48-
},
49-
50-
{
51-
"key" : 'Ruby' ,
52-
"values" : [ [1,29], [2,36], [3,42], [4,25], [5,22], [6,34], [7,41], [8, 19], [9,45], [10,31], [11,28], [12,36], [13,54], [14,41], [15,36], [16,39], [17,21], [18,20], [19, 22], [20, 44], [21,32], [22,20], [23,28], [24, 24], [25,29], [26,19], [27,20], [28,31], [29,49] ]
53-
},
54-
55-
{
56-
"key" : 'Web External' ,
57-
"values" : [ [1,54], [2,74], [3,64], [4,68], [5,56], [6,44], [7,61], [8, 63], [9,45], [10,51], [11,68], [12,46], [13,64], [14,51], [15,42], [16,63], [17,72], [18,60], [19, 52], [20, 58], [21,41], [22,40], [23,58], [24, 30], [25,49], [26,54], [27,60], [28,41], [29,66] ]
58-
} ,
59-
{
60-
"key" : 'Database' ,
61-
"values" : [ [1,64], [2,84], [3,64], [4,68], [5,86], [6,74], [7,81], [8, 83], [9,65], [10,61], [11,88], [12,76], [13,84], [14,71], [15,82], [16,73], [17,92], [18,80], [19, 62], [20, 68], [21,71], [22,50], [23,78], [24, 60], [25,59], [26,74], [27,80], [28,51], [29,97] ]
62-
}
63-
64-
65-
];
30+
vm.performanceChartData = [];
6631
vm.performancePeriod = 'week';
6732
vm.changePeriod = changePeriod;
6833

@@ -75,7 +40,7 @@
7540

7641

7742
function loadData() {
78-
vm.performanceData = performanceService.getPerformanceData(vm.performancePeriod);
43+
vm.performanceChartData = performanceService.getPerformanceData(vm.performancePeriod);
7944
}
8045

8146
function changePeriod() {

src/app/views/dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
</div>
1212

1313
<div layout-gt-md="row">
14-
<panel-widget flex title="Performance" template="app/views/partials/progress.html" options="true"></panel-widget>
14+
<panel-widget flex title="Performance" template="app/views/partials/performance.html" options="true"></panel-widget>
1515
<panel-widget flex title="TODO list" template="app/views/partials/checkboxes.html"></panel-widget>
1616
</div>
File renamed without changes.

src/components/data/PerformanceService.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,43 @@
1818
if (performancePeriod === 'week') {
1919
return [
2020
{
21-
title: 'Database',
22-
value: 54,
23-
theme: 'dark'
21+
"key" : 'Middleware' ,
22+
"values" : [ [1,11], [2,10], [3,14], [4,21], [5,13], [6,21], [7,21], [8, 18], [9,11], [10,11], [11,18], [12,14], [13,10], [14,20], [15,21], [16,28], [17,12], [18,16], [19, 22], [20, 18], [21,21], [22,10], [23,11], [24, 14], [25,9], [26,14], [27,10], [28,21], [29,11] ]
2423
},
24+
2525
{
26-
title: 'Web external',
27-
value: 64,
28-
theme: ''
26+
"key" : 'Ruby' ,
27+
"values" : [ [1,29], [2,36], [3,42], [4,25], [5,22], [6,34], [7,41], [8, 19], [9,45], [10,31], [11,28], [12,36], [13,54], [14,41], [15,36], [16,39], [17,21], [18,20], [19, 22], [20, 44], [21,32], [22,20], [23,28], [24, 24], [25,29], [26,19], [27,20], [28,31], [29,49] ]
2928
},
29+
3030
{
31-
title: 'Middleware',
32-
value: 13,
33-
theme: 'grey'
34-
},
31+
"key" : 'Web External' ,
32+
"values" : [ [1,54], [2,74], [3,64], [4,68], [5,56], [6,44], [7,61], [8, 63], [9,45], [10,51], [11,68], [12,46], [13,64], [14,51], [15,42], [16,63], [17,72], [18,60], [19, 52], [20, 58], [21,41], [22,40], [23,58], [24, 30], [25,49], [26,54], [27,60], [28,41], [29,66] ]
33+
} ,
3534
{
36-
title: 'Ruby',
37-
value: 29,
38-
theme: 'red'
35+
"key" : 'Database' ,
36+
"values" : [ [1,64], [2,84], [3,64], [4,68], [5,86], [6,74], [7,81], [8, 83], [9,65], [10,61], [11,88], [12,76], [13,84], [14,71], [15,82], [16,73], [17,92], [18,80], [19, 62], [20, 68], [21,71], [22,50], [23,78], [24, 60], [25,59], [26,74], [27,80], [28,51], [29,97] ]
3937
}
4038
]
4139
} else {
4240
return [
4341
{
44-
title: 'Database',
45-
value: 41,
46-
theme: 'dark'
42+
"key" : 'Middleware' ,
43+
"values" : [ [1,13], [2,14], [3,24], [4,18], [5,16], [6,14], [7,11], [8, 13], [9,15], [10,11], [11,18], [12,16], [13,28], [14,11], [15,12], [16,13], [17,12], [18,20], [19, 22], [20, 18], [21,11], [22,10], [23,18], [24, 20], [25,9], [26,14], [27,10], [28,11], [29,17] ]
4744
},
45+
4846
{
49-
title: 'Web external',
50-
value: 43,
51-
theme: ''
47+
"key" : 'Ruby' ,
48+
"values" : [ [1,29], [2,36], [3,42], [4,25], [5,22], [6,34], [7,41], [8, 19], [9,45], [10,31], [11,28], [12,36], [13,54], [14,41], [15,36], [16,39], [17,21], [18,20], [19, 22], [20, 44], [21,32], [22,20], [23,28], [24, 24], [25,29], [26,19], [27,20], [28,31], [29,49] ]
5249
},
50+
5351
{
54-
title: 'Middleware',
55-
value: 6,
56-
theme: 'grey'
57-
},
52+
"key" : 'Web External' ,
53+
"values" : [ [1,54], [2,74], [3,64], [4,68], [5,56], [6,44], [7,61], [8, 63], [9,45], [10,51], [11,68], [12,46], [13,64], [14,51], [15,42], [16,63], [17,72], [18,60], [19, 52], [20, 58], [21,41], [22,40], [23,58], [24, 30], [25,49], [26,54], [27,60], [28,41], [29,66] ]
54+
} ,
5855
{
59-
title: 'Ruby',
60-
value: 21,
61-
theme: 'red'
56+
"key" : 'Database' ,
57+
"values" : [ [1,74], [2,64], [3,84], [4,78], [5,66], [6,64], [7,71], [8, 83], [9,55], [10,81], [11,88], [12,76], [13,84], [14,71], [15,62], [16,73], [17,82], [18,80], [19, 92], [20, 68], [21,71], [22,70], [23,78], [24, 80], [25,59], [26,74], [27,80], [28,51], [29,67] ]
6258
}
6359
]
6460
}

0 commit comments

Comments
 (0)