rclement / datasette-dashboards

Datasette plugin providing data dashboards from metadata
https://datasette-dashboards-demo.vercel.app
Apache License 2.0
137 stars 7 forks source link

Add chart row limit warning tooltip #156

Closed rclement closed 1 year ago

rclement commented 1 year ago

Fixes #144

codecov[bot] commented 1 year ago

Codecov Report

Merging #156 (04233e5) into master (c66d8df) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #156   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          389       388    -1     
  Branches        73        73           
=========================================
- Hits           389       388    -1     
Files Changed Coverage Δ
datasette_dashboards/__init__.py 100.00% <ø> (ø)
tests/test_dashboard_chart.py 100.00% <100.00%> (ø)
tests/test_dashboard_chart_embed.py 100.00% <100.00%> (ø)
tests/test_dashboard_view.py 100.00% <100.00%> (ø)

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

rclement commented 1 year ago

@HaveF I have implemented a chart row limit warning tooltip as per your suggestion in discussion #142. Could you review it works as expected on your end please?

In the demo, you can see the query behind the map chart exceeds the default 1000 rows limit: https://chart-row-limit-dd-demo.vercel.app/-/dashboards/job-offers-stats

rclement commented 1 year ago

There seems to be a regression in the dashboard view only: the size of the viewport is extended on the right and an horizontal scroll is available. This might be coming from the tooltip element not playing nice with the global layout...

HaveF commented 1 year ago

@rclement It looks great! I tested it in my local environment and it works perfectly with my Vega Lite case.

HaveF commented 1 year ago

There seems to be a regression in the dashboard view only: the size of the viewport is extended on the right and an horizontal scroll is available. This might be coming from the tooltip element not playing nice with the global layout...

I observed that this only appears within a certain window size range. Does it have something to do with reactive layout?

rclement commented 1 year ago

I observed that this only appears within a certain window size range. Does it have something to do with reactive layout?

The reactive layout is automatically handled by the native CSS Grid system, so there is almost nothing we can leverage there.

However, debugging elements overflowing the viewport, the culprit is coming from tooltip text boxes (visible or hidden) on the right-most charts of the grid:

Screenshot 2023-08-17 at 18 02 10

So I need a better way to display tooltips without screwing-up the layout with overflows...

rclement commented 1 year ago

Ok so after some digging, here is what I've come up with:

The title attribute is not the sexiest tooltip implementation but is native, requires only HTML (not even CSS not JS) and prevents overflows. So let's use that instead!

@HaveF Can you review the new implementation please? https://chart-row-limit-dd-demo.vercel.app/-/dashboards/job-offers-stats?date_start=2021-01-01

HaveF commented 1 year ago

@rclement It appears to be a reasonable solution without the need for too many dependencies. I also tested it locally with Vega Lite examples, and there were no issues.

However, there is one minor problem - the prompts displayed a bit slowly, taking approximately 2 to 3 seconds. At one point, I thought there were no prompts being displayed at all. If this issue is difficult to address, I believe I can still accept it. It seems a feature of browser, I believe we can accept it.

rclement commented 1 year ago

~However, there is one minor problem - the prompts displayed a bit slowly, taking approximately 2 to 3 seconds. At one point, I thought there were no prompts being displayed at all. If this issue is difficult to address, I believe I can still accept it.~ It seems a feature of browser, I believe we can accept it.

The display latency of the tooltip is the main drawback as I see it, but there is nothing we can do about it as this is a per-browser implementation detail, as you observed.

Let's go with that for now, if there is some tooltip wizard in the audience that want to shime in and propose a dependency-free enhancement we'll check it out!