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 min_interval and max_interval to the RangeToolLink #6134

Merged
merged 10 commits into from May 17, 2024

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Feb 27, 2024

Fixes #6060

It needs #6130 to work! I have set the merge to that PR, but it should not be merged into it (for obvious reasons).

Todo:

screenrecord-2024-02-27_12.47.17.mp4
Code
from datetime import timedelta, datetime

import pandas as pd
import holoviews as hv
from holoviews import opts
from holoviews.plotting.links import RangeToolLink
from bokeh.sampledata.stocks import AAPL

hv.extension("bokeh")

aapl_df = pd.DataFrame(AAPL["close"], columns=["close"], index=pd.to_datetime(AAPL["date"]))
aapl_df.index.name = "Date"
aapl_curve = hv.Curve(aapl_df, "Date", ("close", "Price ($)"))

tgt = aapl_curve.relabel("AAPL close price").opts(width=800, labelled=["y"], toolbar="disable")
src = aapl_curve.opts(width=800, height=100, yaxis=None, default_tools=[])

RangeToolLink(
    src,
    tgt,
    axes=["x", "y"],
    boundsx=(datetime(2002, 1, 1), datetime(2003, 1, 1)),
    intervalsx=(timedelta(days=100), timedelta(days=365)),
)

layout = (tgt + src).cols(1)
layout.opts(opts.Layout(shared_axes=False, merge_tools=False))

@hoxbro hoxbro added the type: enhancement Minor feature or improvement to an existing feature label Feb 27, 2024
@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2024

Codecov Report

Attention: Patch coverage is 88.73239% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 88.19%. Comparing base (e70ed32) to head (4f33ab5).

Files Patch % Lines
holoviews/tests/ui/bokeh/test_links.py 82.14% 5 Missing ⚠️
holoviews/plotting/bokeh/links.py 93.33% 2 Missing ⚠️
holoviews/tests/conftest.py 90.90% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6134   +/-   ##
=======================================
  Coverage   88.18%   88.19%           
=======================================
  Files         321      322    +1     
  Lines       67360    67405   +45     
=======================================
+ Hits        59402    59445   +43     
- Misses       7958     7960    +2     

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

@hoxbro hoxbro marked this pull request as draft February 27, 2024 12:41
Base automatically changed from bokeh34 to main February 27, 2024 18:08
@droumis droumis requested a review from philippjfr April 5, 2024 16:24
@TheoMathurin
Copy link
Contributor

TheoMathurin commented Apr 15, 2024

NB: currently on Bokeh 3.4.1 with bokeh/bokeh#13725 fixed, {min,max}_interval are enforced on first render for Bokeh plots but not for Holoviews plots (using a hook).

But I guess this will be addressed in this PR.

@hoxbro
Copy link
Member Author

hoxbro commented Apr 15, 2024

That was a big headache for me this Friday. We use Range1d and the fix in Bokeh was for DataRange1d. I have added some ugly code in 82ab659 to try to improve that, but it is suboptimal at best and workaround the problem and not fixing it.

@philippjfr
Copy link
Member

I have added some ugly code in 82ab659 to try to improve that, but it is suboptimal at best and workaround the problem and not fixing it

Has this been raised in bokeh?

@hoxbro hoxbro marked this pull request as ready for review May 8, 2024 12:45
@philippjfr philippjfr merged commit 4a526c0 into main May 17, 2024
13 checks passed
@philippjfr philippjfr deleted the min_max_interval branch May 17, 2024 11:11
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.

Expose max_interval and min_interval as options for Bokeh plots
4 participants