Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit a908031

Browse files
committed
fix(sparkline): avoid regenerating chart on every data update
When only chart data has changed and config remains unchanged, the sparkline chart component will not be regenerated but the data simply reloaded instead. This should be a lighter-weight operation and avoids a visual flicker and redraw of the chart component on data update. fixes #275
1 parent 3d988b1 commit a908031

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/app/chart/sparkline/sparkline.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ export class SparklineComponent extends ChartBase implements DoCheck, OnInit {
6060
* Check if the component config has changed
6161
*/
6262
ngDoCheck(): void {
63-
if (!isEqual(this.config, this.prevConfig) || !isEqual(this.chartData, this.prevChartData)) {
63+
const dataChanged = !isEqual(this.chartData, this.prevChartData);
64+
if (dataChanged || !isEqual(this.config, this.prevConfig)) {
6465
this.setupConfig();
65-
this.generateChart(this.config, true);
66+
this.generateChart(this.config, !dataChanged);
6667
}
6768
}
6869

0 commit comments

Comments
 (0)