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.ui.extensions.px

fun BarLineChartBase<*>.setStyle(small: Boolean, context: 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

	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

	this.xAxis.setDrawLabels(true)
	this.xAxis.setDrawGridLines(true)
	this.xAxis.granularity = 1.0f
	this.xAxis.isGranularityEnabled = true
	this.xAxis.isEnabled = true

	// Y Axis
	this.axisLeft.setDrawAxisLine(false)
	this.axisLeft.setDrawGridLines(true)
	this.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.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.axisLeft.valueFormatter = HourValueFormatter()
//			} else {
//				this.axisLeft.valueFormatter = LargeNumberFormatter()
//			}
//


}
