https://github.com/bytebeats/compose-charts
Simple Jetpack Compose Charts for multi-platform. Including Android, Web, Desktop.
https://github.com/bytebeats/compose-charts
bar-chart charts compose jetpack jetpack-compose line-chart pie-chart
Last synced: 5 months ago
JSON representation
Simple Jetpack Compose Charts for multi-platform. Including Android, Web, Desktop.
- Host: GitHub
- URL: https://github.com/bytebeats/compose-charts
- Owner: bytebeats
- License: mit
- Created: 2021-09-24T02:56:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-31T03:32:32.000Z (about 2 years ago)
- Last Synced: 2024-05-31T05:29:57.159Z (about 2 years ago)
- Topics: bar-chart, charts, compose, jetpack, jetpack-compose, line-chart, pie-chart
- Language: Kotlin
- Homepage:
- Size: 15.1 MB
- Stars: 142
- Watchers: 6
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# compose-charts
[](https://github.com/bytebeats/compose-charts/commit/)
[](https://github.com/bytebeats/compose-charts/graphs/contributors/)
[](https://github.com/bytebeats/compose-charts/issues/)
[](https://github.com/bytebeats/compose-charts/)
[](https://github.com/bytebeats/compose-charts/network/)
[](https://github.com/bytebeats/compose-charts/stargazers/)
[](https://github.com/bytebeats/compose-charts/watchers/)
Simple Jetpack Compose Charts for multi-platform. Including Android, Web, Desktop.
Compose Multiplatform for Desktop: [compose-charts-desktop](https://github.com/bytebeats/compose-charts-desktop).
**LATEST_VERSION**: 0.2.1
**COMPOSE_VERSION**: 1.6.7
**KOTLIN_VERSION**: 1.9.24
## Graph Effects



## How to use?
1. add maven and dependency:
1.1. add specific maven url in your root `build.gradle.kts`
```
repositories {
...
maven {
url = uri("https://repo1.maven.org/maven2/")
}
}
```
1.2. add dependency in your module `build.gradle.kts`
```
dependencies {
implementation("androidx.compose.ui:ui:$compose_version")
// implementation(project(":charts"))
implementation("io.github.bytebeats:compose-charts:${LATEST_VERSION}")
}
```
2. show Pie Chart in Jetpack Compose:
```
@Composable
fun PieChartView() {
PieChart(
pieChartData = PieChartData(
slices = listOf(
PieChartData.Slice(
randomLength(),
randomColor()
),
PieChartData.Slice(randomLength(), randomColor()),
PieChartData.Slice(randomLength(), randomColor())
)
),
// Optional properties.
modifier = Modifier.fillMaxSize(),
animation = simpleChartAnimation(),
sliceDrawer = SimpleSliceDrawer()
)
}
```
3. show Line Chart in Jetpack Compose:
```
@Composable
fun LineChartView() {
LineChart(
lineChartData = LineChartData(
points = listOf(
Point(randomYValue(), "Line 1"),
Point(randomYValue(), "Line 2"),
Point(randomYValue(), "Line 3"),
Point(randomYValue(), "Line 4"),
Point(randomYValue(), "Line 5"),
Point(randomYValue(), "Line 6"),
Point(randomYValue(), "Line 7")
)
),
// Optional properties.
modifier = Modifier.fillMaxSize(),
animation = simpleChartAnimation(),
pointDrawer = FilledCircularPointDrawer(),
lineDrawer = SolidLineDrawer(),
xAxisDrawer = SimpleXAxisDrawer(),
yAxisDrawer = SimpleYAxisDrawer(),
horizontalOffset = 5f
)
}
```
4. show Bar Chart in Jetpack Compose:
```
@Composable
fun BarChartView() {
BarChart(
barChartData = BarChartData(
bars = listOf(
BarChartData.Bar(
label = "Bar 1",
value = randomValue(),
color = randomColor()
),
BarChartData.Bar(
label = "Bar 2",
value = randomValue(),
color = randomColor()
),
BarChartData.Bar(
label = "Bar 3",
value = randomValue(),
color = randomColor()
),
BarChartData.Bar(
label = "Bar 4",
value = randomValue(),
color = randomColor()
),
)
),
// Optional properties.
modifier = Modifier.fillMaxSize(),
animation = simpleChartAnimation(),
barDrawer = SimpleBarDrawer(),
xAxisDrawer = SimpleXAxisDrawer(),
yAxisDrawer = SimpleYAxisDrawer(),
labelDrawer = SimpleLabelDrawer()
)
}
```
## Stargazers over time
[](https://starchart.cc/bytebeats/compose-charts)
## Github Stars Sparklines
[](https://stars.medv.io/bytebeats/compose-charts)
## Contributors
[](https://www.apiseven.com/en/contributor-graph?chart=contributorOverTime&repo=bytebeats/compose-charts)
## MIT License
Copyright (c) 2021 Chen Pan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.