国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Java > 正文

MPAndroidChart開(kāi)源圖表庫(kù)的使用介紹之餅狀圖、折線圖和柱狀圖

2019-11-26 14:34:07
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

MPAndroidChart開(kāi)源圖表庫(kù)之餅狀圖

  為大家介紹一款圖標(biāo)開(kāi)源庫(kù)MPAndroidChart,它不僅可以在Android設(shè)備上繪制各種統(tǒng)計(jì)圖表,而且可以對(duì)圖表進(jìn)行拖動(dòng)和縮放操作,用起來(lái)非常靈活。MPAndroidChart同樣擁有常用的圖表類型:線型圖、餅圖、柱狀圖和散點(diǎn)圖。

mpandroidchartlibrary.jar包下載地址:

https://github.com/PhilJay/MPAndroidChart/releases

  下面主要實(shí)現(xiàn)以下餅狀圖:

  1.從上面的地址中下載最新mpandroidchartlibrary-2-0-8.jar包, 然后copy到項(xiàng)目的libs中

  2. 定義xml文件

        3. 主要Java邏輯代碼如下。

importjava.util.ArrayList; importcom.github.mikephil.charting.charts.PieChart; importcom.github.mikephil.charting.components.Legend; importcom.github.mikephil.charting.components.Legend.LegendPosition; importcom.github.mikephil.charting.data.Entry; importcom.github.mikephil.charting.data.PieData; importcom.github.mikephil.charting.data.PieDataSet; import android.support.v7.app.ActionBarActivity; importandroid.graphics.Color; importandroid.os.Bundle; importandroid.util.DisplayMetrics; public class MainActivity extends ActionBarActivity { privatePieChartmChart; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mChart = (PieChart) findViewById(R.id.spread_pie_chart); PieDatamPieData = getPieData(4, 100); showChart(mChart, mPieData); } private void showChart(PieChartpieChart, PieDatapieData) { pieChart.setHoleColorTransparent(true); pieChart.setHoleRadius(60f); //半徑pieChart.setTransparentCircleRadius(64f); // 半透明圈//pieChart.setHoleRadius(0) //實(shí)心圓pieChart.setDescription("測(cè)試餅狀圖"); // mChart.setDrawYValues(true); pieChart.setDrawCenterText(true); //餅狀圖中間可以添加文字pieChart.setDrawHoleEnabled(true); pieChart.setRotationAngle(90); // 初始旋轉(zhuǎn)角度// draws the corresponding description value into the slice // mChart.setDrawXValues(true); // enable rotation of the chart by touch pieChart.setRotationEnabled(true); // 可以手動(dòng)旋轉(zhuǎn)// display percentage values pieChart.setUsePercentValues(true); //顯示成百分比// mChart.setUnit(" 

主站蜘蛛池模板:
涪陵区|
海伦市|
德格县|
无极县|
塘沽区|
郴州市|
闽清县|
锡林郭勒盟|
左云县|
克山县|
长宁区|
曲靖市|
山阴县|
方山县|
大洼县|
读书|
宽甸|
大埔县|
灌阳县|
博白县|
兰州市|
永吉县|
临潭县|
凭祥市|
茌平县|
旬阳县|
濮阳县|
黄浦区|
寿宁县|
水富县|
宣化县|
五常市|
滕州市|
正安县|
安多县|
渑池县|
长治县|
枞阳县|
高雄市|
济源市|
论坛|