更改cubism.js中的缩放默认值 [英] Change scale default in cubism.js

查看:179
本文介绍了更改cubism.js中的缩放默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cubism.js来绘制来自JSON对象的一些静态数据。我们希望能够显示一年的数据,每天一点。我的解决方案部分工作,但我想要能够设置独立于今天的日期,即我想要的数据从昨天到去年的相应日期的比例。我试过下面的没有成功:

I'm using cubism.js to graph some static data from a JSON object. We want to be able to display a years worth of data, with a point for each day. I have the solution working partially but I'd like to be able to set the scale independent of today's date, i.e. I'd like to graph data from yesterday to the corresponding day last year. I've tried the following without success:

context.scale(d3.time.scale()。domain([start,end] 96]))

context.scale(d3.time.scale().domain([start, end]).range([0,96]))

其中start和end来自JSON对象。
是否可以将立体声音阶设置为这样的行为?

where start and end come from the JSON object. Is it possible to set the cubism scale to behave in this way ?

非常感谢,

Michael

推荐答案

股票演示 intro talk 几乎正是这样,使用 serverDelay 来移动显示的时间窗口,然后停止以防止更新:

The stocks demo from the intro talk does almost exactly this, using serverDelay to shift the displayed time window and stop to prevent updates:

var context = cubism.context()
    .serverDelay(new Date(2012, 4, 2) - Date.now())
    .step(864e5)
    .size(1280)
    .stop();

我认为API可以更方便地处理这种特定情况,但Cubism主要用于实时显示。

I think the API could be made more convenient to handle this specific case, but Cubism is designed primarily for real-time displays.

这篇关于更改cubism.js中的缩放默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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