From ed96f9b92fa052909f12612a5ff1ceb86fe5afb8 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 11 Jan 2016 15:27:00 -0800 Subject: [PATCH] Fixing the word bad assumptions about field ordering --- panoramix/data/__init__.py | 2 +- panoramix/models.py | 3 +++ panoramix/viz.py | 12 +++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/panoramix/data/__init__.py b/panoramix/data/__init__.py index 13fc9cdbcc5e6..b472b42f52aab 100644 --- a/panoramix/data/__init__.py +++ b/panoramix/data/__init__.py @@ -259,7 +259,7 @@ def get_slice_json(slice_name, **kwargs): table=tbl, params=get_slice_json( slice_name, viz_type="word_cloud", size_from="10", - groupby=['name'], size_to="70", rotation="square", + series='name', size_to="70", rotation="square", limit='100')) session.add(slc) slices.append(slc) diff --git a/panoramix/models.py b/panoramix/models.py index 76a6ae533be75..fcc05c859b0bb 100644 --- a/panoramix/models.py +++ b/panoramix/models.py @@ -917,6 +917,9 @@ def query( query_str += json.dumps(client.query_dict, indent=2) df = client.export_pandas() + if not is_timeseries and 'timestamp' in df.columns: + del df['timestamp'] + # Reordering columns cols = [] if 'timestamp' in df.columns: diff --git a/panoramix/viz.py b/panoramix/viz.py index 93d98dc68380c..6fad20b3e06b9 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -432,7 +432,7 @@ class WordCloudViz(BaseViz): 'fields': ( 'granularity', ('since', 'until'), - 'groupby', 'metric', 'limit', + 'series', 'metric', 'limit', ('size_from', 'size_to'), 'rotation', ) @@ -445,18 +445,16 @@ class WordCloudViz(BaseViz): def query_obj(self): d = super(WordCloudViz, self).query_obj() - if len(d['groupby']) < 1: - raise Exception("Pick at least one field to group by") - metric = self.form_data.get('metric') - if not metric: - raise Exception("Pick a metric!") d['metrics'] = [self.form_data.get('metric')] - d['groupby'] = [d['groupby'][0]] + d['groupby'] = [self.form_data.get('series')] return d def get_json_data(self): df = self.get_df() + # Ordering the columns + df = df[[self.form_data.get('series'), self.form_data.get('metric')]] + # Labeling the columns for uniform json schema df.columns = ['text', 'size'] return df.to_json(orient="records")