Dygraph: zoom into last 1000

纵然是瞬间 提交于 2020-01-07 02:24:11

问题


I'm trying to dygraph to zoom into the last 1000 (or something) points of data. While running simulations, the graphs get more filled, and at some point its just too much.

I've found on the website that using dateWindow: [min, max] works, but the problem is that I cannot retrieve the max value from the CSV file (it is probably stored somewhere, but i do not know where):

document.getElementById("graph_prodnon"),
    "/population_dat/production_scaling.csv", // path to CSV file
    {
      title: 'Scaling NON',
      xlabel: 'Simulation time',
      ylabel: '',
      dateWindow:, [???-1000,????]

Does anybody know what variable should be filled in on the question mark? ;)


回答1:


If g is the Dygraph object, then you can access the last x-value using the getValue method:

var lastX = g.getValue(g.numRows() - 1, 0);  // row, column

Note that the data will only be available after the XHR for your CSV file succeeds, so you may want to throw this in a g.ready() callback.



来源:https://stackoverflow.com/questions/31341760/dygraph-zoom-into-last-1000

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