-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Avoid sphinx
error "Code Execution failed:NameError: name 'format_locale' is not defined"
#3503
Conversation
…mat_locale' is not defined" Occurs during doc build, due to both variables being used without a defintion. ```log .\doc\Lib\site-packages\sphinxext_altair\altairplot.py:261: UserWarning: altair-plot: .\altair\doc\user_guide/customization.rst:826 Code Execution failed: NameError: name 'format_locale' is not defined warnings.warn(message, stacklevel=1) ```
Another option could be just to remove that Localization
------------
The preferred format of numbers, dates, and currencies varies by language and locale.
Vega-Altair takes advantage of `D3's localization support`_ to make it easy to configure
the locale for your chart using the global ``alt.renderers.set_embed_options`` function.
.. altair-plot::
:output: none
import altair as alt
alt.renderers.set_embed_options(format_locale=None, time_format_locale=None)
Here ``format_locale`` and ``time_format_locale`` may either be D3 format dictionaries,
or strings with the names of pre-defined locales. For example, here we use the
Italian locale (named ``it-IT``) for both currencies and dates:
.. altair-plot::
:output: none
import altair as alt
from vega_datasets import data
alt.renderers.set_embed_options(format_locale="it-IT", time_format_locale="it-IT")
source = data.stocks.url
chart = alt.Chart(source).mark_area().transform_filter('year(datum.date) == 2009').encode(
x='date:T',
y=alt.Y('price:Q', axis=alt.Axis(format="$.0f")),
color='symbol:N'
)
chart
|
I agree with your comment that it makes more sense to render it as a code-block and not as a sphinxext-altair |
@mattijn I agree with you on that, but that wasn't what I meant 😄 I meant this change: diff --git a/doc/user_guide/customization.rst b/doc/user_guide/customization.rst
index 77eaf707..9759669b 100644
--- a/doc/user_guide/customization.rst
+++ b/doc/user_guide/customization.rst
@@ -823,12 +823,6 @@ The preferred format of numbers, dates, and currencies varies by language and lo
Vega-Altair takes advantage of `D3's localization support`_ to make it easy to configure
the locale for your chart using the global ``alt.renderers.set_embed_options`` function.
-.. altair-plot::
- :output: none
-
- import altair as alt
- alt.renderers.set_embed_options(format_locale=None, time_format_locale=None)
-
Here ``format_locale`` and ``time_format_locale`` may either be D3 format dictionaries,
or strings with the names of pre-defined locales. For example, here we use the
Italian locale (named ``it-IT``) for both currencies and dates:
This one has to repeat all of what was in the other anyway, but uses real arguments: .. altair-plot:: # <------
:output: none # <------
import altair as alt # <------
from vega_datasets import data
alt.renderers.set_embed_options(format_locale="it-IT", time_format_locale="it-IT") # <------
source = data.stocks.url
chart = alt.Chart(source).mark_area().transform_filter('year(datum.date) == 2009').encode(
x='date:T',
y=alt.Y('price:Q', axis=alt.Axis(format="$.0f")),
color='symbol:N'
)
chart I don't think there's any information lost as a result vs actual |
Also good👍 |
Thanks @mattijn should be ready to merge now |
Thanks for the PR!🥳 |
Occurs during doc build, due to both variables being used without a defintion.