Using Other Data Sources for cubism.js

核能气质少年 提交于 2019-11-27 19:25:55

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!