1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | (function webpackUniversalModuleDefinition(root, factory) {
|
13 | if(typeof exports === 'object' && typeof module === 'object')
|
14 | module.exports = factory(require("d3-selection"));
|
15 | else if(typeof define === 'function' && define.amd)
|
16 | define("bb", ["d3-selection"], factory);
|
17 | else if(typeof exports === 'object')
|
18 | exports["bb"] = factory(require("d3-selection"));
|
19 | else
|
20 | root["bb"] = root["bb"] || {}, root["bb"]["plugin"] = root["bb"]["plugin"] || {}, root["bb"]["plugin"]["bubblecompare"] = factory(root["d3"]);
|
21 | })(this, function(__WEBPACK_EXTERNAL_MODULE__1__) {
|
22 | return (function() {
|
23 | "use strict";
|
24 | var __webpack_modules__ = ([
|
25 | ,
|
26 |
|
27 | (function(module) {
|
28 |
|
29 | module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
|
30 |
|
31 | })
|
32 | ]);
|
33 |
|
34 |
|
35 | var __webpack_module_cache__ = {};
|
36 |
|
37 |
|
38 | function __webpack_require__(moduleId) {
|
39 |
|
40 | var cachedModule = __webpack_module_cache__[moduleId];
|
41 | if (cachedModule !== undefined) {
|
42 | return cachedModule.exports;
|
43 | }
|
44 |
|
45 | var module = __webpack_module_cache__[moduleId] = {
|
46 |
|
47 |
|
48 | exports: {}
|
49 | };
|
50 |
|
51 |
|
52 | __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
53 |
|
54 |
|
55 | return module.exports;
|
56 | }
|
57 |
|
58 |
|
59 |
|
60 | !function() {
|
61 |
|
62 | __webpack_require__.d = function(exports, definition) {
|
63 | for(var key in definition) {
|
64 | if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
65 | Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
66 | }
|
67 | }
|
68 | };
|
69 | }();
|
70 |
|
71 |
|
72 | !function() {
|
73 | __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
74 | }();
|
75 |
|
76 |
|
77 | var __webpack_exports__ = {};
|
78 |
|
79 | !function() {
|
80 |
|
81 |
|
82 | __webpack_require__.d(__webpack_exports__, {
|
83 | "default": function() { return BubbleCompare; }
|
84 | });
|
85 |
|
86 |
|
87 | var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(1);
|
88 | ;
|
89 | var __defProp = Object.defineProperty;
|
90 | var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
91 | var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
92 | class Plugin {
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 | constructor(options = {}) {
|
99 | __publicField(this, "$$");
|
100 | __publicField(this, "options");
|
101 | this.options = options;
|
102 | }
|
103 | |
104 |
|
105 |
|
106 |
|
107 | $beforeInit() {
|
108 | }
|
109 | |
110 |
|
111 |
|
112 |
|
113 | $init() {
|
114 | }
|
115 | |
116 |
|
117 |
|
118 |
|
119 | $afterInit() {
|
120 | }
|
121 | |
122 |
|
123 |
|
124 |
|
125 | $redraw() {
|
126 | }
|
127 | |
128 |
|
129 |
|
130 |
|
131 | $willDestroy() {
|
132 | Object.keys(this).forEach((key) => {
|
133 | this[key] = null;
|
134 | delete this[key];
|
135 | });
|
136 | }
|
137 | }
|
138 | __publicField(Plugin, "version", "3.14.2");
|
139 |
|
140 | ;
|
141 | var bubblecompare_defProp = Object.defineProperty;
|
142 | var bubblecompare_defNormalProp = (obj, key, value) => key in obj ? bubblecompare_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
143 | var bubblecompare_publicField = (obj, key, value) => bubblecompare_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
144 |
|
145 |
|
146 | const _BubbleCompare = class _BubbleCompare extends Plugin {
|
147 | constructor(options) {
|
148 | super(options);
|
149 | bubblecompare_publicField(this, "$$");
|
150 | return this;
|
151 | }
|
152 | $init() {
|
153 | const { $$ } = this;
|
154 | $$.findClosest = this.findClosest.bind(this);
|
155 | $$.getBubbleR = this.getBubbleR.bind(this);
|
156 | $$.pointExpandedR = this.pointExpandedR.bind(this);
|
157 | }
|
158 | pointExpandedR(d) {
|
159 | const baseR = this.getBubbleR(d);
|
160 | const { expandScale = 1 } = this.options;
|
161 | _BubbleCompare.raiseFocusedBubbleLayer(d);
|
162 | this.changeCursorPoint();
|
163 | return baseR * expandScale;
|
164 | }
|
165 | static raiseFocusedBubbleLayer(d) {
|
166 | d.raise && (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(d.node().parentNode.parentNode).raise();
|
167 | }
|
168 | changeCursorPoint() {
|
169 | this.$$.$el.eventRect.style("cursor", "pointer");
|
170 | }
|
171 | findClosest(values, pos) {
|
172 | const { $$ } = this;
|
173 | return values.filter((v) => v && !$$.isBarType(v.id)).reduce((acc, cur) => {
|
174 | const d = $$.dist(cur, pos);
|
175 | return d < this.getBubbleR(cur) ? cur : acc;
|
176 | }, 0);
|
177 | }
|
178 | getBubbleR(d) {
|
179 | const { minR, maxR } = this.options;
|
180 | const curVal = this.getZData(d);
|
181 | if (!curVal) return minR;
|
182 | const [min, max] = this.$$.data.targets.reduce(
|
183 | ([accMin, accMax], cur) => {
|
184 | const val = this.getZData(cur.values[0]);
|
185 | return [Math.min(accMin, val), Math.max(accMax, val)];
|
186 | },
|
187 | [1e4, 0]
|
188 | );
|
189 | const size = min > 0 && max === min ? 0 : curVal / max;
|
190 | return Math.abs(size) * (maxR - minR) + minR;
|
191 | }
|
192 | getZData(d) {
|
193 | return this.$$.isBubbleZType(d) ? this.$$.getBubbleZData(d.value, "z") : d.value;
|
194 | }
|
195 | };
|
196 | bubblecompare_publicField(_BubbleCompare, "version", `0.0.1`);
|
197 | let BubbleCompare = _BubbleCompare;
|
198 |
|
199 |
|
200 | }();
|
201 | __webpack_exports__ = __webpack_exports__["default"];
|
202 | return __webpack_exports__;
|
203 | })()
|
204 | ;
|
205 | }); |
\ | No newline at end of file |