From 2a9278263b4533dd82007c5cb04b30b50261010b Mon Sep 17 00:00:00 2001 From: machines Date: Fri, 14 Jun 2024 13:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EsetLastTimestamp=E6=96=B9?= =?UTF-8?q?=E6=B3=95,=E8=AE=BE=E7=BD=AE=E4=B8=80=E4=B8=AA=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=EF=BC=8C=E8=B6=85=E8=BF=87=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=E7=9A=84K=E7=BA=BF=E4=B8=8D=E4=BC=9A=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E4=BD=86=E6=98=AF=E8=AE=A1=E7=AE=97=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Chart.ts | 5 +++++ src/store/ChartStore.ts | 12 ++++++++++++ src/view/CandleBarView.ts | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/src/Chart.ts b/src/Chart.ts index b336ed30d..15894afdf 100644 --- a/src/Chart.ts +++ b/src/Chart.ts @@ -89,6 +89,7 @@ export interface Chart { setLeftMinVisibleBarCount: (barCount: number) => void setRightMinVisibleBarCount: (barCount: number) => void setBarSpace: (space: number) => void + setLastTimestamp: (timestamp: number) => void getBarSpace: () => number getVisibleRange: () => VisibleRange clearData: () => void @@ -658,6 +659,10 @@ export default class ChartImp implements Chart { this._chartStore.getTimeScaleStore().setBarSpace(space) } + setLastTimestamp (timestamp: number): void { + this._chartStore.setLatestTime(timestamp) + } + getBarSpace (): number { return this._chartStore.getTimeScaleStore().getBarSpace().bar } diff --git a/src/store/ChartStore.ts b/src/store/ChartStore.ts index 0a9dd4f7e..382d1d6be 100644 --- a/src/store/ChartStore.ts +++ b/src/store/ChartStore.ts @@ -76,6 +76,10 @@ export default class ChartStore { */ private _dataList: KLineData[] = [] + /** + * Chart Limit Time + */ + private _latestTime = -1 /** * Load more data callback * Since v9.8.0 deprecated, since v10 removed @@ -191,6 +195,10 @@ export default class ChartStore { return this } + setLatestTime (latestTime: number): void { + this._latestTime = latestTime + } + getStyles (): Styles { return this._styles } @@ -234,6 +242,10 @@ export default class ChartStore { return this._visibleDataList } + getLatestTime (): number { + return this._latestTime + } + async addData (data: KLineData | KLineData[], type?: LoadDataType, more?: boolean): Promise { let success = false let adjustFlag = false diff --git a/src/view/CandleBarView.ts b/src/view/CandleBarView.ts index e051bceae..224fa8424 100644 --- a/src/view/CandleBarView.ts +++ b/src/view/CandleBarView.ts @@ -76,6 +76,11 @@ export default class CandleBarView extends ChildrenView { colors[1] = styles.noChangeBorderColor colors[2] = styles.noChangeWickColor } + if (kLineData.timestamp > chartStore.getLatestTime()) { + colors[0] = '#00000000' + colors[1] = '#00000000' + colors[2] = '#00000000' + } const openY = yAxis.convertToPixel(open) const closeY = yAxis.convertToPixel(close) const priceY = [