Dynamic scaling breaks dynamic plots

psema4 avatarpsema4 created an issue

I'm trying to create a dynamic plot that manages it's own scaling on the Y axis; ideally I'd like to watch the dynamic data coming in to track the highest/lowest values seen and use those values to determine the scale.

Here's a jsfiddle that demonstrates a) how I'm trying to achieve my goal and b) the result. Rendering is controlled by the boolean withCustomResetAxes:

When set to false, replot will be called with resetAxes:true (auto-scaling)

When set to true, replot will be called with min/max settings for both xaxis & yaxis

Regardless of the value that withCustomResetAxes is set to, every 4 seconds a new set of data-points will be generated for the plot. These generated values are only displayed when using auto-scaling. When using custom scaling, the scales adjust as expected but the new data-points are ignored.

Comments (2)

  1. psema4

    I've updated the fiddle to add a pause control which may help make the situation a bit more clear.

    There's also a new flag isScaling - when true I manually try to set the axes minimums & maximums. When false, resetAxes is set to false to "lock" the axes.

    Additionally, I've added a second call to replot (with alternate data) when dynamic scaling is taking place - this replot happens with resetAxes set to false; it happily shows the data.

    It looks like when trying to set resetAxes:['xaxis', 'yaxis'] the points plotted are taken from the original initialization data:

    1. Load the fiddle in Chromium, initial data will be dumped to the devtools console
    2. Check the pause checkbox, the plots' current series[0].data will be dumped
    3. Unpause, wait for the next update (every 4s) which will dump the random data newly loaded into the plot
    4. Pause again. Note that even though the random data was loaded into the plots' series[0].data, only the original initialization data was shown.
  2. psema4

    Looks like the trick (which works but feels like a hack) is to call replot() twice in quick succession - the first to set the appropriate scale, then change the data and call replot() again to show the updated data.

    I'll leave the fiddle link from the previous comment as the base. The workaround in this comment can be found here.

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.