From 28bf479a7672b80c19cae4d8de06c355c45ecf4e Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Tue, 7 Nov 2017 11:51:04 -0800 Subject: [PATCH] set scales at 0 to 1 for normalized data --- src/components/graph/drawGraph.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/graph/drawGraph.js b/src/components/graph/drawGraph.js index 888dd3ee..30afb2c0 100644 --- a/src/components/graph/drawGraph.js +++ b/src/components/graph/drawGraph.js @@ -6,12 +6,12 @@ const margin = {top: 20, right: 10, bottom: 30, left: 40}, width = 960 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; -const MAGIC_CONSTANT_UNTIL_WE_NORMALIZE = 3; /* should be zero to one but it's zero to four for now */ - const x = d3.scaleLinear() + .domain([0, 1]) /* while this is the default for d3, our data is normalized so better to be explicit */ .range([0, width]); const y = d3.scaleLinear() + .domain([0, 1]) /* while this is the default for d3, our data is normalized so better to be explicit */ .range([height, 0]); /****************************************** @@ -65,15 +65,13 @@ export const drawGraph = ( /* clear canvas */ context.clearRect(0, 0, width, height); - x.domain([0, MAGIC_CONSTANT_UNTIL_WE_NORMALIZE]) - y.domain([0, MAGIC_CONSTANT_UNTIL_WE_NORMALIZE]) - let colorScale = null; /* it could be 'by expression' and that's a special case */ if ( color && ranges[color].range /* set up a continuous scale */ ) { + /* this scale should live in redux since it will be consumed by cotinuous as well */ colorScale = d3.scaleLinear() .domain([0, ranges[color].range.max]) .range([1,0])