1. TEHEK
  2. jqplot

Commits

Chris Leonello  committed dba8383

Added tickInset option to axis renderers to position first and last ticks inset from edges of grid. Use instead of padding to get more consistent ticks and look. Allows better results with bars on linear/date axes.
Added drawBaseline, baselineWidth and baselineColor option to linear and date axes.

  • Participants
  • Parent commits 11428a4
  • Branches default

Comments (0)

Files changed (3)

File src/jqplot.linearAxisRenderer.js

View file
  • Ignore whitespace
 (function($) {
     // class: $.jqplot.LinearAxisRenderer
     // The default jqPlot axis renderer, creating a numeric axis.
-    // The renderer has no additional options beyond the <Axis> object.
     $.jqplot.LinearAxisRenderer = function() {
     };
     
         // prop: drawBaseline
         // True to draw the axis baseline.
         this.drawBaseline = true;
+        // prop: baselineWidth
+        // width of the baseline in pixels.
+        this.baselineWidth = null;
+        // prop: baselineColor
+        // CSS color spec for the baseline.
+        this.baselineColor = null;
         // prop: forceTickAt0
         // This will ensure that there is always a tick mark at 0.
         // If data range is strictly positive or negative,
         // This has know effect when any of the following options
         // are set:  autoscale, min, max, numberTicks or tickInterval.
         this.forceTickAt100 = false;
+        // prop: tickInset
+        // Controls the amount to inset the first and last ticks from 
+        // the edges of the grid, in multiples of the tick interval.
+        // 0 is no inset, 0.5 is one half a tick interval, 1 is a full
+        // tick interval, etc.
+        this.tickInset = 0;
         this._autoFormatString = '';
         this._overrideFormatString = false;
         $.extend(true, this, options);
     
     // called with scope of an axis
     $.jqplot.LinearAxisRenderer.prototype.reset = function() {
-        this.min = this._min;
-        this.max = this._max;
-        this.tickInterval = this._tickInterval;
-        this.numberTicks = this._numberTicks;
+        this.min = this._options.min;
+        this.max = this._options.max;
+        this.tickInterval = this._options.tickInterval;
+        this.numberTicks = this._options.numberTicks;
         this._autoFormatString = '';
         if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) {
             this.tickOptions.formatString = '';
                 t = null;
             }
         }
+
+        if (this.tickInset) {
+            this.min = this.min - this.tickInset * this.tickInterval;
+            this.max = this.max + this.tickInset * this.tickInterval;
+        }
+
         ticks = null;
     };
     

File src/plugins/jqplot.dateAxisRenderer.js

View file
  • Ignore whitespace
         // this.tickRenderer = $.jqplot.AxisTickRenderer;
         // this.labelRenderer = $.jqplot.AxisLabelRenderer;
         this.tickOptions.formatter = $.jqplot.DateTickFormatter;
+        // prop: tickInset
+        // Controls the amount to inset the first and last ticks from 
+        // the edges of the grid, in multiples of the tick interval.
+        // 0 is no inset, 0.5 is one half a tick interval, 1 is a full
+        // tick interval, etc.
+        this.tickInset = 0;
+        // prop: drawBaseline
+        // True to draw the axis baseline.
+        this.drawBaseline = true;
+        // prop: baselineWidth
+        // width of the baseline in pixels.
+        this.baselineWidth = null;
+        // prop: baselineColor
+        // CSS color spec for the baseline.
+        this.baselineColor = null;
         this.daTickInterval = null;
         this._daTickInterval = null;
 		
     
     // called with scope of an axis
     $.jqplot.DateAxisRenderer.prototype.reset = function() {
-        this.min = this._min;
-        this.max = this._max;
-        this.tickInterval = this._tickInterval;
-        this.numberTicks = this._numberTicks;
+        this.min = this._options.min;
+        this.max = this._options.max;
+        this.tickInterval = this._options.tickInterval;
+        this.numberTicks = this._options.numberTicks;
+        this._autoFormatString = '';
+        if (this._overrideFormatString && this.tickOptions && this.tickOptions.formatString) {
+            this.tickOptions.formatString = '';
+        }
         this.daTickInterval = this._daTickInterval;
         // this._ticks = this.__ticks;
     };
             }
         }
 
+        if (this.tickInset) {
+            this.min = this.min - this.tickInset * this.tickInterval;
+            this.max = this.max + this.tickInset * this.tickInterval;
+        }
 
         if (this._daTickInterval == null) {
             this._daTickInterval = this.daTickInterval;    
         }
+
+        ticks = null;
     };
    
 })(jQuery);

File src/plugins/jqplot.pyramidAxisRenderer.js

View file
  • Ignore whitespace
         // prop: drawBaseline
         // True to draw the axis baseline.
         this.drawBaseline = true;
+        // prop: baselineWidth
+        // width of the baseline in pixels.
         this.baselineWidth = null;
+        // prop: baselineColor
+        // CSS color spec for the baseline.
         this.baselineColor = null;
         this.tickSpacingFactor = 25;
         this._type = 'pyramid';