package jackall.moncalc.model
import android.graphics.Color
import com.github.mikephil.charting.data.PieData
import com.github.mikephil.charting.data.PieDataSet
import com.github.mikephil.charting.data.PieEntry
import com.github.mikephil.charting.utils.ColorTemplate
/**
* Created by matsumoto_k on 2017/11/04.
*/
class PieChartModel(entries: ArrayList<PieEntry>, labels: String) {
val dataSets = PieDataSet(entries, labels)
val pieData by lazy {
val pieData = PieData(dataSets)
pieData.setValueTextColor(Color.BLACK)
pieData
}
init {
setDataSetsConfig()
}
fun setValueLinePart(length1: Float, length2: Float) {
dataSets.valueLinePart1Length = length1
dataSets.valueLinePart2Length = length2
}
fun setDataSetsConfig() {
dataSets.setSliceSpace(2f)
dataSets.setValueTextSize(15f)
dataSets.setXValuePosition(PieDataSet.ValuePosition.INSIDE_SLICE);
val colors = ArrayList<Int>()
for (c in ColorTemplate.VORDIPLOM_COLORS)
colors.add(c)
for (c in ColorTemplate.JOYFUL_COLORS)
colors.add(c)
dataSets.colors = colors
dataSets.valueTextColor = Color.BLACK
}
}