1 /*global Gallery,Dygraph,data */
2 /*jshint loopfunc:true */
7 name
: 'Synchronization',
8 title
: 'Multiple graphs in sync',
9 setup
: function(parent
) {
12 ' .chart { width: 500px; height: 300px; }',
13 ' .chart-container { overflow: hidden; }',
14 ' #div1 { float: left; }',
15 ' #div2 { float: left; }',
16 ' #div3 { float: left; clear: left; }',
17 ' #div4 { float: left; }',
19 '<p>Zooming and panning on any of the charts will zoom and pan all the',
20 'others. Selecting points on one will select points on the others.</p>',
21 '<p>To use this, source <a href="https://github.com/danvk/dygraphs/blob/master/extras/synchronizer.js"><code>extras/synchronizer.js</code></a> on your page.',
22 'See the comments in that file for usage.</p>',
23 '<div class="chart-container">',
24 ' <div id="div1" class="chart"></div>',
25 ' <div id="div2" class="chart"></div>',
26 ' <div id="div3" class="chart"></div>',
27 ' <div id="div4" class="chart"></div>',
31 ' <input type=checkbox id="chk-zoom" checked><label for="chk-zoom"> Zoom</label>',
32 ' <input type=checkbox id="chk-selection" checked><label for="chk-selection"> Selection</label>',
38 var blockRedraw
= false;
39 for (var i
= 1; i
<= 4; i
++) {
42 document
.getElementById("div" + i
),
50 var sync
= Dygraph
.synchronize(gs
);
53 var zoom
= document
.getElementById('chk-zoom').checked
;
54 var selection
= document
.getElementById('chk-selection').checked
;
56 sync
= Dygraph
.synchronize(gs
, {
61 $('#chk-zoom, #chk-selection').change(update
);