ehsannarmani / ComposeCharts

Animated & Flexible Practical Charts For Jetpack Compose
https://ehsannarmani.github.io/ComposeCharts/
Apache License 2.0
389 stars 25 forks source link

Is there a way to avoid this weird behavior when dynamically calculating data for the pie chart? #54

Open KevinMartinezC opened 2 days ago

KevinMartinezC commented 2 days ago

https://github.com/user-attachments/assets/9b9d27e5-48ee-4f55-95f2-4d34b0c4c65f

 PieChart(
            modifier =
            Modifier
                .align(Alignment.CenterHorizontally)
                .padding(AltaTheme.dimens.spacingSmall)
                .size(200.dp),
            data = data.reversed(),
            onPieClick = {
                println("${it.label} Clicked")
                val pieIndex = data.indexOf(it)
                data = data.mapIndexed { mapIndex, pie -> pie.copy(selected = pieIndex == mapIndex) }
            },
            selectedScale = 1f,
            scaleAnimEnterSpec = spring<Float>(
                dampingRatio = Spring.DampingRatioMediumBouncy,
                stiffness = Spring.StiffnessHigh
            ),
            colorAnimEnterSpec = tween(0),
            colorAnimExitSpec = tween(0),
            scaleAnimExitSpec = tween(0),
            spaceDegreeAnimExitSpec = tween(0),
            spaceDegree = 0f,
            selectedPaddingDegree = 0f,
            style = Pie.Style.Stroke(
                width = 60.dp
            )
        )
ehsannarmani commented 2 days ago

Hi @KevinMartinezC , put the data in remember and check again.

KevinMartinezC commented 2 days ago

yes, i already had my data using a remember and get that behavior

ehsannarmani commented 1 day ago

It's weird, you are changing the data quickly?

KevinMartinezC commented 1 day ago

yes the data is changing quickly