Skip to content

Commit b6863c2

Browse files
committed
g.line: reset y-axis on demand
1 parent d104c22 commit b6863c2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

g.line.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,18 @@
337337
return this;
338338
};
339339

340-
chart.zoomReset = function() {
340+
chart.zoomReset = function(reset_y_axis) {
341341
var from = [];
342342
var to = [];
343343

344344
for (i = 0, ii = valuesy.length; i < ii; i++) {
345345
from.push(0);
346346
to.push(valuesy[i].length-1);
347347
}
348-
chart.zoomInto(from, to);
348+
chart.zoomInto(from, to, reset_y_axis);
349349
};
350350

351-
chart.zoomInto = function(from, to) {
351+
chart.zoomInto = function(from, to, reset_y_axis) {
352352
var max_len = 0;
353353

354354
for (i = 0, ii = valuesy.length; i < ii; i++) {
@@ -374,6 +374,14 @@
374374
maxx = xdim.to;
375375
kx = (width - gutter * 2) / ((maxx - minx) || 1);
376376

377+
if (reset_y_axis) {
378+
ally = Array.prototype.concat.apply([], valuesy_shrinked),
379+
ydim = chartinst.snapEnds(Math.min.apply(Math, ally), Math.max.apply(Math, ally), max_len - 1),
380+
miny = ydim.from,
381+
maxy = ydim.to,
382+
ky = (height - gutter * 2) / ((maxy - miny) || 1);
383+
}
384+
377385
var res = createLines();
378386
lines = res.lines,
379387
symbols = res.symbols;

0 commit comments

Comments
 (0)