|
|
|
@ -1,76 +1,61 @@ |
|
|
|
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 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.util.extensions.px |
|
|
|
import net.pokeranalytics.android.ui.extensions.px |
|
|
|
|
|
|
|
|
|
|
|
//fun BarChart.setStyle(context: Context) { |
|
|
|
fun BarLineChartBase<*>.setStyle(small: Boolean, context: Context) { |
|
|
|
// GraphHelper.setStyle(this, context) |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun BarLineChartBase<*>.setStyle(context: Context) { |
|
|
|
// X Axis |
|
|
|
GraphHelper.setStyle(this, context) |
|
|
|
this.xAxis.axisLineColor = ContextCompat.getColor(context, R.color.chart_default) |
|
|
|
} |
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
class GraphHelper { |
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
this.xAxis.setDrawLabels(true) |
|
|
|
|
|
|
|
this.xAxis.setDrawGridLines(true) |
|
|
|
|
|
|
|
this.xAxis.granularity = 1.0f |
|
|
|
|
|
|
|
this.xAxis.isGranularityEnabled = true |
|
|
|
|
|
|
|
this.xAxis.isEnabled = true |
|
|
|
|
|
|
|
|
|
|
|
fun setStyle(chart: BarLineChartBase<*>, context: Context) { |
|
|
|
// Y Axis |
|
|
|
|
|
|
|
this.axisLeft.setDrawAxisLine(false) |
|
|
|
|
|
|
|
this.axisLeft.setDrawGridLines(true) |
|
|
|
|
|
|
|
this.axisLeft.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) |
|
|
|
|
|
|
|
|
|
|
|
chart.xAxis.axisLineColor = ContextCompat.getColor(context, R.color.chart_default) |
|
|
|
this.axisLeft.setDrawZeroLine(true) |
|
|
|
chart.xAxis.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) |
|
|
|
// this.axisLeft.zeroLineWidth = 1.0f.px |
|
|
|
chart.xAxis.textColor = ContextCompat.getColor(context, R.color.chart_default) |
|
|
|
this.axisLeft.zeroLineColor = ContextCompat.getColor(context, R.color.chart_default) |
|
|
|
chart.xAxis.labelCount = 4 |
|
|
|
|
|
|
|
chart.xAxis.position = XAxis.XAxisPosition.BOTTOM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chart.axisLeft.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) |
|
|
|
this.axisLeft.isGranularityEnabled = true |
|
|
|
|
|
|
|
this.axisLeft.granularity = 1.0f |
|
|
|
|
|
|
|
|
|
|
|
// this.xAxis.axisLineWidth = ChartAppearance.lineWidth |
|
|
|
this.axisLeft.textColor = ContextCompat.getColor(context, R.color.chart_default) |
|
|
|
// this.xAxis.enableGridDashedLine(3.0f, 5.0f, 1.0f) |
|
|
|
this.axisLeft.typeface = Typeface.DEFAULT |
|
|
|
// |
|
|
|
this.axisLeft.labelCount = |
|
|
|
// this.xAxis.labelTextColor = ChartAppearance.defaultColor |
|
|
|
if (small) 1 else 7 // @todo not great if interval is [0..2] for number of records as we get decimals |
|
|
|
// this.xAxis.labelFont = Fonts.graphAxis |
|
|
|
|
|
|
|
// this.xAxis.labelCount = 4 |
|
|
|
this.axisRight.isEnabled = false |
|
|
|
// this.xAxis.labelPosition = .bottom |
|
|
|
this.legend.isEnabled = false |
|
|
|
// |
|
|
|
|
|
|
|
// this.xAxis.drawLabelsEnabled = true |
|
|
|
|
|
|
|
// this.xAxis.drawGridLinesEnabled = true |
|
|
|
// @todo |
|
|
|
// this.xAxis.granularity = 1.0 |
|
|
|
|
|
|
|
// this.xAxis.granularityEnabled = true |
|
|
|
|
|
|
|
// this.xAxis.enabled = true |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// // Y Axis |
|
|
|
|
|
|
|
// this.leftAxis.drawAxisLineEnabled = false |
|
|
|
|
|
|
|
// this.leftAxis.drawGridLinesEnabled = true |
|
|
|
|
|
|
|
// this.leftAxis.gridLineDashLengths = [3.0, 5.0] |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// this.leftAxis.drawZeroLineEnabled = true |
|
|
|
|
|
|
|
// this.leftAxis.zeroLineWidth = ChartAppearance.lineWidth |
|
|
|
|
|
|
|
// this.leftAxis.zeroLineColor = ChartAppearance.defaultColor |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// this.leftAxis.granularityEnabled = true |
|
|
|
|
|
|
|
// this.leftAxis.granularity = 1.0 |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// this.leftAxis.labelTextColor = ChartAppearance.defaultColor |
|
|
|
|
|
|
|
// this.leftAxis.labelFont = Fonts.graphAxis |
|
|
|
|
|
|
|
// this.leftAxis.labelCount = small ? 1 : 7 // @todo not great if interval is [0..2] for number of records as we get decimals |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// if timeYAxis { |
|
|
|
// if timeYAxis { |
|
|
|
// this.leftAxis.valueFormatter = HourValueFormatter() |
|
|
|
// this.axisLeft.valueFormatter = HourValueFormatter() |
|
|
|
// } else { |
|
|
|
// } else { |
|
|
|
// this.leftAxis.valueFormatter = LargeNumberFormatter() |
|
|
|
// this.axisLeft.valueFormatter = LargeNumberFormatter() |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// |
|
|
|
// this.rightAxis.enabled = false |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// this.legend.enabled = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|