Class
caplin.chart

Study

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

The Study class accepts, as its last argument, a map of overrides for configuration options for the descendant study. These 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 type of, and how many, 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 serialised.
colornullString This configuration option has been deprecated, use `colors` instead.
The colour for the study series that should be used by the chart component.
colors[null]Array The list of colours for the study series that should be used by the chart component.

Constructor Summary

Attributes Name and Description
caplin.chart.Study(String alias, Object derivationParams, Object listener, Object configOverrides)

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 data)

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

String getAlias()

Gets the alias name of the study.

String|null getColor()

Array getColors()

Returns a list of colours for each series this study outputs.

void getConfigValue(String key)

Gets a specific Study configuration option.

void getDerivationParam(String key)

Gets a specific Study derivation option.

Object getDerivationParams()

Gets the derivation options of the study.

String getDisplayName(Number seriesIdx)

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 alias, Object derivationParams, Object listener, Object configOverrides)

Provides initial initialisation of the Study. Concrete studies must extend this abstract class and call this constructor (caplin.chart.Study.call(this, alias, derivationParams, listener, configOverrides);).

Parameters
String alias The Study alias.
Object derivationParams Options that the study will use to determine how to calculate the study series data. This will usually be at least period.
Object listener A listener object that implements the caplin.chart.study.StudyListener interface.
Object configOverrides (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 values index within the studies current data set.
Array arr The data that the Study is currently evaluating.

void evaluate(Array data)

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

Parameters
Array data Chart series data in the Caplin Format.

String getAlias()

Gets the alias name of the study.

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

Returns
{String} The alias for the Study.

String|null getColor()

Deprecated
Use caplin.chart.Study#getColors instead. Returns the colour that was set for this study. By default this is null.
Returns
{String|null} The colour of the study.

Array getColors()

Returns a list of colours for each series this study outputs.

Returns
{Array} List of colours for each study series.

void getConfigValue(String key)

Gets a specific Study configuration option.

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

void getDerivationParam(String key)

Gets a specific Study derivation option.

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

Object getDerivationParams()

Gets the derivation options of the study.

Returns
{Object} The options.

String getDisplayName(Number seriesIdx)

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

Parameters
Number seriesIdx (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.