Skip to main content
Version: 6.1.2

Destroying components

All LightningChart JS components can be permanently destroyed or cleaned with dispose method.

series.dispose()
chart.dispose()
lc.dispose()

When destroying components that can own other components (e.g. series are owned by chart), it is enough to dispose the top level component (e.g. chart)

chart.dispose()
// This also disposes all series of the chart

Destroying components is important in applications where charts can be created many times during the application runtime, to avoid memory leaks.

A common mistake is not disposing the top level "LightningChart reference":

const lc = lightningChart()
// `lc` also needs to be disposed before it is forgotten!
lc.dispose()
// This disposes all charts, series, etc. created using the `lc` reference.