From 133a7f3aa893188a5006f7011e9e42b387a447a1 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Wed, 11 Apr 2018 16:28:41 -0700 Subject: [PATCH] import continuous to sidebar --- src/components/continuous/continuous.js | 99 ++++++------------------- src/components/leftsidebar.js | 2 + 2 files changed, 25 insertions(+), 76 deletions(-) diff --git a/src/components/continuous/continuous.js b/src/components/continuous/continuous.js index b7581764..b938d63e 100644 --- a/src/components/continuous/continuous.js +++ b/src/components/continuous/continuous.js @@ -11,6 +11,8 @@ import setupParallelCoordinates from "./setupParallelCoordinates"; import drawAxes from "./drawAxes"; import drawLinesCanvas from "./drawLinesCanvas"; +import HistogramBrush from "./histogramBrush"; + import { margin, width, @@ -47,80 +49,15 @@ class Continuous extends React.Component { }; } componentDidMount() { - const {svg, ctx} = setupParallelCoordinates( - width, - height, - margin - ); - this.setState({svg, ctx}) + } componentWillReceiveProps(nextProps) { - this.maybeDrawAxes(nextProps); - this.maybeDrawLines(nextProps); + } - maybeDrawAxes(nextProps) { - if ( - !this.state.axes && - nextProps.initializeRanges /* axes are created on full range of data */ - ) { - const dimensions = createDimensions(nextProps.initializeRanges); + componentDidMount() { - const xscale = d3.scalePoint() - .domain(d3.range(dimensions.length)) - .range([0, width]); - - const axes = drawAxes( - this.state.svg, - this.state.ctx, - dimensions, - xscale, - height, - width, - this.handleBrushAction.bind(this), - this.handleColorAction.bind(this), - ); - - this.setState({ - axes, - xscale, - dimensions, - }) - - this.props.dispatch({ - type: "parallel coordinates axes have been drawn" - }) - - } } - maybeDrawLines = _.debounce((nextProps) => { /* https://stackoverflow.com/questions/23123138/perform-debounce-in-react-js */ - if ( - nextProps.ranges && - nextProps.currentCellSelection && - nextProps.axesHaveBeenDrawn - ) { - - if (this.state._drawLinesCanvas) { - this.state._drawLinesCanvas.invalidate(); /* this is only necessary if the internals of drawLinesCanvas are using the render queue */ - } - - this.state.ctx.clearRect(0, 0, width, height); - - const _drawLinesCanvas = drawLinesCanvas( - nextProps.currentCellSelection, - this.state.dimensions, - this.state.xscale, - this.state.ctx, - nextProps.colorAccessor, - nextProps.colorScale, - ); - - this.setState({ - _drawLinesCanvas, /* this will only exist if the internals of drawLinesCanvas are using the render queue */ - }) - } - }, 200) - handleBrushAction (selection) { this.props.dispatch({ type: "continuous selection using parallel coords brushing", @@ -138,14 +75,24 @@ class Continuous extends React.Component { render() { return ( -
-
+
+ { + _.map(this.props.ranges, (value, key) => { + const isColorField = key.includes("color") || key.includes("Color"); + if ( + value.range && + key !== "CellName" && + !isColorField + ) { + return ( + + ) + } + }) + }
) } diff --git a/src/components/leftsidebar.js b/src/components/leftsidebar.js index ea5e0619..b3ce6f88 100644 --- a/src/components/leftsidebar.js +++ b/src/components/leftsidebar.js @@ -1,6 +1,7 @@ import React from "react"; import _ from "lodash"; import Categorical from "./categorical/categorical"; +import Continuous from "./continuous/continuous"; import ExpressionButtons from "./expression/expressionButtons"; import { connect } from "react-redux"; import Heatmap from "./expression/diffExpHeatmap"; @@ -66,6 +67,7 @@ class LeftSideBar extends React.Component { overflowX: "hidden", }}> {this.state.currentTab === "metadata" ? : null} + {this.state.currentTab === "metadata" ? : null} {this.state.currentTab === "expression" ? : null}