Question

This may be a bit obscure, but I'm developing a viewer app that chunks up a large dataset and then allows it to be viewed using dygraphs, where new data chunks are loaded on either side as you pan through it.

The trouble is, when you update the graph as it's being panned, it seems to lose its y-axis range. You can see this on the dynamic update demo on the official site:

http://dygraphs.com/tests/dynamic-update.html

If you shift-drag to pan, you'll see the plot (and y-axis) disappear as new data is added. To prove the error, run this in the Chrome console, and you'll see [ NaN, NaN ] output as the plot disappears:

window.setInterval(function() { console.log(window.g.yAxisRange()); }, 200);

Now, there would be various workarounds involving timers, but ultimately this seems like a bug in the dygraphs library itself. Is there an easy way to patch in a fix? Alternatively, if there's a way to tell when a pan is in progress, I could simply avoid altering the data set until I know that the user is not in the middle of a pan—but there's no official callback or flag for this, and it looks like the internal isPanning flag has been carefully hidden on a local-scope context object, where it's safe from my prying eyes.

What's the quickest way to patch or monkey-patch this problem?

Was it helpful?

Solution

This was a bug in dygraphs which is now fixed. If you download the latest version (either from github or dygraphs.com), you'll no longer have this issue.

If you want the gory details, here's the fix: https://github.com/danvk/dygraphs/commit/97583b90be3e80c95654d010db8a4b3f8813bb7a

The panning code was storing data in objects that didn't belong to it, and when updateOptions() got called, those objects were destroyed and chaos ensued.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top