Skip to content

Commit

Permalink
feat(linegraph): Add dynamic render for legend (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndySeymour2904 authored and tw15egan committed Jun 21, 2018
1 parent 075b78f commit d338b96
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/LineGraph/LineGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ class LineGraph extends Component {
}
}

componentDidUpdate(prevProps) {
const { showLegend, seriesLabels } = this.props;

// If seriesLabels change, remove legend and re-render
if (showLegend && seriesLabels.length !== prevProps.seriesLabels.length) {
this.svg.selectAll('.legend').remove();
this.renderLegend();
}
}

updateEmptyState(data) {
if (
data[0]
Expand Down

0 comments on commit d338b96

Please sign in to comment.