Last active
January 22, 2016 01:26
-
-
Save 71713/4a8b5515afde2c278e32 to your computer and use it in GitHub Desktop.
QiitaStockChecker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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