Improving legend

feature/top10
Laurent 7 years ago
parent 2ffe7968be
commit 80bb0a97cd
  1. 8
      app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt
  2. 11
      app/src/main/java/net/pokeranalytics/android/ui/view/LegendView.kt

@ -92,13 +92,15 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener {
dataSetList.firstOrNull()?.let { dataSet -> dataSetList.firstOrNull()?.let { dataSet ->
this.legendView.prepareWithStat(this.stat, dataSet.entryCount)
// initialize chart // initialize chart
this.chartContainer.removeAllViews() this.chartContainer.removeAllViews()
this.chartView = when (dataSet) { this.chartView = when (dataSet) {
is LineDataSet -> LineChart(context) is LineDataSet -> {
this.legendView.prepareWithStat(this.stat, dataSet.entryCount)
LineChart(context)
}
is BarDataSet -> { is BarDataSet -> {
this.legendView.prepareWithStat(this.stat)
val barChart = BarChart(context) val barChart = BarChart(context)
if (stat.showXAxisZero) { if (stat.showXAxisZero) {
barChart.xAxis.axisMinimum = 0.0f barChart.xAxis.axisMinimum = 0.0f

@ -49,7 +49,7 @@ class LegendView : FrameLayout {
/** /**
* Set the stat data to the view * Set the stat data to the view
*/ */
fun prepareWithStat(stat: Stat, counter: Int) { fun prepareWithStat(stat: Stat, counter: Int? = null) {
if (stat.significantIndividualValue) { if (stat.significantIndividualValue) {
this.stat1Name.text = stat.localizedTitle(context) this.stat1Name.text = stat.localizedTitle(context)
@ -60,9 +60,12 @@ class LegendView : FrameLayout {
this.stat2Value.isVisible = false this.stat2Value.isVisible = false
} }
val counterText = "$counter ${context.getString(R.string.sessions)}" counter?.let {
this.counter.text = counterText val counterText = "$it ${context.getString(R.string.sessions)}"
this.counter.isVisible = stat.shouldShowNumberOfSessions this.counter.text = counterText
this.counter.isVisible = stat.shouldShowNumberOfSessions
}
} }

Loading…
Cancel
Save