YCharts icon indicating copy to clipboard operation
YCharts copied to clipboard

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

Open buddha-buktare opened this issue 1 year ago • 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 avatar Dec 12 '23 11:12 buddha-buktare

@buddha-buktare show me your code snippet.

lkant8 avatar Dec 28 '23 10:12 lkant8

@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,
            )
        }

buddha-buktare avatar Jan 22 '24 08:01 buddha-buktare