From dfe5325490459240d7dff0d60ddebd6b00a0b464 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 7 Oct 2014 13:10:10 +0200 Subject: [PATCH] Scale the Y axis to the visible points --- src/root/common.tt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/root/common.tt b/src/root/common.tt index 1ba51da7..00e0a7aa 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -582,10 +582,18 @@ BLOCK createChart %] // now connect the two $("#[%id%]-chart").bind("plotselected", function (event, ranges) { + var ymax = 0; + d.forEach(function(x) { + if (x[0] < ranges.xaxis.from) return; + if (x[0] > ranges.xaxis.to) return; + ymax = Math.max(x[1], ymax); + }); + // do the zooming plot = $.plot($("#[%id%]-chart"), [d], $.extend(true, {}, options, { - xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to } + xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }, + yaxis: { min: 0, max: ymax * 1.1 } })); // don't fire event on the overview to prevent eternal loop