#2478·pyecharts

dark theme never loads its JS, chart stays default

Author: mxrCreated Aug 16, 2026Updated Aug 16, 2026

dark theme does not work. Chart renders as default (white) theme.

Repro

python
from pyecharts import options
from pyecharts.charts import Bar
from pyecharts.globals import ThemeType

c = Bar(init_opts=options.InitOpts(theme=ThemeType.DARK))
c.add_xaxis(["a", "b"]).add_yaxis("x", [1, 2])
c.render("out.html")

Compare <head> output for white, chalk, dark

white (default theme, no extra JS needed):

xml
<script type="text/javascript" src="https://assets.pyecharts.org/assets/v6/echarts.min.js"></script>

chalk (works):

xml
<script type="text/javascript" src="https://assets.pyecharts.org/assets/v6/echarts.min.js"></script>
<script type="text/javascript" src="https://assets.pyecharts.org/assets/v6/themes/chalk.js"></script>

dark (broken):

xml
<script type="text/javascript" src="https://assets.pyecharts.org/assets/v6/echarts.min.js"></script>

Same output as white. chalk gets its own <script> tag for its theme file. dark does not. echarts.init(dom, 'dark', ...) runs, but no theme named 'dark' was ever registered, so it silently falls back to default.

Cause

globals.py:

python
BUILTIN_THEMES = ["light", "dark", "white"]

charts/base.py:

python
def _use_theme(self):
    if self.theme not in ThemeType.BUILTIN_THEMES:
        self.js_dependencies.add(self.theme)

dark is treated as free, like light/white. But light/white need no theme file because they're the engine's actual default. dark is not built into echarts core. Checked echarts.min.js from both assets.pyecharts.org and the official echarts npm package — neither registers a theme named dark. https://assets.pyecharts.org/assets/v6/themes/dark.js exists (200 OK) and is never loaded.

Same bug was reported in #512 back in 2018 (axes turn white, chart stays on white background). It was never fixed for the current CDN-based theme loading path.

Fix

Remove dark from BUILTIN_THEMES so it loads the same way chalk does and add a "dark": ["themes/dark", "js"] entry to pyecharts/datasets/map_filename.json.