com.googlecode.charts4j
Class Data

java.lang.Object
  extended by com.googlecode.charts4j.Data

public class Data
extends Object

Type that contains the numeric information that will be rendered in the chart. The constructor and static factory methods in this class take values from 0 to 100. If your data does not fall in that range, you need to scale it so it does. This is the case for negative number, for instance. If you are having trouble scaling your data please see DataUtil. Numbers outside the 0 to 100 range will be considered invalid and will be treated as invalid according to the chart type. For the curious, behind the scenes, the data in this class is converted to the Google Chart API simple, text, or extended encoding.

Author:
Julien Chastang (julien.c.chastang at gmail dot com)
See Also:
DataUtil, Plots, GCharts

Field Summary
static Data INVALID
          Invalid data series.
static double MAX_VALUE
          Maximum value of data is 100.
static double MIN_VALUE
          Minimum value of data is zero.
 
Constructor Summary
Data(double... data)
          The data that will eventually be rendered by a chart.
 
Method Summary
 double[] getData()
          Get a copy of the backing array.
 int getSize()
          Get the size of the dataset.
static Data newData(double... data)
          Static factory method for creating Data instance.
static Data newData(List<? extends Number> data)
          Static factory method for creating Data instance.
 String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final double MIN_VALUE
Minimum value of data is zero.

See Also:
Constant Field Values

MAX_VALUE

public static final double MAX_VALUE
Maximum value of data is 100.

See Also:
Constant Field Values

INVALID

public static final Data INVALID
Invalid data series.

Constructor Detail

Data

public Data(double... data)
The data that will eventually be rendered by a chart. The static factory methods newData(double...) and newData(List) should be used in preference to this constructor.

Parameters:
data - Double data. Double values must be between 0 and 100. data array is defensively copied. Numbers outside the 0 to 100 range will be considered invalid and will be treated as invalid according to the chart type.
Method Detail

toString

public String toString()

Overrides:
toString in class Object

getData

public final double[] getData()
Get a copy of the backing array. Original backing array is not visible to the caller.

Returns:
copy of double array representing the data.

getSize

public final int getSize()
Get the size of the dataset.

Returns:
Size of the dataset.

newData

public static Data newData(double... data)
Static factory method for creating Data instance.

Parameters:
data - Double data. Double values must be between 0 and 100. data array is deep copied so the array reference the client passes is not kept. Numbers outside the 0 to 100 range will be considered invalid and will be treated as invalid according to the chart type.
Returns:
Freshly constructed Data object.

newData

public static Data newData(List<? extends Number> data)
Static factory method for creating Data instance.

Parameters:
data - Number data. Number values must be between 0 and 100. List is defensively copied. Numbers outside the 0 to 100 range will be considered invalid and will be treated as invalid according to the chart type.
Returns:
Freshly constructed Data object.