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

Add support for hover when datashade points #1428

Closed
ahuang11 opened this issue Sep 30, 2024 · 4 comments · May be fixed by #1430
Closed

Add support for hover when datashade points #1428

ahuang11 opened this issue Sep 30, 2024 · 4 comments · May be fixed by #1430
Labels
type: enhancement New feature or request

Comments

@ahuang11
Copy link
Collaborator

Through ship traffics, I realized I can add hover tooltips to datashaded/rasterized plots; either through hd.inspect_points or a lookup_hook.
https://examples.holoviz.org/gallery/ship_traffic/ship_traffic.html#selecting-specific-datapoints

Can we have a reasonable default for hvPlot when hover=True? Or even HoloViews?

import pandas as pd
import hvplot.pandas
import panel as pn
import datashader as ds
import holoviews as hv
import holoviews.operation.datashader as hd

pop = pd.DataFrame(
    {
        "lon": [-86.75, -86.5, -86.25, -86.0],
        "lat": [33.75, 34.0, 34.25, 34.5],
        "population": [100, 200, 300, 400],
        "R": ["A", "B", "A", "B"],
    }
)

# lon_lat_to_easting_northing
pop["x"], pop["y"] = hv.util.transform.lon_lat_to_easting_northing(
    pop["lon"], pop["lat"]
)
tiles = hv.element.tiles.EsriStreet()

alpha_slider = pn.widgets.FloatSlider(name="Population", start=0, end=1, step=0.1)

highlighter = hd.inspect_points.instance(streams=[hv.streams.Tap])

points = pop.hvplot.points(
    "x",
    "y",
    datashade=True,
    aggregator=ds.count_cat("R"),
    dynspread=True,
    height=800,
    width=1000,
)
highlight = highlighter(points).opts(
    color="white", tools=["hover"], marker="square", size=10, fill_alpha=0
)
points * highlight

image

Currently, if you just do hover=True alongside datashade, it gives a useless RGB value

points = pop.hvplot.points(
    "x",
    "y",
    datashade=True,
    aggregator=ds.count_cat("R"),
    dynspread=True,
    height=800,
    width=1000,
    hover=True
)
points
image
@jbednar
Copy link
Member

jbednar commented Sep 30, 2024

That's certainly where I am hoping instant inspections will end up, revealing as close to what we offer for non-datashaded Bokeh by default, but appropriately modified to take aggregation into account.

@ahuang11 ahuang11 added type: enhancement New feature or request and removed TRIAGE labels Oct 1, 2024
@ahuang11 ahuang11 changed the title Add support for hover when datashade/rasterize Add support for hover when datashade points Oct 2, 2024
@philippjfr
Copy link
Member

I don't think we're at the point where we can realistically offer this by default bound to a PointerXY stream simply because it's too slow and the experience will be sub-optimal. With the index layer approach that Simon will start working on very soon it may be okay.

@philippjfr
Copy link
Member

Indeed this is a duplicate of #1211

@maximlt
Copy link
Member

maximlt commented Oct 4, 2024

Indeed this is a duplicate of #1211

Indeed, closing this issue if favor of the original one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants