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 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) dataSets.colors = colors dataSets.valueTextColor = Color.BLACK } }