From: Philipp Klaus Date: Thu, 24 Aug 2017 11:40:06 +0000 (+0200) Subject: DASH: properly plot horizontal lines X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=2602676664f7d3e552790a5904894474688d1b0f;p=mvd_epics.git DASH: properly plot horizontal lines --- diff --git a/python_suite/dashboard/static/js/sparkline.js b/python_suite/dashboard/static/js/sparkline.js index c4bc8a0..c3a1e3e 100644 --- a/python_suite/dashboard/static/js/sparkline.js +++ b/python_suite/dashboard/static/js/sparkline.js @@ -90,6 +90,7 @@ function sparkline() { .attr("y1", "0%") // starting y point .attr("x2", "0%") // ending x point .attr("y2", "100%") // ending y point + .attr("gradientUnits", "userSpaceOnUse") .attr("spreadMethod", "pad"); chart.gradientColors().forEach(function (color, index) { @@ -124,7 +125,9 @@ function sparkline() { // Scale the range of the data x.domain(d3.extent(data, function (d) { return d[0]; })); - y.domain(d3.extent(data, function (d) { return d[1]; })); + var extent = d3.extent(data, function (d) { return d[1]; }); + if (extent[0] == extent[1]) extent = [ extent[0]-.5, extent[0]+.5]; + y.domain(extent); // Add the valueline path.