Skip to content

Commit

Permalink
Fixing the word bad assumptions about field ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 11, 2016
1 parent 4aa70d0 commit ed96f9b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion panoramix/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 5 additions & 7 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class WordCloudViz(BaseViz):
'fields': (
'granularity',
('since', 'until'),
'groupby', 'metric', 'limit',
'series', 'metric', 'limit',
('size_from', 'size_to'),
'rotation',
)
Expand All @@ -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")

Expand Down

0 comments on commit ed96f9b

Please sign in to comment.