Skip to content

Instantly share code, notes, and snippets.

@DStruths
Created October 2, 2014 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DStruths/121d4ca177a743cfedfd to your computer and use it in GitHub Desktop.
Save DStruths/121d4ca177a743cfedfd to your computer and use it in GitHub Desktop.
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Google results');
data.addRows([
['02', 7390000],
['03', 7650000],
['04', 10590000],
['05', 11950000],
['06', 12010000],
['07', 31900000],
['08', 53300000],
['09', 105200000],
['10', 112600000],
['11', 258900000],
['12', 470000000]
]);
// Set chart options
var options = {'title':'Google results searching for "data" 2002 - 2012',
'width':'100%',
'height':300,
'curveType': "function",
'backgroundColor': "#ffffff",
'chartArea': {'width': '98%'},
'axisTitlesPosition': 'in',
'vAxis': {'textPosition': 'in'},
'titleTextStyle':{'color': '#809ECE'},
'hAxis.textStyle':{'color': '#809ECE'},
'colors': ['#809ECE']
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
chart.draw(data, options);
// Paul Irish’s Debounced resize plug-in
$(window).smartresize(function () {
chart.draw(data, options);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment