Commit 5ac5d2b6139d660db6c9ca1a15a04bfd5125e1e1

Authored by Anais Amato
1 parent 6845708c

Resize d3 js graph with the window size

Showing 1 changed file with 5 additions and 2 deletions   Show diff stats
app/main/static/js/charges.js
... ... @@ -101,11 +101,14 @@ function build_chart(div_selector, data_url, entity_name, category_type) {
101 101 .attr('class', 'fas fa-bars fa-lg export')
102 102 .on("click", update_export_menu);
103 103  
  104 + const real_width = width + margin.left + margin.right;
  105 + const real_height = height + margin.top + margin.bottom;
104 106  
105 107 const svg = d3.select(div_selector).append("svg")
  108 + .attr("viewBox", [0, 0, real_width, real_height])
106 109 .attr("class", "svg_chart")
107   - .attr("width", width + margin.left + margin.right)
108   - .attr("height", height + margin.top + margin.bottom)
  110 + .attr("width", real_width)
  111 + .attr("height", real_height)
109 112 .append("g")
110 113 .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
111 114  
... ...