Skip to content

Conversation

hokolomopo
Copy link
Contributor

Description

We have an humanizeNumbers option for the chart to make large numbers more readable. The option is enabled by default on every chart, but it was not correctly handling decimal numbers. The function was always rounding them to the nearest integer, which does not make sense for small numbers (eg. 0.15 should not be displayed as 0).

Task: 5155591

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

We have an `humanizeNumbers` option for the chart to make large
numbers more readable. The option is enabled by default on every chart,
but it was not correctly handling decimal numbers. The function
was always rounding them to the nearest integer, which does not make
sense for small numbers (eg. 0.15 should not be displayed as 0).

Task: 5155591
@robodoo
Copy link
Collaborator

robodoo commented Oct 9, 2025

Pull request status dashboard

The `humanizeNumbers` checkbox was missing in the design panels of
sunburst, treemap and bar charts.

Task: 5155591
static components = {
...ChartWithAxisDesignPanel.components,
Checkbox,
ChartHumanizeNumbers,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed here, it's already in the ChartWithAxisDesignPanel.components :)

let numberFormat: Format | undefined = format;
if (Math.abs(numberValue) < 1000) {
const hasDecimal = numberValue % 1 !== 0;
numberFormat = !format && hasDecimal ? "0.####" : format;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need to have 4 decimals, I would have gone to 2, but why not :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally it's dependant on the number of digit before the comma (123.4, 12.34, 123.4). And ideally, we should also probably handle the different formats (a formatLargeNumber function, but for small ones)

Not sure it's worth tho, I went with the fast & dumb approach.

@hokolomopo hokolomopo force-pushed the 19.0-fix-humanize-decimal-numbers-adrm branch from 43169df to cc602b8 Compare October 17, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants