실시간 차트 멀티모드 수정
This commit is contained in:
@@ -363,19 +363,43 @@ export class ChartManager {
|
||||
|
||||
this._reapplyAllPatternMarkers();
|
||||
|
||||
// 이전 timeScale visible range를 완전히 리셋
|
||||
// 종목 전환·초기 로드 — bar 수가 적을 때 음수 logical from 은 캔들이 우측으로 몰림
|
||||
this._applyDefaultVisibleRange(200, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 표시용 visible range 설정.
|
||||
* bar < displayCount 이면 fitContent (음수 logical index 사용 금지).
|
||||
*/
|
||||
private _applyDefaultVisibleRange(displayCount: number, extendFutureBars = 0): void {
|
||||
const bars = this.rawBars;
|
||||
if (!bars || bars.length < 2) return;
|
||||
|
||||
const ts = this.chart.timeScale();
|
||||
if (bars.length >= 2) {
|
||||
if (bars.length < 20) {
|
||||
ts.setVisibleLogicalRange({ from: bars.length - 200, to: bars.length + 5 });
|
||||
} else {
|
||||
|
||||
if (bars.length <= displayCount) {
|
||||
if (extendFutureBars > 0) {
|
||||
let to: number = bars[bars.length - 1].time as number;
|
||||
to += extendFutureBars * this._barIntervalSecs();
|
||||
ts.setVisibleRange({
|
||||
from: bars[0].time as Time,
|
||||
to: bars[bars.length - 1].time as Time,
|
||||
to: to as Time,
|
||||
});
|
||||
} else {
|
||||
ts.fitContent();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const startIdx = Math.max(0, bars.length - displayCount);
|
||||
let to: number = bars[bars.length - 1].time as number;
|
||||
if (extendFutureBars > 0) {
|
||||
to += extendFutureBars * this._barIntervalSecs();
|
||||
}
|
||||
ts.setVisibleRange({
|
||||
from: bars[startIdx].time as Time,
|
||||
to: to as Time,
|
||||
});
|
||||
}
|
||||
|
||||
private _createMainSeries(chartType: ChartType, t: ThemeTokens): ISeriesApi<SeriesType> {
|
||||
@@ -2397,30 +2421,7 @@ export class ChartManager {
|
||||
* @param extendFutureBars 마지막 바 이후 추가로 보여줄 바 수 (기본 0)
|
||||
*/
|
||||
setInitialVisibleRange(displayCount: number, extendFutureBars = 0): void {
|
||||
const bars = this.rawBars;
|
||||
if (!bars || bars.length === 0) return;
|
||||
|
||||
const ts = this.chart.timeScale();
|
||||
|
||||
if (bars.length <= displayCount && extendFutureBars === 0) {
|
||||
if (bars.length < 20) {
|
||||
ts.setVisibleLogicalRange({ from: bars.length - displayCount, to: bars.length + 5 });
|
||||
} else {
|
||||
ts.fitContent();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const startIdx = Math.max(0, bars.length - displayCount);
|
||||
const from = bars[startIdx].time as number;
|
||||
let to: number = bars[bars.length - 1].time as number;
|
||||
|
||||
if (extendFutureBars > 0) {
|
||||
const interval = this._barIntervalSecs();
|
||||
to = to + extendFutureBars * interval;
|
||||
}
|
||||
|
||||
ts.setVisibleRange({ from: from as Time, to: to as Time });
|
||||
this._applyDefaultVisibleRange(displayCount, extendFutureBars);
|
||||
}
|
||||
|
||||
/** 일목균형표가 활성화되어 있는지 여부 */
|
||||
|
||||
Reference in New Issue
Block a user