當前位置: 首頁>>代碼示例>>Java>>正文


Java PieDataSet類代碼示例

本文整理匯總了Java中com.github.mikephil.charting.data.PieDataSet的典型用法代碼示例。如果您正苦於以下問題:Java PieDataSet類的具體用法?Java PieDataSet怎麽用?Java PieDataSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PieDataSet類屬於com.github.mikephil.charting.data包,在下文中一共展示了PieDataSet類的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: 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

示例9: 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

示例10: setupChart

import com.github.mikephil.charting.data.PieDataSet; //導入依賴的package包/類
private void setupChart(String shortClicks, String longClicks) {
    List<PieEntry> entries = new ArrayList<>();

    Float short_actual = Float.parseFloat(shortClicks);

    Float long_actual = Float.parseFloat(longClicks);

    Float short_final_percent = (short_actual / (long_actual + short_actual)) * 100;
    Float long_final_percent = (long_actual / (long_actual + short_actual)) * 100;

    if (short_actual != Float.parseFloat("0"))
        entries.add(new PieEntry(short_final_percent, getString(R.string.short_url_clicks_pie_chart)));
    if (long_actual != Float.parseFloat("0"))
        entries.add(new PieEntry(long_final_percent, getString(R.string.long_url_click_pie_chart)));
    PieDataSet set = new PieDataSet(entries, getString(R.string.url_clikc_count_pie_chart));
    set.setColors(ColorTemplate.MATERIAL_COLORS);
    PieData data = new PieData(set);
    pieChart.setData(data);
    pieChart.invalidate(); // refresh

    if (pieChart.isEmpty()) {
        pieChart.setVisibility(View.GONE);
        errorLayout.setVisibility(View.VISIBLE);

    }
}
 
開發者ID:jatindhankhar,項目名稱:shorl,代碼行數:27,代碼來源:DetailActivity.java

示例11: 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

示例12: createPieDataSet

import com.github.mikephil.charting.data.PieDataSet; //導入依賴的package包/類
public PieDataSet createPieDataSet(List<PieEntry> pieEntryList,
                                   @Nullable String label,
                                   @Nullable List<Integer> colors) {
    PieDataSet pieDataSet = new PieDataSet(pieEntryList, label);
    pieDataSet.setSliceSpace(1.5f);
    pieDataSet.setSelectionShift(2f);

    pieDataSet.setDrawValues(true);

    if (colors == null) {
        colors = new ArrayList<>(3);
        colors.add(utilsUI.getColor(R.color.colorPrimaryDark));
        colors.add(utilsUI.getColor(R.color.colorPrimary));
        colors.add(utilsUI.getColor(R.color.colorAccent));
    }

    pieDataSet.setColors(colors);
    return pieDataSet;
}
 
開發者ID:MLSDev,項目名稱:RecipeFinderJavaVersion,代碼行數:20,代碼來源:DiagramUtils.java

示例13: showResults

import com.github.mikephil.charting.data.PieDataSet; //導入依賴的package包/類
private void showResults(NutritionAnalysisResult nutritionAnalysisResult) {
    if (nutritionAnalysisResult == null)
        return;

    calories.set(context.getString(R.string.calories, nutritionAnalysisResult.getCalories()));
    yield.set(context.getString(R.string.yields, String.valueOf(nutritionAnalysisResult.getYield())));

    List<PieEntry> pieEntries = diagramUtils.preparePieEntries(nutritionAnalysisResult.getTotalNutrients());
    chartVisibility.set(pieEntries.isEmpty() ? View.GONE : View.VISIBLE);

    if (pieEntries.isEmpty())
        return;

    PieDataSet pieDataSet = diagramUtils.createPieDataSet(pieEntries, "Nutrients", null);
    pieData = diagramUtils.createPieData(pieDataSet);

    if (onDataLoadedListener != null)
        onDataLoadedListener.onDataLoaded(pieData);
}
 
開發者ID:MLSDev,項目名稱:RecipeFinderJavaVersion,代碼行數:20,代碼來源:RecipeAnalysisDetailsViewModel.java

示例14: 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

示例15: 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


注:本文中的com.github.mikephil.charting.data.PieDataSet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。