Skip to content

Commit

Permalink
Specify PointDrower for each line
Browse files Browse the repository at this point in the history
  • Loading branch information
fracassi-marco committed Oct 23, 2024
1 parent b331287 commit 0a43a7c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion JetChart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ afterEvaluate {
from components.release
groupId = 'io.jetchart'
artifactId = 'JetChart'
version = '1.4.2'
version = '1.4.3'
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions JetChart/src/main/java/io/jetchart/line/Line.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<LinePoint>,
val padBy: Float = 20f,
val startAtZero: Boolean = false,
val lineDrawer: LineDrawer,
val pointDrawer: PointDrawer = FilledPointDrawer(),
val shader: LineShader = NoLineShader,
) {
init {
Expand Down
3 changes: 1 addition & 2 deletions JetChart/src/main/java/io/jetchart/line/LineChart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ fun LineChart(
labels: List<String> = lines.maxByOrNull { it.points.size }?.points?.map { it.label }
?: emptyList(),
animation: AnimationSpec<Float> = fadeInAnimation(),
pointDrawer: PointDrawer = FilledPointDrawer(),
xAxisDrawer: XAxisDrawer = LineXAxisDrawer(),
yAxisDrawer: YAxisDrawer = LineYAxisWithValueDrawer(),
horizontalOffsetPercentage: Float = 5f
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/io/jetchart/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)),
Expand All @@ -124,7 +125,6 @@ fun LineChartComposable() {
.width(1000.dp)
.height(500.dp),
animation = fadeInAnimation(3000),
pointDrawer = FilledPointDrawer(),
xAxisDrawer = LineXAxisDrawer(),
yAxisDrawer = LineYAxisWithValueDrawer(),
horizontalOffsetPercentage = 1f,
Expand Down Expand Up @@ -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)
}

0 comments on commit 0a43a7c

Please sign in to comment.