From 4939f3a2a2d3a538c107684418b3a6b7c33c38e1 Mon Sep 17 00:00:00 2001 From: Maxim Zudilov Date: Fri, 25 Aug 2017 22:30:13 +1200 Subject: [PATCH] Apply advanced analytics processing to comparison time series --- superset/viz.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/superset/viz.py b/superset/viz.py index 98f2d1bc29648..7c88aa12f6de0 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -853,7 +853,7 @@ def to_series(self, df, classed='', title_suffix=''): chart_data.append(d) return chart_data - def get_data(self, df): + def process_data(self, df): fd = self.form_data df = df.fillna(0) if fd.get("granularity") == "all": @@ -909,6 +909,11 @@ def get_data(self, df): df = df[num_period_compare:] + return df + + def get_data(self, df): + fd = self.form_data + df = self.process_data(df) chart_data = self.to_series(df) time_compare = fd.get('time_compare') @@ -922,10 +927,7 @@ def get_data(self, df): df2 = self.get_df(query_object) df2[DTTM_ALIAS] += delta - df2 = df2.pivot_table( - index=DTTM_ALIAS, - columns=fd.get('groupby'), - values=fd.get('metrics')) + df2 = self.process_data(df2) chart_data += self.to_series( df2, classed='superset', title_suffix="---") chart_data = sorted(chart_data, key=lambda x: x['key'])