public class CombinedXYChart

  1. Object
  2. AbstractChart
  3. XYChart
  4. CombinedXYChart

Aggregates multiple XYChart implementations into a single plot so different series can be visualised using different renderers (for example a line overlaid on top of a bar chart).

Provide the constructor with an XYMultipleSeriesDataset, a matching XYMultipleSeriesRenderer and an array of XYCombinedChartDef instances that describe which inner chart type should render each data series. The combined chart can then be wrapped in a com.codename1.charts.ChartComponent for display.

Nested types

class CombinedXYChart.XYCombinedChartDefDefinition of a chart inside a combined XY chart.

Constructors

public CombinedXYChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, CombinedXYChart.XYCombinedChartDef[] chartDefinitions)Builds a new combined XY chart instance.

Methods

public void drawSeries(Canvas canvas, Paint paint, List<Float> points, XYSeriesRenderer seriesRenderer, float yAxisValue, int seriesIndex, int startIndex)The graphical representation of a series.
protected ClickableArea[] clickableAreasForPoints(List<Float> points, List<Double> values, float yAxisValue, int seriesIndex, int startIndex)Returns the clickable areas for all passed points
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.
public int getLegendShapeWidth(int seriesIndex)Returns the legend shape width.
public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y, int seriesIndex, Paint paint)The graphical representation of the legend shape.
public String getChartType()Returns the chart type identifier.

Inherited fields

Inherited methods

Constructor details

CombinedXYChart

public CombinedXYChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, CombinedXYChart.XYCombinedChartDef[] chartDefinitions)
Builds a new combined XY chart instance.

Parameters

dataset XYMultipleSeriesDataset
the multiple series dataset
renderer XYMultipleSeriesRenderer
the multiple series renderer
chartDefinitions CombinedXYChart.XYCombinedChartDef[]
the XY chart definitions

Method details

drawSeries

public 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 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

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

getLegendShapeWidth

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

Parameters

seriesIndex int
the series index

Returns

the legend shape width

drawLegendShape

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

Parameters

canvas Canvas
the canvas to paint to
renderer SimpleSeriesRenderer
the series renderer
x float
the x value of the point the shape should be drawn at
y float
the y value of the point the shape should be drawn at
seriesIndex int
the series index
paint Paint
the paint to be used for drawing

getChartType

public String getChartType()
Returns the chart type identifier.

Returns

the chart type