The test data is 2D data:

Test data

To convert two-dimensional table to one-dimensional table in JavaScript:

1
2
3
4
5
6
7
8
9
10
11
12
data_1D = [];

data_2D.filter(function(d) {
return d.code && d.code!='SOF46'; //skip the row "SOF46"
}).forEach(function(d) {
d.sum = 0;
for(var p in d)
if (p && p!="code" && p!="sum") {
dataP.push({'code':d.code,'type':p,'value':+d[p]});
d.sum+=+d[p];
}
});

Reference: dc.leaflet.js