diff --git a/src/ChartProComponent.tsx b/src/ChartProComponent.tsx index 37d4d176..45f9d204 100644 --- a/src/ChartProComponent.tsx +++ b/src/ChartProComponent.tsx @@ -16,7 +16,7 @@ import { createSignal, createEffect, onMount, Show, onCleanup, startTransition, import { init, dispose, utils, Nullable, Chart, OverlayMode, Styles, - TooltipIconPosition, ActionType, PaneOptions, Indicator, DomPosition, FormatDateType, DeepPartial + TooltipIconPosition, ActionType, PaneOptions, Indicator, DomPosition, FormatDateType, DeepPartial, registerOverlay } from 'klinecharts' import lodashSet from 'lodash/set' @@ -102,6 +102,9 @@ const ChartProComponent: Component = props => { }) props.ref({ + createOverlay: (value: any) => widget!.createOverlay(value), + removeOverlay: (value) => widget!.removeOverlay(value), + registerOverlay: (value) => registerOverlay(value), setTheme, getTheme: () => theme(), setStyles, diff --git a/src/KLineChartPro.tsx b/src/KLineChartPro.tsx index bac9e893..5d7f03f5 100644 --- a/src/KLineChartPro.tsx +++ b/src/KLineChartPro.tsx @@ -14,7 +14,7 @@ import { render } from 'solid-js/web' -import { utils, Nullable, DeepPartial, Styles } from 'klinecharts' +import { utils, Nullable, DeepPartial, Styles, OverlayRemove, OverlayTemplate } from 'klinecharts' import ChartProComponent from './ChartProComponent' @@ -79,6 +79,17 @@ export default class KLineChartPro implements ChartPro { private _chartApi: Nullable = null + createOverlay (value: any): void { + return this._chartApi!.createOverlay(value) + } + + removeOverlay (value?: string | OverlayRemove): void { + return this._chartApi!.removeOverlay(value) + } + + registerOverlay (template: OverlayTemplate): void { + return this._chartApi!.registerOverlay(template) + } setTheme (theme: string): void { this._container?.setAttribute('data-theme', theme) diff --git a/src/types.ts b/src/types.ts index 8f1b97c9..0300892a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -12,7 +12,7 @@ * limitations under the License. */ -import { KLineData, Styles, DeepPartial } from 'klinecharts' +import { KLineData, Styles, DeepPartial, OverlayRemove, OverlayTemplate } from 'klinecharts' export interface SymbolInfo { ticker: string @@ -66,6 +66,9 @@ export interface ChartPro { setLocale(locale: string): void getLocale(): string setTimezone(timezone: string): void + createOverlay (value: any, paneId?: string): any + removeOverlay: (remove?: string | OverlayRemove) => void + registerOverlay(template: OverlayTemplate): void getTimezone(): string setSymbol(symbol: SymbolInfo): void getSymbol(): SymbolInfo