From df657ec621645c2b3bc2ab2b60a69cba9619600f Mon Sep 17 00:00:00 2001 From: DiTus Date: Sun, 22 Mar 2026 20:08:15 +0100 Subject: [PATCH] feat: Add draggable chart resizer and fix flexible layout to prevent empty space --- index.html | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index b0c8e52..a0a4c7f 100644 --- a/index.html +++ b/index.html @@ -80,7 +80,7 @@
-
+
@@ -102,7 +102,7 @@
-
+
@@ -323,8 +323,13 @@
+ +
+
+
+ -
+

analytics @@ -497,6 +502,56 @@ } } }; + + // Chart Resizer Logic + document.addEventListener('DOMContentLoaded', () => { + const resizer = document.getElementById('mainChartResizer'); + const chartWrapper = document.getElementById('chartWrapper'); + + let isResizing = false; + let lastDownY = 0; + + if (resizer && chartWrapper) { + resizer.addEventListener('mousedown', (e) => { + isResizing = true; + lastDownY = e.clientY; + document.body.style.cursor = 'row-resize'; + chartWrapper.style.pointerEvents = 'none'; // Prevent iframe/canvas capturing mouse + }); + + document.addEventListener('mousemove', (e) => { + if (!isResizing) return; + + const deltaY = e.clientY - lastDownY; + lastDownY = e.clientY; + + const newHeight = chartWrapper.offsetHeight + deltaY; + + // Min 200px, Max windowHeight - 150px + if (newHeight > 200 && newHeight < window.innerHeight - 150) { + chartWrapper.style.flex = 'none'; + chartWrapper.style.height = newHeight + 'px'; + + // Force chart layout recalculation if applicable + if (window.dashboard && window.dashboard.chart) { + const container = document.getElementById('chart'); + window.dashboard.chart.applyOptions({ + width: container.clientWidth, + height: container.clientHeight + }); + } + } + }); + + document.addEventListener('mouseup', () => { + if (isResizing) { + isResizing = false; + document.body.style.cursor = ''; + chartWrapper.style.pointerEvents = 'auto'; + } + }); + } + });