Reputation: 4132
I have drawn a Google visualization table chart. How can I get the DataTable that is used to draw the chart? For example, how to get the value of first 5 rows and column 1.
Upvotes: 1
Views: 3799
Reputation: 3551
If you are using the ChartWrapper you can get the DataTable like this:
var wrapper = new google.visualization.ChartWrapper({
chartType: 'ColumnChart',
dataTable: [['Germany', 'USA', 'Brazil', 'Canada', 'France', 'RU'],
[700, 300, 400, 500, 600, 800]],
options: {'title': 'Countries'},
containerId: 'visualization'
});
wrapper.draw();
// get the DT
var dt = wrapper.getDataTable();
console.log(dt);
If you want to get a value from the DataTable, you can use the getValue(rowIndex, columnIndex)
method of a DataTable:
var dt = wrapper.getDataTable();
alert(dt.getValue(3, 1));
Upvotes: 2