File tree Expand file tree Collapse file tree 5 files changed +63
-2
lines changed
Expand file tree Collapse file tree 5 files changed +63
-2
lines changed Original file line number Diff line number Diff line change 1+ TODO:
2+
3+ 1) fetch the repos and console log them
4+ 2) get them in the browser
5+ 3) FILTHER OUT THE Technogo repos
6+ 4) test chart library
Original file line number Diff line number Diff line change 22const ctx = document . getElementById ( 'chart' ) . getContext ( '2d' )
33
44//"Draw" the chart here 👇
5+
6+ console . log ( 'chart is heart' )
7+
8+
9+
10+ const drawChart = ( amount ) => {
11+ const config = {
12+ type : 'doughnut' ,
13+ data : {
14+ labels : [
15+ 'Finished Projects' ,
16+ 'Projects Left'
17+ ] ,
18+ datasets : [ {
19+ label : 'My First Dataset' ,
20+ data : [ amount , 20 - amount ] ,
21+ backgroundColor : [
22+ 'rgb(255, 99, 132)' ,
23+ 'rgb(54, 162, 235)'
24+ ] ,
25+ hoverOffset : 4
26+ } ]
27+ } ,
28+ } ;
29+
30+ const myChart = new Chart ( ctx , config )
31+ }
Original file line number Diff line number Diff line change 66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
77 < title > Project GitHub Tracker</ title >
88 < link rel ="stylesheet " href ="./style.css " />
9+ < script src ="https://cdn.jsdelivr.net/npm/chart.js "> </ script >
910</ head >
1011< body >
1112 < h1 > GitHub Tracker</ h1 >
@@ -17,5 +18,7 @@ <h2>Projects:</h2>
1718
1819 < script src ="./script.js "> </ script >
1920 < script src ="./chart.js "> </ script >
21+ <!-- <script src="./token.js"></script> -->
22+
2023</ body >
2124</ html >
Original file line number Diff line number Diff line change 1+ const USER = 'silvertejp89'
2+ const REPOS_URL = `https://api.github.com/users/${ USER } /repos`
3+ const projectContainer = document . getElementById ( 'projects' )
4+
5+ const getRepos = ( ) => {
6+ fetch ( REPOS_URL )
7+ . then ( response => response . json ( ) )
8+ . then ( data => {
9+ console . log ( data ) //so we can see all the info
10+ // data.forEach(repo => console.log(repo.name)) //Only the names
11+ const forkedRepos = data . filter ( repo => repo . fork && repo . name . startsWith ( 'project-' ) ) //could be written as for example repo.fork ... === true (or false) but if you write nothing is true.
12+ forkedRepos . forEach ( repo => projectContainer . innerHTML += `<h3>${ repo . name } </h3>` )
13+ drawChart ( forkedRepos . length )
14+
15+ } )
16+ }
17+ getRepos ( ) //invoking it
18+
19+
20+
21+
22+
23+
24+
Original file line number Diff line number Diff line change 11body {
2- background : # FFECE9 ;
3- }
2+ background : # e9f3ff ;
3+ }
4+
You can’t perform that action at this time.
0 commit comments