python-visualization / python-visualization/folium

Pass number format to folium legend

Open
#2,014 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
7.4k
Forks
2.3k
Avg merge
17h 22m
Merged PRs (30d)
11

Description

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:

  1. Online as the intended HTML output
  2. 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:

  1. passing a format string, or
  2. specifying a localization that folium can then reference and set the text accordingly
  3. 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:

  1. Create folium map (language localization unimportant since the html will use the localization of the system it is hosted on)
  2. 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating folium's choropleth legend generation and the Leaflet.js output used for the legend scale. Reproduce the issue with one map rendered for multiple number formats and inspect the generated HTML in a headless browser. Done means a caller can control the legend's number formatting without changing global localization, with the supported usage documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
data-visualization, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.