ComposeCharts icon indicating copy to clipboard operation
ComposeCharts copied to clipboard

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

Open KevinMartinezC opened this issue 1 year ago • 4 comments

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
           )
       )

KevinMartinezC avatar Nov 29 '24 21:11 KevinMartinezC

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

ehsannarmani avatar Nov 29 '24 21:11 ehsannarmani

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

KevinMartinezC avatar Nov 29 '24 21:11 KevinMartinezC

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

ehsannarmani avatar Nov 30 '24 09:11 ehsannarmani

yes the data is changing quickly

KevinMartinezC avatar Nov 30 '24 23:11 KevinMartinezC