Skip to content

Commit 4294faa

Browse files
author
Ændrew Rininsland
committed
⭐ New: Adds C3.js example
1 parent fe2f2a5 commit 4294faa

File tree

3 files changed

+252
-0
lines changed

3 files changed

+252
-0
lines changed

C3/160926-c3js.png

31.4 KB
Loading

C3/data.csv

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
country,income,health,population
2+
Afghanistan,1925,57.63,32526562
3+
Albania,10620,76,2896679
4+
Algeria,13434,76.5,39666519
5+
Andorra,46577,84.1,70473
6+
Angola,7615,61,25021974
7+
Antigua and Barbuda,21049,75.2,91818
8+
Argentina,17344,76.2,43416755
9+
Armenia,7763,74.4,3017712
10+
Australia,44056,81.8,23968973
11+
Austria,44401,81,8544586
12+
Azerbaijan,16986,72.9,9753968
13+
Bahamas,22818,72.3,388019
14+
Bahrain,44138,79.2,1377237
15+
Bangladesh,3161,70.1,160995642
16+
Barbados,12984,75.8,284215
17+
Belarus,17415,70.4,9495826
18+
Belgium,41240,80.4,11299192
19+
Belize,8501,70,359287
20+
Benin,1830,65.5,10879829
21+
Bhutan,7983,70.2,774830
22+
Bolivia,6295,72.3,10724705
23+
Bosnia and Herzegovina,9833,77.9,3810416
24+
Botswana,17196,66.4,2262485
25+
Brazil,15441,75.6,207847528
26+
Brunei,73003,78.7,423188
27+
Bulgaria,16371,74.9,7149787
28+
Burkina Faso,1654,62.8,18105570
29+
Burundi,777,60.4,11178921
30+
Cambodia,3267,68.4,15577899
31+
Cameroon,2897,59.5,23344179
32+
Canada,43294,81.7,35939927
33+
Cape Verde,6514,74.6,520502
34+
Central African Republic,599,53.8,4900274
35+
Chad,2191,57.7,14037472
36+
Chile,22465,79.3,17948141
37+
China,13334,76.9,1376048943
38+
Colombia,12761,75.8,48228704
39+
Comoros,1472,64.1,788474
40+
"Congo, Dem. Rep.",809,58.3,77266814
41+
"Congo, Rep.",6220,61.9,4620330
42+
Costa Rica,14132,80,4807850
43+
Cote d'Ivoire,3491,60.33,22701556
44+
Croatia,20260,78,4240317
45+
Cuba,21291,78.5,11389562
46+
Cyprus,29797,82.6,1165300
47+
Czech Republic,29437,78.6,10543186
48+
Denmark,43495,80.1,5669081
49+
Djibouti,3139,64.63,887861
50+
Dominica,10503,74.6,72680
51+
Dominican Republic,12837,73.8,10528391
52+
Ecuador,10996,75.2,16144363
53+
Egypt,11031,71.3,91508084
54+
El Salvador,7776,74.1,6126583
55+
Equatorial Guinea,31087,60.63,845060
56+
Eritrea,1129,62.9,5227791
57+
Estonia,26812,76.8,1312558
58+
Ethiopia,1520,63.6,99390750
59+
Fiji,7925,66.3,892145
60+
Finland,38923,80.8,5503457
61+
France,37599,81.9,64395345
62+
Gabon,18627,60.53,1725292
63+
Gambia,1644,65.1,1990924
64+
Georgia,7474,73.3,3999812
65+
Germany,44053,81.1,80688545
66+
Ghana,4099,65.5,27409893
67+
Greece,25430,79.8,10954617
68+
Grenada,11593,71.7,106825
69+
Guatemala,7279,73.1,16342897
70+
Guinea,1225,60.8,12608590
71+
Guinea-Bissau,1386,53.4,1844325
72+
Guyana,6816,64.4,767085
73+
Haiti,1710,65.3,10711067
74+
Honduras,4270,72.4,8075060
75+
Hungary,24200,76.2,9855023
76+
Iceland,42182,82.8,329425
77+
India,5903,66.8,1311050527
78+
Indonesia,10504,70.9,257563815
79+
Iran,15573,78.5,79109272
80+
Iraq,14646,72.1,36423395
81+
Ireland,47758,80.4,4688465
82+
Israel,31590,82.4,8064036
83+
Italy,33297,82.1,59797685
84+
Jamaica,8606,75.5,2793335
85+
Japan,36162,83.5,126573481
86+
Jordan,11752,78.3,7594547
87+
Kazakhstan,23468,68.2,17625226
88+
Kenya,2898,66.63,46050302
89+
Kiribati,1824,62.4,112423
90+
Kuwait,82633,80.7,3892115
91+
Kyrgyz Republic,3245,69,5939962
92+
Lao,5212,66.4,6802023
93+
Latvia,23282,75.7,1970503
94+
Lebanon,17050,78.5,5850743
95+
Lesotho,2598,48.5,2135022
96+
Liberia,958,63.9,4503438
97+
Libya,17261,76.2,6278438
98+
Lithuania,26665,75.4,2878405
99+
Luxembourg,88314,81.1,567110
100+
"Macedonia, FYR",12547,77,2078453
101+
Madagascar,1400,64.7,24235390
102+
Malawi,799,60.22,17215232
103+
Malaysia,24320,75.1,30331007
104+
Maldives,14408,79.5,363657
105+
Mali,1684,57.6,17599694
106+
Malta,30265,82.1,418670
107+
Marshall Islands,3661,65.1,52993
108+
Mauritania,3877,65.7,4067564
109+
Mauritius,18350,73.9,1273212
110+
Mexico,16850,74.5,127017224
111+
"Micronesia, Fed. Sts.",3510,67,104460
112+
Moldova,4896,72.7,4068897
113+
Mongolia,11819,65.3,2959134
114+
Montenegro,14833,75.8,625781
115+
Morocco,7319,74.7,34377511
116+
Mozambique,1176,56.4,27977863
117+
Myanmar,4012,67.9,53897154
118+
Namibia,10040,61,2458830
119+
Nepal,2352,71.2,28513700
120+
Netherlands,45784,80.6,16924929
121+
New Zealand,34186,80.6,4528526
122+
Nicaragua,4712,76.8,6082032
123+
Niger,943,62.2,19899120
124+
Nigeria,5727,61.33,182201962
125+
North Korea,1390,71.4,25155317
126+
Norway,64304,81.6,5210967
127+
Oman,48226,75.7,4490541
128+
Pakistan,4743,66.5,188924874
129+
Panama,20485,78.2,3929141
130+
Papua New Guinea,2529,60.6,7619321
131+
Paraguay,8219,73.9,6639123
132+
Peru,11903,77.5,31376670
133+
Philippines,6876,70.2,100699395
134+
Poland,24787,77.3,38611794
135+
Portugal,26437,79.8,10349803
136+
Qatar,132877,82,2235355
137+
Romania,19203,76.8,19511324
138+
Russia,23038,73.13,143456918
139+
Rwanda,1549,66.53,11609666
140+
Samoa,5558,72.2,193228
141+
Sao Tome and Principe,3003,68.8,190344
142+
Saudi Arabia,52469,78.1,31540372
143+
Senegal,2251,66.1,15129273
144+
Serbia,12908,78.1,8850975
145+
Seychelles,25684,73.7,96471
146+
Sierra Leone,2085,58.5,6453184
147+
Singapore,80794,82.1,5603740
148+
Slovak Republic,27204,76.4,5426258
149+
Slovenia,28550,80.2,2067526
150+
Solomon Islands,2047,64.1,583591
151+
Somalia,624,58.7,10787104
152+
South Africa,12509,63.72,54490406
153+
South Korea,34644,80.7,50293439
154+
South Sudan,3047,58,12339812
155+
Spain,32979,81.7,46121699
156+
Sri Lanka,10624,76.5,20715010
157+
St. Lucia,9997,74.5,184999
158+
St. Vincent and the Grenadines,10435,72.9,109462
159+
Sudan,3975,69.5,40234882
160+
Suriname,17125,70.5,542975
161+
Swaziland,6095,51.5,1286970
162+
Sweden,44892,82,9779426
163+
Switzerland,56118,82.9,8298663
164+
Syria,4637,70.26,18502413
165+
Tajikistan,2582,71,8481855
166+
Tanzania,2571,63.43,53470420
167+
Thailand,14512,75.1,67959359
168+
Timor-Leste,2086,72.4,1184765
169+
Togo,1433,64.23,7304578
170+
Tonga,5069,70.5,106170
171+
Trinidad and Tobago,30113,71.4,1360088
172+
Tunisia,11126,77.3,11253554
173+
Turkey,19360,76.5,78665830
174+
Turkmenistan,15865,67.9,5373502
175+
Uganda,1680,60.8,39032383
176+
Ukraine,8449,72.1,44823765
177+
United Arab Emirates,60749,76.6,9156963
178+
United Kingdom,38225,81.4,64715810
179+
United States,53354,79.1,321773631
180+
Uruguay,20438,77.3,3431555
181+
Uzbekistan,5598,70.1,29893488
182+
Vanuatu,2912,65,264652
183+
Venezuela,15753,75.8,31108083
184+
Vietnam,5623,76.5,93447601
185+
West Bank and Gaza,4319,75.2,4668466
186+
Yemen,3887,67.6,26832215
187+
Zambia,4034,58.96,16211767
188+
Zimbabwe,1801,60.01,15602751

C3/index.html

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
6+
circle {
7+
fill: black;
8+
opacity:0.7;
9+
}
10+
11+
</style>
12+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.css" media="screen">
13+
<script type="text/javascript" src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
14+
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/c3/0.4.11/c3.min.js"></script>
15+
</head>
16+
<body>
17+
<div id="chart"></div>
18+
<script type="text/javascript">
19+
// load data
20+
var data = d3.csv("data.csv", function(error, data) {
21+
var size = d3.scale.linear()
22+
.domain([
23+
d3.min(data, function(d) {
24+
return Number(d.population); // need to coerce string variable into number.
25+
}),
26+
d3.max(data, function(d) {
27+
return Number(d.population); // same here.
28+
})
29+
])
30+
.range([2, 40]);
31+
32+
c3.generate({
33+
data: {
34+
json: data,
35+
keys: {
36+
value: [
37+
'income',
38+
'health',
39+
]
40+
},
41+
type: 'scatter',
42+
x: 'income',
43+
axes: {
44+
health: 'y'
45+
}
46+
},
47+
point: {
48+
r: function(d) {
49+
return size(data[d.index].population);
50+
}
51+
},
52+
tooltip: {
53+
format: {
54+
title: function(){ return; },
55+
name: function(name, ratio, id, index) {
56+
return data[index].country;
57+
}
58+
}
59+
}
60+
});
61+
});
62+
</script>
63+
</body>
64+
</html>

0 commit comments

Comments
 (0)