From 68d99b71dcfe3b7d74e0ac50e2318a939a42b9c4 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Tue, 12 Dec 2017 21:37:19 -0800 Subject: [PATCH] colors --- src/components/continuous/drawLinesCanvas.js | 13 ++++++----- src/components/graph/drawGraph.js | 24 ++++---------------- src/reducers/controls.js | 3 ++- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/components/continuous/drawLinesCanvas.js b/src/components/continuous/drawLinesCanvas.js index af70cc31..064053f1 100644 --- a/src/components/continuous/drawLinesCanvas.js +++ b/src/components/continuous/drawLinesCanvas.js @@ -20,20 +20,21 @@ const drawLinesCanvas = ( ) => { return (d) => { + ctx.globalAlpha = .1; - if (colorAccessor && colorScale) { + if (colorAccessor && colorScale && d["__selected__"]) { ctx.strokeStyle = d3.interpolateViridis(colorScale(d[colorAccessor])); } else { - ctx.strokeStyle = "rgba(0,0,0,1)"; + ctx.strokeStyle = "rgba(0,0,0,.1)"; } - if (d["__selected__"]) { - ctx.strokeStyle = "rgb(255,0,0)"; - } + // if () { + // ctx.strokeStyle = "rgb(0,0,0)"; + // } ctx.beginPath(); var coords = project(d, dimensions, xscale); - coords.forEach((p,i) => { + coords.forEach((p, i) => { // this tricky bit avoids rendering null values as 0 if (p === null) { // this bit renders horizontal lines on the previous/next diff --git a/src/components/graph/drawGraph.js b/src/components/graph/drawGraph.js index d871ce43..8bce4d19 100644 --- a/src/components/graph/drawGraph.js +++ b/src/components/graph/drawGraph.js @@ -98,32 +98,18 @@ export const drawGraph = ( 2 * Math.PI /* eAngle */ ); - let pointIsInsideBrushBounds; - - if (graphBrushSelection) { - - pointIsInsideBrushBounds = ( - globals.graphXScale(p[1]) >= graphBrushSelection.northwestX && - globals.graphXScale(p[1]) <= graphBrushSelection.southeastX && - globals.graphYScale(p[2]) >= graphBrushSelection.northwestY && - globals.graphYScale(p[2]) <= graphBrushSelection.southeastY - ); - - } - - - context.globalAlpha = !graphBrushSelection || pointIsInsideBrushBounds ? 1 : .2; - if (colorAccessor && colorScale) { context.fillStyle = d3.interpolateViridis(colorScale( _currentCellSelectionMap[p[0]][colorAccessor] )); + } else { + context.fillStyle = "rgb(0,0,0)"; } if (_currentCellSelectionMap[p[0]]["__selected__"]) { - context.fillStyle = "rgb(255,0,0)"; + context.globalAlpha = 1; } else { - context.fillStyle = "rgb(0,0,0)"; + context.globalAlpha = .2; } // if (i < 20) { @@ -140,9 +126,7 @@ export const drawGraph = ( // )); context.fill(); - }); - } const setupGraphBrush = ( diff --git a/src/reducers/controls.js b/src/reducers/controls.js index 40b23935..e9dccde1 100644 --- a/src/reducers/controls.js +++ b/src/reducers/controls.js @@ -52,7 +52,8 @@ const Controls = (state = { }) case "graph brush deselect": return Object.assign({}, state, { - graphBrushSelection: null + graphBrushSelection: null, + currentCellSelection: action.newSelection }) case "color changed": return Object.assign({}, state, {