Skip to content

Commit

Permalink
Merge branch 'master' into nullcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
kkalyan authored Jul 29, 2016
2 parents ab95f72 + 299e31f commit a8a91ec
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 deletions.
5 changes: 3 additions & 2 deletions caravel/assets/visualizations/mapbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
5 changes: 3 additions & 2 deletions caravel/assets/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 5 additions & 2 deletions caravel/bin/caravel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand All @@ -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())
Expand Down
1 change: 1 addition & 0 deletions caravel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions caravel/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions caravel/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,9 @@ class DistributionPieViz(NVD3Viz):
'fields': (
'metrics', 'groupby',
'limit',
'pie_label_type',
('donut', 'show_legend'),
'labels_outside',
)
},)

Expand Down

0 comments on commit a8a91ec

Please sign in to comment.