GitHub user dosubot[bot] added a comment to the discussion: Number format via config.py - Superset 5.0
<!-- Answer --> I couldn't find specific information on defining custom number formats via `config.py` in the Superset repository. However, Superset does integrate D3 formatting for numbers using the `createD3NumberFormatter` function. This involves specifying a `formatString` in the configuration object, which is used as the ID for the formatter and determines the formatting style using D3's format function <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-core/test/number-format/factories/createD3NumberFormatter.test.ts)</sup>. For custom number formats, you might want to explore using the `NumberFormatterRegistry` in Superset, which allows you to register and retrieve custom formatters. You can create a formatter with a valid D3 format string and handle invalid format strings by displaying an error message and setting `isInvalid` to true <sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-core/test/number-format/NumberFormatterRegistrySingleton.test.ts)</sup>. If you are trying to set locale-specific formats, you can customize locale settings using the `locale` property in the formatter configuration. This includes settings for decimal, thousands, grouping, and currency symbols <sup>[[3]](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts)</sup>. For more detailed examples, you can refer to the tests and examples in the Superset codebase, such as those found in `createD3NumberFormatter.test.ts` and `NumberFormat.stories.tsx` <sup>[[4]](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-core/test/number-format/factories/createSmartNumberFormatter.test.ts)</sup><sup>[[5]](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-number-format/NumberFormat.stories.tsx)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/b1429fd4-9820-46e7-8b6f-42cfa0bb9ade?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/b1429fd4-9820-46e7-8b6f-42cfa0bb9ade?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/b1429fd4-9820-46e7-8b6f-42cfa0bb9ade?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/b1429fd4-9820-46e7-8b6f-42cfa0bb9ade?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b1429fd4-9820-46e7-8b6f-42cfa0bb9ade?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/b1429fd4-9820-46e7-8b6f-42cfa0bb9ade?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b1429fd4-9820-46e7-8b6f-42cfa0bb9ade?feedback_type=other)</sup> GitHub link: https://github.com/apache/superset/discussions/33735#discussioncomment-13425147 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
