ehsannarmani / ComposeCharts

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

Label Colors Not Correctly Displayed in RCChartLabelHelper #32

Closed tamtom closed 1 month ago

tamtom commented 1 month ago

Issue: The RCChartLabelHelper function does not correctly assign colors to all labels. the issue happens when first Bars does not contain all the labels in the sample app

@Composable
fun RowScope.ColumnSample2() {

    val data = remember {
        listOf(
            Bars(
                label = "Jan",
                values = listOf(
                    Bars.Data(
                        label = "Linux",
                        value = 50.0,
                        color = Brush.verticalGradient(
                            listOf(
                                Color(0xFFE65100),
                                Color(0xFFFFD54F),
                            )
                        )
                    ),
                    Bars.Data(
                        label = "Windows",
                        value = 100.0,
                        color = Brush.verticalGradient(
                            listOf(
                                Color(0xFF7E57C2),
                                Color(0xFF7986CB),
                            )
                        )
                    ),
                )
            ),
    Bars(
                label = "Feb",
                values = listOf(
                    Bars.Data(
                        label = "Linux",
                        value = 25.0,
                        color = Brush.verticalGradient(
                            listOf(
                                Color(0xFFE65100),
                                Color(0xFFFFD54F),
                            )
                        )
                    ),
                    Bars.Data(
                        label = "Windows",
                        value = 50.0,
                        color = Brush.verticalGradient(
                            listOf(
                                Color(0xFF7E57C2),
                                Color(0xFF7986CB),
                            )
                        )
                    ),
                    Bars.Data(
                        label = "Android",
                        value = 45.0,
                        color = Brush.verticalGradient(
                            listOf(
                                Color(0xFFB71C1C),
                                Color(0xFFEC407A),
                            )
                        )
                    ),
                )
            ),
            //..

I deleted Android from the bars causing this issue

Screenshot 2024-10-15 at 9 58 28 PM