Skip to content

Instantly share code, notes, and snippets.

@sivaprabug
Last active February 26, 2016 12:13
Show Gist options
  • Save sivaprabug/5442498 to your computer and use it in GitHub Desktop.
Save sivaprabug/5442498 to your computer and use it in GitHub Desktop.
Line Chart using google chart API in PHP
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'AIDMK', 'DMK','INC','CPI','CPI-M','PMK','MDMK','DMDK'],
['1977', 130, 48, 27, 5 , 12, 0 , 0, 0 ],
['1980', 129, 37, 31, 9 , 11, 0, 0, 0 ],
['1984', 132, 24, 61, 2 , 5, 0, 0, 0 ],
['1989', 27, 150, 26, 3 , 15, 0 , 0, 0 ] ,
['1991', 164, 2, 60, 1 , 1, 0 , 0, 0 ],
['1996', 4, 173, 0, 8 , 1 , 4 , 0, 0 ],
['2001', 132, 31, 7, 5 , 6 , 20, 0, 0 ],
['2006', 61, 96, 34, 6 , 9, 18, 6, 1 ],
['2011', 150, 23, 5, 9 , 10, 3, 0, 29 ]
]);
var options = {
title: 'Election Performance in Tamil Nadu Assembly 1977 to 2011'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<div id="chart_div" style="width: 1000px; height: 500px;"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment