public final class

ChartArea

implements ILayout.IElement
com.artfulbits.aiCharts.Base.ChartArea

Class Overview

Represents chart area class. Chart area is an integral part of ChartEngine. It handles series and axes drawing logic. By design, chart passes recursive draw and layout calls to its children. Parent ChartEngine is able to host several areas represented by areas collection. Legend may represent series from separate areas making possible complex layout design depending on desired output (i.e. couple pie charts with legend representing each of them).

 // Retrieving default ChartEngine from ChartView
 Chart chart = chartView.getChart();
 // Adding 3 pie areas to the chart.
 for (int i = 0; i < 3; i++)
 {
 	// Instantiating ChartArea.
 	ChartArea area = new ChartArea();
 	// Setting the area name
 	area.setName("area" + i);
 	// Adding new area to chart.
 	chart.getAreas().add(area);
 
 	// Instantiating ChartSeries.
 	ChartSeries series = new ChartSeries("Series" + Integer.toString(i),
 			ChartTypes.Pie);
 	// Caching points collection.
 	ChartPointCollection points = series.getPoints();
 	// Adding 10 points to series.
 	for (int j = 0; j < 10; j++)
 	{
 		points.addXY(j, j * 100);
 	}
 
 	// Wiring series with area
 	series.setArea(area.getName());
 	// Adding series to chart.
 	chart.getSeries().add(series);
 }
 
Following output is expected:

XML Attributes
name Defines area name
grid Defines grid background resource

Summary

Public Constructors
ChartArea()
Initializes a new instance of ChartArea.
ChartArea(String name)
Initialize a new instance of ChartArea with specified Name.
ChartArea(ChartAxis xAxis, ChartAxis yAxis)
Initializes a new instance of ChartArea class using passed axes.
Public Methods
List<ChartAxis> getAxes()
Gets ChartAxis collection.
Drawable getBackground()
Gets the Drawable that is used to draw background of area.
Rect getBounds()
Gets area bounding rectangle.
CoordinateSystem getCoordinateSystem()
Returns current coordinate system.
ChartAxis getDefaultXAxis()
Gets the default X axis.
ChartAxis getDefaultYAxis()
Gets the default Y axis.
Drawable getGridBackground()
Gets the Drawable that is used to draw background of area.
String getName()
Gets the name of this area.
void getPadding(Rect out)
Gets padding applied to this area.
Rect getSeriesBounds()
Gets region occupied by series.
void layout(Rect rect)
Sets bounds for this element.
void measure(Point inOutSize)
Measures the element.
void refresh()
Refreshes the area.
void setBackground(Drawable drawable)
Sets the Drawable that is used to draw background of area grid.
void setBounds(Rect rect)
Sets bounds for this area.
void setDefaultXAxis(ChartAxis axis)
Sets the default X axis.
void setDefaultYAxis(ChartAxis axis)
Sets the default Y axis.
void setGridBackground(Drawable drawable)
Sets the Drawable that is used to draw background of area grid.
void setName(String name)
Sets the name for area.
void setPadding(int left, int top, int right, int bottom)
Sets padding for area.
void setPadding(int padding)
Applies padding for all sides of this area.
[Expand]
Inherited Methods
From interface com.artfulbits.aiCharts.Base.ILayout.IElement

Public Constructors

public ChartArea ()

Initializes a new instance of ChartArea. Sets default orientation for X and Y axes. Series should be added to area in order to be represented.

public ChartArea (String name)

Initialize a new instance of ChartArea with specified Name. Sets default orientation for X and Y axes. Series should be added to area in order to be represented.

Parameters
name unique chart area name

public ChartArea (ChartAxis xAxis, ChartAxis yAxis)

Initializes a new instance of ChartArea class using passed axes.

Parameters
xAxis Vertical axis that represents default X axis for area.
yAxis Horizontal axis that represents default Y axis for

Public Methods

public List<ChartAxis> getAxes ()

Gets ChartAxis collection.

Returns
  • instance of List filled with axes.

public Drawable getBackground ()

Gets the Drawable that is used to draw background of area.

Returns

public Rect getBounds ()

Gets area bounding rectangle.

Returns
  • Rect representing current area bounds.

public CoordinateSystem getCoordinateSystem ()

Returns current coordinate system.

Returns
  • The coordinate system.

public ChartAxis getDefaultXAxis ()

Gets the default X axis.

Returns
  • instance of ChartAxis used as default X axis.

public ChartAxis getDefaultYAxis ()

Gets the default Y axis.

Returns
  • instance of ChartAxis used as default X axis.

public Drawable getGridBackground ()

Gets the Drawable that is used to draw background of area.

Returns

public String getName ()

Gets the name of this area.

Returns
  • String representation of area' name.

public void getPadding (Rect out)

Gets padding applied to this area.

Parameters
out rectangle that represents left, top, right and bottom paddings applied on this area.

public Rect getSeriesBounds ()

Gets region occupied by series.

Returns
  • instance of RectF representing area's series bounds.

public void layout (Rect rect)

Sets bounds for this element.

Parameters
rect instance of Rect representing bounds for element.

public void measure (Point inOutSize)

Measures the element.

Parameters
inOutSize available size to contains the element. This parameter have to be used to return the desired size of element.

public void refresh ()

Refreshes the area. Ensures compatible series visibility, recalculates axes range.

public void setBackground (Drawable drawable)

Sets the Drawable that is used to draw background of area grid.

Parameters
drawable instance of Drawable class.

public void setBounds (Rect rect)

Sets bounds for this area.

Parameters
rect instance of region that should be occupied by this area.

public void setDefaultXAxis (ChartAxis axis)

Sets the default X axis.

Parameters
axis instance of ChartAxis that should be used as default X axis

public void setDefaultYAxis (ChartAxis axis)

Sets the default Y axis.

Parameters
axis instance of ChartAxis that should be used as default Y axis

public void setGridBackground (Drawable drawable)

Sets the Drawable that is used to draw background of area grid.

Parameters
drawable instance of Drawable class.

public void setName (String name)

Sets the name for area.

Parameters
name String representation of desired name.

public void setPadding (int left, int top, int right, int bottom)

Sets padding for area. Area will re-layout itself after this call.

Parameters
left left-side padding.
top top-side padding.
right right-side padding.
bottom bottom-side padding.
See Also

public void setPadding (int padding)

Applies padding for all sides of this area. Area will re-layout itself after this call.

Parameters
padding additional padding for area measured in pixels.