public abstract class XYChart

  1. Object
  2. AbstractChart
  3. XYChart

Known subtypesBarChart, BubbleChart, CombinedXYChart, LineChart, ScatterChart

The XY chart rendering class.

Fields

protected XYMultipleSeriesDataset mDatasetThe multiple series dataset.
protected XYMultipleSeriesRenderer mRendererThe multiple series renderer.

Constructors

protected XYChart()
public XYChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)Builds a new XY chart instance.

Methods

protected void setDatasetRenderer(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)
public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint)The graphical representation of the XY chart.
protected List<Double> getXLabels(double min, double max, int count)
protected Map<Integer, List<Double>> getYLabels(double[] minY, double[] maxY, int maxScaleNumber)
protected Rectangle getScreenR()
protected void setScreenR(Rectangle screenR)
protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, XYMultipleSeriesRenderer.Orientation or, int startIndex)Draws the series.
protected void drawPoints(Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex)Draws the series points.
protected void drawChartValuesText(Canvas canvas, XYSeries series, XYSeriesRenderer renderer, Paint paint, List<Float> points, int seriesIndex, int startIndex)The graphical representation of the series values as text.
protected void drawText(Canvas canvas, String text, float x, float y, Paint paint, float extraAngle)The graphical representation of a text, to handle both HORIZONTAL and VERTICAL orientations and extra rotation angles.
protected void drawXLabels(List<Double> xLabels, Double[] xTextLabelLocations, Canvas canvas, Paint paint, int left, int top, int bottom, double xPixelsPerUnit, double minX, double maxX)The graphical representation of the labels on the X axis.
protected void drawYLabels(Map<Integer, List<Double>> allYLabels, Canvas canvas, Paint paint, int maxScaleNumber, int left, int right, int bottom, double[] yPixelsPerUnit, double[] minY)The graphical representation of the labels on the Y axis.
protected void drawXTextLabels(Double[] xTextLabelLocations, Canvas canvas, Paint paint, boolean showLabels, int left, int top, int bottom, double xPixelsPerUnit, double minX, double maxX)The graphical representation of the text labels on the X axis.
public XYMultipleSeriesRenderer getRenderer()
public XYMultipleSeriesDataset getDataset()
public double[] getCalcRange(int scale)
public void setCalcRange(double[] range, int scale)
public double[] toRealPoint(float screenX, float screenY)
public double[] toScreenPoint(double[] realPoint)
public double[] toRealPoint(float screenX, float screenY, int scale)Transforms a screen point to a real coordinates point.
public double[] toScreenPoint(double[] realPoint, int scale)
public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)Given screen coordinates, returns the series and point indexes of a chart element.
public abstract void drawSeries(Canvas canvas, Paint paint, List<Float> points, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex)The graphical representation of a series.
protected abstract ClickableArea[] clickableAreasForPoints(List<Float> points, List<Double> values, float yAxisValue, int seriesIndex, int startIndex)Returns the clickable areas for all passed points
protected boolean isRenderNullValues()Returns if the chart should display the null values.
public boolean isRenderPoints(SimpleSeriesRenderer renderer)Returns if the chart should display the points as a certain shape.
public double getDefaultMinimum()Returns the default axis minimum.
public ScatterChart getPointsChart()Returns the scatter chart to be used for drawing the data points.
public abstract String getChartType()Returns the chart type identifier.

Inherited methods

Field details

mDataset

protected XYMultipleSeriesDataset mDataset
The multiple series dataset.

mRenderer

protected XYMultipleSeriesRenderer mRenderer
The multiple series renderer.

Constructor details

XYChart

protected XYChart()

XYChart

public XYChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)
Builds a new XY chart instance.

Parameters

dataset XYMultipleSeriesDataset
the multiple series dataset
renderer XYMultipleSeriesRenderer
the multiple series renderer

Method details

setDatasetRenderer

protected void setDatasetRenderer(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)

draw

public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint)
The graphical representation of the XY chart.

Parameters

canvas Canvas
the canvas to paint to
x int
the top left x value of the view to draw to
y int
the top left y value of the view to draw to
width int
the width of the view to draw to
height int
the height of the view to draw to
paint Paint
the paint

getXLabels

protected List<Double> getXLabels(double min, double max, int count)

getYLabels

protected Map<Integer, List<Double>> getYLabels(double[] minY, double[] maxY, int maxScaleNumber)

getScreenR

protected Rectangle getScreenR()

setScreenR

protected void setScreenR(Rectangle screenR)

drawSeries

protected void drawSeries(XYSeries series, Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, XYMultipleSeriesRenderer.Orientation or, int startIndex)
Draws the series.

Parameters

series XYSeries
the series
canvas Canvas
the canvas
paint Paint
the paint object
pointsList List<Float>
the points to be rendered
seriesRenderer XYSeriesRenderer
the series renderer
yAxisValue float
the y axis value in pixels
seriesIndex int
the series index
or XYMultipleSeriesRenderer.Orientation
the orientation
startIndex int
the start index of the rendering points

drawPoints

protected void drawPoints(Canvas canvas, Paint paint, List<Float> pointsList, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex)
Draws the series points.

Parameters

canvas Canvas
the canvas
paint Paint
the paint object
pointsList List<Float>
the points to be rendered
seriesRenderer XYSeriesRenderer
the series renderer
yAxisValue float
the y axis value in pixels
seriesIndex int
the series index
startIndex int
the start index of the rendering points

drawChartValuesText

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

Parameters

canvas Canvas
the canvas to paint to
series XYSeries
the series to be painted
renderer XYSeriesRenderer
the series renderer
paint Paint
the paint to be used for drawing
points List<Float>
the array of points to be used for drawing the series
seriesIndex int
the index of the series currently being drawn
startIndex int
the start index of the rendering points

drawText

protected void drawText(Canvas canvas, String text, float x, float y, Paint paint, float extraAngle)
The graphical representation of a text, to handle both HORIZONTAL and VERTICAL orientations and extra rotation angles.

Parameters

canvas Canvas
the canvas to paint to
text String
the text to be rendered
x float
the X axis location of the text
y float
the Y axis location of the text
paint Paint
the paint to be used for drawing
extraAngle float
the text angle

drawXLabels

protected void drawXLabels(List<Double> xLabels, Double[] xTextLabelLocations, Canvas canvas, Paint paint, int left, int top, int bottom, double xPixelsPerUnit, double minX, double maxX)
The graphical representation of the labels on the X axis.

Parameters

xLabels List<Double>
the X labels values
xTextLabelLocations Double[]
the X text label locations
canvas Canvas
the canvas to paint to
paint Paint
the paint to be used for drawing
left int
the left value of the labels area
top int
the top value of the labels area
bottom int
the bottom value of the labels area
xPixelsPerUnit double
the amount of pixels per one unit in the chart labels
minX double
the minimum value on the X axis in the chart
maxX double
the maximum value on the X axis in the chart

drawYLabels

protected void drawYLabels(Map<Integer, List<Double>> allYLabels, Canvas canvas, Paint paint, int maxScaleNumber, int left, int right, int bottom, double[] yPixelsPerUnit, double[] minY)
The graphical representation of the labels on the Y axis.

Parameters

allYLabels Map<Integer, List<Double>>
the Y labels values
canvas Canvas
the canvas to paint to
paint Paint
the paint to be used for drawing
maxScaleNumber int
the maximum scale number
left int
the left value of the labels area
right int
the right value of the labels area
bottom int
the bottom value of the labels area
yPixelsPerUnit double[]
the amount of pixels per one unit in the chart labels
minY double[]
the minimum value on the Y axis in the chart

drawXTextLabels

protected void drawXTextLabels(Double[] xTextLabelLocations, Canvas canvas, Paint paint, boolean showLabels, int left, int top, int bottom, double xPixelsPerUnit, double minX, double maxX)
The graphical representation of the text labels on the X axis.

Parameters

xTextLabelLocations Double[]
the X text label locations
canvas Canvas
the canvas to paint to
paint Paint
the paint to be used for drawing
showLabels boolean
Not documented.
left int
the left value of the labels area
top int
the top value of the labels area
bottom int
the bottom value of the labels area
xPixelsPerUnit double
the amount of pixels per one unit in the chart labels
minX double
the minimum value on the X axis in the chart
maxX double
the maximum value on the X axis in the chart

getRenderer

public XYMultipleSeriesRenderer getRenderer()

getDataset

public XYMultipleSeriesDataset getDataset()

getCalcRange

public double[] getCalcRange(int scale)

setCalcRange

public void setCalcRange(double[] range, int scale)

toRealPoint

public double[] toRealPoint(float screenX, float screenY)

toScreenPoint

public double[] toScreenPoint(double[] realPoint)

toRealPoint

public double[] toRealPoint(float screenX, float screenY, int scale)
Transforms a screen point to a real coordinates point.

Parameters

screenX float
the screen x axis value
screenY float
the screen y axis value
scale int
Not documented.

Returns

the real coordinates point

toScreenPoint

public double[] toScreenPoint(double[] realPoint, int scale)

getSeriesAndPointForScreenCoordinate

public SeriesSelection getSeriesAndPointForScreenCoordinate(Point screenPoint)
Given screen coordinates, returns the series and point indexes of a chart element. If there is no chart element (line, point, bar, etc) at those coordinates, null is returned.

Returns

the series and point indexes

drawSeries

public abstract void drawSeries(Canvas canvas, Paint paint, List<Float> points, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex)
The graphical representation of a series.

Parameters

canvas Canvas
the canvas to paint to
paint Paint
the paint to be used for drawing
points List<Float>
the array of points to be used for drawing the series
seriesRenderer XYSeriesRenderer
the series renderer
yAxisValue float
the minimum value of the y axis
seriesIndex int
the index of the series currently being drawn
startIndex int
the start index of the rendering points

clickableAreasForPoints

protected abstract ClickableArea[] clickableAreasForPoints(List<Float> points, List<Double> values, float yAxisValue, int seriesIndex, int startIndex)
Returns the clickable areas for all passed points

Parameters

points List<Float>
the array of points
values List<Double>
the array of values of each point
yAxisValue float
the minimum value of the y axis
seriesIndex int
the index of the series to which the points belong
startIndex int
the start index of the rendering points

Returns

an array of rectangles with the clickable area

isRenderNullValues

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

Returns

if null values should be rendered

isRenderPoints

public boolean isRenderPoints(SimpleSeriesRenderer renderer)
Returns if the chart should display the points as a certain shape.

Parameters

renderer SimpleSeriesRenderer
the series renderer

getDefaultMinimum

public double getDefaultMinimum()
Returns the default axis minimum.

Returns

the default axis minimum

getPointsChart

public ScatterChart getPointsChart()
Returns the scatter chart to be used for drawing the data points.

Returns

the data points scatter chart

getChartType

public abstract String getChartType()
Returns the chart type identifier.

Returns

the chart type