-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchart.js
115 lines (93 loc) · 2.35 KB
/
chart.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import '../external/chart.js'
// This class provides some common functionality for all charts
// It should not be used as actual diagram. Please use the corresponding subclasses.
export default class MetricChart {
constructor(parameters = { canvas: null, statistics_container: null }) {
this._data = []
this._chart = null
this._canvas = parameters.canvas
this._statistics_container = parameters.statistics_container
this._title = ''
this._data_title = ''
this._git_artifact_name = ''
this._config = {}
}
get git_artifact_name() {
return this._git_artifact_name
}
set git_artifact_name(value) {
this._git_artifact_name = value
}
get config() {
return this._config
}
set config(value) {
this._config = value
}
set chart(chart) {
this._chart = chart
}
get chart() {
return this._chart
}
set data_title(title) {
this._data_title = title
}
get data_title() {
return this._data_title
}
set title(title) {
this._title = title
}
get title() {
return this._title
}
set data(data) {
this._data = data
}
get data() {
return this._data
}
get canvas() {
return this._canvas
}
get statistics_container() {
return this._statistics_container
}
draw() {
if (this.chart === null) {
this.chart = this._construct_chart()
}
this._update()
}
_update() {
this.chart.data = {
labels: this._construct_chart_labels(),
datasets: this._construct_chart_datasets()
}
this.chart.update()
}
_construct_chart() {
const drawing_context = this.canvas.getContext('2d')
return new Chart(drawing_context, {
data: {
labels: this._construct_chart_labels(),
datasets: this._construct_chart_datasets()
},
plugins: this._construct_chart_plugins(),
options: this._construct_chart_options()
})
}
_construct_chart_plugins() {
return []
}
_construct_chart_options() {
return {}
}
_construct_chart_labels() {
return []
}
_construct_chart_datasets() {
return []
}
}