dojox.charting.axis2d.Default.getOffsets
dojo.require("dojox.charting.axis2d.Default");
defined in dojox/charting/axis2d/Default.js
Usage
function () (view source)
var offsets = {l: 0, r: 0, t: 0, b: 0}, s, labelWidth, gtb, a, b, c, d; var offset = 0, ta = this.chart.theme.axis, taFont = "font" in this.opt ? this.opt.font : ta.font, taMajorTick = "majorTick" in this.opt ? this.opt.majorTick : ta.majorTick, taMinorTick = "minorTick" in this.opt ? this.opt.minorTick : ta.minorTick, size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0; if(this.vertical){ if(size){ s = this.scaler; if(this.labels){ labelWidth = df.foldl(df.map(this.labels, function(label){ return dojox.gfx._base._getTextBox(label.text, {font: taFont}).w; }), "Math.max(a, b)", 0); }else{ gtb = dojox.gfx._base._getTextBox; a = gtb(this._getLabel(s.major.start, s.major.prec), {font: taFont}).w; b = gtb(this._getLabel(s.major.start + s.major.count * s.major.tick, s.major.prec), {font: taFont}).w; c = gtb(this._getLabel(s.minor.start, s.minor.prec), {font: taFont}).w; d = gtb(this._getLabel(s.minor.start + s.minor.count * s.minor.tick, s.minor.prec), {font: taFont}).w; labelWidth = Math.max(a, b, c, d); } offset = labelWidth + labelGap; } offset += labelGap + Math.max(taMajorTick.length, taMinorTick.length); offsets[this.opt.leftBottom ? "l" : "r"] = offset; offsets.t = offsets.b = size / 2; }else{ if(size){ offset = size + labelGap; } offset += labelGap + Math.max(taMajorTick.length, taMinorTick.length); offsets[this.opt.leftBottom ? "b" : "t"] = offset; if(size){ s = this.scaler; if(this.labels){ labelWidth = df.foldl(df.map(this.labels, function(label){ return dojox.gfx._base._getTextBox(label.text, {font: taFont}).w; }), "Math.max(a, b)", 0); }else{ gtb = dojox.gfx._base._getTextBox; a = gtb(this._getLabel(s.major.start, s.major.prec), {font: taFont}).w; b = gtb(this._getLabel(s.major.start + s.major.count * s.major.tick, s.major.prec), {font: taFont}).w; c = gtb(this._getLabel(s.minor.start, s.minor.prec), {font: taFont}).w; d = gtb(this._getLabel(s.minor.start + s.minor.count * s.minor.tick, s.minor.prec), {font: taFont}).w; labelWidth = Math.max(a, b, c, d); } offsets.l = offsets.r = labelWidth / 2; } } return offsets;