Это описано в документации Google в разделе Роли DataTable.
В документации гистограммы объясняется, какие роли доступны для этой диаграммы здесь
Что вам нужно сделать, так это добавить дополнительные столбцы к вашим данным с помощью добавленной {role: tooltip}, причем в этом столбце будет показано, что вы хотите, чтобы всплывающая подсказка говорила.
Например:
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Sales');
data.addColumn({type: 'string', role: 'tooltip'});
data.addColumn('number', 'Expenses');
data.addColumn({type: 'string', role: 'tooltip'});
data.addRows([
['2004', 1000, '1M$ sales in 2004', 400, '$0.4M expenses in 2004'],
['2005', 1170, '1.17M$ sales in 2005', 460, '$0.46M expenses in 2005'],
['2006', 660, '.66$ sales in 2006', 1120, '$1.12M expenses in 2006'],
['2007', 1030, '1.03M$ sales in 2007', 540, '$0.54M expenses in 2007']
]);
Окончательный код будет выглядеть так:
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Sales');
data.addColumn({type: 'string', role: 'tooltip'});
data.addColumn('number', 'Expenses');
data.addColumn({type: 'string', role: 'tooltip'});
data.addRows([
['2004', 1000, '1M$ sales in 2004', 400, '$0.4M expenses in 2004'],
['2005', 1170, '1.17M$ sales in 2005', 460, '$0.46M expenses in 2005'],
['2006', 660, '.66$ sales in 2006', 1120, '$1.12M expenses in 2006'],
['2007', 1030, '1.03M$ sales in 2007', 540, '$0.54M expenses in 2007']
]);
// Create and draw the visualization.
new google.visualization.BarChart(document.getElementById('visualization')).
draw(data,
{title:"Yearly Coffee Consumption by Country",
isStacked: true,
width:600, height:400,
vAxis: {title: "Year"},
hAxis: {title: "Sales"}}
);
}
См. Пример здесь.
person
jmac
schedule
11.01.2013