flot/flot — pull request #911 by dnschnur (2012-12-23 17:17:28+00:00)
Title: Added a series 'zero' option to control automatic scaling.

Filled plot types, like areas and bars, convey information through size. They traditionally start from zero, because starting from a different value changes the amount of filled space, thereby distorting the value of the data. In some contexts, however, the fill is used in more of a decorative sense, and in this case many users (#316, #529, #856, and others) expect to see exactly the same behavior as an unfilled line plot.

Purists would argue that this is simply wrong, and the only correct solution is to use a different plot type, but I don't believe that Flot should pass such judgement. Since neither behavior is 'correct', I propose adding an option to pass the choice on to users.

The option is called *zero*, and applies to lines and bars series. It defaults to the current behavior, where zero is true for bars and filled lines, otherwise false. I then gave the datapoint format a new option called *autoscale*, which controls whether it is considered when auto-calculating the axis min/max. The *zero* option controls the value of *autoscale* for the dummy-point used to represent the bottom of a bar or area.

This pull request is a draft, for review and comment. I'll make updates to the API and changelog once the implementation is finalized. Some unresolved questions/issues are:

- Currently the option is specific to lines and bars; should it be made global? This would be more consistent, but on the other hand it's simply not applicable to pie charts and many other plot types.

- On lines, the option currently applies even when 'fill' is false. This has no negative effects, but might again be inconsistent/confusing.

- The categories plugin duplicates some of the axis auto-scale code. The plugin enhancements that we're planning to do for 0.9 would take care of this, but for now I think I'll have to replicate my changes to the duplicate code in categories.