-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
fix: Drill to detail blocked by tooltip #22082
fix: Drill to detail blocked by tooltip #22082
Conversation
Codecov Report
@@ Coverage Diff @@
## master #22082 +/- ##
==========================================
- Coverage 65.49% 65.46% -0.04%
==========================================
Files 1835 1835
Lines 69927 69983 +56
Branches 7590 7610 +20
==========================================
+ Hits 45802 45814 +12
- Misses 22159 22203 +44
Partials 1966 1966
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Some thoughts, let me know if you wanna discuss this
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 left a long reply to your comment, but TL;DR, even if we don't implement an exotic position callback, I think your solution might be better than the current behavior, which isn't completely unproblematic, either. So I'm approving this, but it could be fun to try to create a better positioning function and maybe contribute that upstream? Happy to pair on it if you're interested 🙂
Looking at the examples you posted I'm still not happy with the final result. I agree we should try to improve the algorithm. Did you see this one? I'll leave this open so we can collaborate. |
f331477
to
26ee293
Compare
/testenv up |
@villebro Ephemeral environment spinning up at http://34.220.125.160:8080. Credentials are |
/testenv up |
@michael-s-molina Ephemeral environment spinning up at http://54.188.153.91:8080. Credentials are |
}: TimeseriesChartTransformedProps) { | ||
const { emitFilter, stack } = formData; | ||
const echartRef = useRef<EchartsHandler | null>(null); | ||
// eslint-disable-next-line no-param-reassign | ||
refs.echartRef = echartRef; |
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.
It seems echartRef
is only being used internally in EchartsTimeseries
. Do we need to add it to refs
?
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.
It was previously being passed to the Echart
component in a separate dedicated ref
field. To avoid having two properties (one for the div ref and one for the echart ref), I decided to just place both of them in that refs
object (I was becoming tired at this point and running low on imagination 😄 )
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.
Echart
is not using echartRef
@@ -38,6 +41,7 @@ export default function transformProps(chartProps: BigNumberTotalChartProps) { | |||
timeFormat, | |||
yAxisFormat, | |||
} = formData; | |||
const refs: Refs = {}; |
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.
the refs
object is needed here so the downstream code (transformProps
-> Chart plugin component -> Echart
component) can add the reference to the chart div for the tooltip positioning callback to calculate the current location of the pointer.
@@ -311,7 +291,7 @@ class BigNumberVis extends React.PureComponent<BigNumberVisProps> { | |||
return ( | |||
<div className={className} style={{ height }}> | |||
{this.renderFallbackWarning()} | |||
{this.renderKicker(kickerFontSize * height)} | |||
{this.renderKicker((kickerFontSize || 0) * height)} |
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.
lots of minor checks that needed to be added when the interfaces/types where updated
|
||
export type TimeSeriesDatum = [number, number | null]; | ||
|
||
export type BigNumberVizProps = { |
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.
note: This whole chart should be refactored to be a functional component
} & EchartsTitleFormData; | ||
} & TitleFormData; |
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 decided to remove the Echarts
prefix from some types as it felt slightly redundant (this is an ECharts plugin, after all)
BaseTransformedProps<EchartsGaugeFormData> & | ||
ContextMenuTransformedProps & | ||
CrossFilterTransformedProps; |
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 decided to split out the context menu and cross filtering props into separate types to avoid code duplication.
@@ -106,6 +111,7 @@ function Echart( | |||
// did mount | |||
useEffect(() => { | |||
handleSizeChange({ width, height }); | |||
return () => chartRef.current?.dispose(); |
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 fixes the sticky tooltip bug (disposes the chart instance during cleanup)
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
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 looked through the code and tested the flows on eph env. Looks great to me!
Ephemeral environment shutdown and build artifacts deleted. |
SUMMARY
Implements a custom tooltip positioning function that ensures that the tooltip never overlaps with the pointer during normal use. In addition this fixes a bug that would cause the tooltip to stay on screen if the tooltip was visible when the user navigated away from the page.
This PR also cleans up some types on the ECharts plugin package (these kinda needed to be fixed as the code was becoming difficult to manage.
AFTER
Now tooltips are allowed to overflow other charts:
hover3.mp4
In addition, the sticky hover bug is also gone:
nav_after.mp4
BEFORE
Before, the pointer would overflow the tooltip if the chart was small enough and never utilized free space next to the chart:
overlap_before.mp4
Also navigating away from the page with the chart would sometimes leave the tooltip stuck in the middle of the screen:
nav_before.mp4
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
: