From c3f96074b95d7030e9cd142964d91ac9da7597fa Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Wed, 9 Dec 2015 18:11:45 -0800 Subject: [PATCH] Insuring column order --- panoramix/viz.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/panoramix/viz.py b/panoramix/viz.py index 0ac7b9311..082c85f1e 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -840,10 +840,20 @@ class SunburstViz(BaseViz): 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()