Android library for drawing Pie charts and Donut charts with the ability to customize almost anything in it.

Overview

Release workflow Codecov Latest Maven Central release

Logo

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

build.gradle[.kts]

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

XML layout

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

Kotlin Activity

val pieChart = findViewById<PieChart>(R.id.pieChart)
pieChart.slices = listOf(
    PieChart.Slice(0.2f, Color.BLUE),
    PieChart.Slice(0.4f, Color.MAGENTA),
    PieChart.Slice(0.3f, Color.YELLOW),
    PieChart.Slice(0.1f, Color.CYAN)
)

Jetpack Compose

@Composable
fun PieChartView() {
    AndroidView(
        modifier = Modifier.fillMaxSize(),
        factory = { context ->
            PieChart(context).apply {
                slices = listOf(
                    PieChart.Slice(0.2f, Color.BLUE),
                    PieChart.Slice(0.4f, Color.MAGENTA),
                    PieChart.Slice(0.3f, Color.YELLOW),
                    PieChart.Slice(0.1f, Color.CYAN)
                )
            }
        },
        update = { view ->
            // View's been inflated or state read in this block has been updated
            // Add logic here if necessary
        }
    )
}

Screenshots

Screenshot 1 Screenshot 2 Screenshot 3 Screenshot 4 Screenshot 5
Screenshot 2 Screenshot 1 Screenshot 3 Screenshot 4 Screenshot 5

Contributing

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


* Or Doughnut

Comments
  • Provide extension properties for numbers as size

    Provide extension properties for numbers as size

    Replace different variables and functions to set a specific property of the chart in different units with extension properties on numbers like used in Jetpack Compose (source code).

    Example: 40.dp 12.px

    enhancement 
    opened by mahozad 0
  • Update the AGP and Gradle

    Update the AGP and Gradle

    Update Android Gradle Plugin to version 7.0.0, and Gradle to version 7.1.1, and Kotlin to version 1.5.21 and also update the Java compile version to 11

    see https://developer.android.com/studio/releases/gradle-plugin?buildsystem=cmake#java-11

    enhancement 
    opened by mahozad 0
  • Include commit SHAs that are related to a changelog entry beside that entry

    Include commit SHAs that are related to a changelog entry beside that entry

    Include issue number (if any) and commit hashes that a feature, bug, etc. refers to in the end of that changelog entry, like this:

    New features

    • Feature 1 (#0, a1b2c3d, ...)
    documentation publishing 
    opened by mahozad 0
  • Set up CI/CD for the project

    Set up CI/CD for the project

    Configure CI/CD for the library either with GitHub or with Travis CI (other tutorial 1, other tutorial 2).

    • [x] Update the ciManagement in publishing block of the build script
    • [x] Create and publish the test app APK in the GitHub release
    • [x] Add or update the badge for CI/CD in the main README
    • [x] Disable force push to prod branch in IntelliJ
    • [x] Disable force push to prod branch in GitHub
    publishing 
    opened by mahozad 0
  • Implement legends

    Implement legends

    Implement legends for the chart.

    • [x] legend, legendSize, icon, iconHeight, iconTint, iconTransparency, iconMargin, percent, percentSize, percentMargin
    • [x] Legends margin from the pie
    • [x] Margin between each legend
    • [x] Legends title
    • [x] Legend title margin
    • [x] Margin between lines if legends are so many that they constitute multiple lines
    • [x] Custom legend icon
    • [x] Box for legends
      • [x] Background color
      • [x] Box padding
      • [x] Box border
        • [x] Border thickness
        • [x] Border color
        • [x] Border shape (solid, dashed, ...)
        • [x] Border corner radius
    • [x] Property for aligning legend box in the view (center, start, end)

    At the very least these legends should be supported:

    • horizontal top
    • horizontal bottom
    • vertical left/start
    • vertical right/end
    • vertical in-hole
    feature 
    opened by mahozad 0
  • Add screenshot tests

    Add screenshot tests

    Use a library to add screenshot tests as acceptance tests to ensure the final appearance of the chart is appropriate.

    The two libraries defined below do not support running screenshot tests on Windows 10. Use them when/if they support Windows 10 (though it might be late to this because most of the library features will have been implemented by that time and writing tests afterwards may not be so useful). Refer to this issue for shot and this section for screenshot-tests-for-android to see if they have started to support Windows 10 or not.

    See this (note how it saves the images and compares them. Also note that it reads screenshots from the assets directory).

    Possible libraries:

    • https://medium.com/stepstone-tech/how-to-capture-screenshots-for-failed-ui-tests-9927eea6e1e4
    • https://github.com/square/spoon
    • https://github.com/rtyley/android-screenshot-lib
    • https://github.com/Karumi/Shot (example usage in a library could be found in samplelibrary subproject here)
    • https://github.com/facebook/screenshot-tests-for-android (https://jobandtalent.engineering/screenshot-testing-on-android-88da6c004cf0)

    Another solution:

    • https://proandroiddev.com/easy-ui-and-screenshot-testing-on-android-2b138f6d1eb8

    Can we use "Emulator Snapshots for test failures" available in newer versions of Android Studio?

    tests 
    opened by mahozad 0
  • Make unit test assertions more strict

    Make unit test assertions more strict

    In unit tests that compare floating point numbers, update the assertions to compare with 0.01 precision instead of current 1.

    This is because current comparisons may give false negative results, that is, pass when they should have failed.

    tests 
    opened by mahozad 0
  • Fix the javadoc artifact having no content in releases

    Fix the javadoc artifact having no content in releases

    The javadoc.jar artifact has no javadoc in it. For example, this javadoc for version 0.4.0 of the library.

    See this post and this post and this page and also dokka homepage for setting up kdoc in Android.

    Important

    If the docs cannot be generated offline, add this block of code to the build script:

    val dokka by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)
    dokka.configure<org.jetbrains.dokka.gradle.DokkaTask> {
        dokkaSourceSets {
            named("main") {
                noAndroidSdkLink.set(false)
            }
        }
    }
    

    See this and this and https://github.com/Kotlin/dokka/issues/1706 for more information about the noAndroidSdkLink property.

    bug documentation 
    opened by mahozad 0
  • Implement center label

    Implement center label

    Add ability to specify a label/icon in the center of the chart.

    The chart hole is not modified and may overlap with the center label/icon (because the user may want that behavior).

    It is up to the user to make sure the hole is big enough to accommodate the center label/icon, if he wants no overlap.

    feature 
    opened by mahozad 0
  • Automate publishing of the API documentation in the website

    Automate publishing of the API documentation in the website

    For each new version of the library, publish its KDoc files (i.e. content of the javadoc.jar) to the website (Git branch on GitHub) automatically (using a CI in GitHub Actions).

    NOTE

    Dokka supports Versioning plugin as stated in its website which aims to "provide users with ability to create a versioned documentation. Therefore, users of the documentation can view different versions of the documentation by going to the main page and change versions."

    documentation 
    opened by mahozad 0
  • Similar libraries

    Similar libraries

    https://github.com/data2viz/data2viz https://github.com/grafana/grafana https://github.com/apache/superset https://github.com/JetBrains/lets-plot https://github.com/AAChartModel/AAChartCore-Kotlin

    opened by mahozad 0
Releases(v0.7.0)
  • v0.7.0(Aug 31, 2021)

  • v0.6.2(Aug 25, 2021)

  • v0.6.1(Aug 22, 2021)

  • v0.6.0(Aug 21, 2021)

  • v0.5.0(Aug 1, 2021)

    This is a major release.

    New features

    • Legends (17d74f86 and other commits)
      Including properties and attributes for:
      • Legends automatic wrapping
      • Legends box (enable/disable, title, background, border, color, position, alignment)
      • Legends arrangement (horizontal/vertical)
      • Legends percentage (enable/disable, size, color)
      • Legends alignment
      • Legends icons (default icons, tint, height, margin from legend text)
    • Center label (5907b86d)
    • Center background (f88d28c5)

    Updates

    • Update some library dependencies (e9420e85)
    • Update Kotlin version (ce8cda52)

    Other

    • Fix empty javadoc jar by including dokka documentation in it (87195e51)

    All commits since version 0.4.0

    Source code(tar.gz)
    Source code(zip)
    showcase.apk(2.14 MB)
  • v0.4.0(Jul 4, 2021)

    This is a major release.

    New features

    • Outside inward circular label (3bad21df)
    • Outside outward circular label (3bad21df)
    • Attribute to change label icon tint for all slices (891f77be)

    Updates

    • Update androidx.core dependency (173eb33b)
    • Decrease default icon margin (e0724cb7)

    Removals

    • Remove unneeded library dependencies (820810fd)

    All commits since version 0.3.0

    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Jun 5, 2021)

    This is a major release.

    New features

    • Top and bottom placements for label icons (065b44aa)
    • Icon for outside label (065b44aa)
    • New label type NONE (cdbb69e6)
    • Attribute to change label icon placement for all slices (f2cd0152)

    Updates

    • Decrease default label font size (7c42e475)
    • PieChart::slices property is now immutable var instead of mutable val (53a3381c)

    All commits since version 0.2.0

    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(May 31, 2021)

    This is a major release.

    New features

    • Outside label (currently not supporting icon) (d5269dd9)
    • Outward Pointer for slices (d5269dd9)
    • Label icon for inside labels (7dffb164)
    • Properties for changing label colors (7c374cec)

    Updates

    • Attributes are now public to use in layouts (64a1f18d)

    All commits since version 0.1.0

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(May 23, 2021)

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

⚡ A powerful & easy to use chart library for Android ⚡ Charts is the iOS version of this library Table of Contents Quick Start Gradle Maven Documentat

Philipp Jahoda 36k Dec 31, 2022
Open-source native Android graph/chart framework includes line chart,stick chart,candlestick chart,pie chart,spider-web chart etc.

Welcome to Android-Charts Welcome to Android-Charts project page on github.com. We just moved from Google Code. Android-Charts is an open-source andro

limc.cn 813 Dec 20, 2022
A vector-drawing program in Kotlin and Java FX

Artist This is a vector-drawing program in Kotlin/Java FX. Your program will allow a user to select shapes to draw, set their properties, and draw the

Bruce Jin 2 Aug 9, 2022
AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.

AnyChart for Android AnyChart Android Charts is an amazing data visualization library for easily creating interactive charts in Android apps. It runs

AnyChart 2k Jan 4, 2023
Android Library to rapidly develop attractive and insightful charts in android applications.

williamchart Williamchart is an Android Library to rapidly implement attractive and insightful charts in android applications. Note: WilliamChart v3 h

Diogo Bernardino 4.9k Dec 30, 2022
Android Library to rapidly develop attractive and insightful charts in android applications.

williamchart Williamchart is an Android Library to rapidly implement attractive and insightful charts in android applications. Note: WilliamChart v3 h

Diogo Bernardino 4.8k Dec 22, 2021
Charts/graphs library for Android compatible with API 8+, several chart types with support for scaling, scrolling and animations

HelloCharts for Android Charting library for Android compatible with API 8+(Android 2.2). Works best when hardware acceleration is available, so API 1

Leszek Wach 7.4k Jan 6, 2023
An android compose library with different Graphs and Charts

plot An android compose library with different Graphs and Charts (currently supports only Line graph, more types will be added soon) Download reposito

Madrapps 106 Dec 30, 2022
An open source library used to draw charts in Android with Jetpack Compose with a simple and easy to use

android-compose-charts This is an open source library used to draw charts in Android with Jetpack Compose with a simple and easy to use. Just couples

Mahmoud Ibrahim 17 Dec 31, 2022
An easy-to-use Android charts library with animation.

AndroidCharts A simple Android charts library. Known Uses in Pomotodo Including in Your Project Eclipse Import /AndroidCharts folder. Move /java folde

HackPlan 1.3k Jan 2, 2023
YBKChart is a library of 3D graphics charts for Android. 📊

YBKChart is a library of 3D graphics charts for Android. ?? For more information, see the Wiki. Chart List Pie Chart Download Use gradle. rep

ByungKwan Yun 10 Jun 19, 2022
Library for charts in android with animations

Charts Gradle Setup Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories: allprojects {

Ayush Saini 4 Dec 30, 2022
Straiberry Charts - An awesome Chart library for android

Straiberry Charts An awesome Chart library for android Straiberry · Report Bug · Request Feature Getting Started Adding dependecies Add it in your roo

StrAIberry 30 Dec 30, 2022
TChart - Simple and fast charts.

TChart - Simple and fast charts.

null 30 Sep 20, 2022
Simple Jetpack Compose Charts for multi-platform. Including Android, Web, Desktop.

compose-charts Simple Jetpack Compose Charts for multi-platform. Including Android, Web, Desktop. Graph Effects How to use? 1, show Pie Chart in Jetpa

Chen Pan 112 Jan 8, 2023
Simple Compose Charts for multi-platform. Including Android, Web, Desktop.

compose-charts-desktop Simple Compose Charts for multi-platform. Including Android, Web, Desktop. Compose multiplatform for Android: compose-charts. G

Chen Pan 13 Dec 30, 2022
Arc Chart View (Draw Creative Statistic Arc Charts)

ArcChartViewDemo You can use this library to draw Arc charts and show your statistics or anything you want or maybe get some ratings from user. you ca

Iman khoshabi 106 Nov 22, 2022