-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraph.js
42 lines (35 loc) · 824 Bytes
/
Graph.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
class Graph{
constructor(ctx, type) {
this.ctx = ctx
this.graphType = type
this.datasets = []
}
addDataset(dataset){
this.datasets.push(dataset)
}
setLabels(labels){
this.labels = labels
}
removeDataset(dataset, i){
this.datasets.splice(i, 1)
}
clearAllDatasets(){
this.datasets = []
}
show(){
console.log("Graph Type: " + this.graphType)
console.log("Labels: ", this.labels)
console.log("Datasets: ", this.datasets)
}
plot(){
var chart = new Chart(this.ctx,{
type: this.graphType,
data: {
labels: this.labels,
datasets: this.datasets
}
})
this.chartObject = chart
return chart
}
}