holoviz / geoviews

Simple, concise geographical visualization in Python
http://geoviews.org
BSD 3-Clause "New" or "Revised" License
597 stars 77 forks source link

Fix hover for overlays of gv.Points #631

Closed hoxbro closed 1 year ago

hoxbro commented 1 year ago

Fixes #618 (the hover problem)

The main problem is the self.handles.get('hover') was the same for all plots in the overlay, where we wanted the hover per plot.

The example given in the issue could be cut down to this MRE:

import geoviews as gv
import pandas as pd

gv.extension("bokeh")
gv.opts.defaults(
    gv.opts.NdOverlay(tools=["hover"], legend_position="right", width=600),
    gv.opts.Points(tools=["hover"], size=10),
)

df = pd.DataFrame(
    dict(
        latitude=range(55, 60),
        longitude=range(-160, -155),
        time=pd.date_range("2020-01-01", freq="M", periods=5),
    )
)

ds = gv.Dataset(df, kdims=["longitude", "latitude", "time"])
ds.to(gv.Points).overlay()

image

(Note the NaN problem will be fixed in #625)