Skip to content

Instantly share code, notes, and snippets.

@sangheestyle
Last active December 30, 2015 18:28
Show Gist options
  • Save sangheestyle/7867428 to your computer and use it in GitHub Desktop.
Save sangheestyle/7867428 to your computer and use it in GitHub Desktop.
Scene: Official Twitter App for knowing mobile platform
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="//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 = google.visualization.arrayToDataTable([
['Platform', 'Nexus 5', 'Moto X', 'LG G2'],
['Twitter for Android', 69991, 21491, 17195],
['Twitter for iPhone', 19113, 5710, 4957],
['Twitter for iPad', 4509, 1044, 1049],
['Twitter for BlackBerry\xc2\xae', 3622, 4223, 1961],
['Twitter for Windows Phone', 1825, 598, 386],
]);
var nexus_5_data = google.visualization.arrayToDataTable([
['Platform', 'Nexus 5'],
['Twitter for Android', 69991],
['Twitter for iPhone', 19113],
['Twitter for iPad', 4509],
['Twitter for BlackBerry\xc2\xae', 3622],
['Twitter for Windows Phone', 1825],
]);
var moto_x_data = google.visualization.arrayToDataTable([
['Platform', 'Moto X',],
['Twitter for Android',21491],
['Twitter for iPhone',5710],
['Twitter for iPad',1044],
['Twitter for BlackBerry\xc2\xae',4223],
['Twitter for Windows Phone',598],
]);
var lg_g2_data = google.visualization.arrayToDataTable([
['Platform', 'LG G2'],
['Twitter for Android', 17195],
['Twitter for iPhone', 4957],
['Twitter for iPad', 1049],
['Twitter for BlackBerry\xc2\xae', 1961],
['Twitter for Windows Phone', 386],
]);
// Create and draw the visualization.
new google.visualization.BarChart(document.getElementById('visualization')).
draw(data,
{title:"Official Mobile App",
width:1000, height:400,
vAxis: {title: "Mobile Platform"},
hAxis: {title: "Tweets"}}
);
new google.visualization.PieChart(document.getElementById('visualization_nexus_5')).
draw(nexus_5_data,
{title:"Official Mobile App for Nexus 5",
width:1000, height:400,
is3D: true,
}
);
new google.visualization.PieChart(document.getElementById('visualization_moto_x')).
draw(moto_x_data,
{title:"Official Mobile App for Moto X",
width:1000, height:400,
is3D: true,
}
);
new google.visualization.PieChart(document.getElementById('visualization_lg_g2')).
draw(lg_g2_data,
{title:"Official Mobile App for LG G2",
width:1000, height:400,
is3D: true,
}
);
}
google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization" style="width: 600px; height: 400px;"></div>
<div id="visualization_nexus_5" style="width: 600px; height: 400px;"></div>
<div id="visualization_moto_x" style="width: 600px; height: 400px;"></div>
<div id="visualization_lg_g2" style="width: 600px; height: 400px;"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment