From b6924a96d934e9f70ba746240dd8d7cc863d8f84 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 23 Dec 2012 09:44:18 -0500 Subject: [PATCH] Update auto-scaling to support the zero option. Added a format option 'autoscale' that controls whether the given point is considered when determining an automatic scale. The lines & bars 'zero' option controls whether autoscale is set on the dummy point that is inserted to create the series lower-bound. --- jquery.flot.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 13f8db3..c423256 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -556,8 +556,9 @@ Licensed under the MIT license. format.push({ x: true, number: true, required: true }); format.push({ y: true, number: true, required: true }); - if (s.bars.show || (s.lines.show && s.lines.fill)) { - format.push({ y: true, number: true, required: false, defaultValue: 0 }); + if (s.bars.show || (s.lines.show && (s.lines.fill || s.lines.zero))) { + var autoscale = !!((s.bars.show && s.bars.zero) || (s.lines.show && s.lines.zero)); + format.push({ y: true, number: true, required: false, defaultValue: 0, autoscale: autoscale }); if (s.bars.horizontal) { delete format[format.length - 1].y; format[format.length - 1].x = true; @@ -671,7 +672,7 @@ Licensed under the MIT license. for (m = 0; m < ps; ++m) { val = points[j + m]; f = format[m]; - if (!f || val == fakeInfinity || val == -fakeInfinity) + if (!f || f.autoscale === false || val == fakeInfinity || val == -fakeInfinity) continue; if (f.x) {