Skip to main content
Version: Next

Plugin development

Plugins let you extend Lightweight Charts™ with your own functionality: new series types, drawing tools, indicators, watermarks, and other custom elements rendered as part of the chart. This section explains how plugins work and how to build your own.

Choosing a plugin type

You want to buildPlugin typeAttach with
A drawing tool, annotation, or overlay tied to a series and its scalesSeries primitiveISeriesApi.attachPrimitive
A pane-wide element independent of any series, such as a watermarkPane primitiveIPaneApi.attachPrimitive
A new way to draw data: a series with its own data structure and renderingCustom seriesaddCustomSeries
tip

If your element visualizes its own data, build a custom series; if it decorates a series or reacts to its scales, build a series primitive; if it belongs to the pane as a whole, build a pane primitive. Series primitives can also render on the price and time scales; pane primitives cannot.

Development workflow

  1. Scaffold a project. Run npm create lwc-plugin@latest — the create-lwc-plugin package generates a ready-to-run project for the plugin type you choose.
  2. Implement the plugin interface. Follow the article for your plugin type from the table above.
  3. Render on the canvas. Draw in the right coordinate space with Canvas rendering target, and keep lines crisp with the Pixel perfect rendering techniques.
  4. Learn from working code. The Plugin examples demo hosts interactive examples of heatmaps, alerts, watermarks, and tooltips; their sources live in the plugin-examples folder of the repository.