Skip to content

Instantly share code, notes, and snippets.

@cimi
Created January 30, 2012 14:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cimi/1704731 to your computer and use it in GitHub Desktop.
Size of analytics scripts on mobile sites.
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type="text/javascript">
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
var raw_data = [
['IKEA', 67, 22],
['HP', 53, 20],
['Dell', 50, 19],
['Target', 47, 17],
['IBM', 18.6, 6.8],
['Groupon Featured', 9, 3],
['Amazon', 5, 2],
['eBay', 0, 0],
['Walmart', 0, 0],
['Newegg', 0, 0],
['Microsoft', 0, 0]
];
var types = ['Uncompressed', 'Compressed'];
data.addColumn('string', 'Year');
for (var i = 0; i < raw_data.length; ++i) {
data.addColumn('number', raw_data[i][0]);
}
data.addRows(types.length);
for (var j = 0; j < types.length; ++j) {
data.setValue(j, 0, types[j].toString());
}
for (var i = 0; i < raw_data.length; ++i) {
for (var j = 1; j < raw_data[i].length; ++j) {
data.setValue(j-1, i+1, raw_data[i][j]);
}
}
// Create and draw the visualization.
new google.visualization.ColumnChart(document.getElementById('visualization')).
draw(data,
{
title:"Size of Mobile Metrics Code",
width: 800, height: 400,
vAxis: {
format: '#.##KB',
baseline: -2,
minValue: 0,
viewWindow: { min: -2 }
}
}
);
}
google.setOnLoadCallback(drawVisualization);
</script>
<div id="visualization" style="width: 800px; height: 400px;"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment