Rearrange code
This commit is contained in:
parent
098d9d821c
commit
cc657ad4e4
1 changed files with 14 additions and 6 deletions
20
gym/views.py
20
gym/views.py
|
@ -295,12 +295,20 @@ class TheoreticalMaxListView(LoginRequiredMixin, QuickActionsMixin, generic.List
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**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()])],
|
data = [
|
||||||
"layout": go.Layout(title="Évolution du max théorique",
|
go.Scatter(
|
||||||
yaxis={"title": "Charge ({})".format(self.equipment.unit.name)},
|
x=[max.date for max in self.get_queryset()],
|
||||||
xaxis={"title": "Date"}),
|
y=[max.value for max in self.get_queryset()],
|
||||||
}, auto_open=False, output_type='div')
|
),
|
||||||
|
]
|
||||||
|
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['graph'] = graph
|
||||||
context['equipment'] = self.equipment
|
context['equipment'] = self.equipment
|
||||||
|
|
Loading…
Reference in a new issue