Temp Crash fix on Line Chart

This commit is contained in:
z3r0c00l-2k 2019-05-20 19:41:53 +05:30
parent b424951447
commit ab7e31a5ed
3 changed files with 10 additions and 16 deletions

View file

@ -37,13 +37,12 @@ class StatsActivity : AppCompatActivity() {
finish()
}
greetings.text = "Hello, " + sharedPref.getString(AppUtils.NAME_KEY, "User")
greetings.text = "Hello, " + sharedPref.getString(AppUtils.NAME_KEY, "User") + ". Your water intake habit"
val entries = ArrayList<Entry>()
val dateArray = ArrayList<String>()
val cursor: Cursor = sqliteHelper.getAllStats()
Toast.makeText(this, "" + cursor.count, Toast.LENGTH_LONG).show()
if (cursor.moveToFirst()) {
@ -63,7 +62,7 @@ class StatsActivity : AppCompatActivity() {
if (!entries.isEmpty()) {
chart.description.isEnabled = false
chart.animateX(1500, Easing.Linear)
chart.animateY(1000, Easing.Linear)
chart.viewPortHandler.setMaximumScaleX(1.5f)
chart.xAxis.setDrawGridLines(false)
chart.xAxis.position = XAxis.XAxisPosition.TOP

View file

@ -5,6 +5,8 @@ import com.github.mikephil.charting.formatter.ValueFormatter
class ChartXValueFormatter(val dateArray: ArrayList<String>) : ValueFormatter() {
override fun getAxisLabel(value: Float, axis: AxisBase?): String {
if (value.toInt() <= dateArray.size)
return ""
return dateArray[value.toInt()]
}
}

View file

@ -22,16 +22,6 @@
android:id="@+id/btnBack" app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="16dp"/>
<TextView
android:text="Your Water Intake Habit"
android:textColor="@color/colorWhite"
android:textStyle="bold"
android:textSize="22sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView5"
app:layout_constraintStart_toEndOf="@+id/btnBack" android:layout_marginStart="24dp"
android:layout_marginTop="16dp" app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:text="0 %"
android:layout_width="wrap_content"
@ -72,9 +62,12 @@
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/colorWhite"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/greetings" android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="24dp" app:layout_constraintTop_toBottomOf="@+id/textView5"/>
android:id="@+id/greetings"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/btnBack"
android:layout_marginStart="24dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="16dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>