Graphics Reference
In-Depth Information
d3.js . In this section, you find step-by-step instructions for coding the
global trade visualization shown in Figure 12-7 using d3.js , which you can
easily adapt to your own data and embed in your own web app.
Prepare the Data
Yearly import and export trade data is available for all reporting countries
from the U.N., subject to availability and usage restrictions. Data available
includes detailed statistics by classification of goods. This example uses the
2010 reported imports only for each of the 25 high gross domestic product
(GDP) countries selected, which is recommended over the mirror statistics
reported by the exporting country.
Note
Data for this example was obtained online from the DESA/UNSD,
United Nations Comtrade database at comtrade.un.org , which makes
data freely available for personal use or limited publications like this
one. If you intend to use data from Comtrade, be sure you read its
policy document first to understand usage and re-dissemination
restrictions.
Locate the imports.csv data file in the example materials you downloaded
from the Supplementary Materials provided on this topic's companion
website for this chapter. Each record in the data contains a reporting
country and the partner country where the goods came from. The value
column indicates the total value of goods in U.S. dollars.
Reporter,Partner,Value
36,36,872953626
36,56,1390394950
36,76,680796081
36,124,1561155248
...
Note that some countries report re-imports to themselves, which you will
likely want to ignore. More obviously, countries in this data are represented
by what looks like ISO 3166 numeric country codes. Because you want to
not only label countries in the visualization but also arrange them according
Search WWH ::




Custom Search