diff --git a/charts/src/commonMain/kotlin/io/github/dautovicharis/charts/internal/barchart/BarChart.kt b/charts/src/commonMain/kotlin/io/github/dautovicharis/charts/internal/barchart/BarChart.kt index 066d911..3147297 100644 --- a/charts/src/commonMain/kotlin/io/github/dautovicharis/charts/internal/barchart/BarChart.kt +++ b/charts/src/commonMain/kotlin/io/github/dautovicharis/charts/internal/barchart/BarChart.kt @@ -101,20 +101,19 @@ private fun DrawScope.drawBars( val spacing = style.space.toPx() val barWidth = (size.width - spacing * (dataSize - 1)) / dataSize - val finalBarHeight = size.height * (abs(value) / (maxValue - minValue)) + val selectedBarScale = if (index == selectedIndex) MAX_SCALE else DEFAULT_SCALE + val finalBarHeight = size.height * selectedBarScale * (abs(value) / (maxValue - minValue)) val barHeight = lerp(0f, finalBarHeight.toFloat(), progress[index].value) val top = if (value >= 0) baselineY - barHeight else baselineY val left = (barWidth + spacing) * index - val selectedBarScale = if (index == selectedIndex) MAX_SCALE else DEFAULT_SCALE - drawRect( color = barColor, topLeft = Offset(x = left, y = top.toFloat()), size = Size( width = barWidth * selectedBarScale, - height = barHeight * selectedBarScale + height = barHeight ) ) } diff --git a/charts/src/commonMain/kotlin/io/github/dautovicharis/charts/internal/barstackedchart/BarStackedChart.kt b/charts/src/commonMain/kotlin/io/github/dautovicharis/charts/internal/barstackedchart/BarStackedChart.kt index 96cea33..b6f1e80 100644 --- a/charts/src/commonMain/kotlin/io/github/dautovicharis/charts/internal/barstackedchart/BarStackedChart.kt +++ b/charts/src/commonMain/kotlin/io/github/dautovicharis/charts/internal/barstackedchart/BarStackedChart.kt @@ -98,7 +98,7 @@ private fun DrawScope.drawBars( item.item.points.forEachIndexed { dataIndex, value -> val height = lerp( 0f, - (value.toFloat() / totalMaxValue.toFloat()) * size.height, + (value.toFloat() * selectedBarScale / totalMaxValue.toFloat()) * size.height, progress[index].value ) topOffset -= height @@ -108,7 +108,7 @@ private fun DrawScope.drawBars( topLeft = Offset(x = index * (barWidth + spacing), y = topOffset), size = Size( width = barWidth * selectedBarScale, - height = height * selectedBarScale + height = height ) ) }