-
-
Save ukiuni/7cf34ac2540d1d45d5c6 to your computer and use it in GitHub Desktop.
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 = window.location.hash.substring(1); | |
var data; | |
var TotalCount=0; | |
function setData() { | |
if(!qiitaAccount){ | |
qiitaAccount = "71713@github"; | |
window.location.hash = qiitaAccount; | |
} | |
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); | |
} | |
}); | |
drawChart(data); | |
}); | |
}); | |
} | |
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> | |
<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