2014-03-24 60 views
0

我正在genearting柱形圖但現在我想生成該數據是在該方式生成柱狀圖3列到第1列

['name',10,7,3] 

現在我正在一個問題爲genearting的直方圖直方圖,我希望我的圖表只有1列顯示通過(7)和失敗(3)總數不同的顏色(10)。

我在django模板中這樣做。代碼是

google.load('visualization', '1', {packages: ['corechart','table']}); 
    function drawVisualization() { 
    // Some raw data (not necessarily accurate) 
    var data = google.visualization.arrayToDataTable([ 
     ['Job-Names', 'Total', 'Pass', 'Fail'], 
      {{data.0|safe}} 

]);

var options = { 
     title : 'Jenkins Job Details for project {{head_title}}', 
     vAxis: {title: "Number of BULDS" ,ticks : [2,4,6,8,10] }, 
     hAxis: {title: "Job-Names" , slantedText:true, slantedTextAngle:30 , textStyle : {fontSize : 9}}, 
     is3D: true, 
     height: 550, 
     width: 600, 
     colors : ["#194D86","#33FF66", "#FF3333"], 
     pointSize: 4 

    }; 

    var chart = new google.visualization.Histogram(document.getElementById('chart_div')); 
    chart.draw(data, options); 

    var table = new google.visualization.Table(document.getElementById('table_div')); 
    table.draw(data, {showRowNumber: false}); 
    } 

    google.setOnLoadCallback(drawVisualization); 

數據我通過在下面的格式 [「名」,總,及格,不及格]

回答

0

如果我正確地瞭解您的需求,我想你想要做的是創造了一個DataView僅顯示名稱,通過和失敗列的HistogramChart:

var view = new google.visualization.DataView(data); 
view.setColumns([0, 2, 3]); 

var chart = new google.visualization.Histogram(document.getElementById('chart_div')); 
chart.draw(view, options);