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

Bar Chart Type

Overview

A bar chart is a chart with rectangular bars with lengths proportional to the values that they represent. Bar charts are used for comparing two or more values that were taken over time or on different conditions, usually on small data sets. This chart type is one of the most suitable way to display results that are one time, that are not continuous. The aiCharts bar chart uses the Y-axis for labeling. In the situation like this, there is more room to fit text labels for categorical variables on the Y-axis.

Creating the Bar Chart

In order to create a simple bar chart is needed to create an instance of chart series, set ChartType as Bar 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.barsample;

import java.util.Calendar;

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 series1 = chartView.getSeries().get(0);
		
		double[] data = { 74, 38, 56, 67, 49, 51, 34 };
		Calendar calendar = Calendar.getInstance();
		
		calendar.clear();
		calendar.set(2010, 2, 12);
		
		for (int i = 0; i < data.length; i++)
		{
			series1.getPoints().addDate(calendar, data[i]);
			calendar.add(Calendar.DAY_OF_MONTH, 1);
		}
	}
}
<?xml version="1.0" encoding="utf-8"?>
<chart>
	<area>
		<area.xaxis title="Sales"/>
		<area.yaxis title="Date"  valuetype="Date"/>
	</area>
	<series type="Bar" color="#FFE0400A" showlabel="true" halign="Near"/>
</chart>
Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2016 ArtfulBits. All rights reserved.