This commit is contained in:
Colin Megill
2018-01-12 16:01:39 -08:00
parent e28cb1516a
commit ba9d7b9130
3 changed files with 20 additions and 5 deletions
+6 -1
View File
@@ -8,7 +8,11 @@ import SectionHeader from "../framework/sectionHeader"
import Value from "./value"; import Value from "./value";
import { alphabeticallySortedValues } from "./util"; import { alphabeticallySortedValues } from "./util";
@connect() @connect((state) => {
return {
colorAccessor: state.controls.colorAccessor
}
})
class Category extends React.Component { class Category extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -39,6 +43,7 @@ class Category extends React.Component {
this.setState({isChecked: false}) this.setState({isChecked: false})
} }
render() { render() {
return ( return (
<div style={{ <div style={{
// display: "flex", // display: "flex",
+7 -1
View File
@@ -5,7 +5,9 @@ import actions from "../../actions";
@connect((state) => { @connect((state) => {
return { return {
categoricalAsBooleansMap: state.controls.categoricalAsBooleansMap categoricalAsBooleansMap: state.controls.categoricalAsBooleansMap,
colorScale: state.controls.colorScale,
colorAccessor: state.controls.colorAccessor,
} }
}) })
class CategoryValue extends React.Component { class CategoryValue extends React.Component {
@@ -30,6 +32,7 @@ class CategoryValue extends React.Component {
if (!this.props.categoricalAsBooleansMap) return null if (!this.props.categoricalAsBooleansMap) return null
const selected = this.props.categoricalAsBooleansMap[this.props.metadataField][this.props.value] 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 ( return (
<div <div
@@ -53,6 +56,9 @@ class CategoryValue extends React.Component {
{this.props.value} {this.props.value}
</p> </p>
<p style={{ <p style={{
padding: "1px 10px",
backgroundColor: c ? this.props.colorScale(this.props.value) : "white",
color: c ? "white" : "black",
margin: 0, margin: 0,
lineHeight: "1em" lineHeight: "1em"
}}> }}>
+7 -3
View File
@@ -8,6 +8,7 @@ const Controls = (state = {
categoricalAsBooleansMap: null, categoricalAsBooleansMap: null,
colorAccessor: null, colorAccessor: null,
colorScale: null, colorScale: null,
opacityForDeselectedCells: .5,
graphBrushSelection: null, graphBrushSelection: null,
continuousSelection: null, continuousSelection: null,
axesHaveBeenDrawn: false, axesHaveBeenDrawn: false,
@@ -105,17 +106,20 @@ const Controls = (state = {
case "color by continuous metadata": case "color by continuous metadata":
return Object.assign({}, state, { return Object.assign({}, state, {
colorAccessor: action.colorAccessor, colorAccessor: action.colorAccessor,
currentCellSelection: action.currentSelectionWithUpdatedColors /* this comes from middleware */ currentCellSelection: action.currentSelectionWithUpdatedColors, /* this comes from middleware */
colorScale: action.colorScale,
}); });
case "color by expression": case "color by expression":
return Object.assign({}, state, { return Object.assign({}, state, {
colorAccessor: action.gene, 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": case "color by categorical metadata":
return Object.assign({}, state, { return Object.assign({}, state, {
colorAccessor: action.colorAccessor, /* pass the scale through additionally, and it's a legend! */ 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": case "store current cell selection as differential set 1":
return Object.assign({}, state, { return Object.assign({}, state, {