From b2dd87f122f5fdb1d9e8b11ffe83f403404d5315 Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Tue, 29 Aug 2017 12:03:58 +0200 Subject: [PATCH] DASH: hide focus for plots with NO value --- python_suite/dashboard/static/js/sparkline.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/python_suite/dashboard/static/js/sparkline.js b/python_suite/dashboard/static/js/sparkline.js index 04bcc84..d3f1b5d 100644 --- a/python_suite/dashboard/static/js/sparkline.js +++ b/python_suite/dashboard/static/js/sparkline.js @@ -164,6 +164,7 @@ function sparkline() { var focus = svg.append("g") .attr("class", "focus") + .attr("transform", "translate(-10,-10)") .style("display", "none"); focus.append("circle") @@ -191,13 +192,15 @@ function sparkline() { var d = x0 - d0[0] > d1[0] - x0 ? d1 : d0; //console.log(x(d[0])); //console.log(y(d[1])); - focus.attr("transform", "translate(" + x(d[0]) + "," + y(d[1]) + ")"); var val = d[1]; - if (precision != null) + if (val != null && precision != null) val = val.toFixed(precision); - tooltip_val.text(val); - var iso_date = d[0].toISOString(); - tooltip_ts.text(iso_date.slice(11, 11+10)); + if (val != null) { + focus.attr("transform", "translate(" + x(d[0]) + "," + y(d[1]) + ")"); + tooltip_val.text(val); + var iso_date = d[0].toISOString(); + tooltip_ts.text(iso_date.slice(11, 11+10)); + } } } } -- 2.43.0