diff --git a/caravel/assets/visualizations/mapbox.jsx b/caravel/assets/visualizations/mapbox.jsx index 97281e9a0decb..75a6909f81ce3 100644 --- a/caravel/assets/visualizations/mapbox.jsx +++ b/caravel/assets/visualizations/mapbox.jsx @@ -137,12 +137,13 @@ class ScatterPlotGlowOverlay extends ScatterPlotOverlay { let pointLabel; if (radiusProperty !== null) { + const pointLatitude = props.lngLatAccessor(location)[1]; if (props.pointRadiusUnit === 'Kilometers') { pointLabel = d3.round(pointRadius, 2) + 'km'; - pointRadius = kmToPixels(pointRadius, props.latitude, props.zoom); + pointRadius = kmToPixels(pointRadius, pointLatitude, props.zoom); } else if (props.pointRadiusUnit === 'Miles') { pointLabel = d3.round(pointRadius, 2) + 'mi'; - pointRadius = kmToPixels(pointRadius * MILES_PER_KM, props.latitude, props.zoom); + pointRadius = kmToPixels(pointRadius * MILES_PER_KM, pointLatitude, props.zoom); } } diff --git a/caravel/assets/visualizations/nvd3_vis.js b/caravel/assets/visualizations/nvd3_vis.js index 7a6074034629f..b7512e7349129 100644 --- a/caravel/assets/visualizations/nvd3_vis.js +++ b/caravel/assets/visualizations/nvd3_vis.js @@ -117,9 +117,10 @@ function nvd3Vis(slice) { chart.valueFormat(f); if (fd.donut) { chart.donut(true); - chart.labelsOutside(true); } - chart.labelsOutside(true); + chart.labelsOutside(fd.labels_outside); + chart.labelThreshold(0.05) //Configure the minimum slice size for labels to show up + .labelType(fd.pie_label_type); chart.cornerRadius(true); break; diff --git a/caravel/bin/caravel b/caravel/bin/caravel index 8c560f934cdf8..3ae2b68516da3 100755 --- a/caravel/bin/caravel +++ b/caravel/bin/caravel @@ -24,6 +24,9 @@ manager.add_command('db', MigrateCommand) @manager.option( '-d', '--debug', action='store_true', help="Start the web server in debug mode") +@manager.option( + '-a', '--address', default=config.get("CARAVEL_WEBSERVER_ADDRESS"), + help="Specify the address to which to bind the web server") @manager.option( '-p', '--port', default=config.get("CARAVEL_WEBSERVER_PORT"), help="Specify the port on which to run the web server") @@ -33,7 +36,7 @@ manager.add_command('db', MigrateCommand) @manager.option( '-t', '--timeout', default=config.get("CARAVEL_WEBSERVER_TIMEOUT"), help="Specify the timeout (seconds) for the gunicorn web server") -def runserver(debug, port, timeout, workers): +def runserver(debug, address, port, timeout, workers): """Starts a Caravel web server""" debug = debug or config.get("DEBUG") if debug: @@ -46,7 +49,7 @@ def runserver(debug, port, timeout, workers): "gunicorn " "-w {workers} " "--timeout {timeout} " - "-b 0.0.0.0:{port} " + "-b {address}:{port} " "--limit-request-line 0 " "--limit-request-field_size 0 " "caravel:app").format(**locals()) diff --git a/caravel/config.py b/caravel/config.py index d8d12e3ad0848..3780ca787a21b 100644 --- a/caravel/config.py +++ b/caravel/config.py @@ -23,6 +23,7 @@ ROW_LIMIT = 50000 CARAVEL_WORKERS = 16 +CARAVEL_WEBSERVER_ADDRESS = '0.0.0.0' CARAVEL_WEBSERVER_PORT = 8088 CARAVEL_WEBSERVER_TIMEOUT = 60 diff --git a/caravel/forms.py b/caravel/forms.py index cb45d21df8bd4..6499747b7c679 100755 --- a/caravel/forms.py +++ b/caravel/forms.py @@ -695,6 +695,16 @@ def __init__(self, viz): "default": 'linear', "description": _("Line interpolation as defined by d3.js") }), + 'pie_label_type': (SelectField, { + "label": _("Label Type"), + "default": 'key', + "choices": ( + ('key', _("Category Name")), + ('value', _("Value")), + ('percent', _("Percentage")), + ), + "description": _("What should be shown on the label?") + }), 'code': (TextAreaField, { "label": _("Code"), "description": _("Put your code here"), @@ -789,6 +799,11 @@ def __init__(self, viz): "default": False, "description": _("Do you want a donut or a pie?") }), + 'labels_outside': (BetterBooleanField, { + "label": _("Put labels outside"), + "default": True, + "description": _("Put the labels outside the pie?") + }), 'contribution': (BetterBooleanField, { "label": _("Contribution"), "default": False, diff --git a/caravel/views.py b/caravel/views.py index 41ef2c883a6c0..a1dfb3fe19218 100755 --- a/caravel/views.py +++ b/caravel/views.py @@ -910,7 +910,7 @@ def save_or_overwrite_slice( del d['action'] del d['previous_viz_type'] - as_list = ('metrics', 'groupby', 'columns', 'all_columns', 'mapbox_label') + as_list = ('metrics', 'groupby', 'columns', 'all_columns', 'mapbox_label', 'order_by_cols') for k in d: v = d.get(k) if k in as_list and not isinstance(v, list): diff --git a/caravel/viz.py b/caravel/viz.py index 28ef014d6d829..64c5a73f9b850 100755 --- a/caravel/viz.py +++ b/caravel/viz.py @@ -1175,7 +1175,9 @@ class DistributionPieViz(NVD3Viz): 'fields': ( 'metrics', 'groupby', 'limit', + 'pie_label_type', ('donut', 'show_legend'), + 'labels_outside', ) },)