6
私はcubism.jsから始めるばかりですキューブメトリックのステップを変更するにはどうすればよいですか?
サンプルコードを削除する1つの計算済み(kpi1) - ランダム関数、1つのキューブ(kpi2)から2つのメトリックを表示できます。 1e4に変更するとすぐに1e4のコンテキストステップで完璧に動作します。計算された1つのランダムは、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>
これは、これが提供するパフォーマンス向上の要因を知っていますか? – Renaud