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

StackedArea Chart Type

Overview

An stack area chart is a type of chart where multiple series are stacked vertically. If there is only one series in your chart, the stacked area chart will display the same as an area chart.

Creating the Stack Area Chart

In order to create a stack column chart is needed to create two instances of chart series, set ChartType for those series as StackedBar 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.stackedareasample;

import com.artfulbits.aiCharts.ChartView;
import com.artfulbits.aiCharts.Base.ChartPoint;
import com.artfulbits.aiCharts.Base.ChartSeries;

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 sunSeries = chartView.getSeries().get("Sun");
		ChartSeries rainSeries = chartView.getSeries().get("Rain");
		ChartSeries snowSeries = chartView.getSeries().get("Snow");
		
		String[] labels = { "summer", "autumn", "winter", "spring", "summer" }; 
		double[] sun = { 50, 30, 20, 40, 50 };
		double[] rain = { 30, 50, 5, 40, 30 };
		double[] snow = { 0, 30, 80, 20, 0 };
		
		for (int i = 0; i < sun.length; i++)
		{
			ChartPoint point = sunSeries.getPoints().addXY(i, sun[i]);
			
			rainSeries.getPoints().addXY(i, rain[i]);
			snowSeries.getPoints().addXY(i, snow[i]);
			
			point.setAxisLabel(labels[i]);
		}
	}
}
<?xml version="1.0" encoding="utf-8"?>
<ai:chart xmlns:ai="http://www.artfulbits.com/android/aiCharts">
	<ai:area>
		<ai:area.yaxis labels_visible="false"/>
		<ai:area.xaxis labels_mode="SeriesLabels"/>
	</ai:area>
	<ai:series type="StackedArea" name="Sun" color="#FFFFD800"/>
	<ai:series type="StackedArea" name="Snow" color="#FFFFFFFF"/>
	<ai:series type="StackedArea" name="Rain" color="#FF0094FF"/>
	<ai:legend/>
</ai:chart>
Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2016 ArtfulBits. All rights reserved.