A pie chart is a circular chart divided into sectors, illustrating relative magnitudes or frequencies. In a pie chart, the arc length of each sector (and consequently its central angle and area), is proportional to the quantity it represents. Together, the sectors create a full disk. It is named for its resemblance to a pie which has been sliced. While the pie chart is perhaps the most ubiquitous statistical chart in the business world and the mass media, it is rarely used in scientific or technical publications. Pie charts are good when you are showing the relative proportion of numbers that add up to a total. Pie charts are good in displaying a single series of data and they are best when there are not too many wedges, particularly too many small ones. Pie charts show a good qualitative view of the data but this chart type are not good for quantitative displays, because it is hard to judge the relative angle of the wedges at different orientations.
In order to create a simple spline area chart is needed to create an instance of chart series, set ChartType as Pie and fill series with some data, like in the following sample:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.artfulbits.aiCharts.ChartView android:id="@+id/chartView" chart="@xml/chart" android:background="@android:drawable/alert_dark_frame" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </LinearLayout>
package com.artfulbits.aiCharts.piesample; import com.artfulbits.aiCharts.ChartView; import com.artfulbits.aiCharts.Base.*; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ChartView chartView = (ChartView) findViewById(R.id.chartView); ChartSeries series = chartView.getSeries().get(0); double[] data = { 973, 4054, 732, 577, 337, 34 }; String[] labels = { "Africa", "Asia", "Europe", "Latin America and the Caribbean", "Northern America", "Oceania" }; for (int i = 0; i < data.length; i++) { ChartPoint point = series.getPoints().addXY(i, data[i]); point.setLabel(labels[i]); } } }
<?xml version="1.0" encoding="utf-8"?> <ai:chart xmlns:ai="http://www.artfulbits.com/android/aiCharts"> <ai:area /> <ai:series type="Pie"/> <ai:title text="World populations" dock="Top" /> <ai:legend dock="Right" align="Far" background="@android:drawable/alert_dark_frame" /> </ai:chart>