Skip to content

Commit

Permalink
Improve behavior of CartesianLayer#updateChartValues implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmichalik committed Dec 14, 2023
1 parent 4a97909 commit 25a269c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,10 @@ public open class ColumnCartesianLayer(
axisPosition = verticalAxisPosition,
minX = axisValueOverrider?.getMinX(model) ?: model.minX,
maxX = axisValueOverrider?.getMaxX(model) ?: model.maxX,
minY = axisValueOverrider?.getMinY(model) ?: mergeMode.getMinY(model),
maxY = axisValueOverrider?.getMaxY(model) ?: mergeMode.getMaxY(model),
minY = axisValueOverrider?.getMinY(model) ?: mergeMode.getMinY(model).coerceAtMost(0f),
maxY =
axisValueOverrider?.getMaxY(model)
?: if (model.minY == 0f && model.maxY == 0f) 1f else mergeMode.getMaxY(model).coerceAtLeast(0f),
)
}

Expand Down Expand Up @@ -446,8 +448,8 @@ public open class ColumnCartesianLayer(
*/
public fun getMinY(model: ColumnCartesianLayerModel): Float =
when (this) {
Grouped -> model.minY.coerceAtMost(0f)
Stacked -> model.minAggregateY.coerceAtMost(0f)
Grouped -> model.minY
Stacked -> model.minAggregateY
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,10 @@ public open class LineCartesianLayer(
chartValues.tryUpdate(
minX = axisValueOverrider?.getMinX(model) ?: model.minX,
maxX = axisValueOverrider?.getMaxX(model) ?: model.maxX,
minY = axisValueOverrider?.getMinY(model) ?: min(model.minY, 0f),
maxY = axisValueOverrider?.getMaxY(model) ?: model.maxY,
minY = axisValueOverrider?.getMinY(model) ?: model.minY.coerceAtMost(0f),
maxY =
axisValueOverrider?.getMaxY(model)
?: if (model.minY == 0f && model.maxY == 0f) 1f else model.maxY.coerceAtLeast(0f),
axisPosition = verticalAxisPosition,
)
}
Expand Down

0 comments on commit 25a269c

Please sign in to comment.