package com.zxhyis.toolss.ui.page.recentusage

import com.github.mikephil.charting.charts.BarLineChartBase
import com.github.mikephil.charting.formatter.ValueFormatter
import kotlin.time.Duration.Companion.hours
import kotlin.time.DurationUnit

class AppScreenValueFormatter(val char: BarLineChartBase<*>) : ValueFormatter() {

    private val timesPeriod = arrayOf(
        "00:00", "04:00", "08:00", "12:00", "16:00", "20:00",
    )

    /**
     * 根据数据的x值，获取下标label
     */
    override fun getFormattedValue(value: Float): String {
        return when (value) {
            0f -> timesPeriod[0]
            in 0f..4.hours.toLong(DurationUnit.MILLISECONDS).toFloat() -> timesPeriod[1]
            else -> ""
        }
    }

}