Search code examples
javascriptdygraphs

Knowing the range of the visible X axis on dygraphs


I'm using dygraphs to print two curves on a single graph, and the user have to be able to resize it, at least in the X axis.

I succeed doing this, but now, I'd want to calculate some values (like the average value) in function of the visible curve. (I want a local average changing when the user move/zoom the graph).

How do I get the range of the X axis when the user zoomed/move the graph ?

Thanks !


Solution

  • Okay, I just looked at the dygraphs documentation in more details.

    There is a function to do this (see here) : xAxisRange().

    It returns an array of two Date.