com.fusioncharts
Class Series

java.lang.Object
  extended by com.fusioncharts.Series
All Implemented Interfaces:
java.lang.Cloneable

public class Series
extends java.lang.Object
implements java.lang.Cloneable

The Series class provides a series object that is used by the Graph class Originally this was a subclass of WePopChart.java but we decided that it was a better solution to separate it from the class. 20090323 - First created by David Lai


Nested Class Summary
static class Series.SeriesType
          Series Enum that determines the series type Can either be: Bar, Line, Area, Trendline
 
Constructor Summary
Series(java.lang.String label, int count)
          Creates a Series object.
 
Method Summary
 void add(int index, java.lang.Double value)
          Adds the value at a specified index by the specified value.
 double calculateAvg()
          Calculates the average of the series.
 double calculateMax()
          Calculates the maximum value of the series.
 double calculateMin()
          Calculates the minimum value of the series.
 double calculateSum()
          Calculates the sum of the series.
 double calculateSum(int startIndex, int untilIndex)
          Calculates the sum of a segment of the series.
 void clear()
          Clears the data from this Series and resets the values to zero.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 void dec(int index)
          Decrements the value at a specified index.
 void div(int index, double value)
          Divides the value at a specified index by the specified value.
 java.lang.String getColor(int index)
          Accessor method to get the color of the series.
 java.lang.String getEvent(int index)
          Gets the javascript event or url for drill downs at a specific index
 java.text.DecimalFormat getFormat()
          Accessor method to return the decimal format of the series.
 java.lang.String getLabel()
          Accessor method to return the series label.
 int getNumberOfValues()
          Returns the number of data values.
 Series.SeriesType getSeriesType()
          Accessor method to return the series type.
 java.lang.String getToolText(int index)
          Returns the tooltip popup value.
 java.lang.Double getValue(int index)
          Returns the data values.
 void inc(int index)
          Increments the value at a specified index by one.
 void mul(int index, double value)
          Multiplies the value at a specified index by the specified value.
 void setColor(int r, int g, int b, int index)
          Manipulator method to set the color specified red, green, and blue values in the range (0 - 255).
 void setColor(int index, java.lang.String color)
          Sets color at the specified indice.
 void setColor(java.lang.String... colors)
          Manipulator method to set the colors.
 void setEvent(int index, java.lang.String event)
          Sets the url or javascript event at the specified indice.
 void setEvent(java.lang.String... events)
          Sets the javascript event or url for drill downs.
 void setFormat(java.text.DecimalFormat format)
          Manipulator method to set the decimal formatting object.
 void setFormat(java.lang.String format)
          Manipulator method to set the decimal format pattern.
 void setLabel(java.lang.String label)
          Manipulator method to set the series label.
 void setSeriesType(Series.SeriesType seriesType)
          Manipulator method to set the series type.
 void setToolText(int index, java.lang.String toolText)
          Sets the Tool Tip popup value at the specified indice.
 void setToolText(java.lang.String... toolText)
          Sets the Tool Tip popup values.
 void setValue(java.lang.Double... value)
          Sets the data values.
 void setValue(int index, java.lang.Double value)
          Sets the data value at the specified indice.
 void sub(int index, double value)
          Subtracts the value at a specified index by the specified value.
 java.lang.String toString()
          Method to return the string representation of this series.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Series

public Series(java.lang.String label,
              int count)
       throws java.lang.IllegalArgumentException
Creates a Series object. The series is set to a BAR series by default.

Parameters:
label - The series label.
count - The number of data values.
Throws:
java.lang.IllegalArgumentException - If the count is less than or equal to zero.
Method Detail

getSeriesType

public Series.SeriesType getSeriesType()
Accessor method to return the series type.

Returns:
seriesType The series type. Note that normal seriesType can be assumed as regular

setSeriesType

public void setSeriesType(Series.SeriesType seriesType)
Manipulator method to set the series type.

Parameters:
seriesType - The series type. For example if it is a trendline then mark it as "trendline"

setLabel

public void setLabel(java.lang.String label)
Manipulator method to set the series label.

Parameters:
label - The series label.

getLabel

public java.lang.String getLabel()
Accessor method to return the series label.

Returns:
label The series label.

setColor

public void setColor(int index,
                     java.lang.String color)
              throws java.lang.ArrayIndexOutOfBoundsException
Sets color at the specified indice.

Parameters:
index - The indice of the color to set.
color - The color to set.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than zero or greater than or equal to the length.

setColor

public void setColor(java.lang.String... colors)
Manipulator method to set the colors. The first color corresponds to index 0. If the length of the array passed is less than the length of the value array, the last value of the array passed will be used to fill the remaining events.

Parameters:
colors - The colors array in the format RRGGBB.

setColor

public void setColor(int r,
                     int g,
                     int b,
                     int index)
              throws java.lang.IllegalArgumentException
Manipulator method to set the color specified red, green, and blue values in the range (0 - 255).

Parameters:
r - The red component.
g - The green component.
b - The blue component.
index - The indice of the color to set.
Throws:
java.lang.IllegalArgumentException - If the color component is not in the range of 0 to 255.

getColor

public java.lang.String getColor(int index)
                          throws java.lang.ArrayIndexOutOfBoundsException
Accessor method to get the color of the series.

Parameters:
index - The indice of the color to get.
Returns:
color The color in the format RRGGBB.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than zero or greater than or equal to the length.

setFormat

public void setFormat(java.text.DecimalFormat format)
Manipulator method to set the decimal formatting object.

Parameters:
format - The decimal format.
See Also:
java.text.DecimalFormat} For the available formatting patterns and characters.

setFormat

public void setFormat(java.lang.String format)
Manipulator method to set the decimal format pattern.

Parameters:
format - The decimal format pattern.
See Also:
java.text.DecimalFormat} For the available formatting patterns and characters.

getFormat

public java.text.DecimalFormat getFormat()
Accessor method to return the decimal format of the series.

Returns:
DecimalFormat The decimal format.

setEvent

public void setEvent(int index,
                     java.lang.String event)
              throws java.lang.ArrayIndexOutOfBoundsException
Sets the url or javascript event at the specified indice.

Parameters:
index - The indice of the event to set.
event - The url or javascript event.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than zero or greater than or equal to the length.

setEvent

public void setEvent(java.lang.String... events)
Sets the javascript event or url for drill downs. The first value corresponds to index 0. If the length of the array passed is less than the length of the value array, the last value of the array passed will be used to fill the remaining events.

Parameters:
events - The javascript event to use for drill-downs.

getEvent

public java.lang.String getEvent(int index)
                          throws java.lang.ArrayIndexOutOfBoundsException
Gets the javascript event or url for drill downs at a specific index

Parameters:
index - The indice of the event to set.
Returns:
String[] The javascript or url.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than zero or greater than or equal to the length.

setValue

public void setValue(int index,
                     java.lang.Double value)
              throws java.lang.ArrayIndexOutOfBoundsException
Sets the data value at the specified indice.

Parameters:
index - The indice of the data to set.
value - The data value.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than zero or greater than or equal to the length.

setValue

public void setValue(java.lang.Double... value)
Sets the data values. The first value corresponds to index 0. If the length of the array passed is less than the length of the value array, the last value is the array passed will be used to fill the remaining values.

Parameters:
value - The data value(s).

getValue

public java.lang.Double getValue(int index)
                          throws java.lang.ArrayIndexOutOfBoundsException
Returns the data values.

Parameters:
index - The indice of the data to get.
Returns:
value The data values.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than zero or greater than or equal to the length.

getToolText

public java.lang.String getToolText(int index)
                             throws java.lang.ArrayIndexOutOfBoundsException
Returns the tooltip popup value.

Parameters:
index - The indice of the tooltext to get.
Returns:
toolText The toolText popup.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than zero or greater than or equal to the length.

setToolText

public void setToolText(java.lang.String... toolText)
Sets the Tool Tip popup values. The first value corresponds to index 0. If the length of the array passed is less than the length of the toolText array, the last value is the array passed will be used to fill the remaining toolText values.

Parameters:
toolText - The toolText value(s).

setToolText

public void setToolText(int index,
                        java.lang.String toolText)
                 throws java.lang.ArrayIndexOutOfBoundsException
Sets the Tool Tip popup value at the specified indice.

Parameters:
index - The indice of the data to set.
toolText - The Tool Tip value.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than zero or greater than or equal to the length.

getNumberOfValues

public int getNumberOfValues()
Returns the number of data values.

Returns:
int The number of data values.

inc

public void inc(int index)
         throws java.lang.ArrayIndexOutOfBoundsException
Increments the value at a specified index by one.

Parameters:
index - The index of the value to modify.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than 0 or greater than or equal to the length of all the values.

dec

public void dec(int index)
         throws java.lang.ArrayIndexOutOfBoundsException
Decrements the value at a specified index.

Parameters:
index - The index of the value to modify.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than 0 or greater than or equal to the length of all the values.

add

public void add(int index,
                java.lang.Double value)
         throws java.lang.ArrayIndexOutOfBoundsException
Adds the value at a specified index by the specified value.

Parameters:
index - The index of the value to modify.
value - The value to increment by.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than 0 or greater than or equal to the length of all the values.

sub

public void sub(int index,
                double value)
         throws java.lang.ArrayIndexOutOfBoundsException
Subtracts the value at a specified index by the specified value.

Parameters:
index - The index of the value to modify.
value - The value to decrement by.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than 0 or greater than or equal to the length of all the values.

mul

public void mul(int index,
                double value)
         throws java.lang.ArrayIndexOutOfBoundsException
Multiplies the value at a specified index by the specified value.

Parameters:
index - The index of the value to modify.
value - The value to multiply by.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than 0 or greater than or equal to the length of all the values.

div

public void div(int index,
                double value)
         throws java.lang.ArrayIndexOutOfBoundsException
Divides the value at a specified index by the specified value.

Parameters:
index - The index of the value to modify.
value - The value to divide by.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the index is less than 0 or greater than or equal to the length of all the values.

calculateSum

public double calculateSum(int startIndex,
                           int untilIndex)
Calculates the sum of a segment of the series. The starting index will be the maximum of the start index and 0 and the ending index will be the minimum between the ending index and the length of the values.

Parameters:
startIndex - The index to start from.
untilIndex - The index to end at (not including).
Returns:
double The sum of the series segment.

calculateSum

public double calculateSum()
Calculates the sum of the series.

Returns:
double The sum of the series.

calculateAvg

public double calculateAvg()
Calculates the average of the series.

Returns:
double The average of the series.

calculateMin

public double calculateMin()
Calculates the minimum value of the series.

Returns:
double The minimum of the series.

calculateMax

public double calculateMax()
Calculates the maximum value of the series.

Returns:
double The maximum of the series.

clear

public void clear()
Clears the data from this Series and resets the values to zero. Series properties such as color, format and drill-down event are maintained.


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates and returns a copy of this object.

Overrides:
clone in class java.lang.Object
Returns:
Object A clone of this instance.
Throws:
java.lang.CloneNotSupportedException - If the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
See Also:
java.lang.Cloneable}

toString

public java.lang.String toString()
Method to return the string representation of this series.

Overrides:
toString in class java.lang.Object
Returns:
String The script representation of this series.