Skip to content

Commit 64abab8

Browse files
committed
fix: maxBarValue not updated in a timely manner
1 parent 06a4fc7 commit 64abab8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/src/main/java/me/bytebeats/views/charts/app/ui/screen/bar/BarChartDataModel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,16 @@ class BarChartDataModel {
7575
}
7676

7777
internal fun addBar() {
78-
barChartData = barChartData.copy(bars = bars.toMutableList().apply {
78+
val newBars = bars.toMutableList().apply {
7979
add(
8080
BarChartData.Bar(
8181
label = "Bar ${bars.size + 1}",
8282
value = randomValue(),
8383
color = randomColor()
8484
)
8585
)
86-
}.toList())
86+
}.toList()
87+
barChartData = barChartData.copy(bars = newBars, maxBarValue = newBars.maxOf { it.value })
8788
}
8889

8990
internal fun removeBar() {

0 commit comments

Comments
 (0)