Skip to content

Instantly share code, notes, and snippets.

@nikitae
Created February 15, 2013 12:48
Show Gist options
  • Save nikitae/4960203 to your computer and use it in GitHub Desktop.
Save nikitae/4960203 to your computer and use it in GitHub Desktop.
Untitled
<html>
<head>
<title> Example Chart </title>
<script language="javascript" src="http://www.google.com/jsapi"></script>
</head>
<body>
<div id="chart"></div>
<script type="text/javascript">
var queryString = '';
var dataUrl = '';
function onLoadCallback() {
if (dataUrl.length > 0) {
var query = new google.visualization.Query(dataUrl);
query.setQuery(queryString);
query.send(handleQueryResponse);
} else {
var dataTable = new google.visualization.DataTable();
dataTable.addRows(8);
dataTable.addColumn('number');
dataTable.setValue(0, 0, 41.59678347641602);
dataTable.setValue(1, 0, 27.95341455930611);
dataTable.setValue(2, 0, 21.343014558806317);
dataTable.setValue(3, 0, 30.8511166513199);
dataTable.setValue(4, 0, 48.31288517671055);
dataTable.setValue(5, 0, 44.987110364309046);
dataTable.setValue(6, 0, 27.68451037190971);
dataTable.setValue(7, 0, 34.01339502306655);
draw(dataTable);
}
}
function draw(dataTable) {
var vis = new google.visualization.ImageChart(document.getElementById('chart'));
var options = {
chxl: '',
chxp: '',
chxr: '0,0,30',
chxs: '',
chxtc: '',
chxt: 'x',
chs: '700x225',
cht: 'ls',
chco: '000000',
chd: 's:ZRNTdbRV',
chdl: '',
chg: '14,-1,1,1',
chls: '3,4,0',
chm: 'B,FF9900CE,0,0,0|o,000000,0,-1,10.1'
};
vis.draw(dataTable, options);
}
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
draw(response.getDataTable());
}
google.load("visualization", "1", {packages:["imagechart"]});
google.setOnLoadCallback(onLoadCallback);
</script>
</body>
</html>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"html"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment