gpt4 book ai didi

cubism.js - 如何更改 Cube 指标的步骤?

转载 作者:行者123 更新时间:2023-12-04 15:24:51 25 4
gpt4 key购买 nike

我刚开始使用 cubism.js

剥离示例代码,我能够显示两个指标..一个计算的 (kpi1) - 随机函数,一个来自 Cube (kpi2)。只要我将其更改为 1e3,它就可以在 1e4 的上下文步骤中完美运行,计算出的一个 - 随机 - 在 1s 的分辨率下显示良好,而来自 Cube 的一个根本不显示。

这有效:

var context = cubism.context()
.serverDelay(0)
.clientDelay(0)
.step(1e4)
.size(960);

这不会:
var context = cubism.context()
.serverDelay(0)
.clientDelay(0)
.step(1e3)
.size(960);

我究竟做错了什么?
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta charset="utf-8">

<title>Dashboard</title>

</head><body><div id="body">


<div id="kpi1"></div>
<div id="kpi2"></div>


<script src="../d3.v2.js"></script>
<script src="../cubism.v1.js"></script>

<script>function random(name) {
var value = 0,
values = [],
i = 0,
last;
return context.metric(function(start, stop, step, callback) {
start = +start, stop = +stop;
if (isNaN(last)) last = start;
while (last < stop) {
last += step;
value = Math.max(-10, Math.min(10, value + .8 * Math.random() - .4 + .2 * Math.cos(i += .2)));
values.push(value);
}
callback(null, values = values.slice((start - stop) / step));
}, name);
}</script>

<script>

var context = cubism.context()
.serverDelay(0)
.clientDelay(0)
.step(1e4)
.size(960);

var foo = random("foo");
var cube = context.cube();

d3.select("#kpi1").call(function(div) {

div.selectAll(".horizon")
.data([foo])
.enter().append("div")
.attr("class", "horizon")
.call(context.horizon());

});

d3.select("#kpi2").call(function(div) {

div.selectAll(".horizon")
.data([cube.metric("median(cube_compute(ms))")])
.enter().append("div")
.attr("class", "horizon")
.call(context.horizon());

});

</script>

</body></html>

最佳答案

Cubism.js 支持任何步骤,但 Cube 后端系统仅支持以下五个步骤之一的存储指标聚合:

  1e4 or 10 seconds
6e4 or 1 minute
3e5 or 5 minutes
36e5 or 1 hour
864e5 or 1 day


如果您要使用介于或低于这些之间的步骤,Cube 将无法利用在较低和最低支持级别进行的预先计算,使用 pyramidal reducers .

关于cubism.js - 如何更改 Cube 指标的步骤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13052877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com