mirror of
https://github.com/flarum/core.git
synced 2025-08-01 14:10:37 +02:00
committed by
GitHub
parent
1e6f94c366
commit
a2049ebbb8
@@ -16,8 +16,8 @@ import abbreviateNumber from 'flarum/utils/abbreviateNumber';
|
|||||||
import { Chart } from 'frappe-charts/dist/frappe-charts.esm.js';
|
import { Chart } from 'frappe-charts/dist/frappe-charts.esm.js';
|
||||||
|
|
||||||
export default class StatisticsWidget extends DashboardWidget {
|
export default class StatisticsWidget extends DashboardWidget {
|
||||||
init() {
|
oninit(vnode) {
|
||||||
super.init();
|
super.oninit(vnode);
|
||||||
|
|
||||||
// Create a Date object which represents the start of the day in the
|
// Create a Date object which represents the start of the day in the
|
||||||
// configured timezone. To do this we convert a UTC time into that timezone,
|
// configured timezone. To do this we convert a UTC time into that timezone,
|
||||||
@@ -89,13 +89,13 @@ export default class StatisticsWidget extends DashboardWidget {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
<div className="StatisticsWidget-chart" config={this.drawChart.bind(this)}/>
|
<div className="StatisticsWidget-chart" oncreate={this.drawChart.bind(this)} onupdate={this.drawChart.bind(this)}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawChart(elm, isInitialized, context) {
|
drawChart(vnode) {
|
||||||
if (context.chart && context.entity === this.selectedEntity && context.period === this.selectedPeriod) {
|
if (this.chart && this.entity === this.selectedEntity && this.period === this.selectedPeriod) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,8 +135,8 @@ export default class StatisticsWidget extends DashboardWidget {
|
|||||||
datasets
|
datasets
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!context.chart) {
|
if (!this.chart) {
|
||||||
context.chart = new Chart(elm, {
|
this.chart = new Chart(vnode.dom, {
|
||||||
data,
|
data,
|
||||||
type: 'line',
|
type: 'line',
|
||||||
height: 280,
|
height: 280,
|
||||||
@@ -151,11 +151,11 @@ export default class StatisticsWidget extends DashboardWidget {
|
|||||||
colors: ['black', app.forum.attribute('themePrimaryColor')]
|
colors: ['black', app.forum.attribute('themePrimaryColor')]
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
context.chart.update(data);
|
this.chart.update(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.entity = this.selectedEntity;
|
this.entity = this.selectedEntity;
|
||||||
context.period = this.selectedPeriod;
|
this.period = this.selectedPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
changeEntity(entity) {
|
changeEntity(entity) {
|
||||||
|
Reference in New Issue
Block a user