diff --git a/caravel/views.py b/caravel/views.py index aea86169c7b..ec25b2d9406 100644 --- a/caravel/views.py +++ b/caravel/views.py @@ -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, diff --git a/caravel/viz.py b/caravel/viz.py index 6cc0523931d..ed5d7419f48 100644 --- a/caravel/viz.py +++ b/caravel/viz.py @@ -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