質問編集履歴
2
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,263 +48,363 @@
|
|
48
48
|
|
49
49
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
<
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
|
52
|
+
|
53
|
+
</head>
|
54
|
+
|
55
|
+
<body>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
<!-- グラフの描画エリア -->
|
60
|
+
|
61
|
+
<div id="chart_div" style="width: 100%; height: 350px"></div>
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<select id="example" name="example" style="margin-bottom: 20px;">
|
66
|
+
|
67
|
+
<option value="0">粒度 - 小</option>
|
68
|
+
|
69
|
+
<option value="1">粒度 - 中</option>
|
70
|
+
|
71
|
+
<option value="2">粒度 - 大</option>
|
72
|
+
|
73
|
+
</select>
|
74
|
+
|
75
|
+
<input type="hidden" class="single-slider" value="4.9" style="margin-top: 0px;" />
|
76
|
+
|
77
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
|
78
|
+
|
79
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
|
80
|
+
|
81
|
+
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
82
|
+
|
83
|
+
<script src="jRange/jquery.range.js"></script>
|
84
|
+
|
85
|
+
<link rel="stylesheet" href="jRange/jquery.range.css">
|
86
|
+
|
87
|
+
<script type="text/javascript">
|
88
|
+
|
89
|
+
// ライブラリのロード
|
90
|
+
|
91
|
+
// name:visualization(可視化),version:バージョン(1),packages:パッケージ(corechart)
|
92
|
+
|
93
|
+
google.load('visualization', '1', {'packages':['corechart']});
|
94
|
+
|
95
|
+
var data;
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
$('.single-slider').jRange({
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
from: 0,
|
104
|
+
|
105
|
+
to: 4.9,
|
106
|
+
|
107
|
+
step: 0.1,
|
108
|
+
|
109
|
+
scale: [0, 1, 2, 3, 4, 4.9],
|
110
|
+
|
111
|
+
format: '%s',
|
112
|
+
|
113
|
+
width: 300,
|
114
|
+
|
115
|
+
showLabels: true,
|
116
|
+
|
117
|
+
isRange: true,
|
118
|
+
|
119
|
+
onstatechange: function () {
|
120
|
+
|
121
|
+
$(".single-slider").trigger('change');
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
});
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
document.addEventListener('DOMContentLoaded', function () {
|
130
|
+
|
131
|
+
var dataset0=[
|
132
|
+
|
133
|
+
['Labels','data'],
|
134
|
+
|
135
|
+
[0.1,110],
|
136
|
+
|
137
|
+
[0.2,90],
|
138
|
+
|
139
|
+
[0.3,120],
|
140
|
+
|
141
|
+
[0.4,80],
|
142
|
+
|
143
|
+
[0.5,160],
|
144
|
+
|
145
|
+
[0.6,120],
|
146
|
+
|
147
|
+
[0.7,140],
|
148
|
+
|
149
|
+
[0.8,120],
|
150
|
+
|
151
|
+
[0.9,100],
|
152
|
+
|
153
|
+
[1 ,100],
|
154
|
+
|
155
|
+
[1.1,110],
|
156
|
+
|
157
|
+
[1.2,130],
|
158
|
+
|
159
|
+
[1.3,110],
|
160
|
+
|
161
|
+
[1.4,100],
|
162
|
+
|
163
|
+
[1.5,180],
|
164
|
+
|
165
|
+
[1.6,120],
|
166
|
+
|
167
|
+
[1.7,140],
|
168
|
+
|
169
|
+
[1.8,120],
|
170
|
+
|
171
|
+
[1.9,140],
|
172
|
+
|
173
|
+
[2 ,90],
|
174
|
+
|
175
|
+
[2.1,70],
|
176
|
+
|
177
|
+
[2.2,60],
|
178
|
+
|
179
|
+
[2.3,100],
|
180
|
+
|
181
|
+
[2.4,80],
|
182
|
+
|
183
|
+
[2.5,90],
|
184
|
+
|
185
|
+
[2.6,70],
|
186
|
+
|
187
|
+
[2.7,60],
|
188
|
+
|
189
|
+
[2.8,150],
|
190
|
+
|
191
|
+
[2.9,80],
|
192
|
+
|
193
|
+
[3 ,90],
|
194
|
+
|
195
|
+
[3.1,70],
|
196
|
+
|
197
|
+
[3.2,60],
|
198
|
+
|
199
|
+
[3.3,100],
|
200
|
+
|
201
|
+
[3.4,80],
|
202
|
+
|
203
|
+
[3.5,40],
|
204
|
+
|
205
|
+
[3.6,40],
|
206
|
+
|
207
|
+
[3.7,40],
|
208
|
+
|
209
|
+
[3.8,20],
|
210
|
+
|
211
|
+
[3.9,60],
|
212
|
+
|
213
|
+
[4 ,100],
|
214
|
+
|
215
|
+
[4.1,120],
|
216
|
+
|
217
|
+
[4.2,140],
|
218
|
+
|
219
|
+
[4.3,120],
|
220
|
+
|
221
|
+
[4.4,80],
|
222
|
+
|
223
|
+
[4.5,100],
|
224
|
+
|
225
|
+
[4.6,110],
|
226
|
+
|
227
|
+
[4.7,100],
|
228
|
+
|
229
|
+
[4.8,90],
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
];
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
var dataset1= [
|
238
|
+
|
239
|
+
['Labels','data'],
|
240
|
+
|
241
|
+
["0〜0.5",500],
|
242
|
+
|
243
|
+
["0.6〜1",600],
|
244
|
+
|
245
|
+
["1.1〜1.5",550],
|
246
|
+
|
247
|
+
["1.6〜2",700],
|
248
|
+
|
249
|
+
["2.1〜2.5",400],
|
250
|
+
|
251
|
+
["2.6〜3",450],
|
252
|
+
|
253
|
+
["3.1〜3.5",400],
|
254
|
+
|
255
|
+
["3.6〜4",200],
|
256
|
+
|
257
|
+
["4.1〜4.5",400],
|
258
|
+
|
259
|
+
["4.6〜5",550],
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
];
|
266
|
+
|
267
|
+
var dataset2= [
|
268
|
+
|
269
|
+
['Labels','data'],
|
270
|
+
|
271
|
+
["0〜0.9",1100],
|
272
|
+
|
273
|
+
["1〜1.9",1250],
|
274
|
+
|
275
|
+
["2〜2.9",850],
|
276
|
+
|
277
|
+
["3〜3.9",600],
|
278
|
+
|
279
|
+
["4〜4.9",950],
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
];
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
// グラフを描画する為のコールバック関数を指定
|
294
|
+
|
295
|
+
google.setOnLoadCallback(drawChart);
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
// グラフの描画
|
302
|
+
|
303
|
+
function drawChart() {
|
304
|
+
|
305
|
+
const dataSet = google.visualization.arrayToDataTable(data);
|
306
|
+
|
307
|
+
// オプションの設定
|
308
|
+
|
309
|
+
var options = {
|
310
|
+
|
311
|
+
'title':'マグロ (BML) [LC]',
|
312
|
+
|
313
|
+
'is3D':true,
|
314
|
+
|
315
|
+
'chartArea': {'height': '80%', 'width': '90%'},
|
316
|
+
|
317
|
+
'hAxis': { title: '測定値(LC)', 'slantedText': false},
|
318
|
+
|
319
|
+
'vAxis': { title: '人数' },
|
320
|
+
|
321
|
+
'legend':'left',
|
322
|
+
|
323
|
+
};
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
// 指定されたIDの要素に棒グラフを作成
|
332
|
+
|
333
|
+
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
// グラフの描画
|
340
|
+
|
341
|
+
chart.draw(dataSet, options);
|
342
|
+
|
343
|
+
}
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
// select要素を取得
|
350
|
+
|
351
|
+
const selectElm = document.getElementById('#example');
|
352
|
+
|
353
|
+
// 外側でも使うために、処理を別枠で定義
|
354
|
+
|
355
|
+
const changeFunc = function(){
|
356
|
+
|
357
|
+
// 選択しているoptionの値を使いたい場合は、this.value
|
358
|
+
|
359
|
+
switch (Number(this.value)) {
|
360
|
+
|
361
|
+
case 0:
|
362
|
+
|
363
|
+
data = dataset0;
|
364
|
+
|
365
|
+
c
|
366
|
+
|
367
|
+
case 1:
|
368
|
+
|
369
|
+
data = dataset1;
|
60
370
|
|
61
371
|
|
62
372
|
|
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
|
-
[1.4,100],
|
94
|
-
|
95
|
-
[1.5,180],
|
96
|
-
|
97
|
-
[1.6,120],
|
98
|
-
|
99
|
-
[1.7,140],
|
100
|
-
|
101
|
-
[1.8,120],
|
102
|
-
|
103
|
-
[1.9,140],
|
104
|
-
|
105
|
-
[2 ,90],
|
106
|
-
|
107
|
-
[2.1,70],
|
108
|
-
|
109
|
-
[2.2,60],
|
110
|
-
|
111
|
-
[2.3,100],
|
112
|
-
|
113
|
-
[2.4,80],
|
114
|
-
|
115
|
-
[2.5,90],
|
116
|
-
|
117
|
-
[2.6,70],
|
118
|
-
|
119
|
-
[2.7,60],
|
120
|
-
|
121
|
-
[2.8,150],
|
122
|
-
|
123
|
-
[2.9,80],
|
124
|
-
|
125
|
-
[3 ,90],
|
126
|
-
|
127
|
-
[3.1,70],
|
128
|
-
|
129
|
-
[3.2,60],
|
130
|
-
|
131
|
-
[3.3,100],
|
132
|
-
|
133
|
-
[3.4,80],
|
134
|
-
|
135
|
-
[3.5,40],
|
136
|
-
|
137
|
-
[3.6,40],
|
138
|
-
|
139
|
-
[3.7,40],
|
140
|
-
|
141
|
-
[3.8,20],
|
142
|
-
|
143
|
-
[3.9,60],
|
144
|
-
|
145
|
-
[4 ,100],
|
146
|
-
|
147
|
-
[4.1,120],
|
148
|
-
|
149
|
-
[4.2,140],
|
150
|
-
|
151
|
-
[4.3,120],
|
152
|
-
|
153
|
-
[4.4,80],
|
154
|
-
|
155
|
-
[4.5,100],
|
156
|
-
|
157
|
-
[4.6,110],
|
158
|
-
|
159
|
-
[4.7,100],
|
160
|
-
|
161
|
-
[4.8,90],
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
];
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
var dataset1= [
|
170
|
-
|
171
|
-
['Labels','data'],
|
172
|
-
|
173
|
-
["0〜0.5",500],
|
174
|
-
|
175
|
-
["0.6〜1",600],
|
176
|
-
|
177
|
-
["1.1〜1.5",550],
|
178
|
-
|
179
|
-
["1.6〜2",700],
|
180
|
-
|
181
|
-
["2.1〜2.5",400],
|
182
|
-
|
183
|
-
["2.6〜3",450],
|
184
|
-
|
185
|
-
["3.1〜3.5",400],
|
186
|
-
|
187
|
-
["3.6〜4",200],
|
188
|
-
|
189
|
-
["4.1〜4.5",400],
|
190
|
-
|
191
|
-
["4.6〜5",550],
|
373
|
+
case 2:
|
374
|
+
|
375
|
+
data = dataset2;
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
default:
|
380
|
+
|
381
|
+
data = dataset0;
|
382
|
+
|
383
|
+
}
|
384
|
+
|
385
|
+
};
|
386
|
+
|
387
|
+
// 初期値を適用させるために、実行
|
388
|
+
|
389
|
+
changeFunc.call(selectElm);
|
390
|
+
|
391
|
+
// select要素が、変化するたびに実行される
|
392
|
+
|
393
|
+
selectElm.onchange = changeFunc;
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
});
|
400
|
+
|
401
|
+
|
192
402
|
|
193
403
|
|
194
404
|
|
195
|
-
|
196
|
-
|
197
|
-
];
|
198
|
-
|
199
|
-
var dataset2= [
|
200
|
-
|
201
|
-
['Labels','data'],
|
202
|
-
|
203
|
-
["0〜0.9",1100],
|
204
|
-
|
205
|
-
["1〜1.9",1250],
|
206
|
-
|
207
|
-
["2〜2.9",850],
|
208
|
-
|
209
|
-
["3〜3.9",600],
|
210
|
-
|
211
|
-
["4〜4.9",950],
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
];
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
// グラフを描画する為のコールバック関数を指定
|
224
|
-
|
225
|
-
google.setOnLoadCallback(drawChart);
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
// グラフの描画
|
234
|
-
|
235
|
-
function drawChart() {
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
// 配列からデータの生成⇦ここにセットしております
|
240
|
-
|
241
|
-
var data = google.visualization.arrayToDataTable(dataset0);
|
242
|
-
|
243
|
-
// オプションの設定
|
244
|
-
|
245
|
-
var options = {
|
246
|
-
|
247
|
-
'title':'全体',
|
248
|
-
|
249
|
-
'is3D':true,
|
250
|
-
|
251
|
-
'chartArea': {'height': '80%', 'width': '90%'},
|
252
|
-
|
253
|
-
'hAxis': { title: '値', 'slantedText': false},
|
254
|
-
|
255
|
-
'vAxis': { title: '人数' },
|
256
|
-
|
257
|
-
'legend':'left',
|
258
|
-
|
259
|
-
};
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
// 指定されたIDの要素に棒グラフを作成
|
268
|
-
|
269
|
-
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
// グラフの描画
|
274
|
-
|
275
|
-
chart.draw(data, options);
|
276
|
-
|
277
|
-
}
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
405
|
</script>
|
284
406
|
|
285
|
-
|
407
|
+
|
286
|
-
|
287
|
-
<body>
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
<!-- グラフの描画エリア -->
|
292
|
-
|
293
|
-
<div id="chart_div" style="width: 100%; height: 350px"></div>
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
<select id="example" name="example" style="margin-bottom: 20px;">
|
298
|
-
|
299
|
-
<option value="0">0</option>
|
300
|
-
|
301
|
-
<option value="1">1</option>
|
302
|
-
|
303
|
-
<option value="2" selected>2</option>
|
304
|
-
|
305
|
-
</select>
|
306
|
-
|
307
|
-
|
308
408
|
|
309
409
|
</body>
|
310
410
|
|
@@ -312,4 +412,6 @@
|
|
312
412
|
|
313
413
|
|
314
414
|
|
415
|
+
|
416
|
+
|
315
417
|
```
|
1
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,6 +12,28 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
+
▼追記
|
16
|
+
|
17
|
+
#exampleが0を選択されている場合は
|
18
|
+
|
19
|
+
var data = google.visualization.arrayToDataTable(dataset0);
|
20
|
+
|
21
|
+
#exampleが1を選択されている場合は
|
22
|
+
|
23
|
+
var data = google.visualization.arrayToDataTable(dataset1);
|
24
|
+
|
25
|
+
#exampleが2を選択されている場合は
|
26
|
+
|
27
|
+
var data = google.visualization.arrayToDataTable(dataset2);
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
のように
|
32
|
+
|
33
|
+
datasetの部分を変化させたいです。。
|
34
|
+
|
35
|
+
|
36
|
+
|
15
37
|
|
16
38
|
|
17
39
|
### 該当のソースコード
|