Skip to content
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

Merged
merged 11 commits into from
Nov 23, 2022

Conversation

michael-s-molina
Copy link
Member

@michael-s-molina michael-s-molina commented Nov 9, 2022

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

  1. Go to eph env and open the "tooltip test" dashboard.
  2. Try to make the tooltip overlap the pointer of fall outside the screen (note that scrolling can still make the tooltip go outside)
  3. Navigate away from the dashboard page while the tooltip is open (by using keyboard shortcuts) - the tooltip will no longer be stuck on the screen after navigation.

ADDITIONAL INFORMATION

  • Has associated issue

:

  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@michael-s-molina
Copy link
Member Author

@villebro and @kgabryje I added you as reviewers because this PR is changing the code that you wrote and you may have additional context.

@codecov
Copy link

codecov bot commented Nov 9, 2022

Codecov Report

Merging #22082 (7ad716d) into master (a77b2d6) will decrease coverage by 0.03%.
The diff coverage is 24.24%.

@@            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              
Flag Coverage Δ
javascript 53.75% <24.24%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rts/src/BigNumber/BigNumberTotal/transformProps.ts 0.00% <0.00%> (ø)
...lugin-chart-echarts/src/BigNumber/BigNumberViz.tsx 0.00% <0.00%> (ø)
...lugin-chart-echarts/src/BoxPlot/EchartsBoxPlot.tsx 0.00% <ø> (ø)
.../plugins/plugin-chart-echarts/src/BoxPlot/types.ts 0.00% <ø> (ø)
.../plugin-chart-echarts/src/Funnel/EchartsFunnel.tsx 0.00% <ø> (ø)
...d/plugins/plugin-chart-echarts/src/Funnel/types.ts 100.00% <ø> (ø)
...ns/plugin-chart-echarts/src/Gauge/EchartsGauge.tsx 0.00% <ø> (ø)
...nd/plugins/plugin-chart-echarts/src/Gauge/types.ts 100.00% <ø> (ø)
...ns/plugin-chart-echarts/src/Graph/EchartsGraph.tsx 0.00% <ø> (ø)
...nd/plugins/plugin-chart-echarts/src/Graph/types.ts 100.00% <ø> (ø)
... and 28 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@villebro villebro left a 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

Copy link
Member

@villebro villebro left a 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 🙂

@michael-s-molina
Copy link
Member Author

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.

@villebro
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@villebro Ephemeral environment spinning up at http://34.220.125.160:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@michael-s-molina
Copy link
Member Author

/testenv up

@github-actions
Copy link
Contributor

@michael-s-molina Ephemeral environment spinning up at http://54.188.153.91:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

}: TimeseriesChartTransformedProps) {
const { emitFilter, stack } = formData;
const echartRef = useRef<EchartsHandler | null>(null);
// eslint-disable-next-line no-param-reassign
refs.echartRef = echartRef;
Copy link
Member Author

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?

Copy link
Member

@villebro villebro Nov 23, 2022

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 😄 )

Copy link
Member Author

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 = {};
Copy link
Member

@villebro villebro Nov 23, 2022

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)}
Copy link
Member

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 = {
Copy link
Member

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

Comment on lines -32 to +34
} & EchartsTitleFormData;
} & TitleFormData;
Copy link
Member

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)

Comment on lines +88 to +90
BaseTransformedProps<EchartsGaugeFormData> &
ContextMenuTransformedProps &
CrossFilterTransformedProps;
Copy link
Member

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();
Copy link
Member

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)

Copy link
Member

@jinghua-qa jinghua-qa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@kgabryje kgabryje left a 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!

@villebro villebro merged commit 3bc0865 into apache:master Nov 23, 2022
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XL 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants