@@ -248,10 +248,10 @@ fun MeasurementChart(
248248 lineTypesToActuallyPlot.any { it.id == goal.measurementTypeId }
249249 }
250250 }
251- }.collectAsStateWithLifecycle(initialValue = emptyList() )
251+ }.collectAsStateWithLifecycle(initialValue = null )
252252
253253 val goalValuesForScaling = remember(goalsToActuallyPlot, showGoalLinesSetting) {
254- if (showGoalLinesSetting) goalsToActuallyPlot.map { it.goalValue.toFloat() }
254+ if (showGoalLinesSetting) goalsToActuallyPlot? .map { it.goalValue.toFloat() } ? : emptyList()
255255 else emptyList()
256256 }
257257
@@ -472,6 +472,12 @@ fun MeasurementChart(
472472 }
473473
474474 else -> {
475+ if (goalsToActuallyPlot == null && showGoalLinesSetting) {
476+ Box (
477+ modifier = Modifier .weight(1f ).fillMaxSize(),
478+ contentAlignment = Alignment .Center ,
479+ ) { CircularProgressIndicator () }
480+ } else {
475481 val scrollState = rememberVicoScrollState()
476482 val zoomState = rememberVicoZoomState(zoomEnabled = true , initialZoom = Zoom .Content )
477483
@@ -499,11 +505,11 @@ fun MeasurementChart(
499505 val typeById = remember(allAvailableMeasurementTypes) {
500506 allAvailableMeasurementTypes.associateBy { it.id }
501507 }
502- val goalDecorations = if (showGoalLinesSetting) {
503- goalsToActuallyPlot.map { goal ->
504- rememberGoalLine(goal = goal, type = typeById[goal.measurementTypeId])
505- }
506- } else emptyList()
508+ val goalDecorations = if (showGoalLinesSetting) {
509+ goalsToActuallyPlot? .map { goal ->
510+ rememberGoalLine(goal = goal, type = typeById[goal.measurementTypeId])
511+ } ? : emptyList()
512+ } else emptyList()
507513
508514 val chart = rememberCartesianChart(
509515 layers = layers.toTypedArray(),
@@ -525,6 +531,7 @@ fun MeasurementChart(
525531 zoomState = zoomState,
526532 )
527533 }
534+ }
528535 }
529536
530537 if (showFilterTitle) {
0 commit comments