-
Notifications
You must be signed in to change notification settings - Fork 68
LG-4580: tooltip pinning #2837
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
base: main
Are you sure you want to change the base?
LG-4580: tooltip pinning #2837
Conversation
…heck, add options to off/on callbacks, and add showTooltip callback
…ltipVisibility hook
🦋 Changeset detectedLatest commit: a892fcd The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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: +1.61 kB (+0.11%) Total Size: 1.5 MB
ℹ️ View Unchanged
|
56c6da7
to
b12995e
Compare
@@ -27,14 +29,13 @@ | |||
"@lg-charts/colors": "workspace:^", | |||
"@lg-charts/series-provider": "workspace:^", | |||
"echarts": "^5.5.1", | |||
"lodash.debounce": "^4.0.8" |
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.
removed debounce in previous PR but forgot to drop this dep
}); | ||
} | ||
}, [echart, hideTooltip, off, on, ready]); | ||
const { tooltipPinned, setTooltipMounted } = useTooltipVisibility({ echart }); |
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.
abstracted all tooltip visibility logic into useTooltipVisibility
hook
@@ -50,14 +55,25 @@ export function CustomTooltip({ | |||
} | |||
|
|||
return ( | |||
<div className={getContainerStyles(theme)}> |
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.
moved container styles up to the echarts tooltip root because this isn't reactive to theme
changes
options?: Partial<{ useCanvasAsTrigger: boolean }>, | ||
): void; | ||
( | ||
event: 'zoomselect', | ||
callback: (params: EChartZoomSelectionEvent) => void, | ||
options?: Partial<{ useCanvasAsTrigger: boolean }>, |
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.
open to feedback on naming here. this will make sure the event listener is attached to the full canvas
https://echarts.apache.org/en/tutorial.html#Events%20and%20Actions%20in%20ECharts
@@ -171,7 +171,7 @@ export function useEchart({ | |||
const isZoomed = params?.start !== 0 || params?.end !== 100; | |||
|
|||
if (isZoomed) { | |||
echartsInstance?.dispatchAction({ | |||
echartsInstance!.dispatchAction({ |
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.
updated these to echartsInstance!
because withInstanceCheck
has already checked for the existence of an instance
if ( | ||
params.componentType === 'markPoint' || | ||
params.componentType === 'markLine' | ||
) { | ||
hideTooltip(); | ||
on(EChartEvents.MouseMove, hideTooltip); | ||
off(EChartEvents.Click, pinTooltipOnClick, { | ||
useCanvasAsTrigger: true, | ||
}); | ||
} |
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.
proactively updated this to apply to mark lines as well
…ltip stories, remove console.log
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.
I think there might be some issues with this when multiple charts are rendered: https://642700aa3e49e32bdbf0b0fc-bjcjukghmg.chromatic.com/?path=/story/charts-core--synced-by-group-id
When I keep them synced, the behavior appears a bit erratic:
https://github.com/user-attachments/assets/158141f9-f0fd-47e7-8f20-74ae28e5b572
If I unsync them and just have them both render I'm seeing some z-index issues:
I'm also noticing that sometimes if I move the mouse around enough, one tooltip will become frozen on one chart even though I never clicked and pinned it:
5a638e3
to
5796f15
Compare
✍️ Proposed changes
Primary changes:
ChartTooltip
visibility intouseTooltipVisibility
hookAdditional changes:
echartsInstance
in callbacks that are wrappedwithInstanceCheck
ChartTooltip
to useTOOLTIP_ID
constant🎟 Jira ticket: LG-4580
✅ Checklist
For bug fixes, new features & breaking changes
pnpm changeset
and documented my changes🧪 How to test changes
WithZoomAndTooltip
story