diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14f0b0aa9c4..03f6ecb575c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
+## [2.5.0] - UNRELEASED
+### Updated
+- `plotly.figure_factory.create_choropleth` has changed some of the default plotting options:
+ - 'offline_mode' param has been removed from call signature
+ - persistent selection api for the centroid points is automatically enabled. See https://plot.ly/python/reference/#scatter-selected and https://plot.ly/python/reference/#scatter-unselected for details
+ - FIPS values that appear on hover are 0-padded to ensure they are 5 digits
+ - for the county lines data `hover_info='none'` by default
+
## [2.4.1] - 2018-02-21
### Fixed
- The required shapefiles to generate the choropleths via `plotly.figure_factory.create_choropleth` are now shipped in the package data.
diff --git a/circle.yml b/circle.yml
index 0703e482f2c..28413b9b886 100644
--- a/circle.yml
+++ b/circle.yml
@@ -12,7 +12,7 @@ machine:
node:
# use a pre-installed version of node so we don't need to download it.
- version: 4.2.2
+ version: 6.0.0
dependencies:
diff --git a/plotly/figure_factory/_county_choropleth.py b/plotly/figure_factory/_county_choropleth.py
index cb542064dda..cc70eeb9fe7 100644
--- a/plotly/figure_factory/_county_choropleth.py
+++ b/plotly/figure_factory/_county_choropleth.py
@@ -300,6 +300,8 @@ def _intervals_as_labels(array_of_intervals, round_legend_values, exponent_forma
def _calculations(df, fips, values, index, f, simplify_county, level,
x_centroids, y_centroids, centroid_text, x_traces,
y_traces, fips_polygon_map):
+ # 0-pad FIPS code to ensure exactly 5 digits
+ padded_f = str(f).zfill(5)
if fips_polygon_map[f].type == 'Polygon':
x = fips_polygon_map[f].simplify(
simplify_county
@@ -311,10 +313,11 @@ def _calculations(df, fips, values, index, f, simplify_county, level,
x_c, y_c = fips_polygon_map[f].centroid.xy
county_name_str = str(df[df['FIPS'] == f]['COUNTY_NAME'].iloc[0])
state_name_str = str(df[df['FIPS'] == f]['STATE_NAME'].iloc[0])
+
t_c = (
'County: ' + county_name_str + '
' +
'State: ' + state_name_str + '
' +
- 'FIPS: ' + str(f) + '
Value: ' + str(values[index])
+ 'FIPS: ' + padded_f + '
Value: ' + str(values[index])
)
x_centroids.append(x_c[0])
@@ -337,7 +340,7 @@ def _calculations(df, fips, values, index, f, simplify_county, level,
text = (
'County: ' + county_name_str + '
' +
'State: ' + state_name_str + '
' +
- 'FIPS: ' + str(f) + '
Value: ' + str(values[index])
+ 'FIPS: ' + padded_f + '
Value: ' + str(values[index])
)
t_c = [text for poly in fips_polygon_map[f]]
x_centroids = x_c + x_centroids
@@ -352,12 +355,11 @@ def _calculations(df, fips, values, index, f, simplify_county, level,
def create_choropleth(fips, values, scope=['usa'], binning_endpoints=None,
colorscale=None, order=None, simplify_county=0.02,
- simplify_state=0.02, asp=None, offline_mode=False,
- show_hover=True, show_state_data=True,
- state_outline=None, county_outline=None,
- centroid_marker=None, round_legend_values=False,
- exponent_format=False, legend_title='',
- **layout_options):
+ simplify_state=0.02, asp=None, show_hover=True,
+ show_state_data=True, state_outline=None,
+ county_outline=None, centroid_marker=None,
+ round_legend_values=False, exponent_format=False,
+ legend_title='', **layout_options):
"""
Returns figure for county choropleth. Uses data from package_data.
@@ -399,12 +401,6 @@ def create_choropleth(fips, values, scope=['usa'], binning_endpoints=None,
Default = 0.02
:param (float) asp: the width-to-height aspect ratio for the camera.
Default = 2.5
- :param (bool) offline_mode: if set to True, the centroids of each county
- are invisible until selected over with a dragbox. Warning: this can
- only be used if you are plotting in offline mode with validate set to
- False as the params that are being added to the fig dictionary are not
- yet part of the plotly.py python library. Stay tuned for updates.
- Default = False
:param (bool) show_hover: show county hover and centroid info
:param (bool) show_state_data: reveals state boundary lines
:param (dict) state_outline: dict of attributes of the state outline
@@ -416,8 +412,9 @@ def create_choropleth(fips, values, scope=['usa'], binning_endpoints=None,
https://plot.ly/python/reference/#scatter-marker-line for all valid
params
:param (dict) centroid_marker: dict of attributes of the centroid marker.
- See https://plot.ly/python/reference/#scatter-marker for all valid
- params
+ The centroid markers are invisible by default and appear visible on
+ selection. See https://plot.ly/python/reference/#scatter-marker for
+ all valid params
:param (bool) round_legend_values: automatically round the numbers that
appear in the legend to the nearest integer.
Default = False
@@ -587,9 +584,11 @@ def create_choropleth(fips, values, scope=['usa'], binning_endpoints=None,
county_outline = {'color': 'rgb(0, 0, 0)',
'width': 0}
if not centroid_marker:
- centroid_marker = {'size': 2,
- 'color': 'rgb(255, 255, 255)',
- 'opacity': 0}
+ centroid_marker = {'size': 3, 'color': 'white', 'opacity': 1}
+
+ # ensure centroid markers appear on selection
+ if 'opacity' not in centroid_marker:
+ centroid_marker.update({'opacity': 1})
if len(fips) != len(values):
raise exceptions.PlotlyError(
@@ -788,7 +787,7 @@ def create_choropleth(fips, values, scope=['usa'], binning_endpoints=None,
fill='toself',
fillcolor=color_lookup[lev],
name=lev,
- hoverinfo='text',
+ hoverinfo='none',
)
plot_data.append(county_data)
@@ -802,19 +801,14 @@ def create_choropleth(fips, values, scope=['usa'], binning_endpoints=None,
text=centroid_text,
name='US Counties',
mode='markers',
- marker=centroid_marker,
+ marker={'color': 'white', 'opacity': 0},
hoverinfo='text'
)
- if offline_mode:
- centroids_on_select = dict(
- selected=dict(
- marker=dict(size=2, color='white', opacity=1)
- ),
- unselected=dict(
- marker=dict(opacity=0)
- )
- )
- hover_points.update(centroids_on_select)
+ centroids_on_select = dict(
+ selected=dict(marker=centroid_marker),
+ unselected=dict(marker=dict(opacity=0))
+ )
+ hover_points.update(centroids_on_select)
plot_data.append(hover_points)
if show_state_data:
diff --git a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_county_500k/cb_2016_us_county_500k.dbf b/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_county_500k/cb_2016_us_county_500k.dbf
deleted file mode 100644
index 1ef3b1499fe..00000000000
Binary files a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_county_500k/cb_2016_us_county_500k.dbf and /dev/null differ
diff --git a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_county_500k/cb_2016_us_county_500k.shp b/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_county_500k/cb_2016_us_county_500k.shp
deleted file mode 100644
index 45b3f041f32..00000000000
Binary files a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_county_500k/cb_2016_us_county_500k.shp and /dev/null differ
diff --git a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_county_500k/cb_2016_us_county_500k.shx b/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_county_500k/cb_2016_us_county_500k.shx
deleted file mode 100644
index 715e770c755..00000000000
Binary files a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_county_500k/cb_2016_us_county_500k.shx and /dev/null differ
diff --git a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_state_500k/cb_2016_us_state_500k.dbf b/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_state_500k/cb_2016_us_state_500k.dbf
deleted file mode 100755
index c3e3b13e212..00000000000
Binary files a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_state_500k/cb_2016_us_state_500k.dbf and /dev/null differ
diff --git a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_state_500k/cb_2016_us_state_500k.shp b/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_state_500k/cb_2016_us_state_500k.shp
deleted file mode 100755
index f2a32cd6a2f..00000000000
Binary files a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_state_500k/cb_2016_us_state_500k.shp and /dev/null differ
diff --git a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_state_500k/cb_2016_us_state_500k.shx b/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_state_500k/cb_2016_us_state_500k.shx
deleted file mode 100755
index 95347eb02db..00000000000
Binary files a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/cb_2016_us_state_500k/cb_2016_us_state_500k.shx and /dev/null differ
diff --git a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/gz_2010_us_050_00_500k/gz_2010_us_050_00_500k.dbf b/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/gz_2010_us_050_00_500k/gz_2010_us_050_00_500k.dbf
deleted file mode 100755
index 8397f541eca..00000000000
Binary files a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/gz_2010_us_050_00_500k/gz_2010_us_050_00_500k.dbf and /dev/null differ
diff --git a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/gz_2010_us_050_00_500k/gz_2010_us_050_00_500k.shp b/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/gz_2010_us_050_00_500k/gz_2010_us_050_00_500k.shp
deleted file mode 100755
index a1177e7b3ca..00000000000
Binary files a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/gz_2010_us_050_00_500k/gz_2010_us_050_00_500k.shp and /dev/null differ
diff --git a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/gz_2010_us_050_00_500k/gz_2010_us_050_00_500k.shx b/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/gz_2010_us_050_00_500k/gz_2010_us_050_00_500k.shx
deleted file mode 100755
index 85675d9254e..00000000000
Binary files a/plotly/tests/test_optional/test_figure_factory/plotly/package_data/data/gz_2010_us_050_00_500k/gz_2010_us_050_00_500k.shx and /dev/null differ
diff --git a/plotly/version.py b/plotly/version.py
index 5cd7abf832e..e59b17b4f4c 100644
--- a/plotly/version.py
+++ b/plotly/version.py
@@ -1 +1 @@
-__version__ = '2.4.1'
+__version__ = '2.5.0'