Sha256: 11e4c75ed21ccfd6718ed72732dc83a8b6e921ac202373532245341c75d44572

Contents?: true

Size: 1.86 KB

Versions: 7

Compression:

Stored size: 1.86 KB

Contents

dojo.provide("dojox.charting.axis2d.common");

dojo.require("dojox.gfx");

(function(){
	var g = dojox.gfx;
	
	function clearNode(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";
	}
	
	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){
				// setup the text node
				var p = dojo.doc.createElement("div"), s = p.style;
				clearNode(s);
				s.font = font;
				p.innerHTML = String(text).replace(/\s/g, " ");
				s.color = fontColor;
				// measure the size
				s.position = "absolute";
				s.left = "-10000px";
				dojo.body().appendChild(p);
				var size = g.normalizedLength(g.splitFontString(font).size),
					box = dojo.marginBox(p);
				// new settings for the text node
				dojo.body().removeChild(p);
				s.position = "relative";
				switch(align){
					case "middle":
						s.left = Math.floor(x - box.w / 2) + "px";
						break;
					case "end":
						s.left = Math.floor(x - box.w) + "px";
						break;
					//case "start":
					default:
						s.left = Math.floor(x) + "px";
						break;
				}
				s.top = Math.floor(y - size) + "px";
				// setup the wrapper node
				var wrap = dojo.doc.createElement("div"), w = wrap.style;
				clearNode(w);
				w.width = "0px";
				w.height = "0px";
				// insert nodes
				wrap.appendChild(p)
				chart.node.insertBefore(wrap, chart.node.firstChild);
				return wrap;
			}
		}
	});
})();

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dojo-pkg-1.132.0 data/dojo-release-1.3.2-src/dojox/charting/axis2d/common.js
dojo-pkg-1.120.0 data/dojo-release-1.2.0-src/dojox/charting/axis2d/common.js
dojo-pkg-1.121.0 data/dojo-release-1.2.1-src/dojox/charting/axis2d/common.js
dojo-pkg-1.122.0 data/dojo-release-1.2.2-src/dojox/charting/axis2d/common.js
dojo-pkg-1.123.0 data/dojo-release-1.2.3-src/dojox/charting/axis2d/common.js
dojo-pkg-1.130.0 data/dojo-release-1.3.0-src/dojox/charting/axis2d/common.js
dojo-pkg-1.131.0 data/dojo-release-1.3.1-src/dojox/charting/axis2d/common.js