问题
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