Skip to content

Instantly share code, notes, and snippets.

@ukiuni ukiuni/index.html forked from 71713/index.html
Last active Jan 22, 2016

Embed
What would you like to do?
<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
You can’t perform that action at this time.