File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22const ctx = document . getElementById ( 'chart' ) . getContext ( '2d' )
33
44//"Draw" the chart here 👇
5+ const drawChart = ( amount ) => {
6+
7+
8+ const config = {
9+ type : 'doughnut' ,
10+ data : {
11+ labels : [
12+ 'Finished projects' ,
13+ 'Upcoming projects' ,
14+ 'Yellow'
15+ ] ,
16+ datasets : [ {
17+ label : 'My First Dataset' ,
18+ data : [ amount , 19 - amount ] ,
19+ backgroundColor : [
20+ 'rgb(255, 99, 132)' ,
21+ 'rgb(54, 162, 235)' ,
22+ 'rgb(255, 205, 86)'
23+ ] ,
24+ hoverOffset : 4
25+ } ]
26+ } ,
27+ } ;
28+
29+
30+ const projectsChart = 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 >
Original file line number Diff line number Diff line change 1+ const USER = 'hejmaria'
2+ const REPOS_URL = `http://api.github.com/users/${ USER } /repos`
3+
4+ const projectContainer = document . getElementById ( 'projects' )
5+
6+
7+
8+ const getRepos = ( ) => {
9+ fetch ( REPOS_URL )
10+ . then ( res => res . json ( ) )
11+ . then ( data => {
12+ console . log ( 'The data' , data )
13+ data . forEach ( repo => console . log ( repo . name ) )
14+ const forkedRepos = data . filter ( repo => repo . fork && repo . name . startsWith ( 'project-' ) )
15+ forkedRepos . forEach ( repo => console . log ( repo . name ) )
16+
17+ forkedRepos . forEach ( repo => projectContainer . innerHTML += `<h3>${ repo . name } </h3>` )
18+
19+ //make into a div or something to style them
20+ drawChart ( forkedRepos . length )
21+ } ) ;
22+
23+ }
24+
25+ getRepos ( ) ;
26+
27+ //const drawChart = (amoun
Original file line number Diff line number Diff line change 1+ const USER = 'hejmaria'
2+ const REPOS_URL = `http://api.github.com/users/${ USER } /repos`
3+
4+ const getRepos = ( ) => {
5+ fetch ( REPOS_URL )
6+ . then ( res => res . json ( ) )
7+ . then ( data => {
8+ console . log ( data )
9+ //data.forEach (repo => console.log(repo.name))
10+ const forkedRepos = data . fillter ( repo => repo . fork && repo . name . startsWith ( 'procet-' ) )
11+ forkedRepos . forEach ( repo => console . log ( repo . name ) )
12+ forkedRepos . forEach ( repo => projectsContainer . inneHTML += `<h3>${ repo . name } </h3>` )
13+ //make into a div or something to style them
14+ drawChart ( forkedRepos . length )
15+ } ) ;
16+
17+ }
18+
19+ const drawChart = ( amount ) =>
You can’t perform that action at this time.
0 commit comments