Skip to content

Commit 4a20395

Browse files
committed
agriculture: fix charts and wind direction
Signed-off-by: Victor Coman <victor.coman@digi.com>
1 parent 971c6a9 commit 4a20395

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

agriculture/agriculturecommon/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<script src="https://www.gstatic.com/charts/loader.js"></script>
2222
<script>
2323
<!--42 is for version 42 cause there is a bug that causes the charts popups to flicker and version 42 did not have this issue.-->
24-
google.charts.load("42", {"packages":["line", "corechart"]});
24+
google.charts.load("current", {"packages":["line", "corechart"]});
2525
</script>
2626
</head>
2727
<body>

agriculture/agriculturecore/templates/history.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,5 @@ <h5 class="card-title">Historic data: Irrigation controller</h5>
155155
drawAllCharts();
156156
});
157157
</script>
158+
<style>div.google-visualization-tooltip { width:150px;}</style>
158159
{% endblock %}

agriculture/static/js/dashboard.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -523,23 +523,25 @@ function updateWeatherStation(response) {
523523
// Update the wind direction value.
524524
controllerWindDir = weatherStationStatus[ID_WIND_DIR];
525525
dir = "";
526-
if (controllerWindDir = 0)
526+
527+
if (controllerWindDir == 0)
527528
dir = "N"
528-
if (controllerWindDir = 8)
529+
if (controllerWindDir == 8)
529530
dir = "NE"
530-
if (controllerWindDir = 16)
531+
if (controllerWindDir == 16)
531532
dir = "E"
532-
if (controllerWindDir = 24)
533+
if (controllerWindDir == 24)
533534
dir = "SE"
534-
if (controllerWindDir = 32)
535+
if (controllerWindDir == 32)
535536
dir = "S"
536-
if (controllerWindDir = 40)
537+
if (controllerWindDir == 40)
537538
dir = "SW"
538-
if (controllerWindDir = 48)
539+
if (controllerWindDir == 48)
539540
dir = "W"
540-
if (controllerWindDir = 56)
541+
if (controllerWindDir == 56)
541542
dir = "NW"
542543

544+
543545
let controllerWindDirElement = document.getElementById(ID_WIND_DIR);
544546
if (controllerWindDirElement != null)
545547
controllerWindDirElement.innerText = dir;

agriculture/static/js/history.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null,
309309
return;
310310

311311
var dataTable = new google.visualization.DataTable();
312-
dataTable.addColumn("date", "");
312+
dataTable.addColumn('date', '');
313313
dataTable.addColumn("number", title);
314314
if (data2 != null){
315315
dataTable.addColumn("number", title2);
@@ -329,8 +329,8 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null,
329329
dataTable.addRows(maximumLength);
330330

331331
$.each(data, function(k, v) {
332-
dataTable.setCell(k, 0, new Date(v["timestamp"]));
333-
dataTable.setCell(k, 1, v["data"]);
332+
dataTable.setCell(k, 0, new Date(v["timestamp"]));
333+
dataTable.setCell(k, 1, v["data"]);
334334
});
335335

336336
if(data2 != null){
@@ -345,7 +345,7 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null,
345345
options = {
346346
backgroundColor: "transparent",
347347
series: {
348-
0: {targetAxisIndex: 0, color: color},
348+
0: { targetAxisIndex: 0, color: color},
349349
},
350350
vAxes: {
351351
// Adds titles to each axis.
@@ -354,7 +354,8 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null,
354354
vAxis: {
355355
ticks: [{v: 0}, {v: 8}, {v: 16}, {v: 24}, {v: 32}, {v: 40}, {v: 48}, {v: 56} , {v: 64}]
356356
},
357-
legend: { position: 'bottom' }
357+
legend: { position: 'bottom' },
358+
tooltip: { ignoreBounds: true, isHtml: true, trigger: 'both' }
358359
};
359360
}
360361
else if(data2 == null && id != "rain-chart"){
@@ -372,7 +373,8 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null,
372373
min: 0
373374
}
374375
},
375-
legend: { position: 'bottom' }
376+
legend: { position: 'bottom' },
377+
tooltip: { ignoreBounds: true, isHtml: true, trigger: 'both' }
376378
};
377379
}
378380
else if(data2 != null){
@@ -396,7 +398,8 @@ function drawChart(id, data, title, units, color=null, data2=null, units2=null,
396398
minValue: 0,
397399
ticks: [{v: 0, f: 'N'}, {v: 8, f: 'NE'}, {v: 16, f: 'E'}, {v: 24, f: 'SE'}, {v: 32, f: 'S'}, {v: 40, f: 'SW'}, {v: 48, f: 'W'}, {v: 56, f: 'NW'} ]
398400
}],
399-
legend: { position: 'bottom' }
401+
legend: { position: 'bottom' },
402+
tooltip: { ignoreBounds: true, isHtml: true, trigger: 'both' }
400403
};
401404
}
402405

0 commit comments

Comments
 (0)