2016-06-08 77 views

回答

1

看看這段代碼:

var n = 4, // number of layers 
    m = 25, // number of samples per layer 
    stack = d3.layout.stack(), 
    layers = stack(d3.range(n).map(function() { return bumpLayer(m, .1); })) 

基本上,其堆疊的圖表,所以你需要方便地組織數據:

var data = [ 
// first group 
{ 
"index":"0", 
"position":"bottom", 
"num_visitors":"30" 
}, 
{ 
"index":"0", 
"position":"middle", 
"num_visitors":"10" 
}, 
{ 
"index":"0", 
"position":"top", 
"num_visitors":"15" 
}, 
// second group 
{ 
"index":"1", 
"position":"bottom", 
"num_visitors":"56" 
}, 
{ 
"index":"1", 
"position":"middle", 
"num_visitors":"32" 
}, 
{ 
"index":"1", 
"position":"top", 
"num_visitors":"21" 
}, .... 
相關問題