codeandtheory/YCharts

Not able to remove the extra space on the right of bar chart.

buddha-buktare opened this issue · 2 comments

As shown in the image, when the labels of the x-axis are less in number, I want to end the rendering of graph at the end of last label. But it is taking the full width. Modifier.wrapContentwidth() is not working.
PS. The red background is applied for the whole graph.

Screenshot 2023-12-12 at 4 37 54 PM

@buddha-buktare show me your code snippet.

@buddha-buktare show me your code snippet.

@lkant8

val barChartData = BarChartData(
            chartData = chartData,
            xAxisData = xAxisData,
            yAxisData = yAxisData,
            backgroundColor = Color.Transparent,
            barStyle = BarStyle(
                barWidth = barWidth,
                cornerRadius = 4.dp,
                paddingBetweenBars = paddingBetweenBars,
                selectionHighlightData = null,
            ),
            paddingEnd = 0.dp,
            drawBar = { drawScope, barChartData, drawOffset, height, barChartType, barStyle ->
                drawCustomBarGraph(
                    drawScope,
                    barChartData,
                    drawOffset,
                    height,
                    barChartType,
                    barStyle
                )
            }
        )

        Box(
            modifier = modifier,
            contentAlignment = Alignment.Center,
        ) {
            BarChart(
                modifier = Modifier
                    .height(300.dp)
                    .background(Color.White),
                barChartData = barChartData,
            )
        }