Commit 31b5d092 authored by Aron Fiechter's avatar Aron Fiechter
Browse files

Update diagram polygon colors whenever the selected year range changes

parent c3e608ac
......@@ -53,6 +53,7 @@ class Voronoi extends React.Component {
this.findChildrenOf = this.findChildrenOf.bind(this);
this.setPolygonColor = this.setPolygonColor.bind(this);
this.isEntityInYearRange = this.isEntityInYearRange.bind(this);
this.updateDiagramHighlight = this.updateDiagramHighlight.bind(this);
}
/**
......@@ -71,10 +72,14 @@ class Voronoi extends React.Component {
*/
componentDidUpdate(prevProps, prevState, snapshot) {
logger.debug('> componentDidUpdate');
const differentTimestamp = prevProps.data?.timestamp !== this.props.data?.timestamp;
const differentQuery = prevProps.data?.query !== this.props.data?.query;
if (differentTimestamp && differentQuery) {
const differentQuery = prevProps.data?.timestamp !== this.props.data?.timestamp;
const differentYearsRange =
prevProps.yearRange?.start !== this.props.yearRange?.start ||
prevProps.yearRange?.end !== this.props.yearRange?.end;
if (differentQuery) {
this.createDiagram();
} else if (differentYearsRange) {
this.updateDiagramHighlight();
}
}
......@@ -422,6 +427,10 @@ class Voronoi extends React.Component {
});
}
updateDiagramHighlight() {
this.state.diagram.selectAll('polygon').attr('fill', this.setPolygonColor);
}
/**
* Given an entity, extract its colors and
* @param d
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment