com.googlecode.charts4j
Class DataUtil

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

public final class DataUtil
extends Object

Perusing the Google Chart API Group reveals that a lot of users and developers are having difficulty scaling their data. A common question is "What do I do about negative numbers?". Or "What if my data lies outside the simple or extended encoding range?" The answer to these problems is that users must scale their data so that they may be rendered in the chart. This class helps users achieve that goal.

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

Method Summary
static Data scale(double... data)
          Static factory method that will simply scale between the minimum and maximum values in the data.
static Data scale(List<? extends Number> data)
          Static factory method that will simply scale between the minimum and maximum values in the data.
static Data scaleWithinRange(double min, double max, double[] data)
          Static factory method that will scale data between the min and max.
static Data scaleWithinRange(double min, double max, List<? extends Number> data)
          Static factory method that will scale data between the min and max.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

scaleWithinRange

public static Data scaleWithinRange(double min,
                                    double max,
                                    double[] data)
Static factory method that will scale data between the min and max. If max equals min or max is less than min, no scaling will occur. Note that the min value can be less than the minimum value of the data and that the max value can be greater than the maximum value of the data. This scenario is useful when you don't want your plot to span the entire chart, but you would like the plots to be "squeezed in" a bit.

Parameters:
min - The minimum value in the scaling range.
max - The maximum value in the scaling range.
data - The data
Returns:
A Data object scaled between min and max.
See Also:
Data

scaleWithinRange

public static Data scaleWithinRange(double min,
                                    double max,
                                    List<? extends Number> data)
Static factory method that will scale data between the min and max. If max equals min or max is less than min, no scaling will occur. Note that the min value can be less than the minimum value of the data and that the max value can be greater than the maximum value of the data. This scenario is useful when you don't want your plot to span the entire chart, but you would like the plots to be "squeezed in" a bit.

Parameters:
min - The minimum value in the scaling range.
max - The maximum value in the scaling range.
data - The data list to be scaled. The Number type is used as a convenience but Numbers that fall outside the Double.MAX_VALUE and Double.MIN_VALUE should not be used.
Returns:
A Data object scaled between min and max.
See Also:
Data

scale

public static Data scale(double... data)
Static factory method that will simply scale between the minimum and maximum values in the data.

Parameters:
data - Provide a data series that will be scaled by this method.
Returns:
A Data object scaled between minimum and maximum in the provided data series.
See Also:
Data

scale

public static Data scale(List<? extends Number> data)
Static factory method that will simply scale between the minimum and maximum values in the data.

Parameters:
data - Provide a data series that will be scaled by this method.
Returns:
A Data object scaled between minimum and maximum in the provided data series. The Number type is used as a convenience but Numbers that fall outside the Double.MAX_VALUE and Double.MIN_VALUE should not be used.
See Also:
Data