This commit is contained in:
coco
2026-07-03 15:56:07 +08:00
commit caef23209c
5767 changed files with 1004268 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
### BarChart
To use the BarChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `BarChart` composable in your code:
```kotlin @Composable
fun BarChart(
dataCollection: ChartDataCollection,
modifier: Modifier = Modifier,
barSpacing: Dp = 8.dp,
padding: Dp = 16.dp,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
) {
// Implementation details...
}
```
or
```kotlin @Composable
fun BarChart(
dataCollection: ChartDataCollection,
modifier: Modifier = Modifier,
barSpacing: Dp = 8.dp,
padding: Dp = 16.dp,
barColor: Color = Color.Blue,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
){
// Implementation details...
}
```
In the above `BarChart`, we have `barColor` that will override the individual BarData's `color`
### Parameters
`BarChart` accepts the following parameters:
- `dataCollection`: A `ChartDataCollection` object representing the data to be displayed in the bar
chart.
- `modifier`: Optional `Modifier` to customize the appearance and behavior of the chart.
- `barSpacing`: Optional `Dp` value representing the spacing between bars in the chart. Default
is `8.dp`.
- `padding`: Optional `Dp` value representing the padding around the chart. Default is `16.dp`.
- `barColor`: Optional `Color` value representing the color of the bars in the chart. Default
is `Color.Blue`.
- `axisConfig`: Optional `AxisConfig` object representing the configuration of the chart axes.
Default is `ChartDefaults.axisConfigDefaults()`.
Where, AxisConfig looks like,
```kotlin
data class AxisConfig(
val showAxes: Boolean,
val showGridLines: Boolean,
val showGridLabel: Boolean,
val axisStroke: Float,
val minLabelCount: Int,
val axisColor: Color,
val gridColor: Color = axisColor.copy(alpha = 0.5F),
)
```
#### Copyright (c) 2023. Charty Contributor