Skip to content

Commit

Permalink
Added 2021 year to bike chart
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasztyrala committed Nov 5, 2023
1 parent 9fd1258 commit 94d29a0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion js/chart.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Prepare the data
const currentYear = new Date().getFullYear();
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const distances2022 = [ 71, 141, 279, 318, 85, 365, 472, 497, 302, 276, 224, 157];
const distances2021 = [ 48, 43, 222, 178, 484, 444, 112, 450, 91, 141, 14, 131];
const distances2022 = [ 71, 141, 279, 318, 85, 365, 472, 497, 302, 276, 224, 157];
const distances2023 = [ 97, 100, 82, 275, 293, 270, 197, 272, 83, 255, 89, NaN];

// Data structure for uPlot
const data = [
months.map((m, i) => i), // Convert month names to indices
distances2021,
distances2022,
distances2023,
];
Expand All @@ -16,6 +18,13 @@ const options = {
height: 200,
series: [
{ value: (self, rawValue) => months[rawValue] }, // Assuming months are 0-indexed
{
label: "2021",
stroke: '#a1c0cc',
dash: [10,5],
width: 2,
value: (self, rawValue) => rawValue + ' km', // Append 'km' units to series values
},
{
label: "2022",
stroke: '#a1c0cc',
Expand Down

0 comments on commit 94d29a0

Please sign in to comment.