From 5f89fdc7503c1313d2287f18f01c550dea12794e Mon Sep 17 00:00:00 2001 From: Richard Hitier Date: Mon, 12 Apr 2021 10:49:36 +0200 Subject: [PATCH] Fix color scale: Embeding declarations in main fun --- app/main/static/js/charges.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/main/static/js/charges.js b/app/main/static/js/charges.js index 5ce606b..3211572 100644 --- a/app/main/static/js/charges.js +++ b/app/main/static/js/charges.js @@ -1,31 +1,31 @@ -const main_elt = document.getElementById("main") +function build_chart(div_selector, data_url, project_name, category) { + const main_elt = document.getElementById("main") -const margin = {top: 60, right: 350, bottom: 100, left: 90}, - width = main_elt.offsetWidth * 0.95 - margin.left - margin.right, - height = 500 - margin.top - margin.bottom; + const margin = {top: 60, right: 350, bottom: 100, left: 90}, + width = main_elt.offsetWidth * 0.95 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom; -const height_ratio = 1.2 + const height_ratio = 1.2 -const tooltip_offset = {dx: 0, dy: 100} -const tooltip_offset_dot = {dx: 20, dy: 60} + const tooltip_offset = {dx: 0, dy: 100} + const tooltip_offset_dot = {dx: 20, dy: 60} -const colorScale = d3.scaleOrdinal(d3.schemeCategory10); + const colorScale = d3.scaleOrdinal(d3.schemeCategory10); -const y_ticks_num = 5 + const y_ticks_num = 5 -const legend_cell_size = 15; // colored scare size -const legend_x = width + 20; // begin legend a bit after the end of the chart + const legend_cell_size = 15; // colored scare size + const legend_x = width + 20; // begin legend a bit after the end of the chart -const dot_radius = 6; + const dot_radius = 6; -const xScale = d3.scaleBand() - .range([0, width]) - .padding(0.2); + const xScale = d3.scaleBand() + .range([0, width]) + .padding(0.2); -const yScale = d3.scaleLinear() - .range([height, 0]) + const yScale = d3.scaleLinear() + .range([height, 0]) -function build_chart(div_selector, data_url, project_name, category) { var chart_title = "" var category_title = "" -- libgit2 0.21.2