Make sure charts are destroyed.

This commit is contained in:
James Cole
2023-10-01 11:32:08 +02:00
parent 78122a7d4b
commit ccec203910
6 changed files with 19 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@@ -30,10 +30,10 @@
"integrity": "sha384-B73JAwYNSgI4rwb14zwxigHgAkg1Ms+j6+9sJoDpiL11+VW5RjQCLfIh0RVoi0h6"
},
"resources/assets/v2/pages/dashboard/dashboard.js": {
"file": "assets/dashboard-30735080.js",
"file": "assets/dashboard-9c9be7cf.js",
"isEntry": true,
"src": "resources/assets/v2/pages/dashboard/dashboard.js",
"integrity": "sha384-dOS/aqo8HSBC1WH7zzmysvvdJdCMYW/RYDXYcq6d33huiXJe2VHhIreFTW/4Lh0R"
"integrity": "sha384-fpX8mrTJxfFxKxTS5d9M+3SJnQE9ePo1Re15lATVi+Q165igCJ6/Rs/mXyezYI4G"
},
"resources/assets/v2/sass/app.scss": {
"file": "assets/app-28a195fd.css",

View File

@@ -70,6 +70,9 @@ export default () => ({
for (const i in data) {
if (data.hasOwnProperty(i)) {
const current = data[i];
if (!current.hasOwnProperty('key')) {
continue;
}
let key = current.key;
// native (auto conversion):
if (this.autoConversion) {

View File

@@ -164,7 +164,7 @@ export default () => ({
y: {
ticks: {
callback: function (context) {
return formatMoney(context, currencies[0]);
return formatMoney(context, currencies[0] ?? 'EUR');
}
}
}

View File

@@ -25,6 +25,7 @@ import {Flow, SankeyController} from 'chartjs-chart-sankey';
import {loadTranslations} from "../../support/load-translations.js";
import {I18n} from "i18n-js";
import {getCacheKey} from "../../support/get-cache-key.js";
import {format} from "date-fns";
Chart.register({SankeyController, Flow});

View File

@@ -197,6 +197,9 @@ export default () => ({
console.error('cannot handle yet');
return;
}
// reset subscription data
subscriptionData = {};
this.subscriptions = [];
console.log('cache is invalid, must download');
let params = {
start: format(start, 'y-MM-dd'),
@@ -263,6 +266,10 @@ export default () => ({
},
}
};
var graph = Chart.getChart(document.querySelector(id));
if (typeof graph !== 'undefined') {
graph.destroy();
}
new Chart(document.querySelector(id), config);
},