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: Server side HoverTool for rasterized/datashaded plots with selector #6422

Draft
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Oct 25, 2024

Previously, we sent all hover data to the front end. This could lead to significant overhead on larger plots. With this PR, the data is pushed server side to the hover tool with a custom data model.

Screencast.2024-10-25.15.50.14.mp4
import datashader as ds
import numpy as np
import pandas as pd
import panel as pn

import holoviews as hv
from holoviews.operation.datashader import rasterize, datashade, dynspread

hv.extension("bokeh")

num = 10000
seed = np.random.default_rng(1)


dists = {
    cat: pd.DataFrame(
        {
            "x": seed.normal(x, s, num),
            "y": seed.normal(y, s, num),
            "s": s,
            "val": val,
            "cat": cat,
        }
    )
    for x, y, s, val, cat in [
        (2, 2, 0.03, 0, "d1"),
        (2, -2, 0.10, 1, "d2"),
        (-2, -2, 0.50, 2, "d3"),
        (-2, 2, 1.00, 3, "d4"),
        (0, 0, 3.00, 4, "d5"),
    ]
}

df = pd.concat(dists, ignore_index=True)
points = hv.Points(df)
agg, sel = ds.min("s"), ds.min("s")
plot = rasterize(points, aggregator=agg, selector=sel).opts(tools=["hover"])

Also adding support for datashaded plots:

plot = datashade(points, aggregator=agg, selector=sel).opts(tools=["hover"], hover_tooltips=["x", "y", "s"])
Screencast.2024-10-28.10.28.49.mp4

And dynspread:

plot = datashade(points, aggregator=agg, selector=sel).opts(tools=["hover"], hover_tooltips=["x", "y", "s", "cat"])
plot = dynspread(plot)
Screencast.2024-10-29.13.47.42.mp4

@hoxbro hoxbro added the type: enhancement Minor feature or improvement to an existing feature label Oct 25, 2024
Copy link

codecov bot commented Oct 25, 2024

Codecov Report

Attention: Patch coverage is 84.82143% with 34 lines in your changes missing coverage. Please review.

Project coverage is 88.48%. Comparing base (3acfadb) to head (8fe1e26).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/tests/ui/bokeh/test_hover.py 51.28% 19 Missing ⚠️
holoviews/operation/datashader.py 89.04% 8 Missing ⚠️
holoviews/plotting/bokeh/raster.py 88.88% 6 Missing ⚠️
holoviews/element/raster.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6422      +/-   ##
==========================================
- Coverage   88.50%   88.48%   -0.03%     
==========================================
  Files         323      323              
  Lines       68631    68796     +165     
==========================================
+ Hits        60741    60872     +131     
- Misses       7890     7924      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hoxbro hoxbro changed the title enh: Update hovertool server side for rasterized plots enh: Make HoverTool update server side for rasterized/datashaded plots Oct 28, 2024
@hoxbro hoxbro changed the title enh: Make HoverTool update server side for rasterized/datashaded plots feat: Make HoverTool update server side for rasterized/datashaded plots Nov 5, 2024
@hoxbro hoxbro changed the title feat: Make HoverTool update server side for rasterized/datashaded plots feat: Server side HoverTool for rasterized/datashaded plots Nov 5, 2024
@hoxbro hoxbro changed the title feat: Server side HoverTool for rasterized/datashaded plots feat: Server side HoverTool for rasterized/datashaded plots with selector Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant