-
Notifications
You must be signed in to change notification settings - Fork 695
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
new(annotation): add new Annotation components #907
Merged
Merged
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
Pull Request Test Coverage Report for Build 348377735
💛 - Coveralls |
I'll add better tests in a separate PR since coverage ⬇️ |
1 task
hshoff
approved these changes
Nov 3, 2020
kristw
approved these changes
Nov 5, 2020
ff89d3e
to
f38df36
Compare
…ditableAnnotation
566753b
to
20565c2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🚀 Enhancements
This PR builds on required
@visx/drag
work (#902, #905) and adds several new components to@visx/annotation
.Why?
Previously we recommended using
react-annotation
which is the most fully featured annotation library out there. We would like to build in a solid annotation layer into the new@visx/xychart
, and when evaluatingreact-annotation
I was a little discouraged because its bundle size is relatively high (95kb
minified) and it has no typings so I would have had to re-write the types anyway.I think we can keep this package size down by avoiding use of
d3-shape
which adds30kb
, and doing some relatively simple math for the few shapes we need.What
![](https://user-images.githubusercontent.com/4496521/97762871-164ea900-1ac7-11eb-9358-7f0ade4eac96.png)
![](https://user-images.githubusercontent.com/4496521/97762971-60d02580-1ac7-11eb-868f-17fbc96a5913.png)
Example usage
Several components are added which are inspired by the
react-annotation
API which has a concept of subject, connector, and label:Label
the annotation label, takestitle/subtitle
and handles@visx/text
rendering, styles, and wrapConnector
the connector from an annotationLabel
to the annotation*Subject
line
andelbow
types (latter shown above)CircleSubject
to annotate a single point (shown above)LineSubject
to annotate a threshold (vertical or horizontal line)In addition to these component parts there are two higher-level components
Annotation
simply takesx/y/dx/dy
as props and provides them incontext
for consumption by child subject, connector, and label componentsEditableAnnotation
wrapsAnnotation
and allows draggable editing of anAnnotation
s position (subject + label)Future work
/annotation
demo to@visx/demo
(sneak peek above 👀 ) + update/docs/annotation
pageRectSubject
to annotate regionsCircleSubject
Connector
to account for aSubject
s fill region (above you can see that the connector line spills into the circle subject's radius, ideally it is aware of the subject region and doesn't enter it)@kristw @hshoff