回答編集履歴
3
消し忘れた
test
CHANGED
@@ -126,7 +126,7 @@
|
|
126
126
|
|
127
127
|
i++;
|
128
128
|
|
129
|
-
setTimeout(test,100
|
129
|
+
setTimeout(test,100);
|
130
130
|
|
131
131
|
}
|
132
132
|
|
2
ちょっとよくなかったので修正
test
CHANGED
@@ -61,3 +61,77 @@
|
|
61
61
|
}
|
62
62
|
|
63
63
|
```
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
##### ちょっとよくなかったので修正
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
```js
|
72
|
+
|
73
|
+
window.addEventListener('load', function () {
|
74
|
+
|
75
|
+
var ctx = document.getElementById('js-line-graph');
|
76
|
+
|
77
|
+
var data = [40, 30, 48, 33, 30, 30, 38, 33, 28, 40, 31, 40];
|
78
|
+
|
79
|
+
var i = 0;
|
80
|
+
|
81
|
+
var lineGraph = new Chart(ctx, {
|
82
|
+
|
83
|
+
type: 'line',
|
84
|
+
|
85
|
+
data: {
|
86
|
+
|
87
|
+
//...
|
88
|
+
|
89
|
+
datasets: [
|
90
|
+
|
91
|
+
{
|
92
|
+
|
93
|
+
label: '',
|
94
|
+
|
95
|
+
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
96
|
+
|
97
|
+
//...
|
98
|
+
|
99
|
+
},
|
100
|
+
|
101
|
+
options: {
|
102
|
+
|
103
|
+
//...
|
104
|
+
|
105
|
+
animation:{
|
106
|
+
|
107
|
+
onComplete:function(animation){
|
108
|
+
|
109
|
+
setTimeout(test,100);
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
},
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
});
|
118
|
+
|
119
|
+
function test(){
|
120
|
+
|
121
|
+
if ( i < data.length ){
|
122
|
+
|
123
|
+
lineGraph.data.datasets[0].data[i] = data[i];
|
124
|
+
|
125
|
+
lineGraph.update();
|
126
|
+
|
127
|
+
i++;
|
128
|
+
|
129
|
+
setTimeout(test,100,i);
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
});
|
136
|
+
|
137
|
+
```
|
1
書式の修正
test
CHANGED
@@ -3,6 +3,32 @@
|
|
3
3
|
[サンプル](https://jsfiddle.net/Lhankor_Mhy/x4ebhgru/)
|
4
4
|
|
5
5
|
```js
|
6
|
+
|
7
|
+
window.addEventListener('load', function () {
|
8
|
+
|
9
|
+
var data = [40, 30, 48, 33, 30, 30, 38, 33, 28, 40, 31, 40];
|
10
|
+
|
11
|
+
var lineGraph = new Chart(ctx, {
|
12
|
+
|
13
|
+
data: {
|
14
|
+
|
15
|
+
//...
|
16
|
+
|
17
|
+
datasets: [
|
18
|
+
|
19
|
+
{
|
20
|
+
|
21
|
+
label: '',
|
22
|
+
|
23
|
+
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
24
|
+
|
25
|
+
//...
|
26
|
+
|
27
|
+
},
|
28
|
+
|
29
|
+
options: {
|
30
|
+
|
31
|
+
//...
|
6
32
|
|
7
33
|
animation:{
|
8
34
|
|
@@ -14,9 +40,11 @@
|
|
14
40
|
|
15
41
|
},
|
16
42
|
|
17
|
-
|
43
|
+
//...
|
18
44
|
|
45
|
+
}
|
46
|
+
|
19
|
-
|
47
|
+
});
|
20
48
|
|
21
49
|
function test(i){
|
22
50
|
|