From 0d37a46593c7a1e0b8706be60a3d594ac3285c73 Mon Sep 17 00:00:00 2001 From: Olof-Hojvall Date: Mon, 1 Jul 2019 14:04:16 +0200 Subject: [PATCH] Fixed Plotly Holiday Hover Text --- python/fbprophet/plot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/fbprophet/plot.py b/python/fbprophet/plot.py index f3f90c4..59b3124 100644 --- a/python/fbprophet/plot.py +++ b/python/fbprophet/plot.py @@ -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 != '')] += '
' # Add newline if additional holiday + text[idxs.astype(bool)] += holiday_feature traces = [] traces.append(go.Scatter(