fun ExpensesGraph(paddingValues: PaddingValues) {
    val db = FirebaseFirestore.getInstance()

    // Define your timeframes
    val timeFrames = listOf("Daily", "Weekly", "Monthly", "Yearly")
    val selectedIndex = remember { mutableStateOf(0) }

    // Fetch and process the expenses data
    val chartEntries = remember { mutableStateOf(entriesOf(*arrayOf<Float>())) }
    var chartModelProducer = ChartEntryModelProducer(chartEntries.value)

    var xAxisLabels = remember {
        mutableStateOf(listOf("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"))
    }

    var bottomAxisValueFormatter =
        AxisValueFormatter<AxisPosition.Horizontal.Bottom> { x, _ -> xAxisLabels.value[x.toInt() % xAxisLabels.value.size] }

    val expensesMap = mutableMapOf<String, Float>().apply {
        xAxisLabels.value.forEach { put(it, 0f) }
    }

    fun fetchExpensesData(timeFrame: String) {
        val startCalendar = Calendar.getInstance()
        val endCalendar = Calendar.getInstance()
        var dateFormat: SimpleDateFormat

        val query = db.collection("expenses")
            .document("Kantin")
            .collection(timeFrame.lowercase())

        startCalendar.firstDayOfWeek = Calendar.MONDAY
        endCalendar.firstDayOfWeek = Calendar.MONDAY

            when (timeFrame) {
                "Daily" -> {
                    // Daily: Showing 7 days in a week
                    startCalendar.set(Calendar.DAY_OF_WEEK, startCalendar.firstDayOfWeek)
                    startCalendar.set(Calendar.HOUR_OF_DAY, 0)
                    startCalendar.set(Calendar.MINUTE, 0)
                    startCalendar.set(Calendar.SECOND, 0)
                    startCalendar.set(Calendar.MILLISECOND, 0)

//                    endCalendar.set(Calendar.DAY_OF_WEEK, startCalendar.firstDayOfWeek + 2)
                    endCalendar.set(Calendar.DAY_OF_WEEK, startCalendar.firstDayOfWeek + 6)
                    endCalendar.set(Calendar.HOUR_OF_DAY, 23)
                    endCalendar.set(Calendar.MINUTE, 59)
                    endCalendar.set(Calendar.SECOND, 59)
                    endCalendar.set(Calendar.MILLISECOND, 999)
                    dateFormat = SimpleDateFormat("EEEE_dd_MMM_yyyy", Locale.getDefault())

                    val c = Calendar.getInstance()
                    c.time = startCalendar.time
                    val newLabels = mutableListOf<String>()

                    while (c.timeInMillis <= endCalendar.timeInMillis) {
                        newLabels.add(dateFormat.format(c.time))
                        c.add(Calendar.DATE, 1)
                    }
                    xAxisLabels.value = newLabels

                    bottomAxisValueFormatter =
                        AxisValueFormatter { x, _ -> xAxisLabels.value[x.toInt() % xAxisLabels.value.size] }

                    val startDocId = dateFormat.format(startCalendar.time)
                    val endDocId = dateFormat.format(endCalendar.time)
                    query.orderBy(FieldPath.documentId()).startAt(startDocId).endAt(endDocId)
                }

                "Weekly" -> {
                    // Weekly: Showing 4 weeks in a month
                    startCalendar.set(Calendar.DAY_OF_MONTH, 1)
                    startCalendar.set(Calendar.HOUR_OF_DAY, 0)
                    startCalendar.set(Calendar.MINUTE, 0)
                    startCalendar.set(Calendar.SECOND, 0)
                    startCalendar.set(Calendar.MILLISECOND, 0)

                    while (startCalendar.get(Calendar.DAY_OF_WEEK) != startCalendar.firstDayOfWeek) {
                        startCalendar.add(Calendar.DATE, +1)
                    }

                    endCalendar.time = startCalendar.time
                    endCalendar.add(Calendar.DATE, 3 * 7)
                    endCalendar.set(Calendar.HOUR_OF_DAY, 23)
                    endCalendar.set(Calendar.MINUTE, 59)
                    endCalendar.set(Calendar.SECOND, 59)
                    endCalendar.set(Calendar.MILLISECOND, 999)
                    dateFormat = SimpleDateFormat("W_MMM_yyyy", Locale.getDefault())
                    val weekDateFormat = SimpleDateFormat("d_MMM_yyyy", Locale.getDefault())

                    val c = Calendar.getInstance()
                    c.time = startCalendar.time
                    val newLabels = mutableListOf<String>()

                    var weekCounter = 1
                    while (c.timeInMillis <= endCalendar.timeInMillis) {
                        newLabels.add("Week $weekCounter")
                        weekCounter += 1
                    }
                    xAxisLabels.value = newLabels

//                    xAxisLabels.value = (1..4).map { "Week $it" }
                    bottomAxisValueFormatter =
                        AxisValueFormatter { x, _ -> xAxisLabels.value[x.toInt() % xAxisLabels.value.size] }

                    val startDocId = dateFormat.format(startCalendar.time)
                    val endDocId = dateFormat.format(endCalendar.time)
                    query.orderBy(FieldPath.documentId()).startAt(startDocId).endAt(endDocId)
                }

                "Monthly" -> {
                    // Monthly: Showing 12 months in a year
                    startCalendar.set(Calendar.MONTH, 0)
                    startCalendar.set(Calendar.DAY_OF_MONTH, 1)
                    startCalendar.set(Calendar.HOUR_OF_DAY, 0)
                    startCalendar.set(Calendar.MINUTE, 0)
                    startCalendar.set(Calendar.SECOND, 0)
                    startCalendar.set(Calendar.MILLISECOND, 0)
                    endCalendar.set(Calendar.MONTH, 11)
                    endCalendar.set(
                        Calendar.DAY_OF_MONTH,
                        endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH)
                    )
                    endCalendar.set(Calendar.HOUR_OF_DAY, 0)
                    endCalendar.set(Calendar.MINUTE, 0)
                    endCalendar.set(Calendar.SECOND, 0)
                    endCalendar.set(Calendar.MILLISECOND, 0)
                    dateFormat = SimpleDateFormat("MMM_yyyy", Locale.getDefault())

                    val c = Calendar.getInstance()
                    c.time = startCalendar.time
                    val newLabels = mutableListOf<String>()

                    while (c.timeInMillis <= endCalendar.timeInMillis) {
                        newLabels.add(dateFormat.format(c.time))
                        c.add(Calendar.DATE, 1)
                    }
                    xAxisLabels.value = newLabels

//                    xAxisLabels.value = listOf(
//                        "Jan",
//                        "Feb",
//                        "Mar",
//                        "Apr",
//                        "May",
//                        "June",
//                        "July",
//                        "Aug",
//                        "Sep",
//                        "Oct",
//                        "Nov",
//                        "Dec"
//                    )
                    bottomAxisValueFormatter =
                        AxisValueFormatter { x, _ -> xAxisLabels.value[x.toInt() % xAxisLabels.value.size] }

                    val startDocId = dateFormat.format(startCalendar.time)
                    val endDocId = dateFormat.format(endCalendar.time)
                    query.orderBy(FieldPath.documentId()).startAt(startDocId).endAt(endDocId)
                }

                "Yearly" -> {
                    startCalendar.set(Calendar.MONTH, 0)
                    startCalendar.set(Calendar.DAY_OF_MONTH, -1)
                    startCalendar.set(Calendar.HOUR_OF_DAY, 0)
                    startCalendar.set(Calendar.MINUTE, 0)
                    startCalendar.set(Calendar.SECOND, 0)
                    startCalendar.set(Calendar.MILLISECOND, 0)
                    endCalendar.set(Calendar.MONTH, 11)
                    endCalendar.set(Calendar.DAY_OF_MONTH, 31)
                    endCalendar.set(Calendar.HOUR_OF_DAY, 0)
                    endCalendar.set(Calendar.MINUTE, 0)
                    endCalendar.set(Calendar.SECOND, 0)
                    endCalendar.set(Calendar.MILLISECOND, 0)
                    dateFormat = SimpleDateFormat("yyyy", Locale.getDefault())

                    val startDocId = dateFormat.format(startCalendar.time)
                    val endDocId = dateFormat.format(endCalendar.time)
                    query.orderBy(FieldPath.documentId()).startAt(startDocId).endAt(endDocId)
                }

                else -> {
                    throw IllegalArgumentException("Unsupported time frame: $timeFrame")
                }
            }

        query.get().addOnSuccessListener { result ->
            val expenses = mutableListOf<Pair<Float, Date>>()
            for (document in result) {
                val total = document.getDouble("total")?.toFloat() ?: 0f
                val date = dateFormat.parse(document.id) ?: Date()
                if (date.time >= startCalendar.timeInMillis && date.time <= endCalendar.timeInMillis) {
                    expenses.add(total to date)
                }
            }

            val expensesMap = mutableMapOf<String, Float>().apply {
                xAxisLabels.value.forEach { put(it, 0f) }
            }

            expenses.groupBy({ dateFormat.format(it.second) }, { it.first })
                .forEach { date, values ->
                    values.sum().let { expenseSum ->
                        expensesMap[date] = expensesMap.getOrDefault(date, 0f) + expenseSum
                    }
                }

            for (expense in expenses) {
                val dateFormatted = dateFormat.format(expense.second)
                expensesMap[dateFormatted] = expense.first
            }

            chartEntries.value =
                entriesOf(*expensesMap.entries.mapIndexed { index, (_, expense) -> index.toFloat() to expense }
                    .toTypedArray())
        }
    }

    LaunchedEffect(Unit) {
        fetchExpensesData(timeFrames[0])
    }

    Column(modifier = Modifier.padding(paddingValues)) {
        timeFrames.forEachIndexed { index, timeFrame ->
            Button(
                onClick = {
                    selectedIndex.value = index
                    fetchExpensesData(timeFrame)
                },
                colors = ButtonDefaults.buttonColors(
                    containerColor = if (selectedIndex.value == index) DarkGray else LightGray
                )
            ) {
                Text(timeFrame)
            }
        }
        val AXIS_VALUE_OVERRIDER_Y_FRACTION = 1.2f
        val axisValueOverrider =
            AxisValuesOverrider.adaptiveYValues(
                yFraction = AXIS_VALUE_OVERRIDER_Y_FRACTION,
                round = true
            )

        ProvideChartStyle(chartStyle = m3ChartStyle()) {
            Chart(
                chart = columnChart(
                    axisValuesOverrider = axisValueOverrider
                ),
                chartModelProducer = chartModelProducer,
                startAxis = startAxis(),
                bottomAxis = bottomAxis(
                    valueFormatter = bottomAxisValueFormatter
                ),
                marker = rememberMarker()
            )
        }
    }
}

why is my weekly graph showing Week1, Week2, Week3, Week4 and Week1, I only have 3_Apr_2023 in my firestore weekly timeframe, I want it to be mapped to Week1, Week2, Week3, and Week4 and only that