Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

overlay create and removal api #9

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/ChartProComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -102,6 +102,9 @@ const ChartProComponent: Component<ChartProComponentProps> = props => {
})

props.ref({
createOverlay: (value: any) => widget!.createOverlay(value),
removeOverlay: (value) => widget!.removeOverlay(value),
registerOverlay: (value) => registerOverlay(value),
setTheme,
getTheme: () => theme(),
setStyles,
Expand Down
13 changes: 12 additions & 1 deletion src/KLineChartPro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -79,6 +79,17 @@ export default class KLineChartPro implements ChartPro {

private _chartApi: Nullable<ChartPro> = 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)
Expand Down
5 changes: 4 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down