Commits

Chris Leonello  committed e616a64

Added custom tick capability to category axis.
Fixed bug where tick marks weren't getting drawn on the axis.

  • Participants
  • Parent commits 460d5f9

Comments (0)

Files changed (2)

File jqplot.categoryAxisRenderer.js

 
     $.jqplot.CategoryAxisRenderer.prototype.createTicks = function() {
         // we're are operating on an axis here
-        log("in category axis renderer create ticks");
         var ticks = this._ticks;
+        var userTicks = this.ticks;
         var name = this.name;
         // databounds were set on axis initialization.
         var db = this._dataBounds;
         var tt, i;
 
         // if we already have ticks, use them.
-        if (ticks.length) {
-            var newticks = [];
+        if (userTicks.length) {
             this.min = 0.5;
-            this.max = ticks.length + 0.5;
+            this.max = userTicks.length + 0.5;
             var range = this.max - this.min;
-            this.numberTicks = 2*ticks.length + 1;
-            for (i=0; i<ticks.length; i++){
-                tt = this.min + i * range / (this.numberTicks-1);
+            this.numberTicks = 2*userTicks.length + 1;
+            for (i=0; i<userTicks.length; i++){
+                tt = this.min + 2 * i * range / (this.numberTicks-1);
                 // need a marker before and after the tick
                 var t = new this.tickRenderer(this.tickOptions);
                 t.showLabel = false;
                 t.showMark = true;
                 t.showGridline = true;
                 t.setTick(tt, this.name);
-                newticks.push(t);
+                this._ticks.push(t);
                 var t = new this.tickRenderer(this.tickOptions);
+                t.label = userTicks[i];
                 t.showLabel = true;
                 t.showMark = false;
                 t.showGridline = false;
-                t.
-
+                t.setTick(tt+0.5, this.name);
+                this._ticks.push(t);
             }
+            // now add the last tick at the end
+            var t = new this.tickRenderer(this.tickOptions);
+            t.showLabel = false;
+            t.showMark = true;
+            t.showGridline = true;
+            t.setTick(tt+1, this.name);
+            this._ticks.push(t);
         }
 
         // we don't have any ticks yet, let's make some!
             this.max = max;
             var track = 0;
             var maxVisibleTicks = parseInt(3+dim/45);
-            log(numcats);
-            log(maxVisibleTicks);
             var skip = parseInt(numcats/maxVisibleTicks);
-            log(skip);
 
 
             this.tickInterval = range / (this.numberTicks-1);
                 t.setTick(tt, this.name);
                 this._ticks.push(t);
             }
-            log(this);
         }
     };
     

File jquery.jqplot.js

         ctx.strokeStyle = '#cccccc';
         for (var name in axes) {
             var axis = axes[name];
-            var to = axis.tickOptions;
-            if (axis.show && to.mark) {
-                var ticks = axis._ticks;
-                var s = to.markSize;
-                var m = to.mark;
+            if (axis.show) {
                 var t = axis._ticks;
                 for (var i=0; i<t.length; i++) {
-                    if (t[i].show && t[i].showMark) {
+                    if (t[i].show && t[i].showMark && t[i].mark) {
+                        s = t[i].markSize;
+                        m = t[i].mark;
                         var pos = Math.round(axis.u2p(t[i].value)) + 0.5;
                         var b, e;
                         switch (name)     {