parent
d7a2f100af
commit
44202dc50b
@ -1,76 +1,63 @@ |
||||
package net.pokeranalytics.android.ui.graph |
||||
|
||||
import android.content.Context |
||||
import android.graphics.Typeface |
||||
import androidx.core.content.ContextCompat |
||||
import com.github.mikephil.charting.charts.BarLineChartBase |
||||
import com.github.mikephil.charting.components.XAxis |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.util.extensions.px |
||||
|
||||
//fun BarChart.setStyle(context: Context) { |
||||
// GraphHelper.setStyle(this, context) |
||||
//} |
||||
fun BarLineChartBase<*>.setStyle(small: Boolean, context: Context) { |
||||
|
||||
fun BarLineChartBase<*>.setStyle(context: Context) { |
||||
GraphHelper.setStyle(this, context) |
||||
} |
||||
// X Axis |
||||
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.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) |
||||
|
||||
companion object { |
||||
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 |
||||
|
||||
fun setStyle(chart: BarLineChartBase<*>, context: Context) { |
||||
this.xAxis.setDrawLabels(true) |
||||
this.xAxis.setDrawGridLines(true) |
||||
this.xAxis.granularity = 1.0f |
||||
this.xAxis.isGranularityEnabled = true |
||||
this.xAxis.isEnabled = true |
||||
|
||||
chart.xAxis.axisLineColor = ContextCompat.getColor(context, R.color.chart_default) |
||||
chart.xAxis.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) |
||||
chart.xAxis.textColor = ContextCompat.getColor(context, R.color.chart_default) |
||||
chart.xAxis.labelCount = 4 |
||||
chart.xAxis.position = XAxis.XAxisPosition.BOTTOM |
||||
// Y Axis |
||||
this.axisLeft.setDrawAxisLine(false) |
||||
this.axisLeft.setDrawGridLines(true) |
||||
this.axisLeft.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) |
||||
|
||||
chart.axisLeft.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) |
||||
this.axisLeft.setDrawZeroLine(true) |
||||
// this.axisLeft.zeroLineWidth = 1.0f.px |
||||
this.axisLeft.zeroLineColor = ContextCompat.getColor(context, R.color.chart_default) |
||||
|
||||
// this.xAxis.axisLineWidth = ChartAppearance.lineWidth |
||||
// this.xAxis.enableGridDashedLine(3.0f, 5.0f, 1.0f) |
||||
// |
||||
// this.xAxis.labelTextColor = ChartAppearance.defaultColor |
||||
// this.xAxis.labelFont = Fonts.graphAxis |
||||
// this.xAxis.labelCount = 4 |
||||
// this.xAxis.labelPosition = .bottom |
||||
// |
||||
// this.xAxis.drawLabelsEnabled = true |
||||
// this.xAxis.drawGridLinesEnabled = true |
||||
// 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 |
||||
// |
||||
this.axisLeft.isGranularityEnabled = true |
||||
this.axisLeft.granularity = 1.0f |
||||
|
||||
this.axisLeft.textColor = ContextCompat.getColor(context, R.color.chart_default) |
||||
this.axisLeft.typeface = Typeface.DEFAULT |
||||
this.axisLeft.labelCount = |
||||
if (small) 1 else 7 // @todo not great if interval is [0..2] for number of records as we get decimals |
||||
|
||||
this.axisRight.isEnabled = false |
||||
this.legend.isEnabled = false |
||||
|
||||
|
||||
// @todo |
||||
// if timeYAxis { |
||||
// this.leftAxis.valueFormatter = HourValueFormatter() |
||||
// this.axisLeft.valueFormatter = HourValueFormatter() |
||||
// } else { |
||||
// this.leftAxis.valueFormatter = LargeNumberFormatter() |
||||
// this.axisLeft.valueFormatter = LargeNumberFormatter() |
||||
// } |
||||
// |
||||
// this.rightAxis.enabled = false |
||||
// |
||||
// this.legend.enabled = false |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
Loading…
Reference in new issue