fix: destroy charts when reloading domain reports
This commit is contained in:
parent
7271da95ac
commit
fb753a1189
1 changed files with 11 additions and 0 deletions
|
@ -171,6 +171,15 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function destroyCharts(container) {
|
||||||
|
container.querySelectorAll('canvas').forEach(c => {
|
||||||
|
const chart = Chart.getChart(c);
|
||||||
|
if (chart) {
|
||||||
|
chart.destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function loadReports() {
|
function loadReports() {
|
||||||
let path;
|
let path;
|
||||||
let container;
|
let container;
|
||||||
|
@ -183,6 +192,7 @@
|
||||||
} else {
|
} else {
|
||||||
container = containers.domain;
|
container = containers.domain;
|
||||||
if (!currentDomain) {
|
if (!currentDomain) {
|
||||||
|
destroyCharts(container);
|
||||||
container.innerHTML = '<p>Select a domain</p>';
|
container.innerHTML = '<p>Select a domain</p>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -192,6 +202,7 @@
|
||||||
fetch(path + '/reports.json')
|
fetch(path + '/reports.json')
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(reports => {
|
.then(reports => {
|
||||||
|
destroyCharts(container);
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
reports.forEach(rep => {
|
reports.forEach(rep => {
|
||||||
fetch(path + '/' + rep.html)
|
fetch(path + '/' + rep.html)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue