Skip to content

Commit

Permalink
Insuring column order
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Dec 10, 2015
1 parent 1685911 commit c3f9607
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,10 +840,20 @@ def get_df(self):

def get_json_data(self):
df = self.get_df()
# if m1 == m2 dupplicate the metric column
if self.form_data['metric'] == self.form_data['secondary_metric']:
df['dup'] = df[df.columns[-1]]
return df.to_json(orient="values")

# if m1 == m2 duplicate the metric column
cols = self.form_data.get('groupby')
metric = self.form_data.get('metric')
secondary_metric = self.form_data.get('secondary_metric')
if metric == secondary_metric:
ndf = df[cols]
ndf['m1'] = df[metric]
ndf['m2'] = df[metric]
else:
cols += [
self.form_data['metric'], self.form_data['secondary_metric']]
ndf = df[cols]
return ndf.to_json(orient="values")

def query_obj(self):
qry = super(SunburstViz, self).query_obj()
Expand Down

0 comments on commit c3f9607

Please sign in to comment.