Skip to content

Commit

Permalink
Apply advanced analytics processing to comparison time series
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmzdlv committed Aug 25, 2017
1 parent 0c8b243 commit 4939f3a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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')
Expand All @@ -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'])
Expand Down

0 comments on commit 4939f3a

Please sign in to comment.