From 80fbb15280490a5a9ee22cfbccc0b7629218a71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 6 Nov 2023 19:42:34 +0100 Subject: [PATCH] Apply deferred chart loading also to cache pie at settings system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/settings-system.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/pi-hole/js/settings-system.js b/scripts/pi-hole/js/settings-system.js index c7f5c647..9befc225 100644 --- a/scripts/pi-hole/js/settings-system.js +++ b/scripts/pi-hole/js/settings-system.js @@ -12,6 +12,13 @@ var cachePieChart = null; var cacheSize = 0, cacheEntries = 0; +// Register the ChartDeferred plugin to all charts: +Chart.register(ChartDeferred); +Chart.defaults.set('plugins.deferred', { + yOffset: '50%', + delay: 500 +}) + function updateCachePie(data) { var v = [], c = [], @@ -69,10 +76,10 @@ function updateCachePie(data) { cachePieChart.data.datasets[0] = dd; cachePieChart.data.labels = k; $("#cache-pie-chart .overlay").hide(); - cachePieChart.update(); + // Passing 'none' will prevent rotation animation for further updates + //https://www.chartjs.org/docs/latest/developers/updates.html#preventing-animations + cachePieChart.update('none'); - // Don't use rotation animation for further updates - cachePieChart.options.animation.duration = 0; } function updateHostInfo() {