Commits

cleonello  committed 624d8a5

Enhancement to category axes, more intuitive handling of series with missing data values. e.g. with data like:

[[[2006, 4], [2008, 9], [2009, 16]], [[2006, 3], [2007, 7], [2008, 6]]]

previously category axis would create four columns with no bars in the last column. Now axis will create four categories and properly bin each point.

Note, this only applies to numerical category axis labels. Series data values are, in general, always expected to be numerical. To use textual axis labels with 4 categories, should do:

[[[2006, 4], [2007, null], [2008, 9], [2009, 16]], [[2006, 3], [2007, 7], [2008, 6], [2009, null]]]

or even;

[[4, null, 9, 16], [3, 7, 6, null]]

and supply a tick array like:

ticks:['year 1', 'year 2', 'year 3', 'year 4']

This is also how numerical labels with skipped points should have been handled before this change.

  • Participants
  • Parent commits 19ffa0a

Comments (0)

Files changed (2)

+jqPlot change log
+
 0.6.5
-Fixed bug #4, series of unequal data length not rendering correctly.
+
+* Fixed bug #4, series of unequal data length not rendering correctly.
 This is a bugfix release only.
 
 0.6.4
-Fixed bug (issue #1 in tracker) where flat line data series (all x and/or y values are euqal)
+
+* Fixed bug (issue #1 in tracker) where flat line data series (all x and/or y values are euqal)
 or single value data series would crash.
 
 0.6.3
-Support for stacked line (a.k.a. area) and stacked bar (horizontal and vertical) charts.
-Refactored barRenderer to use default shape and shadow renderers.
-Added info (contacts & support information) page to web site.
+
+* Support for stacked line (a.k.a. area) and stacked bar (horizontal and vertical) charts.
+* Refactored barRenderer to use default shape and shadow renderers.
+* Added info (contacts & support information) page to web site.
 
 0.6.2
-This is a minor upgrade to docs and build only.  No functionality has changed.
-Ant build script generates entire site, examples, tests and distribution.
-Improvements to documentation.
+
+* This is a minor upgrade to docs and build only.  No functionality has changed.
+* Ant build script generates entire site, examples, tests and distribution.
+* Improvements to documentation.
 
 0.6.1
-New sprintf implementation from Ash Searle that implements %g.
-Fix to sprintf e/f formats.
-Created new format specifier, %p and %P to preserve significance.
-Modified p/P format to better display larger numbers.
-Fixed and simplified significant digits calculation for sprintf.
-Added option to have cursor tooltip follow the mouse or not.
-Added options to change size of highlight.
-Updates to handle dates like '6-May-09'.
-Mods to improve look of web site.
-Updates to documentation.
-Added license and copyright statement to source files.
+
+* New sprintf implementation from Ash Searle that implements %g.
+* Fix to sprintf e/f formats.
+* Created new format specifier, %p and %P to preserve significance.
+* Modified p/P format to better display larger numbers.
+* Fixed and simplified significant digits calculation for sprintf.
+* Added option to have cursor tooltip follow the mouse or not.
+* Added options to change size of highlight.
+* Updates to handle dates like '6-May-09'.
+* Mods to improve look of web site.
+* Updates to documentation.
+* Added license and copyright statement to source files.
 
 0.6.0
-Added rotated text support.  Uses native canvas text functionality in
+
+* Added rotated text support.  Uses native canvas text functionality in
 browsers that support it or draws text on canvas with Hershey font
-metrics for non-supporting browsers.
-Removed lots of lint in js code.
-Moved tick css from js code into css file.
-Fix to tick positioning css.  y axis ticks were positioned to wrong side of axis div.
-Refactored axis tick renderer instantiation into the axes renderers themselves.
+* metrics for non-supporting browsers.
+* Removed lots of lint in js code.
+* Moved tick css from js code into css file.
+* Fix to tick positioning css.  y axis ticks were positioned to wrong side of axis div.
+* Refactored axis tick renderer instantiation into the axes renderers themselves.
 
 
 For chnages prior to 0.6.0 release, please see change log at http://bitbucket.org/cleonello/jqplot/changesets/

File src/plugins/jqplot.categoryAxisRenderer.js

                         numcats += 1;      
                         labels.push(val);
                     }
-                    // for category axis, force the values into category bins.
+                }
+            }
+            
+            labels.sort(function (a, b) { return a - b;});
+            
+            // now bin the data values to the right lables.
+            for (var i=0; i<this._series.length; i++) {
+                var s = this._series[i];
+                for (var j=0; j<s.data.length; j++) {
                     if (this.name == 'xaxis' || this.name == 'x2axis') {
-                        s.data[j][0] = j+1;
+                        val = s.data[j][0];
                     }
                     else {
-                        s.data[j][1] = j+1;
+                        val = s.data[j][1];
+                    }
+                    // for category axis, force the values into category bins.
+                    // we should have the value in the label array now.
+                    var idx = $.inArray(val, labels)+1;
+                    if (this.name == 'xaxis' || this.name == 'x2axis') {
+                        s.data[j][0] = idx;
+                    }
+                    else {
+                        s.data[j][1] = idx;
                     }
                 }
             }