Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply advanced analytics processing to comparison time series #3373

Merged
merged 1 commit into from
Aug 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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