当前位置: 首页>>代码示例>>Java>>正文


Java PieDataSet.setColors方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.data.PieDataSet.setColors方法的典型用法代码示例。如果您正苦于以下问题:Java PieDataSet.setColors方法的具体用法?Java PieDataSet.setColors怎么用?Java PieDataSet.setColors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.data.PieDataSet的用法示例。


在下文中一共展示了PieDataSet.setColors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generatePieData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SimpleFragment.java

示例2: setData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void setData(int count, float range) {

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

        for (int i = 0; i < count; i++) {
            values.add(new PieEntry((float) ((Math.random() * range) + range / 5), mParties[i % mParties.length]));
        }

        PieDataSet dataSet = new PieDataSet(values, "Election Results");
        dataSet.setSliceSpace(3f);
        dataSet.setSelectionShift(5f);

        dataSet.setColors(ColorTemplate.MATERIAL_COLORS);
        //dataSet.setSelectionShift(0f);

        PieData data = new PieData(dataSet);
        data.setValueFormatter(new PercentFormatter());
        data.setValueTextSize(11f);
        data.setValueTextColor(Color.WHITE);
        data.setValueTypeface(mTfLight);
        mChart.setData(data);

        mChart.invalidate();
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:HalfPieChartActivity.java

示例3: generateDataPie

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:ListViewMultiChartActivity.java

示例4: generatePieData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private PieData generatePieData(List<PieChartItem> pieChartItems) {

        ArrayList<PieEntry> entries = new ArrayList<>();
        for (PieChartItem item : pieChartItems) {
            entries.add(new PieEntry(item.getTime(), item.getName(), item.getPercent()));
        }

        PieDataSet pieDataSet = new PieDataSet(entries, "");
        pieDataSet.setAutomaticallyDisableSliceSpacing(true);
        pieDataSet.setColors(chartColors);

        PieData pieData = new PieData(pieDataSet);
        pieData.setValueFormatter(new CustomPercentFormatter());
        pieData.setValueTextColor(Color.WHITE);
        return pieData;
    }
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:17,代码来源:ChartFragment.java

示例5: populatePieData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * Set the pie chart data source
 */
public static PieData populatePieData(List<PieEntry> entries, String label){
    PieDataSet dataSet = new PieDataSet(entries, label);
    dataSet.setSliceSpace(3f);
    dataSet.setSelectionShift(5f);
    //dataSet.setColors(populateColors());// add a lot of colors
    dataSet.setColors(ColorTemplate.MATERIAL_COLORS);
    dataSet.setValueLinePart1OffsetPercentage(80.f);
    dataSet.setValueLinePart1Length(0.2f);
    dataSet.setValueLinePart2Length(0.4f);
   // dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
    dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
    dataSet.setValueTextSize(11f);
    return new PieData(dataSet);
}
 
开发者ID:graviton57,项目名称:DOUSalaries,代码行数:18,代码来源:ChartHelper.java

示例6: createPieChart

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void createPieChart(ArrayList<PieEntry> yEntrys, ArrayList<Integer> colors) {

        //create the data set
        PieDataSet pieDataSet = new PieDataSet(yEntrys, "");
        pieDataSet.setSliceSpace(2);
        pieDataSet.setValueTextSize(12);
        pieDataSet.setColors(colors);

        pieChart.setCenterText(start.toString() + "\n" + end.toString());
        pieChart.setCenterTextColor(Color.BLACK);
        pieChart.setCenterTextSize(20);

        pieChart.animateY(2000);
        pieChart.animateX(2000);
        pieChart.getLegend().setEnabled(true);

        Description description = new Description();
        description.setText("");
        pieChart.setDescription(description);

        //create pie data object
        PieData pieData = new PieData();
        pieData.addDataSet(pieDataSet);
        pieChart.setData(pieData);
        pieChart.invalidate();
    }
 
开发者ID:alewin,项目名称:moneytracking,代码行数:27,代码来源:ShowChartActivity.java

示例7: setPieChartData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void setPieChartData(int count, float range) {

        ArrayList<PieEntry> entries = ChartData.getPieData(count, range);
        PieDataSet dataSet = new PieDataSet(entries, "Weekly spend distribution");

        dataSet.setDrawIcons(false);
        dataSet.setSliceSpace(3f);
        dataSet.setIconsOffset(new MPPointF(0, 40));
        dataSet.setSelectionShift(5f);

        ArrayList<Integer> colors = new ArrayList<>();
        for (int c : ColorTemplate.LIBERTY_COLORS)
            colors.add(c);
        dataSet.setColors(colors);

        PieData data = new PieData(dataSet);
        data.setValueFormatter(new PercentFormatter());
        data.setValueTextSize(11f);
        data.setValueTextColor(Color.GRAY);
        pieChart.setData(data);
        pieChart.highlightValues(null);
        pieChart.invalidate();
    }
 
开发者ID:VidyaSastry,项目名称:Opal-Chat-AnalyticsDashboard,代码行数:24,代码来源:DashboardFragment.java

示例8: defaultLanguageChart

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
public static PieChart defaultLanguageChart(List<Language> languages, PieChart chart, Linguist linguist) {
    chart.setCenterText(chart.getContext().getString(R.string.title_languages));

    List<PieEntry> dataSet = new ArrayList<>(languages.size());
    List<Integer> colors = new ArrayList<>(languages.size());

    for (Language language : languages) {
        dataSet.add(new PieEntry(language.getPercent(), language.getName()));
        int color = linguist.decode(language.getName());
        colors.add(color);
    }
    PieDataSet pieDataSet = new PieDataSet(dataSet, chart.getContext().getString(R.string.title_languages));
    pieDataSet.setValueTextColor(Color.WHITE);
    pieDataSet.setSliceSpace(3f);
    pieDataSet.setSelectionShift(5f);
    pieDataSet.setColors(colors);
    pieDataSet.setValueTextSize(14f);
    PieData pieData = new PieData(pieDataSet);
    pieData.setValueFormatter(new PercentFormatter());
    chart.setData(pieData);
    return chart;
}
 
开发者ID:omgitsjoao,项目名称:wakatime-android-client,代码行数:23,代码来源:Charts.java

示例9: generateDataPie

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * generates a random ChartData object with just one DataSet
 * 
 * @return
 */
private PieData generateDataPie(int cnt) {

    ArrayList<Entry> entries = new ArrayList<Entry>();

    for (int i = 0; i < 4; i++) {
        entries.add(new Entry((int) (Math.random() * 70) + 30, i));
    }

    PieDataSet d = new PieDataSet(entries, "");
    
    // space between slices
    d.setSliceSpace(2f);
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);
    
    PieData cd = new PieData(getQuarters(), d);
    return cd;
}
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:23,代码来源:ListViewMultiChartActivity.java

示例10: setData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void setData(long tips, long transactionsToRequest) {

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

        entries.add(new PieEntry(tips, getString(R.string.tips) + " " + "(" + tips + ")"));
        entries.add(new PieEntry(transactionsToRequest, getString(R.string.transactions_to_request) + " " + "(" + transactionsToRequest + ")"));

        PieDataSet dataSet = new PieDataSet(entries, getString(R.string.transactions) + "\n(" + (tips + transactionsToRequest) + ")");

        dataSet.setSliceSpace(3f);
        dataSet.setSelectionShift(5f);

        // add a lot of colors

        ArrayList<Integer> colors = new ArrayList<>();

        for (int c : ColorTemplate.LIBERTY_COLORS)
            colors.add(c);

        dataSet.setColors(colors);

        dataSet.setValueLinePart1OffsetPercentage(80.f);
        dataSet.setValueLinePart1Length(0.2f);
        dataSet.setValueLinePart2Length(0.4f);
        dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
        dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
        dataSet.setValueTextColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary));

        PieData data = new PieData(dataSet);
        data.setValueFormatter(new PercentFormatter());
        data.setValueTextSize(12f);
        data.setValueTextColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary));
        chart.setData(data);

        // undo all highlights
        chart.highlightValues(null);
        chart.invalidate();
    }
 
开发者ID:iotaledger,项目名称:android-wallet-app,代码行数:39,代码来源:NodeInfoFragment.java

示例11: getData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
@NonNull
private PieData getData(Leader leader) {
    RealmList<Language> languages = leader.getRunningTotal().getLanguages();
    List<PieEntry> entries = new ArrayList<>(languages.size());
    List<Integer> colors = new ArrayList<>(languages.size());
    for (Language language : languages) {
        entries.add(new PieEntry(language.getTotalSeconds(), language.getName()));
        colors.add(linguist.decode(language.getName()));
    }
    PieDataSet pieDataSet = new PieDataSet(entries, getString(R.string.languages));

    pieDataSet.setColors(colors);
    pieDataSet.setSliceSpace(3f);
    pieDataSet.setSelectionShift(5f);
    PieData pieData = new PieData(pieDataSet);
    pieData.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> String.valueOf(toMinutes((long) value)));
    pieData.setValueTextSize(16f);
    pieData.setValueTextColor(Color.WHITE);
    return pieData;
}
 
开发者ID:omgitsjoao,项目名称:wakatime-android-client,代码行数:21,代码来源:LeaderProfileFragment.java

示例12: generateDataPie

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * generates a random ChartData object with just one DataSet
 */
private PieData generateDataPie() {

    ArrayList<Entry> entries = new ArrayList<Entry>();

    for (int i = 0; i < 4; i++) {
        entries.add(new Entry((int) (Math.random() * 70) + 30, i));
    }

    PieDataSet d = new PieDataSet(entries, "");

    // 设置各个扇形部分之间的间距
    d.setSliceSpace(12f);
    // 设置各个扇形部分的颜色
    d.setColors(ColorTemplate.VORDIPLOM_COLORS);

    PieData cd = new PieData(getQuarters(), d);
    return cd;
}
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:22,代码来源:PieChartActivity.java

示例13: createPieChartData

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
public PieData createPieChartData()
{
    List<Entry> entries = new ArrayList<>();
    entries.add(new Entry(50, 0));
    entries.add(new Entry(25, 1));
    entries.add(new Entry(12.5f, 2));
    entries.add(new Entry(12.5f, 3));

    PieDataSet data = new PieDataSet(entries, null);
    data.setDrawValues(false);
    data.setColors(new int[] {
            0xFF673ab7, 0xFF2196f3, 0xFF4caf50, 0xFF009688
    });

    String[] labels = new String[] {"Blackberry", "Blueberry", "Green apple", "Seaweed"};

    return new PieData(labels, data);
}
 
开发者ID:ResearchStack,项目名称:SampleApp,代码行数:19,代码来源:DashboardFragment.java

示例14: initializeChart

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
 * Initializes the PieChart with the given parameters. Automatically hides description and adds animation.
 *
 * @param chart: PieChart object defined in XML layout
 * @param colorTemplate: int[] array of colors, where each color is a resource, i.e. R.color.green
 * @param data: HashMap of section name label to value, i.e. "Yes": 40, "No": 60
 */
public void initializeChart(PieChart chart, int[] colorTemplate, HashMap<String, Integer> data) {
    // Add y-values from data to the pie chart data set
    ArrayList<Entry> values = new ArrayList<Entry>();
    int index = 0;
    for (int value : data.values())
        values.add(new Entry(value, index++));
    PieDataSet dataSet = new PieDataSet(values, "");

    // Create section labels and disable x-value labels
    chart.setData(new PieData(new ArrayList<String>(data.keySet()), dataSet));
    chart.setDrawXValues(false);

    // Add colors from color template
    dataSet.setColors(colorTemplate);

    // Hide description and legend
    chart.setDescription("");
    chart.setDrawLegend(false);

    // Add animation
    chart.animateXY(1500, 1500);
}
 
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:30,代码来源:AnalyticsFragment.java

示例15: refreshSleepAmounts

import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void refreshSleepAmounts(List<ActivityData> samples) {
    ActivityAnalysis analysis = new ActivityAnalysis();
    ActivityAmounts amounts = analysis.calculateActivityAmounts(samples);
    float hoursOfSleep = amounts.getTotalSeconds() / (float) (60 * 60);
    pieChart.setCenterText((int) hoursOfSleep + "h"); // FIXME
    PieData data = new PieData();
    List<Entry> entries = new ArrayList<>();
    List<Integer> colors = new ArrayList<>();
    int index = 0;
    for (ActivityAmount amount : amounts.getAmounts()) {
        entries.add(new Entry(amount.getTotalSeconds(), index++));
        colors.add(getColorFor(amount.getActivityKind()));
        data.addXValue(amount.getName());
    }
    PieDataSet set = new PieDataSet(entries, "Sleep comparison");
    set.setColors(colors);
    data.setDataSet(set);
    pieChart.setData(data);

    //setupLegend(pieChart);

    pieChart.invalidate();
}
 
开发者ID:betomaluje,项目名称:Mi-Band,代码行数:24,代码来源:SleepChartActivity.java


注:本文中的com.github.mikephil.charting.data.PieDataSet.setColors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。