Architectural Overview

Our charting library has been designed primarily to interface with the Caplin Platform via StreamLinkJS to retrieve chart series data and relay that data to the OEM licensed chart rendering engine Highstock or HighChart. In its default configuration, series data can be retrieved from available platform services - a Java Charting DataSource for historic data (daily, weekly or monthly periods) and Transformer’s Charting Service for periods of less than 1 day (fully configurable).

Charting architecture diagram

However, this pipeline can be customised at well-defined points to suit your particular environment’s setup.

Chart Service

The Chart Service provides the mechanism to get data from your back end. If you are getting series data from the platform, there’s nothing you need to configure, you can just create a chart and it will use this service.

If the provided platform services do not suit your requirements, you can implement a chart data service that retrieves data from your existing data sources (e.g. a webservice), or to translate retrieved series data into an alternate format for usage by your preferred rendering engine.

Swapping out the default implementation is simply a matter of creating a new class that implements the caplin.chart.service.ChartService interface and then defining an alias mapping in your application’s default aspect aliases.xml file:

<alias name="caplin.chart-service" class="novox.chart.service.MyChartService"/>

SeriesRequest

SeriesRequest contains properties that define the series that will be presented on the resultant chart. You create one and pass it to a Series that you are going to request.

Series

The primary purpose of the Series class is to offer provisions for client-side derivations (Studies) that can be run against existing chart data. Each Series instance maintains a cache of the retrieved point data in the form:

[
    [utc_timestamp, open, high, low, close(, volume)],

    ...
  ]

This cache is used as source data for any Study that is added to the chart without having to go to the server again. The chosen cache format matches that used by Highstock, making it convenient to render OHLC and candlestick series representations.

If an alternate chart engine is preferred over Highstock or a simpler series representation is required (e.g. a simple time value spline), the output of the Series instance can be modified by providing an adaptor during construction.

... = new caplin.chart.Series(oSeriesRequest, oListener, oChartSeriesAdaptor);

See the "Write a chart component" tutorial for further information on how a series can be retrieved and rendered.

Studies

A number of common studies have been added to the Caplin chart libraries to get you started:

Study Name Alias

Simple Moving Average

caplin.chart-sma-study

Exponential Moving Average

caplin.chart-ema-study

Bollinger Bands

caplin.chart-bollinger-bands-study

These studies are ready to be used in your own chart component, or if preferred, an alternative alias mapping can be defined to swap out the default implementation with your own.

See the "Add a study to my chart" tutorial for further information on how studies can be presented alongside series data or "Create my own study" tutorial for writing your own.

Class Architecture (UML)

20130920.charting sparse