Skip to content

Commit

Permalink
[bugfix] fix visualization with adhocMetric (apache#5080)
Browse files Browse the repository at this point in the history
* fix visualization with adhocMetric

* update
  • Loading branch information
zhaoyongjie authored and mistercrunch committed May 25, 2018
1 parent cdcb4e1 commit e592a39
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def as_floats(field):

def get_data(self, df):
df = df.fillna(0)
df['metric'] = df[[self.metric]]
df['metric'] = df[[self.get_metric_label(self.metric)]]
values = df['metric'].values
return {
'measures': values.tolist(),
Expand Down Expand Up @@ -1324,8 +1324,8 @@ def get_data(self, df):
if self.form_data.get('granularity') == 'all':
raise Exception(_('Pick a time granularity for your time series'))

metric = fd.get('metric')
metric_2 = fd.get('metric_2')
metric = self.get_metric_label(fd.get('metric'))
metric_2 = self.get_metric_label(fd.get('metric_2'))
df = df.pivot_table(
index=DTTM_ALIAS,
values=[metric, metric_2])
Expand Down Expand Up @@ -1376,7 +1376,7 @@ def get_data(self, df):
df = df.pivot_table(
index=DTTM_ALIAS,
columns='series',
values=fd.get('metric'))
values=self.get_metric_label(fd.get('metric')))
chart_data = self.to_series(df)
for serie in chart_data:
serie['rank'] = rank_lookup[serie['key']]
Expand Down Expand Up @@ -1544,8 +1544,8 @@ class SunburstViz(BaseViz):
def get_data(self, df):
fd = self.form_data
cols = fd.get('groupby')
metric = fd.get('metric')
secondary_metric = fd.get('secondary_metric')
metric = self.get_metric_label(fd.get('metric'))
secondary_metric = self.get_metric_label(fd.get('secondary_metric'))
if metric == secondary_metric or secondary_metric is None:
df.columns = cols + ['m1']
df['m2'] = df['m1']
Expand Down Expand Up @@ -1644,7 +1644,7 @@ def query_obj(self):
qry = super(ChordViz, self).query_obj()
fd = self.form_data
qry['groupby'] = [fd.get('groupby'), fd.get('columns')]
qry['metrics'] = [fd.get('metric')]
qry['metrics'] = [self.get_metric_label(fd.get('metric'))]
return qry

def get_data(self, df):
Expand Down Expand Up @@ -1712,8 +1712,8 @@ def get_data(self, df):
from superset.data import countries
fd = self.form_data
cols = [fd.get('entity')]
metric = fd.get('metric')
secondary_metric = fd.get('secondary_metric')
metric = self.get_metric_label(fd.get('metric'))
secondary_metric = self.get_metric_label(fd.get('secondary_metric'))
if metric == secondary_metric:
ndf = df[cols]
# df[metric] will be a DataFrame
Expand Down

0 comments on commit e592a39

Please sign in to comment.