Search in sources :

Example 16 with PieDataSet

use of com.github.mikephil.charting.data.PieDataSet 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 17 with PieDataSet

use of com.github.mikephil.charting.data.PieDataSet 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

PieDataSet (com.github.mikephil.charting.data.PieDataSet)17 ArrayList (java.util.ArrayList)13 PieData (com.github.mikephil.charting.data.PieData)12 PieEntry (com.github.mikephil.charting.data.PieEntry)11 Paint (android.graphics.Paint)5 Entry (com.github.mikephil.charting.data.Entry)5 PercentFormatter (com.github.mikephil.charting.formatter.PercentFormatter)4 ActivityAmounts (nodomain.freeyourgadget.gadgetbridge.model.ActivityAmounts)2 Point (android.graphics.Point)1 PointF (android.graphics.PointF)1 RectF (android.graphics.RectF)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 TextView (android.widget.TextView)1 LegendEntry (com.github.mikephil.charting.components.LegendEntry)1 BarDataSet (com.github.mikephil.charting.data.BarDataSet)1 IValueFormatter (com.github.mikephil.charting.formatter.IValueFormatter)1 Legend (com.github.mikephil.charting.utils.Legend)1 MPPointF (com.github.mikephil.charting.utils.MPPointF)1 ViewPortHandler (com.github.mikephil.charting.utils.ViewPortHandler)1