Update calendar graph UI

feature/top10
Aurelien Hubert 7 years ago
parent e2c3854b57
commit 0651263e45
  1. 1
      app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt
  2. 26
      app/src/main/java/net/pokeranalytics/android/ui/graph/GraphExtensions.kt
  3. 3
      app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt

@ -158,6 +158,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
val colors = arrayOf(R.color.green_light).toIntArray() val colors = arrayOf(R.color.green_light).toIntArray()
dataSet.setColors(colors, context) dataSet.setColors(colors, context)
dataSet.setDrawCircles(false) dataSet.setDrawCircles(false)
dataSet.setDrawValues(false)
val lineData = LineData(listOf(dataSet)) val lineData = LineData(listOf(dataSet))
this.chartView = when (stat.graphType) { this.chartView = when (stat.graphType) {

@ -1,31 +1,29 @@
package net.pokeranalytics.android.ui.graph package net.pokeranalytics.android.ui.graph
import android.content.Context import android.content.Context
import android.graphics.Typeface
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import com.github.mikephil.charting.charts.BarLineChartBase import com.github.mikephil.charting.charts.BarLineChartBase
import com.github.mikephil.charting.components.XAxis import com.github.mikephil.charting.components.XAxis
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.extensions.px import net.pokeranalytics.android.ui.extensions.px
fun BarLineChartBase<*>.setStyle(small: Boolean, context: Context) { fun BarLineChartBase<*>.setStyle(small: Boolean, context: Context) {
// X Axis // X Axis
this.xAxis.axisLineColor = ContextCompat.getColor(context, R.color.chart_default) this.xAxis.axisLineColor = ContextCompat.getColor(context, R.color.chart_default)
this.xAxis.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) this.xAxis.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px)
this.xAxis.textColor = ContextCompat.getColor(context, R.color.chart_default)
this.xAxis.labelCount = 4
this.xAxis.position = XAxis.XAxisPosition.BOTTOM this.xAxis.position = XAxis.XAxisPosition.BOTTOM
this.xAxis.textColor = ContextCompat.getColor(context, R.color.chart_default)
this.xAxis.typeface = Typeface.DEFAULT
this.xAxis.labelCount = 4
this.xAxis.position = XAxis.XAxisPosition.BOTTOM
this.xAxis.setDrawLabels(true) this.xAxis.setDrawLabels(true)
this.xAxis.setDrawGridLines(true) this.xAxis.setDrawGridLines(true)
this.xAxis.granularity = 1.0f
this.xAxis.isGranularityEnabled = true this.xAxis.isGranularityEnabled = true
this.xAxis.granularity = 1.0f
this.xAxis.textColor = ContextCompat.getColor(context, R.color.chart_default)
this.xAxis.typeface = ResourcesCompat.getFont(context, R.font.roboto_medium)
this.xAxis.labelCount = 4
this.xAxis.textSize = 12f
this.xAxis.isEnabled = true this.xAxis.isEnabled = true
// Y Axis // Y Axis
@ -41,12 +39,14 @@ fun BarLineChartBase<*>.setStyle(small: Boolean, context: Context) {
this.axisLeft.granularity = 1.0f this.axisLeft.granularity = 1.0f
this.axisLeft.textColor = ContextCompat.getColor(context, R.color.chart_default) this.axisLeft.textColor = ContextCompat.getColor(context, R.color.chart_default)
this.axisLeft.typeface = Typeface.DEFAULT this.axisLeft.typeface = ResourcesCompat.getFont(context, R.font.roboto_medium)
this.axisLeft.labelCount = this.axisLeft.labelCount = if (small) 1 else 7 // @todo not great if interval is [0..2] for number of records as we get decimals
if (small) 1 else 7 // @todo not great if interval is [0..2] for number of records as we get decimals this.axisLeft.textSize = 12f
this.axisRight.isEnabled = false this.axisRight.isEnabled = false
this.legend.isEnabled = false this.legend.isEnabled = false
this.data.isHighlightEnabled = !small
this.description.isEnabled = false
// @todo // @todo

@ -329,6 +329,7 @@ enum class RowViewType(private var layoutRes: Int) {
val colors = arrayOf(R.color.green_light).toIntArray() val colors = arrayOf(R.color.green_light).toIntArray()
dataSet.setColors(colors, context) dataSet.setColors(colors, context)
dataSet.setDrawCircles(false) dataSet.setDrawCircles(false)
dataSet.setDrawValues(false)
val lineData = LineData(listOf(dataSet)) val lineData = LineData(listOf(dataSet))
val chartView = when (row.stat.graphType) { val chartView = when (row.stat.graphType) {
@ -348,7 +349,7 @@ enum class RowViewType(private var layoutRes: Int) {
it.addView(chartView) it.addView(chartView)
} }
chartView.setStyle(false, context) chartView.setStyle(true, context)
chartView.setTouchEnabled(false) chartView.setTouchEnabled(false)
chartView.highlightValue((entries.size - 1).toFloat(), 0) chartView.highlightValue((entries.size - 1).toFloat(), 0)
} }

Loading…
Cancel
Save