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.
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
Expression data loader