public class LineChart

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

Known subtypesCubicLineChart, TimeChart

Plots series of X/Y points using straight line segments.

Supply the chart with an XYMultipleSeriesDataset and configure its appearance via an XYMultipleSeriesRenderer. The chart is commonly wrapped in a com.codename1.charts.ChartComponent before being added to a Codename One form.

Fields

public static final String TYPE = "Line"The constant to identify this chart type.

Constructors

public LineChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)Builds a new line chart instance.

Methods

protected void setDatasetRenderer(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)Sets the series and the renderer.
public void drawSeries(Canvas canvas, Paint paint, List<Float> points, XYSeriesRenderer renderer, 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
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 boolean isRenderPoints(SimpleSeriesRenderer renderer)Returns if the chart should display the points as a certain shape.
public ScatterChart getPointsChart()Returns the scatter chart to be used for drawing the data points.
public String getChartType()Returns the chart type identifier.

Inherited fields

Inherited methods

Field details

TYPE

public static final String TYPE = "Line"
The constant to identify this chart type.

Constructor details

LineChart

public LineChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)
Builds a new line 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)
Sets the series and the renderer.

Parameters

dataset XYMultipleSeriesDataset
the series dataset
renderer XYMultipleSeriesRenderer
the series renderer

drawSeries

public void drawSeries(Canvas canvas, Paint paint, List<Float> points, XYSeriesRenderer renderer, 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
renderer 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

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

isRenderPoints

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

Parameters

renderer SimpleSeriesRenderer
the series renderer

getPointsChart

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

Returns

the data points scatter chart

getChartType

public String getChartType()
Returns the chart type identifier.

Returns

the chart type