라벨 중복문제 수정

This commit is contained in:
Macbook
2026-05-26 22:45:54 +09:00
parent a4830e9bd8
commit 94e96b9a9b
9 changed files with 388 additions and 43 deletions
+71
View File
@@ -467,6 +467,7 @@ export class ChartManager {
// ─── Theme ──────────────────────────────────────────────────────────────
setTheme(theme: Theme): void {
this.currentTheme = theme;
const t = getTheme(theme);
this.chart.applyOptions({
layout: { background: { type: ColorType.Solid, color: t.bgColor }, textColor: t.textColor },
@@ -475,6 +476,59 @@ export class ChartManager {
timeScale: { borderColor: t.borderColor },
rightPriceScale: { borderColor: t.borderColor },
});
this._applyMainSeriesTheme(t);
this._applyVolumeSeriesTheme(t);
}
private _applyMainSeriesTheme(t: ThemeTokens): void {
if (!this.mainSeries) return;
switch (this.currentChartType) {
case 'candlestick':
this.mainSeries.applyOptions({
upColor: t.upColor,
downColor: t.downColor,
borderUpColor: t.upColor,
borderDownColor: t.downColor,
wickUpColor: t.upColor,
wickDownColor: t.downColor,
});
break;
case 'bar':
this.mainSeries.applyOptions({ upColor: t.upColor, downColor: t.downColor });
break;
default:
break;
}
}
private _applyVolumeSeriesTheme(t: ThemeTokens): void {
if (!this.volumeSeries || this.rawBars.length === 0) return;
this.volumeSeries.setData(this.rawBars.map(b => ({
time: b.time as Time,
value: b.volume,
color: b.close >= b.open ? `${t.upColor}88` : `${t.downColor}88`,
})));
}
private _discardIndicatorSeries(
seriesList: ISeriesApi<SeriesType>[],
options?: { cloudPlugin?: IchimokuCloudPlugin; fillPrimitive?: IndicatorFillPrimitive },
): void {
if (options?.cloudPlugin) {
for (const s of seriesList) {
try { s.detachPrimitive(options.cloudPlugin); } catch { /* ok */ }
}
}
if (options?.fillPrimitive && seriesList[0]) {
try { seriesList[0].detachPrimitive(options.fillPrimitive); } catch { /* ok */ }
}
for (const s of seriesList) {
try { this.chart.removeSeries(s); } catch { /* ok */ }
}
}
private _indicatorLoadStale(loadGen: number): boolean {
return loadGen !== this._dataGeneration;
}
// ─── Indicators ─────────────────────────────────────────────────────────
@@ -505,6 +559,10 @@ export class ChartManager {
// ─── 일목균형표 특별 처리 ────────────────────────────────────────────
if (config.type === 'IchimokuCloud') {
const { cloudPlugin, seriesMeta: ichiMeta } = await this._addIchimokuSeries(result, pane, config, seriesList);
if (this._indicatorLoadStale(dataGenAtStart) || this.indicators.has(config.id)) {
this._discardIndicatorSeries(seriesList, { cloudPlugin });
return;
}
this.indicators.set(config.id, { id: config.id, type: config.type, seriesList, seriesMeta: ichiMeta, paneIndex: pane, alertLines: [], hlineRefs: [], config, cloudPlugin });
this.applyIndicatorStyle(config);
return;
@@ -593,6 +651,10 @@ export class ChartManager {
id: config.id, type: config.type, seriesList, seriesMeta,
paneIndex: pane, alertLines: [], hlineRefs, fillPrimitive, config,
};
if (this._indicatorLoadStale(dataGenAtStart) || this.indicators.has(config.id)) {
this._discardIndicatorSeries(seriesList, { fillPrimitive });
return;
}
this.indicators.set(config.id, entry);
this.applyIndicatorStyle(config);
if (config.type === 'BollingerBands' && !indicatorHidden) {
@@ -613,6 +675,10 @@ export class ChartManager {
* reloadAll 과 달리 setData()를 호출하지 않으므로 메인 캔들 차트가 깜빡이지 않는다.
*/
async reloadIndicatorsOnly(inds: import('../types').IndicatorConfig[]): Promise<void> {
this.cancelPendingIndicatorUpdates();
this._dataGeneration += 1;
const loadGen = this._dataGeneration;
// ① 기존 보조지표 시리즈 모두 제거 (메인·볼륨 제외)
for (const entry of this.indicators.values()) {
if (entry.cloudPlugin) {
@@ -632,6 +698,7 @@ export class ChartManager {
// ② 새 순서로 재추가 (병합 호스트 → 멤버 순)
this._indRunning = false;
for (const ind of sortIndicatorsForPaneLoad(inds)) {
if (this._indicatorLoadStale(loadGen)) break;
await this.addIndicator(ind);
}
@@ -1293,6 +1360,9 @@ export class ChartManager {
* 심볼/타임프레임 변경 시 사용. 실시간 수신 시에는 appendBar()를 사용할 것.
*/
async recalculateIndicators(newBars: OHLCVBar[]): Promise<void> {
this.cancelPendingIndicatorUpdates();
this._dataGeneration += 1;
const loadGen = this._dataGeneration;
this.rawBars = newBars;
const configs = Array.from(this.indicators.values()).map(e => e.config);
@@ -1307,6 +1377,7 @@ export class ChartManager {
this._removeExtraSubPanes();
for (const cfg of configs) {
if (this._indicatorLoadStale(loadGen)) break;
await this.addIndicator(cfg);
}
}