I have the following bit of code to define the tools for my plot.
tools = [
PanTool(),
BoxZoomTool(),
WheelZoomTool(),
ResetTool(),
CrosshairTool(),
SaveTool(),
HoverTool(
tooltips=tooltips_top,
formatters={'@time': 'datetime'}
)
]
p1 = figure(plot_width=600,
plot_height=400,
tools=tools,
x_axis_type='datetime',
sizing_mode='stretch_width',
tooltips=tooltips_top,
y_axis_location="right")
I’m not able to define the initial active_drag
state. I tried many things such as:
p1.toolbar.active_drag = 'xpan'
but I’m not sure how to get this working.
The following approach works, but then I cannot configure the tools:
tools='xpan, xwheel_zoom, xbox_zoom, reset, hover',
active_drag='xpan',
active_scroll='xwheel_zoom'
I don’t know how to mix those two approaches, where you provide the tools as a list of strings and as a list of functions.
Sorry, I had to edit my question so it is a bit more clear.
You’re creating a completely new tool by doing that. You should save the result of the first call to PanTool()
and later pass it to .active_drag
.
Hi,
Sorry, I don’t understand. Basically, when I provide the tools as a list of tool names, such as below:
tools='xpan, xwheel_zoom, xbox_zoom, reset, hover',
I can do the following:
active_drag='xpan',
active_scroll='xwheel_zoom'
which works, but I also would like to customise some of the tools, like the hover tool for example, pass some custom settings to it.
So when I do this:
MY_TOOLS = [
PanTool(),
BoxZoomTool(),
WheelZoomTool(),
ResetTool(),
CrosshairTool(),
SaveTool(),
HoverTool(
tooltips=tooltips_top,
formatters={'@time': 'datetime'}
)
]
tools=MY_TOOLS
I can no longer define the active_drag
and the active_scroll
states.
Does this work?
pan_tool = PanTool()
tools = [
pan_tool,
...
]
p1 = figure(..., tools=tools, active_drag=pan_tool)
1 Like
Yes! Thank you very much.
One final thing though, how can I have the xpan
mode in the above scenario?
active_drag=xpan_tool
Now I get the X
and Y
pan by using the pan_tool = PanTool()
Is there my_pan_tool = PanTool(axis='X')
?
Got it, it is:
my_pan_tool = PanTool(dimensions='width')
This is working.