From 126cb072fc081049f8c1be8a66b79ebaed6a72aa Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 23 Dec 2012 08:54:34 -0500 Subject: [PATCH] Added a 'zero' option for lines and bars. Area and bar plots normally use a minimum of zero, since their purpose is to show size, and using an auto-scaled minimum distorts the plot's meaning. But this behavior is undesirable in cases where the plot type is used in more of a decorative sense. The zero option provides a way to control this behavior. It defauls to true for bars and filled lines. --- jquery.flot.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jquery.flot.js b/jquery.flot.js index 605fce8..13f8db3 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -106,6 +106,8 @@ Licensed under the MIT license. fill: false, fillColor: null, steps: false + // Omit 'zero', so we can later default its value to + // match that of the 'fill' option. }, bars: { show: false, @@ -114,7 +116,8 @@ Licensed under the MIT license. fill: true, fillColor: null, align: "left", // "left", "right", or "center" - horizontal: false + horizontal: false, + zero: true }, shadowSize: 3, highlightColor: null @@ -498,6 +501,13 @@ Licensed under the MIT license. s.lines.show = true; } + // If nothing was provided for lines.zero, default it to match + // lines.fill, since areas by default should extend to zero. + + if (s.lines.show && s.lines.zero == null) { + s.lines.zero = !!s.lines.fill; + } + // setup axes s.xaxis = getOrCreateAxis(xaxes, axisNumber(s, "x")); s.yaxis = getOrCreateAxis(yaxes, axisNumber(s, "y"));