-
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
feat(interaction): crosshair #96
Conversation
a848e45
to
d54a2cb
Compare
Codecov Report
@@ Coverage Diff @@
## master #96 +/- ##
==========================================
+ Coverage 89.63% 90.17% +0.54%
==========================================
Files 28 31 +3
Lines 1167 1405 +238
Branches 119 150 +31
==========================================
+ Hits 1046 1267 +221
- Misses 111 125 +14
- Partials 10 13 +3
Continue to review full report at Codecov.
|
d54a2cb
to
76f6b48
Compare
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.
tested locally on Firefox & looks good! Just left a few comments & questions here
strokeHitEnabled={false} | ||
listening={false} | ||
perfectDrawEnabled={true} | ||
perfectDrawEnabled={false} |
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.
To maintain consistency of the props between the animated and non-animated versions, could create an object with the shared props and spread them? (Here and for other animated components)
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.
will work on that on a different PR
if (this.onElementOverListener) { | ||
this.onElementOverListener(tooltip.value); | ||
|
||
setCursorPosition = action((x: number, y: number) => { |
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.
Perhaps some of the computation in this function can be pulled into utils as pure functions which (hopefully) will make test writing a bit easier.
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.
partially solved 7212d51
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 LGTM 👍 and tested locally on Firefox
fixed crosshair/tooltip positioning on rotated charts, moved computation to state, add testing for set cursor function
Refactor based on review. Removed an unused function
for ordinal chart with line/area only, we have to take in consideration that the bandwidth of the cursorBand is the same as the bandwidth of the scale, and we don't have to take in consideration that the totalgroupcount is 0 (that compute only bar groups)
I've refactored the name because it's a bit more clear to read and understand than a generic groupCount. In fact, that value counts the number of bars clusteres on each x value.
Refactored the mergeYdomains to avoid throwing that will never happens
5246166
to
82a18d3
Compare
🎉 This PR is included in version 3.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
close #80
close #58
close #88
Summary
This PR introduce the Crosshair interaction.
We have removed every listeners to canvas elements. We are instead using a map for each value on the chart: this map maps x value and any relative Y values associated. We then just invert the x scale relative to the mouse point to get the right X key to use on that map. This increase the performance on highly/medium dense charts.
We added two new props to
Settings
:tooltipType
: that describe the type of tooltip/crosshair to useCrosshair
,VerticalCursor
,Follow
,None
tooltipSnap
: that define if we want to tooltip to snap to the grid/x axis values or not for line/area chartsNOTE
The inverted function on time scales, currently works correctly when using UTC dates. Further investigation needs to be done to make that works with any time zone. To test this check
Interactions - brush selection tool on time charts
story and remove theZ
from thenow
constant time.ToDo:
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.