项目作者: mahozad

项目描述 :
(WIP) Android library for drawing Pie charts and Donut charts
高级语言: Kotlin
项目地址: git://github.com/mahozad/android-pie-chart.git
创建时间: 2021-05-17T16:02:26Z
项目社区:https://github.com/mahozad/android-pie-chart

开源协议:Apache License 2.0

下载


Codecov
Latest Maven Central release
Kotlin

A Pie/Donut*/Ring chart for Android, customizable to the most extent possible.
For tutorial and examples refer to the website.



| Screenshot 1 | Screenshot 2 | Screenshot 3 | Screenshot 4 | Screenshot 5 |
|————————-|————————-|————————-|————————-|————————-|
| Screenshot 2 | Screenshot 1 | Screenshot 3 | Screenshot 4 | Screenshot 5 |

build.gradle[.kts]

  1. implementation("ir.mahozad.android:pie-chart:0.7.0")

XML layout

  1. <ir.mahozad.android.PieChart
  2. android:id="@+id/pieChart"
  3. android:layout_width="wrap_content"
  4. android:layout_height="wrap_content" ></ir.mahozad.android.PieChart>

Kotlin Activity

  1. val pieChart = findViewById<PieChart>(R.id.pieChart)
  2. pieChart.slices = listOf(
  3. PieChart.Slice(0.2f, Color.BLUE),
  4. PieChart.Slice(0.4f, Color.MAGENTA),
  5. PieChart.Slice(0.3f, Color.YELLOW),
  6. PieChart.Slice(0.1f, Color.CYAN)
  7. )

Jetpack Compose

  1. @Composable
  2. fun PieChartView() {
  3. AndroidView(
  4. modifier = Modifier.fillMaxSize(),
  5. factory = { context ->
  6. PieChart(context).apply {
  7. slices = listOf(
  8. PieChart.Slice(0.2f, Color.BLUE),
  9. PieChart.Slice(0.4f, Color.MAGENTA),
  10. PieChart.Slice(0.3f, Color.YELLOW),
  11. PieChart.Slice(0.1f, Color.CYAN)
  12. )
  13. }
  14. },
  15. update = { view ->
  16. // View's been inflated or state read in this block has been updated
  17. // Add logic here if necessary
  18. }
  19. )
  20. }

Contributing

Please help improve the library by fixing the issues that I couldn’t tackle myself.
Any other contributions are also welcome.


Or Doughnut*