Open Hugovdberg opened 3 years ago
Thanks - sphinx does not use the renderers framework, unfortunately, so renderer settings will not apply. You'll need to find another way to specify those settings. Renderers are what are used to render charts in Jupyter/IPython environments.
I think this is more of a documentation issue than a bug, to be honest.
Through some digging in the code I see that it is possible to call plot.to_html(embed_options=alt.renderers.options['embed_options'])
, which includes the options in the embedOptions for saving, but that option appears to be missing from the sphinxext altogether. I would expect those options to be included automatically, or at least to provide a shorthand. So this is indeed more of a documentation issue.
Regarding sphinx, perhaps the renderers framework is not the most appropriate location for the embed options in sphinx, but those settings are still relevant in the sphinx context I think. Perhaps the sphinx extension could pick up the locale settings from sphinx and apply those to the plots, or allow specification of the embed options in conf.py
?
I saw this message in the CI of Altair in the build run that might be related to this issue:
/home/runner/.local/share/hatch/env/virtual/altair/801ceKDt/doc/lib/python3.10/site-packages/sphinxext_altair/altairplot.py:261: UserWarning: altair-plot: /home/runner/work/altair/altair/doc/user_guide/customization.rst:826 Code Execution failed:NameError: name 'format_locale' is not defined
I include several altair plots in a Sphinx project, and I wish to set the locale to Dutch. In Jupyter I can use the following to set the locale:
However, when exporting to json/html or using sphinxext these settings are lost from the embed options:
The variable
embedOpt
is missing the configured locale settings.I can workaround this in the sphinx extension by rewriting the jinja2 template for the plot, at least hard coding the required options, but I would expect these settings to be included automatically.
Please follow these steps to make it more efficient to solve your issue:
vega_datasets
.