Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用自定义颜色时,如何消除饼图周围的模糊?_Android_Pie Chart_Mpandroidchart_Donut Chart - Fatal编程技术网

Android 使用自定义颜色时,如何消除饼图周围的模糊?

Android 使用自定义颜色时,如何消除饼图周围的模糊?,android,pie-chart,mpandroidchart,donut-chart,Android,Pie Chart,Mpandroidchart,Donut Chart,我正在使用MPAndroidchart饼图,并使用我自己的颜色绘制图表。现在的问题是饼图是模糊的。它的边缘模糊不清。我想去除模糊,使之成为锐利的边缘。怎么做 我没有10个声誉来发布图片。 下面是显示图表的代码 private void showChart(BudgetResponse.Budgets[] items) { chart.setVisibility(View.VISIBLE); chart.setUsePercentValues(true);

我正在使用MPAndroidchart饼图,并使用我自己的颜色绘制图表。现在的问题是饼图是模糊的。它的边缘模糊不清。我想去除模糊,使之成为锐利的边缘。怎么做

我没有10个声誉来发布图片。

下面是显示图表的代码

private void showChart(BudgetResponse.Budgets[] items) {
        chart.setVisibility(View.VISIBLE);
        chart.setUsePercentValues(true);
        chart.getDescription().setEnabled(false);
        chart.setExtraOffsets(5, 10, 5, 5);

        chart.setDragDecelerationFrictionCoef(0.95f);

        //chart.setCenterTextTypeface(tfLight);
        //chart.setCenterText(generateCenterSpannableText());


        chart.setDrawHoleEnabled(true);
        chart.setHoleColor(Color.TRANSPARENT);

        chart.setTransparentCircleColor(Color.WHITE);
        chart.setTransparentCircleAlpha(110);

        chart.setHoleRadius(58f);
        chart.setTransparentCircleRadius(61f);

        chart.setDrawCenterText(true);
        SimpleSpanBuilder sb=new SimpleSpanBuilder();
        sb.append("Total budget",new RelativeSizeSpan(1.0f));
        float budget=0;
        try{
            for (int i=0;i<items.length;i++){
                budget+=Float.parseFloat(items[i].getCurrentAmount());
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        sb.append("\n"+budget,new RelativeSizeSpan(2.0f),
                new ForegroundColorSpan(activity.getResources().getColor(R.color.colorPrimary)));

        chart.setCenterText(sb.build());
        chart.setCenterTextColor(activity.getResources().getColor(R.color.titleColor));
        chart.setCenterTextSizePixels(12f);

        chart.setRotationAngle(0);
        // enable rotation of the chart by touch
        chart.setRotationEnabled(false);
        chart.setHighlightPerTapEnabled(true);

        chart.animateY(1400, Easing.EaseInOutQuad);

        chart.getLegend().setEnabled(false);

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

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

        for (BudgetResponse.Budgets budgets:items){
            entries.add(new PieEntry(Float.parseFloat(budgets.getCurrentAmount()), budgets.getCategoryGroupName()));
            if(budgets.getCategoryGroupName().contains("Bills")){
                pieColors.add(getAppColor(R.color.lightViolet));
            }else if(budgets.getCategoryGroupName().contains("Entertainment")){
                pieColors.add(getAppColor(R.color.lightPink));
            }else if(budgets.getCategoryGroupName().contains("Food")){
                pieColors.add(getAppColor(R.color.lightBlue));
            }else if(budgets.getCategoryGroupName().contains("Auto")){
                pieColors.add(getAppColor(R.color.darkViolet));
            }else if(budgets.getCategoryGroupName().contains("Shopping")){
                pieColors.add(getAppColor(R.color.lightOrangeVariant));
            }else if(budgets.getCategoryGroupName().contains("Transfers")){
                pieColors.add(getAppColor(R.color.lightGreenVariant));
            }
        }
        // add a lot of colors

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

        PieDataSet dataSet = new PieDataSet(entries, "Budget Spends");

        dataSet.setDrawIcons(false);

        dataSet.setSliceSpace(3f);
        dataSet.setIconsOffset(new MPPointF(0, 40));
        dataSet.setSelectionShift(1f);


        colors.add(ColorTemplate.getHoloBlue());

        dataSet.setColors(colors);
        //dataSet.setSelectionShift(0f);

        PieData data = new PieData(dataSet);
        data.setValueFormatter(new PercentFormatter(chart));
        data.setValueTextSize(11f);
        data.setValueTextColor(Color.TRANSPARENT);
        //data.setValueTypeface(tfLight);
        chart.setData(data);

        //to remove labels over pie chart
        chart.setDrawEntryLabels(false);
        //to remove percentage over pie chart
        chart.setUsePercentValues(false);
        //chart.setDrawCenterText(false);

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

        MyMarkerView mv = new MyMarkerView(activity, R.layout.custom_marker_view);
        mv.setChartView(chart); // For bounds control
        chart.setMarker(mv); //

        chart.invalidate();

    }
private void显示图(预算响应.预算[]项){
chart.setVisibility(View.VISIBLE);
chart.setUsePercentValues(真);
chart.getDescription().setEnabled(false);
图表.设置外部偏移(5,10,5,5);
图表.设定阻力减阻摩擦系数(0.95f);
//chart.setCenterTextTypeface(tfLight);
//setCenterText(generateCenterSpannableText());
图表。setDrawHoleEnabled(真);
图表。setHoleColor(颜色。透明);
图表.设置透明圆环颜色(颜色.白色);
图表:setTransparentCircleAlpha(110);
图.塞托莱拉迪乌斯(58f);
图.setTransparentCircleRadius(61f);
chart.setDrawCenterText(true);
SimplePanBuilder sb=新SimplePanBuilder();
sb.追加(“总预算”,新的相对跨度(1.0f));
浮动预算=0;
试一试{
对于(int i=0;i