Commit 5f89fdc7503c1313d2287f18f01c550dea12794e
1 parent
ec07c812
Exists in
master
and in
4 other branches
Fix color scale: Embeding declarations in main fun
Showing
1 changed file
with
18 additions
and
18 deletions
Show diff stats
app/main/static/js/charges.js
1 | -const main_elt = document.getElementById("main") | |
1 | +function build_chart(div_selector, data_url, project_name, category) { | |
2 | + const main_elt = document.getElementById("main") | |
2 | 3 | |
3 | -const margin = {top: 60, right: 350, bottom: 100, left: 90}, | |
4 | - width = main_elt.offsetWidth * 0.95 - margin.left - margin.right, | |
5 | - height = 500 - margin.top - margin.bottom; | |
4 | + const margin = {top: 60, right: 350, bottom: 100, left: 90}, | |
5 | + width = main_elt.offsetWidth * 0.95 - margin.left - margin.right, | |
6 | + height = 500 - margin.top - margin.bottom; | |
6 | 7 | |
7 | -const height_ratio = 1.2 | |
8 | + const height_ratio = 1.2 | |
8 | 9 | |
9 | -const tooltip_offset = {dx: 0, dy: 100} | |
10 | -const tooltip_offset_dot = {dx: 20, dy: 60} | |
10 | + const tooltip_offset = {dx: 0, dy: 100} | |
11 | + const tooltip_offset_dot = {dx: 20, dy: 60} | |
11 | 12 | |
12 | -const colorScale = d3.scaleOrdinal(d3.schemeCategory10); | |
13 | + const colorScale = d3.scaleOrdinal(d3.schemeCategory10); | |
13 | 14 | |
14 | -const y_ticks_num = 5 | |
15 | + const y_ticks_num = 5 | |
15 | 16 | |
16 | -const legend_cell_size = 15; // colored scare size | |
17 | -const legend_x = width + 20; // begin legend a bit after the end of the chart | |
17 | + const legend_cell_size = 15; // colored scare size | |
18 | + const legend_x = width + 20; // begin legend a bit after the end of the chart | |
18 | 19 | |
19 | -const dot_radius = 6; | |
20 | + const dot_radius = 6; | |
20 | 21 | |
21 | -const xScale = d3.scaleBand() | |
22 | - .range([0, width]) | |
23 | - .padding(0.2); | |
22 | + const xScale = d3.scaleBand() | |
23 | + .range([0, width]) | |
24 | + .padding(0.2); | |
24 | 25 | |
25 | -const yScale = d3.scaleLinear() | |
26 | - .range([height, 0]) | |
26 | + const yScale = d3.scaleLinear() | |
27 | + .range([height, 0]) | |
27 | 28 | |
28 | -function build_chart(div_selector, data_url, project_name, category) { | |
29 | 29 | |
30 | 30 | var chart_title = "" |
31 | 31 | var category_title = "" | ... | ... |