-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Introducing choroplethmapbox traces #3988
Conversation
- valid choropleth datum must have a valid location AND `z` value - set calcdata[i][j].index during calc so that choroplethmapbox can use it in its convert.js
... and update choropleth baselines that didn't show the "correct" default "black"
for geo AND mapbox base plot modules ... that way we do this only once when geo and mapbox modules are registered
- reusing choropleth calc, hover, select, eventData and feature2polygon - use `PlotlyGeoAssets` to stash fetched geojson url data - use two layers, one fill (to filled choropleth polygon), one line to draw `marker.line` styles - add mockAxis on mapbox subplot instances, used to format choroplethmapbox 'z' on hover
... similar to how we do things on geo subplots
- use _rehover wrapper similar to cartesian subplots and call it on moveend - split fx init code into prototype.initFx
- where by default chroroplethmapbox traces are placed above the top most "water" layer - N.B. we need to remove/add again layers when *below* is updated
moduleType: 'trace', | ||
name: 'choroplethmapbox', | ||
basePlotModule: require('../../plots/mapbox'), | ||
categories: ['mapbox', 'gl', 'noOpacity'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on the road, it may be of interest to have traces with opacity. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opacity
here for choroplethmapbox
traces would be equivalent to marker.opacity
, so we don't need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about dimming marker.lines? Trace opacity may be handy for adjusting both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but I'm not going to do this now for consistency with choropleth
:
plotly.js/src/traces/choropleth/index.js
Line 26 in cb202a8
categories: ['geo', 'noOpacity'], |
- move isNonBlankString in outer scope - add "" around URL in invalid-url error msg
... when marker.line.width===0
Introducing densitymapbox traces
Is everyone subscribed to this PR ok with the behavior? |
No news, good news I guess. Merging this PR into #3987 to have all 1.49.0 mapbox items in one place |
Based off #3987
This PR adds a new mapbox-based trace type:
choroplethmapbox
๐ ๐บ๏ธ ๐ฐ๏ธExample: https://codepen.io/etpinard/pen/orGQNe
In brief,
choroplethmapbox
traces have a very similar API as their geo-subplot cousinchoropleth
. Both uselocations
andz
to set the polygon-to-color mapping. But unlikechoropleth
,choroplethmapbox
traces (currently) must be set with ageojson
attribute that contains polygon coordinates.Note that, this PR also fixes a
choropleth
bug in 91e0319 - where we didn't use the correctmarker.line.color
default.Things that work
geojson
can be set either as URL string or{ }
GeoJSON object. We accept GeoJSONs of typeFeature
andFeatureCollection
and geometries of typePolygon
andMultiPolygon
.choropleth
choropleth
logic, where the polygons' centroid is used.properties
fields are accessible inhovertemplate
(example)Things worthy of discussion
below
default.below
(like inmapbox.layers
) sets theid
of the layer just below where thechoroplethmapbox
trace will be plotted. I tentatively chose the layer just above the last "water" layer. That is,choroplethmapbox
traces are plotted below roads and labels by default.below
, we could plotchoroplethmapbox
traces above all background layers (but belowscattermapbox
traces) and have a defaultmarker.opacity
of e.g. 0.7?Things that we could add
locationmode
. The current behavior would correspond tolocationmode: 'geojson-id'
. Some users might expect to identify GeoJSON features using theirproperties.name
(this would correspond to e.g.locationmode: 'geojson-prop-name'
. Moreover, we could also support thelocationmode
values found in geo traces:'ISO-3', 'USA-states', 'country names'
zkey
attribute as an alternative to thez
array. For example,zkey: 'value'
would read off theproperties.value
values in the GeoJSON set bygeojson
cc @plotly/plotly_js @nicolaskruchten @chriddyp