mirror of
https://github.com/klinecharts/KLineChart.git
synced 2024-11-25 16:22:43 +08:00
impr: getter and setter
This commit is contained in:
parent
abfd3584d1
commit
420cfa4dc3
@ -21,7 +21,8 @@ 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"
|
||||
"@typescript-eslint/max-params": "off",
|
||||
"accessor-pairs": "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.getStyles().separator.size
|
||||
const separatorSize = this._chartStore.styles.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.getStyles()
|
||||
const styles = this._chartStore.styles
|
||||
|
||||
let leftYAxisWidth = 0
|
||||
let leftYAxisOutside = true
|
||||
@ -429,7 +429,7 @@ export default class ChartImp implements Chart {
|
||||
mainRight = rightYAxisWidth
|
||||
}
|
||||
|
||||
this._chartStore.getTimeScaleStore().setTotalBarSpace(mainWidth)
|
||||
this._chartStore.timeScaleStore.totalBarSpace = 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.getActionStore()
|
||||
const actionStore = this._chartStore.actionStore
|
||||
if (actionStore.has(ActionType.OnCrosshairChange)) {
|
||||
const indicatorData = {}
|
||||
this._drawPanes.forEach(pane => {
|
||||
const id = pane.getId()
|
||||
const paneIndicatorData = {}
|
||||
const indicators = this._chartStore.getIndicatorStore().getInstanceByPaneId(id)
|
||||
const indicators = this._chartStore.indicatorStore.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.setOptions({ styles })
|
||||
this._chartStore.options = { styles }
|
||||
this.adjustPaneViewport(true, true, true, true, true)
|
||||
}
|
||||
|
||||
getStyles (): Styles {
|
||||
return this._chartStore.getStyles()
|
||||
return this._chartStore.styles
|
||||
}
|
||||
|
||||
setLocale (locale: string): void {
|
||||
this._chartStore.setOptions({ locale })
|
||||
this._chartStore.options = { locale }
|
||||
this.adjustPaneViewport(true, true, true, true, true)
|
||||
}
|
||||
|
||||
getLocale (): string {
|
||||
return this._chartStore.getLocale()
|
||||
return this._chartStore.locale
|
||||
}
|
||||
|
||||
setCustomApi (customApi: Partial<CustomApi>): void {
|
||||
this._chartStore.setOptions({ customApi })
|
||||
this._chartStore.options = { customApi }
|
||||
this.adjustPaneViewport(true, true, true, true, true)
|
||||
}
|
||||
|
||||
setPriceVolumePrecision (pricePrecision: number, volumePrecision: number): void {
|
||||
this._chartStore.setPrecision({ price: pricePrecision, volume: volumePrecision })
|
||||
this._chartStore.precision = { price: pricePrecision, volume: volumePrecision }
|
||||
}
|
||||
|
||||
getPriceVolumePrecision (): Precision {
|
||||
return this._chartStore.getPrecision()
|
||||
return this._chartStore.precision
|
||||
}
|
||||
|
||||
setTimezone (timezone: string): void {
|
||||
this._chartStore.setOptions({ timezone })
|
||||
this._chartStore.options = { timezone }
|
||||
const axis = (this._xAxisPane.getAxisComponent() as unknown as AxisImp)
|
||||
axis.buildTicks(true)
|
||||
this._xAxisPane.update(UpdateLevel.Drawer)
|
||||
}
|
||||
|
||||
getTimezone (): string {
|
||||
return this._chartStore.getTimeScaleStore().getTimezone()
|
||||
return this._chartStore.timeScaleStore.timezone
|
||||
}
|
||||
|
||||
setOffsetRightDistance (distance: number): void {
|
||||
this._chartStore.getTimeScaleStore().setOffsetRightDistance(distance, true)
|
||||
this._chartStore.timeScaleStore.setOffsetRightDistance(distance, true)
|
||||
}
|
||||
|
||||
getOffsetRightDistance (): number {
|
||||
return this._chartStore.getTimeScaleStore().getOffsetRightDistance()
|
||||
return this._chartStore.timeScaleStore.offsetRightDistance
|
||||
}
|
||||
|
||||
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.getTimeScaleStore().setMaxOffsetLeftDistance(distance)
|
||||
this._chartStore.timeScaleStore.maxOffsetLeftDistance = 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.getTimeScaleStore().setMaxOffsetRightDistance(distance)
|
||||
this._chartStore.timeScaleStore.maxOffsetRightDistance = 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.getTimeScaleStore().setLeftMinVisibleBarCount(Math.ceil(barCount))
|
||||
this._chartStore.timeScaleStore.leftMinVisibleBarCount = 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.getTimeScaleStore().setRightMinVisibleBarCount(Math.ceil(barCount))
|
||||
this._chartStore.timeScaleStore.rightMinVisibleBarCount = Math.ceil(barCount)
|
||||
}
|
||||
|
||||
setBarSpace (space: number): void {
|
||||
this._chartStore.getTimeScaleStore().setBarSpace(space)
|
||||
this._chartStore.timeScaleStore.setBarSpace(space)
|
||||
}
|
||||
|
||||
getBarSpace (): number {
|
||||
return this._chartStore.getTimeScaleStore().getBarSpace().bar
|
||||
return this._chartStore.timeScaleStore.garSpace.bar
|
||||
}
|
||||
|
||||
getVisibleRange (): VisibleRange {
|
||||
return this._chartStore.getTimeScaleStore().getVisibleRange()
|
||||
return this._chartStore.timeScaleStore.visibleRange
|
||||
}
|
||||
|
||||
clearData (): void {
|
||||
@ -712,7 +712,7 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
getDataList (): KLineData[] {
|
||||
return this._chartStore.getDataList()
|
||||
return this._chartStore.dataList
|
||||
}
|
||||
|
||||
applyNewData (data: KLineData[], more?: boolean | Partial<LoadDataMore>): void {
|
||||
@ -734,7 +734,7 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
setLoadMoreDataCallback (cb: LoadDataCallback): void {
|
||||
this._chartStore.setLoadMoreDataCallback(cb)
|
||||
this._chartStore.loadMoreDataCallback = 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.getIndicatorStore().addInstance(indicator, paneId ?? '', isStack ?? false)
|
||||
const result = this._chartStore.indicatorStore.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.getIndicatorStore().addInstance(indicator, paneId, isStack ?? false)
|
||||
const result = this._chartStore.indicatorStore.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.getIndicatorStore().override(override)
|
||||
const result = this._chartStore.indicatorStore.override(override)
|
||||
if (result) {
|
||||
this.adjustPaneViewport(false, false, true)
|
||||
}
|
||||
}
|
||||
|
||||
getIndicators (filter?: IndicatorFilter): Map<string, Indicator[]> {
|
||||
return this._chartStore.getIndicatorStore().getInstanceByFilter(filter ?? {})
|
||||
return this._chartStore.indicatorStore.getInstanceByFilter(filter ?? {})
|
||||
}
|
||||
|
||||
removeIndicator (filter?: IndicatorFilter): void {
|
||||
const indicatorStore = this._chartStore.getIndicatorStore()
|
||||
const indicatorStore = this._chartStore.indicatorStore
|
||||
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.getOverlayStore().addInstances(overlays, appointPaneFlags)
|
||||
const ids = this._chartStore.overlayStore.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.getOverlayStore().getInstanceByFilter(filter ?? {})
|
||||
return this._chartStore.overlayStore.getInstanceByFilter(filter ?? {})
|
||||
}
|
||||
|
||||
overrideOverlay (override: Partial<OverlayCreate>): void {
|
||||
this._chartStore.getOverlayStore().override(override)
|
||||
this._chartStore.overlayStore.override(override)
|
||||
}
|
||||
|
||||
removeOverlay (filter?: OverlayFilter): void {
|
||||
this._chartStore.getOverlayStore().removeInstance(filter ?? {})
|
||||
this._chartStore.overlayStore.removeInstance(filter ?? {})
|
||||
}
|
||||
|
||||
setPaneOptions (options: PaneOptions): void {
|
||||
@ -877,24 +877,24 @@ export default class ChartImp implements Chart {
|
||||
}
|
||||
|
||||
setZoomEnabled (enabled: boolean): void {
|
||||
this._chartStore.getTimeScaleStore().setZoomEnabled(enabled)
|
||||
this._chartStore.timeScaleStore.zoomEnabled = enabled
|
||||
}
|
||||
|
||||
isZoomEnabled (): boolean {
|
||||
return this._chartStore.getTimeScaleStore().getZoomEnabled()
|
||||
return this._chartStore.timeScaleStore.zoomEnabled
|
||||
}
|
||||
|
||||
setScrollEnabled (enabled: boolean): void {
|
||||
this._chartStore.getTimeScaleStore().setScrollEnabled(enabled)
|
||||
this._chartStore.timeScaleStore.scrollEnabled = enabled
|
||||
}
|
||||
|
||||
isScrollEnabled (): boolean {
|
||||
return this._chartStore.getTimeScaleStore().getScrollEnabled()
|
||||
return this._chartStore.timeScaleStore.scrollEnabled
|
||||
}
|
||||
|
||||
scrollByDistance (distance: number, animationDuration?: number): void {
|
||||
const duration = isNumber(animationDuration) && animationDuration > 0 ? animationDuration : 0
|
||||
const timeScaleStore = this._chartStore.getTimeScaleStore()
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
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.getTimeScaleStore()
|
||||
const { bar: barSpace } = timeScaleStore.getBarSpace()
|
||||
const difBarCount = timeScaleStore.getLastBarRightSideDiffBarCount() - timeScaleStore.getInitialOffsetRightDistance() / barSpace
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
const { bar: barSpace } = timeScaleStore.garSpace
|
||||
const difBarCount = timeScaleStore.lastBarRightSideDiffBarCount - timeScaleStore.initialOffsetRightDistance / barSpace
|
||||
const distance = difBarCount * barSpace
|
||||
this.scrollByDistance(distance, animationDuration)
|
||||
}
|
||||
|
||||
scrollToDataIndex (dataIndex: number, animationDuration?: number): void {
|
||||
const timeScaleStore = this._chartStore.getTimeScaleStore()
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
const distance = (
|
||||
timeScaleStore.getLastBarRightSideDiffBarCount() + (this.getDataList().length - 1 - dataIndex)
|
||||
) * timeScaleStore.getBarSpace().bar
|
||||
timeScaleStore.lastBarRightSideDiffBarCount + (this.getDataList().length - 1 - dataIndex)
|
||||
) * timeScaleStore.garSpace.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.getTimeScaleStore()
|
||||
const { bar: barSpace } = timeScaleStore.getBarSpace()
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
const { bar: barSpace } = timeScaleStore.garSpace
|
||||
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.getBarSpace().bar * SCALE_MULTIPLIER
|
||||
const scale = (progressBarSpace - prevProgressBarSpace) / timeScaleStore.garSpace.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.getTimeScaleStore().dataIndexToCoordinate(dataIndex)
|
||||
const x = this._chartStore.timeScaleStore.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.getTimeScaleStore()
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
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.getTimeScaleStore()
|
||||
const timeScaleStore = this._chartStore.timeScaleStore
|
||||
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.getTooltipStore().setCrosshair(crosshair)
|
||||
this._chartStore.tooltipStore.setCrosshair(crosshair)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subscribeAction (type: ActionType, callback: ActionCallback): void {
|
||||
this._chartStore.getActionStore().subscribe(type, callback)
|
||||
this._chartStore.actionStore.subscribe(type, callback)
|
||||
}
|
||||
|
||||
unsubscribeAction (type: ActionType, callback?: ActionCallback): void {
|
||||
this._chartStore.getActionStore().unsubscribe(type, callback)
|
||||
this._chartStore.actionStore.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().getTimeScaleStore().zoom(0.5)
|
||||
this._chart.getChartStore().timeScaleStore.zoom(0.5)
|
||||
break
|
||||
}
|
||||
case 'Minus': {
|
||||
this._chart.getChartStore().getTimeScaleStore().zoom(-0.5)
|
||||
this._chart.getChartStore().timeScaleStore.zoom(-0.5)
|
||||
break
|
||||
}
|
||||
case 'ArrowLeft': {
|
||||
const timeScaleStore = this._chart.getChartStore().getTimeScaleStore()
|
||||
const timeScaleStore = this._chart.getChartStore().timeScaleStore
|
||||
timeScaleStore.startScroll()
|
||||
timeScaleStore.scroll(-3 * timeScaleStore.getBarSpace().bar)
|
||||
timeScaleStore.scroll(-3 * timeScaleStore.garSpace.bar)
|
||||
break
|
||||
}
|
||||
case 'ArrowRight': {
|
||||
const timeScaleStore = this._chart.getChartStore().getTimeScaleStore()
|
||||
const timeScaleStore = this._chart.getChartStore().timeScaleStore
|
||||
timeScaleStore.startScroll()
|
||||
timeScaleStore.scroll(3 * timeScaleStore.getBarSpace().bar)
|
||||
timeScaleStore.scroll(3 * timeScaleStore.garSpace.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().getTimeScaleStore().zoom(zoomScale, { x: event.x, y: event.y })
|
||||
this._chart.getChartStore().timeScaleStore.zoom(zoomScale, { x: event.x, y: event.y })
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
mouseWheelHortEvent (_: MouseTouchEvent, distance: number): boolean {
|
||||
const timeScaleStore = this._chart.getChartStore().getTimeScaleStore()
|
||||
const timeScaleStore = this._chart.getChartStore().timeScaleStore
|
||||
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().getTimeScaleStore().zoom(scale, { x: event.x, y: event.y })
|
||||
this._chart.getChartStore().timeScaleStore.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().getTimeScaleStore().startScroll()
|
||||
this._chart.getChartStore().timeScaleStore.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.getTooltipStore().getActiveIcon() !== null) {
|
||||
if (consumed && chartStore.tooltipStore.getActiveIcon() !== null) {
|
||||
crosshair = undefined
|
||||
if (widget !== null) {
|
||||
widget.getContainer().style.cursor = 'pointer'
|
||||
}
|
||||
}
|
||||
this._chart.getChartStore().getTooltipStore().setCrosshair(crosshair)
|
||||
this._chart.getChartStore().tooltipStore.setCrosshair(crosshair)
|
||||
return consumed
|
||||
}
|
||||
case WidgetNameConstants.SEPARATOR:
|
||||
case WidgetNameConstants.X_AXIS:
|
||||
case WidgetNameConstants.Y_AXIS: {
|
||||
const consumed = widget.dispatchEvent('mouseMoveEvent', event)
|
||||
this._chart.getChartStore().getTooltipStore().setCrosshair()
|
||||
this._chart.getChartStore().tooltipStore.setCrosshair()
|
||||
return consumed
|
||||
}
|
||||
}
|
||||
@ -270,9 +270,9 @@ export default class Event implements EventHandler {
|
||||
})
|
||||
}
|
||||
const distance = event.x - this._startScrollCoordinate.x
|
||||
this._chart.getChartStore().getTimeScaleStore().scroll(distance)
|
||||
this._chart.getChartStore().timeScaleStore.scroll(distance)
|
||||
}
|
||||
this._chart.getChartStore().getTooltipStore().setCrosshair({ x: event.x, y: event.y, paneId: pane?.getId() })
|
||||
this._chart.getChartStore().tooltipStore.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().getTimeScaleStore().zoom(zoomScale, this._xAxisStartScaleCoordinate ?? undefined)
|
||||
this._chart.getChartStore().timeScaleStore.zoom(zoomScale, this._xAxisStartScaleCoordinate ?? undefined)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -413,7 +413,7 @@ export default class Event implements EventHandler {
|
||||
}
|
||||
|
||||
mouseLeaveEvent (): boolean {
|
||||
this._chart.getChartStore().getTooltipStore().setCrosshair()
|
||||
this._chart.getChartStore().tooltipStore.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.getTooltipStore()
|
||||
const tooltipStore = chartStore.tooltipStore
|
||||
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.getTimeScaleStore().startScroll()
|
||||
chartStore.timeScaleStore.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.getTooltipStore()
|
||||
const tooltipStore = chartStore.tooltipStore
|
||||
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.getTimeScaleStore().scroll(distance)
|
||||
chartStore.timeScaleStore.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().getTimeScaleStore()
|
||||
const timeScaleStore = this._chart.getChartStore().timeScaleStore
|
||||
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.getTooltipStore()
|
||||
const tooltipStore = chartStore.tooltipStore
|
||||
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().getTooltipStore().setCrosshair({ x: event.x, y: event.y, paneId: pane?.getId() })
|
||||
this._chart.getChartStore().tooltipStore.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().getStyles().separator.size
|
||||
const separatorSize = this._chart.getChartStore().styles.separator.size
|
||||
for (const [, pane] of separatorPanes) {
|
||||
const bounding = pane.getBounding()
|
||||
const top = bounding.top - Math.round((REAL_SEPARATOR_HEIGHT - separatorSize) / 2)
|
||||
|
@ -52,8 +52,7 @@ export default abstract class XAxisImp extends AxisImp implements XAxis {
|
||||
|
||||
protected override createRangeImp (): AxisRange {
|
||||
const chartStore = this.getParent().getChart().getChartStore()
|
||||
const visibleDataRange = chartStore.getTimeScaleStore().getVisibleRange()
|
||||
const { from, to } = visibleDataRange
|
||||
const { from, to } = chartStore.timeScaleStore.visibleRange
|
||||
const af = from
|
||||
const at = to - 1
|
||||
const diff = to - from
|
||||
@ -73,10 +72,10 @@ export default abstract class XAxisImp extends AxisImp implements XAxis {
|
||||
|
||||
protected override createTicksImp (): AxisTick[] {
|
||||
const chartStore = this.getParent().getChart().getChartStore()
|
||||
const timeScaleStore = chartStore.getTimeScaleStore()
|
||||
const formatDate = chartStore.getCustomApi().formatDate
|
||||
const timeTickList = timeScaleStore.getVisibleRangeTimeTickList()
|
||||
const dateTimeFormat = timeScaleStore.getDateTimeFormat()
|
||||
const timeScaleStore = chartStore.timeScaleStore
|
||||
const formatDate = chartStore.customApi.formatDate
|
||||
const timeTickList = timeScaleStore.visibleRangeTimeTickList
|
||||
const dateTimeFormat = timeScaleStore.dateTimeFormat
|
||||
const ticks = timeTickList.map(({ dataIndex, weight, timestamp }) => {
|
||||
let text = ''
|
||||
switch (weight) {
|
||||
@ -159,23 +158,23 @@ export default abstract class XAxisImp extends AxisImp implements XAxis {
|
||||
}
|
||||
|
||||
convertTimestampFromPixel (pixel: number): Nullable<number> {
|
||||
const timeScaleStore = this.getParent().getChart().getChartStore().getTimeScaleStore()
|
||||
const timeScaleStore = this.getParent().getChart().getChartStore().timeScaleStore
|
||||
const dataIndex = timeScaleStore.coordinateToDataIndex(pixel)
|
||||
return timeScaleStore.dataIndexToTimestamp(dataIndex)
|
||||
}
|
||||
|
||||
convertTimestampToPixel (timestamp: number): number {
|
||||
const timeScaleStore = this.getParent().getChart().getChartStore().getTimeScaleStore()
|
||||
const timeScaleStore = this.getParent().getChart().getChartStore().timeScaleStore
|
||||
const dataIndex = timeScaleStore.timestampToDataIndex(timestamp)
|
||||
return timeScaleStore.dataIndexToCoordinate(dataIndex)
|
||||
}
|
||||
|
||||
convertFromPixel (pixel: number): number {
|
||||
return this.getParent().getChart().getChartStore().getTimeScaleStore().coordinateToDataIndex(pixel)
|
||||
return this.getParent().getChart().getChartStore().timeScaleStore.coordinateToDataIndex(pixel)
|
||||
}
|
||||
|
||||
convertToPixel (value: number): number {
|
||||
return this.getParent().getChart().getChartStore().getTimeScaleStore().dataIndexToCoordinate(value)
|
||||
return this.getParent().getChart().getChartStore().timeScaleStore.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.getIndicatorStore().getInstanceByPaneId(paneId)
|
||||
const indicators = chartStore.indicatorStore.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.getPrecision()
|
||||
const { price: pricePrecision } = chartStore.precision
|
||||
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.getVisibleRangeDataList()
|
||||
const visibleRangeDataList = chartStore.visibleRangeDataList
|
||||
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.getDataList(),
|
||||
dataVisibleRange: chartStore.getTimeScaleStore().getVisibleRange(),
|
||||
kLineDataList: chartStore.dataList,
|
||||
dataVisibleRange: chartStore.timeScaleStore.visibleRange,
|
||||
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.getCustomApi()
|
||||
const customApi = chartStore.customApi
|
||||
const optimalTicks: AxisTick[] = []
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const thousandsSeparator = chartStore.getThousandsSeparator()
|
||||
const decimalFoldThreshold = chartStore.getDecimalFoldThreshold()
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const thousandsSeparator = chartStore.thousandsSeparator
|
||||
const decimalFoldThreshold = chartStore.decimalFoldThreshold
|
||||
let precision = 0
|
||||
let shouldFormatBigNumber = false
|
||||
if (this.isInCandle()) {
|
||||
precision = chartStore.getPrecision().price
|
||||
precision = chartStore.precision.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.getStyles().xAxis.tickText.size
|
||||
const textHeight = chartStore.styles.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.getCustomApi()
|
||||
const customApi = chartStore.customApi
|
||||
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.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const indicators = chartStore.indicatorStore.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.getPrecision()
|
||||
const { price: pricePrecision } = chartStore.precision
|
||||
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.getDecimalFoldThreshold())
|
||||
valueText = formatFoldDecimal(valueText, chartStore.decimalFoldThreshold)
|
||||
crosshairVerticalTextWidth += (
|
||||
crosshairStyles.horizontal.text.paddingLeft +
|
||||
crosshairStyles.horizontal.text.paddingRight +
|
||||
|
@ -128,7 +128,9 @@ export default class ChartStore {
|
||||
|
||||
constructor (chart: Chart, options?: Options) {
|
||||
this._chart = chart
|
||||
this.setOptions(options)
|
||||
if (isValid(options)) {
|
||||
this.options = options
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,7 +143,7 @@ export default class ChartStore {
|
||||
{ x: 0, price: Number.MIN_SAFE_INTEGER },
|
||||
{ x: 0, price: Number.MAX_SAFE_INTEGER },
|
||||
]
|
||||
const { realFrom, realTo } = this._timeScaleStore.getVisibleRange()
|
||||
const { realFrom, realTo } = this._timeScaleStore.visibleRange
|
||||
for (let i = realFrom; i < realTo; i++) {
|
||||
const kLineData = this._dataList[i]
|
||||
const x = this._timeScaleStore.dataIndexToCoordinate(i)
|
||||
@ -150,25 +152,27 @@ export default class ChartStore {
|
||||
x,
|
||||
data: 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 (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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setOptions (options?: Options): this {
|
||||
set options (options: Options) {
|
||||
if (isValid(options)) {
|
||||
const { locale, timezone, styles, customApi, thousandsSeparator, decimalFoldThreshold } = options
|
||||
if (isString(locale)) {
|
||||
this._locale = locale
|
||||
}
|
||||
if (isString(timezone)) {
|
||||
this._timeScaleStore.setTimezone(timezone)
|
||||
this._timeScaleStore.timezone = timezone
|
||||
}
|
||||
if (isValid(styles)) {
|
||||
let ss: Nullable<DeepPartial<Styles>> = null
|
||||
@ -193,48 +197,46 @@ export default class ChartStore {
|
||||
this._decimalFoldThreshold = decimalFoldThreshold
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
getStyles (): Styles {
|
||||
get styles (): Styles {
|
||||
return this._styles
|
||||
}
|
||||
|
||||
getLocale (): string {
|
||||
get locale (): string {
|
||||
return this._locale
|
||||
}
|
||||
|
||||
getCustomApi (): CustomApi {
|
||||
get customApi (): CustomApi {
|
||||
return this._customApi
|
||||
}
|
||||
|
||||
getThousandsSeparator (): string {
|
||||
get thousandsSeparator (): string {
|
||||
return this._thousandsSeparator
|
||||
}
|
||||
|
||||
getDecimalFoldThreshold (): number {
|
||||
get decimalFoldThreshold (): number {
|
||||
return this._decimalFoldThreshold
|
||||
}
|
||||
|
||||
getPrecision (): Precision {
|
||||
get precision (): Precision {
|
||||
return this._precision
|
||||
}
|
||||
|
||||
setPrecision (precision: Precision): this {
|
||||
set precision (precision: Precision) {
|
||||
this._precision = precision
|
||||
this._indicatorStore.synchronizeSeriesPrecision()
|
||||
return this
|
||||
}
|
||||
|
||||
getDataList (): KLineData[] {
|
||||
get dataList (): KLineData[] {
|
||||
return this._dataList
|
||||
}
|
||||
|
||||
getVisibleRangeDataList (): VisibleRangeData[] {
|
||||
get visibleRangeDataList (): VisibleRangeData[] {
|
||||
return this._visibleRangeDataList
|
||||
}
|
||||
|
||||
getVisibleRangeHighLowPrice (): Array<{ price: number; x: number }> {
|
||||
get visibleRangeHighLowPrice (): Array<{ price: number; x: number }> {
|
||||
return this._visibleRangeHighLowPrice
|
||||
}
|
||||
|
||||
@ -283,9 +285,9 @@ export default class ChartStore {
|
||||
if (timestamp > lastDataTimestamp) {
|
||||
this._timeScaleStore.classifyTimeTicks([data], true)
|
||||
this._dataList.push(data)
|
||||
let lastBarRightSideDiffBarCount = this._timeScaleStore.getLastBarRightSideDiffBarCount()
|
||||
let lastBarRightSideDiffBarCount = this._timeScaleStore.lastBarRightSideDiffBarCount
|
||||
if (lastBarRightSideDiffBarCount < 0) {
|
||||
this._timeScaleStore.setLastBarRightSideDiffBarCount(--lastBarRightSideDiffBarCount)
|
||||
this._timeScaleStore.lastBarRightSideDiffBarCount = --lastBarRightSideDiffBarCount
|
||||
}
|
||||
dataLengthChange = 1
|
||||
success = true
|
||||
@ -307,7 +309,7 @@ export default class ChartStore {
|
||||
}
|
||||
}
|
||||
|
||||
setLoadMoreDataCallback (callback: LoadDataCallback): void {
|
||||
set loadMoreDataCallback (callback: LoadDataCallback) {
|
||||
this._loadMoreDataCallback = callback
|
||||
}
|
||||
|
||||
@ -342,27 +344,27 @@ export default class ChartStore {
|
||||
this._tooltipStore.clear()
|
||||
}
|
||||
|
||||
getTimeScaleStore (): TimeScaleStore {
|
||||
get timeScaleStore (): TimeScaleStore {
|
||||
return this._timeScaleStore
|
||||
}
|
||||
|
||||
getIndicatorStore (): IndicatorStore {
|
||||
get indicatorStore (): IndicatorStore {
|
||||
return this._indicatorStore
|
||||
}
|
||||
|
||||
getOverlayStore (): OverlayStore {
|
||||
get overlayStore (): OverlayStore {
|
||||
return this._overlayStore
|
||||
}
|
||||
|
||||
getTooltipStore (): TooltipStore {
|
||||
get tooltipStore (): TooltipStore {
|
||||
return this._tooltipStore
|
||||
}
|
||||
|
||||
getActionStore (): ActionStore {
|
||||
get actionStore (): ActionStore {
|
||||
return this._actionStore
|
||||
}
|
||||
|
||||
getChart (): Chart {
|
||||
get chart (): Chart {
|
||||
return this._chart
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ export default class IndicatorStore {
|
||||
type: loadDataType,
|
||||
indicator
|
||||
})
|
||||
indicator.calcImp(this._chartStore.getDataList()).then(result => {
|
||||
indicator.calcImp(this._chartStore.dataList).then(result => {
|
||||
if (result) {
|
||||
this._chartStore.getChart().adjustPaneViewport(false, true, true, true)
|
||||
this._chartStore.chart.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.getPrecision()
|
||||
const { price: pricePrecision, volume: volumePrecision } = this._chartStore.precision
|
||||
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.getChart()
|
||||
const chart = this._chartStore.chart
|
||||
updatePaneIds.forEach(paneId => {
|
||||
chart.updatePane(UpdateLevel.Overlay, paneId)
|
||||
})
|
||||
@ -205,7 +205,7 @@ export default class OverlayStore {
|
||||
return ids
|
||||
}
|
||||
|
||||
getProgressInstanceInfo (): Nullable<ProgressOverlayInfo> {
|
||||
get progressInstanceInfo (): Nullable<ProgressOverlayInfo> {
|
||||
return this._progressInstanceInfo
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ export default class OverlayStore {
|
||||
this._sort()
|
||||
}
|
||||
if (updatePaneIds.length > 0) {
|
||||
const chart = this._chartStore.getChart()
|
||||
const chart = this._chartStore.chart
|
||||
updatePaneIds.forEach(paneId => {
|
||||
chart.updatePane(UpdateLevel.Overlay, paneId)
|
||||
})
|
||||
@ -289,7 +289,7 @@ export default class OverlayStore {
|
||||
})
|
||||
})
|
||||
if (updatePaneIds.length > 0) {
|
||||
const chart = this._chartStore.getChart()
|
||||
const chart = this._chartStore.chart
|
||||
updatePaneIds.forEach(paneId => {
|
||||
chart.updatePane(UpdateLevel.Overlay, paneId)
|
||||
})
|
||||
@ -297,17 +297,17 @@ export default class OverlayStore {
|
||||
}
|
||||
}
|
||||
|
||||
setPressedInstanceInfo (info: EventOverlayInfo): void {
|
||||
set pressedInstanceInfo (info: EventOverlayInfo) {
|
||||
this._pressedInstanceInfo = info
|
||||
}
|
||||
|
||||
getPressedInstanceInfo (): EventOverlayInfo {
|
||||
get pressedInstanceInfo (): EventOverlayInfo {
|
||||
return this._pressedInstanceInfo
|
||||
}
|
||||
|
||||
updatePointPosition (dataChangeLength: number, type?: LoadDataType): void {
|
||||
if (dataChangeLength > 0) {
|
||||
const dataList = this._chartStore.getDataList()
|
||||
const dataList = this._chartStore.dataList
|
||||
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.getChart().updatePane(UpdateLevel.Overlay)
|
||||
this._chartStore.chart.updatePane(UpdateLevel.Overlay)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getHoverInstanceInfo (): EventOverlayInfo {
|
||||
get hoverInstanceInfo (): 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.getChart()
|
||||
const chart = this._chartStore.chart
|
||||
chart.updatePane(UpdateLevel.Overlay, info.paneId)
|
||||
if (paneId !== info.paneId) {
|
||||
chart.updatePane(UpdateLevel.Overlay, paneId)
|
||||
@ -387,7 +387,7 @@ export default class OverlayStore {
|
||||
}
|
||||
}
|
||||
|
||||
getClickInstanceInfo (): EventOverlayInfo {
|
||||
get clickInstanceInfo (): 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.getDataList()
|
||||
const dataList = this._chartStore.dataList
|
||||
baseDataIndex = dataList.length
|
||||
prevKLineData = dataList[baseDataIndex - 1]
|
||||
} else {
|
||||
@ -199,7 +199,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
|
||||
adjustVisibleRangeTimeTickList (): void {
|
||||
const tickTextStyles = this._chartStore.getStyles().xAxis.tickText
|
||||
const tickTextStyles = this._chartStore.styles.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 {
|
||||
}
|
||||
}
|
||||
|
||||
getVisibleRangeTimeTickList (): TimeTick[] {
|
||||
get visibleRangeTimeTickList (): TimeTick[] {
|
||||
return this._visibleRangeTimeTickList
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ export default class TimeScaleStore {
|
||||
* adjust visible range
|
||||
*/
|
||||
adjustVisibleRange (): void {
|
||||
const dataList = this._chartStore.getDataList()
|
||||
const dataList = this._chartStore.dataList
|
||||
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.getActionStore().execute(ActionType.OnVisibleRangeChange, this._visibleRange)
|
||||
this._chartStore.actionStore.execute(ActionType.OnVisibleRangeChange, this._visibleRange)
|
||||
this._chartStore.adjustVisibleRangeDataList()
|
||||
if (
|
||||
this._cacheVisibleRange.from !== this._visibleRange.from ||
|
||||
@ -326,7 +326,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
}
|
||||
|
||||
getDateTimeFormat (): Intl.DateTimeFormat {
|
||||
get dateTimeFormat (): Intl.DateTimeFormat {
|
||||
return this._dateTimeFormat
|
||||
}
|
||||
|
||||
@ -352,20 +352,20 @@ export default class TimeScaleStore {
|
||||
return dateTimeFormat
|
||||
}
|
||||
|
||||
setTimezone (timezone: string): void {
|
||||
set timezone (timezone: string) {
|
||||
const dateTimeFormat: Nullable<Intl.DateTimeFormat> = this._buildDateTimeFormat(timezone)
|
||||
if (dateTimeFormat !== null) {
|
||||
this.classifyTimeTicks(this._chartStore.getDataList())
|
||||
this.classifyTimeTicks(this._chartStore.dataList)
|
||||
this.adjustVisibleRangeTimeTickList()
|
||||
this._dateTimeFormat = dateTimeFormat
|
||||
}
|
||||
}
|
||||
|
||||
getTimezone (): string {
|
||||
get timezone (): string {
|
||||
return this._dateTimeFormat.resolvedOptions().timeZone
|
||||
}
|
||||
|
||||
getBarSpace (): BarSpace {
|
||||
get garSpace (): BarSpace {
|
||||
return {
|
||||
bar: this._barSpace,
|
||||
halfBar: this._barSpace / 2,
|
||||
@ -382,17 +382,16 @@ export default class TimeScaleStore {
|
||||
this._calcOptimalBarSpace()
|
||||
adjustBeforeFunc?.()
|
||||
this.adjustVisibleRange()
|
||||
this._chartStore.getTooltipStore().recalculateCrosshair(true)
|
||||
this._chartStore.getChart().adjustPaneViewport(false, true, true, true)
|
||||
this._chartStore.tooltipStore.recalculateCrosshair(true)
|
||||
this._chartStore.chart.adjustPaneViewport(false, true, true, true)
|
||||
}
|
||||
|
||||
setTotalBarSpace (totalSpace: number): this {
|
||||
set totalBarSpace (totalSpace: number) {
|
||||
if (this._totalBarSpace !== totalSpace) {
|
||||
this._totalBarSpace = totalSpace
|
||||
this.adjustVisibleRange()
|
||||
this._chartStore.getTooltipStore().recalculateCrosshair(true)
|
||||
this._chartStore.tooltipStore.recalculateCrosshair(true)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
setOffsetRightDistance (distance: number, isUpdate?: boolean): this {
|
||||
@ -400,8 +399,8 @@ export default class TimeScaleStore {
|
||||
this._lastBarRightSideDiffBarCount = this._offsetRightDistance / this._barSpace
|
||||
if (isUpdate ?? false) {
|
||||
this.adjustVisibleRange()
|
||||
this._chartStore.getTooltipStore().recalculateCrosshair(true)
|
||||
this._chartStore.getChart().adjustPaneViewport(false, true, true, true)
|
||||
this._chartStore.tooltipStore.recalculateCrosshair(true)
|
||||
this._chartStore.chart.adjustPaneViewport(false, true, true, true)
|
||||
}
|
||||
return this
|
||||
}
|
||||
@ -410,48 +409,43 @@ export default class TimeScaleStore {
|
||||
this.setOffsetRightDistance(this._offsetRightDistance)
|
||||
}
|
||||
|
||||
getInitialOffsetRightDistance (): number {
|
||||
get initialOffsetRightDistance (): number {
|
||||
return this._offsetRightDistance
|
||||
}
|
||||
|
||||
getOffsetRightDistance (): number {
|
||||
get offsetRightDistance (): number {
|
||||
return Math.max(0, this._lastBarRightSideDiffBarCount * this._barSpace)
|
||||
}
|
||||
|
||||
getLastBarRightSideDiffBarCount (): number {
|
||||
get lastBarRightSideDiffBarCount (): number {
|
||||
return this._lastBarRightSideDiffBarCount
|
||||
}
|
||||
|
||||
setLastBarRightSideDiffBarCount (barCount: number): this {
|
||||
set lastBarRightSideDiffBarCount (barCount: number) {
|
||||
this._lastBarRightSideDiffBarCount = barCount
|
||||
return this
|
||||
}
|
||||
|
||||
setMaxOffsetLeftDistance (distance: number): this {
|
||||
set maxOffsetLeftDistance (distance: number) {
|
||||
this._scrollLimitRole = ScrollLimitRole.Distance
|
||||
this._maxOffsetDistance.left = distance
|
||||
return this
|
||||
}
|
||||
|
||||
setMaxOffsetRightDistance (distance: number): this {
|
||||
set maxOffsetRightDistance (distance: number) {
|
||||
this._scrollLimitRole = ScrollLimitRole.Distance
|
||||
this._maxOffsetDistance.right = distance
|
||||
return this
|
||||
}
|
||||
|
||||
setLeftMinVisibleBarCount (barCount: number): this {
|
||||
set leftMinVisibleBarCount (barCount: number) {
|
||||
this._scrollLimitRole = ScrollLimitRole.BarCount
|
||||
this._minVisibleBarCount.left = barCount
|
||||
return this
|
||||
}
|
||||
|
||||
setRightMinVisibleBarCount (barCount: number): this {
|
||||
set rightMinVisibleBarCount (barCount: number) {
|
||||
this._scrollLimitRole = ScrollLimitRole.BarCount
|
||||
this._minVisibleBarCount.right = barCount
|
||||
return this
|
||||
}
|
||||
|
||||
getVisibleRange (): VisibleRange {
|
||||
get visibleRange (): VisibleRange {
|
||||
return this._visibleRange
|
||||
}
|
||||
|
||||
@ -467,22 +461,22 @@ export default class TimeScaleStore {
|
||||
const prevLastBarRightSideDistance = this._lastBarRightSideDiffBarCount * this._barSpace
|
||||
this._lastBarRightSideDiffBarCount = this._startLastBarRightSideDiffBarCount - distanceBarCount
|
||||
this.adjustVisibleRange()
|
||||
this._chartStore.getTooltipStore().recalculateCrosshair(true)
|
||||
this._chartStore.getChart().adjustPaneViewport(false, true, true, true)
|
||||
this._chartStore.tooltipStore.recalculateCrosshair(true)
|
||||
this._chartStore.chart.adjustPaneViewport(false, true, true, true)
|
||||
const realDistance = Math.round(
|
||||
prevLastBarRightSideDistance - this._lastBarRightSideDiffBarCount * this._barSpace
|
||||
)
|
||||
if (realDistance !== 0) {
|
||||
this._chartStore.getActionStore().execute(ActionType.OnScroll, { distance: realDistance })
|
||||
this._chartStore.actionStore.execute(ActionType.OnScroll, { distance: realDistance })
|
||||
}
|
||||
}
|
||||
|
||||
getDataByDataIndex (dataIndex: number): Nullable<KLineData> {
|
||||
return this._chartStore.getDataList()[dataIndex] ?? null
|
||||
return this._chartStore.dataList[dataIndex] ?? null
|
||||
}
|
||||
|
||||
coordinateToFloatIndex (x: number): number {
|
||||
const dataCount = this._chartStore.getDataList().length
|
||||
const dataCount = this._chartStore.dataList.length
|
||||
const deltaFromRight = (this._totalBarSpace - x) / this._barSpace
|
||||
const index = dataCount + this._lastBarRightSideDiffBarCount - deltaFromRight
|
||||
return Math.round(index * 1000000) / 1000000
|
||||
@ -494,7 +488,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
|
||||
timestampToDataIndex (timestamp: number): number {
|
||||
const dataList = this._chartStore.getDataList()
|
||||
const dataList = this._chartStore.dataList
|
||||
if (dataList.length === 0) {
|
||||
return 0
|
||||
}
|
||||
@ -502,7 +496,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
|
||||
dataIndexToCoordinate (dataIndex: number): number {
|
||||
const dataCount = this._chartStore.getDataList().length
|
||||
const dataCount = this._chartStore.dataList.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)
|
||||
@ -518,7 +512,7 @@ export default class TimeScaleStore {
|
||||
}
|
||||
let zoomCoordinate: Nullable<Partial<Coordinate>> = coordinate ?? null
|
||||
if (!isNumber(zoomCoordinate?.x)) {
|
||||
const crosshair = this._chartStore.getTooltipStore().getCrosshair()
|
||||
const crosshair = this._chartStore.tooltipStore.getCrosshair()
|
||||
zoomCoordinate = { x: crosshair?.x ?? this._totalBarSpace / 2 }
|
||||
}
|
||||
const x = zoomCoordinate.x!
|
||||
@ -530,25 +524,23 @@ export default class TimeScaleStore {
|
||||
})
|
||||
const realScale = this._barSpace / prevBarSpace
|
||||
if (realScale !== 1) {
|
||||
this._chartStore.getActionStore().execute(ActionType.OnZoom, { scale: realScale })
|
||||
this._chartStore.actionStore.execute(ActionType.OnZoom, { scale: realScale })
|
||||
}
|
||||
}
|
||||
|
||||
setZoomEnabled (enabled: boolean): this {
|
||||
set zoomEnabled (enabled: boolean) {
|
||||
this._zoomEnabled = enabled
|
||||
return this
|
||||
}
|
||||
|
||||
getZoomEnabled (): boolean {
|
||||
get zoomEnabled (): boolean {
|
||||
return this._zoomEnabled
|
||||
}
|
||||
|
||||
setScrollEnabled (enabled: boolean): this {
|
||||
set scrollEnabled (enabled: boolean) {
|
||||
this._scrollEnabled = enabled
|
||||
return this
|
||||
}
|
||||
|
||||
getScrollEnabled (): boolean {
|
||||
get scrollEnabled (): boolean {
|
||||
return this._scrollEnabled
|
||||
}
|
||||
|
||||
|
@ -41,12 +41,12 @@ export default class TooltipStore {
|
||||
* @param notInvalidate
|
||||
*/
|
||||
setCrosshair (crosshair?: Crosshair, notInvalidate?: boolean): void {
|
||||
const dataList = this._chartStore.getDataList()
|
||||
const dataList = this._chartStore.dataList
|
||||
const cr = crosshair ?? {}
|
||||
let realDataIndex = 0
|
||||
let dataIndex = 0
|
||||
if (isNumber(cr.x)) {
|
||||
realDataIndex = this._chartStore.getTimeScaleStore().coordinateToDataIndex(cr.x)
|
||||
realDataIndex = this._chartStore.timeScaleStore.coordinateToDataIndex(cr.x)
|
||||
if (realDataIndex < 0) {
|
||||
dataIndex = 0
|
||||
} else if (realDataIndex > dataList.length - 1) {
|
||||
@ -59,17 +59,18 @@ export default class TooltipStore {
|
||||
dataIndex = realDataIndex
|
||||
}
|
||||
const kLineData: Nullable<KLineData> = dataList[dataIndex]
|
||||
const realX = this._chartStore.getTimeScaleStore().dataIndexToCoordinate(realDataIndex)
|
||||
const realX = this._chartStore.timeScaleStore.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) {
|
||||
this._chartStore.getChart().crosshairChange(this._crosshair)
|
||||
chart.crosshairChange(this._crosshair)
|
||||
}
|
||||
if (!(notInvalidate ?? false)) {
|
||||
this._chartStore.getChart().updatePane(UpdateLevel.Overlay)
|
||||
chart.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().getActionStore().execute(ActionType.OnCandleBarClick, data)
|
||||
this.getWidget().getPane().getChart().getChartStore().actionStore.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.getTimeScaleStore().getBarSpace()
|
||||
const { gapBar } = chartStore.timeScaleStore.garSpace
|
||||
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.getStyles().candle
|
||||
const candleStyles = chartStore.styles.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.getStyles().candle.priceMark
|
||||
const priceMarkStyles = chartStore.styles.candle.priceMark
|
||||
const highPriceMarkStyles = priceMarkStyles.high
|
||||
const lowPriceMarkStyles = priceMarkStyles.low
|
||||
if (priceMarkStyles.show && (highPriceMarkStyles.show || lowPriceMarkStyles.show)) {
|
||||
const highestLowestPrice = chartStore.getVisibleRangeHighLowPrice()
|
||||
const thousandsSeparator = chartStore.getThousandsSeparator()
|
||||
const decimalFoldThreshold = chartStore.getDecimalFoldThreshold()
|
||||
const precision = chartStore.getPrecision()
|
||||
const highestLowestPrice = chartStore.visibleRangeHighLowPrice
|
||||
const thousandsSeparator = chartStore.thousandsSeparator
|
||||
const decimalFoldThreshold = chartStore.decimalFoldThreshold
|
||||
const precision = chartStore.precision
|
||||
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.getStyles().candle.priceMark
|
||||
const priceMarkStyles = chartStore.styles.candle.priceMark
|
||||
const lastPriceMarkStyles = priceMarkStyles.last
|
||||
const lastPriceMarkTextStyles = lastPriceMarkStyles.text
|
||||
if (priceMarkStyles.show && lastPriceMarkStyles.show && lastPriceMarkTextStyles.show) {
|
||||
const precision = chartStore.getPrecision()
|
||||
const precision = chartStore.precision
|
||||
const yAxis = pane.getAxisComponent() as YAxis
|
||||
const dataList = chartStore.getDataList()
|
||||
const dataList = chartStore.dataList
|
||||
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.getThousandsSeparator()), chartStore.getDecimalFoldThreshold())
|
||||
text = formatFoldDecimal(formatThousands(text, chartStore.thousandsSeparator), chartStore.decimalFoldThreshold)
|
||||
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.getStyles().candle.priceMark
|
||||
const priceMarkStyles = chartStore.styles.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.getDataList()
|
||||
const dataList = chartStore.dataList
|
||||
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.getTooltipStore().getCrosshair()
|
||||
const crosshair = chartStore.tooltipStore.getCrosshair()
|
||||
if (isValid(crosshair.kLineData)) {
|
||||
const bounding = widget.getBounding()
|
||||
const yAxisBounding = pane.getYAxisWidget()!.getBounding()
|
||||
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 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 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.getVisibleRangeDataList()
|
||||
const barSpace = chartStore.getTimeScaleStore().getBarSpace()
|
||||
const visibleRangeDataList = chartStore.visibleRangeDataList
|
||||
const barSpace = chartStore.timeScaleStore.garSpace
|
||||
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.getTooltipStore().getCrosshair()
|
||||
const styles = chartStore.getStyles().crosshair
|
||||
const crosshair = chartStore.tooltipStore.getCrosshair()
|
||||
const styles = chartStore.styles.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.getPrecision().price
|
||||
precision = chartStore.precision.price
|
||||
} else {
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(crosshair.paneId!)
|
||||
const indicators = chartStore.indicatorStore.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.getCustomApi().formatBigNumber(text)
|
||||
text = chartStore.customApi.formatBigNumber(text)
|
||||
}
|
||||
return formatFoldDecimal(formatThousands(text, chartStore.getThousandsSeparator()), chartStore.getDecimalFoldThreshold())
|
||||
return formatFoldDecimal(formatThousands(text, chartStore.thousandsSeparator), chartStore.decimalFoldThreshold)
|
||||
}
|
||||
|
||||
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.getTooltipStore().getCrosshair()
|
||||
const styles = chartStore.getStyles().crosshair
|
||||
const crosshair = chartStore.tooltipStore.getCrosshair()
|
||||
const styles = chartStore.styles.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.getCustomApi().formatDate(chartStore.getTimeScaleStore().getDateTimeFormat(), timestamp!, 'YYYY-MM-DD HH:mm', FormatDateType.Crosshair)
|
||||
return chartStore.customApi.formatDate(chartStore.timeScaleStore.dateTimeFormat, 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.getCustomApi()
|
||||
const defaultStyles = chartStore.getStyles().indicator
|
||||
const customApi = chartStore.customApi
|
||||
const defaultStyles = chartStore.styles.indicator
|
||||
const lastValueMarkStyles = defaultStyles.lastValueMark
|
||||
const lastValueMarkTextStyles = lastValueMarkStyles.text
|
||||
if (lastValueMarkStyles.show) {
|
||||
const yAxis = pane.getAxisComponent()
|
||||
const yAxisRange = yAxis.getRange()
|
||||
const dataList = chartStore.getDataList()
|
||||
const dataList = chartStore.dataList
|
||||
const dataIndex = dataList.length - 1
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const thousandsSeparator = chartStore.getThousandsSeparator()
|
||||
const decimalFoldThreshold = chartStore.getDecimalFoldThreshold()
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const thousandsSeparator = chartStore.thousandsSeparator
|
||||
const decimalFoldThreshold = chartStore.decimalFoldThreshold
|
||||
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().getActionStore().execute(ActionType.OnTooltipIconClick, { ...currentIcon })
|
||||
pane.getChart().getChartStore().actionStore.execute(ActionType.OnTooltipIconClick, { ...currentIcon })
|
||||
return true
|
||||
}
|
||||
|
||||
private readonly _boundIconMouseMoveEvent = (currentIconInfo: TooltipIcon) => () => {
|
||||
const pane = this.getWidget().getPane()
|
||||
const tooltipStore = pane.getChart().getChartStore().getTooltipStore()
|
||||
const tooltipStore = pane.getChart().getChartStore().tooltipStore
|
||||
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.getTooltipStore().getCrosshair()
|
||||
const crosshair = chartStore.tooltipStore.getCrosshair()
|
||||
if (isValid(crosshair.kLineData)) {
|
||||
const bounding = widget.getBounding()
|
||||
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 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 { offsetLeft, offsetTop, offsetRight } = defaultStyles.tooltip
|
||||
this.drawIndicatorTooltip(
|
||||
ctx, pane.getId(), chartStore.getDataList(),
|
||||
ctx, pane.getId(), chartStore.dataList,
|
||||
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.getTimeScaleStore().getVisibleRange(),
|
||||
visibleRange: chartStore.timeScaleStore.visibleRange,
|
||||
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.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const indicators = chartStore.indicatorStore.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.getStyles().indicator
|
||||
const defaultStyles = chartStore.styles.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.getDataList()
|
||||
const timeScaleStore = chartStore.getTimeScaleStore()
|
||||
const visibleRange = timeScaleStore.getVisibleRange()
|
||||
const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId())
|
||||
const defaultStyles = chartStore.getStyles().indicator
|
||||
const dataList = chartStore.dataList
|
||||
const timeScaleStore = chartStore.timeScaleStore
|
||||
const visibleRange = timeScaleStore.visibleRange
|
||||
const indicators = chartStore.indicatorStore.getInstanceByPaneId(pane.getId())
|
||||
const defaultStyles = chartStore.styles.indicator
|
||||
ctx.save()
|
||||
indicators.forEach(indicator => {
|
||||
if (indicator.visible) {
|
||||
@ -89,7 +89,7 @@ export default class IndicatorView extends CandleBarView {
|
||||
indicator,
|
||||
visibleRange,
|
||||
bounding,
|
||||
barSpace: timeScaleStore.getBarSpace(),
|
||||
barSpace: timeScaleStore.garSpace,
|
||||
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().getOverlayStore()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
this.registerEvent('mouseMoveEvent', (event: MouseTouchEvent) => {
|
||||
const progressInstanceInfo = overlayStore.getProgressInstanceInfo()
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
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.getProgressInstanceInfo()
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
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.getProgressInstanceInfo()
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
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.getProgressInstanceInfo()
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
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.getPressedInstanceInfo()
|
||||
const { instance: overlay, figureIndex, figureKey } = overlayStore.pressedInstanceInfo
|
||||
if (overlay !== null) {
|
||||
overlay.onPressedMoveEnd?.({ overlay, figureKey, figureIndex, ...event })
|
||||
}
|
||||
overlayStore.setPressedInstanceInfo({
|
||||
overlayStore.pressedInstanceInfo = {
|
||||
paneId, instance: null, figureType: EventOverlayInfoFigureType.None, figureKey: '', figureIndex: -1, attrsIndex: -1
|
||||
})
|
||||
}
|
||||
return false
|
||||
}).registerEvent('pressedMouseMoveEvent', (event: MouseTouchEvent) => {
|
||||
const { instance: overlay, figureType, figureIndex, figureKey } = overlayStore.getPressedInstanceInfo()
|
||||
const { instance: overlay, figureType, figureIndex, figureKey } = overlayStore.pressedInstanceInfo
|
||||
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().getTimeScaleStore())
|
||||
overlay.eventPressedOtherMove(point, this.getWidget().getPane().getChart().getChartStore().timeScaleStore)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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().getOverlayStore()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
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().getOverlayStore()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
overlay.startPressedMove(this._coordinateToPoint(overlay, event))
|
||||
overlay.onPressedMoveStart?.({ overlay, figureIndex, figureKey, ...event })
|
||||
overlayStore.setPressedInstanceInfo({ paneId, instance: overlay, figureType, figureKey, figureIndex, attrsIndex })
|
||||
overlayStore.pressedInstanceInfo = { 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().getOverlayStore()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
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().getOverlayStore()
|
||||
const overlayStore = pane.getChart().getChartStore().overlayStore
|
||||
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().getTimeScaleStore()
|
||||
const timeScaleStore = chart.getChartStore().timeScaleStore
|
||||
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().getOverlayStore().isDrawing()) {
|
||||
if (this.getWidget().getPane().getChart().getChartStore().overlayStore.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.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 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 overlays = this.getCompleteOverlays(overlayStore, paneId)
|
||||
const paneIndicators = chartStore.getIndicatorStore().getInstanceByPaneId(paneId)
|
||||
const paneIndicators = chartStore.indicatorStore.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.getProgressInstanceInfo()
|
||||
const progressInstanceInfo = overlayStore.progressInstanceInfo
|
||||
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().getTooltipStore().setActiveIcon()
|
||||
pane.getChart().getChartStore().tooltipStore.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().getActionStore().execute(ActionType.OnPaneDrag, { paneId: currentPane.getId() })
|
||||
chart.getChartStore().actionStore.execute(ActionType.OnPaneDrag, { paneId: currentPane.getId() })
|
||||
chart.adjustPaneViewport(true, true, true, true, true)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user