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

feat(partition): add legend and highlighters #616

Merged
merged 37 commits into from
Apr 14, 2020

Conversation

markov00
Copy link
Member

@markov00 markov00 commented Apr 2, 2020

Summary

This PR adds the legend to pie charts and treemaps.
Close #486 finishing the decoupling of the legend from XY charts
Close #532 request to add legend and tooltips to partition charts

Screenshot 2020-04-09 at 13 06 04

Two more options are added to the <Settings/> components

  • flatLegend will flat the legend for pie/tree hierarchical legend as in the following screenshot

Screenshot 2020-04-09 at 13 06 23

  • legendMaxDepth will limit the legend hierarchy to a maximum depth value: 1 is the root level. Can be combined with the flatLegend

legendMaxDepth={1} example on a 3 level piechart
Screenshot 2020-04-09 at 13 06 38

legendMaxDepth={2} example on a 3 level piechart
Screenshot 2020-04-09 at 13 06 52

The PR also add the highlighter when hovering over the pie/tree chart and over the legend items as shown in the following gifs
pielight
piedark
treedark
treelight

Checklist

Delete any items that are not applicable to this PR.

  • Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)
  • This was checked for cross-browser compatibility, including a check against IE11
  • Proper documentation or storybook story was added for features that require explanation or tutorials
  • Unit tests were updated or added to match the most common scenarios

@markov00 markov00 added enhancement New feature or request wip work in progress :partition Partition/PieChart/Donut/Sunburst/Treemap chart related labels Apr 2, 2020
@markov00 markov00 changed the title Add legend to partition feat(partition): add legend and highlighters Apr 8, 2020
@codecov-io
Copy link

codecov-io commented Apr 8, 2020

Codecov Report

Merging #616 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #616   +/-   ##
=======================================
  Coverage   66.81%   66.81%           
=======================================
  Files         252      252           
  Lines        7166     7166           
  Branches     1352     1352           
=======================================
  Hits         4788     4788           
  Misses       2361     2361           
  Partials       17       17           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11f120f...11f120f. Read the comment docs.

@markov00 markov00 removed the wip work in progress label Apr 8, 2020
@markov00 markov00 requested review from nickofthyme and monfera and removed request for nickofthyme and monfera April 8, 2020 09:57
@markov00 markov00 requested review from monfera and rshen91 April 9, 2020 11:59
@wylieconlon
Copy link

Based on the screenshots and gifs, this looks like exactly what we are looking for! Thank you!

});

return (
<Chart className="story-chart" /*size={{ width: 1200, height: 800 }}*/>
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to remove this comment?

Copy link
Contributor

@rshen91 rshen91 left a comment

Choose a reason for hiding this comment

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

Tested locally and stories seem to be rendering correctly and quickly on Chrome. There's a lot I like in this PR: moving LegendItem and seriesId into commons especially. I was a little thrown at first what legend files would remain specific for either xy_charts or partitions and so I'm going to include in here how I'm understanding the breakup of the legend (which to be clear, I think it makes a lot of sense). As far as I'm understanding it looks like the majority of the legend logic is in the components directory, LegendItem has been moved to the commons directory, and then the implementation of compute_legend is specific for either partition charts or xy_charts. This makes a lot more sense to me setting it up this way. Any future types of charts then just need to have their own compute_legend.ts file. Let me know if I'm misunderstanding, thanks!

The highlighter.tsx file is very cool for computing the focusing on specific slices or not - I wonder if this might be able to also help in terms of keyboard navigation in the future (from what I understand working with SVG for keyboard navigation vs canvas is much easier)?

The new story in legend, single sunburst in the sunburst stories, and adding the <Settings showLegend /> in some sunburst stories, interactions, and two layers stress test in treemaps looks awesome! 💯

@markov00 markov00 added the :legend Legend related issue label Apr 10, 2020
Copy link
Collaborator

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

Overall code changes look good. A few nits and comments. Much cleaner shared structure ❤️

Tested stories locally in Chrome and Firefox. All look good. Banded legend changes work as normal.

Tested triple-layer sunburst in IE11 with flatLegend and legendMaxDepth. Renders fine but seems to render a little slow still. Also get long-running script warning but eventually renders without incident.

Unrelated: I noticed a small issue on the tooltip. Opened an issue here #628

src/components/legend/legend_item.tsx Outdated Show resolved Hide resolved
src/components/legend/legend_item.tsx Show resolved Hide resolved
src/components/legend/legend_item.tsx Outdated Show resolved Hide resolved
src/state/selectors/get_legend_size.ts Show resolved Hide resolved
Copy link
Contributor

@monfera monfera left a comment

Choose a reason for hiding this comment

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

Epic PR with tons of legends rework to make it more general! Good to go, the singularity case can be a subsequent PR by either of us

@markov00
Copy link
Member Author

jenkins test this

@markov00 markov00 merged commit 6a4247e into elastic:master Apr 14, 2020
@markov00 markov00 deleted the add_legend_to_partition branch April 14, 2020 17:55
markov00 pushed a commit that referenced this pull request Apr 15, 2020
# [18.3.0](v18.2.2...v18.3.0) (2020-04-15)

### Bug Fixes

* remove series with undefined splitSeriesAccessor values ([#627](#627)) ([59f0f6e](59f0f6e))

### Features

* gauge, goal and bullet graph (alpha) ([#614](#614)) ([5669178](5669178))
* **partition:** add legend and highlighters ([#616](#616)) ([6a4247e](6a4247e)), closes [#486](#486) [#532](#532)
@markov00
Copy link
Member Author

🎉 This PR is included in version 18.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Apr 15, 2020
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request :legend Legend related issue :partition Partition/PieChart/Donut/Sunburst/Treemap chart related released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Partition charts with legend and tooltip Decouple legend and tooltip from XYChart
6 participants