diff --git a/gym/views.py b/gym/views.py index f08c8a5..ed94fe9 100644 --- a/gym/views.py +++ b/gym/views.py @@ -295,12 +295,20 @@ class TheoreticalMaxListView(LoginRequiredMixin, QuickActionsMixin, generic.List def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - graph = plotly.offline.plot({ - "data": [go.Scatter(x=[max.date for max in self.get_queryset()], y=[max.value for max in self.get_queryset()])], - "layout": go.Layout(title="Évolution du max théorique", - yaxis={"title": "Charge ({})".format(self.equipment.unit.name)}, - xaxis={"title": "Date"}), - }, auto_open=False, output_type='div') + + data = [ + go.Scatter( + x=[max.date for max in self.get_queryset()], + y=[max.value for max in self.get_queryset()], + ), + ] + layout = go.Layout( + title="Évolution du max théorique", + yaxis={"title": "Charge ({})".format(self.equipment.unit.name)}, + xaxis={"title": "Date"}, + ) + figure = {"data": data, "layout": layout, } + graph = plotly.offline.plot(figure, auto_open=False, output_type='div') context['graph'] = graph context['equipment'] = self.equipment