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?: {
barSpaceLimit?: {
min?: number
max?: number
}
pane?: {
height?: number
minHeight?: number
dragEnabled?: boolean
order?: number
state?: 'normal' | 'maximize' | 'minimize'
}
yAxis?: {
reverse?: boolean
inside?: boolean
needWidget?: boolean
position?: 'left' | 'right'
scrollZoomEnabled?: boolean
gap?: {
top?: number
bottom?: number
}
}
}
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' }
hotkey?: {
enabled?: boolean
exclude?: string[]
}
}
) => ChartParameters
dsContainer, which can be a DOM element or an element id.optionsOptional configuration item.layoutCustom layout configuration.barSpaceLimitBar space limit.minMinimum bar space.maxMaximum bar space.
paneDefault pane configuration.heightHeight.minHeightMin height.dragEnabledWhether the height can be adjusted by dragging.orderOrder.stateState, supportsnormal,maximizeandminimize.
yAxisDefault y-axis configuration.reverseWhether to reverse.insideWhether it is inside.needWidgetWhether to create an axis widget.positionPosition, supportsleftandright.scrollZoomEnabledWhether to allow scrolling and zooming on the Y-axis.gapTop and bottom margin configuration.topTop margin.bottomBottom margin.
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.hotkeyHot key configuration.enabledWhether hot keys are enabled.excludeGlobal hot key names to exclude.
Returns
init returns an object Chart。