From ba9d7b913040c57ac41ea3dd7ef935df42108f95 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Fri, 12 Jan 2018 16:01:39 -0800 Subject: [PATCH] swatches --- src/components/categorical/categorical.js | 7 ++++++- src/components/categorical/value.js | 8 +++++++- src/reducers/controls.js | 10 +++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/categorical/categorical.js b/src/components/categorical/categorical.js index c413cfcd..31e894c0 100644 --- a/src/components/categorical/categorical.js +++ b/src/components/categorical/categorical.js @@ -8,7 +8,11 @@ import SectionHeader from "../framework/sectionHeader" import Value from "./value"; import { alphabeticallySortedValues } from "./util"; -@connect() +@connect((state) => { + return { + colorAccessor: state.controls.colorAccessor + } +}) class Category extends React.Component { constructor(props) { super(props); @@ -39,6 +43,7 @@ class Category extends React.Component { this.setState({isChecked: false}) } render() { + return (
{ return { - categoricalAsBooleansMap: state.controls.categoricalAsBooleansMap + categoricalAsBooleansMap: state.controls.categoricalAsBooleansMap, + colorScale: state.controls.colorScale, + colorAccessor: state.controls.colorAccessor, } }) class CategoryValue extends React.Component { @@ -30,6 +32,7 @@ class CategoryValue extends React.Component { if (!this.props.categoricalAsBooleansMap) return null const selected = this.props.categoricalAsBooleansMap[this.props.metadataField][this.props.value] + const c = this.props.metadataField === this.props.colorAccessor /* this is the color scale, so add swatches below */ return (

diff --git a/src/reducers/controls.js b/src/reducers/controls.js index 7b9a1108..b5f64b2a 100644 --- a/src/reducers/controls.js +++ b/src/reducers/controls.js @@ -8,6 +8,7 @@ const Controls = (state = { categoricalAsBooleansMap: null, colorAccessor: null, colorScale: null, + opacityForDeselectedCells: .5, graphBrushSelection: null, continuousSelection: null, axesHaveBeenDrawn: false, @@ -105,17 +106,20 @@ const Controls = (state = { case "color by continuous metadata": return Object.assign({}, state, { colorAccessor: action.colorAccessor, - currentCellSelection: action.currentSelectionWithUpdatedColors /* this comes from middleware */ + currentCellSelection: action.currentSelectionWithUpdatedColors, /* this comes from middleware */ + colorScale: action.colorScale, }); case "color by expression": return Object.assign({}, state, { colorAccessor: action.gene, - currentCellSelection: action.currentSelectionWithUpdatedColors /* this comes from middleware */ + currentCellSelection: action.currentSelectionWithUpdatedColors, /* this comes from middleware */ + colorScale: action.colorScale, }) case "color by categorical metadata": return Object.assign({}, state, { colorAccessor: action.colorAccessor, /* pass the scale through additionally, and it's a legend! */ - currentCellSelection: action.currentSelectionWithUpdatedColors /* this comes from middleware */ + currentCellSelection: action.currentSelectionWithUpdatedColors, /* this comes from middleware */ + colorScale: action.colorScale, }) case "store current cell selection as differential set 1": return Object.assign({}, state, {