Debian Codegraph @

dojox/geo/charting/_base.js

raw symbols SCIP
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(/*String*/innerHTML, /*dojox/gfx/shape.Shape*/ gfxObject, /*String[]?*/ positions){
15 // summary:
16 // Show a Tooltip displaying the given HTML message around the given gfx shape.
17 // innerHTML: String
18 // The message to display as a HTML string.
19 // gfxObject: dojox/gfx/shape.Shape
20 // The gfx shape around which the tooltip will be placed.
21 // position: String[]?
22 // The tooltip position.
23 var arroundNode = dgc._normalizeArround(gfxObject);
24 return Tooltip.show(innerHTML, arroundNode, positions);
25 };
26
27 dgc.hideTooltip = function( /*dojox/gfx/shape.Shape*/gfxObject){
28 // summary:
29 // Hides the tooltip displayed around the given shape.
30 // gfxObject: dojox.gfx.shape.Shape
31 // A gfx shape.
32 return Tooltip.hide(gfxObject);
33 };
34
35 dgc._normalizeArround = function(gfxObject){
36 var bbox = dgc._getRealBBox(gfxObject);
37 //var bbox = gfxObject.getBoundingBox();
38 //get the real screen coords for gfx object
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){//the gfx object is group
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 });