
I am trying to embed a json plot that could have either “dark” or “light” flavors.
My simplifed example code is:
def dummy_plot(dark_mode: bool) -> Dict[str,Any]:
xs = [1,2,3,4,5,6]
ys = [3,6,5,4,7,1]
data = ColumnDataSource( {
"x": xs,
"y": ys
})
p = figure(title="Simple Plot Example", x_axis_label="x", y_axis_label="y")
line = p.line(x="x", y="y", source=data, legend_label="A line!", line_width=2)
if dark_mode:
theme = DARK_MINIMAL
else:
theme = LIGHT_MINIMAL
plot_json = json_item(p, target=None, theme=theme)
plot_string = ujson.dumps(plot_json)
return {
"bokeh_css": CDN.render_css(),
"bokeh_js": CDN.render_js(),
"bokeh_plot": plot_string,
}
The returned dictionary goes to a jinja template that generates the final web page, but I don’t believe that part is the problem here, since the plot does show up. However, regardless of whether I pass in true or false for dark_mode, the plot background is always white.
What did I miss?

