Java Code Examples for com.github.mikephil.charting.data.PieDataSet#setValueTextSize()

The following examples show how to use com.github.mikephil.charting.data.PieDataSet#setValueTextSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleFragment.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
/**
 * generates less data (1 DataSet, 4 values)
 * @return PieData
 */
protected PieData generatePieData() {

    int count = 4;

    ArrayList<PieEntry> entries1 = new ArrayList<>();

    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;
}
 
Example 2
Source File: GraphicActivity.java    From ToDay with MIT License 5 votes vote down vote up
private void addDataSet() {
    Log.d(TAG, "addDataSet started");
    ArrayList<PieEntry> yEntrys = new ArrayList<>();
    ArrayList<String> xEntrys = new ArrayList<>();

    for(int i = 0; i < yData.length; i++){
        yEntrys.add(new PieEntry(yData[i] , i));
    }

    for(int i = 1; i < xData.length; i++){
        xEntrys.add(xData[i]);
    }

    //create the data set
    PieDataSet pieDataSet = new PieDataSet(yEntrys, "Төлөвлөгөөний үзүүлэлтлл");
    pieDataSet.setSliceSpace(2);
    pieDataSet.setValueTextSize(12);

    //add colors to dataset
    ArrayList<Integer> colors = new ArrayList<>();
    colors.add(Color.GRAY);
    colors.add(Color.BLUE);
    colors.add(Color.RED);
    colors.add(Color.GREEN);
    colors.add(Color.CYAN);
    colors.add(Color.YELLOW);
    colors.add(Color.MAGENTA);

    pieDataSet.setColors(colors);

    //add legend to chart
    Legend legend = pieChart.getLegend();
    legend.setForm(Legend.LegendForm.CIRCLE);
    legend.setPosition(Legend.LegendPosition.LEFT_OF_CHART);

    //create pie data object
    PieData pieData = new PieData(pieDataSet);
    pieChart.setData(pieData);
    pieChart.invalidate();
}
 
Example 3
Source File: ChartSettings.java    From BrainPhaser with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the specified format to the PieDataSet Object.
 *
 * @param dataset the dataset which will be formatted
 * @param type    the statistic type of the chart the format is applied to
 */
public void applyDataSetSettings(PieDataSet dataset, StatisticType type) {
    dataset.setSliceSpace(SLICE_SPACE);
    dataset.setValueTextSize(VALUE_TEXT_SIZE);
    dataset.setSelectionShift(SELECTION_SHIFT);
    if (type == StatisticType.TYPE_STAGE) {
        dataset.setColors(mColorsetStage);
    } else if (type == StatisticType.TYPE_DUE) {
        dataset.setColors(mColorsetDue);
    } else {
        dataset.setColors(mColorsetPlayed);
    }

    dataset.setValueFormatter(new CustomizedFormatter());
}
 
Example 4
Source File: SimpleFragment.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
/**
 * generates less data (1 DataSet, 4 values)
 * @return
 */
protected PieData generatePieData() {
    
    int count = 4;
    
    ArrayList<Entry> entries1 = new ArrayList<Entry>();
    ArrayList<String> xVals = new ArrayList<String>();
    
    xVals.add("Quarter 1");
    xVals.add("Quarter 2");
    xVals.add("Quarter 3");
    xVals.add("Quarter 4");
    
    for(int i = 0; i < count; i++) {
        xVals.add("entry" + (i+1));

        entries1.add(new Entry((float) (Math.random() * 60) + 40, i));
    }
    
    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(xVals, ds1);
    d.setValueTypeface(tf);

    return d;
}