how to set theme after creat a chartXY object?

168 views Asked by At

i created chartXY like this:

this.chart = lightningChart().ChartXY({container: `${this.chartId}`,theme:Themes.dark})

Does anyone know how to change the theme to Themes.light without using lightningChart().ChartXY() again?

1

There are 1 answers

2
Snekw On BEST ANSWER

The theme for a chart can't be changed after the chart has been created.

The only option is to recreate the chart with the different theme.

const lc = lightningChart()

let chart = lc.ChartXY({theme:Themes.dark})

...

// delete the old chart, also ensure that no references to the old chart is left in application code
chart.dispose()
chart = undefined

// recreate the chart
chart = lc.ChartXY({theme:Themes.light})