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

feat: Utility function to render chart tooltips #27950

Merged

Conversation

michael-s-molina
Copy link
Member

@michael-s-molina michael-s-molina commented Apr 9, 2024

SUMMARY

This PR adds an utility function to render chart tooltips with the following objectives:

  • Add the ability to display total and percentage values for our tooltips. This improvement will also allow us to migrate legacy timeseries charts, which currently display that information, to ECharts.
  • Standardize the way we display tooltips. Currently, every plugin displays tooltips using different information and designs, which decreases the overall user experience. By creating a reusable function, we can ensure consistency across plugins.
  • Reduce code duplication.

This PR will only format ECharts tooltips to limit the scope of work but other plugins can also benefit from the utility function.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screenshot 2024-04-09 at 10 40 12 Screenshot 2024-04-09 at 09 27 11 Screenshot 2024-04-09 at 10 38 21 Screenshot 2024-04-16 at 15 17 05 Screenshot 2024-04-09 at 10 42 09 Screenshot 2024-04-09 at 09 37 36 Screenshot 2024-04-10 at 10 19 15 Screenshot 2024-04-10 at 11 23 46 Screenshot 2024-04-16 at 10 55 53 Screenshot 2024-04-16 at 11 37 02 Screenshot 2024-04-16 at 15 02 27 Screenshot 2024-04-16 at 15 08 56 Screenshot 2024-04-16 at 15 23 41 Screenshot 2024-04-16 at 15 34 21 Screenshot 2024-04-18 at 13 37 20 Screenshot 2024-04-18 at 13 41 16 Screenshot 2024-04-18 at 14 12 42 Screenshot 2024-04-18 at 14 48 27 Screenshot 2024-04-19 at 09 12 08 Screenshot 2024-04-19 at 09 24 32 Screenshot 2024-04-19 at 11 35 04 Screenshot 2024-04-19 at 11 50 08 Screenshot 2024-04-19 at 13 22 01 Screenshot 2024-04-19 at 13 25 55 Screenshot 2024-04-19 at 13 30 42 Screenshot 2024-04-19 at 13 43 55 Screenshot 2024-04-19 at 13 49 11 Screenshot 2024-04-19 at 13 56 33

TESTING INSTRUCTIONS

Test consists in checking how the tooltip is displayed for all ECharts plugins and their different control combinations.

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

@rusackas
Copy link
Member

rusackas commented Apr 9, 2024

One question I have isn't about the PR itself (which is lookin' good!) but about the new component's potential future, and thus its location in the codebase.

Since the TooltipRenderer component doesn't seem to rely on anything ECharts related, do you think it would make sense to move it out of the ECharts plugin and into Superset-UI/core or similar? It seems like we could use it on other plugins (ECharts or not) to standardize the UI even further across Superset. Having that might also pave the way to add a customization controls to it down the road, enabling templating (handlebars/jinja/whatever) and replacing the JS Tooltips used by DeckGL.

@michael-s-molina michael-s-molina changed the title feat: ECharts tooltip renderer feat: Tooltip renderer Apr 9, 2024
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.

This is super exciting, I'm really looking forward to standardizing the tooltip renderer! First pass comment regarding potential readability/performance.

@michael-s-molina
Copy link
Member Author

michael-s-molina commented Apr 10, 2024

@justinpark @villebro @rusackas Thank you for the comments. I'm still working on the component's API and implementation as I continue to iterate on each plugin. I'm still not sure what will be the final API and implementation because each plugin has a unique set of requirements. For that reason, I'll first make sure all ECharts plugins are using the renderer, to have a clear view of all requirements, and then work on optimizations. Feel free to review this PR while it evolves or wait for when it leaves the draft state.

@michael-s-molina michael-s-molina changed the title feat: Tooltip renderer feat: Chart tooltip renderer Apr 10, 2024
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.

This is looking great! Maybe add a few tests, but other than that, once CI clears this looks much better than the current state of affairs.

@michael-s-molina michael-s-molina force-pushed the improve-echarts-tooltip branch 2 times, most recently from 8d4e7b6 to 09a2995 Compare April 19, 2024 14:53
@michael-s-molina michael-s-molina changed the title feat: Chart tooltip renderer feat: Utility function to render chart tooltips Apr 30, 2024
@michael-s-molina michael-s-molina marked this pull request as ready for review April 30, 2024 12:56
@sfirke
Copy link
Member

sfirke commented Apr 30, 2024

Wow this is a nice improvement! 🤩 Thank you for including all of the before/after screenshots. This will implement the following feature requests:

  1. [Chart] Tooltip should show total in Stacked charts (bar, area, ...) #18462
  2. Request: show both %s and frequencies in chart tooltip #28216

@michael-s-molina
Copy link
Member Author

Thanks for linking the resources @sfirke!

Copy link
Member

@justinpark justinpark left a comment

Choose a reason for hiding this comment

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

LGTM!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 7, 2024
@michael-s-molina michael-s-molina merged commit b549977 into apache:master May 7, 2024
29 checks passed
imancrsrk pushed a commit to imancrsrk/superset that referenced this pull request May 10, 2024
jzhao62 pushed a commit to jzhao62/superset that referenced this pull request May 16, 2024
EnxDev pushed a commit to EnxDev/superset that referenced this pull request May 31, 2024
@igamat
Copy link

igamat commented Jun 7, 2024

Really nice feature indeed ! Will this feature be also available for the other types of charts (Country Map, World Map, Bar chart...) any time soon ? Thanks

@rusackas
Copy link
Member

rusackas commented Jun 7, 2024

Really nice feature indeed ! Will this feature be also available for the other types of charts (Country Map, World Map, Bar chart...) any time soon ? Thanks

I think we all WANT it to get there, but it's probably not a high priority at the moment. If you have the means to contribute that as a PR, we'd be super excited to review it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer packages plugins size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants