Skip to content

Commit

Permalink
CandlestickCartesianLayer: Correct bodyCenterX calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmichalik committed Apr 1, 2024
1 parent ac8deca commit c3e4c2f
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ public open class CandlestickCartesianLayer(
drawingModel: CandlestickCartesianLayerDrawingModel?,
) {
val yRange = chartValues.getYRange(verticalAxisPosition)
val halfMaxCandleWidth = candles.getWidestCandle(model.extraStore).widthDp.half.pixels

val drawingStart: Float =
bounds.getStart(isLtr = isLtr) + (
horizontalDimensions.startPadding -
candles.getWidestCandle(model.extraStore).widthDp.half.pixels * zoom
) * layoutDirectionMultiplier - horizontalScroll
val drawingStart =
bounds.getStart(isLtr) +
(horizontalDimensions.startPadding - halfMaxCandleWidth * zoom) * layoutDirectionMultiplier -
horizontalScroll

var bodyCenterX: Float
var candle: Candle
Expand All @@ -132,7 +132,7 @@ public open class CandlestickCartesianLayer(

val xSpacingMultiplier = (entry.x - chartValues.minX) / chartValues.xStep
bodyCenterX = drawingStart + layoutDirectionMultiplier * horizontalDimensions.xSpacing *
xSpacingMultiplier + candle.widthDp.half.pixels * zoom
xSpacingMultiplier + halfMaxCandleWidth * zoom

var bodyBottomY = bounds.bottom - candleInfo.bodyBottomY * bounds.height()
var bodyTopY = bounds.bottom - candleInfo.bodyTopY * bounds.height()
Expand Down

0 comments on commit c3e4c2f

Please sign in to comment.