Start of Distribution chart + refactoring

feature/top10
Laurent 7 years ago
parent ca2ef99609
commit 0408c8e7b2
  1. 15
      app/src/main/java/net/pokeranalytics/android/calculus/Calculator.kt
  2. 100
      app/src/main/java/net/pokeranalytics/android/calculus/Report.kt
  3. 4
      app/src/main/java/net/pokeranalytics/android/ui/fragment/CalendarDetailsFragment.kt
  4. 95
      app/src/main/java/net/pokeranalytics/android/ui/fragment/GraphFragment.kt
  5. 1
      app/src/main/java/net/pokeranalytics/android/ui/graph/ChartDataSet.kt
  6. 53
      app/src/main/java/net/pokeranalytics/android/ui/view/RowViewType.kt

@ -177,7 +177,7 @@ class Calculator {
results.computeStatVariations(comparedResults) results.computeStatVariations(comparedResults)
} }
if (options.shouldManageMultiGroupProgressValues == true) { if (options.shouldManageMultiGroupProgressValues) {
group.comparedComputedResults = report.results.lastOrNull() group.comparedComputedResults = report.results.lastOrNull()
} }
@ -268,15 +268,15 @@ class Calculator {
// Iterate for each session // Iterate for each session
if (shouldIterateOverComputables) { if (shouldIterateOverComputables) {
var index: Int = 0 var index = 0
var tSum = 0.0 var tSum = 0.0
var tBBSum = 0.0 var tBBSum = 0.0
var tBBSessionCount = 0 var tBBSessionCount = 0
var tWinningSessionCount = 0 var tWinningSessionCount = 0
var tBuyinSum = 0.0 var tBuyinSum = 0.0
var tHands = 0.0 var tHands = 0.0
var longestWinStreak = 0; var longestWinStreak = 0
var longestLoseStreak = 0; var longestLoseStreak = 0
var currentStreak = 0 var currentStreak = 0
computables.forEach { computable -> computables.forEach { computable ->
@ -316,6 +316,7 @@ class Calculator {
data = session data = session
) )
results.addEvolutionValue(tBuyinSum / index, stat = AVERAGE_BUYIN, data = session) results.addEvolutionValue(tBuyinSum / index, stat = AVERAGE_BUYIN, data = session)
results.addEvolutionValue(computable.ratedNet, stat = STANDARD_DEVIATION, data = session)
Stat.netBBPer100Hands(tBBSum, tHands)?.let { netBB100 -> Stat.netBBPer100Hands(tBBSum, tHands)?.let { netBB100 ->
results.addEvolutionValue(netBB100, stat = NET_BB_PER_100_HANDS, data = session) results.addEvolutionValue(netBB100, stat = NET_BB_PER_100_HANDS, data = session)
@ -355,7 +356,7 @@ class Calculator {
} }
} }
val shouldIterateOverSets = computableGroup.conditions.size > 0 || val shouldIterateOverSets = computableGroup.conditions.isNotEmpty() ||
options.evolutionValues != Options.EvolutionValues.NONE || options.evolutionValues != Options.EvolutionValues.NONE ||
options.computeDaysPlayed options.computeDaysPlayed
@ -366,8 +367,8 @@ class Calculator {
var tRatedNetSum = 0.0 var tRatedNetSum = 0.0
var tBBSum = 0.0 var tBBSum = 0.0
var tTotalHands = 0.0 var tTotalHands = 0.0
var tHourlyRate = 0.0 var tHourlyRate: Double
var tHourlyRateBB = 0.0 var tHourlyRateBB: Double
val daysSet = mutableSetOf<Date>() val daysSet = mutableSetOf<Date>()
var tMaxDuration = 0.0 var tMaxDuration = 0.0

@ -1,15 +1,17 @@
package net.pokeranalytics.android.calculus package net.pokeranalytics.android.calculus
import android.content.Context import android.content.Context
import com.github.mikephil.charting.data.BarEntry import com.github.mikephil.charting.data.*
import com.github.mikephil.charting.data.Entry
import io.realm.Realm import io.realm.Realm
import io.realm.RealmResults import io.realm.RealmResults
import net.pokeranalytics.android.R
import net.pokeranalytics.android.model.filter.QueryCondition import net.pokeranalytics.android.model.filter.QueryCondition
import net.pokeranalytics.android.model.interfaces.Timed import net.pokeranalytics.android.model.interfaces.Timed
import net.pokeranalytics.android.model.realm.ComputableResult import net.pokeranalytics.android.model.realm.ComputableResult
import net.pokeranalytics.android.model.realm.Filter import net.pokeranalytics.android.model.realm.Filter
import net.pokeranalytics.android.model.realm.SessionSet import net.pokeranalytics.android.model.realm.SessionSet
import net.pokeranalytics.android.ui.graph.PALineDataSet
import kotlin.math.abs
/** /**
* The class returned after performing calculation in the Calculator object * The class returned after performing calculation in the Calculator object
@ -34,7 +36,7 @@ class Report(var options: Calculator.Options) {
* Returns the list of entries corresponding to the provided [stat] * Returns the list of entries corresponding to the provided [stat]
* One value will be returned by result * One value will be returned by result
*/ */
fun lineEntries(stat: Stat): List<Entry> { fun lineEntries(stat: Stat, context: Context): LineDataSet {
val entries = mutableListOf<Entry>() val entries = mutableListOf<Entry>()
this._results.forEachIndexed { index, results -> this._results.forEachIndexed { index, results ->
@ -42,11 +44,11 @@ class Report(var options: Calculator.Options) {
entries.add(Entry(index.toFloat(), progressValue.toFloat(), results)) entries.add(Entry(index.toFloat(), progressValue.toFloat(), results))
} }
} }
return entries return PALineDataSet(entries, stat.name, context)
} }
fun barEntries(stat: Stat? = null): List<Entry> { fun barEntries(stat: Stat? = null): BarDataSet {
val entries = mutableListOf<Entry>() val entries = mutableListOf<BarEntry>()
val statToUse = stat ?: options.displayedStats.firstOrNull() val statToUse = stat ?: options.displayedStats.firstOrNull()
statToUse?.let { statToUse?.let {
@ -59,16 +61,16 @@ class Report(var options: Calculator.Options) {
} }
} }
return entries return BarDataSet(entries, stat?.name)
} }
fun multiLineEntries(): List<List<Entry>> { fun multiLineEntries(context: Context): List<List<Entry>> {
val entries = mutableListOf<List<Entry>>() val entries = mutableListOf<List<Entry>>()
options.displayedStats.forEach { stat -> options.displayedStats.forEach { stat ->
this._results.forEach { result -> this._results.forEach { result ->
val entryList = result.singleLineEntries(stat) val dataSet = result.singleLineEntries(stat, context)
entries.add(entryList) // entries.add(entryList)
} }
} }
@ -328,48 +330,55 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
this.consolidateProgressStats() this.consolidateProgressStats()
if (options.evolutionValues != Calculator.Options.EvolutionValues.NONE) { // if (options.evolutionValues != Calculator.Options.EvolutionValues.NONE) {
//
// Sort points as a distribution // // Sort points as a distribution
this._computedStats.keys.filter { it.hasDistributionSorting() }.forEach { _ -> // this._computedStats.keys.filter { it.hasDistributionSorting() }.forEach { stat ->
// @todo sort // // @todo sort
// var evolutionValues = this._evolutionValues[stat] // this._evolutionValues[stat]?.let { pointList ->
// evolutionValues.so //
} // pointList.sortBy { point ->
// return@sortBy true
} // }
//
// }
//
// }
//
// }
} }
// MPAndroidChart // MPAndroidChart
fun defaultStatEntries(stat: Stat): List<Entry> { fun defaultStatEntries(stat: Stat, context: Context): DataSet<out Entry> {
return when (stat) { return when (stat) {
Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES -> this.barEntries(stat) Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES -> this.barEntries(stat)
else -> this.singleLineEntries(stat) Stat.STANDARD_DEVIATION -> this.distributionEntries(stat, context)
else -> this.singleLineEntries(stat, context)
} }
} }
fun singleLineEntries(stat: Stat): List<Entry> { fun singleLineEntries(stat: Stat, context: Context): LineDataSet {
val entries = mutableListOf<Entry>() val entries = mutableListOf<Entry>()
this._evolutionValues[stat]?.let { points -> this._evolutionValues[stat]?.let { points ->
points.forEachIndexed { index, p -> points.forEachIndexed { index, p ->
entries.add(Entry(index.toFloat(), p.y.toFloat(), p.data)) entries.add(Entry(index.toFloat(), p.y.toFloat(), p.data))
} }
} }
return entries return PALineDataSet(entries, stat.name, context)
} }
fun durationEntries(stat: Stat): List<Entry> { fun durationEntries(stat: Stat, context: Context): LineDataSet {
val entries = mutableListOf<Entry>() val entries = mutableListOf<Entry>()
this._evolutionValues[stat]?.let { points -> this._evolutionValues[stat]?.let { points ->
points.forEach { p -> points.forEach { p ->
entries.add(Entry(p.x.toFloat(), p.y.toFloat(), p.data)) entries.add(Entry(p.x.toFloat(), p.y.toFloat(), p.data))
} }
} }
return entries return PALineDataSet(entries, stat.name, context)
} }
fun barEntries(stat: Stat): List<BarEntry> { fun barEntries(stat: Stat): BarDataSet {
val entries = mutableListOf<BarEntry>() val entries = mutableListOf<BarEntry>()
this._evolutionValues[stat]?.let { points -> this._evolutionValues[stat]?.let { points ->
@ -377,7 +386,42 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
entries.add(BarEntry(p.x.toFloat(), p.y.toFloat(), p.data)) entries.add(BarEntry(p.x.toFloat(), p.y.toFloat(), p.data))
} }
} }
return entries return BarDataSet(entries, stat.name)
}
fun distributionEntries(stat: Stat, context: Context): BarDataSet {
val colors = mutableListOf<Int>()
val entries = mutableListOf<BarEntry>()
this._evolutionValues[stat]?.let { points ->
val negative = mutableListOf<Point>()
val positive = mutableListOf<Point>()
points.forEach {
if (it.y < 0) {
negative.add(it)
} else {
positive.add(it)
}
}
negative.sortBy { it.y }
positive.sortByDescending { it.y }
negative.forEachIndexed { index, p ->
entries.add(BarEntry(index.toFloat(), abs(p.y.toFloat()), p.data))
colors.add(context.getColor(R.color.red))
}
positive.forEachIndexed { index, p ->
val x = negative.size + index.toFloat()
entries.add(BarEntry(x, p.y.toFloat(), p.data))
colors.add(context.getColor(R.color.green))
}
}
val dataSet = BarDataSet(entries, stat.name)
dataSet.colors = colors
return dataSet
} }
val isEmpty: Boolean val isEmpty: Boolean

@ -187,10 +187,10 @@ class CalendarDetailsFragment : PokerAnalyticsFragment(), StaticRowRepresentable
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.NET_RESULT), it.computedStat(Stat.HOURLY_RATE))) rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.NET_RESULT), it.computedStat(Stat.HOURLY_RATE)))
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.LOCATIONS_PLAYED), it.computedStat(Stat.LONGEST_STREAKS))) rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.LOCATIONS_PLAYED), it.computedStat(Stat.LONGEST_STREAKS)))
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.distribution)) rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.distribution))
rowRepresentables.add(GraphRow(report, Stat.NET_RESULT)) rowRepresentables.add(GraphRow(report, Stat.STANDARD_DEVIATION))
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.WIN_RATIO), it.computedStat(Stat.MAXIMUM_NETRESULT))) rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.WIN_RATIO), it.computedStat(Stat.MAXIMUM_NETRESULT)))
rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.volume)) rowRepresentables.add(CustomizableRowRepresentable(RowViewType.HEADER_TITLE, resId = R.string.volume))
rowRepresentables.add(GraphRow(report, Stat.NET_RESULT)) rowRepresentables.add(GraphRow(report, Stat.DURATION))
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.DURATION), it.computedStat(Stat.AVERAGE_DURATION))) rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.DURATION), it.computedStat(Stat.AVERAGE_DURATION)))
rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.DAYS_PLAYED), it.computedStat(Stat.MAXIMUM_DURATION))) rowRepresentables.add(StatDoubleRow(it.computedStat(Stat.DAYS_PLAYED), it.computedStat(Stat.MAXIMUM_DURATION)))
} }

@ -17,7 +17,6 @@ import net.pokeranalytics.android.R
import net.pokeranalytics.android.calculus.* import net.pokeranalytics.android.calculus.*
import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity import net.pokeranalytics.android.ui.activity.components.PokerAnalyticsActivity
import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment import net.pokeranalytics.android.ui.fragment.components.PokerAnalyticsFragment
import net.pokeranalytics.android.ui.graph.PALineDataSet
import net.pokeranalytics.android.ui.graph.setStyle import net.pokeranalytics.android.ui.graph.setStyle
import net.pokeranalytics.android.ui.view.LegendView import net.pokeranalytics.android.ui.view.LegendView
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
@ -65,33 +64,20 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
loadGraph() loadGraph()
} }
// OnChartValueSelectedListener /**
override fun onNothingSelected() { * Set data
// nothing to do */
} fun setData(report: Report, stat: Stat, aggregationType: AggregationType) {
override fun onValueSelected(e: Entry?, h: Highlight?) {
e?.let { entry ->
val statEntry = when (entry.data) {
is ObjectIdentifier -> {
val identifier = entry.data as ObjectIdentifier
getRealm().where(identifier.clazz).equalTo("id", identifier.id).findAll().firstOrNull()
}
is StatEntry -> entry.data as StatEntry?
else -> null
}
statEntry?.let {
val formattedDate = it.entryTitle this.selectedReport = report
val entryValue = it.formattedValue(this.stat, requireContext()) this.aggregationType = aggregationType
val totalStatValue = this.stat.format(entry.y.toDouble(), currency = null) this.stat = stat
this.legendView.setItemData(this.stat, formattedDate, entryValue, totalStatValue) if (isAdded && !isDetached) {
} loadGraph()
} }
} }
/** /**
* Init UI * Init UI
*/ */
@ -118,38 +104,33 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
*/ */
private fun loadGraph() { private fun loadGraph() {
val graphEntries = when (aggregationType) { val ds = when (aggregationType) {
AggregationType.SESSION -> selectedReport.results.firstOrNull()?.defaultStatEntries(stat) AggregationType.SESSION -> selectedReport.results.firstOrNull()?.defaultStatEntries(stat, requireContext())
AggregationType.DURATION -> { AggregationType.DURATION -> {
selectedReport.results.firstOrNull()?.durationEntries(stat) selectedReport.results.firstOrNull()?.durationEntries(stat, requireContext())
} }
AggregationType.MONTH, AggregationType.YEAR -> { AggregationType.MONTH, AggregationType.YEAR -> {
when (this.stat) { when (this.stat) {
Stat.NUMBER_OF_GAMES, Stat.NUMBER_OF_SETS -> selectedReport.barEntries(this.stat) Stat.NUMBER_OF_GAMES, Stat.NUMBER_OF_SETS -> selectedReport.barEntries(this.stat)
else -> selectedReport.lineEntries(this.stat) else -> selectedReport.lineEntries(this.stat, requireContext())
} }
} }
} }
graphEntries?.let { entries -> ds?.let { dataSet ->
this.legendView.prepareWithStat(this.stat, entries.size) this.legendView.prepareWithStat(this.stat, dataSet.entryCount)
when (stat.graphType) { when (dataSet) {
GraphType.LINE -> { is LineDataSet -> {
val lineChart: LineChart = this.chartView as LineChart val lineChart: LineChart = this.chartView as LineChart
val dataSet = PALineDataSet(entries, this.stat.name, requireContext())
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)
val lineData = LineData(listOf(dataSet)) val lineData = LineData(listOf(dataSet))
lineChart.data = lineData lineChart.data = lineData
} }
GraphType.BAR -> { is BarDataSet -> {
val barChart = this.chartView as BarChart val barChart = this.chartView as BarChart
val dataSet = BarDataSet(entries as List<BarEntry>, this.stat.name)
val colors = arrayOf(R.color.green_light).toIntArray() val colors = arrayOf(R.color.green_light).toIntArray()
dataSet.setColors(colors, context) dataSet.setColors(colors, context)
val barData = BarData(listOf(dataSet)) val barData = BarData(listOf(dataSet))
@ -161,23 +142,43 @@ class GraphFragment : PokerAnalyticsFragment(), OnChartValueSelectedListener, Co
this.chartView.setStyle(false, axisFormatting, requireContext()) this.chartView.setStyle(false, axisFormatting, requireContext())
this.chartView.setOnChartValueSelectedListener(this) this.chartView.setOnChartValueSelectedListener(this)
this.chartView.highlightValue((entries.size - 1).toFloat(), 0) this.selectValue(dataSet.getEntryForIndex(dataSet.entryCount - 1))
// this.chartView.highlightValue((entries.size - 1).toFloat(), 0)
} }
} }
/** // OnChartValueSelectedListener
* Set data override fun onNothingSelected() {
*/ // nothing to do
fun setData(report: Report, stat: Stat, aggregationType: AggregationType) { }
this.selectedReport = report override fun onValueSelected(e: Entry?, h: Highlight?) {
this.aggregationType = aggregationType e?.let { entry ->
this.stat = stat this.selectValue(entry)
}
}
if (isAdded && !isDetached) { private fun selectValue(entry: Entry) {
loadGraph()
val statEntry = when (entry.data) {
is ObjectIdentifier -> {
val identifier = entry.data as ObjectIdentifier
getRealm().where(identifier.clazz).equalTo("id", identifier.id).findAll().firstOrNull()
} }
is StatEntry -> entry.data as StatEntry?
else -> null
}
statEntry?.let {
val formattedDate = it.entryTitle
val entryValue = it.formattedValue(this.stat, requireContext())
val totalStatValue = this.stat.format(entry.y.toDouble(), currency = null)
this.legendView.setItemData(this.stat, formattedDate, entryValue, totalStatValue)
}
} }
} }

@ -10,6 +10,7 @@ class PALineDataSet(yVals: List<Entry>, label: String, context: Context) : LineD
init { init {
this.highLightColor = context.getColor(R.color.chart_highlight_indicator) this.highLightColor = context.getColor(R.color.chart_highlight_indicator)
this.setDrawValues(false) this.setDrawValues(false)
this.setDrawCircles(false)
} }
} }

@ -13,17 +13,18 @@ import androidx.core.widget.ContentLoadingProgressBar
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.mikephil.charting.charts.BarChart import com.github.mikephil.charting.charts.BarChart
import com.github.mikephil.charting.charts.LineChart import com.github.mikephil.charting.charts.LineChart
import com.github.mikephil.charting.data.BarData
import com.github.mikephil.charting.data.BarDataSet
import com.github.mikephil.charting.data.LineData import com.github.mikephil.charting.data.LineData
import com.github.mikephil.charting.data.LineDataSet
import kotlinx.android.synthetic.main.row_history_session.view.* import kotlinx.android.synthetic.main.row_history_session.view.*
import kotlinx.android.synthetic.main.row_transaction.view.* import kotlinx.android.synthetic.main.row_transaction.view.*
import net.pokeranalytics.android.R import net.pokeranalytics.android.R
import net.pokeranalytics.android.calculus.GraphType
import net.pokeranalytics.android.model.realm.Session import net.pokeranalytics.android.model.realm.Session
import net.pokeranalytics.android.model.realm.Transaction import net.pokeranalytics.android.model.realm.Transaction
import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter import net.pokeranalytics.android.ui.adapter.RowRepresentableAdapter
import net.pokeranalytics.android.ui.extensions.setTextFormat import net.pokeranalytics.android.ui.extensions.setTextFormat
import net.pokeranalytics.android.ui.graph.AxisFormatting import net.pokeranalytics.android.ui.graph.AxisFormatting
import net.pokeranalytics.android.ui.graph.PALineDataSet
import net.pokeranalytics.android.ui.graph.setStyle import net.pokeranalytics.android.ui.graph.setStyle
import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable import net.pokeranalytics.android.ui.view.rowrepresentable.CustomizableRowRepresentable
import net.pokeranalytics.android.ui.view.rowrepresentable.GraphRow import net.pokeranalytics.android.ui.view.rowrepresentable.GraphRow
@ -149,9 +150,7 @@ enum class RowViewType(private var layoutRes: Int) {
val listener = View.OnClickListener { val listener = View.OnClickListener {
adapter.delegate?.onRowSelected(position, row) adapter.delegate?.onRowSelected(position, row)
} }
itemView.findViewById<View?>(R.id.container)?.let { itemView.findViewById<View?>(R.id.container)?.setOnClickListener(listener)
it.setOnClickListener(listener)
}
} }
} }
@ -189,9 +188,7 @@ enum class RowViewType(private var layoutRes: Int) {
} }
} }
itemView.findViewById<View?>(R.id.container)?.let { itemView.findViewById<View?>(R.id.container)?.setOnClickListener(listener)
it.setOnClickListener(listener)
}
} }
// Switch // Switch
@ -318,41 +315,51 @@ enum class RowViewType(private var layoutRes: Int) {
BindableHolder { BindableHolder {
override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) { override fun bind(position: Int, row: RowRepresentable, adapter: RowRepresentableAdapter) {
//TODO: Implementation
if (row is GraphRow) { if (row is GraphRow) {
row.report.results.firstOrNull()?.defaultStatEntries(row.stat)?.let { entries -> row.report.results.firstOrNull()?.defaultStatEntries(row.stat, itemView.context)?.let { dataSet ->
val context = itemView.context val context = itemView.context
val dataSet = PALineDataSet(entries, row.stat.name, context) val chartView = when (dataSet) {
val colors = arrayOf(R.color.green_light).toIntArray() is LineDataSet -> {
dataSet.setColors(colors, context)
dataSet.setDrawCircles(false)
dataSet.setDrawValues(false)
val lineData = LineData(listOf(dataSet))
val chartView = when (row.stat.graphType) {
GraphType.LINE -> {
val lineChart = LineChart(context) val lineChart = LineChart(context)
lineChart.data = lineData lineChart.data = LineData(dataSet)
lineChart lineChart
} }
GraphType.BAR -> { is BarDataSet -> {
val barChart = BarChart(context) val barChart = BarChart(context)
barChart.data = BarData(dataSet)
barChart barChart
} }
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 { itemView.findViewById<FrameLayout?>(R.id.chartContainer)?.let {
it.removeAllViews() it.removeAllViews()
it.addView(chartView) it.addView(chartView)
} }
chartView?.let {
chartView.setStyle(true, AxisFormatting.DEFAULT, context) chartView.setStyle(true, AxisFormatting.DEFAULT, context)
chartView.setTouchEnabled(false) chartView.setTouchEnabled(false)
chartView.highlightValue((entries.size - 1).toFloat(), 0) }
// chartView.highlightValue((entries.size - 1).toFloat(), 0)
} }
} }

Loading…
Cancel
Save