Skip to content

Commit 8e2a589

Browse files
committed
feat(graphs): add marker guidelines to show on hold
Closes: #118
1 parent 4ca7505 commit 8e2a589

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeColumnChart.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import com.patrykandpatrick.vico.core.cartesian.marker.DefaultCartesianMarker
5858
import com.patrykandpatrick.vico.core.common.Fill
5959
import com.patrykandpatrick.vico.core.common.Insets
6060
import com.patrykandpatrick.vico.core.common.shape.CorneredShape
61+
import com.patrykandpatrick.vico.core.common.shape.DashedShape
6162
import org.nsh07.pomodoro.ui.theme.TomatoTheme
6263
import org.nsh07.pomodoro.utils.millisecondsToHours
6364
import org.nsh07.pomodoro.utils.millisecondsToHoursMinutes
@@ -112,14 +113,14 @@ fun TimeColumnChart(
112113
),
113114
startAxis = VerticalAxis.rememberStart(
114115
line = rememberLineComponent(Fill.Transparent),
115-
label = rememberTextComponent(typeface = axisTypeface),
116+
label = rememberTextComponent(colorScheme.onSurface, axisTypeface),
116117
tick = rememberLineComponent(Fill.Transparent),
117118
guideline = rememberLineComponent(Fill.Transparent),
118119
valueFormatter = yValueFormatter
119120
),
120121
bottomAxis = HorizontalAxis.rememberBottom(
121122
line = rememberLineComponent(Fill.Transparent),
122-
label = rememberTextComponent(typeface = axisTypeface),
123+
label = rememberTextComponent(colorScheme.onSurface, axisTypeface),
123124
tick = rememberLineComponent(Fill.Transparent),
124125
guideline = rememberLineComponent(Fill.Transparent),
125126
valueFormatter = xValueFormatter
@@ -137,7 +138,15 @@ fun TimeColumnChart(
137138
padding = Insets(verticalDp = 4f, horizontalDp = 8f),
138139
margins = Insets(bottomDp = 2f)
139140
),
140-
valueFormatter = markerValueFormatter
141+
valueFormatter = markerValueFormatter,
142+
guideline = rememberLineComponent(
143+
fill = fill(colorScheme.primary),
144+
shape = DashedShape(
145+
shape = CorneredShape.Pill,
146+
dashLengthDp = 16f,
147+
gapLengthDp = 8f
148+
)
149+
)
141150
),
142151
fadingEdges = rememberFadingEdges()
143152
),

app/src/main/java/org/nsh07/pomodoro/ui/statsScreen/TimeLineChart.kt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ import com.patrykandpatrick.vico.core.cartesian.marker.DefaultCartesianMarker
6161
import com.patrykandpatrick.vico.core.cartesian.marker.LineCartesianLayerMarkerTarget
6262
import com.patrykandpatrick.vico.core.common.Fill
6363
import com.patrykandpatrick.vico.core.common.Insets
64+
import com.patrykandpatrick.vico.core.common.component.ShapeComponent
6465
import com.patrykandpatrick.vico.core.common.shader.ShaderProvider
6566
import com.patrykandpatrick.vico.core.common.shape.CorneredShape
67+
import com.patrykandpatrick.vico.core.common.shape.DashedShape
6668
import org.nsh07.pomodoro.ui.theme.TomatoTheme
6769
import org.nsh07.pomodoro.utils.millisecondsToHours
6870
import org.nsh07.pomodoro.utils.millisecondsToHoursMinutes
@@ -127,14 +129,14 @@ fun TimeLineChart(
127129
),
128130
startAxis = VerticalAxis.rememberStart(
129131
line = rememberLineComponent(Fill.Transparent),
130-
label = rememberTextComponent(typeface = axisTypeface),
132+
label = rememberTextComponent(colorScheme.onSurface, axisTypeface),
131133
tick = rememberLineComponent(Fill.Transparent),
132134
guideline = rememberLineComponent(Fill.Transparent),
133135
valueFormatter = yValueFormatter
134136
),
135137
bottomAxis = HorizontalAxis.rememberBottom(
136138
line = rememberLineComponent(Fill.Transparent),
137-
label = rememberTextComponent(typeface = axisTypeface),
139+
label = rememberTextComponent(colorScheme.onSurface, axisTypeface),
138140
tick = rememberLineComponent(Fill.Transparent),
139141
guideline = rememberLineComponent(Fill.Transparent),
140142
valueFormatter = xValueFormatter
@@ -152,7 +154,22 @@ fun TimeLineChart(
152154
padding = Insets(verticalDp = 4f, horizontalDp = 8f),
153155
margins = Insets(bottomDp = 2f)
154156
),
155-
valueFormatter = markerValueFormatter
157+
valueFormatter = markerValueFormatter,
158+
indicator = {
159+
ShapeComponent(
160+
fill = fill(it),
161+
shape = CorneredShape.Pill,
162+
margins = Insets(3f)
163+
)
164+
},
165+
guideline = rememberLineComponent(
166+
fill = fill(colorScheme.primary),
167+
shape = DashedShape(
168+
shape = CorneredShape.Pill,
169+
dashLengthDp = 16f,
170+
gapLengthDp = 8f
171+
)
172+
)
156173
),
157174
fadingEdges = rememberFadingEdges()
158175
),

0 commit comments

Comments
 (0)