質問編集履歴
2
情報追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -51,3 +51,151 @@
|
|
51
51
|
というデータを追加し、それをクリック等で切り替えられるようにしたいです。
|
52
52
|
|
53
53
|
どのようなコードを記述すれば実現出来るのでしょうか?
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```html
|
58
|
+
|
59
|
+
<script>
|
60
|
+
|
61
|
+
var ctx = document.getElementById("BarChart").getContext('2d');
|
62
|
+
|
63
|
+
var DiskChart = new Chart(ctx, {
|
64
|
+
|
65
|
+
type: 'bar',
|
66
|
+
|
67
|
+
data: {
|
68
|
+
|
69
|
+
labels: ["2018/9", "2018/10", "2018/11"],
|
70
|
+
|
71
|
+
datasets: [
|
72
|
+
|
73
|
+
{
|
74
|
+
|
75
|
+
label: "しめじ",
|
76
|
+
|
77
|
+
data: [20, 26, 12],
|
78
|
+
|
79
|
+
},
|
80
|
+
|
81
|
+
{
|
82
|
+
|
83
|
+
label: "えのき",
|
84
|
+
|
85
|
+
data: [28, 22, 32],
|
86
|
+
|
87
|
+
},
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
{
|
92
|
+
|
93
|
+
label: "しいたけ",
|
94
|
+
|
95
|
+
data: [15, 23, 15],
|
96
|
+
|
97
|
+
},
|
98
|
+
|
99
|
+
]
|
100
|
+
|
101
|
+
},
|
102
|
+
|
103
|
+
options: {
|
104
|
+
|
105
|
+
scales: {
|
106
|
+
|
107
|
+
xAxes: [{
|
108
|
+
|
109
|
+
stacked: true,
|
110
|
+
|
111
|
+
}],
|
112
|
+
|
113
|
+
yAxes: [{
|
114
|
+
|
115
|
+
stacked: true,
|
116
|
+
|
117
|
+
}],
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
});
|
124
|
+
|
125
|
+
</script>
|
126
|
+
|
127
|
+
```
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
```html
|
132
|
+
|
133
|
+
<script>
|
134
|
+
|
135
|
+
var ctx = document.getElementById("BarChart").getContext('2d');
|
136
|
+
|
137
|
+
var DiskChart = new Chart(ctx, {
|
138
|
+
|
139
|
+
type: 'bar',
|
140
|
+
|
141
|
+
data: {
|
142
|
+
|
143
|
+
labels: ["2018/9", "2018/10", "2018/11"],
|
144
|
+
|
145
|
+
datasets: [
|
146
|
+
|
147
|
+
{
|
148
|
+
|
149
|
+
label: "リンゴ",
|
150
|
+
|
151
|
+
data: [20, 26, 12],
|
152
|
+
|
153
|
+
},
|
154
|
+
|
155
|
+
{
|
156
|
+
|
157
|
+
label: "みかん",
|
158
|
+
|
159
|
+
data: [28, 22, 32],
|
160
|
+
|
161
|
+
},
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
{
|
166
|
+
|
167
|
+
label: "ぶどう",
|
168
|
+
|
169
|
+
data: [15, 23, 15],
|
170
|
+
|
171
|
+
},
|
172
|
+
|
173
|
+
]
|
174
|
+
|
175
|
+
},
|
176
|
+
|
177
|
+
options: {
|
178
|
+
|
179
|
+
scales: {
|
180
|
+
|
181
|
+
xAxes: [{
|
182
|
+
|
183
|
+
stacked: true,
|
184
|
+
|
185
|
+
}],
|
186
|
+
|
187
|
+
yAxes: [{
|
188
|
+
|
189
|
+
stacked: true,
|
190
|
+
|
191
|
+
}],
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
});
|
198
|
+
|
199
|
+
</script>
|
200
|
+
|
201
|
+
```
|
1
情報追加
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
chart.jsでグラフのデータを動的に
|
1
|
+
chart.jsでグラフのデータを動的に切り替えるにはどのようにすれば良いでしょうか?
|
test
CHANGED
File without changes
|