Graphics Reference
In-Depth Information
to location, you must merge in country detail data. That data is in the
countries.csv
file.
ISOCC2,ISOCC3,ISONo,CountryName,ContinentCode,Continent,Latitude,
Longitude
AD,AND,20,Andorra,EU,Europe,42.5,1.6
AE,ARE,784,United Arab Emirates,AS,Asia,24,54
AF,AFG,4,Afghanistan,AS,Asia,33,65
AG,ATG,28,Antigua and Barbuda,NA,Americas,17.05,-61.8
AI,AIA,660,Anguilla,NA,Americas,18.25,-63.1667
...
Note
You may find that Comtrade does use ISO 3166 country codes, but with
some slight differences, which have been corrected for this example.
Create the Page Structure
With the two data files and the
d3.min.js
library file, you are ready to
begin coding. Start with a simple container page. The following
index.html
pagecreatesanemptypagewithatitleandsomebasicstyling,
loads
d3.js
,andloadsaJavaScriptfilenamed
worldtrade.js
whereyou
will put your code:
<!
DOCTYPE
html>
<html>
<head>
<
meta
charset
=
"utf-8"
>
<
title
>Global Trade Flow</
title
>
<
script
src
=
"d3.min.js"
></
script
>
<!-- container styling -->
<
style
>
body
{
margin
:
1em auto 4em auto
;
position
:
relative
;
width
:
720px
;
}