Skip to content

Instantly share code, notes, and snippets.

@jweisman jweisman/chart.html
Last active Nov 21, 2016

Embed
What would you like to do?
Google Chart from Analytics API
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['corechart']}]}"></script>
<script>
google.setOnLoadCallback(drawChart);
function drawChart() {
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","https://api-na.hosted.exlibrisgroup.com/almaws/v1/analytics/reports?path=%2Fshared%2FAlma%2FFulfillment%2FReports%2FGeneral%20Circulation%20Statistics&apikey=[[APIKEY]]",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var rows = xmlDoc.getElementsByTagName("Row");
var data = new google.visualization.DataTable();
data.addColumn('string', 'Library');
data.addColumn('number', 'Loans');
for (var i = 0; i < rows.length; i++) {
data.addRow([
rows[i].getElementsByTagName("Column1")[0].childNodes[0].nodeValue,
parseInt(rows[i].getElementsByTagName("Column6")[0].childNodes[0].nodeValue)
]);
}
var options = {
title: 'Loans by Library',
is3D: true
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<h1>Student Portal</h1>
<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.