使用cubism.js的其他数据源 [英] Using Other Data Sources for cubism.js

查看:290
本文介绍了使用cubism.js的其他数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢立体派的用户体验,并希望在后端使用它。

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

我已经阅读过API文档和一些代码,大部分代码似乎被提取掉了。我如何开始使用其他数据源?

I've read the API doc's and some of the code, most of this seems to be extracted away. How could I begin to use other data sources exactly?

我有一个大约6k个单独的机器的数据存储,5分钟精确度约100左右的统计。

I have a data store of about 6k individual machines with 5 minute precision on around 100 or so stats.

我想查询具有该机器的特定标识符的某个网络应用程序,然后通过查询特定的mongo数据存储来呈现与立体主义相似的仪表板。

I would like to query some web app with a specific identifier for that machine and then render a dashboard similar to cubism via querying a specific mongo data store.

将webapp或查询写入mongo不是问题。

Writing the webapp or the querying to mongo isn't the issue.

这个问题更符合立体主义似乎要求查询每个数据点使用的任何数据存储的事实(例如,您有100个统计信息一个星期...昂贵)。

The issue is more in line with the fact that cubism seems to require querying whatever data store you use for each individual data point (say you have 100 stats across a window of a week...expensive).

有没有另一种方法,我可以利用这个工具来查看使用类似以下代码加载的数据?

Is there another way I could leverage this tool to look at data that gets loaded using something similar to the code below?

var data = [];
d3.json("/initial", function(json) { data.concat(json); });
d3.json("/update", function(json) { data.push(json); });


推荐答案

Cubism负责初始化和更新:初始请求是完整的可见窗口(开始停止,通常为1,440个数据点),而后续请求仅针对几个最近的指标(7个数据点)。

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).

查看 context.metric 了解如何实现新的数据源。最简单的实现是这样的:

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);
  });
});

您可以扩展它以根据需要更改/ dataURL,和步骤时间,以及要用于标识度量的任何其他值。例如,Cube和Graphite都使用指标表达式作为其他查询参数。

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.

这篇关于使用cubism.js的其他数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆