Simple Android compose charts.

Overview

Compose Charts

This is an exploratory playground library to figure out how to Draw and animate using Android Jetpack Compose library. Currently this is using 1.0.1 library.

[Release] (https://jitpack.io/#tehras/charts)

How it looks:

How to use Pie Chart:

@Composable
fun MyChartParent() {
    PieChart(
        pieChartData = PieChartData(listOf(Slice(...), Slice(...),....)),
        // Optional properties.
        modifier = Modifier.fillMaxSize(),
        animation = simpleChartAnimation(),
        sliceDrawer = SimpleSliceDrawer()
    )
}

How to use Bar Chart:

@Composable
fun MyBarChartParent() {
    fun BarChart(
        barChartData = BarChartData(bars = listOf(Bar(label = "Bar Label", value = 100f, color = Color.Red)),
        // Optional properties.
        modifier = Modifier.fillMaxSize(),
        animation = simpleChartAnimation(),
        barDrawer = SimpleBarDrawer(),
        xAxisDrawer = SimpleXAxisDrawer(),
        yAxisDrawer = SimpleYAxisDrawer(),
        labelDrawer = SimpleValueDrawer()
    ) 
}

How to use Line Chart:

@Composable
fun MyLineChartParent() {
    LineChart(
        lineChartData = LineChartData(points = listOf(LineChartData.Point(1f,"Label 1"), ...)),
        // Optional properties.
        modifier = Modifier.fillMaxSize(),
        animation = simpleChartAnimation(),
        pointDrawer = FilledCircularPointDrawer(),
        lineDrawer = SolidLineDrawer(),
        xAxisDrawer = SimpleXAxisDrawer(),
        yAxisDrawer = SimpleYAxisDrawer(),
        horizontalOffset = 5f
    )
}

License

Copyright 2020 Taras Koshkin.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • compose chart for desktop in intelliJ IDEA

    compose chart for desktop in intelliJ IDEA

    Please help me for add implementation for compose chart desktop in my project intelliJ. I want to add charts(bar & pie) to compose desktop project.

    opened by momeni1367 2
  • Unable to integrate this library in my Compose Desktop project

    Unable to integrate this library in my Compose Desktop project

    Hello,

    I am looking for a library to display graphics in my Compose Desktop application. I came across yours, so I tried to integrate it as shown here.

    But when I run the gradle runDistributable task, I get this error:

    Execution failed for task ':compileKotlin'.
    > Could not resolve all files for configuration ':compileClasspath'.
       > Could not find com.github.tehras:charts:Tag.
         Searched in the following locations:
           - https://repo.maven.apache.org/maven2/com/github/tehras/charts/Tag/charts-Tag.pom
           - https://maven.pkg.jetbrains.space/public/p/compose/dev/com/github/tehras/charts/Tag/charts-Tag.pom
           - https://jitpack.io/com/github/tehras/charts/Tag/charts-Tag.pom
           - https://dl.google.com/dl/android/maven2/com/github/tehras/charts/Tag/charts-Tag.pom
         Required by:
             project :
    
    Possible solution:
     - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
    

    Here is my build.gradle.kts:

    import org.jetbrains.compose.compose
    import org.jetbrains.compose.desktop.application.dsl.TargetFormat
    import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
    
    plugins {
        kotlin("jvm") version "1.5.21"
        id("org.jetbrains.compose") version "1.0.0-alpha4-build310"
    }
    
    group = "fr.genie23"
    version = "1.0.0"
    
    repositories {
        mavenCentral()
        maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
        maven("https://jitpack.io")
        google()
    }
    
    dependencies {
        implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.21")
        implementation(compose.desktop.currentOs)
        implementation("com.github.tehras:charts:Tag")
        implementation("org.apache.pdfbox:pdfbox:2.0.24")
        implementation("org.apache.pdfbox:fontbox:2.0.24")
        implementation("org.apache.pdfbox:jempbox:1.8.16")
        implementation("org.apache.pdfbox:xmpbox:2.0.24")
        implementation("org.apache.pdfbox:preflight:2.0.24")
        implementation("org.apache.pdfbox:pdfbox-tools:2.0.24")
        implementation("org.bouncycastle:bcprov-jdk15on:1.69")
        implementation("org.bouncycastle:bcmail-jdk15on:1.69")
        implementation("org.bouncycastle:bcpkix-jdk15on:1.69")
    }
    
    tasks.withType<KotlinCompile> {
        kotlinOptions.jvmTarget = "11"
    }
    
    tasks.withType<KotlinCompile>().configureEach {
        kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
    }
    
    tasks.register<Copy>("copyRelease") {
        group = "compose desktop"
        description = "Copy release builded executable into out folder."
        duplicatesStrategy = DuplicatesStrategy.INCLUDE
        from(
            "build/compose/binaries/main/deb",
            "build/compose/binaries/main/dmg",
            "build/compose/binaries/main/exe",
            "build/compose/binaries/main/rpm"
        )
        into("out")
    }
    
    compose.desktop {
        application {
            mainClass = "MainKt"
            nativeDistributions {
                packageName = "Free CoManagement"
                description = "Logiciel de fusion de documents PDF"
                targetFormats(TargetFormat.Dmg, TargetFormat.Exe, TargetFormat.Deb, TargetFormat.Rpm)
                windows {
                    iconFile.set(project.file("src/main/resources/icons/logo.64x64.ico"))
                    dirChooser = true
                    menuGroup = "Genie23.fr"
                }
                macOS {
                    iconFile.set(project.file("src/main/resources/icons/logo.64x64.icns"))
                }
                linux {
                    iconFile.set(project.file("src/main/resources/icons/logo.64x64.png"))
                    menuGroup = "Genie23.fr"
                }
            }
        }
    }
    
    opened by Genie23 2
  • Update to Compose 1.0.0-alpha03 and Kotlin 1.4.10

    Update to Compose 1.0.0-alpha03 and Kotlin 1.4.10

    This brings the repo up to date with the latest Compose version.

    The app runs on the emulator and looks just like how it did before upgrading so I think this is ok.

    opened by chadmorrow 2
  • Not able to add this library to project

    Not able to add this library to project

    I have been trying to add this library to my project and getting below error at the time of syncing the library. My project's Compose version is 1.0.0 and tehra's charts version used in my project is alpha-0.12.0

    org.gradle.internal.resolve.ModuleVersionNotFoundException: Cannot resolve external dependency org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.5.10 because no repositories are defined.

    opened by anilreddy-insert 1
  • Filled line charts

    Filled line charts

    Just an idea. I was trying to make my own charts in compose and took some inspiration from this library. I actually implemented a Line chart with a custom fill color/gradient. Is that something you have planned? Or I can try working on this with your library. This is how my chart looks (custom gradient fill with a dashed line):- Screenshot from 2021-03-16 01-10-53

    Though note that I am not allowing an x offset (only y offset within the lines) in my chart. So I am not sure how to handle the fill with an x offset (as you have in your example).

    opened by yashovardhan99 1
  • Update compose to 1.0.0-alpha11

    Update compose to 1.0.0-alpha11

    I've also updated Koltin version to 1.4.21-2 as this is required for 1.0.0-alpha11. I've also replaced the occurrences of onCommit, which is now deprecated, with DisposableEffect where appropriate. The Image composeable also now requires a contentDescription so I've added a basic description for all of them.

    opened by vanpra 1
  • Offset is unspecified exception

    Offset is unspecified exception

    java.lang.IllegalStateException: Offset is unspecified
    at androidx.compose.ui.geometry.Offset.getX-impl(Offset.kt:67)
    at com.github.tehras.charts.line.LineChartUtils$calculateLinePath$1$1$1.invoke(LineChartUtils.kt:127)
    at com.github.tehras.charts.line.LineChartUtils$calculateLinePath$1$1$1.invoke(LineChartUtils.kt:114)
    at com.github.tehras.charts.line.LineChartUtils.withProgress(LineChartUtils.kt:103)
    at com.github.tehras.charts.line.LineChartUtils.calculateLinePath(LineChartUtils.kt:114)
    at com.github.tehras.charts.line.LineChartKt.drawLine(LineChart.kt:152)
    at com.github.tehras.charts.line.LineChartKt.access$drawLine(LineChart.kt:1)
    at com.github.tehras.charts.line.LineChartKt$LineChart$6.invoke(LineChart.kt:124)
    at com.github.tehras.charts.line.LineChartKt$LineChart$6.invoke(LineChart.kt:71)
    at androidx.compose.ui.draw.DrawBackgroundModifier.draw(DrawModifier.kt:104)
    at androidx.compose.ui.node.BackwardsCompatNode.draw(BackwardsCompatNode.kt:381)
    at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:92)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:371)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:360)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:236)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:368)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:360)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:236)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:368)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:360)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:236)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:368)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:360)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:236)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:368)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:360)
    at androidx.compose.ui.node.LayoutNode.draw$ui_release(LayoutNode.kt:840)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:151)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:368)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:360)
    at androidx.compose.ui.node.LayoutNode.draw$ui_release(LayoutNode.kt:840)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:151)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:368)
    at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:58)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:397)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:396)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2139)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:130)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:126)
    at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
    at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:126)
    
    opened by GabrielGircenko 0
  • Applied Abraham's PRs, updated README and fixed few issues

    Applied Abraham's PRs, updated README and fixed few issues

    @tehras please add me as a maintainer and I will help you update this repository. If this PR is open when other's see it, go to my fork because I enabled it as a dependency and will continue to maintain it for everyone to use it.

    opened by GabrielGircenko 0
  • App: Fix hardcoded colors

    App: Fix hardcoded colors

    Some buttons used hardcoded black borders. I've replaced them with ButtonDefaults.outlinedBorder, which uses colors.onSurface. The stroke is less thick and opaque but I think it's better this way because it adheres to material design.

    This doesn't fix the hardcoded graph axis colors, which are declared in the library.

    Before: Screenshot_20210406-222554_charts

    After: image

    opened by noahjutz 0
  • Added LineShader for filling a line graph

    Added LineShader for filling a line graph

    • Added computation of fill path
    • Added interface - LineShader
    • Added 3 different implementations of Line Shader:-
      1. NoLineShader - For no line fill
      2. SolidLineShader - For filling the line graph with a single color
      3. GradientLineShader - For filling the line graph with a vertical gradient.

    This closes #14

    opened by yashovardhan99 0
  • onCommit is deprecated

    onCommit is deprecated

    I get this warning: Line 47: onCommit(V1, CommitScope.() -> Unit): Unit' is deprecated. DisposableEffect should be used instead. https://github.com/tehras/charts/blob/master/lib/line/src/main/java/com/github/tehras/charts/line/LineChart.kt

    opened by dbaroncelli 0
  •  java.lang.NoSuchMethodError: No interface method startRestartGroup(ILjava/lang/String;)Landroidx/compose/runtime/Composer; in class Landroidx/compose/runtime/Composer;

    java.lang.NoSuchMethodError: No interface method startRestartGroup(ILjava/lang/String;)Landroidx/compose/runtime/Composer; in class Landroidx/compose/runtime/Composer;

    I am having this error when I want to display a Bar Chart. Here it is my code using this repository:

    @Composable fun MyBarChartParent() { BarChart( barChartData = BarChartData( bars = listOf(BarChartData.Bar(label = "Bar Label", value = 100f, color = Color.Red)) ), // Optional properties. modifier = Modifier.fillMaxSize(), animation = simpleChartAnimation(), barDrawer = SimpleBarDrawer() ) }

    I have just used the sample BarChart code of the ReadME file

    bug good first issue 
    opened by ociler 0
  • java.lang.NoSuchFieldError: No field Fill of type Landroidx/compose/ui/graphics/PaintingStyle

    java.lang.NoSuchFieldError: No field Fill of type Landroidx/compose/ui/graphics/PaintingStyle

    App compiles, but crashes when tries to show the LineChart. I updated Compose version to 1.0.4, and still get it.

    java.lang.NoSuchFieldError: No field Stroke of type Landroidx/compose/ui/graphics/PaintingStyle; in class Landroidx/compose/ui/graphics/PaintingStyle; or its superclasses (declaration of 'androidx.compose.ui.graphics.PaintingStyle' appears in /data/app/~~1IClg3K24qqTN_iqrjdXRg==/es.jnsoft.whatweath-pLHYJOTf4GaonKm_ukZsTg==/base.apk) at com.github.tehras.charts.line.renderer.line.SolidLineDrawer.(SolidLineDrawer.kt:14) at com.github.tehras.charts.line.renderer.line.SolidLineDrawer.(Unknown Source:0) at com.github.tehras.charts.line.renderer.line.SolidLineDrawer.(SolidLineDrawer.kt:8)

    Edited:

    I meant, my project was using Compose 1.0.1, and had the same issue.

    bug good first issue 
    opened by Javicompi 6
  • Support for theming?

    Support for theming?

    Hi there, I think it'd be very helpful if the app could support theming, maybe just adding a default parameter to each chart type with the colors used inside?

    enhancement good first issue 
    opened by aballano 0
  • LineChart values column doesn't show exact values

    LineChart values column doesn't show exact values

    Hi there, thank you for the work in this lib, I've been using it for a bit and I noticed that the chart doesn't show the exact values for the points, at least with the ranges I'm using:

    I created a LineChart with default params as an example with 2 points: Data0 - 5500 and Data1 - 6000

    image

    As you can see the leyend on the left shows a range between 5400 and 6100, which is fine, but then for some reason, the values are unrounded.

    I'm not sure how's done at the moment, but it might need a bit of tweaking. I didn't have time to look into the source code, but if that would help please let me know where I can find the calculation for that so I might open a PR at some moment.

    opened by aballano 0
  • Bar chart animation starts from 0 when bar.value is updated

    Bar chart animation starts from 0 when bar.value is updated

    I have a bar chart with a bar set with bar.value = 100. Then when I update this value to 150 the following happens:

    From 100 it jumps to 0 and then animates back to 150.

    I'm looking for a way so that instead of jumping to 0 and then animating to 150 it animates from 100 to the next new value which in this case is 150.

    Is there a way to do this?

    opened by jcardama 2
Releases(0.2.2-alpha)
Owner
Taras Koshkin
Engineer @square
Taras Koshkin
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
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 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
TChart - Simple and fast charts.

TChart - Simple and fast charts.

null 30 Sep 20, 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
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
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
Donut is an Android library which helps you to easily create beautiful doughnut-like charts.

Doughnut-like graph view capable of displaying multiple datasets with assignable colors

Futured 509 Jan 3, 2023
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
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
Jetpack-linear-chart - A simple way to draw linear chart using Jetpack Compose

jetpack-linear-chart A simple way to draw linear chart using Jetpack Compose We

Bruno Gabriel dos Santos 8 Jan 4, 2023
Simple Line, Circle, Bar chart for Android

SimpleChart Simple Line, Circle, Bar chart for Android LineChart <com.aghajari.simplechart.LineChart android:id="@+id/line_chart" android:layo

AmirHosseinAghajari 5 Jul 28, 2022