| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| (function($) { |
| |
| |
| $.jqplot.LinearAxisRenderer = function() { |
| }; |
| |
| |
| $.jqplot.LinearAxisRenderer.prototype.init = function(options){ |
| |
| |
| |
| |
| |
| |
| |
| |
| this.breakPoints = null; |
| |
| |
| this.breakTickLabel = "≈"; |
| |
| |
| this.drawBaseline = true; |
| |
| |
| this.baselineWidth = null; |
| |
| |
| this.baselineColor = null; |
| |
| |
| |
| |
| |
| |
| |
| |
| this.forceTickAt0 = false; |
| |
| |
| |
| |
| |
| |
| |
| |
| this.forceTickAt100 = false; |
| |
| |
| |
| |
| |
| this.tickInset = 0; |
| |
| |
| |
| |
| this.minorTicks = 0; |
| |
| |
| |
| this.alignTicks = false; |
| this._autoFormatString = ''; |
| this._overrideFormatString = false; |
| this._scalefact = 1.0; |
| $.extend(true, this, options); |
| if (this.breakPoints) { |
| if (!$.isArray(this.breakPoints)) { |
| this.breakPoints = null; |
| } |
| else if (this.breakPoints.length < 2 || this.breakPoints[1] <= this.breakPoints[0]) { |
| this.breakPoints = null; |
| } |
| } |
| if (this.numberTicks != null && this.numberTicks < 2) { |
| this.numberTicks = 2; |
| } |
| this.resetDataBounds(); |
| }; |
| |
| |
| $.jqplot.LinearAxisRenderer.prototype.draw = function(ctx, plot) { |
| if (this.show) { |
| |
| |
| |
| this.renderer.createTicks.call(this, plot); |
| |
| |
| |
| var dim=0; |
| var temp; |
| |
| if (this._elem) { |
| |
| |
| this._elem.emptyForce(); |
| this._elem = null; |
| } |
| |
| this._elem = $(document.createElement('div')); |
| this._elem.addClass('jqplot-axis jqplot-'+this.name); |
| this._elem.css('position', 'absolute'); |
|
|
| |
| if (this.name == 'xaxis' || this.name == 'x2axis') { |
| this._elem.width(this._plotDimensions.width); |
| } |
| else { |
| this._elem.height(this._plotDimensions.height); |
| } |
| |
| |
| this.labelOptions.axis = this.name; |
| this._label = new this.labelRenderer(this.labelOptions); |
| if (this._label.show) { |
| var elem = this._label.draw(ctx, plot); |
| elem.appendTo(this._elem); |
| elem = null; |
| } |
| |
| var t = this._ticks; |
| var tick; |
| for (var i=0; i<t.length; i++) { |
| tick = t[i]; |
| if (tick.show && tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { |
| this._elem.append(tick.draw(ctx, plot)); |
| } |
| } |
| tick = null; |
| t = null; |
| } |
| return this._elem; |
| }; |
| |
| |
| $.jqplot.LinearAxisRenderer.prototype.reset = function() { |
| 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 = ''; |
| } |
|
|
| |
| }; |
| |
| |
| $.jqplot.LinearAxisRenderer.prototype.set = function() { |
| var dim = 0; |
| var temp; |
| var w = 0; |
| var h = 0; |
| var lshow = (this._label == null) ? false : this._label.show; |
| if (this.show) { |
| var t = this._ticks; |
| var tick; |
| for (var i=0; i<t.length; i++) { |
| tick = t[i]; |
| if (!tick._breakTick && tick.show && tick.showLabel && (!tick.isMinorTick || this.showMinorTicks)) { |
| if (this.name == 'xaxis' || this.name == 'x2axis') { |
| temp = tick._elem.outerHeight(true); |
| } |
| else { |
| temp = tick._elem.outerWidth(true); |
| } |
| if (temp > dim) { |
| dim = temp; |
| } |
| } |
| } |
| tick = null; |
| t = null; |
| |
| if (lshow) { |
| w = this._label._elem.outerWidth(true); |
| h = this._label._elem.outerHeight(true); |
| } |
| if (this.name == 'xaxis') { |
| dim = dim + h; |
| this._elem.css({'height':dim+'px', left:'0px', bottom:'0px'}); |
| } |
| else if (this.name == 'x2axis') { |
| dim = dim + h; |
| this._elem.css({'height':dim+'px', left:'0px', top:'0px'}); |
| } |
| else if (this.name == 'yaxis') { |
| dim = dim + w; |
| this._elem.css({'width':dim+'px', left:'0px', top:'0px'}); |
| if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { |
| this._label._elem.css('width', w+'px'); |
| } |
| } |
| else { |
| dim = dim + w; |
| this._elem.css({'width':dim+'px', right:'0px', top:'0px'}); |
| if (lshow && this._label.constructor == $.jqplot.AxisLabelRenderer) { |
| this._label._elem.css('width', w+'px'); |
| } |
| } |
| } |
| }; |
| |
| |
| $.jqplot.LinearAxisRenderer.prototype.createTicks = function(plot) { |
| |
| var ticks = this._ticks; |
| var userTicks = this.ticks; |
| var name = this.name; |
| |
| var db = this._dataBounds; |
| var dim = (this.name.charAt(0) === 'x') ? this._plotDimensions.width : this._plotDimensions.height; |
| var interval; |
| var min, max; |
| var pos1, pos2; |
| var tt, i; |
| |
| var userMin = this.min; |
| var userMax = this.max; |
| var userNT = this.numberTicks; |
| var userTI = this.tickInterval; |
|
|
| var threshold = 30; |
| this._scalefact = (Math.max(dim, threshold+1) - threshold)/300.0; |
| |
| |
| |
| |
| if (userTicks.length) { |
| |
| for (i=0; i<userTicks.length; i++){ |
| var ut = userTicks[i]; |
| var t = new this.tickRenderer(this.tickOptions); |
| if ($.isArray(ut)) { |
| t.value = ut[0]; |
| if (this.breakPoints) { |
| if (ut[0] == this.breakPoints[0]) { |
| t.label = this.breakTickLabel; |
| t._breakTick = true; |
| t.showGridline = false; |
| t.showMark = false; |
| } |
| else if (ut[0] > this.breakPoints[0] && ut[0] <= this.breakPoints[1]) { |
| t.show = false; |
| t.showGridline = false; |
| t.label = ut[1]; |
| } |
| else { |
| t.label = ut[1]; |
| } |
| } |
| else { |
| t.label = ut[1]; |
| } |
| t.setTick(ut[0], this.name); |
| this._ticks.push(t); |
| } |
|
|
| else if ($.isPlainObject(ut)) { |
| $.extend(true, t, ut); |
| t.axis = this.name; |
| this._ticks.push(t); |
| } |
| |
| else { |
| t.value = ut; |
| if (this.breakPoints) { |
| if (ut == this.breakPoints[0]) { |
| t.label = this.breakTickLabel; |
| t._breakTick = true; |
| t.showGridline = false; |
| t.showMark = false; |
| } |
| else if (ut > this.breakPoints[0] && ut <= this.breakPoints[1]) { |
| t.show = false; |
| t.showGridline = false; |
| } |
| } |
| t.setTick(ut, this.name); |
| this._ticks.push(t); |
| } |
| } |
| this.numberTicks = userTicks.length; |
| this.min = this._ticks[0].value; |
| this.max = this._ticks[this.numberTicks-1].value; |
| this.tickInterval = (this.max - this.min) / (this.numberTicks - 1); |
| } |
| |
| |
| else { |
| if (name == 'xaxis' || name == 'x2axis') { |
| dim = this._plotDimensions.width; |
| } |
| else { |
| dim = this._plotDimensions.height; |
| } |
|
|
| var _numberTicks = this.numberTicks; |
|
|
| |
| |
| if (this.alignTicks) { |
| if (this.name === 'x2axis' && plot.axes.xaxis.show) { |
| _numberTicks = plot.axes.xaxis.numberTicks; |
| } |
| else if (this.name.charAt(0) === 'y' && this.name !== 'yaxis' && this.name !== 'yMidAxis' && plot.axes.yaxis.show) { |
| _numberTicks = plot.axes.yaxis.numberTicks; |
| } |
| } |
| |
| min = ((this.min != null) ? this.min : db.min); |
| max = ((this.max != null) ? this.max : db.max); |
|
|
| var range = max - min; |
| var rmin, rmax; |
| var temp; |
|
|
| if (this.tickOptions == null || !this.tickOptions.formatString) { |
| this._overrideFormatString = true; |
| } |
|
|
| |
| if (this.min == null || this.max == null && this.tickInterval == null && !this.autoscale) { |
| |
| |
| if (this.forceTickAt0) { |
| if (min > 0) { |
| min = 0; |
| } |
| if (max < 0) { |
| max = 0; |
| } |
| } |
|
|
| if (this.forceTickAt100) { |
| if (min > 100) { |
| min = 100; |
| } |
| if (max < 100) { |
| max = 100; |
| } |
| } |
|
|
| var keepMin = false, |
| keepMax = false; |
|
|
| if (this.min != null) { |
| keepMin = true; |
| } |
|
|
| else if (this.max != null) { |
| keepMax = true; |
| } |
|
|
| |
| |
| |
| var ret = $.jqplot.LinearTickGenerator(min, max, this._scalefact, _numberTicks, keepMin, keepMax); |
| |
| |
| |
| |
| var tumin = (this.min != null) ? min : min + range*(this.padMin - 1); |
| var tumax = (this.max != null) ? max : max - range*(this.padMax - 1); |
|
|
| |
| |
| if (min <tumin || max > tumax) { |
| tumin = (this.min != null) ? min : min - range*(this.padMin - 1); |
| tumax = (this.max != null) ? max : max + range*(this.padMax - 1); |
| ret = $.jqplot.LinearTickGenerator(tumin, tumax, this._scalefact, _numberTicks, keepMin, keepMax); |
| } |
|
|
| this.min = ret[0]; |
| this.max = ret[1]; |
| |
| this.numberTicks = ret[2]; |
| this._autoFormatString = ret[3]; |
| this.tickInterval = ret[4]; |
| } |
|
|
| |
| else { |
| |
| |
| if (min == max) { |
| var adj = 0.05; |
| if (min > 0) { |
| adj = Math.max(Math.log(min)/Math.LN10, 0.05); |
| } |
| min -= adj; |
| max += adj; |
| } |
| |
| |
| |
| |
| |
| if (this.autoscale && this.min == null && this.max == null) { |
| var rrange, ti, margin; |
| var forceMinZero = false; |
| var forceZeroLine = false; |
| var intervals = {min:null, max:null, average:null, stddev:null}; |
| |
| |
| for (var i=0; i<this._series.length; i++) { |
| var s = this._series[i]; |
| var faname = (s.fillAxis == 'x') ? s._xaxis.name : s._yaxis.name; |
| |
| if (this.name == faname) { |
| var vals = s._plotValues[s.fillAxis]; |
| var vmin = vals[0]; |
| var vmax = vals[0]; |
| for (var j=1; j<vals.length; j++) { |
| if (vals[j] < vmin) { |
| vmin = vals[j]; |
| } |
| else if (vals[j] > vmax) { |
| vmax = vals[j]; |
| } |
| } |
| var dp = (vmax - vmin) / vmax; |
| |
| if (s.renderer.constructor == $.jqplot.BarRenderer) { |
| |
| if (vmin >= 0 && (s.fillToZero || dp > 0.1)) { |
| forceMinZero = true; |
| } |
| else { |
| forceMinZero = false; |
| if (s.fill && s.fillToZero && vmin < 0 && vmax > 0) { |
| forceZeroLine = true; |
| } |
| else { |
| forceZeroLine = false; |
| } |
| } |
| } |
| |
| |
| else if (s.fill) { |
| if (vmin >= 0 && (s.fillToZero || dp > 0.1)) { |
| forceMinZero = true; |
| } |
| else if (vmin < 0 && vmax > 0 && s.fillToZero) { |
| forceMinZero = false; |
| forceZeroLine = true; |
| } |
| else { |
| forceMinZero = false; |
| forceZeroLine = false; |
| } |
| } |
| |
| |
| |
| else if (vmin < 0) { |
| forceMinZero = false; |
| } |
| } |
| } |
| |
| |
| if (forceMinZero) { |
| |
| this.numberTicks = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing); |
| this.min = 0; |
| userMin = 0; |
| |
| |
| ti = max/(this.numberTicks-1); |
| temp = Math.pow(10, Math.abs(Math.floor(Math.log(ti)/Math.LN10))); |
| if (ti/temp == parseInt(ti/temp, 10)) { |
| ti += temp; |
| } |
| this.tickInterval = Math.ceil(ti/temp) * temp; |
| this.max = this.tickInterval * (this.numberTicks - 1); |
| } |
| |
| |
| else if (forceZeroLine) { |
| |
| this.numberTicks = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing); |
| var ntmin = Math.ceil(Math.abs(min)/range*(this.numberTicks-1)); |
| var ntmax = this.numberTicks - 1 - ntmin; |
| ti = Math.max(Math.abs(min/ntmin), Math.abs(max/ntmax)); |
| temp = Math.pow(10, Math.abs(Math.floor(Math.log(ti)/Math.LN10))); |
| this.tickInterval = Math.ceil(ti/temp) * temp; |
| this.max = this.tickInterval * ntmax; |
| this.min = -this.tickInterval * ntmin; |
| } |
| |
| |
| else { |
| if (this.numberTicks == null){ |
| if (this.tickInterval) { |
| this.numberTicks = 3 + Math.ceil(range / this.tickInterval); |
| } |
| else { |
| this.numberTicks = 2 + Math.ceil((dim-(this.tickSpacing-1))/this.tickSpacing); |
| } |
| } |
| |
| if (this.tickInterval == null) { |
| |
| ti = range/(this.numberTicks - 1); |
|
|
| if (ti < 1) { |
| temp = Math.pow(10, Math.abs(Math.floor(Math.log(ti)/Math.LN10))); |
| } |
| else { |
| temp = 1; |
| } |
| this.tickInterval = Math.ceil(ti*temp*this.pad)/temp; |
| } |
| else { |
| temp = 1 / this.tickInterval; |
| } |
| |
| |
| |
| |
| rrange = this.tickInterval * (this.numberTicks - 1); |
| margin = (rrange - range)/2; |
| |
| if (this.min == null) { |
| this.min = Math.floor(temp*(min-margin))/temp; |
| } |
| if (this.max == null) { |
| this.max = this.min + rrange; |
| } |
| } |
|
|
| |
| |
| var sf = $.jqplot.getSignificantFigures(this.tickInterval); |
|
|
| var fstr; |
|
|
| |
| if (sf.digitsLeft >= sf.significantDigits) { |
| fstr = '%d'; |
| } |
|
|
| else { |
| var temp = Math.max(0, 5 - sf.digitsLeft); |
| temp = Math.min(temp, sf.digitsRight); |
| fstr = '%.'+ temp + 'f'; |
| } |
|
|
| this._autoFormatString = fstr; |
| } |
| |
| |
| |
| else { |
|
|
| rmin = (this.min != null) ? this.min : min - range*(this.padMin - 1); |
| rmax = (this.max != null) ? this.max : max + range*(this.padMax - 1); |
| range = rmax - rmin; |
| |
| if (this.numberTicks == null){ |
| |
| |
| if (this.tickInterval != null) { |
| this.numberTicks = Math.ceil((rmax - rmin)/this.tickInterval)+1; |
| } |
| else if (dim > 100) { |
| this.numberTicks = parseInt(3+(dim-100)/75, 10); |
| } |
| else { |
| this.numberTicks = 2; |
| } |
| } |
| |
| if (this.tickInterval == null) { |
| this.tickInterval = range / (this.numberTicks-1); |
| } |
| |
| if (this.max == null) { |
| rmax = rmin + this.tickInterval*(this.numberTicks - 1); |
| } |
| if (this.min == null) { |
| rmin = rmax - this.tickInterval*(this.numberTicks - 1); |
| } |
|
|
| |
| var sf = $.jqplot.getSignificantFigures(this.tickInterval); |
|
|
| var fstr; |
|
|
| |
| if (sf.digitsLeft >= sf.significantDigits) { |
| fstr = '%d'; |
| } |
|
|
| else { |
| var temp = Math.max(0, 5 - sf.digitsLeft); |
| temp = Math.min(temp, sf.digitsRight); |
| fstr = '%.'+ temp + 'f'; |
| } |
|
|
|
|
| this._autoFormatString = fstr; |
|
|
| this.min = rmin; |
| this.max = rmax; |
| } |
| |
| if (this.renderer.constructor == $.jqplot.LinearAxisRenderer && this._autoFormatString == '') { |
| |
| range = this.max - this.min; |
| |
| var temptick = new this.tickRenderer(this.tickOptions); |
| |
| var fs = temptick.formatString || $.jqplot.config.defaultTickFormatString; |
| var fs = fs.match($.jqplot.sprintf.regex)[0]; |
| var precision = 0; |
| if (fs) { |
| if (fs.search(/[fFeEgGpP]/) > -1) { |
| var m = fs.match(/\%\.(\d{0,})?[eEfFgGpP]/); |
| if (m) { |
| precision = parseInt(m[1], 10); |
| } |
| else { |
| precision = 6; |
| } |
| } |
| else if (fs.search(/[di]/) > -1) { |
| precision = 0; |
| } |
| |
| var fact = Math.pow(10, -precision); |
| if (this.tickInterval < fact) { |
| |
| if (userNT == null && userTI == null) { |
| this.tickInterval = fact; |
| if (userMax == null && userMin == null) { |
| |
| this.min = Math.floor(this._dataBounds.min/fact) * fact; |
| if (this.min == this._dataBounds.min) { |
| this.min = this._dataBounds.min - this.tickInterval; |
| } |
| |
| this.max = Math.ceil(this._dataBounds.max/fact) * fact; |
| if (this.max == this._dataBounds.max) { |
| this.max = this._dataBounds.max + this.tickInterval; |
| } |
| var n = (this.max - this.min)/this.tickInterval; |
| n = n.toFixed(11); |
| n = Math.ceil(n); |
| this.numberTicks = n + 1; |
| } |
| else if (userMax == null) { |
| |
| var n = (this._dataBounds.max - this.min) / this.tickInterval; |
| n = n.toFixed(11); |
| this.numberTicks = Math.ceil(n) + 2; |
| this.max = this.min + this.tickInterval * (this.numberTicks-1); |
| } |
| else if (userMin == null) { |
| |
| var n = (this.max - this._dataBounds.min) / this.tickInterval; |
| n = n.toFixed(11); |
| this.numberTicks = Math.ceil(n) + 2; |
| this.min = this.max - this.tickInterval * (this.numberTicks-1); |
| } |
| else { |
| |
| this.numberTicks = Math.ceil((userMax - userMin)/this.tickInterval) + 1; |
| |
| |
| |
| this.min = Math.floor(userMin*Math.pow(10, precision))/Math.pow(10, precision); |
| this.max = Math.ceil(userMax*Math.pow(10, precision))/Math.pow(10, precision); |
| |
| this.numberTicks = Math.ceil((this.max - this.min)/this.tickInterval) + 1; |
| } |
| } |
| } |
| } |
| } |
| |
| } |
| |
| if (this._overrideFormatString && this._autoFormatString != '') { |
| this.tickOptions = this.tickOptions || {}; |
| this.tickOptions.formatString = this._autoFormatString; |
| } |
|
|
| var t, to; |
| for (var i=0; i<this.numberTicks; i++){ |
| tt = this.min + i * this.tickInterval; |
| t = new this.tickRenderer(this.tickOptions); |
| |
|
|
| t.setTick(tt, this.name); |
| this._ticks.push(t); |
|
|
| if (i < this.numberTicks - 1) { |
| for (var j=0; j<this.minorTicks; j++) { |
| tt += this.tickInterval/(this.minorTicks+1); |
| to = $.extend(true, {}, this.tickOptions, {name:this.name, value:tt, label:'', isMinorTick:true}); |
| t = new this.tickRenderer(to); |
| this._ticks.push(t); |
| } |
| } |
| t = null; |
| } |
| } |
|
|
| if (this.tickInset) { |
| this.min = this.min - this.tickInset * this.tickInterval; |
| this.max = this.max + this.tickInset * this.tickInterval; |
| } |
|
|
| ticks = null; |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| $.jqplot.LinearAxisRenderer.prototype.resetTickValues = function(opts) { |
| if ($.isArray(opts) && opts.length == this._ticks.length) { |
| var t; |
| for (var i=0; i<opts.length; i++) { |
| t = this._ticks[i]; |
| t.value = opts[i]; |
| t.label = t.formatter(t.formatString, opts[i]); |
| t.label = t.prefix + t.label; |
| t._elem.html(t.label); |
| } |
| t = null; |
| this.min = $.jqplot.arrayMin(opts); |
| this.max = $.jqplot.arrayMax(opts); |
| this.pack(); |
| } |
| |
| |
| |
| |
| }; |
| |
| |
| $.jqplot.LinearAxisRenderer.prototype.pack = function(pos, offsets) { |
| |
| pos = pos || {}; |
| offsets = offsets || this._offsets; |
| |
| var ticks = this._ticks; |
| var max = this.max; |
| var min = this.min; |
| var offmax = offsets.max; |
| var offmin = offsets.min; |
| var lshow = (this._label == null) ? false : this._label.show; |
| |
| for (var p in pos) { |
| this._elem.css(p, pos[p]); |
| } |
| |
| this._offsets = offsets; |
| |
| var pixellength = offmax - offmin; |
| var unitlength = max - min; |
| |
| |
| if (this.breakPoints) { |
| unitlength = unitlength - this.breakPoints[1] + this.breakPoints[0]; |
| |
| this.p2u = function(p){ |
| return (p - offmin) * unitlength / pixellength + min; |
| }; |
| |
| this.u2p = function(u){ |
| if (u > this.breakPoints[0] && u < this.breakPoints[1]){ |
| u = this.breakPoints[0]; |
| } |
| if (u <= this.breakPoints[0]) { |
| return (u - min) * pixellength / unitlength + offmin; |
| } |
| else { |
| return (u - this.breakPoints[1] + this.breakPoints[0] - min) * pixellength / unitlength + offmin; |
| } |
| }; |
| |
| if (this.name.charAt(0) == 'x'){ |
| this.series_u2p = function(u){ |
| if (u > this.breakPoints[0] && u < this.breakPoints[1]){ |
| u = this.breakPoints[0]; |
| } |
| if (u <= this.breakPoints[0]) { |
| return (u - min) * pixellength / unitlength; |
| } |
| else { |
| return (u - this.breakPoints[1] + this.breakPoints[0] - min) * pixellength / unitlength; |
| } |
| }; |
| this.series_p2u = function(p){ |
| return p * unitlength / pixellength + min; |
| }; |
| } |
| |
| else { |
| this.series_u2p = function(u){ |
| if (u > this.breakPoints[0] && u < this.breakPoints[1]){ |
| u = this.breakPoints[0]; |
| } |
| if (u >= this.breakPoints[1]) { |
| return (u - max) * pixellength / unitlength; |
| } |
| else { |
| return (u + this.breakPoints[1] - this.breakPoints[0] - max) * pixellength / unitlength; |
| } |
| }; |
| this.series_p2u = function(p){ |
| return p * unitlength / pixellength + max; |
| }; |
| } |
| } |
| else { |
| this.p2u = function(p){ |
| return (p - offmin) * unitlength / pixellength + min; |
| }; |
| |
| this.u2p = function(u){ |
| return (u - min) * pixellength / unitlength + offmin; |
| }; |
| |
| if (this.name == 'xaxis' || this.name == 'x2axis'){ |
| this.series_u2p = function(u){ |
| return (u - min) * pixellength / unitlength; |
| }; |
| this.series_p2u = function(p){ |
| return p * unitlength / pixellength + min; |
| }; |
| } |
| |
| else { |
| this.series_u2p = function(u){ |
| return (u - max) * pixellength / unitlength; |
| }; |
| this.series_p2u = function(p){ |
| return p * unitlength / pixellength + max; |
| }; |
| } |
| } |
| |
| if (this.show) { |
| if (this.name == 'xaxis' || this.name == 'x2axis') { |
| for (var i=0; i<ticks.length; i++) { |
| var t = ticks[i]; |
| if (t.show && t.showLabel) { |
| var shim; |
| |
| if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { |
| |
| var temp = (this.name == 'xaxis') ? 1 : -1; |
| switch (t.labelPosition) { |
| case 'auto': |
| |
| if (temp * t.angle < 0) { |
| shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; |
| } |
| |
| else { |
| shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; |
| } |
| break; |
| case 'end': |
| shim = -t.getWidth() + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; |
| break; |
| case 'start': |
| shim = -t._textRenderer.height * Math.sin(t._textRenderer.angle) / 2; |
| break; |
| case 'middle': |
| shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; |
| break; |
| default: |
| shim = -t.getWidth()/2 + t._textRenderer.height * Math.sin(-t._textRenderer.angle) / 2; |
| break; |
| } |
| } |
| else { |
| shim = -t.getWidth()/2; |
| } |
| var val = this.u2p(t.value) + shim + 'px'; |
| t._elem.css('left', val); |
| t.pack(); |
| } |
| } |
| if (lshow) { |
| var w = this._label._elem.outerWidth(true); |
| this._label._elem.css('left', offmin + pixellength/2 - w/2 + 'px'); |
| if (this.name == 'xaxis') { |
| this._label._elem.css('bottom', '0px'); |
| } |
| else { |
| this._label._elem.css('top', '0px'); |
| } |
| this._label.pack(); |
| } |
| } |
| else { |
| for (var i=0; i<ticks.length; i++) { |
| var t = ticks[i]; |
| if (t.show && t.showLabel) { |
| var shim; |
| if (t.constructor == $.jqplot.CanvasAxisTickRenderer && t.angle) { |
| |
| var temp = (this.name == 'yaxis') ? 1 : -1; |
| switch (t.labelPosition) { |
| case 'auto': |
| |
| case 'end': |
| if (temp * t.angle < 0) { |
| shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; |
| } |
| else { |
| shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; |
| } |
| break; |
| case 'start': |
| if (t.angle > 0) { |
| shim = -t._textRenderer.height * Math.cos(-t._textRenderer.angle) / 2; |
| } |
| else { |
| shim = -t.getHeight() + t._textRenderer.height * Math.cos(t._textRenderer.angle) / 2; |
| } |
| break; |
| case 'middle': |
| |
| |
| |
| |
| |
| |
| shim = -t.getHeight()/2; |
| break; |
| default: |
| shim = -t.getHeight()/2; |
| break; |
| } |
| } |
| else { |
| shim = -t.getHeight()/2; |
| } |
| |
| var val = this.u2p(t.value) + shim + 'px'; |
| t._elem.css('top', val); |
| t.pack(); |
| } |
| } |
| if (lshow) { |
| var h = this._label._elem.outerHeight(true); |
| this._label._elem.css('top', offmax - pixellength/2 - h/2 + 'px'); |
| if (this.name == 'yaxis') { |
| this._label._elem.css('left', '0px'); |
| } |
| else { |
| this._label._elem.css('right', '0px'); |
| } |
| this._label.pack(); |
| } |
| } |
| } |
|
|
| ticks = null; |
| }; |
| })(jQuery); |
|
|