google.visualization.events.addListener(chart, 'select', function () {
var sel = chart.getSelection();
// if selection length is 0, we deselected an element
if (sel.length > 0) {
// if row is undefined, we clicked on the legend
alert("selected item is"+sel[0].row);
if (sel[0].row == null) {
var col = sel[0].column;
if (columns[col] == col) {
// grey out the legend entry
// hide the data series
columns[col] = {
label: data.getColumnLabel(col),
type: data.getColumnType(col),
calc: function () {
return null;
}
};
series[col - 1].color = '#CCCCCC';
}else{
// show the data series
columns[col] = col;
series[col - 1].color = null;
//var view = new google.visualization.DataView(data);
//chart.draw(view, options);
}
var view = new google.visualization.DataView(data);
view.setColumns(columns);
chart.draw(view, options);
}
}
});
The probles is sel[0].row is never null
El dimecres 2 d’abril de 2014 16:37:42 UTC+2,
estadistica...@gmail.com va escriure: