In [1]:
import json
from collections import defaultdict
from datetime import datetime
import requests
from IPython.display import HTML
r = requests.get('https://api.github.com/repos/django/django/stats/commit_activity')
series = defaultdict(int)
monthname = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
for d in r.json():
month = datetime.fromtimestamp(d['week']).month
series[month] += d['total']
In [2]:
HTML('''
<div id="chart" style="width: 600px; height:400px;"></div>
<script>
require.config({
paths: {
echarts: '//cdn.bootcss.com/echarts/3.0.0/echarts.min',
}
});
require(['echarts'], function(ec) {
var myChart = ec.init(document.getElementById('chart'));
var option = {
title: {
text: 'Last Year of commit activity',
left: 'center'
},
subtitle: {
text: 'https://github.com/django/django',
},
xAxis: {
data: %s
},
yAxis: {},
series: [{
name: 'Commits',
type: 'line',
data: %s
}]
};
myChart.setOption(option);
});
</script>
''' % (monthname, series.values()))
Out[2]: