Class
caplin.chart

Study

Abstract class that all studies must extend. It provides getters for derivation parameters and study configuration options. It also provide serialization support and batching functionality that concrete studies should use to send the study series data to it's listeners.

The Study class accepts, as it's last argument, a map of configuration options overrides for the descendant study. This options can be overridden in two places. The Study defines the sensible defaults. The first place where the configuration options can be overridden is in the descendant study's constructor when it calls the parent constructor. The second place is when you create a new instance of a study (either using the caplin.chart.study.Factory or caplin.chart.Series#addStudy). A descendant must pass the user's override up to the Study.

The table below explains each possible configuration option.

namedefaulttypedescription
batchSize100Number How many study series points should be sent to the listener at once.
representationTypes['spline']Array What kind of, and how many of, series will this study output.
representationNames['']Array The logical name for each outputted study series. This will only be used by studies that output more than one series.
i18nPrefixct.analysis.study.String The i18n key prefix used by the `getDisplayName`.
isolatedfalseBoolean Should the chart component represent this study on a different panel.
serializetrueBoolean Should this study be serialized.
colornullString The colour for the study series that should be used by the chart component.

Constructor Summary

Attributes Name and Description
caplin.chart.Study(String sAlias, Object mDerivationParams, Object oListener, Object mConfigOverrides)

Provides initial initialisation of the Study.

Method Summary

Attributes Name and Description
void enqueue(Array data, Number idx, Array arr)

Enqueues processed study data, which is then batch forwarded to the listener.

void evaluate(Array pData)

This method will get called by the caplin.chart.Series every time it will get new chart data.

String getAlias()

Gets the study's alias name.

String|null getColor()

Returns the colour that was set for this study.

void getConfigValue(String sKey)

Gets a specific Study configuration option.

void getDerivationParam(String sKey)

Gets a specific Study derivation option.

Object getDerivationParams()

Gets the Study's derivation options.

String getDisplayName(Number nSeriesIdx)

Gets the display name of the series, derived from the alias and configuration parameters.

String getId()

Get the ID of this study.

Array getRepresentationNames()

Gets the representation names for individual series generated by the study.

Array getRepresentationTypes()

Gets the representation types of the data that the study returns (line, spline, .

String serialize()

Returns the serialised state of the study.

Constructor Detail

caplin.chart.Study(String sAlias, Object mDerivationParams, Object oListener, Object mConfigOverrides)

Provides initial initialisation of the Study. Concrete studies must extend this abstract class and call this constructor (caplin.chart.Study.call(this, sAlias, mDerivationParams, oListener, mConfigOverrides);).

Parameters
String sAlias The Study alias.
Object mDerivationParams Options that the study will use to determine how to calculate the study series data. This will usually be at leas period.
Object oListener A listener object that implements the caplin.chart.study.StudyListener interface.
Object mConfigOverrides (optional) The configuration options for the study. See the Study description for details.

Method Detail

void enqueue(Array data, Number idx, Array arr)

Enqueues processed study data, which is then batch forwarded to the listener.

Performance optimisation for older browsers.

This method is only to be called by the Study by methods #evaluate or #onStudyData.

Parameters
Array data The latest value array from the Study.
Number idx The current value's index within the studies current data set.
Array arr The data that the Study is currently evaluating.

void evaluate(Array pData)

This method will get called by the caplin.chart.Series every time it will get new chart data. This method should perform it's calculations and then pass the calculated data to the listeners onStudyData method. See caplin.chart.SeriesListener.

Parameters
Array pData Chart series data in the Caplin Format.

String getAlias()

Gets the study's alias name.

The alias name is used to identify the study when deserialising the persisted form.

Returns
{String} The alias for the Study.

String|null getColor()

Returns the colour that was set for this study. By default this is null.

Returns
{String|null} The colour of the study.

void getConfigValue(String sKey)

Gets a specific Study configuration option.

Parameters
String sKey The configuration option key.
Returns
The configuration option value.

void getDerivationParam(String sKey)

Gets a specific Study derivation option.

Parameters
String sKey The option key.
Returns
The derivation option value.

Object getDerivationParams()

Gets the Study's derivation options.

Returns
{Object} The options.

String getDisplayName(Number nSeriesIdx)

Gets the display name of the series, derived from the alias and configuration parameters.

Parameters
Number nSeriesIdx (optional) The index of the series.
Returns
{String} The internationalised display name.

String getId()

Get the ID of this study.

The ID is constructed from the study type and derivation options.

Returns
{String} The ID of this study.

Array getRepresentationNames()

Gets the representation names for individual series generated by the study. This exists for studies that return more than one series (such as the Bollinger band).

Returns
{Array} The list of series names within a study.

Array getRepresentationTypes()

Gets the representation types of the data that the study returns (line, spline, ...).

This is used by the caplin.chart.Chart to determine how to display the study data.

Returns
{Array} Style of the study data.

String serialize()

Returns the serialised state of the study. The serialisation logic is handled by the caplin.chart.Series so you don't have to call this method manually.

Returns
{String} The XML representation of the object.