Rearrange code

This commit is contained in:
Gabriel Augendre 2018-03-30 20:54:58 +02:00
parent 098d9d821c
commit cc657ad4e4
No known key found for this signature in database
GPG key ID: F360212F958357D4

View file

@ -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