Reputation: 315
How to get center point/data in dygraphs in actual zoom size?
It's easy when x axis is integer, but how to do this when x axis is Date type(Unix timestamps)?
Upvotes: 0
Views: 136
Reputation: 16905
The docs for xAxisRange
say:
Returns the currently-visible x-range. This can be affected by zooming, panning or a call to updateOptions. Returns a two-element array: [left, right]. If the Dygraph has dates on the x-axis, these will be millis since epoch.
So you should be able to do something like:
var range = g.xAxisRange();
var midPointMs = 0.5 * (range[0] + range[1]);
var midPointDate = new Date(midPointMs);
Upvotes: 1