dojox.charting.axis2d.Default.render
dojo.require("dojox.charting.axis2d.Default");
defined in dojox/charting/axis2d/Default.js
Usage
function (dim, offsets) (view source)
if(!this.dirty){ return this; } // prepare variable var start, stop, axisVector, tickVector, labelOffset, labelAlign, ta = this.chart.theme.axis, taStroke = "stroke" in this.opt ? this.opt.stroke : ta.stroke, taMajorTick = "majorTick" in this.opt ? this.opt.majorTick : ta.majorTick, taMinorTick = "minorTick" in this.opt ? this.opt.minorTick : ta.minorTick, taFont = "font" in this.opt ? this.opt.font : ta.font, taFontColor = "fontColor" in this.opt ? this.opt.fontColor : ta.fontColor, tickSize = Math.max(taMajorTick.length, taMinorTick.length), size = taFont ? g.normalizedLength(g.splitFontString(taFont).size) : 0; if(this.vertical){ start = {y: dim.height - offsets.b}; stop = {y: offsets.t}; axisVector = {x: 0, y: -1}; if(this.opt.leftBottom){ start.x = stop.x = offsets.l; tickVector = {x: -1, y: 0}; labelAlign = "end"; }else{ start.x = stop.x = dim.width - offsets.r; tickVector = {x: 1, y: 0}; labelAlign = "start"; } labelOffset = {x: tickVector.x * (tickSize + labelGap), y: size * 0.4}; }else{ start = {x: offsets.l}; stop = {x: dim.width - offsets.r}; axisVector = {x: 1, y: 0}; labelAlign = "middle"; if(this.opt.leftBottom){ start.y = stop.y = dim.height - offsets.b; tickVector = {x: 0, y: 1}; labelOffset = {y: tickSize + labelGap + size}; }else{ start.y = stop.y = offsets.t; tickVector = {x: 0, y: -1}; labelOffset = {y: -tickSize - labelGap}; } labelOffset.x = 0; } // render shapes this.cleanGroup(); var s = this.group, c = this.scaler, step, next, nextMajor = c.major.start, nextMinor = c.minor.start, nextMicro = c.micro.start; s.createLine({x1: start.x, y1: start.y, x2: stop.x, y2: stop.y}).setStroke(taStroke); if(this.opt.microTicks && c.micro.tick){ step = c.micro.tick, next = nextMicro; }else if(this.opt.minorTicks && c.minor.tick){ step = c.minor.tick, next = nextMinor; }else if(c.major.tick){ step = c.major.tick, next = nextMajor; }else{ // don't draw anything return this; } while(next <= c.bounds.upper + 1/c.scale){ var offset = (next - c.bounds.lower) * c.scale, x = start.x + axisVector.x * offset, y = start.y + axisVector.y * offset, elem; if(Math.abs(nextMajor - next) < step / 2){ // major tick s.createLine({ x1: x, y1: y, x2: x + tickVector.x * taMajorTick.length, y2: y + tickVector.y * taMajorTick.length }).setStroke(taMajorTick); if(this.opt.majorLabels){ elem = dc.axis2d.common.createText[this.opt.htmlLabels && dojox.gfx.renderer != "vml" ? "html" : "gfx"] (this.chart, s, x + labelOffset.x, y + labelOffset.y, labelAlign, this._getLabel(nextMajor, c.major.prec), taFont, taFontColor); if(this.opt.htmlLabels){ this.htmlElements.push(elem); } } nextMajor += c.major.tick; nextMinor += c.minor.tick; nextMicro += c.micro.tick; }else if(Math.abs(nextMinor - next) < step / 2){ // minor tick if(this.opt.minorTicks){ s.createLine({ x1: x, y1: y, x2: x + tickVector.x * taMinorTick.length, y2: y + tickVector.y * taMinorTick.length }).setStroke(taMinorTick); if(this.opt.minorLabels && (c.minMinorStep <= c.minor.tick * c.scale)){ elem = dc.axis2d.common.createText[this.opt.htmlLabels && dojox.gfx.renderer != "vml" ? "html" : "gfx"] (this.chart, s, x + labelOffset.x, y + labelOffset.y, labelAlign, this._getLabel(nextMinor, c.minor.prec), taFont, taFontColor); if(this.opt.htmlLabels){ this.htmlElements.push(elem); } } } nextMinor += c.minor.tick; nextMicro += c.micro.tick; }else{ // micro tick if(this.opt.microTicks){ s.createLine({ x1: x, y1: y, // use minor ticks for now x2: x + tickVector.x * taMinorTick.length, y2: y + tickVector.y * taMinorTick.length }).setStroke(taMinorTick); } nextMicro += c.micro.tick; } next += step; } this.dirty = false; return this;
parameter | type | description |
---|---|---|
dim | ||
offsets |