You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We would like to use folium to create choropleths in more than one language. So far (unless I am missing something), it appears that folium is using the system localization to set the language format for numbers in folium legend.
We, and I anticipate others, have more than one use for these maps:
Online as the intended HTML output
Print versions (digitally as images, parts of PDF files and also hard copies).
The problem is that in order to change number formats (in this case comma vs. period for decimal), the language localization needs to be reset globally, in most cases requiring a kernel reset (again, unless I am missing something).
I would like to be able to pass a number format to the legend to change the language format of the numbers in the scale, either by:
passing a format string, or
specifying a localization that folium can then reference and set the text accordingly
Have some documentation on how to inject an equivalent instruction by HTML.
Ultimately, I would like to do the following in a single code execution:
Create folium map (language localization unimportant since the html will use the localization of the system it is hosted on)
Change/re-render choropleths to two languages (with number formats) so that images can be saved for alternate media use
Since headerless browser can be used to generate images and text can be passed in any language, the only thing that is needed is to interact with the format of the numbers in the legend scale.
The text was updated successfully, but these errors were encountered:
My first thought is something you could try right now: to change the format with Javascript after the page is rendered. You could do something like get the css selector for the element with the date, parse it, change the locale, then update the element.
You can add arbitrary Javascript to your Folium map. I’m on mobile now so don’t have a link for you, but there are examples in our Isssues, maybe also docs.
For a more clean solution, having the locale as option when creating a choropleth, or as an argument on colormap… I’m not sure right now, could be interesting. Probably exposing it on colormap in the Branca library is the way to go for that. Choropleth is already quite crowded so I wouldn’t add more arguments there, but through the choropleth object more advanced users could access the colormap object.
We don’t really have dev capacity, so if you manage to find something that works for you please share it here :)
I have looked at the HTML generated. There are a few things I can do for the <style>, such as add font size and weight. I cannot seem to add a "lang:" argument, even though this should be allowed within a <style>. This is likely where it would have to go.
The other option would be to set a language directly in the text line for the legend, but unfortunately this is set as a variable that is in turn fed into the javascript for the associated d3 script (<script src="https://d3js.org/d3.v4.min.js"></script>). This may mean any change here needs to involve changing this script (which is hard-coded into the addon). It may not be possible to pass a format code along with the legend text if the JS is expecting a string with only the legend text to insert into a format defined therein...
I am not good enough at HTML to know how/if I can inject some additional style script to change the number format on the legend scale... I will keep hunting.
We would like to use folium to create choropleths in more than one language. So far (unless I am missing something), it appears that folium is using the system localization to set the language format for numbers in folium legend.
We, and I anticipate others, have more than one use for these maps:
The problem is that in order to change number formats (in this case comma vs. period for decimal), the language localization needs to be reset globally, in most cases requiring a kernel reset (again, unless I am missing something).
I would like to be able to pass a number format to the legend to change the language format of the numbers in the scale, either by:
Ultimately, I would like to do the following in a single code execution:
Since headerless browser can be used to generate images and text can be passed in any language, the only thing that is needed is to interact with the format of the numbers in the legend scale.
The text was updated successfully, but these errors were encountered: