I am a beginner to using Python's bokeh plotting tool and widgets. In my following code I am trying to have the title of the graph change to the value of the TextInput box. However, while the box appears upon entering in text and unfocusing, nothing changes. What could be causing this issue and what can I do to fix it?
p=figure(
height=400,
x_axis_type='datetime',
title=(company+' ('+tickerstring+') ')
)
thedates = np.array(stockdates, dtype=np.datetime64)
source = ColumnDataSource(data=dict(
x=thedates,
y=stockcloseprices
))
p.line('x', 'y', source=source)
p.grid.grid_line_color="white"
p.xaxis.axis_label = 'Date'
p.yaxis.axis_label = 'Price'
p.add_tools(HoverTool(
tooltips=[
("Date", "@x{%F}"),
('Close',"@y")
],
formatters={
'x':'datetime', # use 'datetime' formatter for 'date' field
},
mode='vline'
))
def update_title(attrname, old, new):
p.title = text.value
div = Div(text='<br><b> Key Points </b><br><br>'+percentagechange+'<br><br>'+performance,
width=200, height=100)
text = TextInput(value='Name', title="Enter Ticker Here:")
text.on_change('value', update_title)
grid = gridplot([p, div, text], ncols=2, plot_width=570, plot_height=400)
show(grid)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…