Question

With Dygraph I load csv data and show all records in format:

time,height,length
1393710088000,1.8,2,3
1393710089000,1.9,2.1
... 

When Dygraph finishes loading data OR when when I zoom in/out (selected range) is it possible to get start and end time? So I want to know selected time range.

Was it helpful?

Solution

You want to call the xAxisRange method, which returns a pair of timestamps for the visible range. If you want to get a notification when the user zooms, use a zoomCallback. zoomCallbacks get some parameters indicating the visible range.

g = new Dygraph(div, data, {
  zoomCallback: function(minX, maxX, yRanges) {
    console.log("Zoomed to [", minX, ", ", maxX, "]");
  }
});

g.ready(function() {
  console.log("Data loaded. x-axis range is:", g.xAxisRange());
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top