Skip to content

Commit

Permalink
added stroke size field on line config (#61)
Browse files Browse the repository at this point in the history
Co-authored-by: Alberto Caliman <[email protected]>
  • Loading branch information
SuperCaliMan and Alberto Caliman authored Jan 19, 2023
1 parent 4593860 commit 050fa40
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fun CurveLineChart(
colors = lineColors,
),
style = Stroke(
width = 5F,
width = curveLineConfig.strokeSize.toPx(),
cap = StrokeCap.Round
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fun LineChart(
val scaleFactor = size.height.div(maxYValue)
val brush = Brush.linearGradient(colors)
val radius = size.width.div(70)
val strokeWidth = size.width.div(100)
val strokeWidth = lineConfig.strokeSize.toPx()
val path = Path().apply {
moveTo(0f, size.height)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package com.himanshoe.charty.line.config

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

data class CurveLineConfig(
val hasDotMarker: Boolean,
val dotColor: Color = Color.Transparent,
val strokeSize: Dp = 5.dp
)

internal object CurveLineConfigDefaults {

fun curveLineConfigDefaults() = CurveLineConfig(
hasDotMarker = true,
dotColor = Color.Green
dotColor = Color.Green,
strokeSize = 5.dp
)
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package com.himanshoe.charty.line.config

import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

data class LineConfig(
val hasSmoothCurve: Boolean = false,
val hasDotMarker: Boolean = false
val hasDotMarker: Boolean = false,
val strokeSize: Dp = 5.dp
)

internal object LineConfigDefaults {

fun lineConfigDefaults() = LineConfig(
hasSmoothCurve = true,
hasDotMarker = true
hasDotMarker = true,
strokeSize = 5.dp
)
}

0 comments on commit 050fa40

Please sign in to comment.