Skip to content

Instantly share code, notes, and snippets.

@71713
Last active January 22, 2016 01:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 71713/4a8b5515afde2c278e32 to your computer and use it in GitHub Desktop.
Save 71713/4a8b5515afde2c278e32 to your computer and use it in GitHub Desktop.
QiitaStockChecker
<html>
<head>
<title>QiitaStockChecker</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(setData);
var countStartQiitaId = 74479;
var QiitaAccount = "71713@github";
var data;
var TotalCount=0;
function setData() {
data = new google.visualization.DataTable();
data.addColumn('string', 'QiitaTitle');
data.addColumn('number', 'stock count');
var qiitaAPI = "https://qiita.com/api/v1/users/" + QiitaAccount + "/items"
$(function() {
$.getJSON(qiitaAPI, function(qiitaData) {
$.each(qiitaData,
function(i,v){
if(v.id >= countStartQiitaId){
data.addRow();
data.setValue(i, 0, v.title);
data.setValue(i, 1, parseInt(v.stock_count));
TotalCount += parseInt(v.stock_count);
}
});
});
});
}
function drawChart(importData) {
var options = {
title: QiitaAccount + '\'s Stock Count!!! Total count is : ' + TotalCount,
hAxis: {title: 'QiitaTitle', titleTextStyle: {color: 'skyblue'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(importData, options);
}
</script>
</head>
<body>
<input type="button" value="Make Graph" onClick="drawChart(data)">
<div id="chart_div" 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