correct it so we always load Chart just before creating it

This commit is contained in:
Sam 2018-05-16 16:44:13 +10:00
parent 565fa1f60e
commit f9d2c69bbe
2 changed files with 6 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import { ajax } from "discourse/lib/ajax";
import AsyncReport from "admin/mixins/async-report"; import AsyncReport from "admin/mixins/async-report";
import Report from "admin/models/report"; import Report from "admin/models/report";
import { number } from 'discourse/lib/formatter'; import { number } from 'discourse/lib/formatter';
import loadScript from "discourse/lib/load-script";
function collapseWeekly(data, average) { function collapseWeekly(data, average) {
let aggregate = []; let aggregate = [];
@ -110,7 +111,10 @@ export default Ember.Component.extend(AsyncReport, {
if (this._chart) { if (this._chart) {
this._chart.destroy(); this._chart.destroy();
} }
this._chart = new window.Chart(context, this._buildChartConfig(data));
loadScript("/javascripts/Chart.min.js").then(() => {
this._chart = new window.Chart(context, this._buildChartConfig(data));
});
}); });
}, },

View File

@ -1,9 +1,5 @@
import loadScript from "discourse/lib/load-script";
export default Discourse.Route.extend({ export default Discourse.Route.extend({
activate() { activate() {
loadScript("/javascripts/Chart.min.js").then(() => { this.controllerFor('admin-dashboard-next').fetchDashboard();
this.controllerFor('admin-dashboard-next').fetchDashboard();
});
} }
}); });