【发布时间】:2016-07-19 17:54:49
【问题描述】:
我想在我的图表中添加一些关于工具提示的数据,但我找不到方法来做到这一点。我尝试添加角色:工具提示,但它不起作用
这是我的代码:
google.charts.load('current', {
callback: function () {
var cont = 1;
var rowtbl = document.getElementById("tabella").rows.length;
rowtbl = rowtbl - 1;
// use object notation for column headings
var data = new google.visualization.arrayToDataTable([
[{type: 'string', label: ''}, {type: 'number', label: 'Tempo in minuti: '}, {type: 'string', role: 'tooltip'}]
]);
//number rows table
while(cont <= rowtbl){
var nomi;
var qnt;
var time;
nomi = document.getElementById("tabella").rows[cont].cells[0].innerHTML;
time = document.getElementById("tabella").rows[cont].cells[3].innerHTML;
qnt = document.getElementById("tabella").rows[cont].cells[1].innerHTML;
var info = {
name: nomi,
tempo: time,
qn: qnt,
};
// add row to google data
data.addRow([
info.name,
parseFloat(info.tempo),
info.qn
]);
cont = cont +1;
}
var options = {
tooltip: {isHtml: true},
legend: { position: 'none' },
bar: { groupWidth: "80%" }
};
var chart = new google.charts.Bar(document.getElementById('top_x_div'));
chart.draw(data, google.charts.Bar.convertOptions(options));
},
packages: ['bar']
});
我希望 qnt = document.getElementById("tabella").rows[cont].cells[1].innerHTML; 显示在工具提示中。
我需要如何更改我的代码?
非常感谢你们!
编辑
【问题讨论】:
标签: javascript charts google-visualization