verdier opened a new pull request, #45241:
URL: https://github.com/apache/superset/pull/45241

   ### SUMMARY
   
   `SMART_NUMBER` ("Adaptive formatting", the default number format) and 
`SMART_NUMBER_SIGNED` are registered in the `NumberFormatterRegistry` 
constructor, and `createSmartNumberFormatter` built its d3 formatters once, at 
module load, from `DEFAULT_D3_FORMAT`. `setD3Format()`, called at bootstrap 
with `D3_FORMAT`, only applies to formatters created later from a format 
string, so every chart left on the default format kept the en-US separators 
whatever `D3_FORMAT` said.
   
   This PR:
   
   - adds a `locale` option to `createSmartNumberFormatter`, merged over 
`DEFAULT_D3_FORMAT` (so the ASCII hyphen-minus is kept);
   - makes `NumberFormatterRegistry.setD3Format()` rebuild the two adaptive 
formatters with the configured locale.
   
   With the default config the output is unchanged. 
`createSiAtMostNDigitFormatter` is left out on purpose: it strips trailing 
zeros with `parseFloat`, which needs its own change once the decimal separator 
is not `.` (noted in #45240).
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   With `D3_FORMAT = {"decimal": ",", "thousands": " ", "grouping": [3]}`, a 
value of `1234.5` on a chart using the default format:
   
   - before: `1.23k`
   - after: `1,23k`
   
   ### TESTING INSTRUCTIONS
   
   - `npx jest packages/superset-ui-core/test/number-format`: the new tests in 
`NumberFormatterRegistry.test.ts` and `createSmartNumberFormatter.test.ts` fail 
on `master` and pass here.
   - Manually: set the `D3_FORMAT` above in `superset_config.py`, open a Big 
Number or a table chart left on "Adaptive formatting", and check the decimal 
separator.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: #45240
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to