mirror of https://github.com/apache/superset.git
Apply advanced analytics processing to comparison time series (#3373)
This commit is contained in:
parent
0c8b24378d
commit
c944c61747
|
@ -853,7 +853,7 @@ class NVD3TimeSeriesViz(NVD3Viz):
|
||||||
chart_data.append(d)
|
chart_data.append(d)
|
||||||
return chart_data
|
return chart_data
|
||||||
|
|
||||||
def get_data(self, df):
|
def process_data(self, df):
|
||||||
fd = self.form_data
|
fd = self.form_data
|
||||||
df = df.fillna(0)
|
df = df.fillna(0)
|
||||||
if fd.get("granularity") == "all":
|
if fd.get("granularity") == "all":
|
||||||
|
@ -909,6 +909,11 @@ class NVD3TimeSeriesViz(NVD3Viz):
|
||||||
|
|
||||||
df = df[num_period_compare:]
|
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)
|
chart_data = self.to_series(df)
|
||||||
|
|
||||||
time_compare = fd.get('time_compare')
|
time_compare = fd.get('time_compare')
|
||||||
|
@ -922,10 +927,7 @@ class NVD3TimeSeriesViz(NVD3Viz):
|
||||||
|
|
||||||
df2 = self.get_df(query_object)
|
df2 = self.get_df(query_object)
|
||||||
df2[DTTM_ALIAS] += delta
|
df2[DTTM_ALIAS] += delta
|
||||||
df2 = df2.pivot_table(
|
df2 = self.process_data(df2)
|
||||||
index=DTTM_ALIAS,
|
|
||||||
columns=fd.get('groupby'),
|
|
||||||
values=fd.get('metrics'))
|
|
||||||
chart_data += self.to_series(
|
chart_data += self.to_series(
|
||||||
df2, classed='superset', title_suffix="---")
|
df2, classed='superset', title_suffix="---")
|
||||||
chart_data = sorted(chart_data, key=lambda x: x['key'])
|
chart_data = sorted(chart_data, key=lambda x: x['key'])
|
||||||
|
|
Loading…
Reference in New Issue