public class TimeChart

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

Specialised LineChart that formats the X axis as dates or times.

Populate the chart with an XYMultipleSeriesDataset where X values are expressed as milliseconds since the epoch. Configure the desired date format using #setDateFormat(String) or let the chart choose an appropriate format automatically.

Fields

public static final String TYPE = "Time"/** The constant to identify this chart type.
public static final long DAY = 86400000LThe number of milliseconds in a day.

Constructors

public TimeChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)Builds a new time chart instance.

Methods

public String getDateFormat()Returns the date format pattern to be used for formatting the X axis labels.
public void setDateFormat(String format)Sets the date format pattern to be used for formatting the X axis labels.
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.
public String getChartType()Returns the chart type identifier.
protected List<Double> getXLabels(double min, double max, int count)

Inherited fields

Inherited methods

Field details

TYPE

public static final String TYPE = "Time"
/** The constant to identify this chart type.

DAY

public static final long DAY = 86400000L
The number of milliseconds in a day.

Constructor details

TimeChart

public TimeChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer)
Builds a new time chart instance.

Parameters

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

Method details

getDateFormat

public String getDateFormat()
Returns the date format pattern to be used for formatting the X axis labels.

Returns

the date format pattern for the X axis labels

setDateFormat

public void setDateFormat(String format)
Sets the date format pattern to be used for formatting the X axis labels.

Parameters

format String
the date format pattern for the X axis labels. If null, an appropriate default format will be used.

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

getChartType

public String getChartType()
Returns the chart type identifier.

Returns

the chart type

getXLabels

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