Thank you @Bryan. After doing changes as you mentioned it works for me. But my real issue is with below graph, while applying “hline” mode of Hovertool it works perfectly, but while applying “vline” mode, it doesn’t work on graph rather it display hover on axis for inital and final value.
This is my data format:
DATE VOLUME
0 2019-04-18 18168.0
1 2019-04-16 51630.0
2 2019-04-15 17768.0
3 2019-04-12 57049.0
4 2019-04-11 21701.0
dataframe = pd.DataFrame(data2)
print(dataframe)
if dataframe['VOLUME'].max() >= 100000:
dataframe["VOLUME"] = dataframe["VOLUME"].__div__(100)
else:
dataframe["VOLUME"] = dataframe["VOLUME"]
dataframe['DATE'] = [x.strftime("%Y-%m-%d %H:%M:%S") for x in dataframe['DATE']]
dataframe['DATE'] = pd.to_datetime(dataframe['DATE'])
p = ColumnDataSource( data=dict(DATE=[], VOLUME=[]))
p.data = p.from_df(dataframe)
print(p.data)
ts2 = figure(plot_height=200,sizing_mode='stretch_both', x_axis_type='datetime',
active_drag="auto", x_axis_label='DATE', y_axis_label='VOLUME')
t1 = ts2.vbar(x ='DATE', top= 'VOLUME',width = 1, bottom = 0, legend='volume',
color='red', source=p)
ts2.grid.grid_line_alpha = 0.8
ts2.add_tools(HoverTool(renderers=[t1],
tooltips=[("Date", "@DATE{%F}"), ("Volume", "@VOLUME{0.2f}")],
formatters={"DATE": "datetime"},
mode='vline'))
#ts2.add_tools(hover_tool)
ts2.x_range.start = dataframe.DATE.min().timestamp() * 1000
ts2.x_range.end = dataframe.DATE.max().timestamp() * 1000
curdoc().add_root(ts2)