Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 9 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
# 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/v/tehras/charts.svg)]
(https://jitpack.io/#tehras/charts)

## Implementation:

build.gradle (app)
```groovy
dependecies {
implementation 'com.github.GabrielGircenko:charts:-SNAPSHOT'
}
```

settings.gradle
```
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io'}
}
```

## How it looks:

<img src="/assets/pie_chart.gif" width="200"> <img src="/assets/bar_chart.gif" width="200"> <img src="/assets/line_chart.gif" width="200">
Expand Down Expand Up @@ -49,15 +66,16 @@ fun MyBarChartParent() {
@Composable
fun MyLineChartParent() {
LineChart(
lineChartData = LineChartData(points = listOf(LineChartData.Point(1f,"Label 1"), ...)),
linesChartData = listOf(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
horizontalOffset = 5f,
labels = listOf("label 1" ...)
)
}
```
Expand Down
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ dependencies {
implementation(project(":lib:bar"))
implementation(project(":lib:line"))
}
android {
namespace = "com.github.tehras.charts"
}
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.tehras.charts">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand All @@ -9,7 +8,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Charts">
<activity android:name=".MainActivity">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.github.tehras.charts.ui.line
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
import com.github.tehras.charts.line.LineChartData
import com.github.tehras.charts.line.LineChartData.Point
import com.github.tehras.charts.line.renderer.line.SolidLineDrawer
import com.github.tehras.charts.line.renderer.point.FilledCircularPointDrawer
import com.github.tehras.charts.line.renderer.point.HollowCircularPointDrawer
import com.github.tehras.charts.line.renderer.point.NoPointDrawer
Expand All @@ -24,6 +26,21 @@ class LineChartDataModel {
Point(randomYValue(), "Label5"),
Point(randomYValue(), "Label6"),
Point(randomYValue(), "Label7")
),
lineDrawer = SolidLineDrawer(),
)
)

var lineChartData2 by mutableStateOf(
LineChartData(
points = listOf(
Point(randomYValue(), "Label1"),
Point(randomYValue(), "Label2"),
Point(randomYValue(), "Label3"),

),
lineDrawer = SolidLineDrawer(
color = Color(0xFF00FF00)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ fun LineChartRow(lineChartDataModel: LineChartDataModel) {
.height(250.dp)
.fillMaxWidth()
) {


LineChart(
lineChartData = lineChartDataModel.lineChartData,
linesChartData = listOf(lineChartDataModel.lineChartData, lineChartDataModel.lineChartData2),
horizontalOffset = lineChartDataModel.horizontalOffset,
pointDrawer = lineChartDataModel.pointDrawer
pointDrawer = lineChartDataModel.pointDrawer,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
dependencies {
classpath("com.android.tools.build:gradle:7.0.0")
classpath("com.android.tools.build:gradle:7.3.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
}

Expand Down
12 changes: 6 additions & 6 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@file:JvmName("Deps")

object Versions {
const val kotlin = "1.5.21"
const val kotlin = "1.7.10"
const val composeCompilerVersion = kotlin
const val compose = "1.0.1"
const val targetSdk = 30
const val buildVersion = "30.0.3"
const val compose = "1.3.1"
const val targetSdk = 33
const val buildVersion = "33.0.1"
}

object Compose {
Expand All @@ -20,8 +20,8 @@ object Compose {
}

object Android {
const val activityCompose = "androidx.activity:activity-compose:1.3.1"
const val appcompat = "androidx.appcompat:appcompat:1.3.1"
const val activityCompose = "androidx.activity:activity-compose:1.6.1"
const val appcompat = "androidx.appcompat:appcompat:1.5.1"
}

object Kotlin {
Expand Down
1 change: 0 additions & 1 deletion gradle/configure-compose.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ android {

kotlinOptions {
jvmTarget = "1.8"
useIR = true
}

composeOptions {
Expand Down
2 changes: 1 addition & 1 deletion gradle/jitpack-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ afterEvaluate {
release(MavenPublication) {
from components.release
groupId = "com.github.tehras.charts"
artifactId = module.getName()
// TODO artifactId = module.getName()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Jun 13 09:37:52 PDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 4 additions & 1 deletion lib/bar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ dependencies {
implementation(Compose.material)
implementation(Compose.runtime)
debugImplementation(Compose.tooling)
}
}
android {
namespace = "com.github.tehras.charts.bar"
}
2 changes: 1 addition & 1 deletion lib/bar/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.github.tehras.charts.bar" />
<manifest />
5 changes: 4 additions & 1 deletion lib/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ dependencies {
implementation(Compose.foundation)
implementation(Compose.runtime)
debugImplementation(Compose.tooling)
}
}
android {
namespace = "com.github.tehras.charts.common"
}
2 changes: 1 addition & 1 deletion lib/common/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.github.tehras.charts.common" />
<manifest />
5 changes: 4 additions & 1 deletion lib/line/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ dependencies {
implementation(Compose.foundation)
implementation(Compose.runtime)
debugImplementation(Compose.tooling)
}
}
android {
namespace = "com.github.tehras.charts.line"
}
2 changes: 1 addition & 1 deletion lib/line/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.github.tehras.charts.line">
<manifest>

</manifest>