I have tried to implement the ready event handler, basically copying from the Guide however I cannot get it to work.
What am I missing?
function drawVisualization() {
...
...
...
table = new google.visualization.Table(document.getElementById('table1'));
table.draw(dataTable, {width: 1100});
google.visualization.events.addListener(table, 'ready', resizeTable);
}
function resizeTable() {
alert('Will this work?');
}
//This code does not produce an alert
From google docs about Table events:
ready The chart is ready for external method calls. If you want to interact with the chart, and call methods after you draw it, you should set up a listener for this event before you call the draw method, and call them only after the event was fired.
So, you have to change order of code to:
...
table = new google.visualization.Table(document.getElementById('table1'));
google.visualization.events.addListener(table, 'ready', resizeTable);
table.draw(dataTable, {width: 1100});
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With