Skip to content

Commit

Permalink
LineCartesianLayer: Make DynamicShader-related fixes and improvem…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
patrickmichalik committed Dec 11, 2023
1 parent 482de63 commit a97ec28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import com.patrykandpatrick.vico.core.model.drawing.DrawingModelInterpolator
import com.patrykandpatrick.vico.core.model.drawing.LineCartesianLayerDrawingModel
import com.patrykandpatrick.vico.core.model.forEachInIndexed
import com.patrykandpatrick.vico.core.util.Point
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

Expand Down Expand Up @@ -277,7 +276,7 @@ public open class LineCartesianLayer(

val drawingModel = model.extraStore.getOrNull(drawingModelKey)
val yRange = chartValues.getYRange(verticalAxisPosition)
val zeroLineYFraction = 1f - (drawingModel?.zeroY ?: abs(yRange.minY / yRange.length))
val zeroLineYFraction = drawingModel?.zeroY ?: (yRange.minY / yRange.length + 1f).coerceIn(0f..1f)

model.series.forEachIndexed { entryListIndex, entries ->

Expand Down Expand Up @@ -617,7 +616,7 @@ public open class LineCartesianLayer(
}
}
.let { pointInfo ->
LineCartesianLayerDrawingModel(pointInfo, abs(yRange.minY / yRange.length))
LineCartesianLayerDrawingModel(pointInfo, (yRange.minY / yRange.length + 1f).coerceIn(0f..1f))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import com.patrykandpatrick.vico.core.extension.lerp
import com.patrykandpatrick.vico.core.extension.orZero

/**
* Houses drawing information for a [LineCartesianLayer]. [opacity] is the lines’ opacity. [zeroY] specifies the
* position of the zero line (_y_ = 0) from the bottom of the [LineCartesianLayer] as a fraction of the
* [LineCartesianLayer]’s height.
* Houses drawing information for a [LineCartesianLayer]. [opacity] is the lines’ opacity. [zeroY], restricted to the
* interval [0, 1], specifies the position of the zero line (_y_ = 0) from the top of the [LineCartesianLayer] as a
* fraction of the [LineCartesianLayer]’s height.
*/
public class LineCartesianLayerDrawingModel(
pointInfo: List<Map<Float, PointInfo>>,
Expand Down

0 comments on commit a97ec28

Please sign in to comment.