Skip to content

Commit

Permalink
Merge pull request #1 from AndroidPoet/animation-newcharts
Browse files Browse the repository at this point in the history
animation and new charts added
  • Loading branch information
AndroidPoet authored Sep 25, 2024
2 parents d1e888a + ed96c65 commit 504ff6d
Show file tree
Hide file tree
Showing 67 changed files with 1,762 additions and 323 deletions.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,84 @@ BarChart(
)
```

## Radar Chart

```kotlin
@Composable
fun RadarChartExample() {
ChartTitle(text = "Radar Chart")
val data = listOf(
RadarChartData(
mapOf(
"Execution" to 0.8f,
"Landing" to 0.6f,
"Difficulty" to 0.9f,
"Style" to 0.7f,
"Creativity" to 0.85f,
),
),
)
val colors = listOf(Color.Blue, Color.Red)

RadarChart(
data = data,
colors = colors,
)
}
```

## Gantt Chart

```kotlin
@Composable
fun GanttChartExample() {
ChartTitle(text = "Gantt Chart")
val tasks = listOf(
GanttTask("Planning", 0f, 2f),
GanttTask("Design", 2f, 2f),
GanttTask("Development", 4f, 3f),
GanttTask("Testing", 7f, 2f),
GanttTask("Deployment", 9f, 1f),
)
val data = GanttChartData(tasks)
val renderer = SimpleGanttChartRenderer()
GanttChart(data = data, renderer = renderer, modifier = Modifier.size(400.dp))
}
```

## Bubble Chart

```kotlin
@Composable
fun BubbleChartExample() {
ChartTitle(text = "Bubble Chart")
val data = listOf(
listOf(
BubbleChartData(10f, 26f, 30f, Color.Blue),
BubbleChartData(26f, 30f, 60f, Color.Blue),
BubbleChartData(26f, 46f, 45f, Color.Blue),
),
listOf(
BubbleChartData(14f, 15f, 30f, Color.Green),
BubbleChartData(22f, 36f, 45f, Color.Green),
BubbleChartData(40f, 57f, 75f, Color.Green),
),
listOf(
BubbleChartData(8f, 9f, 30f, Color.Yellow),
BubbleChartData(20f, 57f, 45f, Color.Yellow),
BubbleChartData(40f, 50f, 60f, Color.Yellow),
),
listOf(
BubbleChartData(8f, 20f, 22.5f, Color.Red),
BubbleChartData(12f, 30f, 30f, Color.Red),
BubbleChartData(30f, 40f, 45f, Color.Red),
)
)

BubbleChart(data, Modifier.size(300.dp))
}
```

## Contributing

Contributions are welcome! If you've found a bug, have an idea for an improvement, or want to contribute new features, please open an issue or submit a pull request.
Expand Down
33 changes: 27 additions & 6 deletions app/api/app.api
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public final class io/androidpoet/countrypickerdemo/BuildConfig {
public final class io/androidpoet/drafterdemo/BuildConfig {
public static final field APPLICATION_ID Ljava/lang/String;
public static final field BUILD_TYPE Ljava/lang/String;
public static final field DEBUG Z
Expand All @@ -19,8 +19,12 @@ public final class io/androidpoet/drafterdemo/ComposableSingletons$MainActivityK
public static final field INSTANCE Lio/androidpoet/drafterdemo/ComposableSingletons$MainActivityKt;
public static field lambda-1 Lkotlin/jvm/functions/Function3;
public static field lambda-10 Lkotlin/jvm/functions/Function3;
public static field lambda-11 Lkotlin/jvm/functions/Function2;
public static field lambda-12 Lkotlin/jvm/functions/Function2;
public static field lambda-11 Lkotlin/jvm/functions/Function3;
public static field lambda-12 Lkotlin/jvm/functions/Function3;
public static field lambda-13 Lkotlin/jvm/functions/Function3;
public static field lambda-14 Lkotlin/jvm/functions/Function3;
public static field lambda-15 Lkotlin/jvm/functions/Function2;
public static field lambda-16 Lkotlin/jvm/functions/Function2;
public static field lambda-2 Lkotlin/jvm/functions/Function3;
public static field lambda-3 Lkotlin/jvm/functions/Function3;
public static field lambda-4 Lkotlin/jvm/functions/Function3;
Expand All @@ -32,8 +36,12 @@ public final class io/androidpoet/drafterdemo/ComposableSingletons$MainActivityK
public fun <init> ()V
public final fun getLambda-1$app_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-10$app_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-11$app_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda-12$app_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda-11$app_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-12$app_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-13$app_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-14$app_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-15$app_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda-16$app_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda-2$app_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-3$app_release ()Lkotlin/jvm/functions/Function3;
public final fun getLambda-4$app_release ()Lkotlin/jvm/functions/Function3;
Expand Down Expand Up @@ -69,6 +77,14 @@ public final class io/androidpoet/drafterdemo/bars/WaterfallChartExampleKt {
public static final fun WaterfallChartExample (Landroidx/compose/runtime/Composer;I)V
}

public final class io/androidpoet/drafterdemo/buble/BubbleChartKt {
public static final fun BubbleChartExample (Landroidx/compose/runtime/Composer;I)V
}

public final class io/androidpoet/drafterdemo/gantt/GanntChartDemoKt {
public static final fun GanttChartExample (Landroidx/compose/runtime/Composer;I)V
}

public final class io/androidpoet/drafterdemo/line/GroupedLineChartExampleKt {
public static final fun GroupedLineChartExample (Landroidx/compose/runtime/Composer;I)V
}
Expand All @@ -86,9 +102,14 @@ public final class io/androidpoet/drafterdemo/line/StackedLineChartExampleKt {
}

public final class io/androidpoet/drafterdemo/pie/PieChartExampleKt {
public static final fun DonutCharExample (Landroidx/compose/runtime/Composer;I)V
public static final fun PieChartExample (Landroidx/compose/runtime/Composer;I)V
}

public final class io/androidpoet/drafterdemo/radar/RadarChartKt {
public static final fun RadarChartExample (Landroidx/compose/runtime/Composer;I)V
}

public final class io/androidpoet/drafterdemo/ui/theme/ColorKt {
public static final fun getPink40 ()J
public static final fun getPink80 ()J
Expand All @@ -99,7 +120,7 @@ public final class io/androidpoet/drafterdemo/ui/theme/ColorKt {
}

public final class io/androidpoet/drafterdemo/ui/theme/ThemeKt {
public static final fun CountryPickerDemoTheme (ZZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
public static final fun DrafterDemoTheme (ZZLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V
}

public final class io/androidpoet/drafterdemo/ui/theme/TypeKt {
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import io.androidpoet.countrypicker.Configuration
import io.androidpoet.drafter.Configuration

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
Expand All @@ -35,9 +35,9 @@ plugins {

android {
compileSdk = Configuration.compileSdk
namespace = "io.androidpoet.countrypickerdemo"
namespace = "io.androidpoet.drafterdemo"
defaultConfig {
applicationId = "io.androidpoet.countrypickerdemo"
applicationId = "io.androidpoet.drafterdemo"
minSdk = Configuration.minSdk
targetSdk = Configuration.targetSdk
versionCode = Configuration.versionCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ fun ChartContainer(
content: @Composable () -> Unit,
) {
Box(
modifier = modifier
modifier =
modifier
.fillMaxWidth()
.height(200.dp)
.padding(horizontal = 16.dp),
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/kotlin/io/androidpoet/drafterdemo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,23 @@ import io.androidpoet.drafterdemo.bars.HistogramChartExample
import io.androidpoet.drafterdemo.bars.SimpleBarChartExample
import io.androidpoet.drafterdemo.bars.StackedBarChartExample
import io.androidpoet.drafterdemo.bars.WaterfallChartExample
import io.androidpoet.drafterdemo.buble.BubbleChartExample
import io.androidpoet.drafterdemo.gantt.GanttChartExample
import io.androidpoet.drafterdemo.line.GroupedLineChartExample
import io.androidpoet.drafterdemo.line.ScatterPlotChartExample
import io.androidpoet.drafterdemo.line.SimpleLineChartExample
import io.androidpoet.drafterdemo.line.StackedLineChartExample
import io.androidpoet.drafterdemo.pie.DonutCharExample
import io.androidpoet.drafterdemo.pie.PieChartExample
import io.androidpoet.drafterdemo.ui.theme.CountryPickerDemoTheme
import io.androidpoet.drafterdemo.radar.RadarChartExample
import io.androidpoet.drafterdemo.ui.theme.DrafterDemoTheme

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
CountryPickerDemoTheme {
DrafterDemoTheme {
LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(vertical = 16.dp),
Expand All @@ -57,8 +61,12 @@ class MainActivity : ComponentActivity() {
item { StackedLineChartExample() }
item { HistogramChartExample() }
item { PieChartExample() }
item { DonutCharExample() }
item { ScatterPlotChartExample() }
item { WaterfallChartExample() }
item { RadarChartExample() }
item { GanttChartExample() }
item { BubbleChartExample() }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ import io.androidpoet.drafterdemo.ChartTitle
@Composable
fun GroupedBarChartExample() {
ChartTitle(text = "Grouped Bar Chart")
val data = GroupedBarChartData(
labels = listOf("Q1", "Q2", "Q3", "Q4"),
itemNames = listOf("Product A", "Product B"),
groupedValues = listOf(
listOf(10f, 15f),
listOf(20f, 25f),
listOf(15f, 10f),
listOf(25f, 20f),
),
colors = listOf(Color.Cyan, Color.Magenta),
)
val data =
GroupedBarChartData(
labels = listOf("Q1", "Q2", "Q3", "Q4"),
itemNames = listOf("Product A", "Product B"),
groupedValues =
listOf(
listOf(10f, 15f),
listOf(20f, 25f),
listOf(15f, 10f),
listOf(25f, 20f),
),
colors = listOf(Color.Cyan, Color.Magenta),
)
val renderer = GroupedBarChartRenderer()
ChartContainer {
BarChart(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ import io.androidpoet.drafterdemo.ChartTitle
@Composable
fun SimpleBarChartExample() {
ChartTitle(text = "Simple Bar Chart")
val data = SimpleBarChartData(
labels = listOf("A", "B", "C", "D"),
values = listOf(10f, 20f, 15f, 25f),
colors = listOf(Color.Red, Color.Green, Color.Blue, Color.Yellow),
)
val data =
SimpleBarChartData(
labels = listOf("A", "B", "C", "D"),
values = listOf(10f, 20f, 15f, 25f),
colors = listOf(Color.Red, Color.Green, Color.Blue, Color.Yellow),
)
val renderer = SimpleBarChartRenderer()
ChartContainer {
BarChart(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ import io.androidpoet.drafterdemo.ChartTitle
@Composable
fun StackedBarChartExample() {
ChartTitle(text = "Stacked Bar Chart")
val data = StackedBarChartData(
labels = listOf("Jan", "Feb", "Mar", "Apr"),
stacks = listOf(
listOf(5f, 5f, 2f),
listOf(7f, 3f, 4f),
listOf(6f, 4f, 3f),
listOf(8f, 2f, 5f),
),
colors = listOf(Color.Blue, Color.Red, Color.Green),
)
val data =
StackedBarChartData(
labels = listOf("Jan", "Feb", "Mar", "Apr"),
stacks =
listOf(
listOf(5f, 5f, 2f),
listOf(7f, 3f, 4f),
listOf(6f, 4f, 3f),
listOf(8f, 2f, 5f),
),
colors = listOf(Color.Blue, Color.Red, Color.Green),
)
val renderer = StackedBarChartRenderer()
ChartContainer {
BarChart(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ import io.androidpoet.drafterdemo.ChartTitle
@Composable
fun WaterfallChartExample() {
ChartTitle(text = "Waterfall Chart")
val data = WaterfallChartData(
labels = listOf("Q1", "Q2", "Q3", "Q4"),
values = listOf(500f, -200f, 300f, -100f),
colors = listOf(Color.Green, Color.Red, Color.Green, Color.Red),
initialValue = 1000f,
)
val data =
WaterfallChartData(
labels = listOf("Q1", "Q2", "Q3", "Q4"),
values = listOf(500f, -200f, 300f, -100f),
colors = listOf(Color.Green, Color.Red, Color.Green, Color.Red),
initialValue = 1000f,
)
val renderer = WaterfallChartRenderer()
ChartContainer(modifier = Modifier.height(300.dp)) {
BarChart(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Designed and developed by 2024 androidpoet (Ranbir Singh)
*
* 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.
*/
package io.androidpoet.drafterdemo.buble

import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import io.androidpoet.drafter.buble.BubbleChart
import io.androidpoet.drafter.buble.BubbleChartData
import io.androidpoet.drafterdemo.ChartTitle

@Composable
fun BubbleChartExample() {
ChartTitle(text = "Bubble Chart")
val data = listOf(
listOf(
BubbleChartData(10f, 26f, 30f, Color.Blue),
BubbleChartData(26f, 30f, 60f, Color.Blue),
BubbleChartData(26f, 46f, 45f, Color.Blue),
),
listOf(
BubbleChartData(14f, 15f, 30f, Color.Green),
BubbleChartData(22f, 36f, 45f, Color.Green),
BubbleChartData(40f, 57f, 75f, Color.Green),
),
listOf(
BubbleChartData(8f, 9f, 30f, Color.Yellow),
BubbleChartData(20f, 57f, 45f, Color.Yellow),
BubbleChartData(40f, 50f, 60f, Color.Yellow),
),
listOf(
BubbleChartData(8f, 20f, 22.5f, Color.Red),
BubbleChartData(12f, 30f, 30f, Color.Red),
BubbleChartData(30f, 40f, 45f, Color.Red),
),
)

BubbleChart(data, Modifier.size(300.dp))
}
Loading

0 comments on commit 504ff6d

Please sign in to comment.