123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- if(!dojo._hasResource["dojox.charting.axis2d.common"]){
- dojo._hasResource["dojox.charting.axis2d.common"] = true;
- dojo.provide("dojox.charting.axis2d.common");
- dojo.require("dojox.gfx");
- (function(){
- var g = dojox.gfx;
- var clearNode = function(s){
- s.marginLeft = "0px";
- s.marginTop = "0px";
- s.marginRight = "0px";
- s.marginBottom = "0px";
- s.paddingLeft = "0px";
- s.paddingTop = "0px";
- s.paddingRight = "0px";
- s.paddingBottom = "0px";
- s.borderLeftWidth = "0px";
- s.borderTopWidth = "0px";
- s.borderRightWidth = "0px";
- s.borderBottomWidth = "0px";
- };
- var getBoxWidth = function(n){
-
- if(n["getBoundingClientRect"]){
- var bcr = n.getBoundingClientRect();
- return bcr.width || (bcr.right - bcr.left);
- }else{
- return dojo.marginBox(n).w;
- }
- };
- dojo.mixin(dojox.charting.axis2d.common, {
-
-
- createText: {
- gfx: function(chart, creator, x, y, align, text, font, fontColor){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return creator.createText({
- x: x, y: y, text: text, align: align
- }).setFont(font).setFill(fontColor);
- },
- html: function(chart, creator, x, y, align, text, font, fontColor, labelWidth){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var p = dojo.doc.createElement("div"), s = p.style, boxWidth;
- clearNode(s);
- s.font = font;
- p.innerHTML = String(text).replace(/\s/g, " ");
- s.color = fontColor;
-
- s.position = "absolute";
- s.left = "-10000px";
- dojo.body().appendChild(p);
- var size = g.normalizedLength(g.splitFontString(font).size);
-
- if(!labelWidth){
- boxWidth = getBoxWidth(p);
- }
-
- dojo.body().removeChild(p);
- s.position = "relative";
- if(labelWidth){
- s.width = labelWidth + "px";
-
- switch(align){
- case "middle":
- s.textAlign = "center";
- s.left = (x - labelWidth / 2) + "px";
- break;
- case "end":
- s.textAlign = "right";
- s.left = (x - labelWidth) + "px";
- break;
- default:
- s.left = x + "px";
- s.textAlign = "left";
- break;
- }
- }else{
- switch(align){
- case "middle":
- s.left = Math.floor(x - boxWidth / 2) + "px";
-
- break;
- case "end":
- s.left = Math.floor(x - boxWidth) + "px";
-
- break;
-
- default:
- s.left = Math.floor(x) + "px";
- break;
- }
- }
- s.top = Math.floor(y - size) + "px";
- s.whiteSpace = "nowrap";
-
- var wrap = dojo.doc.createElement("div"), w = wrap.style;
- clearNode(w);
- w.width = "0px";
- w.height = "0px";
-
- wrap.appendChild(p)
- chart.node.insertBefore(wrap, chart.node.firstChild);
- return wrap;
- }
- }
- });
- })();
- }
|