Skip to content

init(ds, options?) โ€‹

init used to initialize a chart.

Tip

When calling, you need to wait until the container dom is ready.

Reference โ€‹

typescript
(
  ds: string | HTMLElement,
  options?: {
    layout?: Array<{
      type: 'candle' | 'indicator' | 'xAxis'
      content?: Array<Indicator | string>
      options?: {
        id?: string
        height?: number
        minHeight?: number
        dragEnabled?: boolean
        order?: number
        state?: 'normal' | 'maximize' | 'minimize'
        axis?: {
          name?: string
          reverse?: boolean
          inside?: boolean
          position?: 'left' | 'right'
          scrollZoomEnabled?: boolean
          gap?: {
            top?: number
            bottom?: number
          }
        }
      }
    }>
    locale?: string
    styles?: string | Styles
    timezone?: string
    customApi?: {
      formatDate?: (timestamp: number, format: string, type: number) => string
      formatBigNumber?: (value: string | number) => string
    }
    thousandsSeparator?: {
      sign?: string
      format: (value: number | string) => string
    }
    decimalFold?: {
      threshold?: number
      format?: (value: number | string) => string
    }
  }
) => Chart

Parameters โ€‹

  • ds Container, which can be a DOM element or an element id.
  • options Optional configuration item.
    • layout Custom layout, an array.
      • type Pane type, supports candle , indicator and xAxis .
      • content Pane content, only supports indicators.
      • options Pane configuration.
        • id Pane id.
        • height Height.
        • minHeight Min height.
        • dragEnabled Whether the height can be adjusted by dragging.
        • order Order.
        • state State, supports normal , maximize and minimize .
        • axis Axis configuration.
          • name The name of the axis.
          • reverse Whether to reverse.
          • inside Whether it is inside.
          • position Position, supports left and right.
          • scrollZoomEnabled Whether to allow scrolling and zooming.
          • gap Top and bottom margin configuration.
            • top Top margin.
            • bottom Bottom margin.
    • locale Locale, with built-in support for zh-CN and en-US .
    • timezone Timezone name, such as Asia/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 .
    • styles It can be a style name registered by klinecharts.registerStyles or Styles . For details about Styles , see Styles. Incremental values โ€‹โ€‹are supported.
    • customApi Customize some APIs.
      • formatDate Formats a date.
      • formatBigNumber Format big numbers, such as 1000 is converted to 1k, 1000000 is converted to 1M, etc.
    • thousandsSeparator Thousand separator configuration.
      • sign Sign.
      • format Custom formatting method.
    • decimalFold Decimal 0 folds the configuration.
      • threshold Fold threshold.
      • format Custom formatting method.

Returns โ€‹

init returns an object Chartใ€‚

Usage โ€‹

Basic usage โ€‹

Custom Layout โ€‹

Built-in locales โ€‹

Custom extension locale โ€‹

Set the timezone โ€‹

Built-in style templates โ€‹

Custom style templates โ€‹

Style override โ€‹

Custom time display โ€‹

Custom big decimal display โ€‹

Do not display thousands separators โ€‹

Custom the display of thousands separators โ€‹

Decimal 0 is not folded โ€‹

Decimal 0 fold custom display โ€‹