Search in sources :

Example 11 with PieEntry

use of com.github.mikephil.charting.data.PieEntry in project MPAndroidChart by PhilJay.

the class SimpleFragment method generatePieData.

/**
     * generates less data (1 DataSet, 4 values)
     * @return
     */
protected PieData generatePieData() {
    int count = 4;
    ArrayList<PieEntry> entries1 = new ArrayList<PieEntry>();
    for (int i = 0; i < count; i++) {
        entries1.add(new PieEntry((float) ((Math.random() * 60) + 40), "Quarter " + (i + 1)));
    }
    PieDataSet ds1 = new PieDataSet(entries1, "Quarterly Revenues 2015");
    ds1.setColors(ColorTemplate.VORDIPLOM_COLORS);
    ds1.setSliceSpace(2f);
    ds1.setValueTextColor(Color.WHITE);
    ds1.setValueTextSize(12f);
    PieData d = new PieData(ds1);
    d.setValueTypeface(tf);
    return d;
}
Also used : PieEntry(com.github.mikephil.charting.data.PieEntry) PieDataSet(com.github.mikephil.charting.data.PieDataSet) ArrayList(java.util.ArrayList) PieData(com.github.mikephil.charting.data.PieData)

Example 12 with PieEntry

use of com.github.mikephil.charting.data.PieEntry in project MPAndroidChart by PhilJay.

the class ListViewMultiChartActivity method generateDataPie.

/**
     * generates a random ChartData object with just one DataSet
     * 
     * @return
     */
private PieData generateDataPie(int cnt) {
    ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
    for (int i = 0; i < 4; i++) {
        entries.add(new PieEntry((float) ((Math.random() * 70) + 30), "Quarter " + (i + 1)));
    }
    PieDataSet d = new PieDataSet(entries, "");
    // space between slices
    d.setSliceSpace(2f);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    PieData cd = new PieData(d);
    return cd;
}
Also used : PieEntry(com.github.mikephil.charting.data.PieEntry) PieDataSet(com.github.mikephil.charting.data.PieDataSet) ArrayList(java.util.ArrayList) PieData(com.github.mikephil.charting.data.PieData)

Aggregations

PieData (com.github.mikephil.charting.data.PieData)12 PieDataSet (com.github.mikephil.charting.data.PieDataSet)12 PieEntry (com.github.mikephil.charting.data.PieEntry)12 ArrayList (java.util.ArrayList)11 PercentFormatter (com.github.mikephil.charting.formatter.PercentFormatter)4 IValueFormatter (com.github.mikephil.charting.formatter.IValueFormatter)2 MPPointF (com.github.mikephil.charting.utils.MPPointF)2 ActivityAmounts (nodomain.freeyourgadget.gadgetbridge.model.ActivityAmounts)2 Paint (android.graphics.Paint)1 Point (android.graphics.Point)1 Drawable (android.graphics.drawable.Drawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TextPaint (android.text.TextPaint)1 View (android.view.View)1 TextView (android.widget.TextView)1 LegendEntry (com.github.mikephil.charting.components.LegendEntry)1 Entry (com.github.mikephil.charting.data.Entry)1 IPieDataSet (com.github.mikephil.charting.interfaces.datasets.IPieDataSet)1 ViewPortHandler (com.github.mikephil.charting.utils.ViewPortHandler)1 NumberFormat (java.text.NumberFormat)1