Mpandroidchart of Android Excellent chart library

Source: Internet
Author: User

Mpandroidchart

1. Many times in the project to analyze the data to use the chart, on GitHub there are a lot of good chart Open Source Library, here is a brief introduction to Mpandroidchart.

He can realize the drag of the chart, the local view, the data dynamic display and other functions

Code download: Download

2. Paste some out:

Linechart

Filling type Linechart

Linechart of a single line

Barchart2d

Barchart3d

Piechart

Scatterchart

3. Use the method to download the library on Gihub: Https://github.com/PhilJay/MPAndroidChart

When you look at the sample it gives, the project may go wrong, and here's the problem of environment coding, and changing to Utf-8 is OK.

in XML

1 < Com.github.mikephil.charting.charts.PieChart 2   Android:id = "@+id/spread_pie_chart" 3   android:layout_width= "Match_parent"4  android:layout_height = "320dip" />

In activity

Initialization

1 colortemplate mCt;2MCt =Newcolortemplate ();3Mct.adddatasetcolors (Colortemplate.pastel_colors, This);4Mchart =(Piechart) Headview.findviewbyid (R.id.spread_pie_chart);5 mchart.setcolortemplate (mCt);6Mchart.setdescription ("");7 Mchart.setholeradius (30f);8 Mchart.settransparentcircleradius (0f);9 mchart.setcentertextsize (18f);TenMchart.setdrawxvalues (true); OneMchart.setusepercentvalues (true); AMchart.setdrawlegend (false); -  //space between slices - Mchart.setslicespace (1f); theMchart.setdrawholeenabled (false); -Mchart.settouchenabled (false);

Data:

1Arraylist<entry> yvals =NewArraylist<entry>();2Arraylist<string> xvals =NewArraylist<string>();3  for(inti = 0; I < listdatas.size (); i++) {4Yvals.add (NewEntry ((float) Listdatas.get (i). Getprovincecount (), i));5 Xvals.add (Listdatas.get (i). Getprovincename ());6 }7DataSet Set1 =NewDataSet (Yvals, "Content");8Arraylist<dataset> dataSets =NewArraylist<dataset>();9 Datasets.add (SET1);TenChartData data =NewChartData (xvals, dataSets); OneMchart.setdata (data);

Where Listdata is the data source in your project.

Mpandroidchart of Android Excellent chart library

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.