Skip to content

Commit

Permalink
Bugfix in line chart where the series name is an empty string (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed May 5, 2016
1 parent 82fa501 commit d304ee0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
16 changes: 9 additions & 7 deletions caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,16 @@ def explore(self, datasource_type, datasource_id):
return redirect(error_redirect)
if request.args.get("json") == "true":
status = 200
try:
if config.get("DEBUG"):
# Allows for nice debugger stack traces in debug mode
payload = obj.get_json()
except Exception as e:
logging.exception(e)
if config.get("DEBUG"):
raise e
payload = str(e)
status = 500
else:
try:
payload = obj.get_json()
except Exception as e:
logging.exception(e)
payload = str(e)
status = 500
resp = Response(
payload,
status=status,
Expand Down
14 changes: 13 additions & 1 deletion caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,15 @@ def get_df(self, query_obj=None):
return df

def to_series(self, df, classed='', title_suffix=''):
cols = []
for col in df.columns:
if col == '':
cols.append('N/A')
elif col == None:
cols.append('NULL')
else:
cols.append(col)
df.columns = cols
series = df.to_dict('series')

chart_data = []
Expand All @@ -931,7 +940,10 @@ def to_series(self, df, classed='', title_suffix=''):
d = {
"key": series_title,
"classed": classed,
"values": [{'x': ds, 'y': ys[ds]} for ds in df.timestamp],
"values": [
{'x': ds, 'y': ys[ds] if ds in ys else None}
for ds in df.timestamp
],
}
chart_data.append(d)
return chart_data
Expand Down

0 comments on commit d304ee0

Please sign in to comment.