Theming System Overview
ECharts provides a powerful theming system that allows you to customize the visual appearance of your charts. Themes can control colors, fonts, backgrounds, and styling for all chart components.How Themes Work
A theme in ECharts is a JavaScript object that defines default styling options for various chart components. When you apply a theme to a chart instance, it sets the default appearance for:- Color palettes for data series
- Background colors
- Axis styling (lines, labels, grid)
- Component styles (legend, tooltip, toolbox, etc.)
- Chart-specific styles (line, bar, candlestick, etc.)
Registering Themes
Before using a custom theme, you must register it with ECharts using theregisterTheme function:
/workspace/source/src/core/echarts.ts:2912
Using Themes
Once a theme is registered, apply it when initializing a chart instance:init function accepts three parameters:
/workspace/source/src/core/echarts.ts:2788
Using a Named Theme
Using an Inline Theme Object
You can also pass a theme object directly without registering it:Theme Structure
A complete theme object can include the following properties:Dark Mode
ECharts themes can include adarkMode property to indicate they are designed for dark backgrounds:
/workspace/source/theme/dark.js:82-86
Complete Example
Next Steps
- Built-in Themes - Explore the available built-in themes
- Custom Themes - Learn how to create your own themes