饼状图简单使用

PieChart使用

主要详细说明饼状图的使用。关联库什么的就不用说了。

  • PieChart
  • Legend

PieChart

  • Entry
    Entry(float val, int xIndex) :某个xIndex的数值val
  • PieData
    可以自己构造JSON数据进行填充。
    PieData(List xVals, PieDataSet dataSet):需要的xVals是分类名称;

  • PieDataSet
    PieDataSet(List yVals, String label) :一个Entry相当于饼状图的一个小部分;

展示PieChart

  • 属性列表
        pieChart.setHoleColorTransparent(true);
        pieChart.setTransparentCircleRadius(EcityConstants.ZERO);
        pieChart.setHoleRadius(EcityConstants.ZERO);
        pieChart.setDescription(description);
        pieChart.setNoDataTextDescription(EcityConstants.NO_DATA_DESCRIPTION);
        pieChart.setDrawCenterText(false);
        pieChart.setDrawSliceText(false);
        pieChart.setDrawHoleEnabled(true);
        pieChart.setRotationAngle(EcityConstants.ROTATION_ANGLE);
        pieChart.setRotationEnabled(true);
        pieChart.setUsePercentValues(true);
        pieData.setValueFormatter(new PercentFormatter());
        pieData.setValueTextSize(11f);
        pieData.setValueTextColor(Color.WHITE);
        pieChart.setData(pieData);
        pieChart.animateXY(EcityConstants.ANIMATE_X, EcityConstants.ANIMATE_Y);

Legend

可自定义,或者从chartView获取到Legend图例。
不涉及到大量数据分类,可以直接使用内置的图例。

  • 属性列表
        Legend legend = pieChart.getLegend();
        legend.setEnabled(true);//自定义时,需要设置为false
        legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_CENTER);
        legend.setTextColor(colors[1]);
        legend.setTextSize(10);
        legend.setXEntrySpace(8f);
        legend.setYEntrySpace(8f);

end.
by.ShawnAtom

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值