From 5be280359d8f77cbedcf17f05e1902e880e97f0d Mon Sep 17 00:00:00 2001 From: liihuu Date: Tue, 3 Sep 2024 23:46:32 +0800 Subject: [PATCH] impr: modify some apis --- scripts/config.js | 5 +- src/Chart.ts | 175 ++++++--------- src/common/LoadMoreCallback.ts | 23 -- src/common/Styles.ts | 32 +-- src/component/Indicator.ts | 6 +- src/component/Overlay.ts | 2 +- src/component/YAxis.ts | 8 +- src/extension/figure/index.ts | 3 +- src/extension/figure/rectText.ts | 37 --- src/index.ts | 4 +- src/pane/types.ts | 5 - src/store/ChartStore.ts | 21 +- src/store/IndicatorStore.ts | 115 ++++------ src/store/OverlayStore.ts | 272 ++++++++++------------- src/store/TimeScaleStore.ts | 1 - src/view/CandleTooltipView.ts | 8 +- src/view/CrosshairHorizontalLabelView.ts | 2 +- src/view/IndicatorLastValueView.ts | 2 +- src/view/IndicatorTooltipView.ts | 12 +- src/view/IndicatorView.ts | 4 +- src/view/OverlayView.ts | 4 +- src/view/OverlayXAxisView.ts | 2 +- 22 files changed, 276 insertions(+), 467 deletions(-) delete mode 100644 src/common/LoadMoreCallback.ts delete mode 100644 src/extension/figure/rectText.ts diff --git a/scripts/config.js b/scripts/config.js index 685b9e9c6..d2063de00 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -1,3 +1,5 @@ +import child_process from 'child_process' + import { nodeResolve } from '@rollup/plugin-node-resolve' import eslint from '@rollup/plugin-eslint' import replace from '@rollup/plugin-replace' @@ -10,6 +12,7 @@ import progress from 'rollup-plugin-progress' import { resolvePath, getVersion } from './utils.js' const version = getVersion() +const commitId = child_process.execSync('git rev-parse --short HEAD').toString().trim() const env = process.env.NODE_ENV @@ -33,7 +36,7 @@ function createInputConfig ({ input, replaceValues }) { replace({ preventAssignment: true, values: { - '__VERSION__': version, + '__VERSION__': `v${version}(${commitId})`, ...replaceValues } }), diff --git a/src/Chart.ts b/src/Chart.ts index 5834f5f02..a2617184e 100644 --- a/src/Chart.ts +++ b/src/Chart.ts @@ -22,7 +22,6 @@ import { UpdateLevel } from './common/Updater' import { type Styles } from './common/Styles' import type Crosshair from './common/Crosshair' import { ActionType, type ActionCallback } from './common/Action' -import type LoadMoreCallback from './common/LoadMoreCallback' import type LoadDataCallback from './common/LoadDataCallback' import type Precision from './common/Precision' import type VisibleRange from './common/VisibleRange' @@ -51,8 +50,8 @@ import { type PaneOptions, PanePosition, PANE_DEFAULT_HEIGHT, PaneIdConstants } import type AxisImp from './component/Axis' import { AxisPosition, type Axis } from './component/Axis' -import { type Indicator, type IndicatorCreate } from './component/Indicator' -import { type Overlay, type OverlayCreate, type OverlayRemove } from './component/Overlay' +import { type IndicatorFilter, type Indicator, type IndicatorCreate } from './component/Indicator' +import { type OverlayFilter, type Overlay, type OverlayCreate } from './component/Overlay' import { getIndicatorClass } from './extension/indicator/index' @@ -94,27 +93,17 @@ export interface Chart { getVisibleRange: () => VisibleRange clearData: () => void getDataList: () => KLineData[] - applyNewData: (dataList: KLineData[], more?: boolean, callback?: () => void) => void - /** - * @deprecated - * Since v9.8.0 deprecated, since v10 removed - */ - applyMoreData: (dataList: KLineData[], more?: boolean, callback?: () => void) => void - updateData: (data: KLineData, callback?: () => void) => void - /** - * @deprecated - * Since v9.8.0 deprecated, since v10 removed - */ - loadMore: (cb: LoadMoreCallback) => void + applyNewData: (dataList: KLineData[], more?: boolean) => void + updateData: (data: KLineData) => void setLoadDataCallback: (cb: LoadDataCallback) => void - createIndicator: (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: PaneOptions, callback?: () => void) => Nullable - overrideIndicator: (override: IndicatorCreate, paneId?: string, callback?: () => void) => void - getIndicatorByPaneId: (paneId?: string, name?: string) => Nullable | Nullable> | Map> - removeIndicator: (paneId: string, name?: string) => void - createOverlay: (value: string | OverlayCreate | Array, paneId?: string) => Nullable | Array> - getOverlayById: (id: string) => Nullable + createIndicator: (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: PaneOptions) => Nullable + overrideIndicator: (override: IndicatorCreate) => void + getIndicators: (filter?: IndicatorFilter) => Map + removeIndicator: (filter?: IndicatorFilter) => void + createOverlay: (value: string | OverlayCreate | Array) => Nullable | Array> + getOverlays: (filter?: OverlayFilter) => Map overrideOverlay: (override: Partial) => void - removeOverlay: (remove?: string | OverlayRemove) => void + removeOverlay: (filter?: OverlayFilter) => void setPaneOptions: (options: PaneOptions) => void setZoomEnabled: (enabled: boolean) => void isZoomEnabled: () => boolean @@ -405,11 +394,12 @@ export default class ChartImp implements Chart { } private _setPaneOptions (options: PaneOptions, forceShouldAdjust: boolean): void { - if (isString(options.id)) { - const pane = this.getDrawPaneById(options.id) - let shouldMeasureHeight = false - if (pane !== null) { - let shouldAdjust = forceShouldAdjust + let shouldMeasureHeight = false + let shouldAdjust = forceShouldAdjust + for (const pane of this._drawPanes) { + const paneIdValid = isValid(options.id) + const isSpecify = paneIdValid && pane.getId() === options.id + if (isSpecify || !paneIdValid) { if (options.id !== PaneIdConstants.CANDLE && isNumber(options.height) && options.height > 0) { const minHeight = Math.max(options.minHeight ?? pane.getOptions().minHeight, 0) const height = Math.max(minHeight, options.height) @@ -417,15 +407,18 @@ export default class ChartImp implements Chart { shouldAdjust = true shouldMeasureHeight = true } - if (isString(options.axis)) { + if (isValid(options.axis)) { shouldAdjust = true } pane.setOptions(options) - if (shouldAdjust) { - this.adjustPaneViewport(shouldMeasureHeight, true, true, true, true) + if (isSpecify) { + break } } } + if (shouldAdjust) { + this.adjustPaneViewport(shouldMeasureHeight, true, true, true, true) + } } getDrawPaneById (paneId: string): Nullable> { @@ -500,7 +493,7 @@ export default class ChartImp implements Chart { this._drawPanes.forEach(pane => { const id = pane.getId() const paneIndicatorData = {} - const indicators = this._chartStore.getIndicatorStore().getInstances(id) + const indicators = this._chartStore.getIndicatorStore().getInstanceByPaneId(id) indicators.forEach(indicator => { const result = indicator.result paneIndicatorData[indicator.name] = result[crosshair.dataIndex ?? result.length - 1] @@ -671,46 +664,19 @@ export default class ChartImp implements Chart { return this._chartStore.getDataList() } - applyNewData (data: KLineData[], more?: boolean, callback?: () => void): void { - if (isValid(callback)) { - logWarn('applyNewData', '', 'param `callback` has been deprecated since version 9.8.0, use `subscribeAction(\'onDataReady\')` instead.') - } + applyNewData (data: KLineData[], more?: boolean): void { this._chartStore.addData(data, LoadDataType.Init, more) - callback?.() - } - - /** - * @deprecated - * Since v9.8.0 deprecated, since v10 removed - */ - applyMoreData (data: KLineData[], more?: boolean, callback?: () => void): void { - logWarn('', '', 'Api `applyMoreData` has been deprecated since version 9.8.0.') - this._chartStore.addData(data, LoadDataType.Forward, more ?? true) - callback?.() } - updateData (data: KLineData, callback?: () => void): void { - if (isValid(callback)) { - logWarn('updateData', '', 'param `callback` has been deprecated since version 9.8.0, use `subscribeAction(\'onDataReady\')` instead.') - } + updateData (data: KLineData): void { this._chartStore.addData(data) - callback?.() - } - - /** - * @deprecated - * Since v9.8.0 deprecated, since v10 removed - */ - loadMore (cb: LoadMoreCallback): void { - logWarn('', '', 'Api `loadMore` has been deprecated since version 9.8.0, use `setLoadDataCallback` instead.') - this._chartStore.setLoadMoreCallback(cb) } setLoadDataCallback (cb: LoadDataCallback): void { this._chartStore.setLoadDataCallback(cb) } - createIndicator (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: Nullable, callback?: () => void): Nullable { + createIndicator (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: Nullable): Nullable { const indicator = isString(value) ? { name: value } : value if (getIndicatorClass(indicator.name) === null) { logWarn('createIndicator', 'value', 'indicator not supported, you may need to use registerIndicator to add one!!!') @@ -732,40 +698,46 @@ export default class ChartImp implements Chart { const result = this._chartStore.getIndicatorStore().addInstance(indicator, paneId, isStack ?? false) if (result) { this.adjustPaneViewport(true, true, true, true, true) - callback?.() } } return paneId ?? null } - overrideIndicator (override: IndicatorCreate, paneId?: Nullable, callback?: () => void): void { - const result = this._chartStore.getIndicatorStore().override(override, paneId ?? null) + overrideIndicator (override: IndicatorCreate): void { + const result = this._chartStore.getIndicatorStore().override(override) if (result) { this.adjustPaneViewport(false, false, true) - callback?.() } } - getIndicatorByPaneId (paneId?: string, name?: string): Nullable | Nullable> | Map> { - return this._chartStore.getIndicatorStore().getInstanceByPaneId(paneId, name) + getIndicators (filter?: IndicatorFilter): Map { + return this._chartStore.getIndicatorStore().getInstanceByFilter(filter ?? {}) } - removeIndicator (paneId: string, name?: string): void { + removeIndicator (filter?: IndicatorFilter): void { const indicatorStore = this._chartStore.getIndicatorStore() - const removed = indicatorStore.removeInstance(paneId, name) + const removed = indicatorStore.removeInstance(filter ?? {}) if (removed) { let shouldMeasureHeight = false - if (paneId !== PaneIdConstants.CANDLE) { + const paneIds: string[] = [] + this._drawPanes.forEach(pane => { + const paneId = pane.getId() + if (paneId !== PaneIdConstants.CANDLE && paneId !== PaneIdConstants.X_AXIS) { + paneIds.push(paneId) + } + }) + + paneIds.forEach(paneId => { if (!indicatorStore.hasInstances(paneId)) { - const pane = this.getDrawPaneById(paneId) - const index = this._drawPanes.findIndex(p => p.getId() === paneId) - if (pane !== null) { + const index = this._drawPanes.findIndex(pane => pane.getId() === paneId) + const pane = this._drawPanes[index] + if (isValid(pane)) { shouldMeasureHeight = true const separatorPane = this._separatorPanes.get(pane) if (isValid(separatorPane)) { const topPane = separatorPane?.getTopPane() for (const item of this._separatorPanes) { - if (item[1].getTopPane().getId() === pane.getId()) { + if (item[1].getTopPane().getId() === paneId) { item[1].setTopPane(topPane) break } @@ -786,56 +758,57 @@ export default class ChartImp implements Chart { this._separatorPanes.delete(firstPane) } } - } + }) this.adjustPaneViewport(shouldMeasureHeight, true, true, true, true) } } - createOverlay (value: string | OverlayCreate | Array, paneId?: string): Nullable | Array> { - let overlays: OverlayCreate[] = [] + createOverlay (value: string | OverlayCreate | Array): Nullable | Array> { + const overlays: OverlayCreate[] = [] + const appointPaneFlags: boolean[] = [] + + const build: ((overlay: OverlayCreate) => void) = overlay => { + if (!isValid(overlay.paneId) || this.getDrawPaneById(overlay.paneId) === null) { + overlay.paneId = PaneIdConstants.CANDLE + appointPaneFlags.push(false) + } else { + appointPaneFlags.push(true) + } + overlays.push(overlay) + } + if (isString(value)) { - overlays = [{ name: value }] + build({ name: value }) } else if (isArray>(value)) { - overlays = (value as Array).map((v: string | OverlayCreate) => { + (value as Array).forEach(v => { + let overlay: OverlayCreate if (isString(v)) { - return { name: v } + overlay = { name: v } + } else { + overlay = v } - return v + build(overlay) }) } else { - const overlay = value as OverlayCreate - overlays = [overlay] - } - let appointPaneFlag = true - if (!isValid(paneId) || this.getDrawPaneById(paneId) === null) { - paneId = PaneIdConstants.CANDLE - appointPaneFlag = false + build(value as OverlayCreate) } - const ids = this._chartStore.getOverlayStore().addInstances(overlays, paneId, appointPaneFlag) + const ids = this._chartStore.getOverlayStore().addInstances(overlays, appointPaneFlags) if (isArray(value)) { return ids } return ids[0] } - getOverlayById (id: string): Nullable { - return this._chartStore.getOverlayStore().getInstanceById(id) ?? null + getOverlays (filter?: OverlayFilter): Map { + return this._chartStore.getOverlayStore().getInstanceByFilter(filter ?? {}) } overrideOverlay (override: Partial): void { this._chartStore.getOverlayStore().override(override) } - removeOverlay (remove?: string | OverlayRemove): void { - let overlayRemove: OverlayRemove - if (isValid(remove)) { - if (isString(remove)) { - overlayRemove = { id: remove } - } else { - overlayRemove = remove - } - } - this._chartStore.getOverlayStore().removeInstance(overlayRemove!) + removeOverlay (filter?: OverlayFilter): void { + this._chartStore.getOverlayStore().removeInstance(filter ?? {}) } setPaneOptions (options: PaneOptions): void { diff --git a/src/common/LoadMoreCallback.ts b/src/common/LoadMoreCallback.ts deleted file mode 100644 index ce7d24b17..000000000 --- a/src/common/LoadMoreCallback.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type Nullable from './Nullable' - -/** - * Since v9.8.0 deprecated, since v10 removed - * @deprecated - */ -type LoadMoreCallback = (timestamp: Nullable) => void - -export default LoadMoreCallback diff --git a/src/common/Styles.ts b/src/common/Styles.ts index 97da551b9..cb3c844f9 100644 --- a/src/common/Styles.ts +++ b/src/common/Styles.ts @@ -92,22 +92,10 @@ export interface TextStyle extends Padding { backgroundColor: string | CanvasGradient } -/** - * @deprecated - * Starting from v10, it will be deleted - */ -export type RectTextStyle = TextStyle - export interface StateTextStyle extends TextStyle { show: boolean } -/** - * @deprecated - * Starting from v10, it will be deleted - */ -export type StateRectTextStyle = StateTextStyle - export type LastValueMarkTextStyle = Omit export enum TooltipShowRule { @@ -145,23 +133,11 @@ export interface TooltipLegendChild { color: string } -/** - * @deprecated - * Starting from v10, it will be deleted - */ -export type TooltipDataChild = TooltipLegendChild - export interface TooltipLegend { title: string | TooltipLegendChild value: string | TooltipLegendChild } -/** - * @deprecated - * Starting from v10, it will be deleted - */ -export type TooltipData = TooltipLegend - export enum TooltipIconPosition { Left = 'left', Middle = 'middle', @@ -349,11 +325,6 @@ export interface OverlayStyle { circle: PolygonStyle arc: LineStyle text: TextStyle - /** - * @deprecated - * Starting from v10, it will be deleted - */ - rectText: TextStyle [key: string]: any } @@ -753,8 +724,7 @@ function getDefaultOverlayStyle (): OverlayStyle { size: 1, dashedValue: [2, 2] }, - text: text(), - rectText: text() + text: text() } } diff --git a/src/component/Indicator.ts b/src/component/Indicator.ts index d62b53973..61e9ab3b2 100644 --- a/src/component/Indicator.ts +++ b/src/component/Indicator.ts @@ -85,7 +85,7 @@ export interface IndicatorTooltipData { name: string calcParamsText: string icons: TooltipIconStyle[] - values: TooltipLegend[] + legends: TooltipLegend[] } export interface IndicatorCreateTooltipDataSourceParams { @@ -221,7 +221,9 @@ export interface Indicator { export type IndicatorTemplate = ExcludePickPartial, 'result'>, 'name' | 'calc'> -export type IndicatorCreate = ExcludePickPartial, 'result'>, 'name'> +export type IndicatorCreate = ExcludePickPartial, 'result'>, 'name'> & { paneId?: string } + +export type IndicatorFilter = Partial> & { paneId?: string } export type IndicatorConstructor = new () => IndicatorImp diff --git a/src/component/Overlay.ts b/src/component/Overlay.ts index 534efade3..eace22108 100644 --- a/src/component/Overlay.ts +++ b/src/component/Overlay.ts @@ -284,7 +284,7 @@ export interface Overlay { export type OverlayTemplate = ExcludePickPartial, 'name'> export type OverlayCreate = ExcludePickPartial, 'name'> -export type OverlayRemove = Partial> +export type OverlayFilter = Partial> export type OverlayInnerConstructor = new () => OverlayImp export type OverlayConstructor = new () => Overlay diff --git a/src/component/YAxis.ts b/src/component/YAxis.ts index cf58f2f6e..dbb83903f 100644 --- a/src/component/YAxis.ts +++ b/src/component/YAxis.ts @@ -32,7 +32,7 @@ import { PaneIdConstants } from '../pane/types' export type YAxisTemplate = AxisTemplate -const TICK_COUNT = 10 +const TICK_COUNT = 8 export interface YAxis extends Axis, YAxisTemplate { isFromZero: () => boolean @@ -109,7 +109,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().getInstances(parent.getId()) + const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(parent.getId()) indicators.forEach(indicator => { if (!shouldOhlc) { shouldOhlc = indicator.shouldOhlc ?? false @@ -287,7 +287,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis { const chartStore = pane.getChart().getChartStore() const customApi = chartStore.getCustomApi() const optimalTicks: AxisTick[] = [] - const indicators = chartStore.getIndicatorStore().getInstances(pane.getId()) + const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId()) const thousandsSeparator = chartStore.getThousandsSeparator() const decimalFoldThreshold = chartStore.getDecimalFoldThreshold() let precision = 0 @@ -362,7 +362,7 @@ export default abstract class YAxisImp extends AxisImp implements YAxis { crosshairStyles.horizontal.show && crosshairStyles.horizontal.text.show ) { - const indicators = chartStore.getIndicatorStore().getInstances(pane.getId()) + const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId()) let indicatorPrecision = 0 let shouldFormatBigNumber = false indicators.forEach(indicator => { diff --git a/src/extension/figure/index.ts b/src/extension/figure/index.ts index 83033c968..cf0774daa 100644 --- a/src/extension/figure/index.ts +++ b/src/extension/figure/index.ts @@ -21,12 +21,11 @@ import line from './line' import polygon from './polygon' import rect from './rect' import text from './text' -import rectText from './rectText' import arc from './arc' const figures: Record = {} -const extensions = [circle, line, polygon, rect, text, rectText, arc] +const extensions = [circle, line, polygon, rect, text, arc] extensions.forEach((figure: FigureTemplate) => { figures[figure.name] = FigureImp.extend(figure) }) diff --git a/src/extension/figure/rectText.ts b/src/extension/figure/rectText.ts deleted file mode 100644 index 1affc2cdb..000000000 --- a/src/extension/figure/rectText.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import text, { drawText } from './text' - -/** - * @deprecated - * Starting from v10, it will be deleted - */ -const rectText = text - -/** - * @deprecated - * Starting from v10, it will be deleted - */ -const drawRectText = drawText - -/** - * @deprecated - * Starting from v10, it will be deleted - */ -export { - drawRectText -} - -export default rectText diff --git a/src/index.ts b/src/index.ts index 18743b8d5..1c7c6094d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,7 +52,6 @@ import { } from './extension/figure/line' import { checkCoordinateOnPolygon, drawPolygon } from './extension/figure/polygon' import { checkCoordinateOnRect, drawRect } from './extension/figure/rect' -import { drawRectText } from './extension/figure/rectText' import { checkCoordinateOnText, drawText } from './extension/figure/text' import { registerFigure, getSupportedFigures, getFigureClass } from './extension/figure/index' @@ -159,8 +158,7 @@ const utils = { drawLine, drawPolygon, drawRect, - drawText, - drawRectText + drawText } export { diff --git a/src/pane/types.ts b/src/pane/types.ts index 5a070e1e3..0115e6ea3 100644 --- a/src/pane/types.ts +++ b/src/pane/types.ts @@ -14,11 +14,6 @@ import { type AxisCreate } from '../component/Axis' -export interface PaneGap { - top?: number - bottom?: number -} - export const enum PanePosition { Top = 'top', Bottom = 'bottom' diff --git a/src/store/ChartStore.ts b/src/store/ChartStore.ts index b1b388df4..fe33ab76f 100644 --- a/src/store/ChartStore.ts +++ b/src/store/ChartStore.ts @@ -21,7 +21,6 @@ import { getDefaultStyles, type Styles, type TooltipLegend } from '../common/Sty import { isArray, isNumber, isString, isValid, merge } from '../common/utils/typeChecks' import type LoadDataCallback from '../common/LoadDataCallback' import { type LoadDataParams, LoadDataType } from '../common/LoadDataCallback' -import type LoadMoreCallback from '../common/LoadMoreCallback' import { ActionType } from '../common/Action' import { getDefaultCustomApi, type CustomApi, defaultLocale, type Options } from '../Options' @@ -74,13 +73,6 @@ export default class ChartStore { */ private _dataList: KLineData[] = [] - /** - * Load more data callback - * Since v9.8.0 deprecated, since v10 removed - * @deprecated - */ - private _loadMoreCallback: Nullable = null - /** * Load data callback */ @@ -290,24 +282,13 @@ export default class ChartStore { if (adjustFlag) { this._timeScaleStore.adjustVisibleRange() this._tooltipStore.recalculateCrosshair(true) - this._indicatorStore.calcInstance() + this._indicatorStore.calcInstance({}) this._chart.adjustPaneViewport(false, true, true, true) } this._actionStore.execute(ActionType.OnDataReady) } } - setLoadMoreCallback (callback: LoadMoreCallback): void { - this._loadMoreCallback = callback - } - - executeLoadMoreCallback (timestamp: Nullable): void { - if (this._forwardMore && !this._loading && isValid(this._loadMoreCallback)) { - this._loading = true - this._loadMoreCallback(timestamp) - } - } - setLoadDataCallback (callback: LoadDataCallback): void { this._loadDataCallback = callback } diff --git a/src/store/IndicatorStore.ts b/src/store/IndicatorStore.ts index 7045d8187..2fb264cb9 100644 --- a/src/store/IndicatorStore.ts +++ b/src/store/IndicatorStore.ts @@ -12,12 +12,11 @@ * limitations under the License. */ -import type Nullable from '../common/Nullable' import { isValid, isString } from '../common/utils/typeChecks' import type ChartStore from './ChartStore' -import { type IndicatorCreate, type Indicator } from '../component/Indicator' +import { type IndicatorCreate, type IndicatorFilter } from '../component/Indicator' import type IndicatorImp from '../component/Indicator' import { IndicatorSeries } from '../component/Indicator' import { getIndicatorClass } from '../extension/indicator/index' @@ -74,7 +73,7 @@ export default class IndicatorStore { this.synchronizeSeriesPrecision(instance) instance.override(indicator) if (!isStack) { - this.removeInstance(paneId) + this.removeInstance({ paneId }) paneInstances = [] } paneInstances.push(instance) @@ -84,32 +83,53 @@ export default class IndicatorStore { return true } - getInstances (paneId: string): IndicatorImp[] { + getInstanceByPaneId (paneId: string): IndicatorImp[] { return this._instances.get(paneId) ?? [] } - removeInstance (paneId: string, name?: string): boolean { + getInstanceByFilter (filter: IndicatorFilter): Map { + const find: ((indicators: IndicatorImp[], name?: string) => IndicatorImp[]) = (indicators, name) => { + return indicators.filter(indicator => { + return !isValid(name) || indicator.name === name + }) + } + const { paneId, name } = filter + const map = new Map() + if (isValid(paneId)) { + const indicators = this.getInstanceByPaneId(paneId) + map.set(paneId, find(indicators, name)) + } else { + if (isValid(name)) { + const map = new Map() + this._instances.forEach((indicators, paneId) => { + map.set(paneId, find(indicators, name)) + }) + } else { + this._instances.forEach((indicators, paneId) => { + map.set(paneId, find(indicators)) + }) + } + } + return map + } + + removeInstance (filter: IndicatorFilter): boolean { let removed = false - const paneInstances = this._instances.get(paneId) - if (isValid(paneInstances)) { - if (isString(name)) { - const index = paneInstances.findIndex(ins => ins.name === name) + const filterMap = this.getInstanceByFilter(filter) + filterMap.forEach((indicators, paneId) => { + const paneInstances = this.getInstanceByPaneId(paneId) + indicators.forEach(indicator => { + const index = paneInstances.findIndex(ins => ins.name === indicator.name) if (index > -1) { - this._scheduler.removeTask(generateTaskId(paneId, name)) + this._scheduler.removeTask(generateTaskId(paneId, indicator.name)) paneInstances.splice(index, 1) removed = true } - } else { - paneInstances.forEach(instance => { - this._scheduler.removeTask(generateTaskId(paneId, instance.name)) - }) - this._instances.set(paneId, []) - removed = true - } - if (this._instances.get(paneId)?.length === 0) { + }) + if (paneInstances.length === 0) { this._instances.delete(paneId) } - } + }) return removed } @@ -117,54 +137,13 @@ export default class IndicatorStore { return this._instances.has(paneId) } - calcInstance (name?: string, paneId?: string): void { - if (isString(name)) { - if (isString(paneId)) { - const paneInstances = this._instances.get(paneId) - if (isValid(paneInstances)) { - const instance = paneInstances.find(ins => ins.name === name) - if (isValid(instance)) { - this._addTask(paneId, instance) - } - } - } else { - this._instances.forEach((paneInstances, paneId) => { - const instance = paneInstances.find(ins => ins.name === name) - if (isValid(instance)) { - this._addTask(paneId, instance) - } - }) - } - } else { - this._instances.forEach((paneInstances, paneId) => { - paneInstances.forEach(instance => { - this._addTask(paneId, instance) - }) - }) - } - } - - getInstanceByPaneId (paneId?: string, name?: string): Nullable | Nullable> | Map> { - const createMapping: ((instances: IndicatorImp[]) => Map) = (instances: IndicatorImp[]) => { - const mapping = new Map() - instances.forEach(ins => { - mapping.set(ins.name, ins) + calcInstance (filter: IndicatorFilter): void { + const filterMap = this.getInstanceByFilter(filter) + filterMap.forEach((indicators, paneId) => { + indicators.forEach(indicator => { + this._addTask(paneId, indicator) }) - return mapping - } - - if (isString(paneId)) { - const paneInstances = this._instances.get(paneId) ?? [] - if (isString(name)) { - return paneInstances?.find(ins => ins.name === name) ?? null - } - return createMapping(paneInstances) - } - const mapping = new Map>() - this._instances.forEach((instances, paneId) => { - mapping.set(paneId, createMapping(instances)) }) - return mapping } synchronizeSeriesPrecision (indicator?: IndicatorImp): void { @@ -194,10 +173,10 @@ export default class IndicatorStore { } } - override (indicator: IndicatorCreate, paneId: Nullable): boolean { - const { name } = indicator + override (indicator: IndicatorCreate): boolean { + const { name, paneId } = indicator let instances = new Map() - if (paneId !== null) { + if (isValid(paneId)) { const paneInstances = this._instances.get(paneId) if (isValid(paneInstances)) { instances.set(paneId, paneInstances) diff --git a/src/store/OverlayStore.ts b/src/store/OverlayStore.ts index 9902a00e2..6c1f98566 100644 --- a/src/store/OverlayStore.ts +++ b/src/store/OverlayStore.ts @@ -20,7 +20,7 @@ import { createId } from '../common/utils/id' import { LoadDataType } from '../common/LoadDataCallback' import type OverlayImp from '../component/Overlay' -import { type OverlayCreate, type OverlayRemove, OVERLAY_ID_PREFIX } from '../component/Overlay' +import { type OverlayCreate, OVERLAY_ID_PREFIX, type OverlayFilter } from '../component/Overlay' import { getOverlayInnerClass } from '../extension/overlay/index' @@ -50,7 +50,7 @@ export interface EventOverlayInfo { export default class OverlayStore { private readonly _chartStore: ChartStore - private _instances = new Map() + private readonly _instances = new Map() /** * Overlay information in painting @@ -97,20 +97,48 @@ export default class OverlayStore { this._chartStore = chartStore } - getInstanceById (id: string): Nullable { - for (const entry of this._instances) { - const paneOverlays = entry[1] - const overlay = paneOverlays.find(o => o.id === id) - if (isValid(overlay)) { - return overlay - } + getInstanceByFilter (filter: OverlayFilter): Map { + const { id, groupId, paneId, name } = filter + const find: ((overlays: OverlayImp[]) => OverlayImp[]) = (overlays) => { + return overlays.filter(overlay => { + if (isValid(id)) { + return overlay.id === id + } else { + if (isValid(groupId)) { + return overlay.groupId === groupId && (!isValid(name) || overlay.name === name) + } + } + return !isValid(name) || overlay.name === name + }) } - if (this._progressInstanceInfo !== null) { - if (this._progressInstanceInfo.instance.id === id) { - return this._progressInstanceInfo.instance - } + + const map = new Map() + if (isValid(paneId)) { + const overlays = this.getInstanceByPaneId(paneId) + map.set(paneId, find(overlays)) + } else { + this._instances.forEach((overlays, paneId) => { + map.set(paneId, find(overlays)) + }) } - return null + const progressOverlay = this._progressInstanceInfo?.instance + if (isValid(progressOverlay)) { + const paneOverlays = map.get(progressOverlay.paneId) ?? [] + paneOverlays.push(progressOverlay) + map.set(progressOverlay.paneId, paneOverlays) + } + return map + } + + getInstanceByPaneId (paneId?: string): OverlayImp[] { + if (!isString(paneId)) { + let overlays: OverlayImp[] = [] + this._instances.forEach(paneOverlays => { + overlays = overlays.concat(paneOverlays) + }) + return overlays + } + return this._instances.get(paneId) ?? [] } private _sort (paneId?: string): void { @@ -123,39 +151,55 @@ export default class OverlayStore { } } - addInstances (overlays: OverlayCreate[], paneId: string, appointPaneFlag: boolean): Array> { - const ids = overlays.map(overlay => { - const id = overlay.id ?? createId(OVERLAY_ID_PREFIX) - if (this.getInstanceById(id) === null) { - const OverlayClazz = getOverlayInnerClass(overlay.name) - if (OverlayClazz !== null) { - const instance = new OverlayClazz() - instance.override({ paneId }) - const groupId = overlay.groupId ?? id - overlay.id = id - overlay.paneId = paneId - overlay.groupId = groupId - instance.override(overlay) - if (instance.isDrawing()) { - this._progressInstanceInfo = { paneId, instance, appointPaneFlag } - } else { - if (!this._instances.has(paneId)) { - this._instances.set(paneId, []) - } - this._instances.get(paneId)?.push(instance) + addInstances (overlays: OverlayCreate[], appointPaneFlags: boolean[]): Array> { + const updatePaneIds: string[] = [] + const ids = overlays.map((overlay, index) => { + if (isValid(overlay.id)) { + let findOverlay: Nullable = null + for (const [, overlays] of this._instances) { + const overlay = overlays.find(o => o.id === overlay.id) + if (isValid(overlay)) { + findOverlay = overlay + break } - if (instance.isStart()) { - instance.onDrawStart?.(({ overlay: instance })) + } + if (isValid(findOverlay)) { + return overlay.id + } + } + const OverlayClazz = getOverlayInnerClass(overlay.name) + if (isValid(OverlayClazz)) { + const id = overlay.id ?? createId(OVERLAY_ID_PREFIX) + const instance = new OverlayClazz() + const groupId = overlay.groupId ?? id + overlay.id = id + overlay.groupId = groupId + instance.override(overlay) + const paneId = instance.paneId + if (!updatePaneIds.includes(paneId)) { + updatePaneIds.push(paneId) + } + if (instance.isDrawing()) { + this._progressInstanceInfo = { paneId, instance, appointPaneFlag: appointPaneFlags[index] } + } else { + if (!this._instances.has(paneId)) { + this._instances.set(paneId, []) } - return id + this._instances.get(paneId)?.push(instance) + } + if (instance.isStart()) { + instance.onDrawStart?.(({ overlay: instance })) } + return id } return null }) - if (ids.some(id => id !== null)) { + if (updatePaneIds.length > 0) { this._sort() const chart = this._chartStore.getChart() - chart.updatePane(UpdateLevel.Overlay, paneId) + updatePaneIds.forEach(paneId => { + chart.updatePane(UpdateLevel.Overlay, paneId) + }) chart.updatePane(UpdateLevel.Overlay, PaneIdConstants.X_AXIS) } return ids @@ -189,135 +233,61 @@ export default class OverlayStore { } } - getInstances (paneId?: string): OverlayImp[] { - if (!isString(paneId)) { - let instances: OverlayImp[] = [] - this._instances.forEach(paneInstances => { - instances = instances.concat(paneInstances) - }) - return instances - } - return this._instances.get(paneId) ?? [] - } - override (overlay: Partial): void { - const { id, groupId, name } = overlay - let updateFlag = false let sortFlag = false - const setFlag: (instance: OverlayImp) => void = (instance: OverlayImp) => { - instance.override(overlay) - const { sort, draw } = instance.shouldUpdate() - - if (draw) { - updateFlag = true - } - if (sort) { - sortFlag = true - } - } - - if (isString(id)) { - const instance = this.getInstanceById(id) - if (instance !== null) { - setFlag(instance) - } - } else { - const nameValid = isString(name) - const groupIdValid = isString(groupId) - this._instances.forEach(paneInstances => { - paneInstances.forEach(instance => { - if ( - (nameValid && instance.name === name) || - (groupIdValid && instance.groupId === groupId) || - (!nameValid && !groupIdValid) - ) { - setFlag(instance) + const updatePaneIds: string[] = [] + const filterMap = this.getInstanceByFilter(overlay) + filterMap.forEach((instances, paneId) => { + instances.forEach(instance => { + instance.override(overlay) + const { sort, draw } = instance.shouldUpdate() + if (sort) { + sortFlag = true + } + if (sort || draw) { + if (!updatePaneIds.includes(paneId)) { + updatePaneIds.push(paneId) } - }) - }) - if (this._progressInstanceInfo !== null) { - const progressInstance = this._progressInstanceInfo.instance - if ( - (nameValid && progressInstance.name === name) || - (groupIdValid && progressInstance.groupId === groupId) || - (!nameValid && !groupIdValid) - ) { - setFlag(progressInstance) } - } - } + }) + }) + if (sortFlag) { this._sort() } - if (updateFlag) { - this._chartStore.getChart().updatePane(UpdateLevel.Overlay) + if (updatePaneIds.length > 0) { + const chart = this._chartStore.getChart() + updatePaneIds.forEach(paneId => { + chart.updatePane(UpdateLevel.Overlay, paneId) + }) + chart.updatePane(UpdateLevel.Overlay, PaneIdConstants.X_AXIS) } } - removeInstance (overlayRemove?: OverlayRemove): void { - const match: ((remove: OverlayRemove, overlay: OverlayImp) => boolean) = (remove: OverlayRemove, overlay: OverlayImp) => { - if (isString(remove.id)) { - if (overlay.id !== remove.id) { - return false + removeInstance (filter: OverlayFilter): void { + const updatePaneIds: string[] = [] + const filterMap = this.getInstanceByFilter(filter) + filterMap.forEach((overlays, paneId) => { + const paneOverlays = this.getInstanceByPaneId(paneId) + overlays.forEach(overlay => { + overlay.onRemoved?.({ overlay }) + if (!updatePaneIds.includes(paneId)) { + updatePaneIds.push(paneId) } - } else { - if (isString(remove.groupId)) { - if (overlay.groupId !== remove.groupId) { - return false - } + if (overlay.isDrawing()) { + this._progressInstanceInfo = null } else { - if (isString(remove.name)) { - if (overlay.name !== remove.name) { - return false - } + const index = paneOverlays.findIndex(o => o.id === overlay.id) + if (index > -1) { + paneOverlays.splice(index, 1) } } - } - return true - } - - const updatePaneIds: string[] = [] - const overlayRemoveValid = isValid(overlayRemove) - if (this._progressInstanceInfo !== null) { - const { instance } = this._progressInstanceInfo - if ( - !overlayRemoveValid || - (overlayRemoveValid && match(overlayRemove, instance)) - ) { - updatePaneIds.push(this._progressInstanceInfo.paneId) - instance.onRemoved?.({ overlay: instance }) - this._progressInstanceInfo = null - } - } - if (overlayRemoveValid) { - const instances = new Map() - for (const entry of this._instances) { - const paneInstances = entry[1] - const newPaneInstances = paneInstances.filter(instance => { - if (match(overlayRemove, instance)) { - if (!updatePaneIds.includes(entry[0])) { - updatePaneIds.push(entry[0]) - } - instance.onRemoved?.({ overlay: instance }) - return false - } - return true - }) - if (newPaneInstances.length > 0) { - instances.set(entry[0], newPaneInstances) + if (paneOverlays.length === 0) { + this._instances.delete(paneId) } - } - this._instances = instances - } else { - this._instances.forEach((paneInstances, paneId) => { - updatePaneIds.push(paneId) - paneInstances.forEach(instance => { - instance.onRemoved?.({ overlay: instance }) - }) }) - this._instances.clear() - } + }) if (updatePaneIds.length > 0) { const chart = this._chartStore.getChart() updatePaneIds.forEach(paneId => { diff --git a/src/store/TimeScaleStore.ts b/src/store/TimeScaleStore.ts index d77051a2e..dd2ddca39 100644 --- a/src/store/TimeScaleStore.ts +++ b/src/store/TimeScaleStore.ts @@ -312,7 +312,6 @@ export default class TimeScaleStore { // More processing and loading, more loading if there are callback methods and no data is being loaded if (from === 0) { const firstData = dataList[0] - this._chartStore.executeLoadMoreCallback(firstData?.timestamp ?? null) this._chartStore.executeLoadDataCallback({ type: LoadDataType.Forward, data: firstData ?? null diff --git a/src/view/CandleTooltipView.ts b/src/view/CandleTooltipView.ts index 27932624f..991d91ce2 100644 --- a/src/view/CandleTooltipView.ts +++ b/src/view/CandleTooltipView.ts @@ -56,7 +56,7 @@ export default class CandleTooltipView extends IndicatorTooltipView { const thousandsSeparator = chartStore.getThousandsSeparator() const decimalFoldThreshold = chartStore.getDecimalFoldThreshold() const activeIcon = chartStore.getTooltipStore().getActiveIcon() - const indicators = chartStore.getIndicatorStore().getInstances(pane.getId()) + const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId()) const dateTimeFormat = chartStore.getTimeScaleStore().getDateTimeFormat() const styles = chartStore.getStyles() const candleStyles = styles.candle @@ -272,9 +272,9 @@ export default class CandleTooltipView extends IndicatorTooltipView { if (isDrawIndicatorTooltip) { ctx.font = createFont(indicatorTextSize, indicatorTextWeight, indicatorTextFamily) indicators.forEach(indicator => { - const tooltipDataValues = this.getIndicatorTooltipData(dataList, crosshair, indicator, customApi, thousandsSeparator, decimalFoldThreshold, indicatorStyles).values ?? [] - indicatorLegendsArray.push(tooltipDataValues) - tooltipDataValues.forEach(data => { + const tooltipDataLegends = this.getIndicatorTooltipData(dataList, crosshair, indicator, customApi, thousandsSeparator, decimalFoldThreshold, indicatorStyles).legends ?? [] + indicatorLegendsArray.push(tooltipDataLegends) + tooltipDataLegends.forEach(data => { const title = data.title as TooltipLegendChild const value = data.value as TooltipLegendChild const text = `${title.text}${value.text}` diff --git a/src/view/CrosshairHorizontalLabelView.ts b/src/view/CrosshairHorizontalLabelView.ts index 0e1cc28fb..ccde6c49c 100644 --- a/src/view/CrosshairHorizontalLabelView.ts +++ b/src/view/CrosshairHorizontalLabelView.ts @@ -70,7 +70,7 @@ export default class CrosshairHorizontalLabelView extend if (yAxis.isInCandle()) { precision = chartStore.getPrecision().price } else { - const indicators = chartStore.getIndicatorStore().getInstances(crosshair.paneId!) + const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(crosshair.paneId!) indicators.forEach(indicator => { precision = Math.max(indicator.precision, precision) if (!shouldFormatBigNumber) { diff --git a/src/view/IndicatorLastValueView.ts b/src/view/IndicatorLastValueView.ts index 0ac98498b..3a88cec37 100644 --- a/src/view/IndicatorLastValueView.ts +++ b/src/view/IndicatorLastValueView.ts @@ -35,7 +35,7 @@ export default class IndicatorLastValueView extends View { const yAxis = pane.getAxisComponent() const dataList = chartStore.getDataList() const dataIndex = dataList.length - 1 - const indicators = chartStore.getIndicatorStore().getInstances(pane.getId()) + const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId()) const thousandsSeparator = chartStore.getThousandsSeparator() const decimalFoldThreshold = chartStore.getDecimalFoldThreshold() indicators.forEach(indicator => { diff --git a/src/view/IndicatorTooltipView.ts b/src/view/IndicatorTooltipView.ts index f4da4e1e0..43b4568af 100644 --- a/src/view/IndicatorTooltipView.ts +++ b/src/view/IndicatorTooltipView.ts @@ -58,7 +58,7 @@ export default class IndicatorTooltipView extends View { const customApi = chartStore.getCustomApi() const thousandsSeparator = chartStore.getThousandsSeparator() const decimalFoldThreshold = chartStore.getDecimalFoldThreshold() - const indicators = chartStore.getIndicatorStore().getInstances(pane.getId()) + const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId()) const activeIcon = chartStore.getTooltipStore().getActiveIcon() const defaultStyles = chartStore.getStyles().indicator const { offsetLeft, offsetTop, offsetRight } = defaultStyles.tooltip @@ -93,7 +93,7 @@ export default class IndicatorTooltipView extends View { indicators.forEach(indicator => { let prevRowHeight = 0 const coordinate = { x: left, y: top } - const { name, calcParamsText, values: legends, icons } = this.getIndicatorTooltipData(dataList, crosshair, indicator, customApi, thousandsSeparator, decimalFoldThreshold, styles) + const { name, calcParamsText, legends, icons } = this.getIndicatorTooltipData(dataList, crosshair, indicator, customApi, thousandsSeparator, decimalFoldThreshold, styles) const nameValid = name.length > 0 const legendValid = legends.length > 0 if (nameValid || legendValid) { @@ -276,7 +276,7 @@ export default class IndicatorTooltipView extends View { calcParamsText = `(${calcParams.join(',')})` } - const tooltipData: IndicatorTooltipData = { name, calcParamsText, values: [], icons: tooltipStyles.icons } + const tooltipData: IndicatorTooltipData = { name, calcParamsText, legends: [], icons: tooltipStyles.icons } const dataIndex = crosshair.dataIndex! const result = indicator.result ?? [] @@ -297,14 +297,14 @@ export default class IndicatorTooltipView extends View { legends.push({ title: { text: figure.title, color }, value: { text: formatFoldDecimal(formatThousands((value ?? tooltipStyles.defaultValue) as string, thousandsSeparator), decimalFoldThreshold), color } }) } }) - tooltipData.values = legends + tooltipData.legends = legends } if (indicator.createTooltipDataSource !== null) { const widget = this.getWidget() const pane = widget.getPane() const chartStore = pane.getChart().getChartStore() - const { name: customName, calcParamsText: customCalcParamsText, values: customLegends, icons: customIcons } = indicator.createTooltipDataSource({ + const { name: customName, calcParamsText: customCalcParamsText, legends: customLegends, icons: customIcons } = indicator.createTooltipDataSource({ kLineDataList: dataList, indicator, visibleRange: chartStore.getTimeScaleStore().getVisibleRange(), @@ -342,7 +342,7 @@ export default class IndicatorTooltipView extends View { value.text = formatFoldDecimal(formatThousands(value.text, thousandsSeparator), decimalFoldThreshold) optimizedLegends.push({ title, value }) }) - tooltipData.values = optimizedLegends + tooltipData.legends = optimizedLegends } } return tooltipData diff --git a/src/view/IndicatorView.ts b/src/view/IndicatorView.ts index 34a719b90..5749df5e4 100644 --- a/src/view/IndicatorView.ts +++ b/src/view/IndicatorView.ts @@ -31,7 +31,7 @@ export default class IndicatorView extends CandleBarView { const pane = this.getWidget().getPane() const yAxis = pane.getAxisComponent() if (!yAxis.isInCandle()) { - const indicators = chartStore.getIndicatorStore().getInstances(pane.getId()) + const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId()) for (const indicator of indicators) { if (indicator.shouldOhlc && indicator.visible) { const indicatorStyles = indicator.styles @@ -71,7 +71,7 @@ export default class IndicatorView extends CandleBarView { const dataList = chartStore.getDataList() const timeScaleStore = chartStore.getTimeScaleStore() const visibleRange = timeScaleStore.getVisibleRange() - const indicators = chartStore.getIndicatorStore().getInstances(pane.getId()) + const indicators = chartStore.getIndicatorStore().getInstanceByPaneId(pane.getId()) const defaultStyles = chartStore.getStyles().indicator ctx.save() indicators.forEach(indicator => { diff --git a/src/view/OverlayView.ts b/src/view/OverlayView.ts index 848a59d8a..6f1986c2c 100644 --- a/src/view/OverlayView.ts +++ b/src/view/OverlayView.ts @@ -392,7 +392,7 @@ export default class OverlayView extends View { const hoverInstanceInfo = overlayStore.getHoverInstanceInfo() const clickInstanceInfo = overlayStore.getClickInstanceInfo() const overlays = this.getCompleteOverlays(overlayStore, paneId) - const paneIndicators = chartStore.getIndicatorStore().getInstances(paneId) + const paneIndicators = chartStore.getIndicatorStore().getInstanceByPaneId(paneId) const overlayPrecision = paneIndicators.reduce((prev, indicator) => { const precision = indicator.precision prev[indicator.name] = precision @@ -512,7 +512,7 @@ export default class OverlayView extends View { } protected getCompleteOverlays (overlayStore: OverlayStore, paneId: string): OverlayImp[] { - return overlayStore.getInstances(paneId) + return overlayStore.getInstanceByPaneId(paneId) } protected getProgressOverlay (info: ProgressOverlayInfo, paneId: string): Nullable { diff --git a/src/view/OverlayXAxisView.ts b/src/view/OverlayXAxisView.ts index 50318efc9..84422db1d 100644 --- a/src/view/OverlayXAxisView.ts +++ b/src/view/OverlayXAxisView.ts @@ -42,7 +42,7 @@ export default class OverlayXAxisView extends OverlayYAxisView { } override getCompleteOverlays (overlayStore: OverlayStore): OverlayImp[] { - return overlayStore.getInstances() + return overlayStore.getInstanceByPaneId() } override getProgressOverlay (info: ProgressOverlayInfo): OverlayImp {