Commit df22e6ddf2cfe9fc4102c6ca39902dd28fb0e03f
1 parent
54e2baa6
Exists in
master
and in
4 other branches
Fix the margins and bar heigts
Showing
1 changed file
with
8 additions
and
3 deletions
Show diff stats
app/main/static/js/charges.js
1 | -const margin = {top: 150, right: 40, bottom: 10, left: 40}, | |
1 | +var margin = {top: 30, right: 30, bottom: 130, left: 90}, | |
2 | 2 | width = 1000 - margin.left - margin.right, |
3 | 3 | height = 500 - margin.top - margin.bottom; |
4 | 4 | |
... | ... | @@ -39,7 +39,7 @@ function build_chart(div_selector, data_url) { |
39 | 39 | var services = data.columns.slice(1) |
40 | 40 | var periods = d3.map(data, d => d.period) |
41 | 41 | |
42 | - console.log(data) | |
42 | + // console.log(data) | |
43 | 43 | |
44 | 44 | var stack = d3.stack() |
45 | 45 | .keys(services) |
... | ... | @@ -53,8 +53,13 @@ function build_chart(div_selector, data_url) { |
53 | 53 | .range([0, width]) |
54 | 54 | .padding(0.1); |
55 | 55 | |
56 | + y_max = d3.max(stacked_data[stacked_data.length - 1], d => d[1]); | |
57 | + if ( y_max == 0 ) { | |
58 | + console.log(y_max) | |
59 | + y_max = height | |
60 | + } | |
56 | 61 | const y = d3.scaleLinear() |
57 | - .domain([0, 100]) | |
62 | + .domain([0, y_max]) | |
58 | 63 | .range([height, 0]); |
59 | 64 | |
60 | 65 | ... | ... |