]> jspc29.x-matter.uni-frankfurt.de Git - mvd_epics.git/commitdiff
DASH: sparkline svg viewBox not fixed width+height
authorPhilipp Klaus <philipp.klaus@gmail.com>
Fri, 29 Sep 2017 12:37:59 +0000 (20:37 +0800)
committerPhilipp Klaus <philipp.klaus@gmail.com>
Fri, 29 Sep 2017 12:37:59 +0000 (20:37 +0800)
This way the SVG image auto-adopts to 100% of the width.

python_suite/dashboard/static/js/sparkline.js

index f809dd46e719cce294474bc8cd38d5ef1fb10764..97b73f64a8e8dd89486bcf2ed0a6c3891e55aa87 100644 (file)
@@ -144,8 +144,8 @@ function sparkline() {
     // Adds the svg canvas to the selector - 'body' by default
     var svg = d3.select(chart.selector())
       .append('svg')
-        .attr('width', width + margin.left + margin.right)
-        .attr('height', height + margin.top + margin.bottom)
+        .attr("viewBox", "0 0 " + (width + margin.left + margin.right) + " " + (height + margin.top + margin.bottom))
+        .attr("preserveAspectRatio", "xMidYMid meet")
       .append('g')
         .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');