Skip to content

Show all weeks and months in charts regardless of data#164

Open
MARMdeveloper wants to merge 2 commits intomainfrom
feat/set-fixed-weeks-months-in-charts
Open

Show all weeks and months in charts regardless of data#164
MARMdeveloper wants to merge 2 commits intomainfrom
feat/set-fixed-weeks-months-in-charts

Conversation

@MARMdeveloper
Copy link
Collaborator

Description

Extends the fix from #110 to also display all weeks (Last 90 days filter) and all months (Last year filter) in the charts, even when there's no data for those periods.

Previously, only the daily filters (Today, Last 7 days, Last 30 days) showed all days including empty ones. Now weekly and monthly views maintain consistency by showing complete periods.

Problem

When filtering by "Last 90 days" or "Last year", weeks or months without charges/drives were not displayed in the chart, making it difficult to:

  • Identify periods of inactivity
  • Compare trends over time
  • Understand the complete timeline at a glance

Changes

Modified calculateChartData() in both ChargesViewModel and DrivesViewModel to:

For WEEKLY granularity:

  • Calculate the first day of the week for the start date
  • Generate all weeks within the range
  • Create data points with zero values for weeks without activity

For MONTHLY granularity:

  • Calculate the first day of the month for the start date
  • Generate all 12 months within the range
  • Create data points with zero values for months without activity

Changes

  • ChargesViewModel.kt: Updated calculateChartData() to handle WEEKLY and MONTHLY cases
  • DrivesViewModel.kt: Updated calculateChartData() to handle WEEKLY and MONTHLY cases

Before → After

Last 90 days:
W1: 5 charges          W1: 5 charges
W3: 2 charges    →     W2: 0 charges
W7: 1 charge           W3: 2 charges
                       W4-W6: 0 charges
                       W7: 1 charge
                       ...
                       W13: 0 charges

Related

@MARMdeveloper MARMdeveloper requested a review from vide February 13, 2026 10:07
It is useful when the car is not used for weeks or months to maintain the same graph when making comparisons.
@vide vide force-pushed the feat/set-fixed-weeks-months-in-charts branch from edc1171 to df6f908 Compare February 14, 2026 06:46
# Conflicts:
#	app/src/main/java/com/matedroid/ui/screens/charges/ChargesViewModel.kt
@MARMdeveloper
Copy link
Collaborator Author

Conflicts solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant