From f4b8af721e48c2b86edfed017cc6dd85081fbb6f Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Thu, 26 Dec 2019 20:58:48 +0100 Subject: [PATCH] refactor chart handling --- snippets/graph.html | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/snippets/graph.html b/snippets/graph.html index bf780b0..d99b32b 100644 --- a/snippets/graph.html +++ b/snippets/graph.html @@ -61,28 +61,33 @@ $(function() { console.log("A new date selection was made: " + start.format() + ' to ' + end.format()); s_start = start.utc().format('YYYY-MM-DDTHH:mm:ss[Z]'); s_end = end.utc().format('YYYY-MM-DDTHH:mm:ss[Z]'); - console.log("Start: " + s_start + ' End: ' + s_end); + console.log("Start: " + s_start + ' End: ' + s_end + ' Property: '+ property); drawGraph(deveui, alias, property, s_start,s_end, false); } $('#btn_w').on("click", function() { - drawGraph(deveui, alias, 'w', s_start,s_end, false); + property = 'w'; + drawGraph(deveui, alias, property, s_start,s_end, false); }); $('#btn_t').on("click", function() { - drawGraph(deveui, alias, 't', s_start,s_end, false); + property = 't'; + drawGraph(deveui, alias, property, s_start,s_end, false); }); $('#btn_h').on("click", function() { - drawGraph(deveui, alias, 'h', s_start,s_end, false); + property = 'h'; + drawGraph(deveui, alias, property, s_start,s_end, false); }); $('#btn_p').on("click", function() { - drawGraph(deveui, alias, 'p', s_start,s_end, false); + property = 'p'; + drawGraph(deveui, alias, property, s_start,s_end, false); }); $('#btn_vp').on("click", function() { - drawGraph(deveui, alias, 'vp', s_start,s_end, false); + property = 'vp'; + drawGraph(deveui, alias, property, s_start,s_end, false); }); $('#reportrange').daterangepicker({ @@ -227,8 +232,10 @@ function drawGraph(deveui, alias, property, start, stop, create_graph) { if (create_graph) { chart = new ApexCharts(document.querySelector("#chart"), options); } else { - chart.updateOptions(options); - chart.updateSeries(mydata); + chart.destroy(); + chart = new ApexCharts(document.querySelector("#chart"), options); + //chart.updateOptions(options); + //chart.updateSeries(mydata); } chart.render();