Skip to content

Instantly share code, notes, and snippets.

@yiyi1991
Last active May 5, 2018 12:36
Show Gist options
  • Save yiyi1991/aba3a24a18e2a4275440ba491e857d60 to your computer and use it in GitHub Desktop.
Save yiyi1991/aba3a24a18e2a4275440ba491e857d60 to your computer and use it in GitHub Desktop.
20180505xb
license: mit
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Stretched Chord to show Flows</title>
<!-- D3.js -->
<script src="http://d3js.org/d3.v3.js"></script>
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Open Sans & CSS -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:700,400,300' rel='stylesheet' type='text/css'>
<style>
body {
font-family: 'Open Sans', sans-serif;
font-size: 12px;
font-weight: 400;
color: #525252;
text-align: center;
}
line {
stroke: #000;
stroke-width: 1.px;
}
text {
font-size: 8px;
}
.titles{
font-size: 10px;
}
path.chord {
fill-opacity: .80;
}
</style>
</head>
<body>
<div id="chart"></div>
<script src="script.js"></script>
</body>
</html>
////////////////////////////////////////////////////////////
//////////////////////// Set-up ////////////////////////////
////////////////////////////////////////////////////////////
var screenWidth = $(window).width();
var margin = {left: 50, top: 10, right: 50, bottom: 10},
width = Math.min(screenWidth, 837) - margin.left - margin.right,
height = Math.min(screenWidth, 1000)*5/6 - margin.top - margin.bottom;
var svg = d3.select("#chart").append("svg")
.attr("width", (width + margin.left + margin.right))
.attr("height", (height + margin.top + margin.bottom));
var wrapper = svg.append("g").attr("class", "chordWrapper")
.attr("transform", "translate(" + (width / 2 + margin.left) + "," + (height / 2 + margin.top) + ")");;
var outerRadius = Math.min(width, height) / 2 - 38,
innerRadius = outerRadius * 0.95,
opacityDefault = 0.7; //default opacity of chords
////////////////////////////////////////////////////////////
////////////////////////// Data ////////////////////////////
////////////////////////////////////////////////////////////
var Names = ["JP_C_rice","JP_C_whet","JP_C_cere","JP_C_vege","JP_C_olsd","JP_C_beet","JP_C_fib","JP_C_crop","JP_C_catt","JP_C_pigs","JP_C_poul","JP_C_meat","JP_C_anip","JP_C_milk","JP_C_wool","JP_C_log","JP_C_fish","JP_MN","JP_P_catt","JP_P_pigs","JP_P_poul","JP_P_meat","JP_P_veol","JP_P_milk","JP_P_rice","JP_P_sugr","JP_P_food","JP_M_beve","JP_M_fish","JP_M_toba","JP_M_text","JP_M_wear","JP_M_lead","JP_M_wd","JP_M_rwd","JP_MaL","JP_MaH","JP_ES","JP_WT","JP_SV","JP_WST","CN_C_rice","CN_C_whet","CN_C_cere","CN_C_vege","CN_C_olsd","CN_C_beet","CN_C_fib","CN_C_crop","CN_C_catt","CN_C_pigs","CN_C_poul","CN_C_meat","CN_C_anip","CN_C_milk","CN_C_wool","CN_C_log","CN_C_fish","CN_MN","CN_P_catt","CN_P_pigs","CN_P_poul","CN_P_meat","CN_P_veol","CN_P_milk","CN_P_rice","CN_P_sugr","CN_P_food","CN_M_beve","CN_M_fish","CN_M_toba","CN_M_text","CN_M_wear","CN_M_lead","CN_M_wd","CN_M_rwd","CN_MaL","CN_MaH","CN_ES","CN_WT","CN_SV","CN_WST"
];
var matrix = [
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.86633563358297,14.34539698133,0,0,9.7106787043958,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.29631086925866,15.9408419197553,0,0,11.6704133521277,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.17130314961027,1.430032188694,0,0,0,1.74585422935895,11.2522322124228,0,0,8.48211229967573,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5.25788921693819,0,0,3.76926190425472,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.26263020188606,0,0,1.62514230555215,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6.05644801231136,0,0,4.36975804899123,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.12466125674031,2.04886083062833,0,0,0,1.05275471445094,6.30250486151322,0,0,5.91713624824849,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.30645078533039,18.1096824196631,0,0,12.2173318176513,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.91268113766959,15.5998765359868,0,0,10.0710984848198,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.15853772606216,0,1.22229222516219,0,2.33788695195586,2.60916917069773,0,0,0,8.13471544663367,51.8986524945525,0,0,35.6216078757575,2.31822777221674],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5.36983865662563,0,0,3.87412061065715,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4.09882230932654,0,0,2.9627693560767,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.87147953684353,0,0,2.07391925640709,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4.94330288592982,0,0,0,0,2.2279269369903,0,0,2.85065590915291,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4.56979046859072,0,0,3.4777210451846,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.15770673726111,0,0,0,0,0,0,2.10401454572414,12.1311050500262,0,0,11.8773199641667,1.59903190373027],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.4649466775751,10.3806735597289,0,0,7.58176423328692,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.71553288215277,0,0,2.10495038930484,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.05140361139903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.17978104081372,0,1.64367665499319,0,3.42683485018829,4.22584719279049,0,0,0,8.83706236905199,61.5756988298255,0,0,45.9699089853745,3.10030273329827],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.76773592156132,2.08708631585737,0,0,0,5.51304025346145,36.2107011076448,0,0,35.1597936090278,1.95760426457112],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.60615842158448,11.3249589279982,0,0,8.66484043129367,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5.99049992931951,0,0,0,0,0,0,0,0,0,0,0,0,0,1.28696763775233,0,0,0,0,0,0,0,0,9.0090782307665,2.07694457307722,5.97196582920671,2.336408920181,666.150698333214,810.434189902949,45.1811301577064,0,0,53.620212064546,283.110936471174,4.10241500556968,0,326.593653193916,45.295430150395],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3.52092017807716,5.39981851390688,0,0,0,4.90919512896162,39.8023964966421,0,0,26.1836054010128,2.00265348285268],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.35870081984522,0,0,0,6.94062962703044,0,0,4.81457183679397,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.78909461964502,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.09100341582587,0,2.02991471051613,0,3.86174474503228,4.24745768527395,0,0,0,14.2670441223683,114.744010592775,1.50953192881224,0,77.0723080725678,5.15410790741472],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.14933732913952,1.26413369964593,0,0,0,4.24617561981853,34.150256782017,0,0,22.9383572864816,1.53397207933674],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,209.084581971084,0,0,0,26.1997268820564,0,13.0913567606529,4.89541512902261,18.5322920496369,12.8189763055419,0,1.94879890848679,3.51974653496277,10.2505217027417,39.3024444223717,1.6974698704714,9.62718061852318,9.22780942912276,5.46825700319222,0,3.08023257134391,9.3342842755637,0,238.635184823865,40.5668367380518,263.609965555978,11.4875786332421,481.33540109029,535.019156998807,108.680764789426,0,0,1651.25511805493,10948.4155492476,135.738113704567,12.1291519917847,7259.3370004064,477.707610446776],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,392.070619656211,0,0,0,48.1872061691696,0,23.9924376577757,9.34023278258879,35.6788367800158,23.8162304853271,1.74553532875125,3.93137488208346,7.34939551142801,21.7599022948563,100.848988421149,3.31482029936151,18.3322177268202,17.9834889407445,9.32515336731012,1.82770280888888,6.53101428354211,21.5100811369495,0,409.097565989506,83.2726138174103,382.104795140232,25.7652485547338,650.039532243788,649.626567146293,168.231703063319,0,0,3099.20880811468,32067.1630612009,420.437127425565,29.7640037452431,16475.8643796541,1187.97014964022],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11.2509626157004,0,0,0,1.40007258266301,0,0,0,1.07202291022049,0,0,0,0,0,2.4895235897545,0,0,0,0,0,0,0,0,13.0210629243857,2.34291822587339,12.9791921637874,0,39.4995671969785,45.1001690718802,6.5337887952002,0,0,90.3607826378263,731.280733753528,9.53856803912465,0,444.702555180692,30.8858327544295],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.41056465608995,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.71452484962429,0,1.67953643057029,0,5.34967205058641,6.17447442202515,0,0,0,11.4884131262094,89.2370431291919,1.18222075547193,0,57.0905178956838,3.91917368355575],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,223.999003301895,0,0,0,28.1964366582818,0,17.875681306652,6.94990923842035,25.1926271985723,17.6091958474536,1.16329379285407,2.75609255663766,4.51382369092556,13.8775268702475,49.6632138202524,2.494090116833,13.4525858886651,13.3539190078238,7.58172017785167,1.22836771053451,4.24642906281401,13.2849040753416,0,306.007745278363,49.1719252055932,281.703877424756,16.7025161510576,649.700463384799,746.844558080771,125.53777258437,0,0,1899.68986451076,13547.6651431033,188.395308241066,15.7119542000531,9763.03382428792,635.04950362085],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7.30765285597286,0,0,0,0,0,0,0,0,0,0,0,0,0,1.65912303033583,0,0,0,0,0,0,0,0,9.19805776001537,1.56208673338984,8.65070246690189,0,23.8355023815597,27.2866101294218,4.18971554412033,0,0,60.0428263745246,463.142399015463,6.3859934540793,0,305.132184822877,21.2753184064542],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.29750165893672,0,0,16.4785316626216,5.89506928594189,5.20802640257791,0,1.49306689771851,3.66082312218529,0,0,0,5.83536197241913,42.3851152530148,1.25287231734069,0,70.6141669574077,4.64411254450119,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.1988643646926,0,0,14.8843237245697,5.44251022546226,2.26281201794616,0,0,2.02201775457823,0,0,0,2.92942862627572,21.4539203331617,0,0,44.0103154635182,2.64500248362464,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.13487865402377,1.2272630083913,0,0,0,1.57515605769025,0,0,19.6831670186414,7.14235988230961,3.01932855610538,0,1.13542439961318,2.78634905039522,0,0,0,3.93194219175937,28.8797537347529,0,0,58.6682757648175,3.55917313840622,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.0695751267393,0,0,0,1.46944205995047,0,0,17.3752894432784,6.63064104131288,3.60991050185848,0,5.3227430883746,12.9869894898986,1.77524033746773,0,0,10.200478133848,76.3901111961721,2.1808717976107,0,114.221395241757,9.41892528952922,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8.71310759261691,2.64254774593093,7.105681686095,0,1.18336793380233,2.89698197787509,0,0,0,4.68845302163491,32.9572693504466,0,0,55.5411373161792,3.65438373147171,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.90362587616091,1.16225843259851,1.56925312132822,0,2.56577304670834,6.25668525406561,0,0,0,4.33307102904777,33.6163780387776,0,0,44.6385666799687,4.07919296305845,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.43806908735599,0,1.02260134692149,0,11.4354670155659,27.7768285531025,1.84998328065615,0,0,4.34240817890818,41.1566123327462,0,0,63.340462336801,7.47255421745903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.84643427436762,1.16128415410692,1.07594161742802,0,2.17280041048627,5.30171461885945,0,0,0,3.98731998132616,31.4619076249424,0,0,39.7613877390993,3.59933307098638,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.36471329332699,0,1.32274592421231,0,1.68537929806471,4.11438493757338,0,0,0,2.61856439746895,20.2593465190166,0,0,28.8954806026129,2.67830782120838,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6.72976218076487,3.05442640959283,5.28496956157921,0,6.02972889592544,14.9283255518288,2.15744943460719,0,0,19.0885130505006,255.02719956755,5.64382814902065,0,199.172017021841,17.4637762676666,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.73690358931841,1.14874628468449,0,0,0,2.23784383276497,0,0,0,4.46683071648706,29.6329219118916,1.0718692548248,0,42.7515304004341,3.51954310080753,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.26194409059918,0,0,1.69572122518544,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3.16074216971998,7.70574936704818,0,0,0,1.99474276457356,16.2451238603154,0,0,26.502535706362,3.0070662022328,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.99569844040463,0,3.97386151290477,0,3.08009370071934,7.5231136109813,1.06984553589636,0,0,5.33869733889622,42.7518841015912,1.19886127509373,0,58.1015039172948,5.16230720562719,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.28614925318182,1.25239492733571,1.27649441508264,0,1.3553015583448,3.315473849065,0,0,0,9.20778605567813,61.4973820567226,2.01266776208055,0,60.560820933428,4.7379626124935,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7.05637609713111,0,1.34938414851299,1.60533125175767,0,0,0,1.34602244100261,0,0,66.5693999358386,4.87618193952712,208.097956427915,0,0,2.07151004617989,0,0,0,12.303085916954,74.6077418713312,2.8136722255254,0,470.252014254717,15.4025200221101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,15.1636670847644,0,0,0,3.17358840032991,0,0,1.52613443120843,0,0,0,0,2.37093451755515,3.4191796238653,0,3.91679283127935,3.84313298895582,1.39823310595107,0,1.92130122346842,9.15921256952611,11.5463499245165,1.10807665335235,72.1948671309683,41.9565398910156,31.8168021170089,4.77009093847795,19.5508929857269,44.7796319449061,7.14499573410394,0,0,473.302817397532,1596.04008702959,372.468273313002,6.27962731460669,2096.4137430418,165.422237324856,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.38701949890712,0,0,2.00648862814681,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4.51386138844528,0,0,6.44742370963497,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.01099267146622,6.55395249005665,0,0,9.44392585378058,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7.21201911495798,2.43585741410021,0,0,0,23.4322303674143,2.41003546824693,6.0979076438514,0,4.37152971960802,12.3821218969652,0,0,0,14.4839014753242,51.2177225513826,1.47266940364946,0,172.173932462981,15.6584243882591,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4.36486793926161,0,7.84267768866625,0,0,0,0,0,0,3.49701146469126,23.2601597276419,0,0,39.9466029296276,2.35164221605689,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.05136644995041,0,3.74028668013534,0,0,0,0,0,0,0,6.04004510025522,0,0,15.3891194359664,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.26880623026494,0,4.72841152030667,0,0,0,0,0,0,1.20555170760841,8.68067828260024,0,0,17.7944447466567,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.01312653322739,0,0,0,0,0,0,0,0,0,2.5831625880174,0,0,4.8264298317855,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1.97753995641207,0,0,0,0,0,0,6.8826767092178,0,0,1.65081940295864,0,0,1.73291953562372,0,10.3642880513708,11.2311972664,4.7348972528028,1.3611943744557,1.09553197902802,14.4091018837758,2.23448056045793,1.60804874818246,178.855056464877,65.416055953227,27.1705244384126,0,9.84262347113413,24.1608413828251,2.57336255230292,0,0,35.1177557996486,257.155237838691,7.97295724184099,0,528.131555206508,31.7064876082897,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.95166678941212,15.9651351629736,0,0,22.464127679406,1.86355014499501,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1.21066598436824,0,0,0,0,0,0,1.64207482568808,0,0,0,0,0,13.6788102776315,0,2.59015331984544,3.08756102228115,1.2882570435777,0,0,2.54504664789683,1.63748938331142,0,128.783685705761,9.15393333754848,404.129710221299,0,1.43997074246593,3.41526717381653,0,0,0,21.9436003588026,128.851895559235,4.91074486736009,0,893.276124394718,28.1858731784678,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6.28501201356111,0,0,6.12735597871818,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,9.23566569738241,0,0,0,1.63806693621496,0,0,0,0,0,0,0,5.9817909134172,10.2300854328716,0,2.25616647760304,2.09899982506619,0,0,1.21222268587103,4.57753504974027,8.07437336660902,0,40.1717719065076,15.9118853197462,28.5612442036467,3.41447281577523,319.548584198117,776.187180226377,51.6944472681695,0,0,121.300074966268,1149.31841798909,16.4435425465059,2.53743263065659,1769.53536209804,208.776705117338,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,5.47427951949497,0,0,0,0,0,0,0,0,0,0,0,0,2.29132474361086,0,1.07584241922415,1.00301170776571,0,0,0,2.54543219032099,4.63655550626295,0,18.9728986928662,7.06301064445491,8.22730637589487,1.31882097344771,7.08561949337044,19.9812257782093,2.73592743807935,0,0,35.3082792471698,246.818868154846,6.34892065529396,0,594.738158844388,98.6769516140708,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.77726136848744,1.314506790408,1.53742272410163,0,2.2603137893095,5.71758663243584,29.6288766540637,0,0,9.42833515485051,103.951119481108,2.83303271953396,0,111.935601663924,13.0310112238574,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.31648717501429,24.7715070555981,0,0,20.0642752422328,1.62761189182847,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.68662396752579,0,0,1.36612146522334,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,91.1733217420685,2.62987204857749,0,0,18.4960709247471,0,0,7.66891843193845,0,0,2.9945638133372,0,10.9928508202641,20.1214161224657,1.27373899324964,18.5563974213889,17.6001641790698,6.87278266985014,4.08757797788625,9.28400011426286,40.7574754205554,57.5246368210588,4.72613515466864,344.749015296009,216.993122536869,184.06666045355,24.9435093399307,112.342817538512,275.144580792226,47.1291017929621,2.59464258074838,0,1785.4734427292,10357.2002964684,275.064885876145,24.1248560523305,10327.259794864,752.599078184015,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,25.4700835937914,0,0,0,6.07207278731289,0,0,3.31962641476931,0,0,1.68683897924258,0,7.27325731575913,18.0601094260167,0,8.41304092427828,8.43788983043652,3.01086535000567,1.62639030570521,3.64737619857643,20.398072064656,26.8721781103276,2.1044079798116,150.184134115723,78.4714081290717,88.2546798629507,14.2056266854937,35.3417801343684,104.14356724112,20.1107016508674,1.70962366148159,0,547.816523698219,13332.7827736006,233.078335265235,15.1090636177579,6408.66464680692,541.926397701497,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,9.24771075280953,0,0,0,1.89725777098078,0,0,1.06635293998775,0,0,0,0,1.50420639816105,3.01374787459396,0,2.44149440150925,2.39855358498714,0,0,1.13161210853881,5.19075913723106,6.54943980934584,0,46.8234499049458,25.0889920963389,30.4035317645156,3.12719972976338,22.9915115478888,56.1439920980316,7.09008519486679,0,0,201.613913277701,1276.90065400267,71.9415930824635,3.15269528491642,1294.56377956932,101.548945179655,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.31746661921206,0,1.07394990278283,0,0,1.7164317660162,0,0,0,4.77132273162018,33.9590867377884,1.44960056767518,0,35.2916641297388,2.83255558789744,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,23.772508264489,0,0,0,4.77024595187485,0,0,4.0673936867117,0,0,1.38902656079672,0,5.02803656547773,9.60662289369897,0,9.50630696310009,9.62466273363904,3.64946650373819,2.4245842322678,3.92447706926797,20.7518226954557,20.1270790283145,2.09645032815434,179.055229410672,93.2623190379586,110.525498084289,21.2194080781276,57.6834243669262,141.172303862202,19.3526426464789,1.1116456996511,0,520.287318004167,3725.46166016631,163.892885741513,17.5773619645085,6262.42397178447,533.59303336719,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1.30272638369058,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8.52592562216632,4.08481909101864,4.85115595628409,0,3.34797999772399,8.19956446683992,1.07398131856816,0,0,24.9881226157992,170.105287505245,8.99390490749164,0,219.617048987975,20.8039506351505,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
];
var chord = d3.layout.chord()
.padding(.02)
.sortSubgroups(d3.descending) //sort the chords inside an arc from high to low
.sortChords(d3.descending) //which chord should be shown on top when chords cross. Now the biggest chord is at the bottom
.matrix(matrix);
var arc = d3.svg.arc()
.innerRadius(innerRadius)
.outerRadius(outerRadius);
var path = d3.svg.chord()
.radius(innerRadius);
var fill = d3.scale.ordinal()
.domain(d3.range(Names.length))
.range(["#9fe901","#f9fd01","#fb31dd","#7701fd","#01e8fd"]);
////////////////////////////////////////////////////////////
//////////////////// Draw outer Arcs ///////////////////////
////////////////////////////////////////////////////////////
var g = wrapper.selectAll("g.group")
.data(chord.groups)
.enter().append("g")
.attr("class", "group");;
g.append("path")
.style("stroke", function(d) { return fill(d.index); })
.style("fill", function(d) { return fill(d.index); })
.attr("d", arc);
////////////////////////////////////////////////////////////
////////////////////// Append Names ////////////////////////
////////////////////////////////////////////////////////////
g.append("text")
.each(function(d) { d.angle = ((d.startAngle + d.endAngle) / 2);})
.attr("dy", ".35em")
.attr("class", "titles")
.attr("text-anchor", function(d) { return d.angle > Math.PI ? "end" : null; })
.attr("transform", function(d,i) {
var c = arc.centroid(d);
return "rotate(" + (d.angle * 180 / Math.PI - 90) + ")"
+ "translate(" + (innerRadius + 27) + ")"
+ (d.angle > Math.PI ? "rotate(180)" : "")
})
.text(function(d,i) { return Names[i]; });
//+ "translate(" + (innerRadius + 55) + ")"
////////////////////////////////////////////////////////////
//////////////////// Draw inner chords /////////////////////
////////////////////////////////////////////////////////////
var colors = ["#3fcf73","#ead63d","#01e8fd","#fc2f2f","#843fcf"];
var chords = wrapper.selectAll("path.chord")
.data(chord.chords)
.enter().append("path")
.attr("class", "chord")
.style("stroke", "none")
.style("fill", function(d,i) { return fill(d.target.index); })
.style("opacity", opacityDefault)
.attr("d", path);
////////////////////////////////////////////////////////////
///////////////////////// Tooltip //////////////////////////
////////////////////////////////////////////////////////////
//Arcs
g.append("title")
.text(function(d, i) {return Math.round(d.value) + " total input in " + Names[i];});
//Chords
chords.append("title")
.text(function(d) {
return [Math.round(d.source.value), " goods and service to ", Names[d.target.index], " from ", Names[d.source.index]].join("");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment