Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom choropleth border opacity #157

Merged
merged 1 commit into from
Jun 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/viz.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ viz.show()
The `ChoroplethViz` object handles the creation of a choropleth map and inherits from the `MapViz` class. It applies a thematic map style to polygon features with color shading in proportion to the intensity of the data being displayed. Choropleth polygons can be initialized with geojson source or vector source styled using the data-join technique.

### Params
**ChoroplethViz**(_data, color_property=None, color_stops=None, color_default='grey', color_function_type='interpolate', line_color='white', line_stroke='solid', line_width=1, height_property=None, height_stops=None, height_default=0.0, height_function_type='interpolate', \*args, \*\*kwargs_)
**ChoroplethViz**(_data, color_property=None, color_stops=None, color_default='grey', color_function_type='interpolate', line_color='white', line_stroke='solid', line_width=1, line_opacity=1, height_property=None, height_stops=None, height_default=0.0, height_function_type='interpolate', \*args, \*\*kwargs_)

Parameter | Description | Example
--|--|--
Expand All @@ -373,6 +373,7 @@ color_function_type | property to determine type of expression used by Mapbox to
line_color | property to determine choropleth border line color | '#FFFFFF'
line_stroke | property to determine choropleth border line stroke (one of solid (-), dashed (--), dotted (:), dash dot (-.)) | 'solid' or '-'
line_width | property to determine choropleth border line width | 1
line_opacity | opacity of choropleth line layer | 1
height_property | feature property for determining polygon height in 3D extruded choropleth map | 'density'
height_stops | property for determining 3D extrusion height | [[0, 0], [500, 50000], [1500, 150000]]
height_default | default height (in meters) for 3D extruded polygons on map | 1500.0
Expand All @@ -397,6 +398,7 @@ viz = ChoroplethViz('us-states.geojson',
line_stroke='--',
line_color='rgb(128,0,38)',
line_width=1,
line_opacity=0.9,
opacity=0.8,
center=(-96, 37.8),
zoom=3,
Expand Down
1 change: 1 addition & 0 deletions examples/notebooks/choropleth-viz-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
" line_stroke='--',\n",
" line_color='rgb(128,0,38)',\n",
" line_width=1,\n",
" line_opacity=0.9,\n",
" opacity=0.8,\n",
" center=(-96, 37.8),\n",
" zoom=3,\n",
Expand Down
2 changes: 1 addition & 1 deletion mapboxgl/templates/choropleth.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"{{ highlightColor }}",
"{{ lineColor }}"],
"line-width": {{ lineWidth }},
"line-opacity": {{ opacity }}
"line-opacity": {{ lineOpacity }}
}
}, "{{ belowLayer }}" );

Expand Down
2 changes: 1 addition & 1 deletion mapboxgl/templates/vector_choropleth.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"{{ highlightColor }}",
"{{ lineColor }}"],
"line-width": {{ lineWidth }},
"line-opacity": {{ opacity }}
"line-opacity": {{ lineOpacity }}
}
{% if enableDataJoin %}
, "filter": layerFilter
Expand Down
4 changes: 4 additions & 0 deletions mapboxgl/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ def __init__(self,
line_color='white',
line_stroke='solid',
line_width=1,
line_opacity=1,
height_property=None,
height_stops=None,
height_default=0.0,
Expand All @@ -654,6 +655,7 @@ def __init__(self,
:param line_color: property to determine choropleth line color
:param line_stroke: property to determine choropleth line stroke (solid, dashed, dotted, dash dot)
:param line_width: property to determine choropleth line width
:param line_opacity: opacity of choropleth line layer
:param height_property: feature property for determining polygon height in 3D extruded choropleth map
:param height_stops: property for determining 3D extrusion height
:param height_default: default height for 3D extruded polygons
Expand All @@ -672,6 +674,7 @@ def __init__(self,
self.line_color = line_color
self.line_stroke = line_stroke
self.line_width = line_width
self.line_opacity = line_opacity
self.height_property = height_property
self.height_stops = height_stops
self.height_default = height_default
Expand Down Expand Up @@ -708,6 +711,7 @@ def add_unique_template_variables(self, options):
lineDashArray=self.line_dash_array,
lineStroke=self.line_stroke,
lineWidth=self.line_width,
lineOpacity=self.line_opacity,
extrudeChoropleth=self.extrude,
highlightColor=self.highlight_color
))
Expand Down