如何在实际缩放尺寸下获取dygraphs中的中心点/数据?
当x轴是整数时很容易,但是当x轴是Date类型(Unix时间戳)时怎么办?
最佳答案
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.
所以你应该能够做类似的事情:
var range = g.xAxisRange();
var midPointMs = 0.5 * (range[0] + range[1]);
var midPointDate = new Date(midPointMs);
关于javascript - Dygraph.js - 当 x 为日期时获取图表的中心点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36452543/