Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sunburst] Single value sometimes shows and 2 slices #2456

Closed
nickofthyme opened this issue Jun 4, 2024 · 0 comments · Fixed by #2457
Closed

[Sunburst] Single value sometimes shows and 2 slices #2456

nickofthyme opened this issue Jun 4, 2024 · 0 comments · Fixed by #2457
Assignees
Labels
bug Something isn't working :partition Partition/PieChart/Donut/Sunburst/Treemap chart related

Comments

@nickofthyme
Copy link
Collaborator

nickofthyme commented Jun 4, 2024

When defining a Partition chart, specifically radial types (i.e. sunburst), the chart can incorrectly show a single (100%) slice as 2 slices indicated by the separating line at the top of the pie chart.

image

The issues here is with this part of the code...

case PartitionLayout.sunburst:
const sunburstValueToAreaScale = TAU / totalValue;
const sunburstAreaAccessor = (e: ArrayEntry) => sunburstValueToAreaScale * mapEntryValue(e);
return sunburst(tree, sunburstAreaAccessor, { x0: 0, y0: -1 }, clockwiseSectors, specialFirstInnermostSector);

Specifically Line 247 which sets the ratio of the total combined value. In some cases, the totalValue can be just right to offset the precision of this value by one decimal, like the case with 678.

TAU = 2 * Math.PI ~= 6.283185307179586
TAU / 678 ~= 0.009267234966341572
0.009267234966341572 * 678 ~= 6.283185307179585 != TAU

This comes into play when we render the sections and check if the x1, or section angle, is equal to TAU or a full circle. With this lose in precision this condition in not met causing the inconsistent rendering of the section divider line.

if (strokeWidth > 0.001 && !(x0 === 0 && x1 === TAU)) {


Related to elastic/kibana#184386

@nickofthyme nickofthyme added bug Something isn't working :partition Partition/PieChart/Donut/Sunburst/Treemap chart related labels Jun 4, 2024
@nickofthyme nickofthyme self-assigned this Jun 4, 2024
@nickofthyme nickofthyme changed the title [Subburst] Single value sometimes shows and 2 slices [Sunburst] Single value sometimes shows and 2 slices Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working :partition Partition/PieChart/Donut/Sunburst/Treemap chart related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant