Change scale default in cubism.js

只谈情不闲聊 提交于 2019-12-01 22:46:16

问题


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:


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.



来源:https://stackoverflow.com/questions/10927848/change-scale-default-in-cubism-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!