Caplin Trader 4.8.0

Class: module:caplin/chart/Series

module:caplin/chart/Series

The Series manages data fetching from a back-end system using the service aliased by caplin.chart-service. Its primary purpose is to provide a study management mechanism.

Chart components construct a new caplin.chart.Series object (passing it a SeriesRequest, which describes the type of data to request) when they wish to request new chart series data to display.

Classes that wish to be notified of events belonging to a series must implement the SeriesListener interface and register themselves as a listener to that series.

Classes that wish to be notified of study events belonging to a series must implement the StudyListener interface and register themselves as a listener to that series.

Constructor

new module:caplin/chart/Series(seriesRequest, chartSeriesAdapter)

Constructs a new caplin.chart.Series.
Parameters:
Name Type Description
seriesRequest Object A SeriesRequest object that defines the data request.
chartSeriesAdapter Object A Adapter object that transforms the series data into an acceptable format for the chart engine in use.
Implements:

Methods

addListener(listener)

Adds a listener for series events.
Parameters:
Name Type Description
listener module:caplin/chart/series/SeriesListener The listener that will receive series data.

addStudy(studyAlias, derivationParams, configOverridesopt, studyAdapteropt) → {module:caplin/chart/Study}

Adds a study to this series.
Parameters:
Name Type Attributes Description
studyAlias String The study alias, to be retrieved from the AliasRegistry.
derivationParams Object An object literal containing the options for the study.
configOverrides Object <optional>
Configuration passed from the descendant class upon instantiation.
studyAdapter module:caplin/chart/study/Adaptor <optional>
The adaptor to pass the study data through before passing it onto the Chart.
Throws:
if the study already exists in the series.
Type
module:caplin/core/Error
Returns:
The newly constructed study.
Type
module:caplin/chart/Study

addStudyListener(listener)

Adds a listener for study events.
Parameters:
Name Type Description
listener module:caplin/chart/series/StudyListener The listener that will receive study data.

dispose()

This method disposes the caplin.chart.Series object. It must be called to properly close subscriptions.

getData() → {Array.<Array.<Number>>}

Return a copy of the data received from the backend for this series or null if no data has been received or series.dispose() was called
Returns:
A copy of the data received from the backend
Type
Array.<Array.<Number>>

getSeriesRequest() → {module:caplin/chart/series/SeriesRequest}

Returns a SeriesRequest object that was passed to the constructor.
Returns:
A Request object.
Type
module:caplin/chart/series/SeriesRequest

getStudy(studyId) → {module:caplin/chart/Study}

Gets the study object.
Parameters:
Name Type Description
studyId String The study ID you want to retrieve.
Returns:
The study if found, otherwise undefined.
Type
module:caplin/chart/Study

removeStudy(studyId)

Removes a study from the series.
Parameters:
Name Type Description
studyId String The ID of the study to remove.
Throws:
if the study does not exist in the series.
Type
module:caplin/core/Error