Search code examples
javascriptdygraphs

Rescale dygraph data on x-axis zoom


I am showing a cumulative time series using the dygraphs library in javascript.

I would like the y-axis values to rescale to the new origin of the graph so it always shows as starting at zero (basically just add an offset to the whole series).

Is that possible ?


Solution

  • You want the "rebase" extra, check out this demo.

    <script src="extras/rebase.js"></script>
    

    and:

    new Dygraph(
      document.getElementById('div'),
      data,
      { plugins: [rebase] }
    )