From: Rani Hod Date: Mon, 2 Oct 2023 15:01:54 +0000 (+0300) Subject: luci-app-statistics: regenerate graphs on window resize X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=b47850a94ef78739c7d01d5711a94f394a09fce8;p=project%2Fluci.git luci-app-statistics: regenerate graphs on window resize Currently graphs are redrawn only based on the refresh interval (never or every 5/30/60 seconds). Since the image size is calculated based on the window size, redraw graphs (once) also after resizing the window. This also captures window resize due to orientation change (e.g., for mobile). Since multiple resize events are fired when dragging the window border, there is a 250ms delay for debouncing. Signed-off-by: Rani Hod Tested-by: Paul Donald (cherry picked from commit 8fcd52f5130acd1a0738ff47f9bba2c9cc42e662) --- diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js index db24d18592..4ac81ff826 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js @@ -244,6 +244,10 @@ return view.extend({ requestAnimationFrame(L.bind(this.updateGraphs, this, hostSel, spanSel, timeSel, graphDiv)); + var resizeTimeout; + var rgCallback = L.bind(this.refreshGraphs, this, hostSel, spanSel, timeSel, graphDiv); + addEventListener('resize', function() { clearTimeout(resizeTimeout); resizeTimeout = setTimeout(rgCallback, 250); }); + return view; },