Skip to content

Commit

Permalink
Fix checking the index of lists in chart label formatter classes
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano committed May 22, 2024
1 parent 930fa44 commit e31a090
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LineChartLabelFormatter @Inject constructor(
) : ValueFormatter() {
override fun getAxisLabel(value: Float, axis: AxisBase?): String {
val index = value.toInt()
return if (entries.isNotEmpty() && index in 0..entries.size) {
return if (entries.isNotEmpty() && index in entries.indices) {
entries[index].label
} else {
""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SubscribersChartLabelFormatter @Inject constructor(
) : ValueFormatter() {
override fun getAxisLabel(value: Float, axis: AxisBase?): String {
val index = value.toInt()
return if (entries.isNotEmpty() && index in 0..entries.size) {
return if (entries.isNotEmpty() && index in entries.indices) {
entries[index].label
} else {
""
Expand Down

0 comments on commit e31a090

Please sign in to comment.