Graph Refactoring

feature/top10
Laurent 7 years ago
parent b376ad2547
commit c4d6f19d67
  1. 6
      app/src/main/java/net/pokeranalytics/android/calculus/Report.kt
  2. 18
      app/src/main/java/net/pokeranalytics/android/calculus/Stat.kt
  3. 30
      app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt
  4. 14
      app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt

@ -370,7 +370,9 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
entries.add(BarEntry(p.x.toFloat(), p.y.toFloat(), p.data))
}
}
return BarDataSet(entries, stat.name)
val dataSet = BarDataSet(entries, stat.name)
dataSet.setDrawValues(false)
return dataSet
}
fun distributionEntries(stat: Stat, context: Context): BarDataSet {
@ -391,7 +393,6 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
}
}
negative.forEachIndexed { index, p ->
entries.add(BarEntry(index.toFloat(), abs(p.y.toFloat()), p.data))
colors.add(context.getColor(R.color.red))
@ -405,6 +406,7 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
}
val dataSet = BarDataSet(entries, stat.name)
dataSet.colors = colors
dataSet.setDrawValues(false)
return dataSet
}

@ -94,16 +94,6 @@ enum class Stat : RowRepresentable {
TOTAL_BUYIN,
;
/**
* Returns whether the stat evolution numericValues requires a distribution sorting
*/
fun hasDistributionSorting(): Boolean {
return when (this) {
STANDARD_DEVIATION, STANDARD_DEVIATION_HOURLY, STANDARD_DEVIATION_BB_PER_100_HANDS -> true
else -> false
}
}
companion object {
fun returnOnInvestment(netResult: Double, buyin: Double): Double? {
@ -224,14 +214,6 @@ enum class Stat : RowRepresentable {
}
}
val graphType: GraphType
get() {
return when (this) {
NUMBER_OF_SETS, NUMBER_OF_GAMES -> GraphType.BAR
else -> GraphType.LINE
}
}
val aggregationTypes: List<AggregationType>
get() {
return when (this) {

@ -45,7 +45,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
private lateinit var parentActivity: PokerAnalyticsActivity
private lateinit var selectedReport: Report
private lateinit var legendView: LegendView
private lateinit var chartView: BarLineChartBase<*>
private var chartView: BarLineChartBase<*>? = null
private var stat: Stat = Stat.NET_RESULT
private var aggregationType: AggregationType = AggregationType.SESSION
@ -89,14 +89,6 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
this.legendView = LegendView(requireContext())
this.legendContainer.addView(this.legendView)
this.chartView = when (stat.graphType) {
GraphType.LINE -> LineChart(context)
GraphType.BAR -> BarChart(context)
}
val axisFormatting = aggregationType.axisFormatting
this.chartView.setStyle(false, axisFormatting, requireContext())
this.chartContainer.addView(this.chartView)
}
/**
@ -121,11 +113,19 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
this.legendView.prepareWithStat(this.stat, dataSet.entryCount)
// initialize chart
if (this.chartView == null) {
this.chartView = when (dataSet) {
is LineDataSet -> LineChart(context)
is BarDataSet -> BarChart(context)
else -> null
}
this.chartContainer.addView(this.chartView)
}
when (dataSet) {
is LineDataSet -> {
val lineChart: LineChart = this.chartView as LineChart
// val colors = arrayOf(R.color.green_light).toIntArray()
// dataSet.setColors(colors, context)
val lineData = LineData(listOf(dataSet))
lineChart.data = lineData
}
@ -139,12 +139,14 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
}
val axisFormatting = aggregationType.axisFormatting
this.chartView.setStyle(false, axisFormatting, requireContext())
this.chartView.setOnChartValueSelectedListener(this)
this.chartView?.let {
it.setStyle(false, axisFormatting, requireContext())
it.setOnChartValueSelectedListener(this)
}
this.selectValue(dataSet.getEntryForIndex(dataSet.entryCount - 1))
// this.chartView.highlightValue((entries.size - 1).toFloat(), 0)
}
}

@ -335,20 +335,6 @@ enum class RowViewType(private var layoutRes: Int) {
else -> null
}
// val lineData = LineData(listOf(dataSet))
//
// val chartView = when (row.stat.graphType) {
// GraphType.LINE -> {
// val lineChart = LineChart(context)
// lineChart.data = lineData
// lineChart
// }
// GraphType.BAR -> {
// val barChart = BarChart(context)
// barChart
// }
// }
itemView.findViewById<FrameLayout?>(R.id.chartContainer)?.let {
it.removeAllViews()
it.addView(chartView)

Loading…
Cancel
Save