load data for the specified resolution
data needs to be structured as follows: [ [timestamp:integer,close:float,open:float,high:float,low:float,volume:float]* ] timestamps are represented as unix timestamps (in milliseconds) if volume is not available, the implementation should provide 0 values if only one value is available, provide the same values for close,open,high,low
The retrieved data should NOT be cached/stored; this is handled automatically by the BG.charts.TSData object.
To update the initially provided historical data the delegate can forward updates in the form of
BG.charts.IDataLoader.TPush objects to the callback provided as the second argument.
The provided objects can either contain individual prices (only a quote
value) or whole OHLCV values.
The most recent data set can be updated by providing an object with a timestamp in the same candle range, containing a OHLCV values.
Older data set can not be modified anymore; timestamps before the beginning of the current candle are therefore not accepted.
The logic for ticks is similar: Ticks smaller than the previously provided value are not accepted.
Each object has to at least specify a timestamp and either a price or a set of OHLCV values.
Tick numbers are optional except for tick resolution, where they are mandatory.
NOTE: when not providing ticks, the implementation will use an automatically assigned number that increases by one for every provided object. It does not distinguish between UPDATE/REPLACE/APPEND, so it is encouraged to provide ticks manually.
The pushCb is also used to forward state information to the library.
Boolean arguments signify if the push is currently busy catching up / synchronizing;
true
: push updates are working on catching up
false
or null
: streaming push updates are in sync (again), no error
Alternatively an instance of BG.charts.Error or BG.charts.RecoverableError can be provided.
If a RecoverableError is provided, the library might call the resumePush
method at a later time to trigger recovery.
NOTE: Errors can be cleared by the loader, by providing false
or null
.
The invalidateCb can be called to invalidate the proided data and force a reload of any chart currently displaying it.
the optional context object can contain arbitrary information about the environment in the key "env". it can be provided when constructing the Controller/ChartSet for example, when generating charts on the server, this object could be used to hold authentication information about the request (e.g. userId, permissions), that are required when loading data. values stored unter "env" must not be modified. additionally, there are also values stored under the key "pass". These get automatically reset every time data is loaded, and can be modified by loaders. For example, these values could be used to keep track of which permissions where actually used to construct a specific chart.
map options and current defaults to a unique timeseries identifier
timeseries identifiers must be distinct. This means that "options" that result in different data must also generate a different unique identifier
when the value of an option provided via the metadata object changes, this method is called to generate the new identifier. the timeseries is then automatically replaced, and a new loader is created for the new identifier.
Example: Assume a loader called "Instrument" has an option to switch between "bid" and "ask" values. The initial identifier is "Instrument(APPL,bid)". When the option "quoteType" is set to "ask" this implementation should return "Instrument(AAPL,ask)"
Additionally, this method is use to finalize any default values, to make sure that even if the default value changes in the future, a serialized chart will ALWAYS look the same.
Example: Assume the loader mentioned in the previous example is created via the identifier "Instrument(AAPL)". As the quote type is not specified, the implementation automatically uses "bid". When this method is called, the implementation should return "Instrument(AAPL,bid)"
Optional
options: { [key: string]: string | number }identifier matching the specified options
Recover previously suspended push updates
This method can be called by the library if the loader previously called the pushCb provided to load
with an instance of BG.charts.RecoverableError
Should return true if a recovery was attemped, false otherwise
NOTE: if true is returned, recovery can still have failed immediately; in this case the loader could even signal another error before returning. But if false is returned, it must not signal a change in push state
Static
Optional
setStatic
Optional
setURLs
interface for a custom time series data loader.
Classes implementing this interface need to be registered via
BG.charts.setLoader