tehras / charts Goto Github PK
View Code? Open in Web Editor NEWSimple Android compose charts.
License: Apache License 2.0
Simple Android compose charts.
License: Apache License 2.0
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.
It would be nice to support Compose Multiplatform so this library can be used in Compose Web (wasm) and Desktop.
Any plans to do this?
I found the line chart couldn't show point in the correct position, for example I revise the line chart data to
var lineChartData by mutableStateOf(
LineChartData(
points = listOf(
Point(0.41163334f, "Label1"),
Point(0.3429857f, "Label2"),
Point(0.39720002f, "Label3"),
Point(0.0842f, "Label4")
),
lineDrawer = SolidLineDrawer(),
)
)
var lineChartData2 by mutableStateOf(
LineChartData(
points = listOf(
Point(0.003534f, "Label1"),
Point(0.000123f, "Label2"),
Point(0f, "Label3"),
Point(0f, "Label4")
),
lineDrawer = SolidLineDrawer(
color = Color(0xFF00FF00)
)
)
)
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
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.
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.
there have been some changes lately in Jetpack Compose,
which doesn't make this library work anymore
Hello good day, when I implement the library I have the next crash in android emulators
I have the following implementation
LineChart( linesChartData = listOf( LineChartData( points = homeModel?.report ?: listOf(), lineDrawer = SolidLineDrawer(), ) ), modifier = Modifier .fillMaxWidth() .height(250.dp) .padding(start = 54.dp, end = 16.dp), animation = simpleChartAnimation(), pointDrawer = FilledCircularPointDrawer(), horizontalOffset = 5f, )
Right now everything is in the DataModel, but that's a bad idea. What I should do is provide "drawer"s, so that anyone can pass in the implementation that they want.
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?
Would be nice if this library was published to maven central which is more reliable and easier to consume than jitpack.
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
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.
I am trying to add LineChart to my project and when I run it I get the error:
java.lang.IllegalStateException: Offset is unspecified
at androidx.compose.ui.geometry.Offset.getX-impl(Offset.kt:67)
at androidx.compose.ui.graphics.AndroidCanvas.drawCircle-9KIMszo(AndroidCanvas.android.kt:209)
at com.github.tehras.charts.line.renderer.point.FilledCircularPointDrawer.drawPoint-0AR0LA0(FilledCircularPointDrawer.kt:30)
at com.github.tehras.charts.line.LineChartKt$drawLine$1$1.invoke(LineChart.kt:175)
at com.github.tehras.charts.line.LineChartKt$drawLine$1$1.invoke(LineChart.kt:170)
at com.github.tehras.charts.line.LineChartUtils.withProgress(LineChartUtils.kt:104)
at com.github.tehras.charts.line.LineChartKt.drawLine(LineChart.kt:170)
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.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)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:120)
at androidx.compose.ui.node.NodeCoordinator.invoke(NodeCoordinator.kt:396)
at androidx.compose.ui.node.NodeCoordinator.invoke(NodeCoordinator.kt:58)
at androidx.compose.ui.platform.RenderNodeApi29.record(RenderNodeApi29.android.kt:180)
at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:298)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:1010)
at android.view.View.draw(View.java:22707)
at android.view.View.updateDisplayListIfDirty(View.java:21579)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
E/AndroidRuntime: at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4512)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4485)
at android.view.View.updateDisplayListIfDirty(View.java:21535)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:534)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:540)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:616)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4525)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4245)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3374)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2179)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8787)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1037)
at android.view.Choreographer.doCallbacks(Choreographer.java:845)
at android.view.Choreographer.doFrame(Choreographer.java:780)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
I have used the code in the example and I still get the same error
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
It would be nice to have an optional text label (inside chart) or legend (below chart) for the different slices of a PieChart, to be able to categorize them for the user.
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?
Been desperately trying to figure out how to use the labelValueFormatter for the SimpleYAxisDrawer, but I just can't seem to figure out how to use it. I have a value that is in seconds and I need to convert it to a string that's something like "1h 30m 23s", but there are no examples, samples, or documentation that I can find on how to use the label formatter. Could you please either post up an example here, or add it to the BarChart sample. I really need this feature. Thank you
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):-
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).
The line chart takes some hundred milliseconds to draw.
Is it a deliberate "animation", or it really takes that amount of time to draw?
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)
I am not able to run the project. It always giving me error
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"
}
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.