보조지표 합치기, 분리, 복사하기 기능 오류 수정
This commit is contained in:
@@ -34,7 +34,7 @@ import {
|
||||
normalizeChartTimeFormat,
|
||||
} from './chartTimeFormat';
|
||||
import { DEFAULT_DISPLAY_TIMEZONE } from './timezone';
|
||||
import { sortIndicatorsForPaneLoad } from './indicatorPaneMerge';
|
||||
import { getPaneHostId, sortIndicatorsForPaneLoad } from './indicatorPaneMerge';
|
||||
import { calculateIndicator, enrichIndicatorConfig, getIndicatorDef, getHLineLabel, type PlotData, type MarkerData } from './indicatorRegistry';
|
||||
import { IchimokuCloudPlugin, type IchimokuCloudPoint } from './IchimokuCloudPlugin';
|
||||
|
||||
@@ -808,6 +808,8 @@ export class ChartManager {
|
||||
private _finalizeIndicatorPaneLayout(): void {
|
||||
this._removeOrphanSubPanes();
|
||||
if (this._activeIndicatorPaneIndices().size > 0) {
|
||||
this._resyncIndicatorPaneIndices();
|
||||
this._splitCollidingIndicatorPanes();
|
||||
this._resyncIndicatorPaneIndices();
|
||||
this._applyAllSeriesPriceFormats();
|
||||
} else {
|
||||
@@ -929,6 +931,8 @@ export class ChartManager {
|
||||
this._removeOrphanSubPanes();
|
||||
this._trimTrailingEmptySubPanes();
|
||||
this._resyncIndicatorPaneIndices();
|
||||
this._splitCollidingIndicatorPanes();
|
||||
this._resyncIndicatorPaneIndices();
|
||||
this.resetPaneHeights(this._lastLayoutAvailableHeight);
|
||||
this._notifyPaneLayout();
|
||||
}
|
||||
@@ -1420,21 +1424,71 @@ export class ChartManager {
|
||||
private _collectUsedSubPaneIndices(): Set<number> {
|
||||
const indices = new Set<number>();
|
||||
for (const entry of this.indicators.values()) {
|
||||
let found = false;
|
||||
let pane = -1;
|
||||
for (const series of entry.seriesList) {
|
||||
const pi = this._readSeriesPaneIndex(series);
|
||||
if (pi >= 2) {
|
||||
indices.add(pi);
|
||||
found = true;
|
||||
}
|
||||
if (pi >= 2) pane = Math.max(pane, pi);
|
||||
}
|
||||
if (!found && entry.paneIndex != null && entry.paneIndex >= 2) {
|
||||
indices.add(entry.paneIndex);
|
||||
if (pane < 2 && entry.paneIndex != null && entry.paneIndex >= 2) {
|
||||
pane = entry.paneIndex;
|
||||
}
|
||||
if (pane >= 2) indices.add(pane);
|
||||
}
|
||||
return indices;
|
||||
}
|
||||
|
||||
private _indicatorConfigsFromMap(): IndicatorConfig[] {
|
||||
return Array.from(this.indicators.values()).map(e => e.config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 병합(mergedWith)이 아닌 서로 다른 호스트가 같은 sub-pane에 붙어 있으면 분리.
|
||||
* entry.paneIndex 와 실제 시리즈 pane 불일치·지표 제거 후 재추가 시 겹침 방지.
|
||||
*/
|
||||
private _splitCollidingIndicatorPanes(): void {
|
||||
const configs = this._indicatorConfigsFromMap();
|
||||
const hostsByPane = new Map<number, string[]>();
|
||||
|
||||
for (const [id, entry] of this.indicators) {
|
||||
const hostId = getPaneHostId(id, configs);
|
||||
if (id !== hostId) continue;
|
||||
|
||||
const def = getIndicatorDef(entry.type);
|
||||
if (def?.overlay || def?.returnsMarkers || entry.seriesList.length === 0) continue;
|
||||
|
||||
let pi = -1;
|
||||
for (const series of entry.seriesList) {
|
||||
pi = Math.max(pi, this._readSeriesPaneIndex(series));
|
||||
}
|
||||
if (pi < 2 && entry.paneIndex != null && entry.paneIndex >= 2) pi = entry.paneIndex;
|
||||
if (pi < 2) continue;
|
||||
|
||||
const list = hostsByPane.get(pi) ?? [];
|
||||
if (!list.includes(hostId)) list.push(hostId);
|
||||
hostsByPane.set(pi, list);
|
||||
}
|
||||
|
||||
let changed = false;
|
||||
for (const hostIds of hostsByPane.values()) {
|
||||
if (hostIds.length <= 1) continue;
|
||||
for (let i = 1; i < hostIds.length; i++) {
|
||||
const hostId = hostIds[i];
|
||||
const target = this._getNextSubPane();
|
||||
for (const [mid, ment] of this.indicators) {
|
||||
if (getPaneHostId(mid, configs) !== hostId) continue;
|
||||
for (const series of ment.seriesList) {
|
||||
try {
|
||||
series.moveToPane(target);
|
||||
} catch { /* ok */ }
|
||||
}
|
||||
ment.paneIndex = target;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) this._removeOrphanSubPanes();
|
||||
}
|
||||
|
||||
private _getNextSubPane(): number {
|
||||
const used = this._collectUsedSubPaneIndices();
|
||||
let pane = 2;
|
||||
@@ -1815,9 +1869,13 @@ export class ChartManager {
|
||||
this._reapplyAllPatternMarkers();
|
||||
this._removeExtraSubPanes();
|
||||
|
||||
for (const cfg of configs) {
|
||||
const sorted = sortIndicatorsForPaneLoad(configs);
|
||||
for (const cfg of sorted) {
|
||||
if (this._indicatorLoadStale(loadGen)) break;
|
||||
await this.addIndicator(cfg);
|
||||
await this.addIndicator(cfg, { skipLayout: true });
|
||||
}
|
||||
if (!this._indicatorLoadStale(loadGen)) {
|
||||
this._finalizeIndicatorPaneLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user