How do I darken colors in a MPandroidchart pie chart in night mode?

215 Views Asked by At

I am creating an Andriod app with sqlite database. I am using MPandroidchart for data visualization. In the pie chart, I was able to tweak everything except the display of colors in the night theme. The colors in the legend are darkened as they would normally in night mode. But the colors on the donut are still vibrant. I just can't fix it. Who can help?

fun drawClientsChart(
    chart: PieChart,
    data: ArrayList<ListItemAnalyticClients>,
    withConsult: Boolean = false,
    withAnimation: Boolean = true
) {

    ...
    val hsv = FloatArray(3)
    hsv[1] = 0.5f // Saturation 0-1
    hsv[2] = 0.89f // Brightness 0-1

    for (i in 0 until data.size) {
        ...
        hsv[0] = (330 * i/data.size).toFloat()
        colors.add(Color.HSVToColor(hsv))
    }
    ...
    catsSet.colors = colors
    ...
    pieData.setValueTextColor(context.resources.getColor(R.color.white, context.theme))
    ...
    chart.setHoleColor(Color.TRANSPARENT)
    ...
}

Screenshots: day mode, night mode

0

There are 0 best solutions below