最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

d3.js - How to localize D3 SI suffixes in Apache Superset number formatting (e.g., k, M, B → тыс., млн, млрд)? - Stack Overflow

programmeradmin2浏览0评论

I've been trying to localize default number formatting in Apache Superset charts, specifically the SI suffixes used in formats like .2s. Out of the box, Superset uses D3 defaults — k, M, B — but I need to show them in Russian: тыс., млн, млрд. What I’ve tried so far:

Changing Babel locale — partially localizes the interface, but does not affect number formatting.

Edited this file:

superset-frontend/node_modules/@superset-ui/core/src/number-format/factories/createD3NumberFormatter.ts

Injected a wrapper around .2s using .replace('k', ' тыс.'), etc.

Ran npm run build

Rebuilt with docker-compose -f docker-compose-non-dev.yml up -d --build

No effect in the UI, even on new charts

Tried registering a custom formatter in setupFormatters.ts:

getNumberFormatterRegistry().registerValue('RU_SHORT', d3Format('.2s'))

But Superset throws:
430227735890.2086 (Invalid format: RU_SHORT)

I also reviewed this article: Unfortunately, it doesn’t address SI suffix localization at all.

What I’m looking for:

Is there an official or stable way to override or localize SI suffixes in Superset?

Where is the correct hook — D3, @superset-ui/core, registry patching?

Has anyone successfully implemented localized short formats like .2s → 5 тыс., 20 млн, 8.3 млрд?

Any guidance, examples, or community experience would be appreciated

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论