X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=gallery%2Flink-interaction.js;h=f0bfecf7759c2fbbff22f07ecdb9203c4183d4ce;hb=1357d81ebb85b87b69a9de0eb01c5d8cb43774d2;hp=aa7f738a65d491064d7f23f7c412147f6ad9e0f4;hpb=fa5a85c4dd16f4d9607d784b3cd0ca8fb9878c76;p=dygraphs.git diff --git a/gallery/link-interaction.js b/gallery/link-interaction.js index aa7f738..f0bfecf 100644 --- a/gallery/link-interaction.js +++ b/gallery/link-interaction.js @@ -4,17 +4,17 @@ Gallery.register( { name: 'Link Interaction', setup: function(parent) { - parent.innerHTML = - "
" + - "Zoom:" + - "hour " + - "day " + - "week " + - "month " + - "full " + - "Pan: " + - "left " + - "right "; + parent.innerHTML = [ + "", + "Zoom:", + "hour ", + "day ", + "week ", + "month ", + "full ", + "Pan: ", + "left ", + "right "].join("\n"); }, run: function() { var r = [ ]; @@ -60,23 +60,31 @@ Gallery.register( setTimeout(approach_range, 50); } - window.zoom = function(res) { + var zoom = function(res) { var w = g.xAxisRange(); desired_range = [ w[0], w[0] + res * 1000 ]; animate(); } - window.reset= function() { + var reset = function() { desired_range = orig_range; animate(); } - window.pan = function(dir) { + var pan = function(dir) { var w = g.xAxisRange(); var scale = w[1] - w[0]; var amount = scale * 0.25 * dir; desired_range = [ w[0] + amount, w[1] + amount ]; animate(); } + + document.getElementById('hour').onclick = function() { zoom(3600); }; + document.getElementById('day').onclick = function() { zoom(86400); }; + document.getElementById('week').onclick = function() { zoom(604800); }; + document.getElementById('month').onclick = function() { zoom(30 * 86400); }; + document.getElementById('full').onclick = function() { reset(); }; + document.getElementById('left').onclick = function() { pan(-1); }; + document.getElementById('right').onclick = function() { pan(+1); }; } }); \ No newline at end of file