-
Notifications
You must be signed in to change notification settings - Fork 114
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): waffle chart #1255
Conversation
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, made a few non-critical comments. I'll let @markov00 have a look before approving.
packages/charts/src/chart_types/partition_chart/layout/utils/legend.ts
Outdated
Show resolved
Hide resolved
|
||
const MAX_PADDING_RATIO = 0.25; | ||
|
||
const latestRafs: Map<ChartId, number> = new Map(); |
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.
Could this cause a memory leak as charts are created and destroyed?
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.
Yep, I agree with Nick, and this needs to be destroyed or cleaned on unmount
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.
It was a primitive map (one string and one number per chart), so this leak was unlikely to be ever detectable without millions of instantiation. Still this was useful feedback, as giving it another look, there's no need for the map to begin with.
39f477a simply persists the raf id in the new animationState
property of the component object, so it goes away upon garbage collection. I think it's almost always better to link memory cleanup to scoped variables/properties, because there's no need for error prone explicit cleanup.
There'll be some DRY up work in some future commit/PR too for animation
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.
f27c202 removes chartId
from the component. Using such an id, external to the component was a bit of an antipattern anyway
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.
fe06920 removes animation code from the wrapped renderer as it's not yet utilized
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.
All good for me, we should remember this PR when bringing back animation
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.
Thanks @markov00! Just to clarify, the animation that existed before (icicle/flame) remained in place (and changed so that there's no rAF
Map
anymore). The waffle renderer was patterned after the icicle/flame renderer but the animation wasn't (yet) adapted to waffles, so there's no loss with the removal of that bit
packages/charts/src/chart_types/partition_chart/state/selectors/compute_legend.ts
Outdated
Show resolved
Hide resolved
packages/charts/src/chart_types/partition_chart/renderer/canvas/canvas_linear_renderers.ts
Show resolved
Hide resolved
|
||
const MAX_PADDING_RATIO = 0.25; | ||
|
||
const latestRafs: Map<ChartId, number> = new Map(); |
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.
Yep, I agree with Nick, and this needs to be destroyed or cleaned on unmount
# Conflicts: # playground/playground.tsx
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.
Code changes looks good to me!
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 thanks for the changes and explanations!
# [33.1.0](v33.0.2...v33.1.0) (2021-07-28) ### Bug Fixes * persisted color via color picker ([#1265](#1265)) ([4205a7f](4205a7f)) ### Features * **legend:** add point shape styles to legend item ([#1227](#1227)) ([46be1d1](46be1d1)) * **partition:** waffle chart ([#1255](#1255)) ([156662a](156662a))
🎉 This PR is included in version 33.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Adds waffle chart to the set of partition charts. It shows a parts to whole relationship, like pie charts or treemaps, but sometimes a better option than these. It is distinct from the gridded charts in APM that show specific units and were titled waffle map.
Consider this chart type if
Pros:
Potential drawbacks:
Details
Sometimes are referred to as square pies.
The waffle chart is a lower precision format, because the data is often continuous, while the waffle cells necessitate rounding, so each cell represents a specific ratio (percentage).
At the current alpha level, there's very limited configurability, and it ought to stay this way until more demanding requirements are registered. For example, it's currently always a 10x10 grid (each cell represents 1% and each row or column, 10%).
This PR alters the legend item order such that the waffle colors and legend items match in sequence. Both follow a decreasing value order.
The waffle is responsive, eg. the separating borders get smaller as the chart gets smaller, though not in linear proportion. The
config.sectorLineWidth
is settable for more or less separation, though other aspects eg. cell corner radius aren't currently configurable (and they may not to be)Known requirements for non-alpha status:
Issues
Checklist
packages/charts/src/index.ts
(and stories only import from../src
except for test data & storybook)