Using Other Data Sources for cubism.js

后端 未结 1 1085
既然无缘
既然无缘 2020-12-05 05:05

I like the user experience of cubism, and would like to use this on top of a backend we have.

I\'ve read the API doc\'s and some of the code, most of this seems to

相关标签:
1条回答
  • 2020-12-05 05:58

    Cubism takes care of initialization and update for you: the initial request is the full visible window (start to stop, typically 1,440 data points), while subsequent requests are only for a few most recent metrics (7 data points).

    Take a look at context.metric for how to implement a new data source. The simplest possible implementation is like this:

    var foo = context.metric(function(start, stop, step, callback) {
      d3.json("/data", function(data) {
        if (!data) return callback(new Error("unable to load data"));
        callback(null, data);
      });
    });
    

    You would extend this to change the "/data" URL as appropriate, passing in the start, stop and step times, and whatever else you want to use to identify a metric. For example, both Cube and Graphite use a metric expression as an additional query parameter.

    0 讨论(0)
提交回复
热议问题