-
Notifications
You must be signed in to change notification settings - Fork 86
/
chart-line-interactive.js
61 lines (52 loc) · 1.31 KB
/
chart-line-interactive.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { inject as service } from '@ember/service';
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import commitStats from '../data/commit-stats';
export default class LineInteractive extends Component {
@service('dynamic-chart')
dynamicChart;
chartOptions = {
chart: {
type: 'line',
},
title: {
text: 'Repo commits',
},
xAxis: {
type: 'category',
title: {
text: 'Week',
},
},
yAxis: {
title: {
text: '# of Commits',
},
},
};
@tracked
chartData = structuredClone(commitStats);
@action
updateSeriesData() {
let newChartData = this.dynamicChart.updateSeriesData(commitStats, 2, 52);
this.chartData = newChartData;
}
@action
fullUpdateToSeries() {
let newChartData = this.dynamicChart.updateSeriesData(commitStats, 2, 52);
// updated currentTime attribute causes series.update() to be used instead of series.setData()
newChartData.forEach((series) => {
series.currentTime = Date.now();
});
this.chartData = newChartData;
}
@action
setSeriesCount(numSeries) {
let newChartData = this.dynamicChart.updateSeriesCount(
commitStats,
numSeries,
);
this.chartData = newChartData;
}
}