sadpandajoe commented on code in PR #45439:
URL: https://github.com/apache/superset/pull/45439#discussion_r4321024503
##########
superset/charts/client_processing.py:
##########
@@ -851,18 +869,53 @@ def format_column(
parallel ``currency_context`` series is present, AUTO uses each row/cell's
contributing currencies first. Mixed context renders a neutral number;
empty context optionally falls back to query-wide detection.
+
+ ``small_d3_format`` is the column's small-number format. The choice is per
+ cell rather than per column, matching ``formatColumnValue``: a value below
+ one in absolute value takes that format with the column config's own
+ currency, exactly what ``getSmallNumberFormatter`` builds, and every other
+ value keeps the column's normal format. An AUTO currency resolves against
+ the row's context on both paths, since the browser passes the row data to
+ either formatter.
"""
- if d3_format or currency.get("symbol"):
+ if d3_format or currency.get("symbol") or small_d3_format:
if currency_context is None:
resolved_currency = resolve_auto_currency(currency,
detected_currency)
- df[column] = df[column].apply(
- partial(format_number_with_config, d3_format,
resolved_currency)
+ format_value = partial(
+ format_number_with_config, d3_format, resolved_currency
)
+ if small_d3_format:
+ format_small = partial(
+ format_number_with_config, small_d3_format, small_currency
or {}
Review Comment:
When the column config carries a `currencyFormat` without a symbol (for
example `{"symbolPosition": "prefix"}` left behind after clearing the currency)
and `d3SmallNumberFormat` is `$,.2f`, `getSmallNumberFormatter` still builds a
`CurrencyFormatter`, which strips the `$` from the d3 format. Here
`format_number_with_config` only strips it when `currency.get("symbol")` is
truthy, so a 0.5 cell renders `$0.50` in the report but `0.50` in Explore. The
AUTO/context branch below has the same gap. Should the small-number path strip
`$` whenever the column config has a `currencyFormat` object, symbol or not?
--
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]