| 1 |
define([ |
| 2 |
"dojo/_base/lang", |
| 3 |
"dojo/_base/array", |
| 4 |
"../../main", |
| 5 |
"dojo/_base/html", |
| 6 |
"dojo/dom-geometry", |
| 7 |
"dojox/gfx/matrix", |
| 8 |
"dijit/Tooltip", |
| 9 |
"dojo/_base/NodeList", |
| 10 |
"dojo/NodeList-traverse" |
| 11 |
], function(lang, arr, dojox, html, domGeom, matrix, Tooltip, NodeList, NodeListTraverse){ |
| 12 |
var dgc = lang.getObject("geo.charting", true, dojox); |
| 13 |
|
| 14 |
dgc.showTooltip = function(innerHTML, gfxObject, positions){ |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
var arroundNode = dgc._normalizeArround(gfxObject); |
| 24 |
return Tooltip.show(innerHTML, arroundNode, positions); |
| 25 |
}; |
| 26 |
|
| 27 |
dgc.hideTooltip = function( gfxObject){ |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
return Tooltip.hide(gfxObject); |
| 33 |
}; |
| 34 |
|
| 35 |
dgc._normalizeArround = function(gfxObject){ |
| 36 |
var bbox = dgc._getRealBBox(gfxObject); |
| 37 |
|
| 38 |
|
| 39 |
var realMatrix = gfxObject._getRealMatrix() || {xx:1,xy:0,yx:0,yy:1,dx:0,dy:0}; |
| 40 |
var point = matrix.multiplyPoint(realMatrix, bbox.x, bbox.y); |
| 41 |
var gfxDomContainer = dgc._getGfxContainer(gfxObject); |
| 42 |
gfxObject.x = domGeom.position(gfxDomContainer,true).x + point.x, |
| 43 |
gfxObject.y = domGeom.position(gfxDomContainer,true).y + point.y, |
| 44 |
gfxObject.w = bbox.width * realMatrix.xx, |
| 45 |
gfxObject.h = bbox.height * realMatrix.yy |
| 46 |
return gfxObject; |
| 47 |
}; |
| 48 |
|
| 49 |
dgc._getGfxContainer = function(gfxObject){ |
| 50 |
if(gfxObject.surface){ |
| 51 |
return (new NodeList(gfxObject.surface.rawNode)).parents("div")[0]; |
| 52 |
}else{ |
| 53 |
return (new NodeList(gfxObject.rawNode)).parents("div")[0]; |
| 54 |
} |
| 55 |
}; |
| 56 |
|
| 57 |
dgc._getRealBBox = function(gfxObject){ |
| 58 |
var bboxObject = gfxObject.getBoundingBox(); |
| 59 |
if(!bboxObject){ |
| 60 |
var shapes = gfxObject.children; |
| 61 |
bboxObject = lang.clone(dgc._getRealBBox(shapes[0])); |
| 62 |
arr.forEach(shapes, function(item){ |
| 63 |
var nextBBox = dgc._getRealBBox(item); |
| 64 |
bboxObject.x = Math.min(bboxObject.x, nextBBox.x); |
| 65 |
bboxObject.y = Math.min(bboxObject.y, nextBBox.y); |
| 66 |
bboxObject.endX = Math.max(bboxObject.x + bboxObject.width, nextBBox.x + nextBBox.width); |
| 67 |
bboxObject.endY = Math.max(bboxObject.y + bboxObject.height, nextBBox.y + nextBBox.height); |
| 68 |
}); |
| 69 |
bboxObject.width = bboxObject.endX - bboxObject.x; |
| 70 |
bboxObject.height = bboxObject.endY - bboxObject.y; |
| 71 |
} |
| 72 |
return bboxObject; |
| 73 |
}; |
| 74 |
|
| 75 |
return dgc; |
| 76 |
}); |