From 5ac5d2b6139d660db6c9ca1a15a04bfd5125e1e1 Mon Sep 17 00:00:00 2001 From: Anaïs Amato Date: Tue, 18 May 2021 14:59:36 +0200 Subject: [PATCH] Resize d3 js graph with the window size --- app/main/static/js/charges.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/main/static/js/charges.js b/app/main/static/js/charges.js index a0f3a1c..aacebba 100644 --- a/app/main/static/js/charges.js +++ b/app/main/static/js/charges.js @@ -101,11 +101,14 @@ function build_chart(div_selector, data_url, entity_name, category_type) { .attr('class', 'fas fa-bars fa-lg export') .on("click", update_export_menu); + const real_width = width + margin.left + margin.right; + const real_height = height + margin.top + margin.bottom; const svg = d3.select(div_selector).append("svg") + .attr("viewBox", [0, 0, real_width, real_height]) .attr("class", "svg_chart") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) + .attr("width", real_width) + .attr("height", real_height) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); -- libgit2 0.21.2