-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
708 lines (583 loc) · 28.3 KB
/
Copy pathindex.html
File metadata and controls
708 lines (583 loc) · 28.3 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>ZAMG weather data by meinsiedler</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="assets/stylesheets/normalize.css" media="screen">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="assets/stylesheets/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="assets/stylesheets/github-light.css" media="screen">
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
<script src="assets/js/d3/d3.js"></script>
</head>
<body>
<section class="page-header">
<h1 class="project-name">ZAMG weather data</h1>
<h2 class="project-tagline">A visualization example for showing weather data using D3</h2>
<a href="https://github.com/meinsiedler/zamg-weather-data" class="btn">View on GitHub</a>
<a href="https://github.com/meinsiedler/zamg-weather-data/zipball/master" class="btn">Download .zip</a>
<a href="https://github.com/meinsiedler/zamg-weather-data/tarball/master" class="btn">Download .tar.gz</a>
</section>
<section class="main-content">
<section class="temperature-trend">
<h2>Trends for Linz/Hörsching weather station</h2>
<div class="row">
<select id="trend-type-select">
</select>
<select id="month-select">
<option value="-1">All months</option>
<option value="0">January</option>
<option value="1">February</option>
<option value="2">March</option>
<option value="3">April</option>
<option value="4">May</option>
<option value="5">June</option>
<option value="6">July</option>
<option value="7">August</option>
<option value="8">September</option>
<option value="9">October</option>
<option value="10">November</option>
<option value="11">December</option>
</select>
<button type="button" id="reset-zoom-button" disabled="disabled">Reset Zoom</button>
</div>
<div class="row small">
<p>
<b>Left mouse button: </b>Click, hold and move mouse to span a rectangle to zoom in.<br>
<b>Right mouse button: </b>Click, hold and move mouse to translate the line chart.
</p>
</div>
<div id="trend-content"></div>
<div class="wrapper">
<div id="wind-direction-content">
<div>Average wind speed per direction</div>
</div>
<div id="scatter-plot-content">
<div class="row">
<select id="scatter-x-axis-type">
</select>
<span>(x-Axis) vs.</span>
<select id="scatter-y-axis-type">
</select>
<span>(y-Axis)</span>
</div>
</div>
</div>
<script type="text/javascript">
const trendTypes = [
{
value: "temperature",
text: "Temperature",
unit: "°C",
convert: row => {
row.temperature = convertToNumber(row, r => r.temperature, 0);
return row;
}
},
{
value: "dewPoint",
text: "Dew Point",
unit: "°C",
convert: row => {
row.dewPoint = convertToNumber(row, r => r.dewPoint, 0);
return row;
}
},
{
value: "relativeHumidity",
text: "Relative Humidity",
unit: "%",
convert: row => {
row.relativeHumidity = convertToNumber(row, r => r.relativeHumidity, 0);
return row;
}
},
{
value: "windSpeed",
text: "Wind Speed",
unit: "km/h",
convert: row => {
row.windSpeed = convertToNumber(row, r => r.windSpeed, 0);
return row;
}
},
{
value: "peakWindSpeed",
text: "Peak Wind Speed",
unit: "km/h",
convert: row => {
row.peakWindSpeed = convertToNumber(row, r => r.peakWindSpeed, 0);
return row;
}
},
{
value: "windDirection",
text: "Wind Direction",
unit: "°",
convert: row => {
row.windDirection = convertToNumber(row, r => r.windDirection, 0);
return row;
}
},
{
value: "rain",
text: "Rain",
unit: "l/m²",
convert: row => {
row.rain = convertToNumber(row, r => r.rain, 0);
return row;
}
},
{
value: "atmosphericPressureRed",
text: "Atm. Pressure (Sea Level)",
unit: "hPa",
convert: row => {
row.atmosphericPressureRed = convertToNumber(row, r => r.atmosphericPressureRed, 1000);
return row;
}
},
{
value: "atmosphericPressureStation",
text: "Atm. Pressure (Station)",
unit: "hPa",
convert: row => {
row.atmosphericPressureStation = convertToNumber(row, r => r.atmosphericPressureStation, 1000);
return row;
}
},
{
value: "sun",
text: "Sun",
unit: "%",
convert: row => {
row.sun = convertToNumber(row, r => r.sun, 0);
return row;
}
}];
function fillTypeSelect(elementSelector) {
const options = d3.select(elementSelector).selectAll("option").data(trendTypes);
const options_enter = options.enter().append("option")
.attr("value", o => o.value)
.text(o => o.text);
options.merge(options_enter);
options.exit().remove();
}
function updateDisabledScatterOptions() {
let selectedXAxisValue = d3.select("#scatter-x-axis-type").property("value");
let selectedYAxisValue = d3.select("#scatter-y-axis-type").property("value");
d3.select("#scatter-x-axis-type").selectAll("option").attr("disabled", null);
d3.select("#scatter-y-axis-type").selectAll("option").attr("disabled", null);
d3.select(`#scatter-x-axis-type option[value='${selectedYAxisValue}']`).attr("disabled", "disabled");
d3.select(`#scatter-y-axis-type option[value='${selectedXAxisValue}']`).attr("disabled", "disabled");
}
function absoluteAxisFormat(d){
if (d === 0) return ''; // No label for '0'
else if (d < 0) d = -d; // No negative labels
return d3.format("0")(d);
}
fillTypeSelect("#trend-type-select");
fillTypeSelect("#scatter-x-axis-type");
fillTypeSelect("#scatter-y-axis-type");
d3.select("#scatter-x-axis-type").property("value", "windSpeed");
d3.select("#scatter-y-axis-type").property("value", "peakWindSpeed");
updateDisabledScatterOptions();
const margin = {top: 2, bottom: 1, left: 35, right: 0};
const zoomDuration = 750;
const moveDuration = 0;
const leftButton = 0;
const rightButton = 2;
const trendWidth = 1200 - margin.left - margin.right;
const windWidth = 360 - margin.left - margin.right;
const scatterWidth = 600 - margin.left - margin.right;
const trendHeight = 400 - margin.top - margin.bottom;
const windHeight = 360 - margin.top - margin.bottom;
const scatterHeight = 350 - margin.top - margin.bottom;
const trendSvg = d3.select('#trend-content').append('svg')
.attr('width', trendWidth)
.attr('height', trendHeight)
.on("contextmenu", (d, i) => d3.event.preventDefault());
const trendGroup = trendSvg.append('g')
.attr('transform', `translate(${margin.left}, ${margin.top})`);
const trendXScale = d3.scaleTime().rangeRound([0, trendWidth]);
const trendYScale = d3.scaleLinear().rangeRound([trendHeight, 0]);
const trendXAxis = d3.axisTop().scale(trendXScale);
const g_trendXAxis = trendGroup.append('g')
.attr('class','x axis')
.attr("transform", `translate(0,${trendHeight - margin.bottom - margin.top})`);
const trendYAxis = d3.axisLeft().scale(trendYScale);
const g_trendYAxis = trendGroup.append('g')
.attr('class','y axis');
g_trendYAxis.append("text")
.attr("fill", "black")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end");
const windSvg = d3.select('#wind-direction-content').append('svg')
.attr('width', windWidth)
.attr('height', windHeight);
const windGroup = windSvg.append('g');
const windXScale = d3.scaleLinear().range([0,windWidth]);
const windYScale = d3.scaleLinear().range([windHeight,0]);
const windGroupContent = windGroup.append('g');
const windXAxis = d3.axisTop().scale(windXScale).tickFormat(absoluteAxisFormat);
const g_windXAxis = windGroup.append('g')
.attr('class','x axis')
.attr("transform", `translate(0,${windHeight/2})`);
const windYAxis = d3.axisLeft().scale(windYScale).tickFormat(absoluteAxisFormat);
const g_windYAxis = windGroup.append('g')
.attr('class','y axis')
.attr("transform", `translate(${windWidth/2},0)`);
function appendAxisLabel(axis, x, y, text, fontSize) {
axis.append("text")
.attr("fill", "black")
.attr("x", x)
.attr("y", y)
.attr("font-size", fontSize)
.text(text);
}
appendAxisLabel(g_windXAxis, 10, 15, "W", 15);
appendAxisLabel(g_windXAxis, 10, 25, "km/h", 10);
appendAxisLabel(g_windXAxis, windWidth-10, 15, "E", 15);
appendAxisLabel(g_windXAxis, windWidth-15, 25, "km/h", 10);
appendAxisLabel(g_windYAxis, 15, 15, "N", 15);
appendAxisLabel(g_windYAxis, 27, 25, "km/h", 10);
appendAxisLabel(g_windYAxis, 15, windHeight-5, "S", 15);
appendAxisLabel(g_windYAxis, 27, windHeight-20, "km/h", 10);
const scatterSvg = d3.select('#scatter-plot-content').append('svg')
.attr('width', scatterWidth)
.attr('height', scatterHeight);
const scatterGroup = scatterSvg.append('g')
.attr('transform', `translate(${margin.left}, ${margin.top})`);
const scatterXScale = d3.scaleLinear().rangeRound([0, scatterWidth]);
const scatterYScale = d3.scaleLinear().rangeRound([scatterHeight, 0]);
const scatterXAxis = d3.axisTop().scale(scatterXScale);
const g_scatterXAxis = scatterGroup.append('g')
.attr('class','x axis')
.attr("transform", `translate(0,${scatterHeight - margin.bottom - margin.top})`);
g_scatterXAxis.append("text")
.attr("fill", "black")
.attr("x", scatterWidth - margin.left - margin.right)
.attr("y", -20)
.style("text-anchor", "end");
const scatterYAxis = d3.axisLeft().scale(scatterYScale);
const g_scatterYAxis = scatterGroup.append('g')
.attr('class','y axis');
g_scatterYAxis.append("text")
.attr("fill", "black")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end");
var data;
const parseDateTime = d3.timeParse("%d.%m.%Y %H:%M:%S");
function getScaledLine(selectorFunc) {
return d3.line()
.x(d => trendXScale(d.date))
.y(d => trendYScale(selectorFunc(d)));
}
const drag = d3.drag().filter(() => {
let allowedButtons = [leftButton, rightButton]; // override filter, default would be only left button
return allowedButtons.includes(d3.event.button);
});
var bandPos = {x: -1, y: -1};
const moveStartPos = {x1: 0, x2: 0, y1: 0, y2: 0};
var zoomArea;
const band = trendGroup.append("rect")
.attr("width", 0)
.attr("height", 0)
.attr("x", 0)
.attr("y", 0)
.attr("class", "band");
trendGroup.append("clipPath")
.attr("id", "clip")
.append("rect")
.attr("width", trendWidth)
.attr("height", trendHeight);
const zoomOverlay = trendGroup.append("rect")
.attr("width", trendWidth)
.attr("height", trendHeight)
.attr("class", "zoomOverlay")
.call(drag);
d3.csv("data/all.csv", type,
(error, data) => {
if(error) throw error;
this.data = data;
initAllPlots(this.data, d => d.temperature);
});
function type(row) {
row.date = parseDateTime(row.date);
trendTypes.forEach(t => row = t.convert(row));
return row;
}
function setResetButtonDisabled(userAppliedZoom) {
d3.select("#reset-zoom-button").attr("disabled", userAppliedZoom ? null : "disabled")
}
function convertToNumber(row, selectorFunc, defaultValue) {
let value = selectorFunc(row);
if(value === undefined) {
console.warn(`A missing for ${selectorFunc} was detected on ${row.date.toISOString()}.`);
return defaultValue;
}
return +value;
}
function initAllPlots(newData, selectorFunc) {
zoomArea = {
x1: d3.min(newData, d => d.date),
y1: d3.min(newData, selectorFunc),
x2: d3.max(newData, d => d.date),
y2: d3.max(newData, selectorFunc),
};
updateAllPlots(newData, selectorFunc, zoomDuration);
}
function updateAllPlots(newData, selectorFunc, duration) {
updateTrend(newData, selectorFunc, duration);
updateWindPlot(newData, duration);
updateScatterPlot(newData, duration);
}
function updateTrend(newData, selectorFunc, duration) {
if (zoomArea.x1 > zoomArea.x2) {
trendXScale.domain([zoomArea.x2, zoomArea.x1]);
} else {
trendXScale.domain([zoomArea.x1, zoomArea.x2]);
}
if (zoomArea.y1 > zoomArea.y2) {
trendYScale.domain([zoomArea.y2, zoomArea.y1]);
} else {
trendYScale.domain([zoomArea.y1, zoomArea.y2]);
}
g_trendYAxis.select("text").text(getSelectedTrendTypeUnit());
g_trendXAxis.transition().duration(duration).call(trendXAxis);
g_trendYAxis.transition().duration(duration).call(trendYAxis);
const path = trendGroup.selectAll('path.line').data([newData], selectorFunc);
const path_enter = path.enter().append('path')
.attr("class", "line")
.attr("clip-path", "url(#clip)");
path.merge(path_enter).transition().duration(duration)
.attr("d", getScaledLine(selectorFunc));
path.exit().remove();
}
function updateWindPlot(newData, duration){
const selectedData = newData.filter(d => d.date >= zoomArea.x1 && d.date <= zoomArea.x2);
const groupedData = d3.nest()
.key(d => d.windDirection)
.entries(selectedData)
.sort((a,b) => d3.ascending(+a.key, +b.key));
var max = d3.max(groupedData, d => d3.mean(d.values, x => x.windSpeed));
windXScale.domain([-max, max]);
windYScale.domain([-max, max]);
g_windXAxis.transition().duration(duration).call(windXAxis);
g_windYAxis.transition().duration(duration).call(windYAxis);
const path = windGroupContent.selectAll('polygon.area')
.data([groupedData]);
const path_enter = path.enter().append('polygon')
.attr("class", "area")
.attr("clip-path", "url(#clip)");
path.merge(path_enter).transition().duration(duration)
.attr("points", function(d){
return d.map(function(d){
let mean = d3.mean(d.values, x => +x.windSpeed);
let x = mean * Math.cos((+d.key+90)*Math.PI/180);
let y = mean * Math.sin((+d.key+90)*Math.PI/180);
return [windXScale(x), windYScale(y)].join(",");
}).join(" ");
});
path.exit().remove();
}
function updateScatterPlot(newData, duration) {
let newDataFilteredByDate = newData.filter(d => d.date >= zoomArea.x1 && d.date <= zoomArea.x2);
let xAxisSelectorFunc = getScatterXAxisSelectorFunc();
let yAxisSelectorFunc = getScatterYAxisSelectorFunc();
scatterXScale.domain(d3.extent(newDataFilteredByDate, xAxisSelectorFunc));
scatterYScale.domain(d3.extent(newDataFilteredByDate, yAxisSelectorFunc));
let xAxisTrendType = getScatterXAxisTrendType();
let yAxisTrendType = getScatterYAxisTrendType();
g_scatterXAxis.select("text").text(`${xAxisTrendType.text} [${xAxisTrendType.unit}]`);
g_scatterYAxis.select("text").text(`${yAxisTrendType.text} [${yAxisTrendType.unit}]`);
g_scatterXAxis.transition().duration(duration).call(scatterXAxis);
g_scatterYAxis.transition().duration(duration).call(scatterYAxis);
const dots = scatterGroup.selectAll(".dot").data(newDataFilteredByDate);
const dots_enter = dots.enter().append("circle")
.attr("class", "dot")
.attr("r", 2)
.style("fill", "steelblue");
dots.merge(dots_enter).transition().duration(duration)
.attr("cx", d => scatterXScale(xAxisSelectorFunc(d)))
.attr("cy", d => scatterYScale(yAxisSelectorFunc(d)));
dots.exit().remove();
}
drag.on("start", function() {
let button = d3.event.sourceEvent.button;
if(button == leftButton) {
dragLeftButtonStart(this);
} else if(button == rightButton) {
dragRightButtonStart(this);
}
});
drag.on("drag", function() {
let button = d3.event.sourceEvent.button;
if(button == leftButton) {
dragLeftButton(this);
} else if(button == rightButton) {
dragRightButton(this);
}
});
drag.on("end", function() {
let button = d3.event.sourceEvent.button;
if(button == leftButton) {
dragLeftButtonEnd(this);
} else if(button == rightButton) {
dragRightButtonEnd(this);
}
});
function dragLeftButton (element) {
let mousePos = d3.mouse(element);
let pos = {x: mousePos[0], y: mousePos[1]};
if (pos.x < bandPos.x) {
d3.select(".band").attr("transform", "translate(" + (pos.x) + "," + bandPos.y + ")");
}
if (pos.y < bandPos.y) {
d3.select(".band").attr("transform", "translate(" + (pos.x) + "," + pos.y + ")");
}
if (pos.y < bandPos.y && pos.x > bandPos.x) {
d3.select(".band").attr("transform", "translate(" + (bandPos.x) + "," + pos.y + ")");
}
d3.select(".band").transition().duration(1)
.attr("width", Math.abs(bandPos.x - pos.x))
.attr("height", Math.abs(bandPos.y - pos.y));
}
function dragLeftButtonEnd(element) {
let mousePos = d3.mouse(element);
let pos = {x: mousePos[0], y: mousePos[1]};
let x1 = trendXScale.invert(bandPos.x);
let x2 = trendXScale.invert(pos.x);
if (x1 < x2) {
zoomArea.x1 = x1;
zoomArea.x2 = x2;
} else {
zoomArea.x1 = x2;
zoomArea.x2 = x1;
}
let y1 = trendYScale.invert(pos.y);
let y2 = trendYScale.invert(bandPos.y);
if (x1 < x2) {
zoomArea.y1 = y1;
zoomArea.y2 = y2;
} else {
zoomArea.y1 = y2;
zoomArea.y2 = y1;
}
bandPos.x = -1;
bandPos.y = -1;
d3.select(".band").transition()
.attr("width", 0)
.attr("height", 0)
.attr("x", bandPos.x)
.attr("y", bandPos.y);
setResetButtonDisabled(true);
updateAllPlots(data, getTrendSelectorFunc(), zoomDuration)
}
function dragLeftButtonStart(element) {
let mousePos = d3.mouse(element);
bandPos = {x: mousePos[0], y: mousePos[1]};
d3.select(".band").attr("transform", "translate(" + bandPos.x + "," + bandPos.y + ")");
}
function dragRightButtonStart(element) {
moveStartPos.x1 = trendXScale(zoomArea.x1);
moveStartPos.x2 = trendXScale(zoomArea.x2);
moveStartPos.y1 = trendYScale(zoomArea.y1);
moveStartPos.y2 = trendYScale(zoomArea.y2);
}
function dragRightButton(element) {
const moveSpeedFactor = 10.0;
moveStartPos.x1 = moveStartPos.x1 - (d3.event.dx / moveSpeedFactor);
moveStartPos.x2 = moveStartPos.x2 - (d3.event.dx / moveSpeedFactor);
moveStartPos.y1 = moveStartPos.y1 - (d3.event.dy / moveSpeedFactor);
moveStartPos.y2 = moveStartPos.y2 - (d3.event.dy / moveSpeedFactor);
let x1 = trendXScale.invert(moveStartPos.x1);
let x2 = trendXScale.invert(moveStartPos.x2);
let y1 = trendYScale.invert(moveStartPos.y1);
let y2 = trendYScale.invert(moveStartPos.y2);
zoomArea.x1 = x1;
zoomArea.x2 = x2;
zoomArea.y1 = y1;
zoomArea.y2 = y2;
setResetButtonDisabled(true);
updateAllPlots(data, getTrendSelectorFunc(), moveDuration);
}
function dragRightButtonEnd(element) {
}
function getSelectedTrendType(elementSelector) {
let selectedValue = d3.select(elementSelector).property("value");
return trendTypes.find(e => e.value == selectedValue);
}
function getSelectedTrendTypeUnit() {
return getSelectedTrendType("#trend-type-select").unit;
}
function getScatterXAxisTrendType() {
return getSelectedTrendType("#scatter-x-axis-type");
}
function getScatterYAxisTrendType() {
return getSelectedTrendType("#scatter-y-axis-type");
}
function getTrendSelectorFunc() {
let selectedValue = d3.select("#trend-type-select").property("value");
return Function("d", `return d.${selectedValue};`);
}
function getScatterXAxisSelectorFunc() {
let selectedValue = d3.select("#scatter-x-axis-type").property("value");
return Function("d", `return d.${selectedValue};`);
}
function getScatterYAxisSelectorFunc() {
let selectedValue = d3.select("#scatter-y-axis-type").property("value");
return Function("d", `return d.${selectedValue};`);
}
function resetZoomToMonth() {
let monthNumber = d3.select("#month-select").property("value");
let selectorFunc = getTrendSelectorFunc();
setResetButtonDisabled(false);
if(monthNumber === undefined || monthNumber < 0) {
initAllPlots(data, selectorFunc)
} else {
let monthFilteredData = data.filter(d => d.date.getMonth() == monthNumber);
zoomArea = {
x1: d3.min(monthFilteredData, d => d.date),
y1: d3.min(monthFilteredData, selectorFunc),
x2: d3.max(monthFilteredData, d => d.date),
y2: d3.max(monthFilteredData, selectorFunc),
};
updateAllPlots(data, getTrendSelectorFunc(), zoomDuration)
}
}
d3.select('#trend-type-select').on("change", function() {
resetZoomToMonth()
});
d3.select("#month-select").on("change", function() {
resetZoomToMonth()
});
d3.select("#scatter-x-axis-type").on("change", function() {
updateDisabledScatterOptions();
updateScatterPlot(data, zoomDuration);
});
d3.select("#scatter-y-axis-type").on("change", function() {
updateDisabledScatterOptions();
updateScatterPlot(data, zoomDuration);
});
d3.select("#reset-zoom-button").on("click", function() {
resetZoomToMonth()
})
</script>
</section>
<footer class="site-footer">
<span class="site-footer-owner"><a href="https://github.com/meinsiedler/zamg-weather-data">ZAMG weather data</a> is maintained by <a
href="https://github.com/meinsiedler">meinsiedler</a>.</span>
<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a
href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a
href="https://twitter.com/jasonlong">Jason Long</a>.</span>
<span class="site-footer-credits">The weather data was taken from <a href="http://at-wetter.tk">at-wetter.tk</a>.</span>
</footer>
</section>
</body>
</html>