Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sychronize with updateOptions bug #956

Closed
shuvigoss opened this issue Apr 2, 2019 · 2 comments
Closed

sychronize with updateOptions bug #956

shuvigoss opened this issue Apr 2, 2019 · 2 comments

Comments

@shuvigoss
Copy link

shuvigoss commented Apr 2, 2019

jsfiddle demo

main code

 $(document).ready(function() {
 			
      var gs = [];
      var blockRedraw = false;
      for (var i = 1; i <= 4; i++) {
        gs.push(
          new Dygraph(
            document.getElementById("div" + i),
            getData(), {
              rollPeriod: 7,
              labels:['time', 'count1', 'count2'],
            }
          )
        );
      }
      var sync = Dygraph.synchronize(gs);
      
      function getData() {
        var current = new Date();
        var data = [];
        for (var i = 0; i < 100; i ++){
      		data.push([new Date(current.getTime() + i * 1000), Math.random() * 100, Math.random() * 100])
      	}
        return data;
    	}
      
      setInterval(() => {
        for (var i = 0; i <= 4; i++) {
        	var g = gs[i];
        	g.updateOptions({'file': getData()})
        }
      }, 3000);
      
      function update() {
        var zoom = document.getElementById('chk-zoom').checked;
        var selection = document.getElementById('chk-selection').checked;
        sync.detach();
        sync = Dygraph.synchronize(gs, {
          zoom: zoom,
          selection: selection
        });
      }
      $('#chk-zoom, #chk-selection').change(update);
    }
    
    
);

after run 1 min the charts is

image

@mirabilos
Copy link
Collaborator

As far as I can tell, the problem here is: when new data comes in, the synchroniser keeps the x axis range static instead of allowing dygraphs to recalculate that.

@mirabilos
Copy link
Collaborator

Fixed by not forcing the x axis range if the x axis is unzoomed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants