Fixed Plotly Holiday Hover Text

This commit is contained in:
Olof-Hojvall 2019-07-01 14:04:16 +02:00 committed by Ben Letham
parent 3ac99e18d4
commit 0d37a46593

View file

@ -823,8 +823,15 @@ def get_forecast_component_plotly_props(m, fcst, name, uncertainty=True, plot_ca
mode = 'lines'
if name == 'holidays':
fcst = fcst[fcst[name] != 0].copy()
text = fcst.merge(m.holidays, how='left', on='ds')['holiday']
mode = 'markers'
# Combine holidays into one hover text
holiday_features, _, _ = m.make_holiday_features(fcst['ds'], m.holidays)
holiday_features.columns = holiday_features.columns.str.replace('_delim_', '', regex=False)
holiday_features.columns = holiday_features.columns.str.replace('+0', '', regex=False)
text = pd.Series(data='', index=holiday_features.index)
for holiday_feature, idxs in holiday_features.iteritems():
text[idxs.astype(bool) & (text != '')] += '<br>' # Add newline if additional holiday
text[idxs.astype(bool)] += holiday_feature
traces = []
traces.append(go.Scatter(