continuous legend conversion

This commit is contained in:
Colin Megill
2018-08-02 15:32:26 -04:00
parent 20331313e0
commit 7ae1db627c
2 changed files with 8 additions and 13 deletions
@@ -51,10 +51,6 @@ class Continuous extends React.Component {
dimensions: null dimensions: null
}; };
} }
componentDidMount() {}
componentWillReceiveProps(nextProps) {}
componentDidMount() {}
handleBrushAction(selection) { handleBrushAction(selection) {
this.props.dispatch({ this.props.dispatch({
type: "continuous selection using parallel coords brushing", type: "continuous selection using parallel coords brushing",
@@ -102,27 +102,26 @@ class ContinuousLegend extends React.Component {
super(props); super(props);
this.state = {}; this.state = {};
} }
componentWillReceiveProps(nextProps) { componentDidUpdate(prevProps) {
if ( if (
nextProps.colorAccessor !== this.props.colorAccessor || prevProps.colorAccessor !== this.props.colorAccessor ||
nextProps.responsive.height !== this.props.responsive.height || prevProps.responsive.height !== this.props.responsive.height ||
nextProps.responsive.width !== this.props.responsive.width prevProps.responsive.width !== this.props.responsive.width
) { ) {
/* always remove it, if it's not continuous we don't put it back. */ /* always remove it, if it's not continuous we don't put it back. */
d3 d3.select("#continuous_legend")
.select("#continuous_legend")
.selectAll("*") .selectAll("*")
.remove(); .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? */ /* 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(
"#continuous_legend", "#continuous_legend",
d3 d3
.scaleSequential(d3.interpolateViridis) .scaleSequential(d3.interpolateViridis)
.domain(nextProps.colorScale.domain()) .domain(this.props.colorScale.domain())
); );
} }
} }