diff options
author | Karel Kočí <karel.koci@nic.cz> | 2017-08-15 17:57:25 +0200 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2017-08-15 17:57:25 +0200 |
commit | 8e8481885d3134e8d994a30fd5254fc6d41df9ea (patch) | |
tree | fefb65fec9f438ee319d1c523ccb8e7417ee215b /foris/templates/javascript/ups_pfc8591 | |
parent | 137e9ac603fac87d42a9e383885827a4e769110d (diff) | |
download | turris-ups-pfc8591-bf8fd5c7ba5358bda7768a6b72571a45adf713f9.tar.gz turris-ups-pfc8591-bf8fd5c7ba5358bda7768a6b72571a45adf713f9.tar.bz2 turris-ups-pfc8591-bf8fd5c7ba5358bda7768a6b72571a45adf713f9.zip |
Rename from i2c-collect to more suitable ups-pfc8591v0.2
Diffstat (limited to 'foris/templates/javascript/ups_pfc8591')
-rw-r--r-- | foris/templates/javascript/ups_pfc8591/ups_pfc8591.js.tpl | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/foris/templates/javascript/ups_pfc8591/ups_pfc8591.js.tpl b/foris/templates/javascript/ups_pfc8591/ups_pfc8591.js.tpl new file mode 100644 index 0000000..5ee281d --- /dev/null +++ b/foris/templates/javascript/ups_pfc8591/ups_pfc8591.js.tpl @@ -0,0 +1,78 @@ +function graph_init(field) { + var graph_config = { + type: 'line', + data: { + labels: graph_labels[field], + datasets: [ + { + label: field, + data: graph_data[field], + }, + ], + fill: false, + steppedLine: false, + }, + options: { + responsive: true, + title: { + display:true, + text:'{{ trans("Sample") }}' + }, + tooltips: { + mode: 'index', + intersect: false, + }, + hover: { + mode: 'nearest', + intersect: true + }, + scales: { + xAxes: [{ + display: true, + scaleLabel: { + display: true, + labelString: '{{ trans("Time") }}' + } + }], + yAxes: [{ + display: true, + scaleLabel: { + display: true, + labelString: '{{ trans("Value") }}' + } + }], + }, + }, + }; + if (field == "voltage") { + graph_config.options.scales.yAxes[0].ticks = { min: 10, max: 15 } + } else if (field == "light" || field == "temperature") { + graph_config.options.scales.yAxes[0].ticks = { min: 0, max: 250 } + } else if (field == "light" || field == "temperature") { + graph_config.options.scales.yAxes[0].ticks = { min: 0, max: 100 } + } + var graph_ctx = document.getElementById("canvas-" + field).getContext("2d"); + Foris.lineChart[field] = new Chart(graph_ctx, graph_config); + Foris.lineChartData[field] = graph_config.data; +} + +$(document).ready(function() { + Foris.lineChart = []; + Foris.lineChartData = []; + graph_init("voltage"); + graph_init("light"); + graph_init("temperature"); + graph_init("trimmer"); +}); + +/* +Foris.WS["ups-pfc8591"] = function (data) { + for (d in data) { + Foris.lineChartData[d].datasets[0].data.push(data[d][0]); + Foris.lineChartData[d].datasets[0].data.shift(); + Foris.lineChartData[d].labels.push(data[d][1]); + Foris.lineChartData[d].labels.shift(); + Foris.lineChart[d].update(); + } +}; +*/ |