Bugfix in line chart where the series name is an empty string (#434)

This commit is contained in:
Maxime Beauchemin
2016-05-05 12:19:51 -07:00
parent 82fa501dea
commit d304ee005a
2 changed files with 22 additions and 8 deletions

View File

@@ -551,14 +551,16 @@ class Caravel(BaseView):
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,

View File

@@ -909,6 +909,15 @@ class NVD3TimeSeriesViz(NVD3Viz):
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 = []
@@ -931,7 +940,10 @@ class NVD3TimeSeriesViz(NVD3Viz):
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