summaryrefslogtreecommitdiff
path: root/js/dojo-1.6/dojox/geo/charting/_base.xd.js
blob: 1071587fab89a50b1195f6a388b487ad24c4864d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


dojo._xdResourceLoaded(function(dojo, dijit, dojox){
return {depends: [["provide", "dojox.geo.charting._base"],
["require", "dojo.NodeList-traverse"],
["require", "dojox.gfx.matrix"],
["require", "dijit.Tooltip"]],
defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.geo.charting._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.geo.charting._base"] = true;
dojo.provide("dojox.geo.charting._base");

dojo.require("dojo.NodeList-traverse");
dojo.require("dojox.gfx.matrix");
dojo.require("dijit.Tooltip");

(function(){
	var dgc = dojox.geo.charting;
	dgc.showTooltip = function(/*String*/innerHTML, /*dojox.gfx.shape*/ gfxObject, /*String[]?*/ position){
		var arroundNode = dgc._normalizeArround(gfxObject);
		return dijit.showTooltip(innerHTML, arroundNode, position);
	};

	dgc.hideTooltip = function( /*dojox.gfx.shape*/gfxObject){
		return dijit.hideTooltip(gfxObject);
	};

	dgc._normalizeArround = function(gfxObject){
		var bbox = dgc._getRealBBox(gfxObject);
		//var bbox = gfxObject.getBoundingBox();
		//get the real screen coords for gfx object
		var realMatrix = gfxObject._getRealMatrix() || {xx:1,xy:0,yx:0,yy:1,dx:0,dy:0};
		var point = dojox.gfx.matrix.multiplyPoint(realMatrix, bbox.x, bbox.y);
		var gfxDomContainer = dojo.coords(dgc._getGfxContainer(gfxObject));
		gfxObject.x = dojo.coords(gfxDomContainer,true).x + point.x,
		gfxObject.y = dojo.coords(gfxDomContainer,true).y + point.y,
		gfxObject.width = bbox.width * realMatrix.xx,
		gfxObject.height = bbox.height * realMatrix.yy
		return gfxObject;
	};

	dgc._getGfxContainer = function(gfxObject){
		return (new dojo.NodeList(gfxObject.rawNode)).parents("div")[0];
	};

	dgc._getRealBBox = function(gfxObject){
		var bboxObject = gfxObject.getBoundingBox();
		if(!bboxObject){//the gfx object is group
			var shapes = gfxObject.children;
			var bboxObject = dojo.clone(dgc._getRealBBox(shapes[0]));
			dojo.forEach(shapes, function(item){
				var nextBBox = dgc._getRealBBox(item);
				bboxObject.x = Math.min(bboxObject.x, nextBBox.x);
				bboxObject.y = Math.min(bboxObject.y, nextBBox.y);
				bboxObject.endX = Math.max(bboxObject.x + bboxObject.width, nextBBox.x + nextBBox.width);
				bboxObject.endY = Math.max(bboxObject.y + bboxObject.height, nextBBox.y + nextBBox.height);
			});
			bboxObject.width = bboxObject.endX - bboxObject.x;
			bboxObject.height = bboxObject.endY - bboxObject.y;
		}
		return bboxObject;
	};
})();

}

}};});