Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增setLastTimestamp方法,设置一个时间戳,超过时间戳的K线不会绘制但是计算时间戳 #569

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 12 additions & 0 deletions src/store/ChartStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -191,6 +195,10 @@ export default class ChartStore {
return this
}

setLatestTime (latestTime: number): void {
this._latestTime = latestTime
}

getStyles (): Styles {
return this._styles
}
Expand Down Expand Up @@ -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<void> {
let success = false
let adjustFlag = false
Expand Down
5 changes: 5 additions & 0 deletions src/view/CandleBarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down