Skip to content

Commit a77356b

Browse files
authored
Merge pull request #439 from plotly/cam/revert-d3-call-signature-changes
docs: Revert D3 call signature changes
2 parents 767215c + 9677192 commit a77356b

5 files changed

Lines changed: 150 additions & 155 deletions

_posts/plotly_js/maps/choropleth-maps/2015-07-11-choropleth-north-america.html

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,42 @@
77
arrangement: horizontal
88
---
99

10-
d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv')
11-
.then((rows) => {
12-
const unpack = (rows, key) => rows.map((row) => row[key]);
10+
d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv', (err, rows) => {
11+
const unpack = (rows, key) => rows.map((row) => row[key]);
1312

14-
const data = [{
15-
type: 'choropleth',
16-
locationmode: 'USA-states',
17-
locations: unpack(rows, 'code'),
18-
z: unpack(rows, 'total exports'),
19-
text: unpack(rows, 'state'),
20-
zmin: 0,
21-
zmax: 17000,
22-
colorscale: [
23-
[0, 'rgb(242,240,247)'], [0.2, 'rgb(218,218,235)'],
24-
[0.4, 'rgb(188,189,220)'], [0.6, 'rgb(158,154,200)'],
25-
[0.8, 'rgb(117,107,177)'], [1, 'rgb(84,39,143)']
26-
],
27-
colorbar: {
28-
title: {text: 'Millions USD'},
29-
thickness: 0.2
30-
},
31-
marker: {
32-
line:{
33-
color: 'rgb(255,255,255)',
34-
width: 2
35-
}
13+
const data = [{
14+
type: 'choropleth',
15+
locationmode: 'USA-states',
16+
locations: unpack(rows, 'code'),
17+
z: unpack(rows, 'total exports'),
18+
text: unpack(rows, 'state'),
19+
zmin: 0,
20+
zmax: 17000,
21+
colorscale: [
22+
[0, 'rgb(242,240,247)'], [0.2, 'rgb(218,218,235)'],
23+
[0.4, 'rgb(188,189,220)'], [0.6, 'rgb(158,154,200)'],
24+
[0.8, 'rgb(117,107,177)'], [1, 'rgb(84,39,143)']
25+
],
26+
colorbar: {
27+
title: {text: 'Millions USD'},
28+
thickness: 0.2
29+
},
30+
marker: {
31+
line:{
32+
color: 'rgb(255,255,255)',
33+
width: 2
3634
}
37-
}];
35+
}
36+
}];
3837

39-
const layout = {
40-
title: {text: '2011 US Agriculture Exports by State'},
41-
geo:{
42-
scope: 'usa',
43-
showlakes: true,
44-
lakecolor: 'rgb(255,255,255)'
45-
}
46-
};
38+
const layout = {
39+
title: {text: '2011 US Agriculture Exports by State'},
40+
geo:{
41+
scope: 'usa',
42+
showlakes: true,
43+
lakecolor: 'rgb(255,255,255)'
44+
}
45+
};
4746

48-
Plotly.newPlot("myDiv", data, layout, {showLink: false});
49-
});
47+
Plotly.newPlot("myDiv", data, layout, {showLink: false});
48+
});

_posts/plotly_js/maps/choropleth-maps/2015-07-11-choropleth-world-robinson.html

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,26 @@
77
arrangement: horizontal
88
---
99

10-
d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2010_alcohol_consumption_by_country.csv')
11-
.then((rows) => {
12-
const unpack = (rows, key) => rows.map((row) => row[key]);
10+
d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2010_alcohol_consumption_by_country.csv', (err, rows) => {
11+
const unpack = (rows, key) => rows.map((row) => row[key]);
1312

14-
const data = [{
15-
type: 'choropleth',
16-
locationmode: 'country names',
17-
locations: unpack(rows, 'location'),
18-
z: unpack(rows, 'alcohol'),
19-
text: unpack(rows, 'location'),
20-
autocolorscale: true
21-
}];
13+
const data = [{
14+
type: 'choropleth',
15+
locationmode: 'country names',
16+
locations: unpack(rows, 'location'),
17+
z: unpack(rows, 'alcohol'),
18+
text: unpack(rows, 'location'),
19+
autocolorscale: true
20+
}];
2221

23-
const layout = {
24-
title: {text: 'Pure alcohol consumption<br>among adults (age 15+) in 2010'},
25-
geo: {
26-
projection: {
27-
type: 'robinson'
28-
}
22+
const layout = {
23+
title: {text: 'Pure alcohol consumption<br>among adults (age 15+) in 2010'},
24+
geo: {
25+
projection: {
26+
type: 'robinson'
2927
}
30-
};
28+
}
29+
};
3130

32-
Plotly.newPlot("myDiv", data, layout, {showLink: false});
33-
});
31+
Plotly.newPlot("myDiv", data, layout, {showLink: false});
32+
});

_posts/plotly_js/maps/choropleth-maps/2015-08-10-countrygdp-choropleth-map.html

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,46 @@
77
arrangement: horizontal
88
---
99

10-
d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')
11-
.then((rows) => {
12-
const unpack = (rows, key) => rows.map((row) => row[key]);
10+
d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv', (err, rows) => {
11+
const unpack = (rows, key) => rows.map((row) => row[key]);
1312

14-
const data = [{
15-
type: 'choropleth',
16-
locations: unpack(rows, 'CODE'),
17-
z: unpack(rows, 'GDP (BILLIONS)'),
18-
text: unpack(rows, 'COUNTRY'),
19-
colorscale: [
20-
[0,'rgb(5, 10, 172)'],[0.35,'rgb(40, 60, 190)'],
21-
[0.5,'rgb(70, 100, 245)'], [0.6,'rgb(90, 120, 245)'],
22-
[0.7,'rgb(106, 137, 247)'],[1,'rgb(220, 220, 220)']],
23-
autocolorscale: false,
24-
reversescale: true,
25-
marker: {
26-
line: {
27-
color: 'rgb(180,180,180)',
28-
width: 0.5
29-
}
30-
},
31-
tick0: 0,
32-
zmin: 0,
33-
dtick: 1000,
34-
colorbar: {
35-
tickmode: 'linear',
36-
tickprefix: '$',
37-
title: {text: 'GDP<br>Billions US$'}
13+
const data = [{
14+
type: 'choropleth',
15+
locations: unpack(rows, 'CODE'),
16+
z: unpack(rows, 'GDP (BILLIONS)'),
17+
text: unpack(rows, 'COUNTRY'),
18+
colorscale: [
19+
[0,'rgb(5, 10, 172)'],[0.35,'rgb(40, 60, 190)'],
20+
[0.5,'rgb(70, 100, 245)'], [0.6,'rgb(90, 120, 245)'],
21+
[0.7,'rgb(106, 137, 247)'],[1,'rgb(220, 220, 220)']],
22+
autocolorscale: false,
23+
reversescale: true,
24+
marker: {
25+
line: {
26+
color: 'rgb(180,180,180)',
27+
width: 0.5
3828
}
39-
}];
29+
},
30+
tick0: 0,
31+
zmin: 0,
32+
dtick: 1000,
33+
colorbar: {
34+
tickmode: 'linear',
35+
tickprefix: '$',
36+
title: {text: 'GDP<br>Billions US$'}
37+
}
38+
}];
4039

41-
const layout = {
42-
title: {text: '2014 Global GDP<br>Source: <a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html"> CIA World Factbook</a>'},
43-
geo:{
44-
showframe: false,
45-
showcoastlines: false,
46-
projection:{
47-
type: 'mercator'
48-
}
40+
const layout = {
41+
title: {text: '2014 Global GDP<br>Source: <a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html"> CIA World Factbook</a>'},
42+
geo:{
43+
showframe: false,
44+
showcoastlines: false,
45+
projection:{
46+
type: 'mercator'
4947
}
50-
};
48+
}
49+
};
5150

52-
Plotly.newPlot("myDiv", data, layout, {showLink: false});
53-
});
51+
Plotly.newPlot("myDiv", data, layout, {showLink: false});
52+
});

_posts/plotly_js/maps/choropleth-maps/2015-08-11-US-pop-by-state-choropleth.html

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,32 @@
77
arrangement: horizontal
88
---
99

10-
d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_usa_states.csv')
11-
.then((rows) => {
12-
const unpack = (rows, key) => rows.map((row) => row[key]);
10+
d3.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_usa_states.csv', (err, rows) => {
11+
const unpack = (rows, key) => rows.map((row) => row[key]);
1312

14-
const data = [{
15-
type: 'choropleth',
16-
locationmode: 'USA-states',
17-
locations: unpack(rows, 'Postal'),
18-
z: unpack(rows, 'Population'),
19-
text: unpack(rows, 'State'),
20-
autocolorscale: true
21-
}];
13+
const data = [{
14+
type: 'choropleth',
15+
locationmode: 'USA-states',
16+
locations: unpack(rows, 'Postal'),
17+
z: unpack(rows, 'Population'),
18+
text: unpack(rows, 'State'),
19+
autocolorscale: true
20+
}];
2221

23-
const layout = {
24-
title: {text: '2014 US Population by State'},
25-
geo:{
26-
scope: 'usa',
27-
countrycolor: 'rgb(255, 255, 255)',
28-
showland: true,
29-
landcolor: 'rgb(217, 217, 217)',
30-
showlakes: true,
31-
lakecolor: 'rgb(255, 255, 255)',
32-
subunitcolor: 'rgb(255, 255, 255)',
33-
lonaxis: {},
34-
lataxis: {}
35-
}
36-
};
22+
const layout = {
23+
title: {text: '2014 US Population by State'},
24+
geo:{
25+
scope: 'usa',
26+
countrycolor: 'rgb(255, 255, 255)',
27+
showland: true,
28+
landcolor: 'rgb(217, 217, 217)',
29+
showlakes: true,
30+
lakecolor: 'rgb(255, 255, 255)',
31+
subunitcolor: 'rgb(255, 255, 255)',
32+
lonaxis: {},
33+
lataxis: {}
34+
}
35+
};
3736

38-
Plotly.newPlot("myDiv", data, layout, {showLink: false});
39-
});
37+
Plotly.newPlot("myDiv", data, layout, {showLink: false});
38+
});

_posts/plotly_js/maps/choropleth-maps/2016-08-04-florida-counties.html

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,38 @@
77
arrangement: horizontal
88
---
99

10-
Promise.all([
11-
d3.json('https://raw.githubusercontent.com/plotly/datasets/master/florida-red-data.json'),
12-
d3.json('https://raw.githubusercontent.com/plotly/datasets/master/florida-blue-data.json')
13-
]).then(([redjson, bluejson]) => {
14-
Plotly.newPlot('myDiv', [{
15-
type: 'scattermap',
16-
lat: [46],
17-
lon: [-74]
18-
}], {
19-
title: {text: "Florida Counties"},
20-
height: 600,
21-
width: 600,
22-
map: {
23-
center: {
24-
lat: 28,
25-
lon: -84
26-
},
27-
style: 'light',
28-
zoom: 4.8,
29-
layers: [
30-
{
31-
sourcetype: 'geojson',
32-
source: redjson,
33-
type: 'fill',
34-
color: 'rgba(163,22,19,0.8)'
10+
d3.json('https://raw.githubusercontent.com/plotly/datasets/master/florida-red-data.json', (redjson) => {
11+
d3.json('https://raw.githubusercontent.com/plotly/datasets/master/florida-blue-data.json', (bluejson) => {
12+
Plotly.newPlot('myDiv', [{
13+
type: 'scattermap',
14+
lat: [46],
15+
lon: [-74]
16+
}], {
17+
title: {text: "Florida Counties"},
18+
height: 600,
19+
width: 600,
20+
map: {
21+
center: {
22+
lat: 28,
23+
lon: -84
3524
},
36-
{
37-
sourcetype: 'geojson',
38-
source: bluejson,
39-
type: 'fill',
40-
color: 'rgba(40,0,113,0.8)'
41-
},
42-
]
43-
}
25+
style: 'light',
26+
zoom: 4.8,
27+
layers: [
28+
{
29+
sourcetype: 'geojson',
30+
source: redjson,
31+
type: 'fill',
32+
color: 'rgba(163,22,19,0.8)'
33+
},
34+
{
35+
sourcetype: 'geojson',
36+
source: bluejson,
37+
type: 'fill',
38+
color: 'rgba(40,0,113,0.8)'
39+
},
40+
]
41+
}
42+
});
4443
});
4544
});

0 commit comments

Comments
 (0)