|
|
|
@ -26,9 +26,9 @@ import timber.log.Timber |
|
|
|
|
|
|
|
|
|
|
|
class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
|
|
|
|
|
|
|
|
enum class LegendType { |
|
|
|
enum class Style { |
|
|
|
DEFAULT, |
|
|
|
LINE, |
|
|
|
DEFAULT_BAR, |
|
|
|
BAR, |
|
|
|
MULTILINE, |
|
|
|
MULTILINE, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -37,9 +37,9 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create new instance |
|
|
|
* Create new instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun newInstance(lineDataSets: List<LineDataSet>? = null, barDataSets: List<BarDataSet>? = null, legendType: LegendType = LegendType.DEFAULT): GraphFragment { |
|
|
|
fun newInstance(lineDataSets: List<LineDataSet>? = null, barDataSets: List<BarDataSet>? = null, style: Style = Style.LINE): GraphFragment { |
|
|
|
val fragment = GraphFragment() |
|
|
|
val fragment = GraphFragment() |
|
|
|
fragment.legendType = legendType |
|
|
|
fragment.style = style |
|
|
|
fragment.lineDataSetList = lineDataSets |
|
|
|
fragment.lineDataSetList = lineDataSets |
|
|
|
fragment.barDataSetList = barDataSets |
|
|
|
fragment.barDataSetList = barDataSets |
|
|
|
val bundle = Bundle() |
|
|
|
val bundle = Bundle() |
|
|
|
@ -51,7 +51,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
|
|
|
|
|
|
|
|
private lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
private lateinit var parentActivity: PokerAnalyticsActivity |
|
|
|
|
|
|
|
|
|
|
|
private var legendType: LegendType = LegendType.DEFAULT |
|
|
|
private var style: Style = Style.LINE |
|
|
|
private lateinit var legendView: LegendView |
|
|
|
private lateinit var legendView: LegendView |
|
|
|
|
|
|
|
|
|
|
|
private var lineDataSetList: List<LineDataSet>? = null |
|
|
|
private var lineDataSetList: List<LineDataSet>? = null |
|
|
|
@ -103,8 +103,8 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
parentActivity = activity as PokerAnalyticsActivity |
|
|
|
parentActivity = activity as PokerAnalyticsActivity |
|
|
|
parentActivity.title = stat.localizedTitle(requireContext()) |
|
|
|
parentActivity.title = stat.localizedTitle(requireContext()) |
|
|
|
|
|
|
|
|
|
|
|
this.legendView = when (this.legendType) { |
|
|
|
this.legendView = when (this.style) { |
|
|
|
LegendType.MULTILINE -> MultiLineLegendView(requireContext()) |
|
|
|
Style.MULTILINE -> MultiLineLegendView(requireContext()) |
|
|
|
else -> LegendView(requireContext()) |
|
|
|
else -> LegendView(requireContext()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -132,7 +132,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
this.chartView = lineChart |
|
|
|
this.chartView = lineChart |
|
|
|
|
|
|
|
|
|
|
|
dataSets.firstOrNull()?.let { |
|
|
|
dataSets.firstOrNull()?.let { |
|
|
|
this.legendView.prepareWithStat(this.stat, it.entryCount, this.legendType) |
|
|
|
this.legendView.prepareWithStat(this.stat, it.entryCount, this.style) |
|
|
|
lastEntry = it.getEntryForIndex(it.entryCount - 1) |
|
|
|
lastEntry = it.getEntryForIndex(it.entryCount - 1) |
|
|
|
groupName = it.label |
|
|
|
groupName = it.label |
|
|
|
} |
|
|
|
} |
|
|
|
@ -141,7 +141,7 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
|
|
|
|
|
|
|
|
this.barDataSetList?.let { dataSets -> |
|
|
|
this.barDataSetList?.let { dataSets -> |
|
|
|
|
|
|
|
|
|
|
|
this.legendView.prepareWithStat(this.stat, legendType = this.legendType) |
|
|
|
this.legendView.prepareWithStat(this.stat, style = this.style) |
|
|
|
val barChart = BarChart(context) |
|
|
|
val barChart = BarChart(context) |
|
|
|
if (stat.showXAxisZero) { |
|
|
|
if (stat.showXAxisZero) { |
|
|
|
barChart.xAxis.axisMinimum = 0.0f |
|
|
|
barChart.xAxis.axisMinimum = 0.0f |
|
|
|
@ -202,8 +202,9 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener { |
|
|
|
is GraphUnderlyingEntry -> entry.data as GraphUnderlyingEntry? |
|
|
|
is GraphUnderlyingEntry -> entry.data as GraphUnderlyingEntry? |
|
|
|
else -> null |
|
|
|
else -> null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
statEntry?.let { |
|
|
|
statEntry?.let { |
|
|
|
val legendValue = it.legendValues(stat, entry, this.legendType, groupName, requireContext()) |
|
|
|
val legendValue = it.legendValues(stat, entry, this.style, groupName, requireContext()) |
|
|
|
this.legendView.setItemData(legendValue) |
|
|
|
this.legendView.setItemData(legendValue) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|