Mercurial > repos > other > exif-graphr
annotate d3.tip.js @ 11:aaf1d6954a2a default tip
Ensure we always have data dir for ExifGraphr cache
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 13 Aug 2023 16:56:40 +0100 |
parents | a11817a35877 |
children |
rev | line source |
---|---|
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // d3.tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // Copyright (c) 2013 Justin Palmer |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 // Tooltips for d3.js SVG visualizations |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 (function (root, factory) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 if (typeof define === 'function' && define.amd) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 // AMD. Register as an anonymous module with d3 as a dependency. |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 define(['d3'], factory) |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
10 } else if (typeof module === 'object' && module.exports) { |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
11 // CommonJS |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
12 var d3 = require('d3') |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
13 module.exports = factory(d3) |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 } else { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 // Browser global. |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 root.d3.tip = factory(root.d3) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 }(this, function (d3) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 // Public - contructs a new tooltip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 // Returns a tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 return function() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 var direction = d3_tip_direction, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 offset = d3_tip_offset, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 html = d3_tip_html, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 node = initNode(), |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 svg = null, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 point = null, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 target = null |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 function tip(vis) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 svg = getSVGNode(vis) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 point = svg.createSVGPoint() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 document.body.appendChild(node) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 // Public - show the tooltip on the screen |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 // Returns a tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 tip.show = function() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 var args = Array.prototype.slice.call(arguments) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 if(args[args.length - 1] instanceof SVGElement) target = args.pop() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 var content = html.apply(this, args), |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 poffset = offset.apply(this, args), |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 dir = direction.apply(this, args), |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
48 nodel = getNodeEl(), |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 i = directions.length, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 coords, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 scrollTop = document.documentElement.scrollTop || document.body.scrollTop, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 nodel.html(content) |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
55 .style('opacity', 1).style('pointer-events', 'all') |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 while(i--) nodel.classed(directions[i], false) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 coords = direction_callbacks.get(dir).apply(this) |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
59 nodel.classed(dir, true) |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
60 .style('top', (coords.top + poffset[0]) + scrollTop + 'px') |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
61 .style('left', (coords.left + poffset[1]) + scrollLeft + 'px') |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
63 return tip; |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
64 }; |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 // Public - hide the tooltip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 // Returns a tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 tip.hide = function() { |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
70 var nodel = getNodeEl() |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
71 nodel.style('opacity', 0).style('pointer-events', 'none') |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 return tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 // Public: Proxy attr calls to the d3 tip container. Sets or gets attribute value. |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 // n - name of the attribute |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 // v - value of the attribute |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 // Returns tip or attribute value |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 tip.attr = function(n, v) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 if (arguments.length < 2 && typeof n === 'string') { |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
83 return getNodeEl().attr(n) |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 } else { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 var args = Array.prototype.slice.call(arguments) |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
86 d3.selection.prototype.attr.apply(getNodeEl(), args) |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
88 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 return tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
91 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
92 // Public: Proxy style calls to the d3 tip container. Sets or gets a style value. |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
93 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
94 // n - name of the property |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
95 // v - value of the property |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
96 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
97 // Returns tip or style property value |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
98 tip.style = function(n, v) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
99 if (arguments.length < 2 && typeof n === 'string') { |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
100 return getNodeEl().style(n) |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 } else { |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
102 var args = Array.prototype.slice.call(arguments) |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
103 d3.selection.prototype.style.apply(getNodeEl(), args) |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
104 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
105 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
106 return tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
107 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
108 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
109 // Public: Set or get the direction of the tooltip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
110 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
111 // v - One of n(north), s(south), e(east), or w(west), nw(northwest), |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
112 // sw(southwest), ne(northeast) or se(southeast) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
113 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
114 // Returns tip or direction |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
115 tip.direction = function(v) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
116 if (!arguments.length) return direction |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
117 direction = v == null ? v : functor(v) |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
118 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
119 return tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
120 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
121 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
122 // Public: Sets or gets the offset of the tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
123 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
124 // v - Array of [x, y] offset |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
125 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
126 // Returns offset or |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
127 tip.offset = function(v) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
128 if (!arguments.length) return offset |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
129 offset = v == null ? v : functor(v) |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
130 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
131 return tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
132 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
133 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 // Public: sets or gets the html value of the tooltip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
135 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
136 // v - String value of the tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
137 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
138 // Returns html value or tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
139 tip.html = function(v) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
140 if (!arguments.length) return html |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
141 html = v == null ? v : functor(v) |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
142 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
143 return tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
144 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
145 |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
146 // Public: destroys the tooltip and removes it from the DOM |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
147 // |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
148 // Returns a tip |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
149 tip.destroy = function() { |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
150 if(node) { |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
151 getNodeEl().remove(); |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
152 node = null; |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
153 } |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
154 return tip; |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
155 } |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
156 |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
157 function d3_tip_direction() { return 'n' } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
158 function d3_tip_offset() { return [0, 0] } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
159 function d3_tip_html() { return ' ' } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
160 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
161 var direction_callbacks = d3.map({ |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
162 n: direction_n, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
163 s: direction_s, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
164 e: direction_e, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
165 w: direction_w, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
166 nw: direction_nw, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
167 ne: direction_ne, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
168 sw: direction_sw, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 se: direction_se |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
170 }), |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
171 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 directions = direction_callbacks.keys() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
173 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
174 function direction_n() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
175 var bbox = getScreenBBox() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
176 return { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
177 top: bbox.n.y - node.offsetHeight, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 left: bbox.n.x - node.offsetWidth / 2 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
179 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
180 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
181 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
182 function direction_s() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
183 var bbox = getScreenBBox() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
184 return { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
185 top: bbox.s.y, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
186 left: bbox.s.x - node.offsetWidth / 2 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
187 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
188 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
189 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
190 function direction_e() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
191 var bbox = getScreenBBox() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
192 return { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
193 top: bbox.e.y - node.offsetHeight / 2, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
194 left: bbox.e.x |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
195 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
196 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
197 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
198 function direction_w() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
199 var bbox = getScreenBBox() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
200 return { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
201 top: bbox.w.y - node.offsetHeight / 2, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
202 left: bbox.w.x - node.offsetWidth |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
203 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
204 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
205 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
206 function direction_nw() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
207 var bbox = getScreenBBox() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
208 return { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
209 top: bbox.nw.y - node.offsetHeight, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
210 left: bbox.nw.x - node.offsetWidth |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
211 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
212 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
213 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
214 function direction_ne() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
215 var bbox = getScreenBBox() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
216 return { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
217 top: bbox.ne.y - node.offsetHeight, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
218 left: bbox.ne.x |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
219 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
220 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
221 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
222 function direction_sw() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
223 var bbox = getScreenBBox() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
224 return { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
225 top: bbox.sw.y, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
226 left: bbox.sw.x - node.offsetWidth |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
227 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
228 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
229 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
230 function direction_se() { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
231 var bbox = getScreenBBox() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
232 return { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
233 top: bbox.se.y, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
234 left: bbox.e.x |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
235 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
236 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
237 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
238 function initNode() { |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
239 var node = d3.select(document.createElement('div')); |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
240 node.style('position', 'absolute').style('top', 0).style('opacity', 0) |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
241 .style('pointer-events', 'none').style('box-sizing', 'border-box') |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
242 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
243 return node.node() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
244 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
245 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
246 function getSVGNode(el) { |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
247 el = el.node() |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
248 if(el.tagName.toLowerCase() === 'svg') |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
249 return el |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
250 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
251 return el.ownerSVGElement |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
252 } |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
253 |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
254 function getNodeEl() { |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
255 if(node === null) { |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
256 node = initNode(); |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
257 // re-add node to DOM |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
258 document.body.appendChild(node); |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
259 }; |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
260 return d3.select(node); |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
261 } |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
262 |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
263 // Private - gets the screen coordinates of a shape |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
264 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
265 // Given a shape on the screen, will return an SVGPoint for the directions |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
266 // n(north), s(south), e(east), w(west), ne(northeast), se(southeast), nw(northwest), |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
267 // sw(southwest). |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
268 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
269 // +-+-+ |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
270 // | | |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
271 // + + |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
272 // | | |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
273 // +-+-+ |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
274 // |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
275 // Returns an Object {n, s, e, w, nw, sw, ne, se} |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
276 function getScreenBBox() { |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
277 var targetel = target || d3.event.target; |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
278 |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
279 while ('undefined' === typeof targetel.getScreenCTM && 'undefined' === targetel.parentNode) { |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
280 targetel = targetel.parentNode; |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
281 } |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
282 |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
283 var bbox = {}, |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
284 matrix = targetel.getScreenCTM(), |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
285 tbbox = targetel.getBBox(), |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
286 width = tbbox.width, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
287 height = tbbox.height, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
288 x = tbbox.x, |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
289 y = tbbox.y |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
290 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
291 point.x = x |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
292 point.y = y |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
293 bbox.nw = point.matrixTransform(matrix) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
294 point.x += width |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
295 bbox.ne = point.matrixTransform(matrix) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
296 point.y += height |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
297 bbox.se = point.matrixTransform(matrix) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
298 point.x -= width |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
299 bbox.sw = point.matrixTransform(matrix) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
300 point.y -= height / 2 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
301 bbox.w = point.matrixTransform(matrix) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
302 point.x += width |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
303 bbox.e = point.matrixTransform(matrix) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
304 point.x -= width / 2 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
305 point.y -= height / 2 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
306 bbox.n = point.matrixTransform(matrix) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
307 point.y += height |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
308 bbox.s = point.matrixTransform(matrix) |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
309 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
310 return bbox |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
311 } |
1
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
312 |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
313 // Private - replace D3JS 3.X d3.functor() function |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
314 function functor(v) { |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
315 return typeof v === "function" ? v : function() { |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
316 return v |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
317 } |
a11817a35877
Update to D3js v4.9.1 and newer D3-tooltip
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
318 } |
0
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
319 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
320 return tip |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
321 }; |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
322 |
42c058ce5b7c
Initial public commit of Exif-Graphr
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
323 })); |