-
Notifications
You must be signed in to change notification settings - Fork 121
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
refactor: annotation marker size calculation #960
refactor: annotation marker size calculation #960
Conversation
Codecov Report
@@ Coverage Diff @@
## master #960 +/- ##
==========================================
+ Coverage 70.90% 72.55% +1.64%
==========================================
Files 350 350
Lines 11072 11052 -20
Branches 2437 2434 -3
==========================================
+ Hits 7851 8019 +168
+ Misses 3208 3019 -189
- Partials 13 14 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
src/chart_types/xy_chart/renderer/dom/annotations/annotations.tsx
Outdated
Show resolved
Hide resolved
if (hasMarkerDimensions) { | ||
return undefined; | ||
} | ||
switch (alignment) { |
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.
reason for changes: compact; O(1); no need for backquotes; no need to play tricks with a TS-enforced default:
as Position
can't be any other value. The constant can be moved outside the function, might even become reusable
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.
fixed here: 7465bb3
src/chart_types/xy_chart/state/selectors/get_annotation_tooltip_state.ts
Outdated
Show resolved
Hide resolved
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, left a few comments. Verified storybook line and rectangular annotation stories a still render and interact the same. 👍🏼
src/chart_types/xy_chart/renderer/dom/annotations/annotations.tsx
Outdated
Show resolved
Hide resolved
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.
Great and quite compact PR, thanks Marco!
🎉 This PR is included in version 24.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
A propedeutic refactor of the
LineAnnotation
spec to allow the use of a custom react reconciler.When using a custom reconciler, every component within the wrapping parent is treated in the same way. Due to the nature of the new reconciler we can't "host" mixed components that are both a Spec component (that store it's props into the redux store) and a React component (as it was the LineAnnotation where the marker was first drawn offscreen, measured and then stored into the redux store).
The
LineAnnotation
was refactored to ignore the marker size, the marker is just rendered when and where needed with a transformation to align itself based on its anchor point.Note
The Path polyfill is removed from the dependencies, since we dropped the IE11 support there is no need for that anymore.
The Path2D mock in the Enzyme testing was applied after receiving an error message from the testing environment. This should not affect the current unit testing as it's just used on the rendering side not tested through Enzyme.
The calculation of the marker size was used to compute the right position of the marker and the mouse coordinate hit point within that marker: I've replaced the placement with a simple css transform and I've replaced the computation of the mouse hit within the marker with a mouseenter/mouseleave listener on the marker container, storing the information of the hovered DOM element within the redux store.
I moved the computation of the formatted details/header within the tooltip since it was a very cleaner to just pass the original datum around and it derivated formatted form.