# MPAndroidChart數據圖表套件 - 圓餅圖PieChart屬性設定 ###### tags: MPAndroidChart [TOC] ## PieChart ### 基本常用屬性設定 ``` pieChartView.setUsePercentValues(true);//使用百分比 pieChartView.getDescription().setEnabled(false);//圖表的描述 pieChartView.setDrawEntryLabels(false);//圖表只顯示餅圖上百分比不顯示文字 pieChartView.setRotationEnabled(false);//圖表是否可以手動旋轉 Legend legend = pieChartView.getLegend();//是否顯示圖例 legend.setEnabled(true); ``` ex: 圖例  ### 內圓屬性設定 ``` pieChartView.setDrawHoleEnabled(true);// 內圓 pieChartView.setHoleRadius(80f);// 设置PieChart内部圆的半徑 pieChartView.setDrawCenterText(false); // 內圓文字 ``` ### 填入數據設定 ``` // 数据的百分比和餅圖上文字 List<PieEntry> strings = new ArrayList<>(); // strings.add(new PieEntry(30f,"aaa")); strings.add(new PieEntry(70f,"bbb")); PieDataSet dataSet = new PieDataSet(strings,"Label"); // 數據的颜色 ArrayList<Integer> colors = new ArrayList<Integer>(); colors.add(getResources().getColor(R.color.login_red)); colors.add(getResources().getColor(R.color.blue)); dataSet.setColors(colors); PieData pieData = new PieData(dataSet); pieData.setDrawValues(true); //設定圓餅上是否顯示數據數字 pieData.setValueTextSize(11f); pieData.setValueTextColor(Color.WHITE); picChart.setData(pieData); picChart.invalidate(); //更新畫面 ```  ### 詳細設定參考網址 https://blog.csdn.net/zcmain/article/details/53611245 https://www.jianshu.com/p/802118e621d6
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up