chart error fix on slow network

This commit is contained in:
Macbook
2026-05-30 03:13:07 +09:00
parent b4dcebf758
commit e7a6c22cc2
3 changed files with 103 additions and 16 deletions
+26
View File
@@ -3435,6 +3435,32 @@ export class ChartManager {
this.mainSeries?.priceScale().setAutoScale(true);
}
/**
* 느린 네트워크·레이아웃 지연 후 가격축이 0~수억처럼 비정상인지 감지.
* (마지막 종가가 가시 범위 밖이거나, 범위 하한이 0 이하인 경우)
*/
isMainPriceScaleLikelyCorrupt(): boolean {
if (!this.mainSeries || this.rawBars.length < 2) return false;
const lastClose = this.rawBars[this.rawBars.length - 1].close;
if (!Number.isFinite(lastClose) || lastClose <= 0) return false;
const main = this.getPaneLayouts().find(l => l.paneIndex === 0);
if (!main || main.height < 24) return true;
try {
const topPrice = this.mainSeries.coordinateToPrice(4);
const bottomPrice = this.mainSeries.coordinateToPrice(main.height - 4);
if (topPrice == null || bottomPrice == null) return false;
const lo = Math.min(topPrice, bottomPrice);
const hi = Math.max(topPrice, bottomPrice);
if (lo <= 0) return true;
if (lastClose < lo * 0.5 || lastClose > hi * 2) return true;
} catch {
return false;
}
return false;
}
/**
* 크로스헤어 파라미터에서 보조지표 시리즈 값 추출
* { indicatorType → [plot0 값, plot1 값, ...] }