Google chart - Responsive
JavaScript
// Load the Visualization API and the piechart package.
google.load('visualization', '1.1', {
'packages': ['corechart']
});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(function () {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);
// Set chart options
var options = {
title: 'How Much Pizza I Ate Last Night',
animation: {
duration: 1000,
easing: 'linear',
},
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
drawChart();
function drawChart() {
// Instantiate and draw our chart, passing in some options.
chart.draw(data, options);
}
/* This does the magic */
$(document).ready(function () {
$(window).resize(function () {
drawChart();
});
});
});