mirror of
https://github.com/klinecharts/KLineChart.git
synced 2024-11-25 16:22:43 +08:00
parent
420cfa4dc3
commit
9d119f56d6
@ -21,8 +21,7 @@ export default [
|
||||
"file-progress/activate": 1,
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/class-methods-use-this": "off",
|
||||
"@typescript-eslint/max-params": "off",
|
||||
"accessor-pairs": "off"
|
||||
"@typescript-eslint/max-params": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
108
src/Chart.ts
108
src/Chart.ts
@ -303,7 +303,7 @@ export default class ChartImp implements Chart {
|
||||
|
||||
private _measurePaneHeight (): void {
|
||||
const totalHeight = this._chartBounding.height
|
||||
const separatorSize = this._chartStore.styles.separator.size
|
||||
const separatorSize = this._chartStore.getStyles().separator.size
|
||||
const xAxisHeight = this._xAxisPane.getAxisComponent().getAutoSize()
|
||||
let remainingHeight = totalHeight - xAxisHeight
|
||||
if (remainingHeight < 0) {
|
||||
@ -390,7 +390,7 @@ export default class ChartImp implements Chart {
|
||||
|
||||
private _measurePaneWidth (): void {
|
||||
const totalWidth = this._chartBounding.width
|
||||
const styles = this._chartStore.styles
|
||||
const styles = this._chartStore.getStyles()
|
||||
|
||||
let leftYAxisWidth = 0
|
||||
let leftYAxisOutside = true
|
||||
@ -429,7 +429,7 @@ export default class ChartImp implements Chart {
|
||||
mainRight = rightYAxisWidth
|
||||
}
|
||||
|
||||
this._chartStore.timeScaleStore.totalBarSpace = mainWidth
|
||||
this._chartStore.getTimeScaleStore().setTotalBarSpace(mainWidth)
|
||||
|
||||
const paneBounding = { width: totalWidth }
|
||||
const mainBounding = { width: mainWidth, left: mainLeft, right: mainRight }
|
||||
@ -545,13 +545,13 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
crosshairChange (crosshair: Crosshair): void {
|
||||
const actionStore = this._chartStore.actionStore
|
||||
const actionStore = this._chartStore.getActionStore()
|
||||
if (actionStore.has(ActionType.OnCrosshairChange)) {
|
||||
const indicatorData = {}
|
||||
this._drawPanes.forEach(pane => {
|
||||
const id = pane.getId()
|
||||
const paneIndicatorData = {}
|
||||
const indicators = this._chartStore.indicatorStore.getInstanceByPaneId(id)
|
||||
const indicators = this._chartStore.getIndicatorStore().getInstanceByPaneId(id)
|
||||
indicators.forEach(indicator => {
|
||||
const result = indicator.result
|
||||
paneIndicatorData[indicator.name] = result[crosshair.dataIndex ?? result.length - 1]
|
||||
@ -614,53 +614,53 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
setStyles (styles: string | DeepPartial<Styles>): void {
|
||||
this._chartStore.options = { styles }
|
||||
this._chartStore.setOptions({ styles })
|
||||
this.adjustPaneViewport(true, true, true, true, true)
|
||||
}
|
||||
|
||||
getStyles (): Styles {
|
||||
return this._chartStore.styles
|
||||
return this._chartStore.getStyles()
|
||||
}
|
||||
|
||||
setLocale (locale: string): void {
|
||||
this._chartStore.options = { locale }
|
||||
this._chartStore.setOptions({ locale })
|
||||
this.adjustPaneViewport(true, true, true, true, true)
|
||||
}
|
||||
|
||||
getLocale (): string {
|
||||
return this._chartStore.locale
|
||||
return this._chartStore.getLocale()
|
||||
}
|
||||
|
||||
setCustomApi (customApi: Partial<CustomApi>): void {
|
||||
this._chartStore.options = { customApi }
|
||||
this._chartStore.setOptions({ customApi })
|
||||
this.adjustPaneViewport(true, true, true, true, true)
|
||||
}
|
||||
|
||||
setPriceVolumePrecision (pricePrecision: number, volumePrecision: number): void {
|
||||
this._chartStore.precision = { price: pricePrecision, volume: volumePrecision }
|
||||
this._chartStore.setPrecision({ price: pricePrecision, volume: volumePrecision })
|
||||
}
|
||||
|
||||
getPriceVolumePrecision (): Precision {
|
||||
return this._chartStore.precision
|
||||
return this._chartStore.getPrecision()
|
||||
}
|
||||
|
||||
setTimezone (timezone: string): void {
|
||||
this._chartStore.options = { timezone }
|
||||
this._chartStore.setOptions({ timezone })
|
||||
const axis = (this._xAxisPane.getAxisComponent() as unknown as AxisImp)
|
||||
axis.buildTicks(true)
|
||||
this._xAxisPane.update(UpdateLevel.Drawer)
|
||||
}
|
||||
|
||||
getTimezone (): string {
|
||||
return this._chartStore.timeScaleStore.timezone
|
||||
return this._chartStore.getTimeScaleStore().getTimezone()
|
||||
}
|
||||
|
||||
setOffsetRightDistance (distance: number): void {
|
||||
this._chartStore.timeScaleStore.setOffsetRightDistance(distance, true)
|
||||
this._chartStore.getTimeScaleStore().setOffsetRightDistance(distance, true)
|
||||
}
|
||||
|
||||
getOffsetRightDistance (): number {
|
||||
return this._chartStore.timeScaleStore.offsetRightDistance
|
||||
return this._chartStore.getTimeScaleStore().getOffsetRightDistance()
|
||||
}
|
||||
|
||||
setMaxOffsetLeftDistance (distance: number): void {
|
||||
@ -668,7 +668,7 @@ export default class ChartImp implements Chart {
|
||||
logWarn('setMaxOffsetLeftDistance', 'distance', 'distance must greater than zero!!!')
|
||||
return
|
||||
}
|
||||
this._chartStore.timeScaleStore.maxOffsetLeftDistance = distance
|
||||
this._chartStore.getTimeScaleStore().setMaxOffsetLeftDistance(distance)
|
||||
}
|
||||
|
||||
setMaxOffsetRightDistance (distance: number): void {
|
||||
@ -676,7 +676,7 @@ export default class ChartImp implements Chart {
|
||||
logWarn('setMaxOffsetRightDistance', 'distance', 'distance must greater than zero!!!')
|
||||
return
|
||||
}
|
||||
this._chartStore.timeScaleStore.maxOffsetRightDistance = distance
|
||||
this._chartStore.getTimeScaleStore().setMaxOffsetRightDistance(distance)
|
||||
}
|
||||
|
||||
setLeftMinVisibleBarCount (barCount: number): void {
|
||||
@ -684,7 +684,7 @@ export default class ChartImp implements Chart {
|
||||
logWarn('setLeftMinVisibleBarCount', 'barCount', 'barCount must greater than zero!!!')
|
||||
return
|
||||
}
|
||||
this._chartStore.timeScaleStore.leftMinVisibleBarCount = Math.ceil(barCount)
|
||||
this._chartStore.getTimeScaleStore().setLeftMinVisibleBarCount(Math.ceil(barCount))
|
||||
}
|
||||
|
||||
setRightMinVisibleBarCount (barCount: number): void {
|
||||
@ -692,19 +692,19 @@ export default class ChartImp implements Chart {
|
||||
logWarn('setRightMinVisibleBarCount', 'barCount', 'barCount must greater than zero!!!')
|
||||
return
|
||||
}
|
||||
this._chartStore.timeScaleStore.rightMinVisibleBarCount = Math.ceil(barCount)
|
||||
this._chartStore.getTimeScaleStore().setRightMinVisibleBarCount(Math.ceil(barCount))
|
||||
}
|
||||
|
||||
setBarSpace (space: number): void {
|
||||
this._chartStore.timeScaleStore.setBarSpace(space)
|
||||
this._chartStore.getTimeScaleStore().setBarSpace(space)
|
||||
}
|
||||
|
||||
getBarSpace (): number {
|
||||
return this._chartStore.timeScaleStore.garSpace.bar
|
||||
return this._chartStore.getTimeScaleStore().getBarSpace().bar
|
||||
}
|
||||
|
||||
getVisibleRange (): VisibleRange {
|
||||
return this._chartStore.timeScaleStore.visibleRange
|
||||
return this._chartStore.getTimeScaleStore().getVisibleRange()
|
||||
}
|
||||
|
||||
clearData (): void {
|
||||
@ -712,7 +712,7 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
getDataList (): KLineData[] {
|
||||
return this._chartStore.dataList
|
||||
return this._chartStore.getDataList()
|
||||
}
|
||||
|
||||
applyNewData (data: KLineData[], more?: boolean | Partial<LoadDataMore>): void {
|
||||
@ -734,7 +734,7 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
setLoadMoreDataCallback (cb: LoadDataCallback): void {
|
||||
this._chartStore.loadMoreDataCallback = cb
|
||||
this._chartStore.setLoadMoreDataCallback(cb)
|
||||
}
|
||||
|
||||
createIndicator (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: Nullable<PaneOptions>): Nullable<string> {
|
||||
@ -747,7 +747,7 @@ export default class ChartImp implements Chart {
|
||||
let paneId = paneOptions?.id
|
||||
const currentPane = this.getDrawPaneById(paneId ?? '')
|
||||
if (currentPane !== null) {
|
||||
const result = this._chartStore.indicatorStore.addInstance(indicator, paneId ?? '', isStack ?? false)
|
||||
const result = this._chartStore.getIndicatorStore().addInstance(indicator, paneId ?? '', isStack ?? false)
|
||||
if (result) {
|
||||
this._setPaneOptions(paneOptions ?? {}, (currentPane.getAxisComponent() as AxisImp).buildTicks(true) ?? false)
|
||||
}
|
||||
@ -756,7 +756,7 @@ export default class ChartImp implements Chart {
|
||||
const pane = this._createPane(IndicatorPane, paneId, paneOptions ?? {})
|
||||
const height = paneOptions?.height ?? PANE_DEFAULT_HEIGHT
|
||||
pane.setOriginalBounding({ height })
|
||||
const result = this._chartStore.indicatorStore.addInstance(indicator, paneId, isStack ?? false)
|
||||
const result = this._chartStore.getIndicatorStore().addInstance(indicator, paneId, isStack ?? false)
|
||||
if (result) {
|
||||
this.adjustPaneViewport(true, true, true, true, true)
|
||||
}
|
||||
@ -765,18 +765,18 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
overrideIndicator (override: IndicatorCreate): void {
|
||||
const result = this._chartStore.indicatorStore.override(override)
|
||||
const result = this._chartStore.getIndicatorStore().override(override)
|
||||
if (result) {
|
||||
this.adjustPaneViewport(false, false, true)
|
||||
}
|
||||
}
|
||||
|
||||
getIndicators (filter?: IndicatorFilter): Map<string, Indicator[]> {
|
||||
return this._chartStore.indicatorStore.getInstanceByFilter(filter ?? {})
|
||||
return this._chartStore.getIndicatorStore().getInstanceByFilter(filter ?? {})
|
||||
}
|
||||
|
||||
removeIndicator (filter?: IndicatorFilter): void {
|
||||
const indicatorStore = this._chartStore.indicatorStore
|
||||
const indicatorStore = this._chartStore.getIndicatorStore()
|
||||
const removed = indicatorStore.removeInstance(filter ?? {})
|
||||
if (removed) {
|
||||
let shouldMeasureHeight = false
|
||||
@ -853,7 +853,7 @@ export default class ChartImp implements Chart {
|
||||
} else {
|
||||
build(value as OverlayCreate)
|
||||
}
|
||||
const ids = this._chartStore.overlayStore.addInstances(overlays, appointPaneFlags)
|
||||
const ids = this._chartStore.getOverlayStore().addInstances(overlays, appointPaneFlags)
|
||||
if (isArray(value)) {
|
||||
return ids
|
||||
}
|
||||
@ -861,15 +861,15 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
getOverlays (filter?: OverlayFilter): Map<string, Overlay[]> {
|
||||
return this._chartStore.overlayStore.getInstanceByFilter(filter ?? {})
|
||||
return this._chartStore.getOverlayStore().getInstanceByFilter(filter ?? {})
|
||||
}
|
||||
|
||||
overrideOverlay (override: Partial<OverlayCreate>): void {
|
||||
this._chartStore.overlayStore.override(override)
|
||||
this._chartStore.getOverlayStore().override(override)
|
||||
}
|
||||
|
||||
removeOverlay (filter?: OverlayFilter): void {
|
||||
this._chartStore.overlayStore.removeInstance(filter ?? {})
|
||||
this._chartStore.getOverlayStore().removeInstance(filter ?? {})
|
||||
}
|
||||
|
||||
setPaneOptions (options: PaneOptions): void {
|
||||
@ -877,24 +877,24 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
setZoomEnabled (enabled: boolean): void {
|
||||
this._chartStore.timeScaleStore.zoomEnabled = enabled
|
||||
this._chartStore.getTimeScaleStore().setZoomEnabled(enabled)
|
||||
}
|
||||
|
||||
isZoomEnabled (): boolean {
|
||||
return this._chartStore.timeScaleStore.zoomEnabled
|
||||
return this._chartStore.getTimeScaleStore().getZoomEnabled()
|
||||
}
|
||||
|
||||
setScrollEnabled (enabled: boolean): void {
|
||||
this._chartStore.timeScaleStore.scrollEnabled = enabled
|
||||
this._chartStore.getTimeScaleStore().setScrollEnabled(enabled)
|
||||
}
|
||||
|
||||
isScrollEnabled (): boolean {
|
||||
return this._chartStore.timeScaleStore.scrollEnabled
|
||||
return this._chartStore.getTimeScaleStore().getScrollEnabled()
|
||||
}
|
||||
|
||||
scrollByDistance (distance: number, animationDuration?: number): void {
|
||||
const duration = isNumber(animationDuration) && animationDuration > 0 ? animationDuration : 0
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
const timeScaleStore = this._chartStore.getTimeScaleStore()
|
||||
timeScaleStore.startScroll()
|
||||
if (duration > 0) {
|
||||
const animation = new Animation({ duration })
|
||||
@ -909,18 +909,18 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
scrollToRealTime (animationDuration?: number): void {
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
const { bar: barSpace } = timeScaleStore.garSpace
|
||||
const difBarCount = timeScaleStore.lastBarRightSideDiffBarCount - timeScaleStore.initialOffsetRightDistance / barSpace
|
||||
const timeScaleStore = this._chartStore.getTimeScaleStore()
|
||||
const { bar: barSpace } = timeScaleStore.getBarSpace()
|
||||
const difBarCount = timeScaleStore.getLastBarRightSideDiffBarCount() - timeScaleStore.getInitialOffsetRightDistance() / barSpace
|
||||
const distance = difBarCount * barSpace
|
||||
this.scrollByDistance(distance, animationDuration)
|
||||
}
|
||||
|
||||
scrollToDataIndex (dataIndex: number, animationDuration?: number): void {
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
const timeScaleStore = this._chartStore.getTimeScaleStore()
|
||||
const distance = (
|
||||
timeScaleStore.lastBarRightSideDiffBarCount + (this.getDataList().length - 1 - dataIndex)
|
||||
) * timeScaleStore.garSpace.bar
|
||||
timeScaleStore.getLastBarRightSideDiffBarCount() + (this.getDataList().length - 1 - dataIndex)
|
||||
) * timeScaleStore.getBarSpace().bar
|
||||
this.scrollByDistance(distance, animationDuration)
|
||||
}
|
||||
|
||||
@ -931,8 +931,8 @@ export default class ChartImp implements Chart {
|
||||
|
||||
zoomAtCoordinate (scale: number, coordinate?: Coordinate, animationDuration?: number): void {
|
||||
const duration = isNumber(animationDuration) && animationDuration > 0 ? animationDuration : 0
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
const { bar: barSpace } = timeScaleStore.garSpace
|
||||
const timeScaleStore = this._chartStore.getTimeScaleStore()
|
||||
const { bar: barSpace } = timeScaleStore.getBarSpace()
|
||||
const scaleBarSpace = barSpace * scale
|
||||
const difSpace = scaleBarSpace - barSpace
|
||||
if (duration > 0) {
|
||||
@ -940,7 +940,7 @@ export default class ChartImp implements Chart {
|
||||
const animation = new Animation({ duration })
|
||||
animation.doFrame(frameTime => {
|
||||
const progressBarSpace = difSpace * (frameTime / duration)
|
||||
const scale = (progressBarSpace - prevProgressBarSpace) / timeScaleStore.garSpace.bar * SCALE_MULTIPLIER
|
||||
const scale = (progressBarSpace - prevProgressBarSpace) / timeScaleStore.getBarSpace().bar * SCALE_MULTIPLIER
|
||||
timeScaleStore.zoom(scale, coordinate)
|
||||
prevProgressBarSpace = progressBarSpace
|
||||
})
|
||||
@ -951,7 +951,7 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
zoomAtDataIndex (scale: number, dataIndex: number, animationDuration?: number): void {
|
||||
const x = this._chartStore.timeScaleStore.dataIndexToCoordinate(dataIndex)
|
||||
const x = this._chartStore.getTimeScaleStore().dataIndexToCoordinate(dataIndex)
|
||||
this.zoomAtCoordinate(scale, { x, y: 0 }, animationDuration)
|
||||
}
|
||||
|
||||
@ -966,7 +966,7 @@ export default class ChartImp implements Chart {
|
||||
if (paneId !== PaneIdConstants.X_AXIS) {
|
||||
const pane = this.getDrawPaneById(paneId)
|
||||
if (pane !== null) {
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
const timeScaleStore = this._chartStore.getTimeScaleStore()
|
||||
const bounding = pane.getBounding()
|
||||
const ps = new Array<Partial<Point>>().concat(points)
|
||||
const xAxis = this._xAxisPane.getAxisComponent()
|
||||
@ -997,7 +997,7 @@ export default class ChartImp implements Chart {
|
||||
if (paneId !== PaneIdConstants.X_AXIS) {
|
||||
const pane = this.getDrawPaneById(paneId)
|
||||
if (pane !== null) {
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
const timeScaleStore = this._chartStore.getTimeScaleStore()
|
||||
const bounding = pane.getBounding()
|
||||
const cs = new Array<Partial<Coordinate>>().concat(coordinates)
|
||||
const xAxis = this._xAxisPane.getAxisComponent()
|
||||
@ -1025,18 +1025,18 @@ export default class ChartImp implements Chart {
|
||||
case ActionType.OnCrosshairChange: {
|
||||
const crosshair: Crosshair = { ...data }
|
||||
crosshair.paneId = crosshair.paneId ?? PaneIdConstants.CANDLE
|
||||
this._chartStore.tooltipStore.setCrosshair(crosshair)
|
||||
this._chartStore.getTooltipStore().setCrosshair(crosshair)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subscribeAction (type: ActionType, callback: ActionCallback): void {
|
||||
this._chartStore.actionStore.subscribe(type, callback)
|
||||
this._chartStore.getActionStore().subscribe(type, callback)
|
||||
}
|
||||
|
||||
unsubscribeAction (type: ActionType, callback?: ActionCallback): void {
|
||||
this._chartStore.actionStore.unsubscribe(type, callback)
|
||||
this._chartStore.getActionStore().unsubscribe(type, callback)
|
||||
}
|
||||
|
||||
getConvertPictureUrl (includeOverlay?: boolean, type?: string, backgroundColor?: string): string {
|
||||
|
50
src/Event.ts
50
src/Event.ts
@ -71,23 +71,23 @@ export default class Event implements EventHandler {
|
||||
if (event.shiftKey) {
|
||||
switch (event.code) {
|
||||
case 'Equal': {
|
||||
this._chart.getChartStore().timeScaleStore.zoom(0.5)
|
||||
this._chart.getChartStore().getTimeScaleStore().zoom(0.5)
|
||||
break
|
||||
}
|
||||
case 'Minus': {
|
||||
this._chart.getChartStore().timeScaleStore.zoom(-0.5)
|
||||
this._chart.getChartStore().getTimeScaleStore().zoom(-0.5)
|
||||
break
|
||||
}
|
||||
case 'ArrowLeft': {
|
||||
const timeScaleStore = this._chart.getChartStore().timeScaleStore
|
||||
const timeScaleStore = this._chart.getChartStore().getTimeScaleStore()
|
||||
timeScaleStore.startScroll()
|
||||
timeScaleStore.scroll(-3 * timeScaleStore.garSpace.bar)
|
||||
timeScaleStore.scroll(-3 * timeScaleStore.getBarSpace().bar)
|
||||
break
|
||||
}
|
||||
case 'ArrowRight': {
|
||||
const timeScaleStore = this._chart.getChartStore().timeScaleStore
|
||||
const timeScaleStore = this._chart.getChartStore().getTimeScaleStore()
|
||||
timeScaleStore.startScroll()
|
||||
timeScaleStore.scroll(3 * timeScaleStore.garSpace.bar)
|
||||
timeScaleStore.scroll(3 * timeScaleStore.getBarSpace().bar)
|
||||
break
|
||||
}
|
||||
default: {
|
||||
@ -119,14 +119,14 @@ export default class Event implements EventHandler {
|
||||
const event = this._makeWidgetEvent(e, widget)
|
||||
const zoomScale = (scale - this._pinchScale) * 5
|
||||
this._pinchScale = scale
|
||||
this._chart.getChartStore().timeScaleStore.zoom(zoomScale, { x: event.x, y: event.y })
|
||||
this._chart.getChartStore().getTimeScaleStore().zoom(zoomScale, { x: event.x, y: event.y })
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
mouseWheelHortEvent (_: MouseTouchEvent, distance: number): boolean {
|
||||
const timeScaleStore = this._chart.getChartStore().timeScaleStore
|
||||
const timeScaleStore = this._chart.getChartStore().getTimeScaleStore()
|
||||
timeScaleStore.startScroll()
|
||||
timeScaleStore.scroll(distance)
|
||||
return true
|
||||
@ -137,7 +137,7 @@ export default class Event implements EventHandler {
|
||||
const event = this._makeWidgetEvent(e, widget)
|
||||
const name = widget?.getName()
|
||||
if (name === WidgetNameConstants.MAIN) {
|
||||
this._chart.getChartStore().timeScaleStore.zoom(scale, { x: event.x, y: event.y })
|
||||
this._chart.getChartStore().getTimeScaleStore().zoom(scale, { x: event.x, y: event.y })
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -157,7 +157,7 @@ export default class Event implements EventHandler {
|
||||
const range = (pane as DrawPane<YAxis>).getAxisComponent().getRange() ?? null
|
||||
this._prevYAxisRange = range === null ? range : { ...range }
|
||||
this._startScrollCoordinate = { x: event.x, y: event.y }
|
||||
this._chart.getChartStore().timeScaleStore.startScroll()
|
||||
this._chart.getChartStore().getTimeScaleStore().startScroll()
|
||||
return widget.dispatchEvent('mouseDownEvent', event)
|
||||
}
|
||||
case WidgetNameConstants.X_AXIS: {
|
||||
@ -202,20 +202,20 @@ export default class Event implements EventHandler {
|
||||
const consumed = widget.dispatchEvent('mouseMoveEvent', event)
|
||||
const chartStore = this._chart.getChartStore()
|
||||
let crosshair: Crosshair | undefined = { x: event.x, y: event.y, paneId: pane?.getId() }
|
||||
if (consumed && chartStore.tooltipStore.getActiveIcon() !== null) {
|
||||
if (consumed && chartStore.getTooltipStore().getActiveIcon() !== null) {
|
||||
crosshair = undefined
|
||||
if (widget !== null) {
|
||||
widget.getContainer().style.cursor = 'pointer'
|
||||
}
|
||||
}
|
||||
this._chart.getChartStore().tooltipStore.setCrosshair(crosshair)
|
||||
this._chart.getChartStore().getTooltipStore().setCrosshair(crosshair)
|
||||
return consumed
|
||||
}
|
||||
case WidgetNameConstants.SEPARATOR:
|
||||
case WidgetNameConstants.X_AXIS:
|
||||
case WidgetNameConstants.Y_AXIS: {
|
||||
const consumed = widget.dispatchEvent('mouseMoveEvent', event)
|
||||
this._chart.getChartStore().tooltipStore.setCrosshair()
|
||||
this._chart.getChartStore().getTooltipStore().setCrosshair()
|
||||
return consumed
|
||||
}
|
||||
}
|
||||
@ -270,9 +270,9 @@ export default class Event implements EventHandler {
|
||||
})
|
||||
}
|
||||
const distance = event.x - this._startScrollCoordinate.x
|
||||
this._chart.getChartStore().timeScaleStore.scroll(distance)
|
||||
this._chart.getChartStore().getTimeScaleStore().scroll(distance)
|
||||
}
|
||||
this._chart.getChartStore().tooltipStore.setCrosshair({ x: event.x, y: event.y, paneId: pane?.getId() })
|
||||
this._chart.getChartStore().getTooltipStore().setCrosshair({ x: event.x, y: event.y, paneId: pane?.getId() })
|
||||
return consumed
|
||||
}
|
||||
case WidgetNameConstants.X_AXIS: {
|
||||
@ -284,7 +284,7 @@ export default class Event implements EventHandler {
|
||||
if (Number.isFinite(scale)) {
|
||||
const zoomScale = (scale - this._xAxisScale) * 10
|
||||
this._xAxisScale = scale
|
||||
this._chart.getChartStore().timeScaleStore.zoom(zoomScale, this._xAxisStartScaleCoordinate ?? undefined)
|
||||
this._chart.getChartStore().getTimeScaleStore().zoom(zoomScale, this._xAxisStartScaleCoordinate ?? undefined)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -413,7 +413,7 @@ export default class Event implements EventHandler {
|
||||
}
|
||||
|
||||
mouseLeaveEvent (): boolean {
|
||||
this._chart.getChartStore().tooltipStore.setCrosshair()
|
||||
this._chart.getChartStore().getTooltipStore().setCrosshair()
|
||||
return true
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ export default class Event implements EventHandler {
|
||||
switch (name) {
|
||||
case WidgetNameConstants.MAIN: {
|
||||
const chartStore = this._chart.getChartStore()
|
||||
const tooltipStore = chartStore.tooltipStore
|
||||
const tooltipStore = chartStore.getTooltipStore()
|
||||
if (widget.dispatchEvent('mouseDownEvent', event)) {
|
||||
this._touchCancelCrosshair = true
|
||||
this._touchCoordinate = null
|
||||
@ -439,7 +439,7 @@ export default class Event implements EventHandler {
|
||||
}
|
||||
this._flingStartTime = new Date().getTime()
|
||||
this._startScrollCoordinate = { x: event.x, y: event.y }
|
||||
chartStore.timeScaleStore.startScroll()
|
||||
chartStore.getTimeScaleStore().startScroll()
|
||||
this._touchZoomed = false
|
||||
if (this._touchCoordinate !== null) {
|
||||
const xDif = event.x - this._touchCoordinate.x
|
||||
@ -475,7 +475,7 @@ export default class Event implements EventHandler {
|
||||
const event = this._makeWidgetEvent(e, widget)
|
||||
const name = widget.getName()
|
||||
const chartStore = this._chart.getChartStore()
|
||||
const tooltipStore = chartStore.tooltipStore
|
||||
const tooltipStore = chartStore.getTooltipStore()
|
||||
switch (name) {
|
||||
case WidgetNameConstants.MAIN: {
|
||||
if (widget.dispatchEvent('pressedMouseMoveEvent', event)) {
|
||||
@ -493,7 +493,7 @@ export default class Event implements EventHandler {
|
||||
Math.abs(this._startScrollCoordinate.x - event.x) > this._startScrollCoordinate.y - event.y
|
||||
) {
|
||||
const distance = event.x - this._startScrollCoordinate.x
|
||||
chartStore.timeScaleStore.scroll(distance)
|
||||
chartStore.getTimeScaleStore().scroll(distance)
|
||||
}
|
||||
}
|
||||
return true
|
||||
@ -525,7 +525,7 @@ export default class Event implements EventHandler {
|
||||
const distance = event.x - this._startScrollCoordinate.x
|
||||
let v = distance / (time > 0 ? time : 1) * 20
|
||||
if (time < 200 && Math.abs(v) > 0) {
|
||||
const timeScaleStore = this._chart.getChartStore().timeScaleStore
|
||||
const timeScaleStore = this._chart.getChartStore().getTimeScaleStore()
|
||||
const flingScroll: (() => void) = () => {
|
||||
this._flingScrollRequestId = requestAnimationFrame(() => {
|
||||
timeScaleStore.startScroll()
|
||||
@ -567,7 +567,7 @@ export default class Event implements EventHandler {
|
||||
if (widget.getName() === WidgetNameConstants.MAIN) {
|
||||
const event = this._makeWidgetEvent(e, widget)
|
||||
const chartStore = this._chart.getChartStore()
|
||||
const tooltipStore = chartStore.tooltipStore
|
||||
const tooltipStore = chartStore.getTooltipStore()
|
||||
if (result) {
|
||||
this._touchCancelCrosshair = true
|
||||
this._touchCoordinate = null
|
||||
@ -598,7 +598,7 @@ export default class Event implements EventHandler {
|
||||
if (widget !== null && widget.getName() === WidgetNameConstants.MAIN) {
|
||||
const event = this._makeWidgetEvent(e, widget)
|
||||
this._touchCoordinate = { x: event.x, y: event.y }
|
||||
this._chart.getChartStore().tooltipStore.setCrosshair({ x: event.x, y: event.y, paneId: pane?.getId() })
|
||||
this._chart.getChartStore().getTooltipStore().setCrosshair({ x: event.x, y: event.y, paneId: pane?.getId() })
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -607,7 +607,7 @@ export default class Event implements EventHandler {
|
||||
private _findWidgetByEvent (event: MouseTouchEvent): EventTriggerWidgetInfo {
|
||||
const { x, y } = event
|
||||
const separatorPanes = this._chart.getSeparatorPanes()
|
||||
const separatorSize = this._chart.getChartStore().styles.separator.size
|
||||
const separatorSize = this._chart.getChartStore().getStyles().separator.size
|
||||
for (const [, pane] of separatorPanes) {
|
||||
const bounding = pane.getBounding()
|
||||
const top = bounding.top - Math.round((REAL_SEPARATOR_HEIGHT - separatorSize) / 2)
|
||||
|
@ -52,7 +52,8 @@ export default abstract class XAxisImp extends AxisImp implements XAxis {
|
||||
|
||||
protected override createRangeImp (): AxisRange {
|
||||
const chartStore = this.getParent().getChart().getChartStore()
|
||||
const { from, to } = chartStore.timeScaleStore.visibleRange
|
||||
const visibleDataRange = chartStore.getTimeScaleStore().getVisibleRange()
|
||||
const { from, to } = visibleDataRange
|
||||
const af = from
|
||||
const at = to - 1
|
||||
const diff = to - from
|
||||
@ -72,10 +73,10 @@ export default abstract class XAxisImp extends AxisImp implements XAxis {
|
||||
|
||||
protected override createTicksImp (): AxisTick[] {
|
||||
const chartStore = this.getParent().getChart().getChartStore()
|
||||
const timeScaleStore = chartStore.timeScaleStore
|
||||
const formatDate = chartStore.customApi.formatDate
|
||||
const timeTickList = timeScaleStore.visibleRangeTimeTickList
|
||||
const dateTimeFormat = timeScaleStore.dateTimeFormat
|
||||
const timeScaleStore = chartStore.getTimeScaleStore()
|
||||
const formatDate = chartStore.getCustomApi().formatDate
|
||||
const timeTickList = timeScaleStore.getVisibleRangeTimeTickList()
|
||||
const dateTimeFormat = timeScaleStore.getDateTimeFormat()
|
||||
const ticks = timeTickList.map(({ dataIndex, weight, timestamp }) => {
|
||||
let text = ''
|
||||
switch (weight) {
|
||||
@ -158,23 +159,23 @@ export default abstract class XAxisImp extends AxisImp implements XAxis {
|
||||
}
|
||||
|
||||
convertTimestampFromPixel (pixel: number): Nullable<number> {
|
||||
const timeScaleStore = this.getParent().getChart().getChartStore().timeScaleStore
|
||||
const timeScaleStore = this.getParent().getChart().getChartStore().getTimeScaleStore()
|
||||
const dataIndex = timeScaleStore.coordinateToDataIndex(pixel)
|
||||
return timeScaleStore.dataIndexToTimestamp(dataIndex)
|
||||
}
|
||||
|
||||
convertTimestampToPixel (timestamp: number): number {
|
||||
const timeScaleStore = this.getParent().getChart().getChartStore().timeScaleStore
|
||||
const timeScaleStore = this.getParent().getChart().getChartStore().getTimeScaleStore()
|
||||
const dataIndex = timeScaleStore.timestampToDataIndex(timestamp)
|
||||
return timeScaleStore.dataIndexToCoordinate(dataIndex)
|
||||
}
|
||||
|
||||
convertFromPixel (pixel: number): number {
|
||||
return this.getParent().getChart().getChartStore().timeScaleStore.coordinateToDataIndex(pixel)
|
||||
return this.getParent().getChart().getChartStore().getTimeScaleStore().coordinateToDataIndex(pixel)
|
||||
}
|
||||
|
||||
convertToPixel (value: number): number {
|
||||
return this.getParent().getChart().getChartStore().timeScaleStore.dataIndexToCoordinate(value)
|
||||
return this.getParent().getChart().getChartStore().getTimeScaleStore().dataIndexToCoordinate(value)
|
||||
}
|
||||
|
||||
static extend (template: XAxisTemplate): XAxisConstructor {
|
||||
|
@ -88,7 +88,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
let specifyMin = Number.MAX_SAFE_INTEGER
|
||||
let specifyMax = Number.MIN_SAFE_INTEGER
|
||||
let indicatorPrecision = Number.MAX_SAFE_INTEGER
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(paneId)
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(paneId)
|
||||
indicators.forEach(indicator => {
|
||||
if (!shouldOhlc) {
|
||||
shouldOhlc = indicator.shouldOhlc ?? false
|
||||
@ -105,7 +105,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
let precision = 4
|
||||
const inCandle = this.isInCandle()
|
||||
if (inCandle) {
|
||||
const { price: pricePrecision } = chartStore.precision
|
||||
const { price: pricePrecision } = chartStore.getPrecision()
|
||||
if (indicatorPrecision !== Number.MAX_SAFE_INTEGER) {
|
||||
precision = Math.min(indicatorPrecision, pricePrecision)
|
||||
} else {
|
||||
@ -116,7 +116,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
precision = indicatorPrecision
|
||||
}
|
||||
}
|
||||
const visibleRangeDataList = chartStore.visibleRangeDataList
|
||||
const visibleRangeDataList = chartStore.getVisibleRangeDataList()
|
||||
const candleStyles = chart.getStyles().candle
|
||||
const isArea = candleStyles.type === CandleType.Area
|
||||
const areaValueKey = candleStyles.area.value
|
||||
@ -169,8 +169,8 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
|
||||
const range = this.createRange?.({
|
||||
paneId,
|
||||
kLineDataList: chartStore.dataList,
|
||||
dataVisibleRange: chartStore.timeScaleStore.visibleRange,
|
||||
kLineDataList: chartStore.getDataList(),
|
||||
dataVisibleRange: chartStore.getTimeScaleStore().getVisibleRange(),
|
||||
indicators,
|
||||
defaultRange
|
||||
})
|
||||
@ -265,15 +265,15 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
const pane = this.getParent()
|
||||
const height = pane.getYAxisWidget()?.getBounding().height ?? 0
|
||||
const chartStore = pane.getChart().getChartStore()
|
||||
const customApi = chartStore.customApi
|
||||
const customApi = chartStore.getCustomApi()
|
||||
const optimalTicks: AxisTick[] = []
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const thousandsSeparator = chartStore.thousandsSeparator
|
||||
const decimalFoldThreshold = chartStore.decimalFoldThreshold
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const thousandsSeparator = chartStore.getThousandsSeparator()
|
||||
const decimalFoldThreshold = chartStore.getDecimalFoldThreshold()
|
||||
let precision = 0
|
||||
let shouldFormatBigNumber = false
|
||||
if (this.isInCandle()) {
|
||||
precision = chartStore.precision.price
|
||||
precision = chartStore.getPrecision().price
|
||||
} else {
|
||||
indicators.forEach(indicator => {
|
||||
precision = Math.max(precision, indicator.precision)
|
||||
@ -282,7 +282,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
}
|
||||
})
|
||||
}
|
||||
const textHeight = chartStore.styles.xAxis.tickText.size
|
||||
const textHeight = chartStore.getStyles().xAxis.tickText.size
|
||||
let validY = NaN
|
||||
ticks.forEach(({ value }) => {
|
||||
let v = this.displayValueToText(+value, precision)
|
||||
@ -318,7 +318,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
return width
|
||||
}
|
||||
const chartStore = chart.getChartStore()
|
||||
const customApi = chartStore.customApi
|
||||
const customApi = chartStore.getCustomApi()
|
||||
let yAxisWidth = 0
|
||||
if (yAxisStyles.show) {
|
||||
if (yAxisStyles.axisLine.show) {
|
||||
@ -342,7 +342,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
crosshairStyles.horizontal.show &&
|
||||
crosshairStyles.horizontal.text.show
|
||||
) {
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
let indicatorPrecision = 0
|
||||
let shouldFormatBigNumber = false
|
||||
indicators.forEach(indicator => {
|
||||
@ -353,7 +353,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
})
|
||||
let precision = 2
|
||||
if (this.isInCandle()) {
|
||||
const { price: pricePrecision } = chartStore.precision
|
||||
const { price: pricePrecision } = chartStore.getPrecision()
|
||||
const lastValueMarkStyles = styles.indicator.lastValueMark
|
||||
if (lastValueMarkStyles.show && lastValueMarkStyles.text.show) {
|
||||
precision = Math.max(indicatorPrecision, pricePrecision)
|
||||
@ -367,7 +367,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis {
|
||||
if (shouldFormatBigNumber) {
|
||||
valueText = customApi.formatBigNumber(valueText)
|
||||
}
|
||||
valueText = formatFoldDecimal(valueText, chartStore.decimalFoldThreshold)
|
||||
valueText = formatFoldDecimal(valueText, chartStore.getDecimalFoldThreshold())
|
||||
crosshairVerticalTextWidth += (
|
||||
crosshairStyles.horizontal.text.paddingLeft +
|
||||
crosshairStyles.horizontal.text.paddingRight +
|
||||
|
@ -128,9 +128,7 @@ export default class ChartStore {
|
||||
|
||||
constructor (chart: Chart, options?: Options) {
|
||||
this._chart = chart
|
||||
if (isValid(options)) {
|
||||
this.options = options
|
||||
}
|
||||
this.setOptions(options)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,7 +141,7 @@ export default class ChartStore {
|
||||
{ x: 0, price: Number.MIN_SAFE_INTEGER },
|
||||
{ x: 0, price: Number.MAX_SAFE_INTEGER },
|
||||
]
|
||||
const { realFrom, realTo } = this._timeScaleStore.visibleRange
|
||||
const { realFrom, realTo } = this._timeScaleStore.getVisibleRange()
|
||||
for (let i = realFrom; i < realTo; i++) {
|
||||
const kLineData = this._dataList[i]
|
||||
const x = this._timeScaleStore.dataIndexToCoordinate(i)
|
||||
@ -152,27 +150,25 @@ export default class ChartStore {
|
||||
x,
|
||||
data: kLineData
|
||||
})
|
||||
if (isValid(kLineData)) {
|
||||
if (this._visibleRangeHighLowPrice[0].price < kLineData.high) {
|
||||
this._visibleRangeHighLowPrice[0].price = kLineData.high
|
||||
this._visibleRangeHighLowPrice[0].x = x
|
||||
}
|
||||
if (this._visibleRangeHighLowPrice[1].price > kLineData.low) {
|
||||
this._visibleRangeHighLowPrice[1].price = kLineData.low
|
||||
this._visibleRangeHighLowPrice[1].x = x
|
||||
}
|
||||
if (this._visibleRangeHighLowPrice[0].price < kLineData.high) {
|
||||
this._visibleRangeHighLowPrice[0].price = kLineData.high
|
||||
this._visibleRangeHighLowPrice[0].x = x
|
||||
}
|
||||
if (this._visibleRangeHighLowPrice[1].price > kLineData.low) {
|
||||
this._visibleRangeHighLowPrice[1].price = kLineData.low
|
||||
this._visibleRangeHighLowPrice[1].x = x
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set options (options: Options) {
|
||||
setOptions (options?: Options): this {
|
||||
if (isValid(options)) {
|
||||
const { locale, timezone, styles, customApi, thousandsSeparator, decimalFoldThreshold } = options
|
||||
if (isString(locale)) {
|
||||
this._locale = locale
|
||||
}
|
||||
if (isString(timezone)) {
|
||||
this._timeScaleStore.timezone = timezone
|
||||
this._timeScaleStore.setTimezone(timezone)
|
||||
}
|
||||
if (isValid(styles)) {
|
||||
let ss: Nullable<DeepPartial<Styles>> = null
|
||||
@ -197,46 +193,48 @@ export default class ChartStore {
|
||||
this._decimalFoldThreshold = decimalFoldThreshold
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
get styles (): Styles {
|
||||
getStyles (): Styles {
|
||||
return this._styles
|
||||
}
|
||||
|
||||
get locale (): string {
|
||||
getLocale (): string {
|
||||
return this._locale
|
||||
}
|
||||
|
||||
get customApi (): CustomApi {
|
||||
getCustomApi (): CustomApi {
|
||||
return this._customApi
|
||||
}
|
||||
|
||||
get thousandsSeparator (): string {
|
||||
getThousandsSeparator (): string {
|
||||
return this._thousandsSeparator
|
||||
}
|
||||
|
||||
get decimalFoldThreshold (): number {
|
||||
getDecimalFoldThreshold (): number {
|
||||
return this._decimalFoldThreshold
|
||||
}
|
||||
|
||||
get precision (): Precision {
|
||||
getPrecision (): Precision {
|
||||
return this._precision
|
||||
}
|
||||
|
||||
set precision (precision: Precision) {
|
||||
setPrecision (precision: Precision): this {
|
||||
this._precision = precision
|
||||
this._indicatorStore.synchronizeSeriesPrecision()
|
||||
return this
|
||||
}
|
||||
|
||||
get dataList (): KLineData[] {
|
||||
getDataList (): KLineData[] {
|
||||
return this._dataList
|
||||
}
|
||||
|
||||
get visibleRangeDataList (): VisibleRangeData[] {
|
||||
getVisibleRangeDataList (): VisibleRangeData[] {
|
||||
return this._visibleRangeDataList
|
||||
}
|
||||
|
||||
get visibleRangeHighLowPrice (): Array<{ price: number; x: number }> {
|
||||
getVisibleRangeHighLowPrice (): Array<{ price: number; x: number }> {
|
||||
return this._visibleRangeHighLowPrice
|
||||
}
|
||||
|
||||
@ -285,9 +283,9 @@ export default class ChartStore {
|
||||
if (timestamp > lastDataTimestamp) {
|
||||
this._timeScaleStore.classifyTimeTicks([data], true)
|
||||
this._dataList.push(data)
|
||||
let lastBarRightSideDiffBarCount = this._timeScaleStore.lastBarRightSideDiffBarCount
|
||||
let lastBarRightSideDiffBarCount = this._timeScaleStore.getLastBarRightSideDiffBarCount()
|
||||
if (lastBarRightSideDiffBarCount < 0) {
|
||||
this._timeScaleStore.lastBarRightSideDiffBarCount = --lastBarRightSideDiffBarCount
|
||||
this._timeScaleStore.setLastBarRightSideDiffBarCount(--lastBarRightSideDiffBarCount)
|
||||
}
|
||||
dataLengthChange = 1
|
||||
success = true
|
||||
@ -309,7 +307,7 @@ export default class ChartStore {
|
||||
}
|
||||
}
|
||||
|
||||
set loadMoreDataCallback (callback: LoadDataCallback) {
|
||||
setLoadMoreDataCallback (callback: LoadDataCallback): void {
|
||||
this._loadMoreDataCallback = callback
|
||||
}
|
||||
|
||||
@ -344,27 +342,27 @@ export default class ChartStore {
|
||||
this._tooltipStore.clear()
|
||||
}
|
||||
|
||||
get timeScaleStore (): TimeScaleStore {
|
||||
getTimeScaleStore (): TimeScaleStore {
|
||||
return this._timeScaleStore
|
||||
}
|
||||
|
||||
get indicatorStore (): IndicatorStore {
|
||||
getIndicatorStore (): IndicatorStore {
|
||||
return this._indicatorStore
|
||||
}
|
||||
|
||||
get overlayStore (): OverlayStore {
|
||||
getOverlayStore (): OverlayStore {
|
||||
return this._overlayStore
|
||||
}
|
||||
|
||||
get tooltipStore (): TooltipStore {
|
||||
getTooltipStore (): TooltipStore {
|
||||
return this._tooltipStore
|
||||
}
|
||||
|
||||
get actionStore (): ActionStore {
|
||||
getActionStore (): ActionStore {
|
||||
return this._actionStore
|
||||
}
|
||||
|
||||
get chart (): Chart {
|
||||
getChart (): Chart {
|
||||
return this._chart
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ export default class IndicatorStore {
|
||||
type: loadDataType,
|
||||
indicator
|
||||
})
|
||||
indicator.calcImp(this._chartStore.dataList).then(result => {
|
||||
indicator.calcImp(this._chartStore.getDataList()).then(result => {
|
||||
if (result) {
|
||||
this._chartStore.chart.adjustPaneViewport(false, true, true, true)
|
||||
this._chartStore.getChart().adjustPaneViewport(false, true, true, true)
|
||||
indicator.onDataStateChange?.({
|
||||
state: IndicatorDataState.Ready,
|
||||
type: loadDataType,
|
||||
@ -164,7 +164,7 @@ export default class IndicatorStore {
|
||||
}
|
||||
|
||||
synchronizeSeriesPrecision (indicator?: IndicatorImp): void {
|
||||
const { price: pricePrecision, volume: volumePrecision } = this._chartStore.precision
|
||||
const { price: pricePrecision, volume: volumePrecision } = this._chartStore.getPrecision()
|
||||
const synchronize: ((instance: IndicatorImp) => void) = instance => {
|
||||
switch (instance.series) {
|
||||
case IndicatorSeries.Price: {
|
||||
|
@ -196,7 +196,7 @@ export default class OverlayStore {
|
||||
})
|
||||
if (updatePaneIds.length > 0) {
|
||||
this._sort()
|
||||
const chart = this._chartStore.chart
|
||||
const chart = this._chartStore.getChart()
|
||||
updatePaneIds.forEach(paneId => {
|
||||
chart.updatePane(UpdateLevel.Overlay, paneId)
|
||||
})
|
||||
@ -205,7 +205,7 @@ export default class OverlayStore {
|
||||
return ids
|
||||
}
|
||||
|
||||
get progressInstanceInfo (): Nullable<ProgressOverlayInfo> {
|
||||
getProgressInstanceInfo (): Nullable<ProgressOverlayInfo> {
|
||||
return this._progressInstanceInfo
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ export default class OverlayStore {
|
||||
this._sort()
|
||||
}
|
||||
if (updatePaneIds.length > 0) {
|
||||
const chart = this._chartStore.chart
|
||||
const chart = this._chartStore.getChart()
|
||||
updatePaneIds.forEach(paneId => {
|
||||
chart.updatePane(UpdateLevel.Overlay, paneId)
|
||||
})
|
||||
@ -289,7 +289,7 @@ export default class OverlayStore {
|
||||
})
|
||||
})
|
||||
if (updatePaneIds.length > 0) {
|
||||
const chart = this._chartStore.chart
|
||||
const chart = this._chartStore.getChart()
|
||||
updatePaneIds.forEach(paneId => {
|
||||
chart.updatePane(UpdateLevel.Overlay, paneId)
|
||||
})
|
||||
@ -297,17 +297,17 @@ export default class OverlayStore {
|
||||
}
|
||||
}
|
||||
|
||||
set pressedInstanceInfo (info: EventOverlayInfo) {
|
||||
setPressedInstanceInfo (info: EventOverlayInfo): void {
|
||||
this._pressedInstanceInfo = info
|
||||
}
|
||||
|
||||
get pressedInstanceInfo (): EventOverlayInfo {
|
||||
getPressedInstanceInfo (): EventOverlayInfo {
|
||||
return this._pressedInstanceInfo
|
||||
}
|
||||
|
||||
updatePointPosition (dataChangeLength: number, type?: LoadDataType): void {
|
||||
if (dataChangeLength > 0) {
|
||||
const dataList = this._chartStore.dataList
|
||||
const dataList = this._chartStore.getDataList()
|
||||
this._instances.forEach(overlays => {
|
||||
overlays.forEach(overlay => {
|
||||
const points = overlay.points
|
||||
@ -356,13 +356,13 @@ export default class OverlayStore {
|
||||
this._sort()
|
||||
}
|
||||
if (!ignoreUpdateFlag) {
|
||||
this._chartStore.chart.updatePane(UpdateLevel.Overlay)
|
||||
this._chartStore.getChart().updatePane(UpdateLevel.Overlay)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get hoverInstanceInfo (): EventOverlayInfo {
|
||||
getHoverInstanceInfo (): EventOverlayInfo {
|
||||
return this._hoverInstanceInfo
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ export default class OverlayStore {
|
||||
if (instance?.id !== infoInstance?.id) {
|
||||
instance?.onDeselected?.({ overlay: instance, figureKey, figureIndex, ...event })
|
||||
infoInstance?.onSelected?.({ overlay: infoInstance, figureKey: info.figureKey, figureIndex: info.figureIndex, ...event })
|
||||
const chart = this._chartStore.chart
|
||||
const chart = this._chartStore.getChart()
|
||||
chart.updatePane(UpdateLevel.Overlay, info.paneId)
|
||||
if (paneId !== info.paneId) {
|
||||
chart.updatePane(UpdateLevel.Overlay, paneId)
|
||||
@ -387,7 +387,7 @@ export default class OverlayStore {
|
||||
}
|
||||
}
|
||||
|
||||
get clickInstanceInfo (): EventOverlayInfo {
|
||||
getClickInstanceInfo (): EventOverlayInfo {
|
||||
return this._clickInstanceInfo
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ export default class TimeScaleStore {
|
||||
let baseDataIndex = 0
|
||||
let prevKLineData: Nullable<KLineData> = null
|
||||
if (isUpdate ?? false) {
|
||||
const dataList = this._chartStore.dataList
|
||||
const dataList = this._chartStore.getDataList()
|
||||
baseDataIndex = dataList.length
|
||||
prevKLineData = dataList[baseDataIndex - 1]
|
||||
} else {
|
||||
@ -199,7 +199,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
|
||||
adjustVisibleRangeTimeTickList (): void {
|
||||
const tickTextStyles = this._chartStore.styles.xAxis.tickText
|
||||
const tickTextStyles = this._chartStore.getStyles().xAxis.tickText
|
||||
const width = Math.max(
|
||||
Math.ceil(this._totalBarSpace / 10),
|
||||
calcTextWidth('0000-00-00 00:00', tickTextStyles.size, tickTextStyles.weight, tickTextStyles.family)
|
||||
@ -254,7 +254,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
}
|
||||
|
||||
get visibleRangeTimeTickList (): TimeTick[] {
|
||||
getVisibleRangeTimeTickList (): TimeTick[] {
|
||||
return this._visibleRangeTimeTickList
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ export default class TimeScaleStore {
|
||||
* adjust visible range
|
||||
*/
|
||||
adjustVisibleRange (): void {
|
||||
const dataList = this._chartStore.dataList
|
||||
const dataList = this._chartStore.getDataList()
|
||||
const totalBarCount = dataList.length
|
||||
const visibleBarCount = this._totalBarSpace / this._barSpace
|
||||
|
||||
@ -301,7 +301,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
const realFrom = this._lastBarRightSideDiffBarCount > 0 ? Math.round(totalBarCount + this._lastBarRightSideDiffBarCount - visibleBarCount) - 1 : from
|
||||
this._visibleRange = { from, to, realFrom, realTo }
|
||||
this._chartStore.actionStore.execute(ActionType.OnVisibleRangeChange, this._visibleRange)
|
||||
this._chartStore.getActionStore().execute(ActionType.OnVisibleRangeChange, this._visibleRange)
|
||||
this._chartStore.adjustVisibleRangeDataList()
|
||||
if (
|
||||
this._cacheVisibleRange.from !== this._visibleRange.from ||
|
||||
@ -326,7 +326,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
}
|
||||
|
||||
get dateTimeFormat (): Intl.DateTimeFormat {
|
||||
getDateTimeFormat (): Intl.DateTimeFormat {
|
||||
return this._dateTimeFormat
|
||||
}
|
||||
|
||||
@ -352,20 +352,20 @@ export default class TimeScaleStore {
|
||||
return dateTimeFormat
|
||||
}
|
||||
|
||||
set timezone (timezone: string) {
|
||||
setTimezone (timezone: string): void {
|
||||
const dateTimeFormat: Nullable<Intl.DateTimeFormat> = this._buildDateTimeFormat(timezone)
|
||||
if (dateTimeFormat !== null) {
|
||||
this.classifyTimeTicks(this._chartStore.dataList)
|
||||
this.classifyTimeTicks(this._chartStore.getDataList())
|
||||
this.adjustVisibleRangeTimeTickList()
|
||||
this._dateTimeFormat = dateTimeFormat
|
||||
}
|
||||
}
|
||||
|
||||
get timezone (): string {
|
||||
getTimezone (): string {
|
||||
return this._dateTimeFormat.resolvedOptions().timeZone
|
||||
}
|
||||
|
||||
get garSpace (): BarSpace {
|
||||
getBarSpace (): BarSpace {
|
||||
return {
|
||||
bar: this._barSpace,
|
||||
halfBar: this._barSpace / 2,
|
||||
@ -382,16 +382,17 @@ export default class TimeScaleStore {
|
||||
this._calcOptimalBarSpace()
|
||||
adjustBeforeFunc?.()
|
||||
this.adjustVisibleRange()
|
||||
this._chartStore.tooltipStore.recalculateCrosshair(true)
|
||||
this._chartStore.chart.adjustPaneViewport(false, true, true, true)
|
||||
this._chartStore.getTooltipStore().recalculateCrosshair(true)
|
||||
this._chartStore.getChart().adjustPaneViewport(false, true, true, true)
|
||||
}
|
||||
|
||||
set totalBarSpace (totalSpace: number) {
|
||||
setTotalBarSpace (totalSpace: number): this {
|
||||
if (this._totalBarSpace !== totalSpace) {
|
||||
this._totalBarSpace = totalSpace
|
||||
this.adjustVisibleRange()
|
||||
this._chartStore.tooltipStore.recalculateCrosshair(true)
|
||||
this._chartStore.getTooltipStore().recalculateCrosshair(true)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
setOffsetRightDistance (distance: number, isUpdate?: boolean): this {
|
||||
@ -399,8 +400,8 @@ export default class TimeScaleStore {
|
||||
this._lastBarRightSideDiffBarCount = this._offsetRightDistance / this._barSpace
|
||||
if (isUpdate ?? false) {
|
||||
this.adjustVisibleRange()
|
||||
this._chartStore.tooltipStore.recalculateCrosshair(true)
|
||||
this._chartStore.chart.adjustPaneViewport(false, true, true, true)
|
||||
this._chartStore.getTooltipStore().recalculateCrosshair(true)
|
||||
this._chartStore.getChart().adjustPaneViewport(false, true, true, true)
|
||||
}
|
||||
return this
|
||||
}
|
||||
@ -409,43 +410,48 @@ export default class TimeScaleStore {
|
||||
this.setOffsetRightDistance(this._offsetRightDistance)
|
||||
}
|
||||
|
||||
get initialOffsetRightDistance (): number {
|
||||
getInitialOffsetRightDistance (): number {
|
||||
return this._offsetRightDistance
|
||||
}
|
||||
|
||||
get offsetRightDistance (): number {
|
||||
getOffsetRightDistance (): number {
|
||||
return Math.max(0, this._lastBarRightSideDiffBarCount * this._barSpace)
|
||||
}
|
||||
|
||||
get lastBarRightSideDiffBarCount (): number {
|
||||
getLastBarRightSideDiffBarCount (): number {
|
||||
return this._lastBarRightSideDiffBarCount
|
||||
}
|
||||
|
||||
set lastBarRightSideDiffBarCount (barCount: number) {
|
||||
setLastBarRightSideDiffBarCount (barCount: number): this {
|
||||
this._lastBarRightSideDiffBarCount = barCount
|
||||
return this
|
||||
}
|
||||
|
||||
set maxOffsetLeftDistance (distance: number) {
|
||||
setMaxOffsetLeftDistance (distance: number): this {
|
||||
this._scrollLimitRole = ScrollLimitRole.Distance
|
||||
this._maxOffsetDistance.left = distance
|
||||
return this
|
||||
}
|
||||
|
||||
set maxOffsetRightDistance (distance: number) {
|
||||
setMaxOffsetRightDistance (distance: number): this {
|
||||
this._scrollLimitRole = ScrollLimitRole.Distance
|
||||
this._maxOffsetDistance.right = distance
|
||||
return this
|
||||
}
|
||||
|
||||
set leftMinVisibleBarCount (barCount: number) {
|
||||
setLeftMinVisibleBarCount (barCount: number): this {
|
||||
this._scrollLimitRole = ScrollLimitRole.BarCount
|
||||
this._minVisibleBarCount.left = barCount
|
||||
return this
|
||||
}
|
||||
|
||||
set rightMinVisibleBarCount (barCount: number) {
|
||||
setRightMinVisibleBarCount (barCount: number): this {
|
||||
this._scrollLimitRole = ScrollLimitRole.BarCount
|
||||
this._minVisibleBarCount.right = barCount
|
||||
return this
|
||||
}
|
||||
|
||||
get visibleRange (): VisibleRange {
|
||||
getVisibleRange (): VisibleRange {
|
||||
return this._visibleRange
|
||||
}
|
||||
|
||||
@ -461,22 +467,22 @@ export default class TimeScaleStore {
|
||||
const prevLastBarRightSideDistance = this._lastBarRightSideDiffBarCount * this._barSpace
|
||||
this._lastBarRightSideDiffBarCount = this._startLastBarRightSideDiffBarCount - distanceBarCount
|
||||
this.adjustVisibleRange()
|
||||
this._chartStore.tooltipStore.recalculateCrosshair(true)
|
||||
this._chartStore.chart.adjustPaneViewport(false, true, true, true)
|
||||
this._chartStore.getTooltipStore().recalculateCrosshair(true)
|
||||
this._chartStore.getChart().adjustPaneViewport(false, true, true, true)
|
||||
const realDistance = Math.round(
|
||||
prevLastBarRightSideDistance - this._lastBarRightSideDiffBarCount * this._barSpace
|
||||
)
|
||||
if (realDistance !== 0) {
|
||||
this._chartStore.actionStore.execute(ActionType.OnScroll, { distance: realDistance })
|
||||
this._chartStore.getActionStore().execute(ActionType.OnScroll, { distance: realDistance })
|
||||
}
|
||||
}
|
||||
|
||||
getDataByDataIndex (dataIndex: number): Nullable<KLineData> {
|
||||
return this._chartStore.dataList[dataIndex] ?? null
|
||||
return this._chartStore.getDataList()[dataIndex] ?? null
|
||||
}
|
||||
|
||||
coordinateToFloatIndex (x: number): number {
|
||||
const dataCount = this._chartStore.dataList.length
|
||||
const dataCount = this._chartStore.getDataList().length
|
||||
const deltaFromRight = (this._totalBarSpace - x) / this._barSpace
|
||||
const index = dataCount + this._lastBarRightSideDiffBarCount - deltaFromRight
|
||||
return Math.round(index * 1000000) / 1000000
|
||||
@ -488,7 +494,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
|
||||
timestampToDataIndex (timestamp: number): number {
|
||||
const dataList = this._chartStore.dataList
|
||||
const dataList = this._chartStore.getDataList()
|
||||
if (dataList.length === 0) {
|
||||
return 0
|
||||
}
|
||||
@ -496,7 +502,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
|
||||
dataIndexToCoordinate (dataIndex: number): number {
|
||||
const dataCount = this._chartStore.dataList.length
|
||||
const dataCount = this._chartStore.getDataList().length
|
||||
const deltaFromRight = dataCount + this._lastBarRightSideDiffBarCount - dataIndex
|
||||
// return Math.floor(this._totalBarSpace - (deltaFromRight - 0.5) * this._barSpace) - 0.5
|
||||
return Math.floor(this._totalBarSpace - (deltaFromRight - 0.5) * this._barSpace + 0.5)
|
||||
@ -512,7 +518,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
let zoomCoordinate: Nullable<Partial<Coordinate>> = coordinate ?? null
|
||||
if (!isNumber(zoomCoordinate?.x)) {
|
||||
const crosshair = this._chartStore.tooltipStore.getCrosshair()
|
||||
const crosshair = this._chartStore.getTooltipStore().getCrosshair()
|
||||
zoomCoordinate = { x: crosshair?.x ?? this._totalBarSpace / 2 }
|
||||
}
|
||||
const x = zoomCoordinate.x!
|
||||
@ -524,23 +530,25 @@ export default class TimeScaleStore {
|
||||
})
|
||||
const realScale = this._barSpace / prevBarSpace
|
||||
if (realScale !== 1) {
|
||||
this._chartStore.actionStore.execute(ActionType.OnZoom, { scale: realScale })
|
||||
this._chartStore.getActionStore().execute(ActionType.OnZoom, { scale: realScale })
|
||||
}
|
||||
}
|
||||
|
||||
set zoomEnabled (enabled: boolean) {
|
||||
setZoomEnabled (enabled: boolean): this {
|
||||
this._zoomEnabled = enabled
|
||||
return this
|
||||
}
|
||||
|
||||
get zoomEnabled (): boolean {
|
||||
getZoomEnabled (): boolean {
|
||||
return this._zoomEnabled
|
||||
}
|
||||
|
||||
set scrollEnabled (enabled: boolean) {
|
||||
setScrollEnabled (enabled: boolean): this {
|
||||
this._scrollEnabled = enabled
|
||||
return this
|
||||
}
|
||||
|
||||
get scrollEnabled (): boolean {
|
||||
getScrollEnabled (): boolean {
|
||||
return this._scrollEnabled
|
||||
}
|
||||
|
||||
|
@ -41,12 +41,12 @@ export default class TooltipStore {
|
||||
* @param notInvalidate
|
||||
*/
|
||||
setCrosshair (crosshair?: Crosshair, notInvalidate?: boolean): void {
|
||||
const dataList = this._chartStore.dataList
|
||||
const dataList = this._chartStore.getDataList()
|
||||
const cr = crosshair ?? {}
|
||||
let realDataIndex = 0
|
||||
let dataIndex = 0
|
||||
if (isNumber(cr.x)) {
|
||||
realDataIndex = this._chartStore.timeScaleStore.coordinateToDataIndex(cr.x)
|
||||
realDataIndex = this._chartStore.getTimeScaleStore().coordinateToDataIndex(cr.x)
|
||||
if (realDataIndex < 0) {
|
||||
dataIndex = 0
|
||||
} else if (realDataIndex > dataList.length - 1) {
|
||||
@ -59,18 +59,17 @@ export default class TooltipStore {
|
||||
dataIndex = realDataIndex
|
||||
}
|
||||
const kLineData: Nullable<KLineData> = dataList[dataIndex]
|
||||
const realX = this._chartStore.timeScaleStore.dataIndexToCoordinate(realDataIndex)
|
||||
const realX = this._chartStore.getTimeScaleStore().dataIndexToCoordinate(realDataIndex)
|
||||
const prevCrosshair = { x: this._crosshair.x, y: this._crosshair.y, paneId: this._crosshair.paneId }
|
||||
this._crosshair = { ...cr, realX, kLineData, realDataIndex, dataIndex }
|
||||
if (
|
||||
prevCrosshair.x !== cr.x || prevCrosshair.y !== cr.y || prevCrosshair.paneId !== cr.paneId
|
||||
) {
|
||||
const chart = this._chartStore.chart
|
||||
if (kLineData !== null) {
|
||||
chart.crosshairChange(this._crosshair)
|
||||
this._chartStore.getChart().crosshairChange(this._crosshair)
|
||||
}
|
||||
if (!(notInvalidate ?? false)) {
|
||||
chart.updatePane(UpdateLevel.Overlay)
|
||||
this._chartStore.getChart().updatePane(UpdateLevel.Overlay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ export interface CandleBarOptions {
|
||||
|
||||
export default class CandleBarView extends ChildrenView {
|
||||
private readonly _boundCandleBarClickEvent = (data: VisibleRangeData) => () => {
|
||||
this.getWidget().getPane().getChart().getChartStore().actionStore.execute(ActionType.OnCandleBarClick, data)
|
||||
this.getWidget().getPane().getChart().getChartStore().getActionStore().execute(ActionType.OnCandleBarClick, data)
|
||||
return false
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ export default class CandleBarView extends ChildrenView {
|
||||
let ohlcSize = 0
|
||||
let halfOhlcSize = 0
|
||||
if (candleBarOptions.type === CandleType.Ohlc) {
|
||||
const { gapBar } = chartStore.timeScaleStore.garSpace
|
||||
const { gapBar } = chartStore.getTimeScaleStore().getBarSpace()
|
||||
ohlcSize = Math.min(Math.max(Math.round(gapBar * 0.2), 1), 8)
|
||||
if (ohlcSize > 2 && ohlcSize % 2 === 1) {
|
||||
ohlcSize--
|
||||
@ -157,7 +157,7 @@ export default class CandleBarView extends ChildrenView {
|
||||
}
|
||||
|
||||
protected getCandleBarOptions (chartStore: ChartStore): Nullable<CandleBarOptions> {
|
||||
const candleStyles = chartStore.styles.candle
|
||||
const candleStyles = chartStore.getStyles().candle
|
||||
return {
|
||||
type: candleStyles.type as Exclude<CandleType, CandleType.Area>,
|
||||
styles: candleStyles.bar
|
||||
|
@ -26,14 +26,14 @@ export default class CandleHighLowPriceView extends View<YAxis> {
|
||||
const widget = this.getWidget()
|
||||
const pane = widget.getPane()
|
||||
const chartStore = pane.getChart().getChartStore()
|
||||
const priceMarkStyles = chartStore.styles.candle.priceMark
|
||||
const priceMarkStyles = chartStore.getStyles().candle.priceMark
|
||||
const highPriceMarkStyles = priceMarkStyles.high
|
||||
const lowPriceMarkStyles = priceMarkStyles.low
|
||||
if (priceMarkStyles.show && (highPriceMarkStyles.show || lowPriceMarkStyles.show)) {
|
||||
const highestLowestPrice = chartStore.visibleRangeHighLowPrice
|
||||
const thousandsSeparator = chartStore.thousandsSeparator
|
||||
const decimalFoldThreshold = chartStore.decimalFoldThreshold
|
||||
const precision = chartStore.precision
|
||||
const highestLowestPrice = chartStore.getVisibleRangeHighLowPrice()
|
||||
const thousandsSeparator = chartStore.getThousandsSeparator()
|
||||
const decimalFoldThreshold = chartStore.getDecimalFoldThreshold()
|
||||
const precision = chartStore.getPrecision()
|
||||
const yAxis = pane.getAxisComponent()
|
||||
|
||||
const { price: high, x: highX } = highestLowestPrice[0]
|
||||
|
@ -25,13 +25,13 @@ export default class CandleLastPriceLabelView extends View {
|
||||
const pane = widget.getPane()
|
||||
const bounding = widget.getBounding()
|
||||
const chartStore = pane.getChart().getChartStore()
|
||||
const priceMarkStyles = chartStore.styles.candle.priceMark
|
||||
const priceMarkStyles = chartStore.getStyles().candle.priceMark
|
||||
const lastPriceMarkStyles = priceMarkStyles.last
|
||||
const lastPriceMarkTextStyles = lastPriceMarkStyles.text
|
||||
if (priceMarkStyles.show && lastPriceMarkStyles.show && lastPriceMarkTextStyles.show) {
|
||||
const precision = chartStore.precision
|
||||
const precision = chartStore.getPrecision()
|
||||
const yAxis = pane.getAxisComponent() as YAxis
|
||||
const dataList = chartStore.dataList
|
||||
const dataList = chartStore.getDataList()
|
||||
const data = dataList[dataList.length - 1]
|
||||
if (isValid(data)) {
|
||||
const { close, open } = data
|
||||
@ -52,7 +52,7 @@ export default class CandleLastPriceLabelView extends View {
|
||||
),
|
||||
precision.price
|
||||
)
|
||||
text = formatFoldDecimal(formatThousands(text, chartStore.thousandsSeparator), chartStore.decimalFoldThreshold)
|
||||
text = formatFoldDecimal(formatThousands(text, chartStore.getThousandsSeparator()), chartStore.getDecimalFoldThreshold())
|
||||
let x = 0
|
||||
let textAlgin: CanvasTextAlign = 'left'
|
||||
if (yAxis.isFromZero()) {
|
||||
|
@ -23,12 +23,12 @@ export default class CandleLastPriceView extends View {
|
||||
const pane = widget.getPane()
|
||||
const bounding = widget.getBounding()
|
||||
const chartStore = pane.getChart().getChartStore()
|
||||
const priceMarkStyles = chartStore.styles.candle.priceMark
|
||||
const priceMarkStyles = chartStore.getStyles().candle.priceMark
|
||||
const lastPriceMarkStyles = priceMarkStyles.last
|
||||
const lastPriceMarkLineStyles = lastPriceMarkStyles.line
|
||||
if (priceMarkStyles.show && lastPriceMarkStyles.show && lastPriceMarkLineStyles.show) {
|
||||
const yAxis = pane.getAxisComponent() as YAxis
|
||||
const dataList = chartStore.dataList
|
||||
const dataList = chartStore.getDataList()
|
||||
const data = dataList[dataList.length - 1]
|
||||
if (isValid(data)) {
|
||||
const { close, open } = data
|
||||
|
@ -44,20 +44,20 @@ export default class CandleTooltipView extends IndicatorTooltipView {
|
||||
const pane = widget.getPane()
|
||||
const paneId = pane.getId()
|
||||
const chartStore = pane.getChart().getChartStore()
|
||||
const crosshair = chartStore.tooltipStore.getCrosshair()
|
||||
const crosshair = chartStore.getTooltipStore().getCrosshair()
|
||||
if (isValid(crosshair.kLineData)) {
|
||||
const bounding = widget.getBounding()
|
||||
const yAxisBounding = pane.getYAxisWidget()!.getBounding()
|
||||
const dataList = chartStore.dataList
|
||||
const precision = chartStore.precision
|
||||
const locale = chartStore.locale
|
||||
const customApi = chartStore.customApi
|
||||
const thousandsSeparator = chartStore.thousandsSeparator
|
||||
const decimalFoldThreshold = chartStore.decimalFoldThreshold
|
||||
const activeIcon = chartStore.tooltipStore.getActiveIcon()
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const dateTimeFormat = chartStore.timeScaleStore.dateTimeFormat
|
||||
const styles = chartStore.styles
|
||||
const dataList = chartStore.getDataList()
|
||||
const precision = chartStore.getPrecision()
|
||||
const locale = chartStore.getLocale()
|
||||
const customApi = chartStore.getCustomApi()
|
||||
const thousandsSeparator = chartStore.getThousandsSeparator()
|
||||
const decimalFoldThreshold = chartStore.getDecimalFoldThreshold()
|
||||
const activeIcon = chartStore.getTooltipStore().getActiveIcon()
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const dateTimeFormat = chartStore.getTimeScaleStore().getDateTimeFormat()
|
||||
const styles = chartStore.getStyles()
|
||||
const candleStyles = styles.candle
|
||||
const indicatorStyles = styles.indicator
|
||||
if (
|
||||
|
@ -27,8 +27,8 @@ export default abstract class ChildrenView extends View<YAxis> {
|
||||
protected eachChildren (childCallback: EachChildCallback): void {
|
||||
const pane = this.getWidget().getPane()
|
||||
const chartStore = pane.getChart().getChartStore()
|
||||
const visibleRangeDataList = chartStore.visibleRangeDataList
|
||||
const barSpace = chartStore.timeScaleStore.garSpace
|
||||
const visibleRangeDataList = chartStore.getVisibleRangeDataList()
|
||||
const barSpace = chartStore.getTimeScaleStore().getBarSpace()
|
||||
const dataLength = visibleRangeDataList.length
|
||||
let index = 0
|
||||
while (index < dataLength) {
|
||||
|
@ -34,8 +34,8 @@ export default class CrosshairHorizontalLabelView<C extends Axis = YAxis> extend
|
||||
const pane = widget.getPane()
|
||||
const bounding = widget.getBounding()
|
||||
const chartStore = widget.getPane().getChart().getChartStore()
|
||||
const crosshair = chartStore.tooltipStore.getCrosshair()
|
||||
const styles = chartStore.styles.crosshair
|
||||
const crosshair = chartStore.getTooltipStore().getCrosshair()
|
||||
const styles = chartStore.getStyles().crosshair
|
||||
if (isString(crosshair.paneId) && this.compare(crosshair, pane.getId())) {
|
||||
if (styles.show) {
|
||||
const directionStyles = this.getDirectionStyles(styles)
|
||||
@ -68,9 +68,9 @@ export default class CrosshairHorizontalLabelView<C extends Axis = YAxis> extend
|
||||
let precision = 0
|
||||
let shouldFormatBigNumber = false
|
||||
if (yAxis.isInCandle()) {
|
||||
precision = chartStore.precision.price
|
||||
precision = chartStore.getPrecision().price
|
||||
} else {
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(crosshair.paneId!)
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(crosshair.paneId!)
|
||||
indicators.forEach(indicator => {
|
||||
precision = Math.max(indicator.precision, precision)
|
||||
if (!shouldFormatBigNumber) {
|
||||
@ -88,9 +88,9 @@ export default class CrosshairHorizontalLabelView<C extends Axis = YAxis> extend
|
||||
)
|
||||
|
||||
if (shouldFormatBigNumber) {
|
||||
text = chartStore.customApi.formatBigNumber(text)
|
||||
text = chartStore.getCustomApi().formatBigNumber(text)
|
||||
}
|
||||
return formatFoldDecimal(formatThousands(text, chartStore.thousandsSeparator), chartStore.decimalFoldThreshold)
|
||||
return formatFoldDecimal(formatThousands(text, chartStore.getThousandsSeparator()), chartStore.getDecimalFoldThreshold())
|
||||
}
|
||||
|
||||
protected getTextAttrs (text: string, _textWidth: number, crosshair: Crosshair, bounding: Bounding, axis: Axis, _styles: StateTextStyle): TextAttrs {
|
||||
|
@ -24,8 +24,8 @@ export default class CrosshairLineView extends View {
|
||||
const pane = widget.getPane()
|
||||
const bounding = widget.getBounding()
|
||||
const chartStore = widget.getPane().getChart().getChartStore()
|
||||
const crosshair = chartStore.tooltipStore.getCrosshair()
|
||||
const styles = chartStore.styles.crosshair
|
||||
const crosshair = chartStore.getTooltipStore().getCrosshair()
|
||||
const styles = chartStore.getStyles().crosshair
|
||||
if (isString(crosshair.paneId) && styles.show) {
|
||||
if (crosshair.paneId === pane.getId()) {
|
||||
const y = crosshair.y!
|
||||
|
@ -38,7 +38,7 @@ export default class CrosshairVerticalLabelView extends CrosshairHorizontalLabel
|
||||
|
||||
override getText (crosshair: Crosshair, chartStore: ChartStore): string {
|
||||
const timestamp = crosshair.kLineData?.timestamp
|
||||
return chartStore.customApi.formatDate(chartStore.timeScaleStore.dateTimeFormat, timestamp!, 'YYYY-MM-DD HH:mm', FormatDateType.Crosshair)
|
||||
return chartStore.getCustomApi().formatDate(chartStore.getTimeScaleStore().getDateTimeFormat(), timestamp!, 'YYYY-MM-DD HH:mm', FormatDateType.Crosshair)
|
||||
}
|
||||
|
||||
override getTextAttrs (text: string, textWidth: number, crosshair: Crosshair, bounding: Bounding, _axis: Axis, styles: StateTextStyle): TextAttrs {
|
||||
|
@ -27,18 +27,18 @@ export default class IndicatorLastValueView extends View<YAxis> {
|
||||
const pane = widget.getPane()
|
||||
const bounding = widget.getBounding()
|
||||
const chartStore = pane.getChart().getChartStore()
|
||||
const customApi = chartStore.customApi
|
||||
const defaultStyles = chartStore.styles.indicator
|
||||
const customApi = chartStore.getCustomApi()
|
||||
const defaultStyles = chartStore.getStyles().indicator
|
||||
const lastValueMarkStyles = defaultStyles.lastValueMark
|
||||
const lastValueMarkTextStyles = lastValueMarkStyles.text
|
||||
if (lastValueMarkStyles.show) {
|
||||
const yAxis = pane.getAxisComponent()
|
||||
const yAxisRange = yAxis.getRange()
|
||||
const dataList = chartStore.dataList
|
||||
const dataList = chartStore.getDataList()
|
||||
const dataIndex = dataList.length - 1
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const thousandsSeparator = chartStore.thousandsSeparator
|
||||
const decimalFoldThreshold = chartStore.decimalFoldThreshold
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const thousandsSeparator = chartStore.getThousandsSeparator()
|
||||
const decimalFoldThreshold = chartStore.getDecimalFoldThreshold()
|
||||
indicators.forEach(indicator => {
|
||||
const result = indicator.result
|
||||
const indicatorData = result[dataIndex] ?? result[dataIndex - 1]
|
||||
|
@ -37,13 +37,13 @@ import View from './View'
|
||||
export default class IndicatorTooltipView extends View<YAxis> {
|
||||
private readonly _boundIconClickEvent = (currentIcon: TooltipIcon) => () => {
|
||||
const pane = this.getWidget().getPane()
|
||||
pane.getChart().getChartStore().actionStore.execute(ActionType.OnTooltipIconClick, { ...currentIcon })
|
||||
pane.getChart().getChartStore().getActionStore().execute(ActionType.OnTooltipIconClick, { ...currentIcon })
|
||||
return true
|
||||
}
|
||||
|
||||
private readonly _boundIconMouseMoveEvent = (currentIconInfo: TooltipIcon) => () => {
|
||||
const pane = this.getWidget().getPane()
|
||||
const tooltipStore = pane.getChart().getChartStore().tooltipStore
|
||||
const tooltipStore = pane.getChart().getChartStore().getTooltipStore()
|
||||
tooltipStore.setActiveIcon({ ...currentIconInfo })
|
||||
return true
|
||||
}
|
||||
@ -52,18 +52,18 @@ export default class IndicatorTooltipView extends View<YAxis> {
|
||||
const widget = this.getWidget()
|
||||
const pane = widget.getPane()
|
||||
const chartStore = pane.getChart().getChartStore()
|
||||
const crosshair = chartStore.tooltipStore.getCrosshair()
|
||||
const crosshair = chartStore.getTooltipStore().getCrosshair()
|
||||
if (isValid(crosshair.kLineData)) {
|
||||
const bounding = widget.getBounding()
|
||||
const customApi = chartStore.customApi
|
||||
const thousandsSeparator = chartStore.thousandsSeparator
|
||||
const decimalFoldThreshold = chartStore.decimalFoldThreshold
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const activeIcon = chartStore.tooltipStore.getActiveIcon()
|
||||
const defaultStyles = chartStore.styles.indicator
|
||||
const customApi = chartStore.getCustomApi()
|
||||
const thousandsSeparator = chartStore.getThousandsSeparator()
|
||||
const decimalFoldThreshold = chartStore.getDecimalFoldThreshold()
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const activeIcon = chartStore.getTooltipStore().getActiveIcon()
|
||||
const defaultStyles = chartStore.getStyles().indicator
|
||||
const { offsetLeft, offsetTop, offsetRight } = defaultStyles.tooltip
|
||||
this.drawIndicatorTooltip(
|
||||
ctx, pane.getId(), chartStore.dataList,
|
||||
ctx, pane.getId(), chartStore.getDataList(),
|
||||
crosshair, activeIcon, indicators, customApi,
|
||||
thousandsSeparator, decimalFoldThreshold,
|
||||
offsetLeft, offsetTop,
|
||||
@ -307,7 +307,7 @@ export default class IndicatorTooltipView extends View<YAxis> {
|
||||
const { name: customName, calcParamsText: customCalcParamsText, legends: customLegends, icons: customIcons } = indicator.createTooltipDataSource({
|
||||
kLineDataList: dataList,
|
||||
indicator,
|
||||
visibleRange: chartStore.timeScaleStore.visibleRange,
|
||||
visibleRange: chartStore.getTimeScaleStore().getVisibleRange(),
|
||||
bounding: widget.getBounding(),
|
||||
crosshair,
|
||||
defaultStyles: styles,
|
||||
|
@ -29,12 +29,12 @@ export default class IndicatorView extends CandleBarView {
|
||||
const pane = this.getWidget().getPane()
|
||||
const yAxis = pane.getAxisComponent()
|
||||
if (!yAxis.isInCandle()) {
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
for (let i = 0; i < indicators.length; i++) {
|
||||
const indicator = indicators[i]
|
||||
if (indicator.shouldOhlc && indicator.visible) {
|
||||
const indicatorStyles = indicator.styles
|
||||
const defaultStyles = chartStore.styles.indicator
|
||||
const defaultStyles = chartStore.getStyles().indicator
|
||||
const upColor = formatValue(indicatorStyles, 'ohlc.upColor', defaultStyles.ohlc.upColor) as string
|
||||
const downColor = formatValue(indicatorStyles, 'ohlc.downColor', defaultStyles.ohlc.downColor) as string
|
||||
const noChangeColor = formatValue(indicatorStyles, 'ohlc.noChangeColor', defaultStyles.ohlc.noChangeColor) as string
|
||||
@ -67,11 +67,11 @@ export default class IndicatorView extends CandleBarView {
|
||||
const xAxis = chart.getXAxisPane().getAxisComponent()
|
||||
const yAxis = pane.getAxisComponent()
|
||||
const chartStore = chart.getChartStore()
|
||||
const dataList = chartStore.dataList
|
||||
const timeScaleStore = chartStore.timeScaleStore
|
||||
const visibleRange = timeScaleStore.visibleRange
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const defaultStyles = chartStore.styles.indicator
|
||||
const dataList = chartStore.getDataList()
|
||||
const timeScaleStore = chartStore.getTimeScaleStore()
|
||||
const visibleRange = timeScaleStore.getVisibleRange()
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const defaultStyles = chartStore.getStyles().indicator
|
||||
ctx.save()
|
||||
indicators.forEach(indicator => {
|
||||
if (indicator.visible) {
|
||||
@ -89,7 +89,7 @@ export default class IndicatorView extends CandleBarView {
|
||||
indicator,
|
||||
visibleRange,
|
||||
bounding,
|
||||
barSpace: timeScaleStore.garSpace,
|
||||
barSpace: timeScaleStore.getBarSpace(),
|
||||
defaultStyles,
|
||||
xAxis,
|
||||
yAxis
|
||||
|
@ -51,9 +51,9 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
private _initEvent (): void {
|
||||
const pane = this.getWidget().getPane()
|
||||
const paneId = pane.getId()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
const overlayStore = pane.getChart().getChartStore().getOverlayStore()
|
||||
this.registerEvent('mouseMoveEvent', (event: MouseTouchEvent) => {
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
const progressInstanceInfo = overlayStore.getProgressInstanceInfo()
|
||||
if (progressInstanceInfo !== null) {
|
||||
const overlay = progressInstanceInfo.instance
|
||||
let progressInstancePaneId = progressInstanceInfo.paneId
|
||||
@ -80,7 +80,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
}, event)
|
||||
return false
|
||||
}).registerEvent('mouseClickEvent', (event: MouseTouchEvent) => {
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
const progressInstanceInfo = overlayStore.getProgressInstanceInfo()
|
||||
if (progressInstanceInfo !== null) {
|
||||
const overlay = progressInstanceInfo.instance
|
||||
let progressInstancePaneId = progressInstanceInfo.paneId
|
||||
@ -112,7 +112,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
}, event)
|
||||
return false
|
||||
}).registerEvent('mouseDoubleClickEvent', (event: MouseTouchEvent) => {
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
const progressInstanceInfo = overlayStore.getProgressInstanceInfo()
|
||||
if (progressInstanceInfo !== null) {
|
||||
const overlay = progressInstanceInfo.instance
|
||||
const progressInstancePaneId = progressInstanceInfo.paneId
|
||||
@ -136,7 +136,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
}
|
||||
return false
|
||||
}).registerEvent('mouseRightClickEvent', (event: MouseTouchEvent) => {
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
const progressInstanceInfo = overlayStore.getProgressInstanceInfo()
|
||||
if (progressInstanceInfo !== null) {
|
||||
const overlay = progressInstanceInfo.instance
|
||||
if (overlay.isDrawing()) {
|
||||
@ -152,16 +152,16 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
}
|
||||
return false
|
||||
}).registerEvent('mouseUpEvent', (event: MouseTouchEvent) => {
|
||||
const { instance: overlay, figureIndex, figureKey } = overlayStore.pressedInstanceInfo
|
||||
const { instance: overlay, figureIndex, figureKey } = overlayStore.getPressedInstanceInfo()
|
||||
if (overlay !== null) {
|
||||
overlay.onPressedMoveEnd?.({ overlay, figureKey, figureIndex, ...event })
|
||||
}
|
||||
overlayStore.pressedInstanceInfo = {
|
||||
overlayStore.setPressedInstanceInfo({
|
||||
paneId, instance: null, figureType: EventOverlayInfoFigureType.None, figureKey: '', figureIndex: -1, attrsIndex: -1
|
||||
}
|
||||
})
|
||||
return false
|
||||
}).registerEvent('pressedMouseMoveEvent', (event: MouseTouchEvent) => {
|
||||
const { instance: overlay, figureType, figureIndex, figureKey } = overlayStore.pressedInstanceInfo
|
||||
const { instance: overlay, figureType, figureIndex, figureKey } = overlayStore.getPressedInstanceInfo()
|
||||
if (overlay !== null) {
|
||||
if (!overlay.lock) {
|
||||
if (!(overlay.onPressedMoving?.({ overlay, figureIndex, figureKey, ...event }) ?? false)) {
|
||||
@ -169,7 +169,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
if (figureType === EventOverlayInfoFigureType.Point) {
|
||||
overlay.eventPressedPointMove(point, figureIndex)
|
||||
} else {
|
||||
overlay.eventPressedOtherMove(point, this.getWidget().getPane().getChart().getChartStore().timeScaleStore)
|
||||
overlay.eventPressedOtherMove(point, this.getWidget().getPane().getChart().getChartStore().getTimeScaleStore())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,7 +236,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
private _figureMouseMoveEvent (overlay: OverlayImp, figureType: EventOverlayInfoFigureType, figureKey: string, figureIndex: number, attrsIndex: number): MouseTouchEventCallback {
|
||||
return (event: MouseTouchEvent) => {
|
||||
const pane = this.getWidget().getPane()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
const overlayStore = pane.getChart().getChartStore().getOverlayStore()
|
||||
overlayStore.setHoverInstanceInfo(
|
||||
{ paneId: pane.getId(), instance: overlay, figureType, figureKey, figureIndex, attrsIndex }, event
|
||||
)
|
||||
@ -248,10 +248,10 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
return (event: MouseTouchEvent) => {
|
||||
const pane = this.getWidget().getPane()
|
||||
const paneId = pane.getId()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
const overlayStore = pane.getChart().getChartStore().getOverlayStore()
|
||||
overlay.startPressedMove(this._coordinateToPoint(overlay, event))
|
||||
overlay.onPressedMoveStart?.({ overlay, figureIndex, figureKey, ...event })
|
||||
overlayStore.pressedInstanceInfo = { paneId, instance: overlay, figureType, figureKey, figureIndex, attrsIndex }
|
||||
overlayStore.setPressedInstanceInfo({ paneId, instance: overlay, figureType, figureKey, figureIndex, attrsIndex })
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -260,7 +260,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
return (event: MouseTouchEvent) => {
|
||||
const pane = this.getWidget().getPane()
|
||||
const paneId = pane.getId()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
const overlayStore = pane.getChart().getChartStore().getOverlayStore()
|
||||
overlayStore.setClickInstanceInfo({ paneId, instance: overlay, figureType, figureKey, figureIndex, attrsIndex }, event)
|
||||
return true
|
||||
}
|
||||
@ -277,7 +277,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
return (event: MouseTouchEvent) => {
|
||||
if (!(overlay.onRightClick?.({ overlay, figureIndex, figureKey, ...event }) ?? false)) {
|
||||
const pane = this.getWidget().getPane()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
const overlayStore = pane.getChart().getChartStore().getOverlayStore()
|
||||
overlayStore.removeInstance(overlay)
|
||||
}
|
||||
return true
|
||||
@ -289,7 +289,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
const pane = this.getWidget().getPane()
|
||||
const chart = pane.getChart()
|
||||
const paneId = pane.getId()
|
||||
const timeScaleStore = chart.getChartStore().timeScaleStore
|
||||
const timeScaleStore = chart.getChartStore().getTimeScaleStore()
|
||||
if (this.coordinateToPointTimestampDataIndexFlag()) {
|
||||
const xAxis = chart.getXAxisPane().getAxisComponent()
|
||||
const dataIndex = xAxis.convertFromPixel(coordinate.x)
|
||||
@ -361,7 +361,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
}
|
||||
|
||||
override dispatchEvent (name: EventName, event: MouseTouchEvent, other?: number): boolean {
|
||||
if (this.getWidget().getPane().getChart().getChartStore().overlayStore.isDrawing()) {
|
||||
if (this.getWidget().getPane().getChart().getChartStore().getOverlayStore().isDrawing()) {
|
||||
return this.onEvent(name, event, other)
|
||||
}
|
||||
return super.dispatchEvent(name, event, other)
|
||||
@ -380,19 +380,19 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
const xAxis = chart.getXAxisPane().getAxisComponent()
|
||||
const bounding = widget.getBounding()
|
||||
const chartStore = chart.getChartStore()
|
||||
const customApi = chartStore.customApi
|
||||
const thousandsSeparator = chartStore.thousandsSeparator
|
||||
const decimalFoldThreshold = chartStore.decimalFoldThreshold
|
||||
const timeScaleStore = chartStore.timeScaleStore
|
||||
const dateTimeFormat = timeScaleStore.dateTimeFormat
|
||||
const barSpace = timeScaleStore.garSpace
|
||||
const precision = chartStore.precision
|
||||
const defaultStyles = chartStore.styles.overlay
|
||||
const overlayStore = chartStore.overlayStore
|
||||
const hoverInstanceInfo = overlayStore.hoverInstanceInfo
|
||||
const clickInstanceInfo = overlayStore.clickInstanceInfo
|
||||
const customApi = chartStore.getCustomApi()
|
||||
const thousandsSeparator = chartStore.getThousandsSeparator()
|
||||
const decimalFoldThreshold = chartStore.getDecimalFoldThreshold()
|
||||
const timeScaleStore = chartStore.getTimeScaleStore()
|
||||
const dateTimeFormat = timeScaleStore.getDateTimeFormat()
|
||||
const barSpace = timeScaleStore.getBarSpace()
|
||||
const precision = chartStore.getPrecision()
|
||||
const defaultStyles = chartStore.getStyles().overlay
|
||||
const overlayStore = chartStore.getOverlayStore()
|
||||
const hoverInstanceInfo = overlayStore.getHoverInstanceInfo()
|
||||
const clickInstanceInfo = overlayStore.getClickInstanceInfo()
|
||||
const overlays = this.getCompleteOverlays(overlayStore, paneId)
|
||||
const paneIndicators = chartStore.indicatorStore.getInstanceByPaneId(paneId)
|
||||
const paneIndicators = chartStore.getIndicatorStore().getInstanceByPaneId(paneId)
|
||||
const overlayPrecision = paneIndicators.reduce((prev, indicator) => {
|
||||
const precision = indicator.precision
|
||||
prev[indicator.name] = precision
|
||||
@ -418,7 +418,7 @@ export default class OverlayView<C extends Axis = YAxis> extends View<C> {
|
||||
)
|
||||
}
|
||||
})
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
const progressInstanceInfo = overlayStore.getProgressInstanceInfo()
|
||||
if (progressInstanceInfo !== null) {
|
||||
const overlay = this.getProgressOverlay(progressInstanceInfo, paneId)
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
||||
|
@ -39,7 +39,7 @@ export default class IndicatorWidget extends DrawWidget<DrawPane<YAxis>> {
|
||||
this.addChild(this._overlayView)
|
||||
this.getContainer().style.cursor = 'crosshair'
|
||||
this.registerEvent('mouseMoveEvent', () => {
|
||||
pane.getChart().getChartStore().tooltipStore.setActiveIcon()
|
||||
pane.getChart().getChartStore().getTooltipStore().setActiveIcon()
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ export default class SeparatorWidget extends Widget<SeparatorPane> {
|
||||
increasedPane.setOriginalBounding({ height: startDragIncreasedPaneHeight + diffHeight })
|
||||
const currentPane = this.getPane()
|
||||
const chart = currentPane.getChart()
|
||||
chart.getChartStore().actionStore.execute(ActionType.OnPaneDrag, { paneId: currentPane.getId() })
|
||||
chart.getChartStore().getActionStore().execute(ActionType.OnPaneDrag, { paneId: currentPane.getId() })
|
||||
chart.adjustPaneViewport(true, true, true, true, true)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user