Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Oct 1, 2015
1 parent 96753cf commit fa08d35
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
16 changes: 12 additions & 4 deletions panoramix/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def __init__(self, viz):
from panoramix.viz import viz_types
viz = self.viz
datasource = viz.datasource
default_metric = datasource.metrics_combo[0][0]
default_groupby = datasource.groupby_column_names[0]
group_by_choices = [(s, s) for s in datasource.groupby_column_names]
# Pool of all the fields that can be used in Panoramix
self.field_dict = {
Expand All @@ -48,11 +50,11 @@ def __init__(self, viz):
description="The type of visualization to display"),
'metrics': SelectMultipleField(
'Metrics', choices=datasource.metrics_combo,
default=[datasource.metrics_combo[0][0]],
default=[default_metric],
description="One or many metrics to display"),
'metric': SelectField(
'Metric', choices=datasource.metrics_combo,
default='',
default=default_metric,
description="One or many metrics to display"),
'groupby': SelectMultipleField(
'Group by',
Expand Down Expand Up @@ -90,18 +92,25 @@ def __init__(self, viz):
"relative to the 'granularity' field")),
'series': SelectField(
'Series', choices=group_by_choices,
default=default_groupby,
description=(
"Defines the grouping of entities. "
"Each serie is shown as a specific color on the chart and "
"has a legend toggle")),
'entity': SelectField('Entity', choices=group_by_choices,
default=default_groupby,
description="This define the element to be plotted on the chart"),
'x': SelectField(
'X Axis', choices=datasource.metrics_combo,
default=default_metric,
description="Metric assigned to the [X] axis"),
'y': SelectField('Y Axis', choices=datasource.metrics_combo,
default=default_metric,
description="Metric assigned to the [Y] axis"),
'size': SelectField('Bubble Size', choices=datasource.metrics_combo),
'size': SelectField(
'Bubble Size',
default=default_metric,
choices=datasource.metrics_combo),
'where': TextField('Custom WHERE clause', default=''),
'compare_lag': TextField('Comparison Period Lag',
description="Based on granularity, number of time periods to compare against"),
Expand Down Expand Up @@ -183,7 +192,6 @@ class QueryForm(OmgWtForm):
async = HiddenField()
json = HiddenField()
previous_viz_type = HiddenField()
standalone = HiddenField()


for i in range(10):
Expand Down
13 changes: 9 additions & 4 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def reassignments(self):
pass

def get_url(self, **kwargs):
d = self.form_data.copy()
d = self.orig_form_data.copy()
if 'action' in d:
del d['action']
d.update(kwargs)
Expand Down Expand Up @@ -285,6 +285,7 @@ def query_obj(self):
self.z_metric = form_data.get('size')
self.entity = form_data.get('entity')
self.series = form_data.get('series')

d['metrics'] = [
self.z_metric,
self.x_metric,
Expand All @@ -309,13 +310,17 @@ def get_json_data(self):
series = defaultdict(list)
for row in df.to_dict(orient='records'):
series[row['group']].append(row)
data = []
chart_data = []
for k, v in series.items():
data.append({
chart_data.append({
'key': k,
"color": utils.color(k),
'values': v })
return json.dumps(data)
return dumps({
'chart_data': chart_data,
'query': self.results.query,
'duration': self.results.duration,
})

class BigNumberViz(BaseViz):
verbose_name = "Big Number"
Expand Down

0 comments on commit fa08d35

Please sign in to comment.