user3198755:
I have a Streaming Chart where the scores are updated in realtime. I am plotting a graph to show the value as a line graph for Student X. I want the Legend to be updated dynamically(either show as legend in the chart or display the name of the student on mouseover). Below is the code which works perfectly fine without "legend" but when I try to add the legend I get the below error.
Related Articles
How can I show the value dynamically using legend or using mouseover event or if possible any other way?
Code:
p = figure(title="Low Percentage", x_axis_label='Time',
y_axis_label='Low_Perc')
r1 = p.line(x = [], y = [], legend = [], color="firebrick", line_width=2)
ds1 = r1.data_source
@linear()
def update(step):
test = pd.read_json('c:/scores.csv', orient='columns')
test2 = pd.read_json( (test['result']).to_json(), orient='index')
df=test2[['Time','Name','Last','Low','Low_Perc']]
df2=df.sort_values(by='Low_Perc', ascending=False)
y = df2['Low_Perc'].iat[0]
name = df7['Name'].iat[0]
output_file("lines.html")
ds1.data['x'].append(step)
ds1.data['y'].append(y)
ds1.data['legend'].append(name)
ds1.trigger('data', ds1.data, ds1.data, ds1.data)
curdoc().add_root(p)
curdoc().add_periodic_callback(update, 30000)
Error:
Error thrown from periodic callback: KeyError('legend',)
Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE