Skip to content

Instantly share code, notes, and snippets.

@klei22
Last active March 15, 2018 03:15
Show Gist options
  • Select an option

  • Save klei22/1a88ba62a69939de727f8c9cda24cbfa to your computer and use it in GitHub Desktop.

Select an option

Save klei22/1a88ba62a69939de727f8c9cda24cbfa to your computer and use it in GitHub Desktop.
Lithium Energy Graph - Google Charts
<div id="chart_div" style="width: 900px; height: 500px;">
</div>
google.load("visualization", "1.1", {
packages: ["corechart"]
});
google.setOnLoadCallback(drawChart);
function drawChart() {
var transactions = [[0, 39, 10],
[12, 21, 7],
[13, 23, 7],
[14, 37, 6],
[15, 38, 6],
[16, 40, 6],
[17, 43, 5],
[18, 40, 8]];
var i=0,j=0;
var tps = transactions.slice(0);
for(i=0;i<tps.length;i++){
for(j=1;j<tps[i].length;j++){
tps[i][j]=tps[i][j]/1.0;
tps[i][j]=Number(tps[i][j].toFixed(2));
}
}
var data = new google.visualization.DataTable();
data.addColumn('number', 'Hour');
data.addColumn('number', 'Positive Tweets - 2018-03-14');
data.addColumn('number', 'Negative Tweets - 2018-03-14');
data.addRows(tps);
var options = {
title: 'Lithium Twitter Sentimental Analysis Percentage By Hour',
curveType: 'function',
pointSize: 5,
legend: {
position: 'right',
alignment: 'center'
},
hAxis: {
title: 'Hour'
},
vAxis: {
title: 'TPS'
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
<script src="https://www.google.com/jsapi"></script>
@klei22
Copy link
Author

klei22 commented Mar 15, 2018

Lithium Twitter Sentimental Analysis Percentage By Hour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment