2015-12-28 69 views
5

可以使用sankey按名稱排序嗎?例如:按名稱在Sankey圖表中排序

實施例:https://jsfiddle.net/Khrys/1s3shf2m/

google.setOnLoadCallback(drawChart); 

    function drawChart() { 
    var data = new google.visualization.DataTable(); 
    data.addColumn('string', 'From'); 
    data.addColumn('string', 'To'); 
    data.addColumn('number', 'Weight'); 
    data.addRows([ 
     [ 'A', 'Mango', 5 ], 
     [ 'A', 'Mango', 7 ], 
     [ 'A', 'Apple', 6 ], 
     [ 'B', 'Coconut', 2 ], 
     [ 'B', 'Mango', 9 ], 
     [ 'B', 'Pineapple', 4 ] 
    ]); 

    // Sets chart options. 
    var options = { 
     width: 600, 
    }; 

    // Instantiates and draws our chart, passing in some options. 
    var chart = new google.visualization.Sankey(document.getElementById('sankey_basic')); 
    chart.draw(data, options); 
    } 

我期待的右側的輸出爲(從上到下):蘋果,椰子,芒果,菠蘿

由於

回答

9

將迭代設置爲0,圖應根據數據的輸入順序進行繪製。

實施例:

var options = { 
    height: 400, 
    width: 400, 
    sankey: { 
iterations: 0, 
     } 

問候