Skip to content

Chart: a pie/doughnut slice label is a share of the total, not the raw value - #113

Closed
delchev wants to merge 1 commit into
mainfrom
fix-pie-percentage-label
Closed

Chart: a pie/doughnut slice label is a share of the total, not the raw value#113
delchev wants to merge 1 commit into
mainfrom
fix-pie-percentage-label

Conversation

@delchev

@delchev delchev commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

renderPie appended a percent sign to the slice's raw value:

svg.appendChild(outsideLabels ? dataText(`${s.value}%`, lx, ly) : onColorText(`${s.value}%`, lx, ly));

so a doughnut of one 336-hour slice renders 336%. pct — the share — was already computed one line above (and used for the 5% sliver cut-off), and both docs/charts/pie.md and docs/charts/doughnut.md describe dataLabels as "each slice's percentage". The existing tests used slices summing to 100 (30/70), which hid it.

Found downstream in Eclipse Dirigible's generated report pages, where a sum(hours) doughnut told a manager "336% billable" (eclipse-dirigible/dirigible#7076).

Fix: label with pct, one decimal below 10% so a small-but-labelled slice (the 5–10% band) stays distinguishable. Polar area, which already labelled with format(s.value), is unchanged — its labels are values by design.

Tests: three added (share label with a non-100 total, single slice = 100%, one decimal under 10%). Full suite green: 3576 passed, 5 skipped.

renderPie drew the slice's raw value with a percent sign appended, so a
doughnut of one 336-hour slice read "336%" where the documented behaviour
(and the already-computed `pct`) says "100%". Slices that happened to sum
to 100 hid it, and so did the tests.

Label with the share instead, one decimal below 10% so small-but-labelled
slices stay distinguishable.

Signed-off-by: delchev <delchevn@gmail.com>
delchev added a commit to eclipse-dirigible/dirigible that referenced this pull request Sep 7, 2026
A `chart: doughnut` report drew one unlabelled ring whose only text was
the measure sum with a percent sign - a 336-hour billable split read
"336% billable" - and nothing said which segment was which.

Two causes. The page turned the legend off unless there were several
measure series (`legend: series.length > 1`), but a circular chart slices
ONE measure by the dimension: its slices are the dimension values, and
the legend is the only thing that names them. And the chart library
prints a pie/doughnut slice's raw value with a percent sign appended
instead of its share (codbex/harmonia#113).

So: the legend is always on for a circular chart and each entry carries
the slice's share of the measure total, computed only when the fetched
rows are the whole result - a windowed dashboard tile must not present a
page-local share as the report's, the rule the table footer already
applies to its totals. Pie and doughnut also pass `dataLabels: false`,
dropping the value-as-percentage label until the pinned Harmonia carries
the fix; polar area, whose labels are values by design, keeps them.

A boolean dimension now reads Yes/No in the chart rather than the raw
true/false, from two new shell keys.

The same treatment goes to the entity report chart page (REPORT_PIE /
REPORT_DOUGHNUT / REPORT_POLARAREA), which had the second half of the
problem.

Verified by IntentEngineIT: OrdersByCustomer gains `chart: doughnut` and
the report-file stack test asserts the generated page's legend, share
labels and suppressed data label. 67 tests, all green.
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.

2 participants