Jul-24-2020, 01:07 PM
Your server function get_weather_data returns a dict whose keys point to two lists, one with strings ('time') and another with numbers ('temp'). When I try to reproduce your code:
>>> temp_data = {'time':['2020-07-23 12:00:00', '2020-07-23 15:00:00', '2020-07-23 18:00:00'], 'temp':[8.81, 7.15, 5.83]} >>> x = [n['time'] for n in temp_data] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: string indices must be integers, not str >>> [type(n) for n in temp_data] [<type 'str'>, <type 'str'>] >>>Because temp_data is the one variable that links to a dict and can be invoked with keys, what happens if you change the line in red with this one:
self.plot_4.data = go.Scatter(x=[n for n in self.temp_data['time']], y=[n for n in self.temp_data['temp']], line=dict(color='#2196f3')