in web/servicemix-web-console/src/main/webapp/js/plotkit/Canvas.js [487:565]
PlotKit.CanvasRenderer.prototype._renderPieAxis = function() {
if (!this.options.drawXAxis)
return;
if (this.layout.xticks) {
// make a lookup dict for x->slice values
var lookup = new Array();
for (var i = 0; i < this.layout.slices.length; i++) {
lookup[this.layout.slices[i].xval] = this.layout.slices[i];
}
var centerx = this.area.x + this.area.w * 0.5;
var centery = this.area.y + this.area.h * 0.5;
var radius = Math.min(this.area.w * this.options.pieRadius,
this.area.h * this.options.pieRadius);
var labelWidth = this.options.axisLabelWidth;
for (var i = 0; i < this.layout.xticks.length; i++) {
var slice = lookup[this.layout.xticks[i][0]];
if (MochiKit.Base.isUndefinedOrNull(slice))
continue;
var angle = (slice.startAngle + slice.endAngle)/2;
// normalize the angle
var normalisedAngle = angle;
if (normalisedAngle > Math.PI * 2)
normalisedAngle = normalisedAngle - Math.PI * 2;
else if (normalisedAngle < 0)
normalisedAngle = normalisedAngle + Math.PI * 2;
var labelx = centerx + Math.sin(normalisedAngle) * (radius + 10);
var labely = centery - Math.cos(normalisedAngle) * (radius + 10);
var attrib = {"position": "absolute",
"zIndex": 11,
"width": labelWidth + "px",
"fontSize": this.options.axisLabelFontSize + "px",
"overflow": "hidden",
"color": this.options.axisLabelColor.toHexString()
};
if (normalisedAngle <= Math.PI * 0.5) {
// text on top and align left
attrib["textAlign"] = "left";
attrib["verticalAlign"] = "top";
attrib["left"] = labelx + "px";
attrib["top"] = (labely - this.options.axisLabelFontSize) + "px";
}
else if ((normalisedAngle > Math.PI * 0.5) && (normalisedAngle <= Math.PI)) {
// text on bottom and align left
attrib["textAlign"] = "left";
attrib["verticalAlign"] = "bottom";
attrib["left"] = labelx + "px";
attrib["top"] = labely + "px";
}
else if ((normalisedAngle > Math.PI) && (normalisedAngle <= Math.PI*1.5)) {
// text on bottom and align right
attrib["textAlign"] = "right";
attrib["verticalAlign"] = "bottom";
attrib["left"] = (labelx - labelWidth) + "px";
attrib["top"] = labely + "px";
}
else {
// text on top and align right
attrib["textAlign"] = "right";
attrib["verticalAlign"] = "bottom";
attrib["left"] = (labelx - labelWidth) + "px";
attrib["top"] = (labely - this.options.axisLabelFontSize) + "px";
}
var label = DIV({'style': attrib}, this.layout.xticks[i][1]);
this.xlabels.push(label);
MochiKit.DOM.appendChildNodes(this.container, label);
}
}
};