holoviews
holoviews copied to clipboard
Add min_interval and max_interval to the RangeToolLink
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:
- [ ] Add tests
- [ ] Add examples
- [ ] Right now, it does not work well without setting bounds (same with bokeh). Is this ok? Opened an issue here: https://github.com/bokeh/bokeh/issues/13725
https://github.com/holoviz/holoviews/assets/19758978/f7c3eaf2-1dc2-40b2-8c46-28fc5d8023a0
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))