whitespace COMPANY whitespace SERVICES whitespace PRODUCTS whitespace PURCHASE whitespace SUPPORT whitespace CONTACTS whitespace Home whitespace Contact Us whitespace Site Map whitespace
whitespace
WHY ARTFULBITS
whitespace
OUR APPROACH
whitespace
OUR TEAM
whitespace
FACT SHEET
whitespace
NEWS & EVENTS
whitespace
PRIVACY
whitespace
whitespace

Doughnut Chart Type

Overview

A doughnut chart is a circular chart divided into sectors, illustrating relative magnitudes or frequencies. In a doughnut 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 doughnut which has been sliced. While the doughnut 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. Doughnut charts are good when you are showing the relative proportion of numbers that add up to a total. doughnut 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. Doughnut 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.

Creating the Doughnut Chart

In order to create a simple doughnut chart is needed to create an instance of chart series, set ChartType as Doughnut and fill series with some data, like in the following sample:

zip archive Download 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.DoughnutSample;

import android.app.Activity;
import android.os.Bundle;

import com.artfulbits.aiCharts.ChartView;
import com.artfulbits.aiCharts.Base.ChartSeries;
import com.artfulbits.aiCharts.Types.ChartDoughnutType;
import com.artfulbits.aiCharts.Types.ChartPieType.LabelStyle;

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); 

		String[] labels = { "milk", "yeast", "flour", 
				"eggs", "butter", "salt", "water", "sugar" };
		int[] weights = {180, 12, 450, 100, 100, 10, 250, 250 };
		
		for (int i = 0; i < weights.length; i++)
			series.getPoints().addXY(i, weights[i]).setLabel(labels[i]);
		
		series.setAttribute(ChartDoughnutType.LABEL_STYLE, LabelStyle.OutsideColumn);
		series.setAttribute(ChartDoughnutType.OPTIMIZE_POINTS, Boolean.FALSE);
	}
}
<?xml version="1.0" encoding="utf-8"?>
<ai:chart xmlns:ai="http://www.artfulbits.com/android/aiCharts">
    <ai:area />
    <ai:series type="Doughnut" showLabel="true"/>
    <ai:title text="Doughnut ingredients"/>
</ai:chart>
Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2014 ArtfulBits. All rights reserved.