Skip to content

Commit 0ffb520

Browse files
author
TereseClaesson
committed
Added a chart to display at my page,change the color i CSS and changed my structure in HTML
1 parent df420f1 commit 0ffb520

File tree

4 files changed

+32
-41
lines changed

4 files changed

+32
-41
lines changed

code/chart.js

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
11
//DOM-selector for the canvas 👇
2-
const ctx = document.getElementById('chart').getContext('2d')
2+
const ctx = document.getElementById('chart').getContext('2d');
33

44
//"Draw" the chart here 👇
5-
const myChart = new Chart(ctx, {
6-
type: 'bar',
7-
data: {
8-
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
9-
datasets: [{
10-
label: '# of Votes',
11-
data: [12, 19, 3, 5, 2, 3],
12-
backgroundColor: [
13-
'rgba(255, 99, 132, 0.2)',
14-
'rgba(54, 162, 235, 0.2)',
15-
'rgba(255, 206, 86, 0.2)',
16-
'rgba(75, 192, 192, 0.2)',
17-
'rgba(153, 102, 255, 0.2)',
18-
'rgba(255, 159, 64, 0.2)'
19-
],
20-
21-
borderColor: [
22-
'rgba(255, 99, 132, 1)',
23-
'rgba(54, 162, 235, 1)',
24-
'rgba(255, 206, 86, 1)',
25-
'rgba(75, 192, 192, 1)',
26-
'rgba(153, 102, 255, 1)',
27-
'rgba(255, 159, 64, 1)'
28-
],
29-
borderWidth: 1
30-
}]
31-
},
32-
options: {
33-
scales: {
34-
y: {
35-
beginAtZero: true
36-
}
37-
}
38-
}
39-
});
5+
const drawChart = (amount) => {
6+
const data = {
7+
labels: [
8+
'completed projects',
9+
'projects left'
10+
],
11+
datasets: [
12+
{
13+
backgroundColor: ['grey', 'black'],
14+
data: [amount, 19 - amount],
15+
hoverOffSet: 4,
16+
},
17+
],
18+
19+
};
20+
const config = {
21+
type: 'doughnut',
22+
data: data
23+
};
24+
const myChart = new Chart(ctx,config);
25+
26+
};
27+

code/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
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@3.7.1/dist/chart.min.js"></script>
910
</head>
1011
<body>
12+
<!-- This will be used to draw the chart 👇 -->
13+
<canvas id="chart" style="width: 100%; max-width: 400px; height: 100%; max-height: 200px;"></canvas>
1114
<h1>GitHub Tracker</h1>
1215
<h2>Projects:</h2>
1316
<main class="container" id="container">
@@ -19,10 +22,9 @@ <h2>Projects:</h2>
1922
</section>
2023
</main>
2124
<footer></footer>
22-
<!-- This will be used to draw the chart 👇 -->
23-
<canvas id="chart"></canvas>
24-
25-
<script src="./script.js"></script>
25+
2626
<script src="./chart.js"></script>
27+
<script src="./script.js"></script>
28+
2729
</body>
2830
</html>

code/script.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ fetch(API_URL_REPOS)
4141
commits(repo.commits_url, repo.name)
4242
});
4343
getPullRequest(forkedRepos);
44+
drawChart(forkedRepos.length);
4445
});
4546
}
4647

code/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
body {
2-
background: #FFECE9;
2+
background: #d5cac4;
33
}

0 commit comments

Comments
 (0)