-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add year to X axis of multi-year graph #2607
Conversation
Hey, @idfunctor 👋! Thanks for your contribution! If I understand correctly, your commit displays the year when period is "All time" or "Custom". If "Last 30 days" is selected and it's January, for example, two years will be returned and the year won't be displayed. To make this work in different scenarios without having to check each period, I think we would need to actually check the graph labels. The function that builds the X-axis of the graph is: // Pseudo-code warning :)
// Somewhere near assets/js/dashboard/stats/graph/visitor-graph.js:80
const yearsInGraph =
graphData.labels
.map(date => date.split('-')[0])
.filter((value, index, list) => list.indexOf(value) === index)
if (yearsInGraph.length > 1) {
return specialDateFormatterWithYear()
} Let me know your thoughts, and thanks again for your contribution! |
@vinibrsl Sorry for being MIA, had a lot going on last week. Thanks for clarifying how it should work, and yes I agree it should be done that way. I did try to see if I could derive a "hasMultipleYears" boolean from the code but for some reason I didn't spend much time trying to figure that out. The code you shared is sufficient for me to get it done now! I'll get on this sometime in the next 2-3 days and request your review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref: #2607 (comment)
No worries. Let me know if you need any help :) |
…ple years present in graph view
@vinibrsl I just pushed changes, again really sorry for the delay, lmk if anything else needs to be done |
BundleMonFiles updated (1)
Unchanged files (6)
Total files change +164B +0.02% Final result: ✅ View report in BundleMon website ➡️ |
Thank you! ✨ |
Changes
Please describe the changes made in the pull request here.
This PR solves Issue #2573
It checks if the period of the graph is "all" or "custom", as the other periods make it intuitive to understand what year the data belongs to. If the period is one of those 2, it prints the year on the entries of the X axis. Does so both for viewing by date and by week.
Below you'll find a checklist. For each item on the list, check one option and delete the other.
Tests
Changelog
Documentation
Dark mode