cacert-testmgr/external/ZendFramework-1.9.5/externals/dojo/dojox/charting/plot2d/Grid.js

126 lines
3.2 KiB
JavaScript
Raw Permalink Normal View History

dojo.provide("dojox.charting.plot2d.Grid");
dojo.require("dojox.charting.Element");
dojo.require("dojox.charting.plot2d.common");
dojo.require("dojox.lang.functional");
(function(){
var du = dojox.lang.utils;
dojo.declare("dojox.charting.plot2d.Grid", dojox.charting.Element, {
defaultParams: {
hAxis: "x", // use a horizontal axis named "x"
vAxis: "y", // use a vertical axis named "y"
hMajorLines: true, // draw horizontal major lines
hMinorLines: false, // draw horizontal minor lines
vMajorLines: true, // draw vertical major lines
vMinorLines: false, // draw vertical minor lines
hStripes: "none", // TBD
vStripes: "none" // TBD
},
optionalParams: {}, // no optional parameters
constructor: function(chart, kwArgs){
this.opt = dojo.clone(this.defaultParams);
du.updateWithObject(this.opt, kwArgs);
this.hAxis = this.opt.hAxis;
this.vAxis = this.opt.vAxis;
this.dirty = true;
},
clear: function(){
this._hAxis = null;
this._vAxis = null;
this.dirty = true;
return this;
},
setAxis: function(axis){
if(axis){
this[axis.vertical ? "_vAxis" : "_hAxis"] = axis;
}
return this;
},
addSeries: function(run){
// nothing
return this;
},
calculateAxes: function(dim){
// nothing
return this;
},
isDirty: function(){
return this.dirty || this._hAxis && this._hAxis.dirty || this._vAxis && this._vAxis.dirty;
},
getRequiredColors: function(){
return 0;
},
render: function(dim, offsets){
this.dirty = this.isDirty();
if(!this.dirty){ return this; }
this.cleanGroup();
var s = this.group, ta = this.chart.theme.axis;
// draw horizontal stripes and lines
try{
var vScaler = this._vAxis.getScaler(),
vt = vScaler.scaler.getTransformerFromModel(vScaler),
ticks = this._vAxis.getTicks();
if(this.opt.hMinorLines){
dojo.forEach(ticks.minor, function(tick){
var y = dim.height - offsets.b - vt(tick.value);
s.createLine({
x1: offsets.l,
y1: y,
x2: dim.width - offsets.r,
y2: y
}).setStroke(ta.minorTick);
});
}
if(this.opt.hMajorLines){
dojo.forEach(ticks.major, function(tick){
var y = dim.height - offsets.b - vt(tick.value);
s.createLine({
x1: offsets.l,
y1: y,
x2: dim.width - offsets.r,
y2: y
}).setStroke(ta.majorTick);
});
}
}catch(e){
// squelch
}
// draw vertical stripes and lines
try{
var hScaler = this._hAxis.getScaler(),
ht = hScaler.scaler.getTransformerFromModel(hScaler),
ticks = this._hAxis.getTicks();
if(ticks && this.opt.vMinorLines){
dojo.forEach(ticks.minor, function(tick){
var x = offsets.l + ht(tick.value);
s.createLine({
x1: x,
y1: offsets.t,
x2: x,
y2: dim.height - offsets.b
}).setStroke(ta.minorTick);
});
}
if(ticks && this.opt.vMajorLines){
dojo.forEach(ticks.major, function(tick){
var x = offsets.l + ht(tick.value);
s.createLine({
x1: x,
y1: offsets.t,
x2: x,
y2: dim.height - offsets.b
}).setStroke(ta.majorTick);
});
}
}catch(e){
// squelch
}
this.dirty = false;
return this;
}
});
})();