fixed: default pane height 120px, save to localStorage on resize
This commit is contained in:
@ -650,7 +650,7 @@ function addIndicator(type) {
|
|||||||
plots: metadata.plots,
|
plots: metadata.plots,
|
||||||
series: [],
|
series: [],
|
||||||
visible: true,
|
visible: true,
|
||||||
paneHeight: Math.floor(window.innerHeight * 0.2) // default 20% of screen
|
paneHeight: 120 // default 120px
|
||||||
});
|
});
|
||||||
|
|
||||||
// Don't set configuringId so indicators are NOT expanded by default
|
// Don't set configuringId so indicators are NOT expanded by default
|
||||||
@ -954,10 +954,26 @@ export function drawIndicatorsOnChart() {
|
|||||||
|
|
||||||
const pane = window.dashboard.chart.panes()[paneIndex];
|
const pane = window.dashboard.chart.panes()[paneIndex];
|
||||||
if (pane) {
|
if (pane) {
|
||||||
// Use stored height or default to 20% of chart height
|
// Use stored height, localStorage, or default 120px
|
||||||
const defaultHeight = Math.floor(window.innerHeight * 0.2);
|
const storedHeight = indicator.paneHeight ||
|
||||||
const storedHeight = indicator.paneHeight || defaultHeight;
|
parseInt(localStorage.getItem(`pane_height_${indicator.type}`)) ||
|
||||||
|
120;
|
||||||
pane.setHeight(storedHeight);
|
pane.setHeight(storedHeight);
|
||||||
|
|
||||||
|
// Subscribe to pane height changes to save to localStorage
|
||||||
|
const currentPane = pane;
|
||||||
|
const originalHeight = storedHeight;
|
||||||
|
const resizeObserver = new ResizeObserver((entries) => {
|
||||||
|
for (const entry of entries) {
|
||||||
|
const newHeight = Math.round(entry.contentRect.height);
|
||||||
|
if (newHeight !== originalHeight && newHeight > 50) {
|
||||||
|
indicator.paneHeight = newHeight;
|
||||||
|
localStorage.setItem(`pane_height_${indicator.type}`, newHeight);
|
||||||
|
console.log(`[Indicators] Saved pane height for ${indicator.type}: ${newHeight}px`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
resizeObserver.observe(pane.domNode());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user