Skip to main content

Theme

The library supports dark and light themes. Use the theme parameter in Widget Constructor to specify a theme. The default value is light. The chart layout does not contain buttons to switch the theme in the UI. Therefore, users cannot switch the theme unless you develop this option outside the library.

tip

If you want to override the default colors of the light and dark themes, you can use the Custom themes API.

Theme switching

You should switch the chart's theme when the theme of your website changes. To do this, use the changeTheme method that changes the theme on the fly.

widget.onChartReady(function() {
widget.changeTheme("dark");
});

You can call the getTheme method to get the current theme.

Note that the theme value is stored in the chart's configuration. Therefore, if you restore the chart that has the dark theme, you may see a black chart background in the light theme. In this case, you should apply the theme once again using the changeTheme method.

Theme is not fully applied