Skip to content

Core concepts

Chart and options

Create a chart, choose a backend, and configure layout, grid, crosshair, scales, and input.

Creating a chart

Signature
createChart(container: HTMLElement, options?: deep_partial<chart_options>): Promise<chart_api>

The chart installs its canvases inside container. If creation fails, it removes them and leaves the container as it was. Without initialPane, the first pane is a financial time pane.

Options

Chart options
OptionWhat it controls
autoSizeFollow the container size with a ResizeObserver. Default false.
theme"light" or "dark". Applied under your explicit options, and switchable live with applyOptions.
backend"auto" (WebGPU with Canvas2D fallback, the default) or "canvas2d".
layoutbackground, textColor, mutedTextColor, bullishColor, bearishColor, fontSize, fontFamily, and pane separators (panes.enableResize defaults to true).
gridvertLines and horzLines. Visible and dashed by default.
crosshairvertLine, horzLine, and mode.
leftPriceScale, rightPriceScalePrice scale visibility, borders, margins, and mode.
timeScaleTime axis border and color, plus time-scale options through chart.timeScale().applyOptions().
watermarkText watermark: visible, text, color, font, and alignment.
wheel_behavior"auto", "pan", or "zoom" for the mouse wheel.
handle_scroll, handle_scaleTurn pan and zoom input on or off. Both default to true.
kinetic_scrollMomentum scrolling. Touch only by default.
price_axis_wheel_zoomZoom price with the wheel over the price axis. Default false.
accessibilityKeyboard and screen-reader support. On by default.
localizationFormatter callbacks for prices and times.
initialPaneThe first pane's horizontal domain, for general-only charts.
licenseKeyCommercial license key. Read at creation only.

Example

Configured chart
const chart = await createChart(container, {
  autoSize: true,
  theme: "dark",
  layout: { fontSize: 12 },
  grid: { vertLines: { visible: false } },
  rightPriceScale: { borderVisible: false },
  wheel_behavior: "auto",
});

// Change options later on the same chart.
chart.applyOptions({ theme: "light" });

Rendering backend

By default the chart uses WebGPU and falls back to Canvas2D when WebGPU is unavailable. Both backends execute the same frame, so the output matches. backend_status() reports the requested and active backend and the reason for any fallback.

Backend
const chart = await createChart(container, { backend: "canvas2d" });
console.log(chart.backend(), chart.backend_status());

Chart methods

Chart methods by purpose
PurposeMethods
Seriesadd_series, add_custom_series, remove_series, series_order, set_series_order
Panespanes, add_pane, remove_pane, swap_panes
Scalestime_scale, price_scale, add_price_scale, price_scales, move_price_scale, remove_price_scale
General axesadd_axis, axis, axes, remove_axis, compose_general_pane
Coordinatesprice_to_coordinate, coordinate_to_price, value_snapshot, format_time_label
Crosshairset_crosshair_position, clear_crosshair_position, apply_external_crosshair
Viewresize, render, reset_view, reset_style_to_defaults, apply_options, options
Stateexport_state, import_state, take_screenshot
Diagnosticsbackend, backend_status, frame_stats
Domainstrading, alerts, accessibility
Lifecycleremove