diff --git a/prices/views.py b/prices/views.py index 21652cd..2216592 100644 --- a/prices/views.py +++ b/prices/views.py @@ -180,6 +180,9 @@ def update_chart(self, context, **kwargs): day_ahead = pd.Series(index=[a.date_time for a in p], data=[a.day_ahead for a in p]) agile = day_ahead_to_agile(day_ahead, region=region).sort_index() + hover_template_time_price = "%{x|%H:%M}
%{y:.2f}p/kWh" + hover_template_price = "%{y:.2f}p/kWh" + data = data + [ go.Scatter( x=agile.loc[:forecast_end].index.tz_convert("GB"), @@ -187,6 +190,7 @@ def update_chart(self, context, **kwargs): marker={"symbol": 104, "size": 1, "color": "white"}, mode="lines", name="Actual", + hovertemplate=hover_template_price, ) ] @@ -216,7 +220,8 @@ def update_chart(self, context, **kwargs): marker={"symbol": 104, "size": 10}, mode="lines", line=dict(width=width), - name=f.name, + name="Prediction", + hovertemplate=hover_template_price, ) ] @@ -230,6 +235,7 @@ def update_chart(self, context, **kwargs): line=dict(width=1, color="red"), name="Low", showlegend=False, + hovertemplate=hover_template_price ), go.Scatter( x=df.index, @@ -241,6 +247,7 @@ def update_chart(self, context, **kwargs): showlegend=False, fill="tonexty", fillcolor="rgba(255,127,127,0.5)", + hovertemplate=hover_template_price, ), ] width = 1 @@ -355,6 +362,7 @@ def update_chart(self, context, **kwargs): legend=legend, height=height, template="plotly_dark", + hovermode='x', ) figure.update_layout(**layout) @@ -376,8 +384,8 @@ def update_chart(self, context, **kwargs): ) figure.update_xaxes( tickformatstops=[ - dict(dtickrange=[None, 86000000], value="%H:%M\n%a %d %b"), - dict(dtickrange=[86000000, None], value="%a\n%b %d"), + dict(dtickrange=[None, 86000000], value="%H:%M
%a %d %b"), + dict(dtickrange=[86000000, None], value="%H:%M
%a %d %b"), ], # fixedrange=True, )