Commits

Anonymous committed 568aa0b

Fixed bug where axis showTicks, showTickMarks options not working as expected and causing improperly rendered axes. Now showTicks overrides showTickMarks and both of those will be overridden by any option specified on the ticks themselves.

Comments (0)

Files changed (3)

src/jqplot.core.js

         // renderer specific options.  See <$.jqplot.LinearAxisRenderer> for options.
         this.rendererOptions = {};
         // prop: showTicks
-        // wether to show the ticks (both marks and labels) or not.
+        // Wether to show the ticks (both marks and labels) or not.
+        // Will not override showMark and showLabel options if specified on the ticks themselves.
         this.showTicks = true;
         // prop: showTickMarks
-        // wether to show the tick marks (line crossing grid) or not.
+        // Wether to show the tick marks (line crossing grid) or not.
+        // Overridden by showTicks and showMark option of tick itself.
         this.showTickMarks = true;
         // prop: showMinorTicks
         // Wether or not to show minor ticks.  This is renderer dependent.
         this.renderer = new this.renderer();
         // set the axis name
         this.tickOptions.axis = this.name;
+        // if showMark or showLabel tick options not specified, use value of axis option.
+        // showTicks overrides showTickMarks.
+        if (this.tickOptions.showMark == null) {
+            this.tickOptions.showMark = this.showTicks;
+        }
+        if (this.tickOptions.showMark == null) {
+            this.tickOptions.showMark = this.showTickMarks;
+        }
+        if (this.tickOptions.showLabel == null) {
+            this.tickOptions.showLabel = this.showTicks;
+        }
+        
         if (this.label == null || this.label == '') {
             this.showLabel = false;
         }
             return {offsets:go, gridPos:gridPos, dataPos:dataPos};
         }
         
-        // function getNeighborPoint(plot, x, y) {
-        //     var ret = null;
-        //     var s, i, d0, d, j, r, k;
-        //     var threshold, t;
-        //     for (var k=plot.seriesStack.length-1; k>-1; k--) {
-        //         i = plot.seriesStack[k];
-        //         s = plot.series[i];
-        //         r = s.renderer;
-        //         if (s.show) {
-        //             t = s.markerRenderer.size/2+s.neighborThreshold;
-        //             threshold = (t > 0) ? t : 0;
-        //             for (var j=0; j<s.gridData.length; j++) {
-        //                 p = s.gridData[j];
-        //                 // neighbor looks different to OHLC chart.
-        //                 if (r.constructor == $.jqplot.OHLCRenderer) {
-        //                     if (r.candleStick) {
-        //                         var yp = s._yaxis.series_u2p;
-        //                         if (x >= p[0]-r._bodyWidth/2 && x <= p[0]+r._bodyWidth/2 && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) {
-        //                             return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-        //                         }
-        //                     }
-        //                     // if an open hi low close chart
-        //                     else if (!r.hlc){
-        //                         var yp = s._yaxis.series_u2p;
-        //                         if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][2]) && y <= yp(s.data[j][3])) {
-        //                             return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-        //                         }
-        //                     }
-        //                     // a hi low close chart
-        //                     else {
-        //                         var yp = s._yaxis.series_u2p;
-        //                         if (x >= p[0]-r._tickLength && x <= p[0]+r._tickLength && y >= yp(s.data[j][1]) && y <= yp(s.data[j][2])) {
-        //                             return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-        //                         }
-        //                     }
-        //                     
-        //                 }
-        //                 else {
-        //                     d = Math.sqrt( (x-p[0]) * (x-p[0]) + (y-p[1]) * (y-p[1]) );
-        //                     if (d <= threshold && (d <= d0 || d0 == null)) {
-        //                        d0 = d;
-        //                        return {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]};
-        //                     }
-        //                 }
-        //             } 
-        //         }
-        //     }
-        //     return ret;
-        // }
-        
         
         // function to check if event location is over a area area
         function checkIntersection(gridpos, plot) {

src/jqplot.linearAxisRenderer.js

                 elem.appendTo(this._elem);
             }
     
-            if (this.showTicks) {
-                var t = this._ticks;
-                for (var i=0; i<t.length; i++) {
-                    var tick = t[i];
-                    if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
-                        var elem = tick.draw(ctx);
-                        elem.appendTo(this._elem);
-                    }
+            var t = this._ticks;
+            for (var i=0; i<t.length; i++) {
+                var tick = t[i];
+                if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
+                    var elem = tick.draw(ctx);
+                    elem.appendTo(this._elem);
                 }
             }
         }
         var w = 0;
         var h = 0;
         var lshow = (this._label == null) ? false : this._label.show;
-        if (this.show && this.showTicks) {
+        if (this.show) {
             var t = this._ticks;
             for (var i=0; i<t.length; i++) {
                 var tick = t[i];
                 if (ut.constructor == Array) {
                     t.value = ut[0];
                     t.label = ut[1];
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
                     t.setTick(ut[0], this.name);
                     this._ticks.push(t);
                 }
                 
                 else {
                     t.value = ut;
-                    if (!this.showTicks) {
-                        t.showLabel = false;
-                        t.showMark = false;
-                    }
-                    else if (!this.showTickMarks) {
-                        t.showMark = false;
-                    }
                     t.setTick(ut, this.name);
                     this._ticks.push(t);
                 }
                 tt = this.min + i * this.tickInterval;
                 var t = new this.tickRenderer(this.tickOptions);
                 // var t = new $.jqplot.AxisTickRenderer(this.tickOptions);
-                if (!this.showTicks) {
-                    t.showLabel = false;
-                    t.showMark = false;
-                }
-                else if (!this.showTickMarks) {
-                    t.showMark = false;
-                }
+
                 t.setTick(tt, this.name);
                 this._ticks.push(t);
             }

src/plugins/jqplot.categoryAxisRenderer.js

                 // need a marker before and after the tick
                 var t = new this.tickRenderer(this.tickOptions);
                 t.showLabel = false;
-                t.showMark = true;
+                // t.showMark = true;
                 t.setTick(tt, this.name);
                 this._ticks.push(t);
                 var t = new this.tickRenderer(this.tickOptions);
                 t.label = userTicks[i];
-                t.showLabel = true;
+                // t.showLabel = true;
                 t.showMark = false;
                 t.showGridline = false;
                 t.setTick(tt+0.5, this.name);
             // now add the last tick at the end
             var t = new this.tickRenderer(this.tickOptions);
             t.showLabel = false;
-            t.showMark = true;
+            // t.showMark = true;
             t.setTick(tt+1, this.name);
             this._ticks.push(t);
         }
                     t.showMark = false;
                     t.showGridline = false;
                 }
-                if (!this.showTicks) {
-                    t.showLabel = false;
-                    t.showMark = false;
-                }
-                else if (!this.showTickMarks) {
-                    t.showMark = false;
-                }
                 t.setTick(tt, this.name);
                 this._ticks.push(t);
             }
                 elem.appendTo(this._elem);
             }
     
-            if (this.showTicks) {
-                var t = this._ticks;
-                for (var i=0; i<t.length; i++) {
-                    var tick = t[i];
-                    if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
-                        var elem = tick.draw(ctx);
-                        elem.appendTo(this._elem);
-                    }
+            var t = this._ticks;
+            for (var i=0; i<t.length; i++) {
+                var tick = t[i];
+                if (tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) {
+                    var elem = tick.draw(ctx);
+                    elem.appendTo(this._elem);
                 }
             }
         
         var w = 0;
         var h = 0;
         var lshow = (this._label == null) ? false : this._label.show;
-        if (this.show && this.showTicks) {
+        if (this.show) {
             var t = this._ticks;
             for (var i=0; i<t.length; i++) {
                 var tick = t[i];