Skip to content

Commit d0fa461

Browse files
Invalidate bar label text measurer caches (#3546)
A bug exists where bar chart labels render incorrectly when the chart is first rendered into a invalid element, such as one with zero size or display: none style. Since text measurement is cached, these incorrect measurements would perist and the labels would remain broken even if the element becomes valid for rendering. This change correctly invalidates all the bar chart label measurer caches, and bar labels will then render correctly when the element becomes valid.
1 parent f892066 commit d0fa461

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Diff for: src/components/legend.ts

+1
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ export class Legend extends Component {
693693
}
694694

695695
public invalidateCache() {
696+
super.invalidateCache();
696697
this._measurer.reset();
697698
}
698699
}

Diff for: src/plots/barPlot.ts

+5
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,11 @@ export class Bar<X, Y> extends XYPlot<X, Y> {
914914
0, 0, plotWidth, plotHeight,
915915
);
916916
}
917+
918+
public invalidateCache() {
919+
super.invalidateCache();
920+
this.datasets().forEach((dataset) => this._labelConfig.get(dataset).measurer.reset());
921+
}
917922
}
918923

919924
/**

0 commit comments

Comments
 (0)