Skip to content

[BUGFIX] PieChart: Decimal, Unit & Short Values attributes not taken …#594

Open
adrianSepiol wants to merge 3 commits intoperses:mainfrom
adrianSepiol:fix-piechart-plugin-decimal-unit-and-short
Open

[BUGFIX] PieChart: Decimal, Unit & Short Values attributes not taken …#594
adrianSepiol wants to merge 3 commits intoperses:mainfrom
adrianSepiol:fix-piechart-plugin-decimal-unit-and-short

Conversation

@adrianSepiol
Copy link
Contributor

@adrianSepiol adrianSepiol commented Mar 9, 2026

…into account

closes: PieChart: Decimal, Unit & Short Values attributes not taken into account

Description

Fixed issue where decimal, unit and short values where not applied. After the change formatting is applied to absolute and relative values in legends table, on chart labels and tooltip. Additionally fixed issue where tooltip showed relative value in "percentage" mode

Screenshots

Before
image
After
image

Before in percentage mode:
image
After in percentage mode:
image

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

@adrianSepiol adrianSepiol requested a review from a team as a code owner March 9, 2026 12:57
@adrianSepiol adrianSepiol requested review from Gladorme and removed request for a team March 9, 2026 12:57
…into account

Signed-off-by: Adrian Sepiół <adisepko@gmail.com>
@adrianSepiol adrianSepiol force-pushed the fix-piechart-plugin-decimal-unit-and-short branch from 881f679 to 3fc393a Compare March 9, 2026 13:00
Copy link
Member

@Gladorme Gladorme left a comment

Choose a reason for hiding this comment

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

You have it also in screenshots, there is double %% in tooltip 🤔
image

const { legendItems, legendColumns } = useMemo(() => {
const pieChartLegendMapper: PieChartLegendMapper =
pieChartLegend?.mode === 'table' ? new PieChartTableLegendMapper() : new PieChartListLegendMapper();
const values = pieChartLegend?.values as ComparisonValues[] | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

If possible:

Suggested change
const values = pieChartLegend?.values as ComparisonValues[] | undefined;
const values: ComparisonValues[] | undefined = pieChartLegend?.values;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wouldn't work as values is Array<LegendValue | ComparisonValues>. I could make downstream function accept this type and just check for the values that interest us ('abs', 'relative'). This way we would avoid casting.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer to avoid casting when possible, would be nice to downstream the type and just check for the values that interest us, like you said

Signed-off-by: Adrian Sepiół <adisepko@gmail.com>
@adrianSepiol
Copy link
Contributor Author

adrianSepiol commented Mar 11, 2026

You have it also in screenshots, there is double %% in tooltip 🤔 image

Good catch, I think I looked at it for too long and stopped seeing it

const relativeFormatOptions = { unit: 'percent', decimalPlaces: formatOptions?.decimalPlaces } as const;
return ({ name, value, percent }: formatterProps): string => {
if (typeof value === 'number') {
return `${format.encodeHTML(name)}: ${formatValue(value, formatOptions)} (${formatValue(percent, relativeFormatOptions)})`;
Copy link
Member

Choose a reason for hiding this comment

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

We never used encodeHTML, I quickly checked the doc, maybe we should use it everywhere.
Or we don't put it anywhere and we suppose datasource should be safe 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Signed-off-by: Adrian Sepiół <adisepko@gmail.com>
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.

PieChart: Decimal, Unit & Short Values attributes not taken into account

2 participants