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


Java PieData.setValueFormatter方法代码示例

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


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

示例1: setData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的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

示例2: generatePieData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的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

示例3: setPieChartData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的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

示例4: setData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的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

示例5: getData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的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

示例6: defaultLanguageChart

import com.github.mikephil.charting.data.PieData; //导入方法依赖的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

示例7: defaultOSChart

import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
public static PieChart defaultOSChart(List<OperatingSystem> operatingSystems, PieChart chart, Linguist linguist) {
    chart.setCenterText(chart.getContext().getString(R.string.title_os));

    List<PieEntry> entries = new ArrayList<>(operatingSystems.size());
    List<Integer> colors = new ArrayList<>(operatingSystems.size());
    for (OperatingSystem operatingSystem : operatingSystems) {
        entries.add(new PieEntry(operatingSystem.getPercent(), operatingSystem.getName()));
        colors.add(linguist.decodeOS(operatingSystem.getName()));
    }
    PieDataSet pieDataSet = new PieDataSet(entries, chart.getContext().getString(R.string.title_os));
    pieDataSet.setColors(colors);
    pieDataSet.setSliceSpace(3f);
    pieDataSet.setSelectionShift(5f);
    pieDataSet.setValueTextSize(14f);
    pieDataSet.setValueTextColor(Color.WHITE);
    PieData pieData = new PieData(pieDataSet);
    pieData.setValueFormatter(new PercentFormatter());
    chart.setData(pieData);
    return chart;
}
 
开发者ID:omgitsjoao,项目名称:wakatime-android-client,代码行数:21,代码来源:Charts.java

示例8: defaultEditorsChart

import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
public static PieChart defaultEditorsChart(List<Editor> editors, PieChart chart) {
    chart.setCenterText(chart.getContext().getString(R.string.title_editors));
    int size = 0;
    if (editors != null) {
        size = editors.size();
    }
    List<PieEntry> dataSet = new ArrayList<>(size);
    //noinspection Convert2streamapi
    for (Editor editor : editors) {
        dataSet.add(new PieEntry(editor.getPercent(), editor.getName()));
    }

    PieDataSet pieDataSet = new PieDataSet(dataSet, chart.getContext().getString(R.string.title_editors));
    pieDataSet.setColors(ColorTemplate.JOYFUL_COLORS);
    pieDataSet.setValueTextColor(Color.WHITE);
    pieDataSet.setValueTextSize(14f);
    pieDataSet.setSliceSpace(3f);
    pieDataSet.setSelectionShift(5f);
    PieData pieData = new PieData(pieDataSet);
    pieData.setValueFormatter(new PercentFormatter());
    chart.setData(pieData);
    return chart;
}
 
开发者ID:omgitsjoao,项目名称:wakatime-android-client,代码行数:24,代码来源:Charts.java

示例9: updateChart

import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void updateChart(String totalSpace, List<PieEntry> entries) {
    boolean isDarkTheme = appTheme.getMaterialDialogTheme() == Theme.DARK;

    PieDataSet set = new PieDataSet(entries, null);
    set.setColors(COLORS);
    set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
    set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
    set.setSliceSpace(5f);
    set.setAutomaticallyDisableSliceSpacing(true);
    set.setValueLinePart2Length(1.05f);
    set.setSelectionShift(0f);

    PieData pieData = new PieData(set);
    pieData.setValueFormatter(new GeneralDialogCreation.SizeFormatter(context));
    pieData.setValueTextColor(isDarkTheme? Color.WHITE:Color.BLACK);

    chart.setCenterText(new SpannableString(context.getString(R.string.total) + "\n" + totalSpace));
    chart.setData(pieData);
}
 
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:20,代码来源:LoadFolderSpaceDataTask.java

示例10: addPieChartData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void addPieChartData(int correctAnswer, int noOfQuestion) {
    float[] yData;
    String[] xData = {getString(R.string.correct_quantity), getString(R.string.incorrect_quantity)};

    ArrayList<Integer> colors = new ArrayList<>();
    colors.add(ContextCompat.getColor(getContext(), R.color.colorDarkBlue));
    colors.add(ContextCompat.getColor(getContext(), R.color.colorRaspberry));

    if (correctAnswer == noOfQuestion) {
        yData = new float[]{100};
    } else if (correctAnswer == 0) {
        yData = new float[]{100};
        colors.remove(0);
    } else {
        float good = (float) correctAnswer * 100 / noOfQuestion;
        yData = new float[]{good, 100 - good};
    }

    ArrayList<Entry> yValues = new ArrayList<>();
    for (int i = 0; i < yData.length; i++)
        yValues.add(new Entry(yData[i], i));

    ArrayList<String> xValues = new ArrayList<>();
    Collections.addAll(xValues, xData);

    PieDataSet dataSet = new PieDataSet(yValues, getString(R.string.your_score));
    dataSet.setColors(colors);
    dataSet.setSliceSpace(5);
    dataSet.setSelectionShift(10);

    PieData data = new PieData(xValues, dataSet);
    data.setValueFormatter(new PercentFormatter());
    data.setValueTextColor(ContextCompat.getColor(getContext(), R.color.colorGrey));
    data.setValueTextSize(20);

    pieChart.setData(data);
    pieChart.highlightValues(null);
    pieChart.invalidate();
}
 
开发者ID:blstream,项目名称:StudyBox_Android,代码行数:40,代码来源:ResultDialogFragment.java

示例11: setChartData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setChartData(PieChart chart, List<Integer> yData) {
    ArrayList<Entry> yVals = new ArrayList<>();

    for (int i = 0; i < yData.size(); ++i) {
        yVals.add(new Entry(yData.get(i), i));
    }

    ArrayList<String> xVals = new ArrayList<>();

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

    PieDataSet dataSet = new PieDataSet(yVals, "");
    dataSet.setSliceSpace(3);
    dataSet.setSelectionShift(5);

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

    colors.add(0xFFDD2C00);
    colors.add(0xFFFF6D00);
    colors.add(0xFFFFAB00);
    colors.add(0xFFAEEA00);
    colors.add(0xFF64DD17);

    dataSet.setColors(colors);

    PieData data = new PieData(xVals, dataSet);
    data.setValueFormatter(new PercentFormatter());
    data.setValueTextSize(15f);
    data.setValueTextColor(Color.BLACK);
    chart.setData(data);
    chart.highlightValues(null);
    chart.invalidate();
}
 
开发者ID:kaiomax,项目名称:RUSpotlight,代码行数:36,代码来源:StatisticsFragment.java

示例12: setData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setData(PieChart colorPie, float value) {

        ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
        float result = value / 5f;
        Log.d(TAG + " result ", result + "");
        entries.add(new PieEntry(result, 0));
        entries.add(new PieEntry(1 - result, 1));
        // NOTE: The order of the entries when being added to the entries array determines their position around the center of
        // the chart.

//        colorPie.setCenterTextTypeface(mTfLight);
        int centerTextColor = android.graphics.Color.argb(255, 57, 197, 193);
        colorPie.setCenterTextColor(centerTextColor);

        PieDataSet dataSet = new PieDataSet(entries, "");
        dataSet.setSliceSpace(3f);
        dataSet.setSelectionShift(3f);

        // add a lot of colors
        ArrayList<Integer> colors = new ArrayList<Integer>();
        colors.add(Color.argb(120, 57, 197, 193));
        colorPie.setCenterText(value + "");
        colorPie.setCenterTextSize(30);

        colors.add(Color.argb(100, 214, 214, 214));
        dataSet.setColors(colors);

        PieData data = new PieData(dataSet);
        data.setValueFormatter(new PercentFormatter());
        data.setValueTextSize(0f);
        data.setValueTextColor(Color.WHITE);
        colorPie.setData(data);

        // undo all highlights
        colorPie.highlightValues(null);

        colorPie.invalidate();
    }
 
开发者ID:clementf2b,项目名称:FaceT,代码行数:39,代码来源:ProductDetailActivity.java

示例13: createPieData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
public PieData createPieData(PieDataSet pieDataSet) {
    PieData pieData = new PieData(pieDataSet);
    pieData.setValueFormatter(new PercentFormatter());
    pieData.setValueTextSize(15f);
    pieData.setValueTextColor(utilsUI.getColor(android.R.color.white));
    return pieData;
}
 
开发者ID:MLSDev,项目名称:RecipeFinderJavaVersion,代码行数:8,代码来源:DiagramUtils.java

示例14: setChartData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setChartData(List<Project> chardData) {
    Typeface lato = Typeface.createFromAsset(this.getContext().getAssets(), "fonts/Lato-Regular.ttf");
    this.mChartProjects.setDrawHoleEnabled(true);
    this.mChartProjects.setHoleColor(Color.WHITE);
    this.mChartProjects.setTransparentCircleColor(Color.WHITE);
    this.mChartProjects.setTransparentCircleAlpha(110);
    this.mChartProjects.setDragDecelerationFrictionCoef(0.95f);
    this.mChartProjects.setHoleRadius(58f);
    this.mChartProjects.setTransparentCircleRadius(61f);
    this.mChartProjects.setDescription("");
    this.mChartProjects.setUsePercentValues(true);
    this.mChartProjects.setEntryLabelColor(Color.WHITE);
    this.mChartProjects.setDrawCenterText(true);
    this.mChartProjects.setCenterText(getString(R.string.title_projects));
    this.mChartProjects.setCenterTextSize(18f);
    this.mChartProjects.setEntryLabelTypeface(lato);
    this.mChartProjects.setCenterTextTypeface(lato);
    this.mChartProjects.setCenterTextColor(getColor(getActivity(), R.color.colorSecondaryText));
    this.mChartProjects.animateY(1400, Easing.EasingOption.EaseInOutQuad);
    enableNestingScrollForAP21();

    List<PieEntry> entries = new ArrayList<>(chardData.size());
    for (Project project : chardData) {
        entries.add(new PieEntry(project.getPercent(), project.getName()));
    }
    PieDataSet pieDataSet = new PieDataSet(entries, getString(R.string.title_projects));
    pieDataSet.setHighlightEnabled(true);
    pieDataSet.setValueTextColor(Color.WHITE);
    pieDataSet.setValueTextSize(14f);
    pieDataSet.setColors(ColorTemplate.VORDIPLOM_COLORS);
    pieDataSet.setSliceSpace(3f);
    pieDataSet.setSelectionShift(5f);
    PieData pieData = new PieData(pieDataSet);
    pieData.setValueFormatter(new PercentFormatter());
    this.mChartProjects.setData(pieData);
}
 
开发者ID:omgitsjoao,项目名称:wakatime-android-client,代码行数:37,代码来源:ProjectFragment.java

示例15: updateChartData

import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void updateChartData(PieChart chart) {
    ArrayList<PieEntry> entries = new ArrayList<>();
    ArrayList<Integer> colors = new ArrayList<>();

    double sum = 0;
    for (int i = 0; i < categorizedExpenses.getCategories().size(); i++) {
        Category c = categorizedExpenses.getCategory(i);
        Report r = categorizedExpenses.getReport(c);
        sum += r.getTotalAmount().doubleValue();
        entries.add(new PieEntry((int) (r.getTotalAmount().doubleValue() * 1000), c.getTitle()));
        colors.add(c.getColor());
    }

    PieDataSet dataSet = new PieDataSet(entries, "Outlay");
    dataSet.setSliceSpace(2f);
    dataSet.setSelectionShift(10f);
    dataSet.setColors(colors);

    PieData data = new PieData(dataSet);
    data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> NumberUtils.formatAmount((double) value / 1000));
    data.setValueTextSize(11f);
    data.setValueTextColor(Color.WHITE);
    chart.setData(data);
    chart.setCenterText(NumberUtils.formatAmount(sum));
    chart.highlightValues(null);
    chart.invalidate();
}
 
开发者ID:bmelnychuk,项目名称:outlay,代码行数:28,代码来源:ReportAdapter.java


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