Skip to content

Commit 6a0540c

Browse files
committed
ENH: Link hover crosshairs across plots
Fixes #133
1 parent a05d9ea commit 6a0540c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

backtesting/_plotting.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
)
1616
from bokeh.plotting import figure as _figure
1717
from bokeh.models import (
18+
CrosshairTool,
1819
CustomJS,
1920
ColumnDataSource,
2021
NumeralTickFormatter,
@@ -192,7 +193,7 @@ def plot(*, results: pd.Series,
192193
x_axis_type='linear',
193194
plot_width=plot_width,
194195
plot_height=400,
195-
tools="xpan,xwheel_zoom,box_zoom,undo,redo,reset,crosshair,save",
196+
tools="xpan,xwheel_zoom,box_zoom,undo,redo,reset,save",
196197
active_drag='xpan',
197198
active_scroll='xwheel_zoom')
198199

@@ -600,6 +601,8 @@ def __eq__(self, other):
600601
code=_AUTOSCALE_JS_CALLBACK))
601602

602603
plots = figs_above_ohlc + [fig_ohlc] + figs_below_ohlc
604+
linked_crosshair = CrosshairTool(dimensions='both')
605+
603606
for f in plots:
604607
if f.legend:
605608
f.legend.location = 'top_left' if show_legend else None
@@ -616,6 +619,7 @@ def __eq__(self, other):
616619
f.min_border_right = 10
617620
f.outline_line_color = '#666666'
618621

622+
f.add_tools(linked_crosshair)
619623
wheelzoom_tool = next(wz for wz in f.tools if isinstance(wz, WheelZoomTool))
620624
wheelzoom_tool.maintain_focus = False
621625

0 commit comments

Comments
 (0)