Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1eb6573

Browse files
committed
Show repo types pie chart on coder page
1 parent 953324f commit 1eb6573

File tree

4 files changed

+72
-3
lines changed

4 files changed

+72
-3
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# README
22

3-
Source files for [coderstats.net](https://coderstats.net/).
3+
Source files for [coderstats.net](https://coderstats.net/).
4+
5+
# GitHub API Calls
6+
7+
* https://api.github.com/search/issues?q=user:yaph&sort=created&order=desc
8+
* https://api.github.com/users/yaph/events/public
9+
* https://api.github.com/users/yaph/received_events/public

src/js/coder.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,36 @@ let coder = new Vue({
5757
forks: function() {
5858
return this.repoRanking('forks_count');
5959
},
60+
repo_types: function() {
61+
let labels = [];
62+
let values = [];
63+
let types = {
64+
active_sources: 0,
65+
archived: 0,
66+
disabled: 0,
67+
forked: 0,
68+
mirrors: 0
69+
};
70+
for (let repo of this.repos_pushed) {
71+
if (repo.archived)
72+
types.archived++;
73+
else if (repo.disabled)
74+
types.disabled++;
75+
else if (repo.fork)
76+
types.forked++;
77+
else if (repo.mirror)
78+
types.mirrors++;
79+
else
80+
types.active_sources++;
81+
}
82+
for (let [label, value] of Object.entries(types)) {
83+
if (value > 0) {
84+
labels.push(label);
85+
values.push(value);
86+
}
87+
}
88+
return {labels: labels, values: values};
89+
},
6090
stars: function() {
6191
return this.repoRanking('stargazers_count');
6292
},
@@ -99,6 +129,10 @@ let coder = new Vue({
99129
this.rankingGraph(this.issues.slice(0, 10), 'open_issues_count', '#issues-ranking');
100130
this.rankingGraph(this.forks.slice(0, 10), 'forks_count', '#forks-ranking');
101131
this.rankingGraph(this.stars.slice(0, 10), 'stargazers_count', '#stars-ranking');
132+
133+
new Chartist.Pie('#repo-types-chart', {
134+
labels: this.repo_types.labels.map(d => d.replace('_', ' ')),
135+
series: this.repo_types.values});
102136
},
103137
methods: {
104138
fetchRepos: function() {

src/scss/coder.scss

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,30 @@
3232
stroke: $color2;
3333
}
3434

35+
.ct-chart-pie {
36+
min-height: 250px;
37+
}
38+
39+
.ct-chart-pie .ct-label {
40+
fill: #222;
41+
}
42+
43+
.ct-series-a .ct-slice-pie {
44+
fill:rgb(141,211,199)
45+
}
46+
.ct-series-b .ct-slice-pie {
47+
fill:rgb(255,255,179)
48+
}
49+
.ct-series-c .ct-slice-pie {
50+
fill:rgb(190,186,218)
51+
}
52+
.ct-series-d .ct-slice-pie {
53+
fill:rgb(251,128,114)
54+
}
55+
.ct-series-e .ct-slice-pie {
56+
fill:rgb(128,177,211)
57+
}
58+
3559
.meta {
3660
background-color: $color4;
3761
}

templates/coder.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{% raw %}
2323
<div id="coder">
2424
<div v-if="user" class="row">
25-
<div class="col-12 col-2-xl col-2-l col-4-m meta">
25+
<div class="col-12 col-2-xl col-3-l col-4-m meta">
2626
<div class="padh">
2727
<header>
2828
<h3>{{ user.name }}</h3>
@@ -34,12 +34,17 @@ <h3>{{ user.name }}</h3>
3434
<span v-if="user.location" class="block"><i class="fa fa-globe" aria-hidden="true"></i> {{ user.location }}</span>
3535
<span v-if="user.company" class="block"><i class="fa fa-money" aria-hidden="true"></i> {{ user.company }}</span>
3636
<blockquote v-if="user.bio"><p>{{ user.bio }}</p></blockquote>
37+
38+
<div v-if="repo_types" class="padv">
39+
<h3>Repo types</h3>
40+
<div id="repo-types-chart"></div>
41+
</div>
3742
</div>
3843
</div>
3944
<div v-if="repos_pushed.length < 2" class="col-12 error">
4045
{{ user.name }} has not pushed changes to enough public repositories to show any interesting data here.
4146
</div>
42-
<div v-else class="col-12 col-10-xl col-10-l col-8-m no-padding main">
47+
<div v-else class="col-12 col-10-xl col-9-l col-8-m no-padding main">
4348
<div class="flex flex-wrap boxes">
4449
<div class="box-stat" title="The number of loaded repositories this user has pushed to.">
4550
<i class="fa fa-code" aria-hidden="true"></i> Pushed to repos

0 commit comments

Comments
 (0)