Hi all,
I’m unable to update the labels of a legend after it has been shown. I initialize the plot with 10 empty lines. I don’t know however in advance which curves the user will decide to plot because there are more then ten possible curves.
in the init method of my class PakTab I have:
class PakTab:
def __init__(self):
self.__signalsCDS = dict()
self.__graph_Signal = figure(title="Sensor", height=400)
self.__graph_Signal.xaxis.axis_label = 'Time (s)'
for i in range(0, 10):
self.__signalsCDS['LINE'+str(i)] = ColumnDataSource(dict(x=[0], y=[0]))
self.__graph_Signal.line(source=self.__signalsCDS['LINE'+str(i)], x='x', y='y', legend_label=str(i),
color=Category10[10][i])
self.__graph_Signal.legend.location = 'bottom_right'
self.__graph_Signal.legend.click_policy = 'hide'
when I plot a curve i call a method, I added .legend.visible=False, and True to see if that updated the graph but it doesn’t:
def __plot_signal(self):
sensor = self.__pak_info.get_sensor_metadata(self.__selected_sensor)
if sensor:
sensor.get_sensor_data()
i = next(self.__iterator)
self.__graph_Signal.legend.items[i].label['value'] = sensor.label
self.__signalsCDS['LINE' + str(i)].data = dict(x=sensor.create_pcm_time(), y=sensor.values)
self.__graph_Signal.legend.visible = False
self.__graph_Signal.legend.visible = True
do you know how I can achieve this?
Many thanks