-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinechart.html
81 lines (74 loc) · 2.61 KB
/
linechart.html
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
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var station = $('#stationform').val();
var date = $('#dateform').val();
var jsonData = $.ajax({
url: "linechartGen.php",
dataType: "json",
data: {station: station, date: date},
async: false
}).responseText;
var data = new google.visualization.DataTable(jsonData);
var options = {
title: 'Hour vs. NO2 Concentration comparison',
hAxis: {
title: 'Hour',
ticks: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]},
vAxis: {title: 'NO2 Concentration (µg/m³)'},
//curveType: 'function',
legend: { position: 'bottom' },
width: 1200
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div style="display: inline-block;">
<form id="form">
<p>Station: </p>
<select name="station" id="stationform" onchange="">
<option value="Brislington">Brislington</option>
<option value="Fishponds">Fishponds</option>
<option value="Newfoundland Way">Newfoundland Way</option>
<option value="Parson St">Parson St</option>
<option value="Rupert St">Rupert St</option>
<option value="Wells Road">Wells Road</option>
</select>
</form>
</div>
<div style="display: inline-block;">
<form id="form">
<p>Date: </p>
<!-- <div id="dateOption"></div> -->
<select name="date" id="dateform" style="width: 80pt" onchange="drawChart();"></select>
</form>
</div>
<div id="curve_chart" style="width: 900px; height: 500px"></div>
<div id="test"></div>
<script>
$(document).ready(function(){
$("#stationform").change(function(){
var station = $('#stationform').val();
$.ajax({
url: "DateDropdown.php",
//context: document.body,
data: {station: station},
success: function(response){
//alert(response);
$('#dateform').html(response);
drawChart();
}
});
});
});
</script>
</body>
</html>