This repository was archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmap.js
More file actions
executable file
·58 lines (51 loc) · 2.39 KB
/
map.js
File metadata and controls
executable file
·58 lines (51 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Map using d3plus (color the countries)
// 1. Modify the dataset to reflect your personal journey
var sample_data = [
{"year": "1992 - 2014", "country": "aschn", "name": "China", "tags": "birth country; undergraduate", "color": "#ABDDA4"},
{"year": "2014", "country": "eudeu", "name": "Germany", "tags": "conference", "color": "#ABDDA4"},
{"year": "2014 - 2017", "country": "nausa", "name": "United States", "tags": "graduate", "color": "#ABDDA4"},
{"year": "2016", "country": "nabhs", "name": "Bahamas", "tags": "travel", "color": "#ABDDA4"},
{"year": "2017", "country": "sachl", "name": "Chile", "tags": "research", "color": "#ABDDA4"}
];
// 2. Add a tooltip to show the year and the tags fields from your dataset
var visualization = d3plus.viz()
.container("#svg_map") // container DIV to hold the visualization
.data(sample_data) // data to use with the visualization
.coords({
"mute": ["anata"],
"value": "http://d3plus.org/topojson/countries.json"
}) // pass topojson coordinates
.type("geo_map") // visualization type
.id("country") // key for which our data is unique on
.text("name") // key to use for display text
.color("color") // key for coloring countries
.draw(); // finally, draw the visualization!
// Using datamaps (d3) http://datamaps.github.io
/*
// 3. Add a new color for a new category
var basic_choropleth = new Datamap({
element: document.getElementById("svg_map"),
projection: 'mercator',
fills: {
defaultFill: "#CCCCCC",
authorHasTraveledTo: "#ABDDA4"
},
data: {
CHN: { fillKey: "authorHasTraveledTo", year: "1992 - 2014" },
DEU: { fillKey: "authorHasTraveledTo", year: "2014" },
USA: { fillKey: "authorHasTraveledTo", year: "2014 - 2017" },
BHS: { fillKey: "authorHasTraveledTo", year: "2016" },
CHL: { fillKey: "authorHasTraveledTo", year: "2017" }
},
geographyConfig: {
popupTemplate: function(geo, data) {
return ['<div class="hoverinfo"><strong>',
'Country: ' + geo.properties.name,
'<br> Year: ' + data.year,
'</strong></div>'].join('');
}
}
});
// 4. Add a legend to show the color of all categories included in your dataset
var legend = d3.select("#svg_map").append("svg").attr("id", "legend");
*/