trendLines

Creates trendLines in the chart.

Syntax

trendLines="trendLines"

where:

Argument Default Description
trendLines null A comma-separated string of trendLines:
trendLines="[trendLine1],[trendLine2],...,[trendLineN]"
Each trendline is a semicolon separated string of parameter=value pairs:
param1=value1;param2=value2;...;paramN=valueN
Valid parameters are:
  • name: Required. A string for the name of the trendline.
  • member: Required. One or more member parameter can be added. The member to use to plot the trendline, in the form of uniqueDimensionName: uniqueMemberName For example: member=All Locations:East
  • type: Required. Valid types are:
    • exponential
    • linear
    • logarithmic
    • moving average(N): where N is at least 2
    • polynomial(N): where N is greater or equal to 2 and less or equal to 100.
    • power
  • drilldownscope: Optional. Valid values are descendents and none.
  • replace: Optional. Set to true for the trendline to be drawn replacing the line or bar with which it is associated; false, not to replace.
  • forecastforward: Optional. A number of periods or units to forecast. Not supported for moving average trendline type.
  • color: Optional. Specify a Java™ color or a hexadecimal value (for example, #CCCCFF).
  • style: Optional. Set to solid or dashed for the line style.

Usage

trendLines can be added to line, bar, area or scatter charts. The trendLines added can be modified by end users via the Chart > trendLines... option from the menu bar.

The following table describes the types of trendLines supported:
Linear
The least squares fit for a line represented.
This image shows the mathematical equation for a linear trendline.
where C1 is the slope and C0 is the intercept.
Logarithmic
The least squares fit through the data points.
This image shows the mathematical equation for a logarithmic trendline.
where C0 and C1 are constants, and ln is the natural logarithm function.
Polynomial
The least squares fit through the data points.
This image shows the mathematical equation for a polynomial trendline.
where C0 and C1...Cn are constants, where N is greater than or equal to 2, and N is less than or equal to 100.
Power
The least squares fit through the data points.
This image shows the mathematical equation for a power trendline.
where c and b are constants
Exponential
The least squares fit through the data points.
This image shows the mathematical equation for an exponential trendline.
where c and b are constants, and e is the base of the natural logarithm.
Moving Average
The average over the a specified time period. The number of periods in a moving average trendline equals the total number of points in the series less the number you specify for the period.
This image shows the mathematical equation for a moving average trendline.
where N is the number of prior periods to include in the moving average; Aj is the actual value at time j; Fj is the forecasted value at time j.
You can also implement your own trendline algorithm.

Custom trendline algorithms

All trending algorithms used by Alphablox are described in the trendingtypes.xml file. This file contains the name and full class name for each trending algorithm This file contains the display name and the full class name for each trending algorithm. An entry is as follows:
<trend-type id="polynomial">
<display-name lang="en">Polynomial</display-name>
<class>com.alphablox.blox.uimodel.core.chart.trending.PolynomialFitAlgorithm</class>
</trend-type>    
In order for the class to be loaded, the default class loader must be able to find the class. In addition, your custom trending algorithm class must extend com.alphablox.blox.uimodel.core.chart.trending.AbstractTrendingAlgorithm. See the Javadoc documentation of this class for further details.
Note: Custom trending algorithms will not be reflected in the trendline dialog.

A simple custom trending algorithm example

The following example implements all the methods required by AbstractTrendingAlgorithm. The custom function is defined in the f(number x) function. It returns 0 if the computation results in a null.
public class myTrendingAlgorithm extends AbstractTrendingAlgorithm {
   public void initialize(Number[] x, Number[] y, Chart chart) {
   }

   public Double f(Number x) {
      // create your algorithm
      return new Double(x == null ? 0 : (20 + (x.doubleValue() * 20))); 
   }

   public boolean isForecastEnabled() {
      return true;
   }

   public void setUserParameter(Object parameter) {
   }

   public boolean isScatterSupported() {
      return true;
   }

   public void parseSavedParameters(String parameters) {
      super.parseSavedParameters(parameters);
   }

   public String getParameterString() {
      return super.getParameterString();
   }

   public boolean isNullAllowed() {
      return true;
   }
}

Installation of custom trending algorithms

After the custom trending algorithm is created:
  1. Compile the class.
  2. Create a JAR file containing your custom class.
  3. Add the JAR file to your JVM's class path. For WebSphere®, the JAR file should be placed under <websphere_app_server_dir>/lib/ext.
  4. Edit the trendingTypes.xml file in <alphablox_dir>/repository/servers and add your trending algorithm.
  5. Restart the server for the changes to take effect.

Examples

The following example creates two trendLines, one polynomial with an order of 3 and the other, linear.
trendLines="name=poly(3);member=All Locations:All Locations;
replace=true; type=polynomial(3),
name=line;member=All Locations:Central;type=linear"

This creates a polynomial trendline plotted for each member in All Locations, whereas the Central location has a linear trendline. The original data series lines/bars are replaced (replace=true).