Skip to content

Commit d304ee0

Browse files
committed
Bugfix in line chart where the series name is an empty string (#434)
1 parent 82fa501 commit d304ee0

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

caravel/views.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,16 @@ def explore(self, datasource_type, datasource_id):
551551
return redirect(error_redirect)
552552
if request.args.get("json") == "true":
553553
status = 200
554-
try:
554+
if config.get("DEBUG"):
555+
# Allows for nice debugger stack traces in debug mode
555556
payload = obj.get_json()
556-
except Exception as e:
557-
logging.exception(e)
558-
if config.get("DEBUG"):
559-
raise e
560-
payload = str(e)
561-
status = 500
557+
else:
558+
try:
559+
payload = obj.get_json()
560+
except Exception as e:
561+
logging.exception(e)
562+
payload = str(e)
563+
status = 500
562564
resp = Response(
563565
payload,
564566
status=status,

caravel/viz.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,15 @@ def get_df(self, query_obj=None):
909909
return df
910910

911911
def to_series(self, df, classed='', title_suffix=''):
912+
cols = []
913+
for col in df.columns:
914+
if col == '':
915+
cols.append('N/A')
916+
elif col == None:
917+
cols.append('NULL')
918+
else:
919+
cols.append(col)
920+
df.columns = cols
912921
series = df.to_dict('series')
913922

914923
chart_data = []
@@ -931,7 +940,10 @@ def to_series(self, df, classed='', title_suffix=''):
931940
d = {
932941
"key": series_title,
933942
"classed": classed,
934-
"values": [{'x': ds, 'y': ys[ds]} for ds in df.timestamp],
943+
"values": [
944+
{'x': ds, 'y': ys[ds] if ds in ys else None}
945+
for ds in df.timestamp
946+
],
935947
}
936948
chart_data.append(d)
937949
return chart_data

0 commit comments

Comments
 (0)