From e5253d2ee04f2fb8772063184cb87a6647bfa6bd Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Tue, 16 Jan 2018 16:26:40 -0800 Subject: [PATCH] opacity --- src/components/graph/drawGraph.js | 3 ++- src/components/graph/graph.js | 21 ++++++++++++++++++++- src/reducers/controls.js | 6 +++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/components/graph/drawGraph.js b/src/components/graph/drawGraph.js index a1632556..f0141059 100644 --- a/src/components/graph/drawGraph.js +++ b/src/components/graph/drawGraph.js @@ -58,6 +58,7 @@ export const drawGraph = ( graphBrushSelection, colorScale, graphMap, /* tmp remove when structure exists on server */ + opacityForDeselectedCells, ) => { /* clear canvas */ @@ -112,7 +113,7 @@ export const drawGraph = ( if (_currentCellSelectionMap[p[0]]["__selected__"]) { context.globalAlpha = 1; } else { - context.globalAlpha = .2; + context.globalAlpha = opacityForDeselectedCells; } // if (i < 20) { diff --git a/src/components/graph/graph.js b/src/components/graph/graph.js index 0444e429..37e61e46 100644 --- a/src/components/graph/graph.js +++ b/src/components/graph/graph.js @@ -20,7 +20,8 @@ import { connect } from "react-redux"; continuousSelection: state.controls.continuousSelection, graphMap: state.controls.graphMap, currentCellSelection: state.controls.currentCellSelection, - graphBrushSelection: state.controls.graphBrushSelection + graphBrushSelection: state.controls.graphBrushSelection, + opacityForDeselectedCells: state.controls.opacityForDeselectedCells, } }) class Graph extends React.Component { @@ -89,6 +90,7 @@ class Graph extends React.Component { nextProps.graphBrushSelection, nextProps.colorScale, nextProps.graphMap, + nextProps.opacityForDeselectedCells, ) } } @@ -101,9 +103,26 @@ class Graph extends React.Component { this.setState({svg, ctx}); } + handleOpacityRangeChange(e) { + this.props.dispatch({ + type: "change opacity deselected cells in 2d graph background", + data: e.target.value + }) + } + render() { return (
+ + background opacity + +
) diff --git a/src/reducers/controls.js b/src/reducers/controls.js index b5f64b2a..b05e5dc8 100644 --- a/src/reducers/controls.js +++ b/src/reducers/controls.js @@ -8,7 +8,7 @@ const Controls = (state = { categoricalAsBooleansMap: null, colorAccessor: null, colorScale: null, - opacityForDeselectedCells: .5, + opacityForDeselectedCells: .2, graphBrushSelection: null, continuousSelection: null, axesHaveBeenDrawn: false, @@ -80,6 +80,10 @@ const Controls = (state = { graphBrushSelection: null, currentCellSelection: action.newSelection /* this comes from middleware */ }) + case "change opacity deselected cells in 2d graph background": + return Object.assign({}, state, { + opacityForDeselectedCells: action.data, + }) case "categorical metadata filter select": return Object.assign({}, state, { categoricalAsBooleansMap: action.newCategoricalAsBooleansMap, /* this comes from middleware */