我正在使用谷歌可视化来绘制饼图。我面临的问题是,我无法在饼图上捕获点击事件。我正在这样做。
function drawchartfromRe()
{
dashboard = new google.visualization.Dashboard(
document.getElementById('dashboard_div'));
//alert("RefuelLength"+totrefuelList.length);
//alert("Vehicleid:"+totrefuelList[0].vehicleId);
//google.load("visualization", "1", {packages:["corechart"]});
data = new google.visualization.DataTable();
data.addColumn('string', 'Task');
data.addColumn('number', 'Quantity');
data.addRows(totrefuelList.length);
for (var i=0;i<totrefuelList.length;i++)
{
data.setValue(i, 0, totrefuelList[i].vehicleName);
data.setValue(i, 1, totrefuelList[i].totalRefuelQty);
}
// var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart = new google.visualization.ChartWrapper({
'chartType': 'PieChart',
'containerId': 'chart_div',
'options': {
title: 'Refuel Trend',
height:'500',
width:'400',
backgroundColor: { fill:'transparent' },
'legend': 'right'
}
});
/* google.visualization.events.addListener(chart, 'select', function(e) {
// var selection = chart.getSelection();
var vehid= data.getValue(visualization.getSelection()[0].row, 0);
getRefueldailywise(vehid);
});*/
// chart.draw(data, options);
drawDashboard(dashboard,data,chart);
google.visualization.events.addListener(chart, 'select', function() {
// grab a few details before redirecting
alert(data.getValue(chart.getSelection()[0].row, 0));
//location.href = 'http://www.google.com?row=' + row + '&col=' + col + '&year=' + year;
});
}
在萤火虫我得到这样的错误..dashboard.getChart 不是一个函数