Caplin Trader 5.1.0

Class: module:ct-chart/Series

module:ct-chart/Series(seriesRequest, chartSeriesAdapter)

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 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:ct-chart/Series(seriesRequest, chartSeriesAdapter)

Constructs a new 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:ct-chart/series/SeriesListener

The listener that will receive series data.

addStudy(studyAlias, derivationParams, configOverridesopt, studyAdapteropt) → {module:ct-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:ct-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:ct-core/Error
Returns:

The newly constructed study.

Type
module:ct-chart/Study

addStudyListener(listener)

Adds a listener for study events.

Parameters:
Name Type Description
listener module:ct-chart/series/StudyListener

The listener that will receive study data.

dispose()

This method disposes the 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:ct-chart/series/SeriesRequest}

Returns a SeriesRequest object that was passed to the constructor.

Returns:

A Request object.

Type
module:ct-chart/series/SeriesRequest

getStudy(studyId) → {module:ct-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:ct-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:ct-core/Error