init(ds, options?)
init used to initialize a chart.
Tip
• When calling, you need to wait until the container is ready.
Reference
typescript
(
ds: string | HTMLElement,
options?: {
layout?: {
basicParams?: {
barSpaceLimitMin?: number
barSpaceLimitMax?: number
yAxisPosition?: 'left' | 'right'
yAxisInside?: boolean
paneMinHeight?: number
paneHeight?: number
}
panes?: Array<{
type: 'candle' | 'indicator' | 'xAxis'
content?: Array<string | IndicatorCreate | {
indicator: string | IndicatorCreate
yAxis?: Omit<YAxisOverride, 'paneId'>
}>
options?: {
id?: string
height?: number
minHeight?: number
dragEnabled?: boolean
order?: number
state?: 'normal' | 'maximize' | 'minimize'
}
}>
}
locale?: string
styles?: string | DeepPartial<Styles>
timezone?: string
formatter?: {
formatDate?: (params: {
dateTimeFormat: Intl.DateTimeFormat
timestamp: number
template: string
type: 'tooltip' | 'crosshair' | 'xAxis'
}) => string
formatBigNumber?: (value: string | number) => string
formatExtendText?: (params: {
type: 'last_price'
data: KLineData
index: number
}) => string
}
thousandsSeparator?: {
sign?: string
format: (value: number | string) => string
}
decimalFold?: {
threshold?: number
format?: (value: number | string) => string
}
zoomAnchor?: 'cursor' | 'last_bar' | { main?: 'cursor' | 'last_bar', xAxis?: 'cursor' | 'last_bar' }
}
) => ChartParameters
dsContainer, which can be a DOM element or an element id.optionsOptional configuration item.layoutCustom layout configuration.basicParamsBasic layout parameters.barSpaceLimitMinMinimum bar space.barSpaceLimitMaxMaximum bar space.yAxisPositionDefault y-axis position, supportsleftandright.yAxisInsideWhether the default y-axis is inside the pane.paneMinHeightDefault pane min height.paneHeightDefault pane height.
panesCustom pane list.typePane type, supportscandle,indicatorandxAxis.contentPane content, only supports indicators. Each item can be an indicator name, an indicator config, or{ indicator, yAxis }.indicatorIndicator name or indicator config.yAxisY-axis configuration bound to this indicator.paneIdis not required.
optionsPane configuration.idPane id.heightHeight.minHeightMin height.dragEnabledWhether the height can be adjusted by dragging.orderOrder.stateState, supportsnormal,maximizeandminimize.
localeLocale, with built-in support forzh-CNanden-US.timezoneTimezone name, such asAsia/Shanghai. If not set, the local time zone will be automatically obtained. For a list of time zone names, please refer to the Timezone List .stylesIt can be a style name registered byklinecharts.registerStylesorStyles. For details aboutStyles, see Styles. Incremental values are supported.formatterSome format APIs.formatDateFormats a date.formatBigNumberFormat big numbers, such as 1000 is converted to 1k, 1000000 is converted to 1M, etc.formatExtendTextFormat extended text.
thousandsSeparatorThousand separator configuration.signSign.formatCustom formatting method.
decimalFoldDecimal 0 folds the configuration.thresholdFold threshold.formatCustom formatting method.
zoomAnchorZoom anchor position. It can belast_bar,cursor, or an object{ main, xAxis }for main chart and x-axis separately.
Returns
init returns an object Chart。