Skip to content

Commit

Permalink
Update auto-scaling to support the zero option.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dnschnur committed Dec 23, 2012
1 parent 126cb07 commit b6924a9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jquery.flot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b6924a9

Please sign in to comment.