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

added yScrolling api to options #7

Open
wants to merge 1 commit 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
8 changes: 7 additions & 1 deletion src/ChartProComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const ChartProComponent: Component<ChartProComponentProps> = 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)
Expand Down Expand Up @@ -108,6 +108,8 @@ const ChartProComponent: Component<ChartProComponentProps> = 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,
Expand Down Expand Up @@ -427,6 +429,10 @@ const ChartProComponent: Component<ChartProComponentProps> = props => {
widget?.setLocale(locale())
})

createEffect(() => {
widget?.setYScrolling(yScrolling())
})

createEffect(() => {
widget?.setTimezone(timezone().key)
})
Expand Down
9 changes: 9 additions & 0 deletions src/KLineChartPro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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']}
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface ChartProOptions {
watermark?: string | Node
theme?: string
locale?: string
yScrolling?: boolean
drawingBarVisible?: boolean
symbol: SymbolInfo
period: Period
Expand All @@ -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
Expand Down