Skip to content

Commit

Permalink
#233 fixed bug with chart zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
maerzman committed Sep 4, 2024
1 parent c77cc13 commit 097ab60
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ export default class CoordinateBubbleChart extends BubbleChart<CoordinateBubbleC
}

componentDidUpdate(prevProps: Readonly<CoordinateBubbleChartProps>, prevState: Readonly<CoordinateBubbleChartState>) {
if (prevProps.data !== this.props.data || prevState.data !== this.state.data) {
if (prevProps.data !== this.props.data) {
this.setState({
data: this.props.data,
});
this.reassignOriginalDataPointValues();
this.updateElement();
}

if (prevState.data !== this.state.data) {
this.reassignOriginalDataPointValues();
this.updateElement();
}
}

reassignOriginalDataPointValues() {
Expand Down Expand Up @@ -228,13 +233,15 @@ export default class CoordinateBubbleChart extends BubbleChart<CoordinateBubbleC

svg.selectAll('*').remove();

const radiusRange = Math.sqrt((width * height) / (8 * Math.PI * data.length));

const scales = this.createScales(
this.getXDims(),
[paddings.left, width - paddings.right],
this.getYDims(),
[height - paddings.bottom, paddings.top],
this.getRadiusDims(),
[d3.min(data, (d: any) => d.size), d3.max(data, (d: any) => d.size)],
[0.2 * radiusRange, radiusRange],
);

this.createBrush(svg, data, width, height);
Expand Down

0 comments on commit 097ab60

Please sign in to comment.