org.achartengine.chart
Class BarChart

java.lang.Object
  extended by org.achartengine.chart.AbstractChart
      extended by org.achartengine.chart.XYChart
          extended by org.achartengine.chart.BarChart
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
RangeBarChart

public class BarChart
extends XYChart

The bar chart rendering class.

See Also:
Serialized Form

Nested Class Summary
static class BarChart.Type
          The bar chart type enum.
 
Field Summary
protected  BarChart.Type mType
          The chart type.
static java.lang.String TYPE
          The constant to identify this chart type.
 
Fields inherited from class org.achartengine.chart.XYChart
mDataset, mRenderer
 
Constructor Summary
BarChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, BarChart.Type type)
          Builds a new bar chart instance.
 
Method Summary
protected  ClickableArea[] clickableAreasForPoints(java.util.List<java.lang.Float> points, java.util.List<java.lang.Double> values, float yAxisValue, int seriesIndex, int startIndex)
          Returns the clickable areas for all passed points
protected  void drawBar(android.graphics.Canvas canvas, float xMin, float yMin, float xMax, float yMax, float halfDiffX, int seriesNr, int seriesIndex, android.graphics.Paint paint)
          Draws a bar.
protected  void drawChartValuesText(android.graphics.Canvas canvas, XYSeries series, SimpleSeriesRenderer renderer, android.graphics.Paint paint, java.util.List<java.lang.Float> points, int seriesIndex, int startIndex)
          The graphical representation of the series values as text.
 void drawLegendShape(android.graphics.Canvas canvas, SimpleSeriesRenderer renderer, float x, float y, int seriesIndex, android.graphics.Paint paint)
          The graphical representation of the legend shape.
 void drawSeries(android.graphics.Canvas canvas, android.graphics.Paint paint, java.util.List<java.lang.Float> points, SimpleSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex)
          The graphical representation of a series.
 java.lang.String getChartType()
          Returns the chart type identifier.
protected  float getCoeficient()
          Returns the value of a constant used to calculate the half-distance.
 double getDefaultMinimum()
          Returns the default axis minimum.
protected  float getHalfDiffX(java.util.List<java.lang.Float> points, int length, int seriesNr)
          Calculates and returns the half-distance in the graphical representation of 2 consecutive points.
 int getLegendShapeWidth(int seriesIndex)
          Returns the legend shape width.
protected  boolean isRenderNullValues()
          Returns if the chart should display the null values.
 
Methods inherited from class org.achartengine.chart.XYChart
draw, drawSeries, drawText, drawXLabels, drawXTextLabels, drawYLabels, getCalcRange, getDataset, getPointsChart, getRenderer, getScreenR, getSeriesAndPointForScreenCoordinate, getXLabels, getYLabels, isRenderPoints, setCalcRange, setDatasetRenderer, setScreenR, toRealPoint, toRealPoint, toScreenPoint, toScreenPoint
 
Methods inherited from class org.achartengine.chart.AbstractChart
drawBackground, drawLabel, drawLegend, drawPath, drawPath, drawString, getExceed, getLabel, getLegendSize, isNullValue, isVertical
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE

public static final java.lang.String TYPE
The constant to identify this chart type.

See Also:
Constant Field Values

mType

protected BarChart.Type mType
The chart type.

Constructor Detail

BarChart

public BarChart(XYMultipleSeriesDataset dataset,
                XYMultipleSeriesRenderer renderer,
                BarChart.Type type)
Builds a new bar chart instance.

Parameters:
dataset - the multiple series dataset
renderer - the multiple series renderer
type - the bar chart type
Method Detail

clickableAreasForPoints

protected ClickableArea[] clickableAreasForPoints(java.util.List<java.lang.Float> points,
                                                  java.util.List<java.lang.Double> values,
                                                  float yAxisValue,
                                                  int seriesIndex,
                                                  int startIndex)
Description copied from class: XYChart
Returns the clickable areas for all passed points

Specified by:
clickableAreasForPoints in class XYChart
Parameters:
points - the array of points
values - the array of values of each point
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series to which the points belong
startIndex - the start index of the rendering points
Returns:
an array of rectangles with the clickable area

drawSeries

public void drawSeries(android.graphics.Canvas canvas,
                       android.graphics.Paint paint,
                       java.util.List<java.lang.Float> points,
                       SimpleSeriesRenderer seriesRenderer,
                       float yAxisValue,
                       int seriesIndex,
                       int startIndex)
The graphical representation of a series.

Specified by:
drawSeries in class XYChart
Parameters:
canvas - the canvas to paint to
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesRenderer - the series renderer
yAxisValue - the minimum value of the y axis
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points

drawBar

protected void drawBar(android.graphics.Canvas canvas,
                       float xMin,
                       float yMin,
                       float xMax,
                       float yMax,
                       float halfDiffX,
                       int seriesNr,
                       int seriesIndex,
                       android.graphics.Paint paint)
Draws a bar.

Parameters:
canvas - the canvas
xMin - the X axis minimum
yMin - the Y axis minimum
xMax - the X axis maximum
yMax - the Y axis maximum
halfDiffX - half the size of a bar
seriesNr - the total number of series
seriesIndex - the current series index
paint - the paint

drawChartValuesText

protected void drawChartValuesText(android.graphics.Canvas canvas,
                                   XYSeries series,
                                   SimpleSeriesRenderer renderer,
                                   android.graphics.Paint paint,
                                   java.util.List<java.lang.Float> points,
                                   int seriesIndex,
                                   int startIndex)
The graphical representation of the series values as text.

Overrides:
drawChartValuesText in class XYChart
Parameters:
canvas - the canvas to paint to
series - the series to be painted
renderer - the series renderer
paint - the paint to be used for drawing
points - the array of points to be used for drawing the series
seriesIndex - the index of the series currently being drawn
startIndex - the start index of the rendering points

getLegendShapeWidth

public int getLegendShapeWidth(int seriesIndex)
Returns the legend shape width.

Specified by:
getLegendShapeWidth in class AbstractChart
Parameters:
seriesIndex - the series index
Returns:
the legend shape width

drawLegendShape

public void drawLegendShape(android.graphics.Canvas canvas,
                            SimpleSeriesRenderer renderer,
                            float x,
                            float y,
                            int seriesIndex,
                            android.graphics.Paint paint)
The graphical representation of the legend shape.

Specified by:
drawLegendShape in class AbstractChart
Parameters:
canvas - the canvas to paint to
renderer - the series renderer
x - the x value of the point the shape should be drawn at
y - the y value of the point the shape should be drawn at
seriesIndex - the series index
paint - the paint to be used for drawing

getHalfDiffX

protected float getHalfDiffX(java.util.List<java.lang.Float> points,
                             int length,
                             int seriesNr)
Calculates and returns the half-distance in the graphical representation of 2 consecutive points.

Parameters:
points - the points
length - the points length
seriesNr - the series number
Returns:
the calculated half-distance value

getCoeficient

protected float getCoeficient()
Returns the value of a constant used to calculate the half-distance.

Returns:
the constant value

isRenderNullValues

protected boolean isRenderNullValues()
Returns if the chart should display the null values.

Overrides:
isRenderNullValues in class XYChart
Returns:
if null values should be rendered

getDefaultMinimum

public double getDefaultMinimum()
Returns the default axis minimum.

Overrides:
getDefaultMinimum in class XYChart
Returns:
the default axis minimum

getChartType

public java.lang.String getChartType()
Returns the chart type identifier.

Specified by:
getChartType in class XYChart
Returns:
the chart type


Copyright © 2009 - 2011 4ViewSoft. All Rights Reserved.