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 |
villebro
left a comment
There was a problem hiding this comment.
Some thoughts, let me know if you wanna discuss this
villebro
left a comment
There was a problem hiding this comment.
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 |
| 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.
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.
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.
Echart is not using echartRef
| timeFormat, | ||
| yAxisFormat, | ||
| } = formData; | ||
| const refs: Refs = {}; |
There was a problem hiding this comment.
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.
| <div className={className} style={{ height }}> | ||
| {this.renderFallbackWarning()} | ||
| {this.renderKicker(kickerFontSize * height)} | ||
| {this.renderKicker((kickerFontSize || 0) * height)} |
There was a problem hiding this comment.
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.
note: This whole chart should be refactored to be a functional component
| } & EchartsTitleFormData; | ||
| } & TitleFormData; |
There was a problem hiding this comment.
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.
I decided to split out the context menu and cross filtering props into separate types to avoid code duplication.
| // did mount | ||
| useEffect(() => { | ||
| handleSizeChange({ width, height }); | ||
| return () => chartRef.current?.dispose(); |
There was a problem hiding this comment.
This fixes the sticky tooltip bug (disposes the chart instance during cleanup)
kgabryje
left a comment
There was a problem hiding this comment.
I looked through the code and tested the flows on eph env. Looks great to me!
|
Ephemeral environment shutdown and build artifacts deleted. |
Co-authored-by: Ville Brofeldt <ville.brofeldt@apple.com>
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
: