-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson.js
53 lines (46 loc) · 1.35 KB
/
json.js
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
src="dist/Chart.js"
$().ready(function(){
$.getJSON( "/log.json", function( data ) {
console.log(data);
var timeData = [];
var moistureData = [];
var moistureData2 = [];
for (i = 0; i < data.length; i++) {
timeData.push(data[i]['Time'])
moistureData.push(data[i]['Ketchups soil moisture'])
moistureData2.push(data[i]['Toms soil moisture'])
}
console.log(timeData)
console.log(moistureData)
var ctx = document.getElementById('myChart');
var myLineChart = new Chart(ctx, {
type: 'line',
data: {
labels: timeData,
datasets: [{
label: 'Ketchups soil moisture %',
data: moistureData,
backgroundColor: 'rgba(255, 0, 0, 0.8)',
fill: false},
{
label: 'Toms soil moisture %',
data: moistureData2,
backgroundColor: 'rgba(0, 255, 0, 0.8)',
fill: false}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
suggestedMax: 100
}
}]
}
}
});
myLineChart.canvas.parentNode.style.height = '18%';
myLineChart.canvas.parentNode.style.width = '70%';
//$("#text").html(data["text"]);
});
});