fixed: preserve pane assignments across redraws instead of clearing

This commit is contained in:
DiTus
2026-03-01 22:49:05 +01:00
parent 6dd4d1c5dd
commit 00aae46c16

View File

@ -887,8 +887,10 @@ export function drawIndicatorsOnChart() {
'dashed': LightweightCharts.LineStyle.Dashed
};
indicatorPanes.clear();
nextPaneIndex = 1;
// Don't clear indicatorPanes - preserve pane assignments across redraws
// Only reset nextPaneIndex to avoid creating duplicate panes
const maxExistingPane = Math.max(...indicatorPanes.values(), 0);
nextPaneIndex = maxExistingPane + 1;
const overlayIndicators = [];
const paneIndicators = [];
@ -938,8 +940,12 @@ export function drawIndicatorsOnChart() {
});
paneIndicators.forEach(({ indicator, meta, instance }, idx) => {
const paneIndex = nextPaneIndex++;
indicatorPanes.set(indicator.id, paneIndex);
// Use existing pane index if already assigned, otherwise create new one
let paneIndex = indicatorPanes.get(indicator.id);
if (paneIndex === undefined) {
paneIndex = nextPaneIndex++;
indicatorPanes.set(indicator.id, paneIndex);
}
console.log(`[Indicators] Processing pane: ${indicator.name} (pane ${paneIndex})`);
console.log(`[Indicators] Before renderIndicatorOnPane: indicator.cachedResults length = ${indicator.cachedResults?.length || 0}`);