質問編集履歴
5
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,16 +28,116 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
+
2017/11/08
|
32
|
+
|
33
|
+
・進捗状況
|
34
|
+
|
35
|
+
ツールチップ常時表示、線グラフの色分け、ラベルの非表示が解決いたしました。
|
36
|
+
|
37
|
+
ただ、線グラフ"After 1 year"以降のツールチップ内のデータが"undefined%"と表示されてしまいます。
|
38
|
+
|
39
|
+
あと、ツールチップ内のラベル名が重複してしまっているので1つに絞りたいと考えています。
|
40
|
+
|
41
|
+
重ねてのお願いで恐縮ですが、ご教示頂けますと幸いです。
|
42
|
+
|
43
|
+
|
44
|
+
|
31
45
|
```ここに言語を入力
|
32
46
|
|
33
|
-
<div class="container" style="width:100%">
|
34
|
-
|
35
|
-
<canvas id="myBarChart1" width="800" height="400"></canvas>
|
36
|
-
|
37
|
-
|
38
|
-
|
39
47
|
<script>
|
40
48
|
|
49
|
+
//ツールチップ常時表示
|
50
|
+
|
51
|
+
Chart.pluginService.register({
|
52
|
+
|
53
|
+
beforeRender: function (chart) {
|
54
|
+
|
55
|
+
if (chart.config.options.showAllTooltips) {
|
56
|
+
|
57
|
+
// create an array of tooltips
|
58
|
+
|
59
|
+
// we can't use the chart tooltip because there is only one tooltip per chart
|
60
|
+
|
61
|
+
chart.pluginTooltips = [];
|
62
|
+
|
63
|
+
chart.config.data.datasets.forEach(function (dataset, i) {
|
64
|
+
|
65
|
+
chart.getDatasetMeta(i).data.forEach(function (sector, j) {
|
66
|
+
|
67
|
+
chart.pluginTooltips.push(new Chart.Tooltip({
|
68
|
+
|
69
|
+
_chart: chart.chart,
|
70
|
+
|
71
|
+
_chartInstance: chart,
|
72
|
+
|
73
|
+
_data: chart.data,
|
74
|
+
|
75
|
+
_options: chart.options.tooltips,
|
76
|
+
|
77
|
+
_active: [sector]
|
78
|
+
|
79
|
+
}, chart));
|
80
|
+
|
81
|
+
});
|
82
|
+
|
83
|
+
});
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
// turn off normal tooltips
|
88
|
+
|
89
|
+
chart.options.tooltips.enabled = false;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
},
|
94
|
+
|
95
|
+
afterDraw: function (chart, easing) {
|
96
|
+
|
97
|
+
if (chart.config.options.showAllTooltips) {
|
98
|
+
|
99
|
+
// we don't want the permanent tooltips to animate, so don't do anything till the animation runs atleast once
|
100
|
+
|
101
|
+
if (!chart.allTooltipsOnce) {
|
102
|
+
|
103
|
+
if (easing !== 1)
|
104
|
+
|
105
|
+
return;
|
106
|
+
|
107
|
+
chart.allTooltipsOnce = true;
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
// turn on tooltips
|
114
|
+
|
115
|
+
chart.options.tooltips.enabled = true;
|
116
|
+
|
117
|
+
Chart.helpers.each(chart.pluginTooltips, function (tooltip) {
|
118
|
+
|
119
|
+
tooltip.initialize();
|
120
|
+
|
121
|
+
tooltip.update();
|
122
|
+
|
123
|
+
// we don't actually need this since we are not animating tooltips
|
124
|
+
|
125
|
+
tooltip.pivot();
|
126
|
+
|
127
|
+
tooltip.transition(easing).draw();
|
128
|
+
|
129
|
+
});
|
130
|
+
|
131
|
+
chart.options.tooltips.enabled = false;
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
});
|
138
|
+
|
139
|
+
|
140
|
+
|
41
141
|
//棒グラフ
|
42
142
|
|
43
143
|
var ctx = document.getElementById("myBarChart1");
|
@@ -52,10 +152,16 @@
|
|
52
152
|
|
53
153
|
data: {
|
54
154
|
|
155
|
+
//データ項目のラベル
|
156
|
+
|
55
157
|
labels: ["Before 3 years","Before 2 years","Before 1 year","Start", "After 1 year", "After 2 years", "After 3 years"],
|
56
158
|
|
159
|
+
//データセット
|
160
|
+
|
57
161
|
datasets: [{
|
58
162
|
|
163
|
+
label: "年間売上比率",
|
164
|
+
|
59
165
|
backgroundColor: ["rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)", "rgba(75,192,192,1)", "rgba(75,192,192,1)", "rgba(75,192,192,1)"],
|
60
166
|
|
61
167
|
//グラフのデータ
|
@@ -74,17 +180,247 @@
|
|
74
180
|
|
75
181
|
options: {
|
76
182
|
|
183
|
+
showAllTooltips: true,
|
184
|
+
|
77
185
|
animation: {
|
78
186
|
|
79
187
|
duration: 8000,
|
80
188
|
|
81
189
|
},
|
82
190
|
|
191
|
+
legend: {
|
192
|
+
|
193
|
+
display: false,
|
194
|
+
|
195
|
+
},
|
196
|
+
|
197
|
+
//軸の設定
|
198
|
+
|
199
|
+
scales: {
|
200
|
+
|
201
|
+
//縦軸の設定
|
202
|
+
|
203
|
+
yAxes: [{
|
204
|
+
|
205
|
+
display: true,
|
206
|
+
|
207
|
+
stacked: false,
|
208
|
+
|
209
|
+
gridLines: {
|
210
|
+
|
211
|
+
display: false
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
}],
|
216
|
+
|
217
|
+
xAxes: [{
|
218
|
+
|
219
|
+
display: true,
|
220
|
+
|
221
|
+
stacked: false,
|
222
|
+
|
223
|
+
gridLines: {
|
224
|
+
|
225
|
+
display: false
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
}]
|
230
|
+
|
231
|
+
},
|
232
|
+
|
233
|
+
tooltips: {
|
234
|
+
|
235
|
+
callbacks: {
|
236
|
+
|
237
|
+
label: function (tooltipItem, data) {
|
238
|
+
|
239
|
+
return data.labels[tooltipItem.index]
|
240
|
+
|
241
|
+
+ ": "
|
242
|
+
|
243
|
+
+ data.datasets[0].data[tooltipItem.index]
|
244
|
+
|
245
|
+
+ " 倍";
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
});
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
</script>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
</div>
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
<canvas id="myLineChart" width="800" height="400"></canvas>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
<script>
|
282
|
+
|
283
|
+
//折れ線グラフ
|
284
|
+
|
285
|
+
var ctx = document.getElementById("myLineChart");
|
286
|
+
|
287
|
+
var myLineChart = new Chart(ctx, {
|
288
|
+
|
289
|
+
//グラフの種類
|
290
|
+
|
291
|
+
type: 'line',
|
292
|
+
|
293
|
+
//データの設定
|
294
|
+
|
295
|
+
data: {
|
296
|
+
|
297
|
+
//データ項目のラベル
|
298
|
+
|
299
|
+
labels: ["Before 3 years","Before 2 years","Before 1 year","Start", "After 1 year", "After 2 years", "After 3 years"],
|
300
|
+
|
301
|
+
//データセット
|
302
|
+
|
303
|
+
datasets: [{
|
304
|
+
|
305
|
+
// Start以前
|
306
|
+
|
307
|
+
label: "転換率",
|
308
|
+
|
309
|
+
borderWidth: 3,
|
310
|
+
|
311
|
+
backgroundColor: "rgba(75,192,192,0.4)",
|
312
|
+
|
313
|
+
borderColor: "rgba(75,192,192,0.6)",
|
314
|
+
|
315
|
+
pointBorderColor: "#fff",
|
316
|
+
|
317
|
+
pointBackgroundColor: "rgba(75,192,192,0.6)",
|
318
|
+
|
319
|
+
pointRadius: 8,
|
320
|
+
|
321
|
+
pointBorderWidth: 5,
|
322
|
+
|
323
|
+
pointHoverRadius: 10,
|
324
|
+
|
325
|
+
pointHitRadius: 5,
|
326
|
+
|
327
|
+
pointStyle: "circle",
|
328
|
+
|
329
|
+
pointHoverBackgroundColor: "rgba(75,192,192,0.6)",
|
330
|
+
|
331
|
+
pointHoverBorderColor: "#fff",
|
332
|
+
|
333
|
+
pointHitRadius: 5,
|
334
|
+
|
335
|
+
//グラフのデータ
|
336
|
+
|
337
|
+
data: [1.06,1.37,1.23,1.49]
|
338
|
+
|
339
|
+
},
|
340
|
+
|
341
|
+
{ // Start以前
|
342
|
+
|
343
|
+
label: "転換率",
|
344
|
+
|
345
|
+
borderWidth: 3,
|
346
|
+
|
347
|
+
backgroundColor: "rgba(75,192,192,0.8)",
|
348
|
+
|
349
|
+
borderColor: "rgba(75,192,192,1)",
|
350
|
+
|
351
|
+
pointBorderColor: "#fff",
|
352
|
+
|
353
|
+
pointBackgroundColor: "rgba(75,192,192,0.8)",
|
354
|
+
|
355
|
+
pointRadius: 8,
|
356
|
+
|
357
|
+
pointBorderWidth: 5,
|
358
|
+
|
359
|
+
pointHoverRadius: 10,
|
360
|
+
|
361
|
+
pointHitRadius: 5,
|
362
|
+
|
363
|
+
pointStyle: "circle",
|
364
|
+
|
365
|
+
pointHoverBackgroundColor: "rgba(75,192,192,1)",
|
366
|
+
|
367
|
+
pointHoverBorderColor: "#fff",
|
368
|
+
|
369
|
+
pointHitRadius: 5,
|
370
|
+
|
371
|
+
//グラフのデータ
|
372
|
+
|
373
|
+
data: [,,, 1.49, 2.09, 3.27, 3.31]
|
374
|
+
|
375
|
+
}
|
376
|
+
|
83
377
|
|
84
378
|
|
379
|
+
]
|
380
|
+
|
381
|
+
},
|
382
|
+
|
85
|
-
|
383
|
+
//オプションの設定
|
384
|
+
|
86
|
-
|
385
|
+
options: {
|
386
|
+
|
387
|
+
showAllTooltips: true,
|
388
|
+
|
389
|
+
animation: {
|
390
|
+
|
391
|
+
duration: 8000
|
392
|
+
|
393
|
+
},
|
394
|
+
|
395
|
+
legend: {
|
396
|
+
|
397
|
+
display: false
|
398
|
+
|
399
|
+
},
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
tooltips: {
|
404
|
+
|
405
|
+
callbacks: {
|
406
|
+
|
407
|
+
label: function (tooltipItem, data) {
|
408
|
+
|
409
|
+
return data.labels[tooltipItem.index]
|
410
|
+
|
411
|
+
+ ": "
|
412
|
+
|
413
|
+
+ data.datasets[0].data[tooltipItem.index]
|
414
|
+
|
415
|
+
+ " %"; //ここで単位を付けます
|
416
|
+
|
417
|
+
}
|
418
|
+
|
419
|
+
}
|
420
|
+
|
421
|
+
},
|
422
|
+
|
87
|
-
scales: {
|
423
|
+
scales: {
|
88
424
|
|
89
425
|
//縦軸の設定
|
90
426
|
|
@@ -114,27 +450,15 @@
|
|
114
450
|
|
115
451
|
}
|
116
452
|
|
117
|
-
}]
|
453
|
+
}],
|
118
|
-
|
119
|
-
|
454
|
+
|
120
|
-
|
121
|
-
tooltips: {
|
122
|
-
|
123
|
-
c
|
455
|
+
ticks: {
|
124
|
-
|
456
|
+
|
125
|
-
|
457
|
+
//最小値を0にする
|
126
|
-
|
127
|
-
|
458
|
+
|
128
|
-
|
129
|
-
|
459
|
+
beginAtZero: true
|
130
|
-
|
131
|
-
|
460
|
+
|
132
|
-
|
133
|
-
+ " 倍";
|
134
|
-
|
135
|
-
}
|
461
|
+
}
|
136
|
-
|
137
|
-
}
|
138
462
|
|
139
463
|
}
|
140
464
|
|
@@ -142,546 +466,8 @@
|
|
142
466
|
|
143
467
|
});
|
144
468
|
|
145
|
-
|
146
|
-
|
147
469
|
</script>
|
148
470
|
|
149
|
-
|
150
|
-
|
151
|
-
<script>
|
152
|
-
|
153
|
-
var ctx = document.getElementById("myChart");
|
154
|
-
|
155
|
-
var myChart= new Chart(ctx, {
|
156
|
-
|
157
|
-
type: type,
|
158
|
-
|
159
|
-
data: data,
|
160
|
-
|
161
|
-
options: options
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
});
|
168
|
-
|
169
|
-
</script>
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
</div>
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
<canvas id="myLineChart" width="800" height="400"></canvas>
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
<script>
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
//折れ線グラフ
|
188
|
-
|
189
|
-
var ctx = document.getElementById("myLineChart");
|
190
|
-
|
191
|
-
var myLineChart = new Chart(ctx, {
|
192
|
-
|
193
|
-
//グラフの種類
|
194
|
-
|
195
|
-
type: 'line',
|
196
|
-
|
197
|
-
//データの設定
|
198
|
-
|
199
|
-
data: {
|
200
|
-
|
201
|
-
//データ項目のラベル
|
202
|
-
|
203
|
-
labels: ["Before 3 years","Before 2 years","Before 1 year","Start", "After 1 year", "After 2 years", "After 3 years"],
|
204
|
-
|
205
|
-
//データセット
|
206
|
-
|
207
|
-
datasets: [{
|
208
|
-
|
209
|
-
label: "転換率",
|
210
|
-
|
211
|
-
borderWidth: 3,
|
212
|
-
|
213
|
-
backgroundColor: "rgba(75,192,192,0.4)",
|
214
|
-
|
215
|
-
borderColor: ["rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)", "rgba(75,192,192,1)", "rgba(75,192,192,1)", "rgba(75,192,192,1)"],
|
216
|
-
|
217
|
-
pointBorderColor: "#fff",
|
218
|
-
|
219
|
-
pointBackgroundColor: ["rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)", "rgba(75,192,192,1)", "rgba(75,192,192,1)", "rgba(75,192,192,1)"],
|
220
|
-
|
221
|
-
pointRadius: 8,
|
222
|
-
|
223
|
-
pointBorderWidth: 5,
|
224
|
-
|
225
|
-
pointHoverRadius: 10,
|
226
|
-
|
227
|
-
pointHitRadius: 5,
|
228
|
-
|
229
|
-
pointStyle: "circle",
|
230
|
-
|
231
|
-
pointHoverBackgroundColor: ["rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)", "rgba(75,192,192,1)", "rgba(75,192,192,1)", "rgba(75,192,192,1)"],
|
232
|
-
|
233
|
-
pointHoverBorderColor: "#fff",
|
234
|
-
|
235
|
-
pointHitRadius: 5,
|
236
|
-
|
237
|
-
//グラフのデータ
|
238
|
-
|
239
|
-
data: [1.06,1.37,1.23,1.49, 2.09, 3.27, 3.31]
|
240
|
-
|
241
|
-
}]
|
242
|
-
|
243
|
-
},
|
244
|
-
|
245
|
-
//オプションの設定
|
246
|
-
|
247
|
-
options: {
|
248
|
-
|
249
|
-
animation: {
|
250
|
-
|
251
|
-
duration: 8000
|
252
|
-
|
253
|
-
},
|
254
|
-
|
255
|
-
tooltips: {
|
256
|
-
|
257
|
-
callbacks: {
|
258
|
-
|
259
|
-
label: function (tooltipItem, data) {
|
260
|
-
|
261
|
-
return data.labels[tooltipItem.index]
|
262
|
-
|
263
|
-
+ ": "
|
264
|
-
|
265
|
-
+ data.datasets[0].data[tooltipItem.index]
|
266
|
-
|
267
|
-
+ " %"; //ここで単位を付けます
|
268
|
-
|
269
|
-
}
|
270
|
-
|
271
|
-
}
|
272
|
-
|
273
|
-
},
|
274
|
-
|
275
|
-
scales: {
|
276
|
-
|
277
|
-
//縦軸の設定
|
278
|
-
|
279
|
-
yAxes: [{
|
280
|
-
|
281
|
-
display: true,
|
282
|
-
|
283
|
-
stacked: false,
|
284
|
-
|
285
|
-
gridLines: {
|
286
|
-
|
287
|
-
display: false
|
288
|
-
|
289
|
-
}
|
290
|
-
|
291
|
-
}],
|
292
|
-
|
293
|
-
xAxes: [{
|
294
|
-
|
295
|
-
display: true,
|
296
|
-
|
297
|
-
stacked: false,
|
298
|
-
|
299
|
-
gridLines: {
|
300
|
-
|
301
|
-
display: false
|
302
|
-
|
303
|
-
}
|
304
|
-
|
305
|
-
}],
|
306
|
-
|
307
|
-
ticks: {
|
308
|
-
|
309
|
-
//最小値を0にする
|
310
|
-
|
311
|
-
beginAtZero: true
|
312
|
-
|
313
|
-
}
|
314
|
-
|
315
|
-
}
|
316
|
-
|
317
|
-
}
|
318
|
-
|
319
|
-
});
|
320
|
-
|
321
|
-
</script>
|
322
|
-
|
323
471
|
```
|
324
472
|
|
325
|
-

|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
2017/11/08
|
332
|
-
|
333
|
-
・進捗状況
|
334
|
-
|
335
|
-
ツールチップ常時表示、線グラフの色分け、ラベルの非表示が解決いたしました。
|
336
|
-
|
337
|
-
ただ、線グラフ"After 1 year"以降のツールチップ内のデータが"undefined%"と表示されてしまいます。
|
338
|
-
|
339
|
-
あと、ツールチップ内のラベル名が重複してしまっているので1つに絞りたいと考えています。
|
340
|
-
|
341
|
-
重ねてのお願いで恐縮ですが、ご教示頂けますと幸いです。
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
```ここに言語を入力
|
346
|
-
|
347
|
-
<script>
|
348
|
-
|
349
|
-
//ツールチップ常時表示
|
350
|
-
|
351
|
-
//文字数制限の為割愛
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
//棒グラフ
|
356
|
-
|
357
|
-
var ctx = document.getElementById("myBarChart1");
|
358
|
-
|
359
|
-
var myBarChart = new Chart(ctx, {
|
360
|
-
|
361
|
-
//グラフの種類
|
362
|
-
|
363
|
-
type: 'bar',
|
364
|
-
|
365
|
-
//データの設定
|
366
|
-
|
367
|
-
data: {
|
368
|
-
|
369
|
-
//データ項目のラベル
|
370
|
-
|
371
|
-
labels: ["Before 3 years","Before 2 years","Before 1 year","Start", "After 1 year", "After 2 years", "After 3 years"],
|
372
|
-
|
373
|
-
//データセット
|
374
|
-
|
375
|
-
datasets: [{
|
376
|
-
|
377
|
-
label: "年間売上比率",
|
378
|
-
|
379
|
-
backgroundColor: ["rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)", "rgba(75,192,192,1)", "rgba(75,192,192,1)", "rgba(75,192,192,1)"],
|
380
|
-
|
381
|
-
//グラフのデータ
|
382
|
-
|
383
|
-
data: [0.7,0.8,0.7,1, 2.1, 8.1, 10.1]
|
384
|
-
|
385
|
-
}
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
]
|
390
|
-
|
391
|
-
},
|
392
|
-
|
393
|
-
//オプションの設定
|
394
|
-
|
395
|
-
options: {
|
396
|
-
|
397
|
-
showAllTooltips: true,
|
398
|
-
|
399
|
-
animation: {
|
400
|
-
|
401
|
-
duration: 8000,
|
402
|
-
|
403
|
-
},
|
404
|
-
|
405
|
-
legend: {
|
406
|
-
|
407
|
-
display: false,
|
408
|
-
|
409
|
-
},
|
410
|
-
|
411
|
-
//軸の設定
|
412
|
-
|
413
|
-
scales: {
|
414
|
-
|
415
|
-
//縦軸の設定
|
416
|
-
|
417
|
-
yAxes: [{
|
418
|
-
|
419
|
-
display: true,
|
420
|
-
|
421
|
-
stacked: false,
|
422
|
-
|
423
|
-
gridLines: {
|
424
|
-
|
425
|
-
display: false
|
426
|
-
|
427
|
-
}
|
428
|
-
|
429
|
-
}],
|
430
|
-
|
431
|
-
xAxes: [{
|
432
|
-
|
433
|
-
display: true,
|
434
|
-
|
435
|
-
stacked: false,
|
436
|
-
|
437
|
-
gridLines: {
|
438
|
-
|
439
|
-
display: false
|
440
|
-
|
441
|
-
}
|
442
|
-
|
443
|
-
}]
|
444
|
-
|
445
|
-
},
|
446
|
-
|
447
|
-
tooltips: {
|
448
|
-
|
449
|
-
callbacks: {
|
450
|
-
|
451
|
-
label: function (tooltipItem, data) {
|
452
|
-
|
453
|
-
return data.labels[tooltipItem.index]
|
454
|
-
|
455
|
-
+ ": "
|
456
|
-
|
457
|
-
+ data.datasets[0].data[tooltipItem.index]
|
458
|
-
|
459
|
-
+ " 倍";
|
460
|
-
|
461
|
-
}
|
462
|
-
|
463
|
-
}
|
464
|
-
|
465
|
-
}
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
}
|
474
|
-
|
475
|
-
});
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
</script>
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
</div>
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
<canvas id="myLineChart" width="800" height="400"></canvas>
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
<script>
|
496
|
-
|
497
|
-
//折れ線グラフ
|
498
|
-
|
499
|
-
var ctx = document.getElementById("myLineChart");
|
500
|
-
|
501
|
-
var myLineChart = new Chart(ctx, {
|
502
|
-
|
503
|
-
//グラフの種類
|
504
|
-
|
505
|
-
type: 'line',
|
506
|
-
|
507
|
-
//データの設定
|
508
|
-
|
509
|
-
data: {
|
510
|
-
|
511
|
-
//データ項目のラベル
|
512
|
-
|
513
|
-
labels: ["Before 3 years","Before 2 years","Before 1 year","Start", "After 1 year", "After 2 years", "After 3 years"],
|
514
|
-
|
515
|
-
//データセット
|
516
|
-
|
517
|
-
datasets: [{
|
518
|
-
|
519
|
-
// Start以前
|
520
|
-
|
521
|
-
label: "転換率",
|
522
|
-
|
523
|
-
borderWidth: 3,
|
524
|
-
|
525
|
-
backgroundColor: "rgba(75,192,192,0.4)",
|
526
|
-
|
527
|
-
borderColor: "rgba(75,192,192,0.6)",
|
528
|
-
|
529
|
-
pointBorderColor: "#fff",
|
530
|
-
|
531
|
-
pointBackgroundColor: "rgba(75,192,192,0.6)",
|
532
|
-
|
533
|
-
pointRadius: 8,
|
534
|
-
|
535
|
-
pointBorderWidth: 5,
|
536
|
-
|
537
|
-
pointHoverRadius: 10,
|
538
|
-
|
539
|
-
pointHitRadius: 5,
|
540
|
-
|
541
|
-
pointStyle: "circle",
|
542
|
-
|
543
|
-
pointHoverBackgroundColor: "rgba(75,192,192,0.6)",
|
544
|
-
|
545
|
-
pointHoverBorderColor: "#fff",
|
546
|
-
|
547
|
-
pointHitRadius: 5,
|
548
|
-
|
549
|
-
//グラフのデータ
|
550
|
-
|
551
|
-
data: [1.06,1.37,1.23,1.49]
|
552
|
-
|
553
|
-
},
|
554
|
-
|
555
|
-
{ // Start以前
|
556
|
-
|
557
|
-
label: "転換率",
|
558
|
-
|
559
|
-
borderWidth: 3,
|
560
|
-
|
561
|
-
backgroundColor: "rgba(75,192,192,0.8)",
|
562
|
-
|
563
|
-
borderColor: "rgba(75,192,192,1)",
|
564
|
-
|
565
|
-
pointBorderColor: "#fff",
|
566
|
-
|
567
|
-
pointBackgroundColor: "rgba(75,192,192,0.8)",
|
568
|
-
|
569
|
-
pointRadius: 8,
|
570
|
-
|
571
|
-
pointBorderWidth: 5,
|
572
|
-
|
573
|
-
pointHoverRadius: 10,
|
574
|
-
|
575
|
-
pointHitRadius: 5,
|
576
|
-
|
577
|
-
pointStyle: "circle",
|
578
|
-
|
579
|
-
pointHoverBackgroundColor: "rgba(75,192,192,1)",
|
580
|
-
|
581
|
-
pointHoverBorderColor: "#fff",
|
582
|
-
|
583
|
-
pointHitRadius: 5,
|
584
|
-
|
585
|
-
//グラフのデータ
|
586
|
-
|
587
|
-
data: [,,, 1.49, 2.09, 3.27, 3.31]
|
588
|
-
|
589
|
-
}
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
]
|
594
|
-
|
595
|
-
},
|
596
|
-
|
597
|
-
//オプションの設定
|
598
|
-
|
599
|
-
options: {
|
600
|
-
|
601
|
-
showAllTooltips: true,
|
602
|
-
|
603
|
-
animation: {
|
604
|
-
|
605
|
-
duration: 8000
|
606
|
-
|
607
|
-
},
|
608
|
-
|
609
|
-
legend: {
|
610
|
-
|
611
|
-
display: false
|
612
|
-
|
613
|
-
},
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
tooltips: {
|
618
|
-
|
619
|
-
callbacks: {
|
620
|
-
|
621
|
-
label: function (tooltipItem, data) {
|
622
|
-
|
623
|
-
return data.labels[tooltipItem.index]
|
624
|
-
|
625
|
-
+ ": "
|
626
|
-
|
627
|
-
+ data.datasets[0].data[tooltipItem.index]
|
628
|
-
|
629
|
-
+ " %"; //ここで単位を付けます
|
630
|
-
|
631
|
-
}
|
632
|
-
|
633
|
-
}
|
634
|
-
|
635
|
-
},
|
636
|
-
|
637
|
-
scales: {
|
638
|
-
|
639
|
-
//縦軸の設定
|
640
|
-
|
641
|
-
yAxes: [{
|
642
|
-
|
643
|
-
display: true,
|
644
|
-
|
645
|
-
stacked: false,
|
646
|
-
|
647
|
-
gridLines: {
|
648
|
-
|
649
|
-
display: false
|
650
|
-
|
651
|
-
}
|
652
|
-
|
653
|
-
}],
|
654
|
-
|
655
|
-
xAxes: [{
|
656
|
-
|
657
|
-
display: true,
|
658
|
-
|
659
|
-
stacked: false,
|
660
|
-
|
661
|
-
gridLines: {
|
662
|
-
|
663
|
-
display: false
|
664
|
-
|
665
|
-
}
|
666
|
-
|
667
|
-
}],
|
668
|
-
|
669
|
-
ticks: {
|
670
|
-
|
671
|
-
//最小値を0にする
|
672
|
-
|
673
|
-
beginAtZero: true
|
674
|
-
|
675
|
-
}
|
676
|
-
|
677
|
-
}
|
678
|
-
|
679
|
-
}
|
680
|
-
|
681
|
-
});
|
682
|
-
|
683
|
-
</script>
|
684
|
-
|
685
|
-
```
|
686
|
-
|
687
473
|

|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -634,8 +634,6 @@
|
|
634
634
|
|
635
635
|
},
|
636
636
|
|
637
|
-
showAllTooltips: true,
|
638
|
-
|
639
637
|
scales: {
|
640
638
|
|
641
639
|
//縦軸の設定
|
3
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -323,3 +323,367 @@
|
|
323
323
|
```
|
324
324
|
|
325
325
|

|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
2017/11/08
|
332
|
+
|
333
|
+
・進捗状況
|
334
|
+
|
335
|
+
ツールチップ常時表示、線グラフの色分け、ラベルの非表示が解決いたしました。
|
336
|
+
|
337
|
+
ただ、線グラフ"After 1 year"以降のツールチップ内のデータが"undefined%"と表示されてしまいます。
|
338
|
+
|
339
|
+
あと、ツールチップ内のラベル名が重複してしまっているので1つに絞りたいと考えています。
|
340
|
+
|
341
|
+
重ねてのお願いで恐縮ですが、ご教示頂けますと幸いです。
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
```ここに言語を入力
|
346
|
+
|
347
|
+
<script>
|
348
|
+
|
349
|
+
//ツールチップ常時表示
|
350
|
+
|
351
|
+
//文字数制限の為割愛
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
//棒グラフ
|
356
|
+
|
357
|
+
var ctx = document.getElementById("myBarChart1");
|
358
|
+
|
359
|
+
var myBarChart = new Chart(ctx, {
|
360
|
+
|
361
|
+
//グラフの種類
|
362
|
+
|
363
|
+
type: 'bar',
|
364
|
+
|
365
|
+
//データの設定
|
366
|
+
|
367
|
+
data: {
|
368
|
+
|
369
|
+
//データ項目のラベル
|
370
|
+
|
371
|
+
labels: ["Before 3 years","Before 2 years","Before 1 year","Start", "After 1 year", "After 2 years", "After 3 years"],
|
372
|
+
|
373
|
+
//データセット
|
374
|
+
|
375
|
+
datasets: [{
|
376
|
+
|
377
|
+
label: "年間売上比率",
|
378
|
+
|
379
|
+
backgroundColor: ["rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)","rgba(75,192,192,0.6)", "rgba(75,192,192,1)", "rgba(75,192,192,1)", "rgba(75,192,192,1)"],
|
380
|
+
|
381
|
+
//グラフのデータ
|
382
|
+
|
383
|
+
data: [0.7,0.8,0.7,1, 2.1, 8.1, 10.1]
|
384
|
+
|
385
|
+
}
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
]
|
390
|
+
|
391
|
+
},
|
392
|
+
|
393
|
+
//オプションの設定
|
394
|
+
|
395
|
+
options: {
|
396
|
+
|
397
|
+
showAllTooltips: true,
|
398
|
+
|
399
|
+
animation: {
|
400
|
+
|
401
|
+
duration: 8000,
|
402
|
+
|
403
|
+
},
|
404
|
+
|
405
|
+
legend: {
|
406
|
+
|
407
|
+
display: false,
|
408
|
+
|
409
|
+
},
|
410
|
+
|
411
|
+
//軸の設定
|
412
|
+
|
413
|
+
scales: {
|
414
|
+
|
415
|
+
//縦軸の設定
|
416
|
+
|
417
|
+
yAxes: [{
|
418
|
+
|
419
|
+
display: true,
|
420
|
+
|
421
|
+
stacked: false,
|
422
|
+
|
423
|
+
gridLines: {
|
424
|
+
|
425
|
+
display: false
|
426
|
+
|
427
|
+
}
|
428
|
+
|
429
|
+
}],
|
430
|
+
|
431
|
+
xAxes: [{
|
432
|
+
|
433
|
+
display: true,
|
434
|
+
|
435
|
+
stacked: false,
|
436
|
+
|
437
|
+
gridLines: {
|
438
|
+
|
439
|
+
display: false
|
440
|
+
|
441
|
+
}
|
442
|
+
|
443
|
+
}]
|
444
|
+
|
445
|
+
},
|
446
|
+
|
447
|
+
tooltips: {
|
448
|
+
|
449
|
+
callbacks: {
|
450
|
+
|
451
|
+
label: function (tooltipItem, data) {
|
452
|
+
|
453
|
+
return data.labels[tooltipItem.index]
|
454
|
+
|
455
|
+
+ ": "
|
456
|
+
|
457
|
+
+ data.datasets[0].data[tooltipItem.index]
|
458
|
+
|
459
|
+
+ " 倍";
|
460
|
+
|
461
|
+
}
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
}
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
}
|
474
|
+
|
475
|
+
});
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
</script>
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
</div>
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
<canvas id="myLineChart" width="800" height="400"></canvas>
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
<script>
|
496
|
+
|
497
|
+
//折れ線グラフ
|
498
|
+
|
499
|
+
var ctx = document.getElementById("myLineChart");
|
500
|
+
|
501
|
+
var myLineChart = new Chart(ctx, {
|
502
|
+
|
503
|
+
//グラフの種類
|
504
|
+
|
505
|
+
type: 'line',
|
506
|
+
|
507
|
+
//データの設定
|
508
|
+
|
509
|
+
data: {
|
510
|
+
|
511
|
+
//データ項目のラベル
|
512
|
+
|
513
|
+
labels: ["Before 3 years","Before 2 years","Before 1 year","Start", "After 1 year", "After 2 years", "After 3 years"],
|
514
|
+
|
515
|
+
//データセット
|
516
|
+
|
517
|
+
datasets: [{
|
518
|
+
|
519
|
+
// Start以前
|
520
|
+
|
521
|
+
label: "転換率",
|
522
|
+
|
523
|
+
borderWidth: 3,
|
524
|
+
|
525
|
+
backgroundColor: "rgba(75,192,192,0.4)",
|
526
|
+
|
527
|
+
borderColor: "rgba(75,192,192,0.6)",
|
528
|
+
|
529
|
+
pointBorderColor: "#fff",
|
530
|
+
|
531
|
+
pointBackgroundColor: "rgba(75,192,192,0.6)",
|
532
|
+
|
533
|
+
pointRadius: 8,
|
534
|
+
|
535
|
+
pointBorderWidth: 5,
|
536
|
+
|
537
|
+
pointHoverRadius: 10,
|
538
|
+
|
539
|
+
pointHitRadius: 5,
|
540
|
+
|
541
|
+
pointStyle: "circle",
|
542
|
+
|
543
|
+
pointHoverBackgroundColor: "rgba(75,192,192,0.6)",
|
544
|
+
|
545
|
+
pointHoverBorderColor: "#fff",
|
546
|
+
|
547
|
+
pointHitRadius: 5,
|
548
|
+
|
549
|
+
//グラフのデータ
|
550
|
+
|
551
|
+
data: [1.06,1.37,1.23,1.49]
|
552
|
+
|
553
|
+
},
|
554
|
+
|
555
|
+
{ // Start以前
|
556
|
+
|
557
|
+
label: "転換率",
|
558
|
+
|
559
|
+
borderWidth: 3,
|
560
|
+
|
561
|
+
backgroundColor: "rgba(75,192,192,0.8)",
|
562
|
+
|
563
|
+
borderColor: "rgba(75,192,192,1)",
|
564
|
+
|
565
|
+
pointBorderColor: "#fff",
|
566
|
+
|
567
|
+
pointBackgroundColor: "rgba(75,192,192,0.8)",
|
568
|
+
|
569
|
+
pointRadius: 8,
|
570
|
+
|
571
|
+
pointBorderWidth: 5,
|
572
|
+
|
573
|
+
pointHoverRadius: 10,
|
574
|
+
|
575
|
+
pointHitRadius: 5,
|
576
|
+
|
577
|
+
pointStyle: "circle",
|
578
|
+
|
579
|
+
pointHoverBackgroundColor: "rgba(75,192,192,1)",
|
580
|
+
|
581
|
+
pointHoverBorderColor: "#fff",
|
582
|
+
|
583
|
+
pointHitRadius: 5,
|
584
|
+
|
585
|
+
//グラフのデータ
|
586
|
+
|
587
|
+
data: [,,, 1.49, 2.09, 3.27, 3.31]
|
588
|
+
|
589
|
+
}
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
]
|
594
|
+
|
595
|
+
},
|
596
|
+
|
597
|
+
//オプションの設定
|
598
|
+
|
599
|
+
options: {
|
600
|
+
|
601
|
+
showAllTooltips: true,
|
602
|
+
|
603
|
+
animation: {
|
604
|
+
|
605
|
+
duration: 8000
|
606
|
+
|
607
|
+
},
|
608
|
+
|
609
|
+
legend: {
|
610
|
+
|
611
|
+
display: false
|
612
|
+
|
613
|
+
},
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
tooltips: {
|
618
|
+
|
619
|
+
callbacks: {
|
620
|
+
|
621
|
+
label: function (tooltipItem, data) {
|
622
|
+
|
623
|
+
return data.labels[tooltipItem.index]
|
624
|
+
|
625
|
+
+ ": "
|
626
|
+
|
627
|
+
+ data.datasets[0].data[tooltipItem.index]
|
628
|
+
|
629
|
+
+ " %"; //ここで単位を付けます
|
630
|
+
|
631
|
+
}
|
632
|
+
|
633
|
+
}
|
634
|
+
|
635
|
+
},
|
636
|
+
|
637
|
+
showAllTooltips: true,
|
638
|
+
|
639
|
+
scales: {
|
640
|
+
|
641
|
+
//縦軸の設定
|
642
|
+
|
643
|
+
yAxes: [{
|
644
|
+
|
645
|
+
display: true,
|
646
|
+
|
647
|
+
stacked: false,
|
648
|
+
|
649
|
+
gridLines: {
|
650
|
+
|
651
|
+
display: false
|
652
|
+
|
653
|
+
}
|
654
|
+
|
655
|
+
}],
|
656
|
+
|
657
|
+
xAxes: [{
|
658
|
+
|
659
|
+
display: true,
|
660
|
+
|
661
|
+
stacked: false,
|
662
|
+
|
663
|
+
gridLines: {
|
664
|
+
|
665
|
+
display: false
|
666
|
+
|
667
|
+
}
|
668
|
+
|
669
|
+
}],
|
670
|
+
|
671
|
+
ticks: {
|
672
|
+
|
673
|
+
//最小値を0にする
|
674
|
+
|
675
|
+
beginAtZero: true
|
676
|
+
|
677
|
+
}
|
678
|
+
|
679
|
+
}
|
680
|
+
|
681
|
+
}
|
682
|
+
|
683
|
+
});
|
684
|
+
|
685
|
+
</script>
|
686
|
+
|
687
|
+
```
|
688
|
+
|
689
|
+

|
2
追加点
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,6 +20,8 @@
|
|
20
20
|
|
21
21
|
両グラフともツールチップを常時表示したままにしたい。
|
22
22
|
|
23
|
+
(可能であればアニメーション終了時に表示開始したい)
|
24
|
+
|
23
25
|
|
24
26
|
|
25
27
|
解決策をご存知の方がいらっしゃいましたら何卒ご教授お願い致します。
|
1
追加点
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,6 +18,10 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
+
両グラフともツールチップを常時表示したままにしたい。
|
22
|
+
|
23
|
+
|
24
|
+
|
21
25
|
解決策をご存知の方がいらっしゃいましたら何卒ご教授お願い致します。
|
22
26
|
|
23
27
|
|