javascript - Responsive more than one google charts -
i'm using google charts in website, , since yesterday i'm searching solution make charts responsive, found 1 in stackoverflow :
<script> function resize () { // change dimensions if necessary chart.draw(datatable1, options); chart.draw(datatable2, options); chart.draw(datatable3, options); } if (window.addeventlistener) { window.addeventlistener('resize', resize); } else { window.attachevent('onresize', resize); } </script>
but probleme when use more 1 chart 1 become responsive, example here : http://jsfiddle.net/faissal_aboullait/5f92veyy/
the problem you're using same var chart.
and of course using on again, chart variable keep reference of 3rd chart.
declare different variable every chart this:
var reservationchart; //............ reservationchart = new google.visualization.columnchart(document.getelementbyid('chart_reservations')); reservationchart.draw(datatable1, options);
and resize function this:
function resize () { // change dimensions if necessary reservationchart.draw(datatable1, options); clientschart.draw(datatable2, options); deprecchart.draw(datatable3, options); }
an updated fiddle here: http://jsfiddle.net/d8vaxuug/
Comments
Post a Comment