Class
caplin.chart

Study

The class is still in Beta and is subject to API changes.
Abstract class that all studies must extend. It provides some basic getter functions and the constructor will setup the new object with member variables that the studies will use (_options & _listener).

The constructor will also initialise three member variables (_representationTypes, _representationNames & _name) for which studies must provide values as they are used in the getId & getRepresentationType methods.

Each study accepts two arguments:

namedescription
mOptions A map of options that the study needs to work.
nameoptionaldescription
period no The period that the study will operate on
... yes Any additional options the study needs
oListener Object that will receive updates from the study when it has evaluated the data. This will be the caplin.chart.Series object in most cases but it can also be another study, as some studies will use other study data to evaluate their own (Bollinger band, for instance, uses the simple moving average). The listener must implement the caplin.chart.SeriesListener interface.
oEmitter An optional object to relay data to the listener.

To use a study you add it to the caplin.chart.Series object wit the caplin.chart.Series#addStudy method.

Constructor Summary

Attributes Name and Description
caplin.chart.Study(Object mOptions, Object oListener, Object oEmitter)

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

Performance optimisation for older browsers

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

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

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

Object getConfiguration()

Get the configuration options for the study.

String getDisplayName( seriesIdx)

Gets the display name, derived from the name and option 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, .

Constructor Detail

caplin.chart.Study(Object mOptions, Object oListener, Object oEmitter)

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

Parameters
Object mOptions Study options
Object oListener The listener for study data
Object oEmitter An optional emitter override

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 deserializing the persisted form

Returns
{String} The alias for the Study

Object getConfiguration()

Get the configuration options for the study.

Returns
{Object} The object literal containing the initialisation options

String getDisplayName( seriesIdx)

Gets the display name, derived from the name and option parameters.

Parameters
seriesIdx
Returns
{String} The internationalized display name

String getId()

Get the ID of this study.

The ID is constructed from the study type and configuration 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