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

enh: Add formatter to Server HoverTool #6531

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

enh: Add formatter to Server HoverTool #6531

wants to merge 6 commits into from

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Mar 10, 2025

import datetime as dt

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

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,
            "dt": dt.datetime(2020, 1, val + 1),
        }
    )
    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)
df["y"] += 100  # Offset to distinguish x from y
points = hv.Points(df)

plot = rasterize(points, aggregator=ds.min("s"), selector=ds.min("s")).opts(tools=["hover"])
pn.panel(plot).servable()

Copy link

codecov bot commented Mar 10, 2025

Codecov Report

Attention: Patch coverage is 71.42857% with 6 lines in your changes missing coverage. Please review.

Project coverage is 88.81%. Comparing base (99d3528) to head (750d953).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/plotting/bokeh/raster.py 73.33% 4 Missing ⚠️
holoviews/tests/ui/bokeh/test_hover.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6531      +/-   ##
==========================================
+ Coverage   88.79%   88.81%   +0.01%     
==========================================
  Files         323      323              
  Lines       68960    68988      +28     
==========================================
+ Hits        61236    61270      +34     
+ Misses       7724     7718       -6     

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hoxbro
Copy link
Member Author

hoxbro commented Mar 13, 2025

Opened an issue in Bokeh: bokeh/bokeh#14413

@hoxbro
Copy link
Member Author

hoxbro commented Mar 18, 2025

We should merge this PR as is, as the datetime fix will likely sort itself with an upstream fix.

@hoxbro hoxbro marked this pull request as ready for review March 18, 2025 09:40
Comment on lines +106 to +109
if BOKEH_GE_3_7_0:
data_coords = {dim: data_sel['coords'][dim]['data'] for dim in coords}
else:
data_coords = {dim: round(data_sel['coords'][dim]['data'], 3) for dim in coords}
Copy link
Member Author

Choose a reason for hiding this comment

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

It would be OK with me to only have the BOKEH_GE_3_7_0 code.

Copy link
Member

Choose a reason for hiding this comment

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

What's the behavior for older bokeh versions?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is only for the x,y-coords, so it would show 1.999999999999 instead of 2.0.

Though, I'm unsure how it would work if x,y-coords are datetime.

@hoxbro hoxbro requested a review from philippjfr March 20, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants