diff --git a/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/StatsActivity.kt b/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/StatsActivity.kt index 0f96ee8..23779b5 100644 --- a/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/StatsActivity.kt +++ b/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/StatsActivity.kt @@ -6,6 +6,7 @@ import android.graphics.Color import android.os.Bundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat import com.github.mikephil.charting.animation.Easing import com.github.mikephil.charting.components.XAxis import com.github.mikephil.charting.data.Entry @@ -75,6 +76,7 @@ class StatsActivity : AppCompatActivity() { chart.axisLeft.setDrawAxisLine(false) chart.xAxis.setDrawAxisLine(false) chart.setDrawMarkers(false) + chart.xAxis.labelCount = 5 val rightAxix = chart.axisRight rightAxix.setDrawGridLines(false) rightAxix.setDrawZeroLine(false) @@ -84,7 +86,7 @@ class StatsActivity : AppCompatActivity() { val dataSet = LineDataSet(entries, "Label") dataSet.setDrawCircles(false) dataSet.lineWidth = 2.5f - dataSet.color = resources.getColor(R.color.colorSecondaryDark) + dataSet.color = ContextCompat.getColor(this, R.color.colorSecondaryDark) dataSet.setDrawFilled(true) dataSet.fillDrawable = getDrawable(R.drawable.graph_fill_gradiant) dataSet.setDrawValues(false) diff --git a/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/utils/ChartXValueFormatter.kt b/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/utils/ChartXValueFormatter.kt index 25c90ed..0cbb7c1 100644 --- a/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/utils/ChartXValueFormatter.kt +++ b/app/src/main/java/io/github/z3r0c00l_2k/aquadroid/utils/ChartXValueFormatter.kt @@ -5,8 +5,6 @@ import com.github.mikephil.charting.formatter.ValueFormatter class ChartXValueFormatter(val dateArray: ArrayList) : ValueFormatter() { override fun getAxisLabel(value: Float, axis: AxisBase?): String { - if (value.toInt() <= dateArray.size) - return "" - return dateArray[value.toInt()] + return dateArray.getOrNull(value.toInt()) ?: "" } } \ No newline at end of file