From 7ae1db627c6274226f6a6f2ef2b47a21eac8eb50 Mon Sep 17 00:00:00 2001 From: Colin Megill Date: Thu, 2 Aug 2018 15:32:26 -0400 Subject: [PATCH] continuous legend conversion --- client/src/components/continuous/continuous.js | 4 ---- client/src/components/continuousLegend/index.js | 17 ++++++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/client/src/components/continuous/continuous.js b/client/src/components/continuous/continuous.js index 226b6d0f..5288d5b2 100644 --- a/client/src/components/continuous/continuous.js +++ b/client/src/components/continuous/continuous.js @@ -51,10 +51,6 @@ class Continuous extends React.Component { dimensions: null }; } - componentDidMount() {} - componentWillReceiveProps(nextProps) {} - - componentDidMount() {} handleBrushAction(selection) { this.props.dispatch({ type: "continuous selection using parallel coords brushing", diff --git a/client/src/components/continuousLegend/index.js b/client/src/components/continuousLegend/index.js index 34b89161..e0aa3b1a 100644 --- a/client/src/components/continuousLegend/index.js +++ b/client/src/components/continuousLegend/index.js @@ -102,27 +102,26 @@ class ContinuousLegend extends React.Component { super(props); this.state = {}; } - componentWillReceiveProps(nextProps) { + componentDidUpdate(prevProps) { if ( - nextProps.colorAccessor !== this.props.colorAccessor || - nextProps.responsive.height !== this.props.responsive.height || - nextProps.responsive.width !== this.props.responsive.width + prevProps.colorAccessor !== this.props.colorAccessor || + prevProps.responsive.height !== this.props.responsive.height || + prevProps.responsive.width !== this.props.responsive.width ) { /* always remove it, if it's not continuous we don't put it back. */ - d3 - .select("#continuous_legend") + d3.select("#continuous_legend") .selectAll("*") .remove(); } - if (nextProps.colorAccessor && nextProps.colorScale) { + if (this.props.colorAccessor && this.props.colorScale) { /* fragile! continuous range is 0 to 1, not [#fa4b2c, ...], make this a flag? */ - if (nextProps.colorScale.range()[0][0] !== "#") { + if (this.props.colorScale.range()[0][0] !== "#") { continuous( "#continuous_legend", d3 .scaleSequential(d3.interpolateViridis) - .domain(nextProps.colorScale.domain()) + .domain(this.props.colorScale.domain()) ); } }