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
+45
View File
@@ -0,0 +1,45 @@
### AreaChart
To use the AreaChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `AreaChart` composable in your code:
```kotlin @Composable
fun AreaChart(
areaData: ComposeList<AreaData>,
modifier: Modifier = Modifier,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
padding: Dp = 16.dp,
) {
// Implementation details...
}
```
### Parameters
`AreaChart` accepts the following parameters:
- `areaData`: A `ComposeList` object representing the data to be displayed in area
chart.
- `modifier`: Optional `Modifier` to customize the appearance and behavior of the chart.
- `padding`: Optional `Dp` value representing the padding around the chart. Default is `16.dp`.
- `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
+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
+56
View File
@@ -0,0 +1,56 @@
### BubbleChart
To use the BubbleChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `BubbleChart` composable in your code:
```kotlin @Composable
fun BubbleChart(
dataCollection: ChartDataCollection,
modifier: Modifier = Modifier,
padding: Dp = 16.dp,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
chartColors: CurvedLineChartColors = CurvedLineChartDefaults.defaultColor(),
) {
// Implementation details...
}
```
### Parameters
`BubbleChart` accepts the following parameters:
- `dataCollection`: A `ChartDataCollection` object representing the data to be displayed in bubble
chart of type `BubbleData`.
- `modifier`: Optional `Modifier` to customize the appearance and behavior of the chart.
- `padding`: Optional `Dp` value representing the padding around the chart. Default is `16.dp`.
- `chartColors`: Optional `CurvedLineChartColors` value representing the color used in the chart.
where it looks like,
```kotlin
data class CurvedLineChartColors(
val dotColor: List<Color> = emptyList(),
val backgroundColors: List<Color> = emptyList(),
val contentColor: List<Color> = emptyList(),
)
```
- `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
+59
View File
@@ -0,0 +1,59 @@
### CandleStickChart
To use the CandleStickChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `CandleStickChart` composable in your code:
```kotlin @Composable
fun CandleStickChart(
candleData: ComposeList<CandleData>,
modifier: Modifier = Modifier,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
padding: Dp = 16.dp,
candleConfig: CandleStickConfig = CandleStickDefaults.defaultCandleStickConfig(),
) {
// Implementation details...
}
```
### Parameters
`CandleStickChart` accepts the following parameters:
- `candleData`: A `ComposeList` object representing the data to be displayed in CandleStickChart
of type `CandleData`.
- `modifier`: Optional `Modifier` to customize the appearance and behavior of the chart.
- `padding`: Optional `Dp` value representing the padding around the chart. Default is `16.dp`.
- `candleConfig`: Optional `CandleStickConfig` value representing the config used in the chart.
where it looks like,
```kotlin
@Immutable
data class CandleStickConfig(
val positiveColor: Color,
val negativeColor: Color,
val wickColor: Color,
val canCandleScale: Boolean,
val wickWidthScale: Float = 0.05f,
)
```
- `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
+51
View File
@@ -0,0 +1,51 @@
### CircleChart
To use the CircleChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `CircleChart` composable in your code:
```kotlin @Composable
fun CircleChart(
dataCollection: ChartDataCollection,
modifier: Modifier = Modifier,
canAnimate: Boolean = true,
textLabelTextConfig: CircleChartLabelTextConfig = CircleConfigDefaults.defaultTextLabelConfig(),
config: CircleChartConfig = CircleConfigDefaults.circleConfigDefaults(),
) {
// Implementation details...
}
```
### Parameters
`CircleChart` accepts the following parameters:
- `dataCollection`: A `ChartDataCollection` object representing the data to be displayed in CircleChart
of type `CircleData`.
- `modifier`: Optional `Modifier` to customize the appearance and behavior of the chart.
- `canAnimate`: Optional `Boolean` value representing if the chart should animate. Default is `true`.
- `textLabelTextConfig` : Optional `CircleChartLabelTextConfig` type parameter. Configuration for the text label that appears in the center of the chart. Default configuration can be accessed through `CircleConfigDefaults.defaultTextLabelConfig()`.
where, it looks like,
```kotlin
data class CircleChartLabelTextConfig(
val textSize: TextUnit,
val fontStyle: FontStyle? = null,
val fontWeight: FontWeight? = null,
val fontFamily: FontFamily? = null,
val indicatorSize: Dp = 10.dp,
val maxLine: Int = 1,
val overflow: TextOverflow = TextOverflow.Ellipsis
)
```
- `config`: Optional `CircleChartConfig` type parameter. Configuration for the circle chart appearance. Default configuration can be accessed through CircleConfigDefaults.circleConfigDefaults().
where, it looks like,
```kotlin
data class CircleChartConfig(
val startAngle: StartAngle = StartAngle.Zero,
val maxValue: Float?,
val showLabel: Boolean
)
```
#### Copyright (c) 2023. Charty Contributor
+73
View File
@@ -0,0 +1,73 @@
## CurveLineChart
The `CurveLineChart` is a composable function that displays a line chart with curved lines using the
Jetpack Compose framework. It is used to visualize data in a smooth curve format.
### Function Signature
```kotlin
@Composable
fun CurveLineChart(
dataCollection: ChartDataCollection,
modifier: Modifier = Modifier,
padding: Dp = 16.dp,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
radiusScale: Float = 0.02f,
lineConfig: LineConfig = LineChartDefaults.defaultConfig(),
chartColors: CurvedLineChartColors = CurvedLineChartDefaults.defaultColor(),
) {
//Implementation
}
```
### Parameters
- `dataCollection`: This parameter is of type `ChartDataCollection` and represents the data that
will be plotted on the chart. It contains a collection of `LineData`.
- `modifier`: This parameter is of type `Modifier` and is used to modify the appearance or behavior
of the chart.
- `padding`: This parameter is of type `Dp` and specifies the padding around the chart.
- `axisConfig`: This parameter is of type `AxisConfig` and is used to configure the appearance and
behavior of the chart axes.
- 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,
)
```
- `radiusScale`: This parameter is of type `Float` and determines the scale of the curve's radius.
It affects the curvature of the lines in the chart.
- `lineConfig`: This parameter is of type `LineConfig` and allows customization of the line
appearance.
- where, `LineConfig` looks like,
```kotlin
data class LineConfig(
val hasSmoothCurve: Boolean,
val hasDotMarker: Boolean,
val strokeSize: Float
)
```
- `chartColors`: This parameter is of type `CurvedLineChartColors` and It allows customization of
colors.
- where, `CurvedLineChartColors` looks like,
```kotlin
data class CurvedLineChartColors(
val dotColor: List<Color> = emptyList(),
val backgroundColors: List<Color> = emptyList(),
val contentColor: List<Color> = emptyList(),
)
```
#### Copyright (c) 2023. Charty Contributor
+47
View File
@@ -0,0 +1,47 @@
### GaugeChart
To use the GaugeChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `GaugeChart` composable in your code:
```kotlin @Composable
fun GaugeChart(
percentValue: Int,
modifier: Modifier = Modifier,
gaugeChartConfig: GaugeChartConfig = GaugeChartDefaults.gaugeConfigDefaults(),
needleConfig: NeedleConfig = GaugeChartDefaults.needleConfigDefaults(),
animated: Boolean = true,
animationSpec: AnimationSpec<Float> = tween(),
) {
// Implementation details...
}
```
### Parameters
- `percentValue`: `Int`
- The percentage value to be displayed on the gauge chart. Must be within the range of 1 to 100.
- `modifier`: `Modifier` (optional)
- Modifier to be applied to the chart layout.
- `gaugeChartConfig`: `GaugeChartConfig` (optional)
- Configuration for the gauge chart appearance. Default configuration can be accessed through `GaugeChartDefaults.gaugeConfigDefaults()`.
- Properties of `GaugeChartConfig`:
- `placeHolderColor`: `Color` - Color of the background arc of the chart. Default is `Color.LightGray`.
- `primaryColor`: `Color` - Color of the primary arc indicating the current value. Default is `Color.Blue`.
- `showNeedle`: `Boolean` - Specifies whether to show the needle indicating the current value. Default is `true`.
- `showIndicator`: `Boolean` - Specifies whether to show the minute hour dividers. Default is `true`.
- `indicatorColor`: `Color` - Color of the minute hour dividers. Default is `Color.Red`.
- `indicatorWidth`: `Dp` - Width of the minute hour dividers. Default is `2.dp`.
- `strokeWidth`: `Dp` - Width of the chart arcs. Default is `16.dp`.
- `needleConfig`: `NeedleConfig` (optional)
- Configuration for the needle appearance. Default configuration can be accessed through `GaugeChartDefaults.needleConfigDefaults()`.
- Properties of `NeedleConfig`:
- `color`: `Color` - Color of the needle. Default is `Color.Black`.
- `strokeWidth`: `Dp` - Width of the needle stroke. Default is `4.dp`.
- `animated`: `Boolean` (optional)
- Specifies whether the chart should animate when data changes. Default is `true`.
- `animationSpec`: `AnimationSpec<Float>` (optional)
- Animation specification for the chart animation. Default is `tween()`.
#### Copyright (c) 2023. Charty Contributor
+51
View File
@@ -0,0 +1,51 @@
## GroupedBarChart
To use the GroupedBarChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `GroupedBarChart` composable in your code:
### Function Signature
```kotlin
@Composable
fun GroupedBarChart(
groupBarDataCollection: ComposeList<GroupBarData>,
modifier: Modifier = Modifier,
padding: Dp = 16.dp,
barWidthRatio: Float = 0.8f,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
textLabelTextConfig: ChartyLabelTextConfig = ChartDefaults.defaultTextLabelConfig(),
) {
// Function body
}
```
### Parameters
- `groupBarDataCollection`: `ComposeList<GroupBarData>`
- A collection of `GroupBarData` objects representing the data for each group in the chart.
- `modifier`: `Modifier` (optional)
- Modifier to be applied to the chart layout.
- `padding`: `Dp` (optional)
- The padding around the chart. Default is `16.dp`.
- `barWidthRatio`: `Float` (optional)
- The ratio of the width of each bar to the total width available for each group. Must be within the range of 0.4f to 0.9f. The default value is `0.8f`, which provides a visually appealing view.
- `axisConfig`: `AxisConfig` (optional)
- Configuration for the chart's axis appearance. Default configuration can be accessed through `ChartDefaults.axisConfigDefaults()`.
- Properties of `AxisConfig`:
- `showAxes`: `Boolean` - Specifies whether to show the X and Y axes. Default is `true`.
- `axisColor`: `Color` - Color of the axes. Default is `Color.Black`.
- `axisStroke`: `Stroke` - Stroke configuration for the axes. Default is `Stroke(width = 2.dp.toPx())`.
- `showGridLines`: `Boolean` - Specifies whether to show the grid lines. Default is `true`.
- `showGridLabel`: `Boolean` - Specifies whether to show labels for the grid lines. Default is `true`.
- `textLabelTextConfig`: `ChartyLabelTextConfig` (optional)
- Configuration for the chart's label text appearance. Default configuration can be accessed through `ChartDefaults.defaultTextLabelConfig()`.
- Properties of `ChartyLabelTextConfig`:
- `textColor`: `Color` - Color of the label text. Default is `Color.Black`.
- `textSize`: `TextUnit` - Size of the label text. Default is `12.sp`.
- `fontStyle`: `FontStyle` - Style of the label text. Default is `FontStyle.Normal`.
- `textAlignment`: `TextAlign` - Alignment of the label text. Default is `TextAlign.Center`.
#### Copyright (c) 2023. Charty Contributor
+67
View File
@@ -0,0 +1,67 @@
### LineChart
To use the LineChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `LineChart` composable in your code:
### Function Signature
```kotlin
@Composable
fun LineChart(
dataCollection: ChartDataCollection,
modifier: Modifier = Modifier,
padding: Dp = 16.dp,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
radiusScale: Float = 0.02f,
lineConfig: LineConfig = LineChartDefaults.defaultConfig(),
chartColors: LineChartColors = LineChartDefaults.defaultColor(),
) {
//Implementation
}
```
### Parameters
- `dataCollection`: This parameter is of type `ChartDataCollection` and represents the data that
will be plotted on the chart. It contains a collection of `LineData`.
- `modifier`: This parameter is of type `Modifier` and is used to modify the appearance or behavior
of the chart.
- `padding`: This parameter is of type `Dp` and specifies the padding around the chart.
- `axisConfig`: This parameter is of type `AxisConfig` and is used to configure the appearance and
behavior of the chart axes.
- `radiusScale`: This parameter is of type `Float` and determines the scale of the dot's radius. It
affects the size of the data points in the chart.
- `lineConfig`: This parameter is of type `LineConfig` and allows customization of the line
appearance.
- `chartColors`: This parameter is of type `LineChartColors` and provides a set of default colors
for the chart components.
## LineChart (Alternate Signature)
```kotlin
@Composable
fun LineChart(
dataCollection: ChartDataCollection,
dotColor: Color,
lineColor: Color,
modifier: Modifier = Modifier,
backgroundColor: Color = Color.White,
padding: Dp = 16.dp,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
lineConfig: LineConfig = LineChartDefaults.defaultConfig(),
radiusScale: Float = 0.02f,
) {
//Implementation
}
```
### Additional Parameters
- `dotColor`: This parameter is of type `Color` and represents the color of the data points (dots) on the chart.
- `lineColor`: This parameter is of type `Color` and represents the color of the lines connecting the data points.
#### Copyright (c) 2023. Charty Contributor
+33
View File
@@ -0,0 +1,33 @@
### PieChart
To use the PieChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `PieChart` composable in your code:
```kotlin
@Composable
fun PieChart(
dataCollection: ChartDataCollection,
modifier: Modifier = Modifier,
textLabelTextConfig: ChartyLabelTextConfig = ChartDefaults.defaultTextLabelConfig(),
pieChartConfig: PieChartConfig = PieChartDefaults.defaultConfig(),
)
```
### Parameters
- `dataCollection`: This parameter is of type `ChartDataCollection` and represents the data that will be plotted on the chart. It contains a collection of `PieData`.
- `modifier`: This parameter is of type `Modifier` and is used to modify the appearance or behavior of the chart.
- `textLabelTextConfig`: This parameter is of type `ChartyLabelTextConfig` and allows customization of the labels displayed inside the chart. It provides options to configure the text appearance, such as color, size, and style.
- `pieChartConfig`: This parameter is of type `PieChartConfig` and allows customization of the pie chart appearance and behavior.It looks like,
```kotlin
data class PieChartConfig(
val donut: Boolean,
val showLabel: Boolean,
val startAngle: StartAngle = StartAngle.Zero
)
```
#### Copyright (c) 2023. Charty Contributor
+61
View File
@@ -0,0 +1,61 @@
### PointChart
To use the PointChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `PointChart` composable in your code:
### Function Signature
```kotlin
@Composable
fun PointChart(
pointData: ChartDataCollection,
contentColor: Color,
modifier: Modifier = Modifier,
backgroundColor: Color = Color.White,
padding: Dp = 16.dp,
pointType: PointType = PointType.Stroke(),
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
radiusScale: Float = 0.02f,
)
```
### Additional Function Signature
```kotlin
@Composable
fun PointChart(
dataCollection: ChartDataCollection,
modifier: Modifier = Modifier,
padding: Dp = 16.dp,
pointType: PointType = PointType.Stroke(),
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
radiusScale: Float = 0.02f,
chartColors: ChartColors = ChartDefaults.colorDefaults(),
)
```
### Parameters
- `dataCollection`: This parameter is of type `ChartDataCollection` and represents the data that
will be plotted on the chart. It contains a collection of `PointData`.
- `modifier`: This parameter is of type `Modifier` and is used to modify the appearance or behavior
of the chart.
- `backgroundColor`: This parameter is of type `Color` and represents the background color of the
chart. The default value is `Color.White`.
- `padding`: This parameter is of type `Dp` and represents the padding around the chart. The default
value is `16.dp`.
- `pointType`: This parameter is of type `PointType` and represents the type of point rendering on
the chart. It can be either `PointType.Stroke()` (hollow points) or `PointType.Fill()` (filled
points). The default value is `PointType.Stroke()`.
- `axisConfig`: This parameter is of type `AxisConfig` and allows customization of the axis
appearance and labels on the chart. The default value is `ChartDefaults.axisConfigDefaults()`.
- `radiusScale`: This parameter is of type `Float` and represents the scale factor for the radius of
the data points on the chart. The default value is `0.02f`.
- `contentColor`: This parameter is of type `Color`.
- `chartColors`: This parameter is of type `ChartColors` and allows customization of the chart's colors. The default value is `ChartDefaults.colorDefaults()`.
#### Copyright (c) 2023. Charty Contributor
+32
View File
@@ -0,0 +1,32 @@
### StackedBarChart
To use the StackedBarChart, follow the steps below:
- Include the Charty library in your Android project.
- Use the `StackedBarChart` composable in your code:
### Function Signature
```kotlin
@Composable
fun StackedBarChart(
stackBarData: ComposeList<StackBarData>,
modifier: Modifier = Modifier,
axisConfig: AxisConfig = ChartDefaults.axisConfigDefaults(),
padding: Dp = 16.dp,
spacing: Dp = 4.dp,
textLabelTextConfig: ChartyLabelTextConfig = ChartDefaults.defaultTextLabelConfig(),
)
```
### Parameters
- `stackBarData`: This parameter is of type `ComposeList<StackBarData>` and represents the data that will be plotted on the stacked bar chart. It contains a list of `StackBarData` objects.
- `modifier`: This parameter is of type `Modifier`.
- `axisConfig`: This parameter is of type `AxisConfig` and allows customization of the axis appearance and labels on the chart. It provides options to configure the axis color, stroke width, and label count, among others. The default value is `ChartDefaults.axisConfigDefaults()`.
- `padding`: This parameter is of type `Dp` and represents the padding around the chart. The default value is `16.dp`.
- `spacing`: This parameter is of type `Dp` and represents the spacing between the stacked bars. The default value is `4.dp`.
- `textLabelTextConfig`: This parameter is of type `ChartyLabelTextConfig` and allows customization of the text labels on the chart. The default value is `ChartDefaults.defaultTextLabelConfig()`.
#### Copyright (c) 2023. Charty Contributor