diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..58702a2e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +// .gitignore file +code/secret.js \ No newline at end of file diff --git a/README.md b/README.md index 1613a3b0..18e0a55c 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,19 @@ Replace this readme with your own information about your project. -Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. +This week we practiced on fetching API from github by extracting data from our forked Technigo repos. +We also learned how to use tokens and adding a chart with chart.js. ## The problem Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? +This time I learned to ask for help sooner than later since I got stuck with fetching pull requests inside a function. +The problem was solved by nesting the fetch of API for pull requests inside the first fetch. Another problem I encountered was not knowing how to use the tokens correctly and how to make Netlify show my index.html site. But after some added information in the notion page the problem was easily fixed! +If I had more time I would try to play around with API:s more and presenting the data with another chart. + ## View it live Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. + +https://dazzling-edison-30e09d.netlify.app/ diff --git a/code/chart.js b/code/chart.js index 92e85a30..e43e8646 100644 --- a/code/chart.js +++ b/code/chart.js @@ -1,4 +1,37 @@ //DOM-selector for the canvas 👇 const ctx = document.getElementById('chart').getContext('2d') -//"Draw" the chart here 👇 +// Creating a function which is invoked in js.file. +const showChart = (repos) => { + Chart.defaults.font.size = 18; + + const data = { + labels: ['Completed projects', 'Remaining projects'], + datasets: [{ + data: [repos, 19-repos], + backgroundColor: ['rgb(27, 20, 100)', 'rgb(255, 255, 0)'], + borderWidth: 2, + borderColor: 'rgb(27, 20, 100)', + hoverBorderWidth:3, + hoverBorderColor: 'rgb(27, 20, 100)', + }] + }; + + const config = { + type: 'doughnut', + data: data, + options: { + plugins: { + legend: { + display: true, + position: 'bottom', + labels: { + color: 'rgb(27, 20, 100)', + } + } + } + } + }; + + const myChart = new Chart(ctx, config); +} diff --git a/code/index.html b/code/index.html index 2fb5e0ae..36b66316 100644 --- a/code/index.html +++ b/code/index.html @@ -6,16 +6,24 @@