diff --git a/src/ChartProComponent.tsx b/src/ChartProComponent.tsx index 37d4d17..e15fb09 100644 --- a/src/ChartProComponent.tsx +++ b/src/ChartProComponent.tsx @@ -76,7 +76,7 @@ const ChartProComponent: Component = props => { const [theme, setTheme] = createSignal(props.theme) const [styles, setStyles] = createSignal(props.styles) const [locale, setLocale] = createSignal(props.locale) - + const [yScrolling, setYScrolling] = createSignal(props.yScrolling) const [symbol, setSymbol] = createSignal(props.symbol) const [period, setPeriod] = createSignal(props.period) const [indicatorModalVisible, setIndicatorModalVisible] = createSignal(false) @@ -108,6 +108,8 @@ const ChartProComponent: Component = props => { getStyles: () => widget!.getStyles(), setLocale, getLocale: () => locale(), + setYScrolling, + getYScrolling: () => yScrolling(), setTimezone: (timezone: string) => { setTimezone({ key: timezone, text: translateTimezone(props.timezone, locale()) }) }, getTimezone: () => timezone().key, setSymbol, @@ -427,6 +429,10 @@ const ChartProComponent: Component = props => { widget?.setLocale(locale()) }) + createEffect(() => { + widget?.setYScrolling(yScrolling()) + }) + createEffect(() => { widget?.setTimezone(timezone().key) }) diff --git a/src/KLineChartPro.tsx b/src/KLineChartPro.tsx index 8f5722d..c4735cd 100644 --- a/src/KLineChartPro.tsx +++ b/src/KLineChartPro.tsx @@ -70,6 +70,7 @@ export default class KLineChartPro implements ChartPro { { multiplier: 1, timespan: 'year', text: 'Y' } ] } + yScrolling={options.yScrolling ?? true} timezone={options.timezone ?? 'Asia/Shanghai'} mainIndicators={options.mainIndicators ?? ['MA']} subIndicators={options.subIndicators ?? ['VOL']} @@ -109,6 +110,14 @@ export default class KLineChartPro implements ChartPro { return this._chartApi!.getLocale() } + setYScrolling (yScrolling: boolean): void { + this._chartApi!.setYScrolling(yScrolling) + } + + getYScrolling (): boolean { + return this._chartApi!.getYScrolling() + } + setTimezone (timezone: string): void { this._chartApi!.setTimezone(timezone) } diff --git a/src/types.ts b/src/types.ts index 8f1b97c..1da120b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -48,6 +48,7 @@ export interface ChartProOptions { watermark?: string | Node theme?: string locale?: string + yScrolling?: boolean drawingBarVisible?: boolean symbol: SymbolInfo period: Period @@ -65,6 +66,8 @@ export interface ChartPro { getStyles(): Styles setLocale(locale: string): void getLocale(): string + setYScrolling(locale: boolean): void + getYScrolling(): boolean setTimezone(timezone: string): void getTimezone(): string setSymbol(symbol: SymbolInfo): void