From 0a43a7c16c28d4a2d13697976b5b2ef95cc938eb Mon Sep 17 00:00:00 2001 From: Marco Fracassi Date: Wed, 23 Oct 2024 22:45:42 +0200 Subject: [PATCH] Specify PointDrower for each line --- JetChart/build.gradle | 2 +- JetChart/src/main/java/io/jetchart/line/Line.kt | 3 +++ JetChart/src/main/java/io/jetchart/line/LineChart.kt | 3 +-- app/src/main/java/io/jetchart/demo/MainActivity.kt | 10 +++++----- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/JetChart/build.gradle b/JetChart/build.gradle index 5c67856..a07fa72 100644 --- a/JetChart/build.gradle +++ b/JetChart/build.gradle @@ -59,7 +59,7 @@ afterEvaluate { from components.release groupId = 'io.jetchart' artifactId = 'JetChart' - version = '1.4.2' + version = '1.4.3' } } } diff --git a/JetChart/src/main/java/io/jetchart/line/Line.kt b/JetChart/src/main/java/io/jetchart/line/Line.kt index 775e797..b5db38a 100644 --- a/JetChart/src/main/java/io/jetchart/line/Line.kt +++ b/JetChart/src/main/java/io/jetchart/line/Line.kt @@ -3,12 +3,15 @@ package io.jetchart.line import io.jetchart.line.renderer.line.LineDrawer import io.jetchart.line.renderer.line.LineShader import io.jetchart.line.renderer.line.NoLineShader +import io.jetchart.line.renderer.point.FilledPointDrawer +import io.jetchart.line.renderer.point.PointDrawer data class Line( val points: List, val padBy: Float = 20f, val startAtZero: Boolean = false, val lineDrawer: LineDrawer, + val pointDrawer: PointDrawer = FilledPointDrawer(), val shader: LineShader = NoLineShader, ) { init { diff --git a/JetChart/src/main/java/io/jetchart/line/LineChart.kt b/JetChart/src/main/java/io/jetchart/line/LineChart.kt index effdd38..747a1c2 100644 --- a/JetChart/src/main/java/io/jetchart/line/LineChart.kt +++ b/JetChart/src/main/java/io/jetchart/line/LineChart.kt @@ -41,7 +41,6 @@ fun LineChart( labels: List = lines.maxByOrNull { it.points.size }?.points?.map { it.label } ?: emptyList(), animation: AnimationSpec = fadeInAnimation(), - pointDrawer: PointDrawer = FilledPointDrawer(), xAxisDrawer: XAxisDrawer = LineXAxisDrawer(), yAxisDrawer: YAxisDrawer = LineYAxisWithValueDrawer(), horizontalOffsetPercentage: Float = 5f @@ -120,7 +119,7 @@ fun LineChart( lineChartData = line, yRange = yRange, transitionAnimation = transitionAnimation[index], - pointDrawer = pointDrawer, + pointDrawer = line.pointDrawer, lineDrawer = line.lineDrawer, lineShader = line.shader, chartDrawableArea = chartDrawableArea diff --git a/app/src/main/java/io/jetchart/demo/MainActivity.kt b/app/src/main/java/io/jetchart/demo/MainActivity.kt index a9f2af7..b2906c3 100644 --- a/app/src/main/java/io/jetchart/demo/MainActivity.kt +++ b/app/src/main/java/io/jetchart/demo/MainActivity.kt @@ -12,7 +12,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -31,9 +31,9 @@ import androidx.compose.ui.unit.dp import io.jetchart.bar.Bar import io.jetchart.bar.BarChart import io.jetchart.bar.Bars +import io.jetchart.bar.renderer.label.SimpleBarLabelDrawer import io.jetchart.bar.renderer.label.SimpleBarValueDrawer import io.jetchart.bar.renderer.label.SimpleBarValueDrawer.ValueDrawLocation.Inside -import io.jetchart.bar.renderer.label.SimpleBarLabelDrawer import io.jetchart.bar.renderer.xaxis.BarXAxisDrawer import io.jetchart.bar.renderer.yaxis.BarYAxisWithValueDrawer import io.jetchart.common.animation.fadeInAnimation @@ -48,7 +48,7 @@ import io.jetchart.line.NullPoint import io.jetchart.line.Point import io.jetchart.line.renderer.line.GradientLineShader import io.jetchart.line.renderer.line.SolidLineDrawer -import io.jetchart.line.renderer.point.FilledPointDrawer +import io.jetchart.line.renderer.point.NoPointDrawer import io.jetchart.line.renderer.xaxis.LineXAxisDrawer import io.jetchart.line.renderer.yaxis.LineYAxisWithValueDrawer import io.jetchart.pie.PieChart @@ -114,6 +114,7 @@ fun LineChartComposable() { Line( points = points(10), lineDrawer = SolidLineDrawer(thickness = 8.dp, color = Blue), + pointDrawer = NoPointDrawer, shader = GradientLineShader(listOf(JetGreen, Transparent)) ), Line(points = points(15), lineDrawer = SolidLineDrawer(thickness = 8.dp, color = Red)), @@ -124,7 +125,6 @@ fun LineChartComposable() { .width(1000.dp) .height(500.dp), animation = fadeInAnimation(3000), - pointDrawer = FilledPointDrawer(), xAxisDrawer = LineXAxisDrawer(), yAxisDrawer = LineYAxisWithValueDrawer(), horizontalOffsetPercentage = 1f, @@ -169,5 +169,5 @@ fun GaugeChartComposable() { @Composable private fun JetDivider() { - Divider(modifier = Modifier.padding(horizontal = 5.dp, vertical = 50.dp), thickness = 1.dp, color = JetGreen) + HorizontalDivider(modifier = Modifier.padding(horizontal = 5.dp, vertical = 50.dp), thickness = 1.dp, color = JetGreen) } \ No newline at end of file