jeroenheijmans / advent-of-code-charts

Inject charts in your private leaderboard page for Advent of Code
MIT License
120 stars 21 forks source link

Chart max daily score rather than moment-wise score #57

Closed vvigilante closed 2 years ago

vvigilante commented 2 years ago

Hi, this is a "feature request". I mean, I implemented the feature for myself, so I put it here if anybody else wants it :D

Since there is one 2-part puzzle a day, the chart gets that staircase-like look that makes impossible to make out anything on it. In this janky change I only plot one point per day (the maximum)

Here it is, enjoy:

diff --git a/src/js/app.js b/src/js/app.js
index 3897444..fddb283 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -1061,6 +1061,7 @@

         loadPointsOverTime(data) {
             let datasets = data.members.sort((a, b) => a.name.localeCompare(b.name)).map(m => {
+                var last_x = 0
                 return {
                     label: m.name,
                     lineTension: 0.2,
@@ -1068,7 +1069,14 @@
                     borderWidth: 1.5,
                     borderColor: m.color,
                     backgroundColor: m.color,
-                    data: m.stars.map(s => {
+                    data: m.stars.filter(s => {
+                        var x = Math.trunc(s.getStarMoment / 1000 / 3600 / 24 )*3600*24*1000;
+                        if (x== last_x){
+                            return false;
+                        }
+                        last_x = x;
+                        return true;
+                    }).map(s => {
                         return {
                             x: s.getStarMoment,
                             y: s.nrOfPointsAfterThisOne,
jeroenheijmans commented 2 years ago

Thanks for sharing this suggestion! I'll have a peek later (or possibly, just before 2022 event) because I agree that this might be useful for more folks.

Happy puzzling!

jeroenheijmans commented 2 years ago

Cheers again for this! I added a commit which I hope simplifies this without breaking anything. I'll have to see when i can release it because releasing browser extensions is a rather inovlved process :'(