parent
d7a2f100af
commit
44202dc50b
@ -1,76 +1,63 @@ |
|||||||
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.util.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.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) |
// Y Axis |
||||||
chart.xAxis.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) |
this.axisLeft.setDrawAxisLine(false) |
||||||
chart.xAxis.textColor = ContextCompat.getColor(context, R.color.chart_default) |
this.axisLeft.setDrawGridLines(true) |
||||||
chart.xAxis.labelCount = 4 |
this.axisLeft.enableGridDashedLine(3.0f.px, 5.0f.px, 1.0f.px) |
||||||
chart.xAxis.position = XAxis.XAxisPosition.BOTTOM |
|
||||||
|
|
||||||
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.axisLeft.isGranularityEnabled = true |
||||||
// this.xAxis.enableGridDashedLine(3.0f, 5.0f, 1.0f) |
this.axisLeft.granularity = 1.0f |
||||||
// |
|
||||||
// this.xAxis.labelTextColor = ChartAppearance.defaultColor |
this.axisLeft.textColor = ContextCompat.getColor(context, R.color.chart_default) |
||||||
// this.xAxis.labelFont = Fonts.graphAxis |
this.axisLeft.typeface = Typeface.DEFAULT |
||||||
// this.xAxis.labelCount = 4 |
this.axisLeft.labelCount = |
||||||
// this.xAxis.labelPosition = .bottom |
if (small) 1 else 7 // @todo not great if interval is [0..2] for number of records as we get decimals |
||||||
// |
|
||||||
// this.xAxis.drawLabelsEnabled = true |
this.axisRight.isEnabled = false |
||||||
// this.xAxis.drawGridLinesEnabled = true |
this.legend.isEnabled = false |
||||||
// this.xAxis.granularity = 1.0 |
|
||||||
// this.xAxis.granularityEnabled = true |
|
||||||
// this.xAxis.enabled = true |
// @todo |
||||||
// |
|
||||||
// // 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 |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue