-
Notifications
You must be signed in to change notification settings - Fork 120
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
fix(legend): width with duplicate nested pie slice labels #1585
Merged
nickofthyme
merged 14 commits into
elastic:master
from
nickofthyme:fix-pie-legend-width
Feb 23, 2022
Merged
fix(legend): width with duplicate nested pie slice labels #1585
nickofthyme
merged 14 commits into
elastic:master
from
nickofthyme:fix-pie-legend-width
Feb 23, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nickofthyme
added
:legend
Legend related issue
:partition
Partition/PieChart/Donut/Sunburst/Treemap chart related
labels
Feb 9, 2022
nickofthyme
commented
Feb 9, 2022
packages/charts/src/chart_types/partition_chart/layout/utils/legend_labels.ts
Show resolved
Hide resolved
@markov00 can you review and approve this? |
markov00
reviewed
Feb 11, 2022
packages/charts/src/chart_types/partition_chart/layout/utils/legend_labels.ts
Outdated
Show resolved
Hide resolved
packages/charts/src/chart_types/partition_chart/layout/utils/legend_labels.ts
Show resolved
Hide resolved
markov00
approved these changes
Feb 23, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
packages/charts/src/chart_types/partition_chart/layout/utils/legend_labels.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
2 Playwright tests are failing only in the CI. Merging for now and will troubleshoot in a separate PR. |
nickofthyme
changed the title
fix(legend): width with duplicate pie slice labels
fix(legend): width with duplicate nested pie slice labels
Feb 23, 2022
nickofthyme
added a commit
that referenced
this pull request
Mar 1, 2022
nickofthyme
pushed a commit
that referenced
this pull request
Mar 1, 2022
# [44.0.0](v43.1.1...v44.0.0) (2022-03-01) ### Bug Fixes * **axis:** correct tick alignment in ordinal scale with numeric values ([#1609](#1609)) ([915349d](915349d)) * **legend:** width with duplicate nested pie slice labels ([#1585](#1585)) ([1073231](1073231)) * **partition:** consider legend extras when computing the legend size ([#1611](#1611)) ([2078f3d](2078f3d)) * **xy:** dataIndex keeps original data order on small multiples ([#1597](#1597)) ([9e2566c](9e2566c)) ### Features * **api:** expose Predicate enum ([#1574](#1574)) ([1f73eec](1f73eec)) * **heatmap:** allow rotation of x axis labels ([#1514](#1514)) ([b655156](b655156)) ### BREAKING CHANGES * **heatmap:** `width`, `align`, and `baseline` style properties are removed from the `xAxisLabels` and `yAxisLabels` style of the Heatmap theme. Co-authored-by: Marco Vettorello <vettorello.marco@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
fixes a bug returning a zero-width legend for identical legend labels using
legendMaxDepth
option.Before
After
Details
The legend label logic in partition charts was understandably simplified to assume the formatted labels across all depths are unique. However, this simplification runs into issues whenever two or more labels across any layer or any depth are identical.
elastic-charts/packages/charts/src/chart_types/partition_chart/layout/utils/legend_labels.ts
Lines 34 to 37 in 185ab47
The logic above creates a
keys
Map
to track the depths across layers and nodes using the formatted label as the key. So in the case where the label is the same for two separate layers (as pictured above), the depth count is incorrectly combined to2
.For the current case, this becomes a problem when limiting the depth using
legendMaxDepth
in which thedepth
count is now incorrectly2
and thus returns[]
causing the legend width to be0
.elastic-charts/packages/charts/src/chart_types/partition_chart/layout/utils/legend_labels.ts
Lines 14 to 16 in 185ab47
The solution -- prevent label collisions using a key derived from the
arrayNode.path
returning all legend labels as a unique value in the labels array. So the example able would be separated into two where the first is at adepth
of1
and the second is at adepth
of2
I confirmed the functionality of the legend highlight strategy is working as expected with this unique label change.
Issues
fix #1584
Checklist
:xy
,:partition
):interactions
,:axis
)closes #123
,fixes #123
)