Skip to content

Commit

Permalink
Chart bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 12, 2015
1 parent 9e4c532 commit 9c10e12
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions airflow/www/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,16 @@ def chart_data(self):

if not payload['error'] and len(df) == 0:
payload['error'] += "Empty result set. "
elif not payload['error'] and len(df.columns) < 3:
elif (
not payload['error'] and
chart.sql_layout == 'series' and
len(df.columns) < 3):
payload['error'] += "SQL needs to return at least 3 columns. "
elif (
not payload['error'] and
chart.sql_layout == 'columns' and
len(df.columns) < 2):
payload['error'] += "SQL needs to return at least 2 columns. "
elif not payload['error']:
import numpy as np

Expand Down Expand Up @@ -353,7 +361,7 @@ def chart_data(self):
xaxis_label = df.columns[0]
yaxis_label = 'y'
df.index = df[df.columns[0]]
df = df.sort('ds')
df = df.sort(df.columns[0])
del df[df.columns[0]]
for col in df.columns:
df[col] = df[col].astype(np.float)
Expand Down Expand Up @@ -1150,7 +1158,7 @@ class ChartModelView(LoginMixin, ModelView):
}

def on_model_change(self, form, model, is_created=True):
if not model.iteration_no:
if model.iteration_no is None:
model.iteration_no = 0
else:
model.iteration_no += 1
Expand Down

0 comments on commit 9c10e12

Please sign in to comment.