X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=gallery%2Flink-interaction.js;h=e1d6faaa0b60a3c1915db876e3a989be8808f6c5;hb=579d9049209ae03829cd8bf6a168eab66a19380b;hp=aa7f738a65d491064d7f23f7c412147f6ad9e0f4;hpb=e2a5e39886ea3bec49f24f937bb2625899710328;p=dygraphs.git diff --git a/gallery/link-interaction.js b/gallery/link-interaction.js index aa7f738..e1d6faa 100644 --- a/gallery/link-interaction.js +++ b/gallery/link-interaction.js @@ -1,20 +1,19 @@ -// Use this as a template for new Gallery entries. Gallery.register( 'link-interaction', { 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 +59,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 + });