File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,22 +10,21 @@ const drawChart = (amount) =>{
1010 labels : [
1111 'Completed Projects' ,
1212 'Remaining Projects' ,
13-
1413 ] ,
1514 datasets : [ {
1615 label : 'My First Dataset' ,
1716 data : [ amount , 24 - amount ] ,
1817 backgroundColor : [
1918 'rgb(255, 99, 132)' ,
20- 'rgb(54, 162, 235)' ,
19+ 'rgb(54, 162, 235)'
2120
2221 ] ,
2322 hoverOffset : 4
2423 } ]
25- }
24+ } ,
2625
27- }
28- const myChart = new Chart ( ctx , config ) ;
26+ } ;
27+ const myChart = new Chart ( ctx , config )
2928}
3029
3130
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ <h2>Projects:</h2>
1717 </ main >
1818
1919 <!-- This will be used to draw the chart 👇 -->
20- < canvas id ="chart " class ="chart "> </ canvas >
20+ < canvas id ="chart " class ="canvas- chart "> </ canvas >
2121
2222 < script src ="./script.js "> </ script >
2323 < script src ="./chart.js "> </ script >
Original file line number Diff line number Diff line change @@ -2,33 +2,27 @@ const USER = 'KaraHowes'
22const repoURL = `https://api.github.com/users/${ USER } /repos`
33const projectsContainer = document . getElementById ( 'projects' )
44
5-
6-
7- fetch ( repoURL )
8- . then ( ( response ) => {
9- return response . json ( )
10- } )
11- . then ( ( data ) => {
12- console . log ( data )
13- projectsContainer . innerHTML = `The name of your first project was ${ data [ 0 ] . name } `
5+ const getRepos = ( ) => {
6+
7+ fetch ( repoURL )
8+ . then ( response => response . json ( ) )
9+ . then ( data => {
10+ console . log ( data )
11+ //projectsContainer.innerHTML = `The name of your first project was ${data[0].name}`
12+
13+
14+ const forkedProjects = data . filter ( repo => repo . fork && repo . name . startsWith ( 'project-' ) )
15+ forkedProjects . forEach ( repo => projectsContainer . innerHTML += `<h3>${ repo . name } </h3>` )
1416
15- const forkedProjects = data . filter ( repo => repo . fork && repo . name . startsWith ( 'project-' ) )
17+ drawChart ( forkedProjects . length )
18+ console . log ( 'hello' , forkedProjects . length )
1619
17- forkedProjects . forEach ( ( forkName ) => {
18- projectsContainer . innerHTML += `<p>${ forkName . name } </p>`
19-
20- drawChart ( forkedProjects . length )
21- console . log ( 'hello' , forkedProjects . length )
22-
20+
21+
22+ }
2323
24- } )
24+
25+ )
2526}
2627
27- //repo.forEach((reponames) => {
28- //projects.innerHTML += `<p> Project name: ${reponames.name}</p>`
29- //});
30-
31-
32-
33- ) . catch ( ( error ) => console . error ( error ) )
34- . then ( ( ) => console . log ( 'Request finished' ) ) ;
28+ getRepos ( )
Original file line number Diff line number Diff line change 22 background-color : aquamarine;
33}
44
5- .chart {
6- max-width : 100 px ;
7- height : 300 px ;
5+ .canvas- chart {
6+ max-width : 500 px ;
7+
88}
You can’t perform that action at this time.
0 commit comments