Skip to content

Commit

Permalink
Bugfix for time series bar chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Oct 16, 2015
1 parent 9605962 commit 9d61ee2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
11 changes: 10 additions & 1 deletion panoramix/static/widgets/viz_nvd3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function viz_nvd3(data_attribute) {

var token_name = data_attribute['token'];
var json_callback = data_attribute['json_endpoint'];

Expand Down Expand Up @@ -58,6 +57,15 @@ function viz_nvd3(data_attribute) {
chart.y2Axis.tickFormat(d3.format('.3p'));
}
}
} else if (viz_type === 'bar') {
var chart = nv.models.multiBarChart()
.showControls(true)
.groupSpacing(0.1);
chart.xAxis
.showMaxMin(false)
.tickFormat(function (d) {return tickMultiFormat(UTC(new Date(d))); });
chart.showLegend(viz.form_data.show_legend);
chart.yAxis.tickFormat(d3.format('.3s'));

} else if (viz_type === 'dist_bar') {
var chart = nv.models.multiBarChart()
Expand Down Expand Up @@ -152,6 +160,7 @@ function viz_nvd3(data_attribute) {

[
'area',
'bar',
'bubble',
'column',
'compare',
Expand Down
3 changes: 3 additions & 0 deletions panoramix/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,11 @@ def datasource(self, datasource_type, datasource_id):
action = request.args.get('action')
if action == 'save':
session = db.session()

# TODO use form processing form wtforms
d = request.args.to_dict(flat=False)
del d['action']
del d['previous_viz_type']
as_list = ('metrics', 'groupby')
for k in d:
v = d.get(k)
Expand Down
10 changes: 6 additions & 4 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, datasource, form_data):
self.request = request
self.viz_type = form_data.get("viz_type")

# TODO refactor all form related logic out of here and into forms.py
ff = FormFactory(self)
form_class = ff.get_form()
defaults = form_class().data.copy()
Expand All @@ -52,10 +53,11 @@ def __init__(self, datasource, form_data):
for k, v in form.errors.items():
if not data.get('json') and not data.get('async'):
flash("{}: {}".format(k, " ".join(v)), 'danger')
data = {
k: form.data[k]
for k in form_data.keys()
if k in form.data}
if previous_viz_type != self.viz_type:
data = {
k: form.data[k]
for k in form_data.keys()
if k in form.data}
defaults.update(data)
self.form_data = defaults

Expand Down

0 comments on commit 9d61ee2

Please sign in to comment.