1
0
mirror of https://github.com/flarum/core.git synced 2025-08-01 14:10:37 +02:00

Only update chart values if needed

This commit is contained in:
Toby Zerner
2017-12-11 18:52:54 +10:30
parent 3f1f92b565
commit b65ad8a5ce

View File

@@ -87,6 +87,10 @@ export default class StatisticsWidget extends DashboardWidget {
} }
drawChart(elm, isInitialized, context) { drawChart(elm, isInitialized, context) {
if (context.chart && context.entity === this.selectedEntity && context.period === this.selectedPeriod) {
return;
}
const entity = this.selectedEntity; const entity = this.selectedEntity;
const period = this.periods[this.selectedPeriod]; const period = this.periods[this.selectedPeriod];
const labels = []; const labels = [];
@@ -121,12 +125,12 @@ export default class StatisticsWidget extends DashboardWidget {
format_tooltip_x: d => d, format_tooltip_x: d => d,
format_tooltip_y: d => d format_tooltip_y: d => d
}); });
} else {
context.chart.update_values(datasets, labels);
} }
context.chart.update_values( context.entity = this.selectedEntity;
datasets, context.period = this.selectedPeriod;
labels
);
} }
changeEntity(entity) { changeEntity(entity) {