Skip to content

Commit 6e0ce80

Browse files
committed
update tile choropleth
1 parent 1463bf2 commit 6e0ce80

File tree

5 files changed

+48
-29
lines changed

5 files changed

+48
-29
lines changed
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
name: Dark tile, Needs Token
2+
name: Dark tile
33
language: plotly_js
4-
suite: mapbox-county-choropleth
4+
suite: tile-county-choropleth
55
order: 3
66
sitemap: false
77
arrangement: horizontal
@@ -10,13 +10,11 @@
1010
---
1111

1212
var data = [{
13-
type: "choroplethmapbox", name: "US states", geojson: "https://raw.githubusercontent.com/python-visualization/folium/master/examples/data/us-states.json", locations: [ "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" ],
13+
type: "choroplethmap", name: "US states", geojson: "https://raw.githubusercontent.com/python-visualization/folium/master/examples/data/us-states.json", locations: [ "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" ],
1414
z: [ 141, 140, 155, 147, 132, 146, 151, 137, 146, 136, 145, 141, 149, 151, 138, 158, 164, 141, 146, 145, 142, 150, 155, 160, 156, 161, 147, 164, 150, 152, 155, 167, 145, 146, 151, 154, 161, 145, 155, 150, 151, 162, 172, 169, 170, 151, 152, 173, 160, 176 ],
1515
zmin: 25, zmax: 280, colorbar: {y: 0, yanchor: "bottom", title: {text: "US states", side: "right"}}}
1616
];
1717

18-
var layout = {mapbox: {style: "dark", center: {lon: -110, lat: 50}, zoom: 0.8}, width: 600, height: 400, margin: {t: 0, b: 0}};
18+
var layout = {map: {style: "dark", center: {lon: -110, lat: 50}, zoom: 0.8}, width: 600, height: 400, margin: {t: 0, b: 0}};
1919

20-
var config = {mapboxAccessToken: "your access token"};
21-
22-
Plotly.newPlot('myDiv', data, layout, config);
20+
Plotly.newPlot('myDiv', data, layout);
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
---
2-
name: Basic Tile, Needs Token
2+
name: Basic Tile
33
language: plotly_js
4-
suite: mapbox-county-choropleth
4+
suite: tile-county-choropleth
55
order: 1
66
sitemap: false
77
arrangement: horizontal
88
markdown_content: |
99

10-
This tutorial uses [Mapbox GL JS](https://docs.mapbox.com/mapbox-gl-js/api/) to make a map of US states using [vector tiles](https://plotly.com/javascript/mapbox-layers/).
10+
This tutorial uses [Maplibre GL JS](https://maplibre.org/maplibre-gl-js/docs/) to make a map of US states using [vector tiles](https://plotly.com/javascript/mapbox-layers/).
1111
---
1212

1313
var data = [{
14-
type: "choroplethmapbox", locations: ["NY", "MA", "VT"], z: [-50, -10, -20],
14+
type: "choroplethmap", locations: ["NY", "MA", "VT"], z: [-50, -10, -20],
1515
geojson: "https://raw.githubusercontent.com/python-visualization/folium/master/examples/data/us-states.json"
1616
}];
1717

18-
var layout = {mapbox: {center: {lon: -74, lat: 43}, zoom: 3.5},
18+
var layout = {map: {center: {lon: -74, lat: 43}, zoom: 3.5},
1919
width: 600, height:400};
2020

21-
var config = {mapboxAccessToken: "your access token"};
22-
23-
Plotly.newPlot('myDiv', data, layout, config);
21+
Plotly.newPlot('myDiv', data, layout);
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
---
2-
name: Streets Tile, Needs Token
2+
name: Streets Tile
33
language: plotly_js
4-
suite: mapbox-county-choropleth
4+
suite: tile-county-choropleth
55
order: 2
66
sitemap: false
77
arrangement: horizontal
88
markdown_content: |
99

10-
The following example sets `geojson object` of type `feature` and geometries of type 'Polygon'. For more information see [geojson attribute](https://plotly.com/javascript/reference/choroplethmapbox/#choroplethmapbox-geojson) in the reference page.
11-
As you see, scattermapbox trace is above Choropleth mapbox. To set the Choropleth mapbox above all the other traces you should set [below attribute](https://plotly.com/javascript/reference/choroplethmapbox/#choroplethmapbox-below).
10+
The following example sets `geojson object` of type `feature` and geometries of type 'Polygon'. For more information see [geojson attribute](https://plotly.com/javascript/reference/choroplethmap/#choroplethmap-geojson) in the reference page.
11+
As you see, the scattermap trace is above the Choropleth map trace. To set the Choropleth map trace above all the other traces you should set [below attribute](https://plotly.com/javascript/reference/choroplethmap/#choroplethmap-below).
1212
---
1313
var data = [
14-
{type: "scattermapbox", lon: [-86], lat: [34], marker: {size: 20, color: 'purple'}},
14+
{type: "scattermap", lon: [-86], lat: [34], marker: {size: 20, color: 'purple'}},
1515
{
16-
type: "choroplethmapbox",locations: ["AL"], z: [10], coloraxis: "coloraxis", geojson: {type: "Feature", id: "AL", geometry: {type: "Polygon", coordinates: [[
16+
type: "choroplethmap",locations: ["AL"], z: [10], coloraxis: "coloraxis", geojson: {type: "Feature", id: "AL", geometry: {type: "Polygon", coordinates: [[
1717
[-86, 35], [-85, 34], [-85, 32], [-85, 32], [-85, 32], [-85, 32], [-85, 31],
1818
[-86, 31], [-87, 31], [-87, 31], [-88, 30], [-88, 30], [-88, 30], [-88, 30],
1919
[-88, 34], [-88, 35]]]
2020
}}}];
2121

22-
var layout = {width: 600, height: 400, mapbox: {style: 'streets',
22+
var layout = {width: 600, height: 400, map: {style: 'streets',
2323
center: {lon: -86, lat: 33}, zoom: 5}, marker: {line: {color: "blue"}},
2424
coloraxis: {showscale: false, colorscale: "Viridis"}};
2525

26-
Plotly.setPlotConfig({mapboxAccessToken: "your access token"});
27-
2826
Plotly.newPlot('myDiv', data, layout);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
2-
description: How to make a D3.js-based choropleth mapbox in JavaScript. A Choropleth
3-
mapbox shades geographic regions by value.
2+
description: How to make a tile-based choropleth map in JavaScript. A Choropleth map shades geographic regions by value.
43
display_as: maps
54
language: plotly_js
65
layout: base
7-
name: Choropleth Mapbox
6+
name: Choropleth Tile Map
87
order: 3
98
page_type: example_index
10-
permalink: javascript/mapbox-county-choropleth/
9+
permalink: javascript/tile-county-choropleth/
10+
redirect_from: javascript/mapbox-county-choropleth/
1111
thumbnail: thumbnail/mapbox-choropleth.png
1212
---
1313

14-
{% assign examples = site.posts | where:"language","plotly_js" | where:"suite","mapbox-county-choropleth" | sort: "order" %}
14+
{% assign examples = site.posts | where:"language","plotly_js" | where:"suite","tile-county-choropleth" | sort: "order" %}
1515
{% include posts/auto_examples.html examples=examples %}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Basic Tile using Mapbox
3+
language: plotly_js
4+
suite: tile-county-choropleth
5+
order: 4
6+
sitemap: false
7+
arrangement: horizontal
8+
markdown_content: |
9+
10+
Earlier examples use traces that render with [Maplibre GL JS](https://maplibre.org/maplibre-gl-js/docs/).
11+
These traces were introduced in Plotly.js 2.35.0 and replace Mapbox-based tile maps,
12+
which are now deprecated. Here's one of the earlier examples using the Mapbox-based `choroplethmapbox` trace
13+
---
14+
15+
var data = [{
16+
type: "choroplethmapbox", locations: ["NY", "MA", "VT"], z: [-50, -10, -20],
17+
geojson: "https://raw.githubusercontent.com/python-visualization/folium/master/examples/data/us-states.json"
18+
}];
19+
20+
var layout = {mapbox: {center: {lon: -74, lat: 43}, zoom: 3.5},
21+
width: 600, height:400};
22+
23+
var config = {mapboxAccessToken: "your access token"};
24+
25+
Plotly.newPlot('myDiv', data, layout, config);

0 commit comments

Comments
 (0)