From d6f0428cfa27a97d9647080a81e7bcb364bcd4ad Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Thu, 24 Aug 2017 11:37:50 +0200 Subject: [PATCH] DASH: updateSparklines() -> /static/js/script.js --- python_suite/dashboard/static/js/script.js | 18 ++++++++++++++++++ .../dashboard/views/pv_overview.jinja2 | 19 ------------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/python_suite/dashboard/static/js/script.js b/python_suite/dashboard/static/js/script.js index 2a0a758..12d05f1 100644 --- a/python_suite/dashboard/static/js/script.js +++ b/python_suite/dashboard/static/js/script.js @@ -2,3 +2,21 @@ alert("whats up"); console.log("what's up?"); */ + +function updateSparklines() { + var sparklineItems = document.getElementsByClassName("sparkline"); + [].forEach.call(sparklineItems, function (el) { + var el_id = el.id; + var pvName = el_id.substring(el_id.indexOf("-")+1, el_id.length); + var pvName = pvName.replace(/-/g, ':'); + + var sparklineChart = sparkline() + .width(155) + .height(50) + .gradientColors(['green', 'orange', 'red']) // top -> bottom + .dataSource('/api/history/' + pvName + '.json') + .dataSourceType('JSON') + .selector('#'+el.id); + sparklineChart(); // render the chart + }); +}; diff --git a/python_suite/dashboard/views/pv_overview.jinja2 b/python_suite/dashboard/views/pv_overview.jinja2 index 2a106ff..24f7907 100644 --- a/python_suite/dashboard/views/pv_overview.jinja2 +++ b/python_suite/dashboard/views/pv_overview.jinja2 @@ -79,25 +79,6 @@ label { {% block js_end_of_page %} - -function updateSparklines() { - var sparklineItems = document.getElementsByClassName("sparkline"); - [].forEach.call(sparklineItems, function (el) { - var el_id = el.id; - var pvName = el_id.substring(el_id.indexOf("-")+1, el_id.length); - var pvName = pvName.replace(/-/g, ':'); - - var sparklineChart = sparkline() - .width(155) - .height(50) - .gradientColors(['green', 'orange', 'red']) // top -> bottom - .dataSource('/api/history/' + pvName + '.json') - .dataSourceType('JSON') - .selector('#'+el.id); - sparklineChart(); // render the chart - }); -}; - $(function() { // on page load updateSparklines(); -- 2.43.0