Make graph variables accesible with the window scope
Scope the variables graph, options and data_table to the window object, to make posible the update of a graph dynamically from external sources
Use cases:
- Update third column of first series with value 10000 of expenses chart, received by socket or ajax request
window.data_table_chart_expenses.setValue(2,1,10000);
window.chart_expenses.draw(window.data_table_chart_expenses, window.options_chart_expenses);

- Redraw the dynamically changed data on resize
$(window).on('debouncedresize', function(event) {
window.chart_expenses.draw(window.data_table_chart_expenses, window.options_chart_expenses);
});
Hi! Would listeners work for you in this case? https://developers.google.com/chart/interactive/docs/events#overview.
I have already added for listeners support on https://github.com/winston/google_visualr/blob/master/lib/google_visualr/base_chart.rb#L55
Thanks!
Hello Winston,
Thank you very much for your feedback, I had read the links you provided me, unfortunately I'm unable to see how to implement the redraw of the graph with only listeners.
As I understand the draw() function needs the data_table and the options to redraw it with the same look and feel, that is the reason I exposed the data_table to update the data and options to preserve the styles to the window scope.
Without exposing those variables, how can I redraw the graph updating the data_table data (adding rows or columns) with the listeners implementation?
Best regards.