dygraphs icon indicating copy to clipboard operation
dygraphs copied to clipboard

sychronize with updateOptions bug

Open shuvigoss opened this issue 5 years ago • 0 comments

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

shuvigoss avatar Apr 02 '19 09:04 shuvigoss