python-visualization / python-visualization/folium

Pass number format to folium legend

未关闭
#2,014 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement
主要语言
Python
星标
7.4k
派生
2.3k
平均合并
17 小时 22 分钟
30 天内合并 PR
11

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先定位 folium 的 choropleth 图例生成逻辑,以及用于图例刻度的 Leaflet.js 输出。使用多种数字格式渲染同一张地图来复现问题,并在无头浏览器中检查生成的 HTML。当调用方可以控制图例的数字格式而无需更改全局本地化设置,并且已记录受支持的用法时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, python
领域
data-visualization, web-dev
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。