Skip to content

Commit 5677eaa

Browse files
committed
Done for the day
1 parent d61d311 commit 5677eaa

File tree

4 files changed

+39
-35
lines changed

4 files changed

+39
-35
lines changed

code/chart.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
const ctx = document.getElementById('chart').getContext('2d')
33

44
//"Draw" the chart here 👇
5+
const drawChart = (repos) => {
6+
7+
58
const labels = [
69
'Compleated Projects',
710
'Remaining Projects',
@@ -13,7 +16,7 @@ const labels = [
1316
label: 'My First dataset',
1417
backgroundColor: ['#B6766D', '#F8E8DE'],
1518
borderColor: '#f7e9e7',
16-
data: [5, 1],
19+
data: [repos, 19-repos],
1720
}]
1821
};
1922

@@ -26,4 +29,6 @@ const labels = [
2629
const myChart = new Chart(
2730
document.getElementById('chart'),
2831
config
29-
);
32+
);
33+
34+
}

code/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
<!-- This will be used to draw the chart 👇 -->
2424

25-
<div class="chart-container">
26-
<canvas id="chart"></canvas>
27-
</div>
25+
<div id="canvas" class="chart-container">
26+
<canvas id="chart"></canvas>
27+
</div>
2828

2929

3030

code/script.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ fetch(API_USER, options)
7474

7575

7676
})
77-
getPullRequests(technigoRepositories)
77+
drawChart(technigoRepositories.length) // Calling the chart
78+
getPullRequests(technigoRepositories) // Calling the pull req and commits function
7879
})
7980

8081

@@ -88,24 +89,12 @@ const getPullRequests = (repos) => {
8889
.then(res => res.json())
8990
.then(data => {
9091
const commits = document.getElementById(`commit-${repo.name}`)
91-
//TODO
92-
//1. Find only the PR that you made by comparing pull.user.login
93-
// with repo.owner.login
92+
9493
const pulls = data.find((pull) => pull.user.login === repo.owner.login);
95-
// console.log(pulls)
96-
// commits.innerHTML += `
97-
// ${pulls.number}
98-
// `
94+
9995
fetchCommits(pulls.commits_url, repo.name)
10096
console.log(pulls.commits_url)
10197

102-
103-
104-
//2. Now you're able to get the commits for each repo by using
105-
// the commits_url as an argument to call another function
106-
107-
//3. You can also get the comments for each PR by calling
108-
// another function with the review_comments_url as argument
10998
})
11099
})
111100
}
@@ -119,4 +108,11 @@ const getPullRequests = (repos) => {
119108
document.getElementById(`commit-${myRepoName}`).innerHTML += data.length
120109

121110
})
122-
}
111+
}
112+
113+
// Center canvas/chart
114+
window.onload = window.onresize = function() {
115+
const canvas = document.getElementById('canvas');
116+
canvas.width = window.innerWidth * 0.8;
117+
canvas.height = window.innerHeight * 0.8;
118+
}

code/style.css

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ body {
1212
left: 100px;
1313
/* padding: 600px 800px; Utöka första vid fler reops */
1414
width: 90vw;
15-
height: 120rem;
15+
height: 230rem;
1616
background: linear-gradient(100deg, #f7e9e7, #B6766D);
1717
z-index: -1;
1818
}
@@ -129,13 +129,14 @@ a:visited, a:link {
129129
text-decoration: none;
130130
}
131131

132-
/* .chart-container {
133-
width: 600px;
134-
height: auto;
135-
padding: 100px;
136-
border: 1px solid black;
137-
} */
138-
132+
.chart-container {
133+
position: absolute;
134+
left: 0;
135+
right: 0;
136+
margin:auto;
137+
width: 600px;
138+
139+
}
139140

140141
@keyframes colorChange {
141142
0% {background-color: #f7f1f0;}
@@ -157,8 +158,6 @@ a:visited, a:link {
157158
.myDiv {
158159
left: 0;
159160
width: 100vw;
160-
161-
162161
}
163162

164163
.container {
@@ -167,8 +166,6 @@ a:visited, a:link {
167166
align-items: center;
168167
justify-content: center;
169168
margin: 110px 0;
170-
171-
172169
}
173170

174171
.header {
@@ -195,6 +192,10 @@ a:visited, a:link {
195192
.header p {
196193
margin: 10px;
197194
}
195+
196+
.chart-container {
197+
width: 400px;
198+
}
198199
}
199200

200201
/* TABLET LANDSCAPE */
@@ -209,8 +210,6 @@ a:visited, a:link {
209210
.myDiv {
210211
left: 0;
211212
width: 100vw;;
212-
213-
214213
}
215214

216215
.container {
@@ -249,4 +248,8 @@ a:visited, a:link {
249248
.header p {
250249
margin: 10px;
251250
}
251+
252+
.chart-container {
253+
width: 600px;
254+
}
252255
}

0 commit comments

Comments
 (0)