-
Notifications
You must be signed in to change notification settings - Fork 66
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
LG-4621: Add zooming to Chart
#2561
Conversation
🦋 Changeset detectedLatest commit: 6bb2d93 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Change: +577 B (+0.04%) Total Size: 1.4 MB
ℹ️ View Unchanged
|
if (onChartReady) { | ||
chartInstance.on('finished', onChartReady); | ||
function onInitialRender() { | ||
if (zoomable) { |
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.
should this check that onZoomSelect
is also passed? otherwise, clicking zoom doesn't do anything right?
or alternatively, should there be a default zoom behavior that takes place? (also I could be misunderstanding the onZoomSelect
. I'm going off of the fact that when I click zoom in the storybook example, it doesn't seem to do anything)
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.
This was something that was discussed in #b-team last week here. We decided zoomable
would turn on the "zoom effect" where one can select an area, and that onZoomSelect
would still be needed for any zooming to occur. This is because after speaking with Gregg and Intel, it seemed there was little value in having a default zoom behavior, as zooming should always require a refetch.
The alternative would be to have onZoomSelect
implicitly also turn on the "zoom effect", since as you noted, it won't actually zoom in on the current data and the handler is essentially required. This was a bit debated so I'm definitely open to other thoughts if this seems confusing.
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.
Discussed offline: After you dropped Adam and I just decided that we are going to get rid of zoomable
altogether. We don't want to set a precedent with the pattern of implying functionality (like the click and drag functionality) based on the presence of a handler like this. However this feels like an exception to the rule due to the fact that the data is essentially always controlled and there never exists a scenario where one is useful without the other.
Will push an update shortly and re-request a review then!
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.
🫡 🫡 🫡
@stephl3 Just a note, I also removed the change to storybook since it seemed like having a prop that did nothing but trigger the call of a handler would only lead to confusion. |
| Name | Description | Type | Default | | ||
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------- | | ||
| `onChartReady` | Callback to be called when chart is finished rendering. | `() => void` | | | ||
| `onZoomSelect` _(optional)_ | Callback to be called when a user clicks and drags on a chart to zoom. Click and drag action will only be enabled if this handler is present. | `(ZoomSelectionEvent) => void` | | |
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.
nit: didn't think about this previously but could be helpful to capture what a ZoomSelectionEvent
is somewhere in the readme
✍️ Proposed changes
Adds zooming functionality to
Chart
🎟 Jira ticket: [LG-4621](https://jira.mongodb.org/browse/LG-4621/
✅ Checklist
For bug fixes, new features & breaking changes
yarn changeset
and documented my changesFor new components
🧪 How to test changes
Try in Storybook