feat(graphs): add marker guidelines to show on hold

Closes: #118
This commit is contained in:
Nishant Mishra
2025-11-20 18:16:18 +05:30
parent 4ca7505825
commit 8e2a58918c
2 changed files with 32 additions and 6 deletions

View File

@@ -58,6 +58,7 @@ import com.patrykandpatrick.vico.core.cartesian.marker.DefaultCartesianMarker
import com.patrykandpatrick.vico.core.common.Fill
import com.patrykandpatrick.vico.core.common.Insets
import com.patrykandpatrick.vico.core.common.shape.CorneredShape
import com.patrykandpatrick.vico.core.common.shape.DashedShape
import org.nsh07.pomodoro.ui.theme.TomatoTheme
import org.nsh07.pomodoro.utils.millisecondsToHours
import org.nsh07.pomodoro.utils.millisecondsToHoursMinutes
@@ -112,14 +113,14 @@ fun TimeColumnChart(
),
startAxis = VerticalAxis.rememberStart(
line = rememberLineComponent(Fill.Transparent),
label = rememberTextComponent(typeface = axisTypeface),
label = rememberTextComponent(colorScheme.onSurface, axisTypeface),
tick = rememberLineComponent(Fill.Transparent),
guideline = rememberLineComponent(Fill.Transparent),
valueFormatter = yValueFormatter
),
bottomAxis = HorizontalAxis.rememberBottom(
line = rememberLineComponent(Fill.Transparent),
label = rememberTextComponent(typeface = axisTypeface),
label = rememberTextComponent(colorScheme.onSurface, axisTypeface),
tick = rememberLineComponent(Fill.Transparent),
guideline = rememberLineComponent(Fill.Transparent),
valueFormatter = xValueFormatter
@@ -137,7 +138,15 @@ fun TimeColumnChart(
padding = Insets(verticalDp = 4f, horizontalDp = 8f),
margins = Insets(bottomDp = 2f)
),
valueFormatter = markerValueFormatter
valueFormatter = markerValueFormatter,
guideline = rememberLineComponent(
fill = fill(colorScheme.primary),
shape = DashedShape(
shape = CorneredShape.Pill,
dashLengthDp = 16f,
gapLengthDp = 8f
)
)
),
fadingEdges = rememberFadingEdges()
),

View File

@@ -61,8 +61,10 @@ import com.patrykandpatrick.vico.core.cartesian.marker.DefaultCartesianMarker
import com.patrykandpatrick.vico.core.cartesian.marker.LineCartesianLayerMarkerTarget
import com.patrykandpatrick.vico.core.common.Fill
import com.patrykandpatrick.vico.core.common.Insets
import com.patrykandpatrick.vico.core.common.component.ShapeComponent
import com.patrykandpatrick.vico.core.common.shader.ShaderProvider
import com.patrykandpatrick.vico.core.common.shape.CorneredShape
import com.patrykandpatrick.vico.core.common.shape.DashedShape
import org.nsh07.pomodoro.ui.theme.TomatoTheme
import org.nsh07.pomodoro.utils.millisecondsToHours
import org.nsh07.pomodoro.utils.millisecondsToHoursMinutes
@@ -127,14 +129,14 @@ fun TimeLineChart(
),
startAxis = VerticalAxis.rememberStart(
line = rememberLineComponent(Fill.Transparent),
label = rememberTextComponent(typeface = axisTypeface),
label = rememberTextComponent(colorScheme.onSurface, axisTypeface),
tick = rememberLineComponent(Fill.Transparent),
guideline = rememberLineComponent(Fill.Transparent),
valueFormatter = yValueFormatter
),
bottomAxis = HorizontalAxis.rememberBottom(
line = rememberLineComponent(Fill.Transparent),
label = rememberTextComponent(typeface = axisTypeface),
label = rememberTextComponent(colorScheme.onSurface, axisTypeface),
tick = rememberLineComponent(Fill.Transparent),
guideline = rememberLineComponent(Fill.Transparent),
valueFormatter = xValueFormatter
@@ -152,7 +154,22 @@ fun TimeLineChart(
padding = Insets(verticalDp = 4f, horizontalDp = 8f),
margins = Insets(bottomDp = 2f)
),
valueFormatter = markerValueFormatter
valueFormatter = markerValueFormatter,
indicator = {
ShapeComponent(
fill = fill(it),
shape = CorneredShape.Pill,
margins = Insets(3f)
)
},
guideline = rememberLineComponent(
fill = fill(colorScheme.primary),
shape = DashedShape(
shape = CorneredShape.Pill,
dashLengthDp = 16f,
gapLengthDp = 8f
)
)
),
fadingEdges = rememberFadingEdges()
),