Change scale default in cubism.js

2019-02-27 12:56发布

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]).range([0,96]))

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

Many thanks,

Michael

1条回答
闹够了就滚
2楼-- · 2019-02-27 13:40

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

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

查看更多
登录 后发表回答