Skip to content

Commit

Permalink
fix: maxBarValue not updated in a timely manner
Browse files Browse the repository at this point in the history
  • Loading branch information
junerver committed Nov 15, 2024
1 parent 06a4fc7 commit 64abab8
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ class BarChartDataModel {
}

internal fun addBar() {
barChartData = barChartData.copy(bars = bars.toMutableList().apply {
val newBars = bars.toMutableList().apply {
add(
BarChartData.Bar(
label = "Bar ${bars.size + 1}",
value = randomValue(),
color = randomColor()
)
)
}.toList())
}.toList()
barChartData = barChartData.copy(bars = newBars, maxBarValue = newBars.maxOf { it.value })
}

internal fun removeBar() {
Expand Down

0 comments on commit 64abab8

Please sign in to comment.