package net.pokeranalytics.android.ui.graph

import android.content.Context
import com.github.mikephil.charting.data.BarDataSet
import com.github.mikephil.charting.data.BarEntry
import com.github.mikephil.charting.data.Entry
import com.github.mikephil.charting.data.LineDataSet
import net.pokeranalytics.android.R

class DataSetFactory {

	companion object {

		fun lineDataSetInstance(yVals: List<Entry>, label: String, context: Context) : LineDataSet {

			val lineDataSet = LineDataSet(yVals, label)
			lineDataSet.highLightColor = context.getColor(R.color.chart_highlight_indicator)
			lineDataSet.setDrawValues(false)
			lineDataSet.setDrawCircles(false)

			val colors = arrayOf(R.color.green_light).toIntArray()
			lineDataSet.setColors(colors, context)

			return lineDataSet
		}

		fun barDataSetInstance(entries: List<BarEntry>, label: String, context: Context, colors: MutableList<Int>? = null) : BarDataSet {

			val barDataSet = BarDataSet(entries, label)
			if (colors != null) {
				barDataSet.colors = colors
			} else {
				barDataSet.color = context.getColor(R.color.chart_bar)
			}
			barDataSet.highLightColor = context.getColor(R.color.chart_selected_bar)
			barDataSet.setDrawValues(false)
			return barDataSet
		}

	}

}
