Speed up sparklines when larger periods are selected and improve detection of trends as well as fix comparison of dates
opened this Pull Request on December 10th 2022
fix #20066 when selecting currently eg a date range of 2 years it can take 2 minutes to load. Instead, we select 24 months which takes 2 seconds and allows the detection of trends much better.
When now selecting a range of 6+ months Matomo will plot weeks in the sparklines
When now selecting a range of 24+ months Matomo will plot months in the sparklines
Fix sparklines when comparing dates. Eg when you compared year vs previous year, then Matomo would load the previous 9 years in days (3000+days) and compared it to 1 year entry. It's completely broken visually and also performance wise it takes forever to load. Now no matter what period is selected, it will behave consistently and compare the selected dates. Eg when a year is compared to previous year, then we're showing the weeks of the first year and also plot the years of the second year so you can compare both years in detail. When comparing, selecting eg the previous 30 periods and comparing them is not as useful (although it can be).
--> Right now without this change comparing any date of a week, month or year is basically broken as the sparklines never load.
--> It now also makes the sparklines behavior consistent with the evolution graph.
We're now showing tooltips when possible to describe what date range and period the sparkline is showing. Before this was never clear eg when a year is selected, it's not obvious if Matomo is showing the months in that period or the previous years.
Changed the logic to have things tested and clearly defined and so the behaviour can be changed easily.
This PR does not change anything in the evolution graph.