2013-02-11 79 views
2

我想谷歌的條形圖中使用的工具提示和正在運行到一個奇怪的問題,第一行的作品在那裏,如果我的數據表的最上面一行有沒有我的提示才起作用工具提示。谷歌圖表工具提示只用無提示

當我這樣做,圖表不會呈現:

function drawVisualization() { 
    // Create and populate the data table. 
    var data = google.visualization.arrayToDataTable([ 
    ['Report','Ineffective', 'Developing', 'Effective', 'Highly Effective'], 
    ['Growth Rating',{v:18, f:'tooltip text'},{v:12, f:'tooltip text'},{v:66, f:'tooltip text'},{v:4, f:'tooltip text'}], 
    ['Composite Rating',{v:6, f:'tooltip text'},{v:12, f:'tooltip text'},{v:58, f:'tooltip text'},{v:25, f:'tooltip text'}] 
    ]); 

    // Create and draw the visualization. 
    new google.visualization.BarChart(document.getElementById('chart_div')). 
     draw(data, 
     {title:"TITLE", 
     colors: ['#638FBC','#FFE17C','#FFA87C','#204C7A'], 
     hAxis: {title: "Percent of Educators", viewWindow:{max:105, min:0}, titleTextStyle: {italic: false}}, 
     chartArea: {width: "60%"}, 
     isStacked: true} 
    ); 
} 

,但如果我這樣做,圖表呈現精細

function drawVisualization() { 
    // Create and populate the data table. 
    var data = google.visualization.arrayToDataTable([ 
    ['Report','Ineffective', 'Developing', 'Effective', 'Highly Effective'], 
    ['Empty', 0 , 0 , 0 , 0 ], 
    ['Growth Rating',{v:18, f:'tooltip text'},{v:12, f:'tooltip text'},{v:66, f:'tooltip text'},{v:4, f:'tooltip text'}], 
    ['Composite Rating',{v:6, f:'tooltip text'},{v:12, f:'tooltip text'},{v:58, f:'tooltip text'},{v:25, f:'tooltip text'}] 
    ]); 

    // Create and draw the visualization. 
    new google.visualization.BarChart(document.getElementById('chart_div')). 
     draw(data, 
     {title:"TITLE", 
     colors: ['#638FBC','#FFE17C','#FFA87C','#204C7A'], 
     hAxis: {title: "Percent of Educators", viewWindow:{max:105, min:0}, titleTextStyle: {italic: false}}, 
     chartArea: {width: "60%"}, 
     isStacked: true} 
    ); 

我不知道爲什麼添加額外的行品牌這行得通。

任何幫助將不勝感激。

回答

1

這是因爲此時對arrayToDataTable中{v:,f:}單元格的支持有點多餘。我們將在該庫的下一個版本中發佈一個修復程序。在此期間,您可以使用google.visualization.DataTable構造函數,如下所示:

var data = new google.visualization.DataTable(); 
data.addColumn('string', 'Report'); 
data.addColumn('string', 'Developing'); 
data.addColumn('string', 'Effective'); 
data.addColumn('string', 'Highly Effective'); 
data.addRows([ 
    ['Growth Rating',{v:18, f:'tooltip text'},{v:12, f:'tooltip text'},{v:66, f:'tooltip text'},{v:4, f:'tooltip text'}], 
    ['Composite Rating',{v:6, f:'tooltip text'},{v:12, f:'tooltip text'},{v:58, f:'tooltip text'},{v:25, f:'tooltip text'}] 
]); 
+1

我希望我可以upvote這兩次:) – Novarg 2015-01-27 13:40:33