Skip to content

Commit 8e6d59f

Browse files
Weekly Hours Comparison Graph
- Removed topic hours pie chart (redundant information and also had a lot of problems with making it responsive) - Added the weekly comparison graph template. I like the graph idea way more.
1 parent 1fb3fd7 commit 8e6d59f

3 files changed

Lines changed: 43 additions & 26 deletions

File tree

src/graphTopics.js

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,58 @@ function getRandomNumber(min, max) {
77
}
88

99
function createTopicHoursGraph() {
10-
const topics = ['Topic 1', 'Topic 2', 'Topic 3', 'Topic 4', 'Topic 5'];
11-
const data = topics.map(() => getRandomNumber(10, 50));
10+
const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
11+
const previousWeekHours = days.map(() => getRandomNumber(0.5, 8));
12+
const currentWeekHours = days.map(() => getRandomNumber(0.5, 8));
1213

1314
return new Chart(ctxTopicHours, {
14-
type: 'doughnut',
15+
type: 'line',
1516
data: {
16-
labels: topics,
17+
labels: days,
1718
datasets: [{
18-
data: data,
19-
backgroundColor: [
20-
'rgba(255, 99, 132, 0.5)',
21-
'rgba(54, 162, 235, 0.5)',
22-
'rgba(255, 206, 86, 0.5)',
23-
'rgba(75, 192, 192, 0.5)',
24-
'rgba(153, 102, 255, 0.5)',
25-
],
26-
borderColor: [
27-
'rgba(255, 99, 132, 1)',
28-
'rgba(54, 162, 235, 1)',
29-
'rgba(255, 206, 86, 1)',
30-
'rgba(75, 192, 192, 1)',
31-
'rgba(153, 102, 255, 1)',
32-
],
33-
borderWidth: 1
19+
label: 'Previous Week',
20+
data: previousWeekHours,
21+
borderColor: 'rgba(169, 169, 169, 0.1)',
22+
backgroundColor: 'rgba(255, 99, 132, 0)',
23+
borderWidth: 2,
24+
fill: false // No fill under the line
25+
},
26+
{
27+
label: 'Current Week',
28+
data: currentWeekHours,
29+
borderColor: 'rgba(54, 162, 235, 1)',
30+
backgroundColor: 'rgba(54, 162, 235, 0)',
31+
borderWidth: 2,
32+
fill: false // No fill under the line
3433
}]
3534
},
3635
options: {
3736
plugins: {
38-
legend: {
39-
display: false,
37+
title: {
38+
display: true,
39+
text: 'Weekly Hours Comparison',
4040
},
41+
legend: {
42+
display: false // Hide legend
43+
}
4144
},
4245
maintainAspectRatio: false,
43-
responsive: false,
44-
},
46+
responsive: true,
47+
scales: {
48+
y: {
49+
display: true, // Display y-axis
50+
ticks: {
51+
stepSize: 1, // Step size for y-axis ticks
52+
font: {
53+
size: 12 // Adjust font size for y-axis ticks
54+
}
55+
}
56+
},
57+
x: {
58+
display: false // Hide x-axis
59+
}
60+
}
61+
}
4562
});
4663
}
4764

src/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ h1,h2,h3,h4,h5,h6 {
217217

218218
.bottom-grid {
219219
display: grid;
220-
grid-template-columns: 1fr 1fr auto;
220+
grid-template-columns: 1fr 1fr 1fr;
221221
grid-gap: 5px;
222222
overflow: hidden;
223223
}

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h3>10.5</h3>
8787
</div>
8888
<div class="bottom-right-graphs">
8989
<div class="container">
90-
<canvas id="topicHoursGraph" style="width: auto; height: 100%; align-self: center;"></canvas>
90+
<canvas id="topicHoursGraph"></canvas>
9191
</div>
9292
<div class="container">
9393
<canvas id="annualHoursGraph"></canvas>

0 commit comments

Comments
 (0)