From df22e6ddf2cfe9fc4102c6ca39902dd28fb0e03f Mon Sep 17 00:00:00 2001 From: Richard Hitier Date: Fri, 2 Apr 2021 17:04:09 +0200 Subject: [PATCH] Fix the margins and bar heigts --- app/main/static/js/charges.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/main/static/js/charges.js b/app/main/static/js/charges.js index 42a89a1..28a8ae9 100644 --- a/app/main/static/js/charges.js +++ b/app/main/static/js/charges.js @@ -1,4 +1,4 @@ -const margin = {top: 150, right: 40, bottom: 10, left: 40}, +var margin = {top: 30, right: 30, bottom: 130, left: 90}, width = 1000 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; @@ -39,7 +39,7 @@ function build_chart(div_selector, data_url) { var services = data.columns.slice(1) var periods = d3.map(data, d => d.period) - console.log(data) + // console.log(data) var stack = d3.stack() .keys(services) @@ -53,8 +53,13 @@ function build_chart(div_selector, data_url) { .range([0, width]) .padding(0.1); + y_max = d3.max(stacked_data[stacked_data.length - 1], d => d[1]); + if ( y_max == 0 ) { + console.log(y_max) + y_max = height + } const y = d3.scaleLinear() - .domain([0, 100]) + .domain([0, y_max]) .range([height, 0]); -- libgit2 0.21.2