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-delaunay"), require("d3-polygon"), require("d3-selection"), require("d3-brush"));
|
15 | else if(typeof define === 'function' && define.amd)
|
16 | define("bb", ["d3-delaunay", "d3-polygon", "d3-selection", "d3-brush"], factory);
|
17 | else if(typeof exports === 'object')
|
18 | exports["bb"] = factory(require("d3-delaunay"), require("d3-polygon"), require("d3-selection"), require("d3-brush"));
|
19 | else
|
20 | root["bb"] = root["bb"] || {}, root["bb"]["plugin"] = root["bb"]["plugin"] || {}, root["bb"]["plugin"]["textoverlap"] = factory(root["d3"], root["d3"], root["d3"], root["d3"]);
|
21 | })(this, function(__WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__13__, __WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__3__) {
|
22 | return (function() {
|
23 | "use strict";
|
24 | var __webpack_modules__ = ({
|
25 |
|
26 | 3:
|
27 | (function(module) {
|
28 |
|
29 | module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
|
30 |
|
31 | }),
|
32 |
|
33 | 12:
|
34 | (function(module) {
|
35 |
|
36 | module.exports = __WEBPACK_EXTERNAL_MODULE__12__;
|
37 |
|
38 | }),
|
39 |
|
40 | 13:
|
41 | (function(module) {
|
42 |
|
43 | module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
|
44 |
|
45 | }),
|
46 |
|
47 | 1:
|
48 | (function(module) {
|
49 |
|
50 | module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
|
51 |
|
52 | })
|
53 |
|
54 | });
|
55 |
|
56 |
|
57 | var __webpack_module_cache__ = {};
|
58 |
|
59 |
|
60 | function __webpack_require__(moduleId) {
|
61 |
|
62 | var cachedModule = __webpack_module_cache__[moduleId];
|
63 | if (cachedModule !== undefined) {
|
64 | return cachedModule.exports;
|
65 | }
|
66 |
|
67 | var module = __webpack_module_cache__[moduleId] = {
|
68 |
|
69 |
|
70 | exports: {}
|
71 | };
|
72 |
|
73 |
|
74 | __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
75 |
|
76 |
|
77 | return module.exports;
|
78 | }
|
79 |
|
80 |
|
81 |
|
82 | !function() {
|
83 |
|
84 | __webpack_require__.d = function(exports, definition) {
|
85 | for(var key in definition) {
|
86 | if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
87 | Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
88 | }
|
89 | }
|
90 | };
|
91 | }();
|
92 |
|
93 |
|
94 | !function() {
|
95 | __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
96 | }();
|
97 |
|
98 |
|
99 | var __webpack_exports__ = {};
|
100 |
|
101 | !function() {
|
102 |
|
103 |
|
104 | __webpack_require__.d(__webpack_exports__, {
|
105 | "default": function() { return TextOverlap; }
|
106 | });
|
107 |
|
108 | ;
|
109 | function _newArrowCheck(innerThis, boundThis) {
|
110 | if (innerThis !== boundThis) {
|
111 | throw new TypeError("Cannot instantiate an arrow function");
|
112 | }
|
113 | }
|
114 | ;
|
115 | function _assertThisInitialized(self) {
|
116 | if (self === void 0) {
|
117 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
118 | }
|
119 | return self;
|
120 | }
|
121 | ;
|
122 | function _setPrototypeOf(o, p) {
|
123 | _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
124 | o.__proto__ = p;
|
125 | return o;
|
126 | };
|
127 | return _setPrototypeOf(o, p);
|
128 | }
|
129 | ;
|
130 |
|
131 | function _inheritsLoose(subClass, superClass) {
|
132 | subClass.prototype = Object.create(superClass.prototype);
|
133 | subClass.prototype.constructor = subClass;
|
134 | _setPrototypeOf(subClass, superClass);
|
135 | }
|
136 |
|
137 | var external_commonjs_d3_delaunay_commonjs2_d3_delaunay_amd_d3_delaunay_root_d3_ = __webpack_require__(12);
|
138 |
|
139 | var external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_ = __webpack_require__(13);
|
140 | ;
|
141 | function _defineProperty(obj, key, value) {
|
142 | if (key in obj) {
|
143 | Object.defineProperty(obj, key, {
|
144 | value: value,
|
145 | enumerable: true,
|
146 | configurable: true,
|
147 | writable: true
|
148 | });
|
149 | } else {
|
150 | obj[key] = value;
|
151 | }
|
152 | return obj;
|
153 | }
|
154 |
|
155 | var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(1);
|
156 |
|
157 | var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(3);
|
158 | ;
|
159 |
|
160 | var _this = undefined;
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 | var win = function () {
|
172 | _newArrowCheck(this, _this);
|
173 | var root = typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis || typeof global === "object" && global !== null && global.Object === Object && global || typeof self === "object" && self !== null && self.Object === Object && self;
|
174 | return root || Function("return this")();
|
175 | }.bind(undefined)();
|
176 |
|
177 |
|
178 |
|
179 | win.requestIdleCallback = win.requestIdleCallback || function (cb) {
|
180 | _newArrowCheck(this, _this);
|
181 | return setTimeout(cb, 1);
|
182 | }.bind(undefined);
|
183 |
|
184 | win.requestAnimationFrame = win.requestAnimationFrame || function (cb) {
|
185 | _newArrowCheck(this, _this);
|
186 | return setTimeout(cb, 1);
|
187 | }.bind(undefined);
|
188 | var doc = win == null ? void 0 : win.document;
|
189 | ;
|
190 |
|
191 |
|
192 | var util_this = undefined;
|
193 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
194 | function _objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 | var isValue = function (v) {
|
205 | _newArrowCheck(this, util_this);
|
206 | return v || v === 0;
|
207 | }.bind(undefined),
|
208 | isFunction = function (v) {
|
209 | _newArrowCheck(this, util_this);
|
210 | return typeof v === "function";
|
211 | }.bind(undefined),
|
212 | isString = function (v) {
|
213 | _newArrowCheck(this, util_this);
|
214 | return typeof v === "string";
|
215 | }.bind(undefined),
|
216 | isNumber = function (v) {
|
217 | _newArrowCheck(this, util_this);
|
218 | return typeof v === "number";
|
219 | }.bind(undefined),
|
220 | isUndefined = function (v) {
|
221 | _newArrowCheck(this, util_this);
|
222 | return typeof v === "undefined";
|
223 | }.bind(undefined),
|
224 | isDefined = function (v) {
|
225 | _newArrowCheck(this, util_this);
|
226 | return typeof v !== "undefined";
|
227 | }.bind(undefined),
|
228 | isboolean = function (v) {
|
229 | _newArrowCheck(this, util_this);
|
230 | return typeof v === "boolean";
|
231 | }.bind(undefined),
|
232 | ceil10 = function (v) {
|
233 | _newArrowCheck(this, util_this);
|
234 | return Math.ceil(v / 10) * 10;
|
235 | }.bind(undefined),
|
236 | asHalfPixel = function (n) {
|
237 | _newArrowCheck(this, util_this);
|
238 | return Math.ceil(n) + .5;
|
239 | }.bind(undefined),
|
240 | diffDomain = function (d) {
|
241 | _newArrowCheck(this, util_this);
|
242 | return d[1] - d[0];
|
243 | }.bind(undefined),
|
244 | isObjectType = function (v) {
|
245 | _newArrowCheck(this, util_this);
|
246 | return typeof v === "object";
|
247 | }.bind(undefined),
|
248 | isEmpty = function (o) {
|
249 | _newArrowCheck(this, util_this);
|
250 | return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
|
251 | }.bind(undefined),
|
252 | notEmpty = function (o) {
|
253 | _newArrowCheck(this, util_this);
|
254 | return !isEmpty(o);
|
255 | }.bind(undefined),
|
256 | isArray = function (arr) {
|
257 | _newArrowCheck(this, util_this);
|
258 | return Array.isArray(arr);
|
259 | }.bind(undefined),
|
260 | isObject = function (obj) {
|
261 | _newArrowCheck(this, util_this);
|
262 | return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
|
263 | }.bind(undefined);
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 | function getOption(options, key, defaultValue) {
|
274 | return isDefined(options[key]) ? options[key] : defaultValue;
|
275 | }
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 | function hasValue(dict, value) {
|
285 | var _this2 = this,
|
286 | found = !1;
|
287 | Object.keys(dict).forEach(function (key) {
|
288 | _newArrowCheck(this, _this2);
|
289 | return dict[key] === value && (found = !0);
|
290 | }.bind(this));
|
291 | return found;
|
292 | }
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 | function callFn(fn, thisArg) {
|
303 | for (var isFn = isFunction(fn), _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
304 | args[_key - 2] = arguments[_key];
|
305 | }
|
306 | isFn && fn.call.apply(fn, [thisArg].concat(args));
|
307 | return isFn;
|
308 | }
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 | function endall(transition, cb) {
|
317 | var _this3 = this,
|
318 | n = 0,
|
319 | end = function () {
|
320 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
321 | args[_key2] = arguments[_key2];
|
322 | }
|
323 | --n || cb.apply.apply(cb, [this].concat(args));
|
324 | };
|
325 |
|
326 | if ("duration" in transition) {
|
327 | transition.each(function () {
|
328 | _newArrowCheck(this, _this3);
|
329 | return ++n;
|
330 | }.bind(this)).on("end", end);
|
331 | } else {
|
332 | ++n;
|
333 | transition.call(end);
|
334 | }
|
335 | }
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 | function sanitise(str) {
|
344 | return isString(str) ? str.replace(/</g, "<").replace(/>/g, ">") : str;
|
345 | }
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 | function setTextValue(node, text, dy, toMiddle) {
|
356 | var _this4 = this;
|
357 | if (dy === void 0) {
|
358 | dy = [-1, 1];
|
359 | }
|
360 | if (toMiddle === void 0) {
|
361 | toMiddle = !1;
|
362 | }
|
363 | if (!node || !isString(text)) {
|
364 | return;
|
365 | }
|
366 | if (text.indexOf("\n") === -1) {
|
367 | node.text(text);
|
368 | } else {
|
369 | var diff = [node.text(), text].map(function (v) {
|
370 | _newArrowCheck(this, _this4);
|
371 | return v.replace(/[\s\n]/g, "");
|
372 | }.bind(this));
|
373 | if (diff[0] !== diff[1]) {
|
374 | var multiline = text.split("\n"),
|
375 | len = toMiddle ? multiline.length - 1 : 1;
|
376 |
|
377 | node.html("");
|
378 | multiline.forEach(function (v, i) {
|
379 | _newArrowCheck(this, _this4);
|
380 | node.append("tspan").attr("x", 0).attr("dy", (i === 0 ? dy[0] * len : dy[1]) + "em").text(v);
|
381 | }.bind(this));
|
382 | }
|
383 | }
|
384 | }
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 | function getRectSegList(path) {
|
393 | |
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 | var _path$getBBox = path.getBBox(),
|
401 | x = _path$getBBox.x,
|
402 | y = _path$getBBox.y,
|
403 | width = _path$getBBox.width,
|
404 | height = _path$getBBox.height;
|
405 | return [{
|
406 | x: x,
|
407 | y: y + height
|
408 | },
|
409 |
|
410 | {
|
411 | x: x,
|
412 | y: y
|
413 | },
|
414 |
|
415 | {
|
416 | x: x + width,
|
417 | y: y
|
418 | },
|
419 |
|
420 | {
|
421 | x: x + width,
|
422 | y: y + height
|
423 | }
|
424 | ];
|
425 | }
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 | function getPathBox(path) {
|
434 | var _path$getBoundingClie = path.getBoundingClientRect(),
|
435 | width = _path$getBoundingClie.width,
|
436 | height = _path$getBoundingClie.height,
|
437 | items = getRectSegList(path),
|
438 | x = items[0].x,
|
439 | y = Math.min(items[0].y, items[1].y);
|
440 | return {
|
441 | x: x,
|
442 | y: y,
|
443 | width: width,
|
444 | height: height
|
445 | };
|
446 | }
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 | function getPointer(event, element) {
|
456 | var _ref,
|
457 | touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]),
|
458 | pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element),
|
459 | _this5 = this;
|
460 | return pointer.map(function (v) {
|
461 | _newArrowCheck(this, _this5);
|
462 | return isNaN(v) ? 0 : v;
|
463 | }.bind(this));
|
464 | }
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 | function getBrushSelection(ctx) {
|
473 | var event = ctx.event,
|
474 | $el = ctx.$el,
|
475 | main = $el.subchart.main || $el.main,
|
476 | selection;
|
477 |
|
478 | if (event && event.type === "brush") {
|
479 | selection = event.selection;
|
480 |
|
481 | } else if (main && (selection = main.select(".bb-brush").node())) {
|
482 | selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection);
|
483 | }
|
484 | return selection;
|
485 | }
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 | function getBoundingRect(node) {
|
495 | var needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
|
496 | return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
|
497 | }
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 | function getRandom(asStr, min, max) {
|
508 | if (asStr === void 0) {
|
509 | asStr = !0;
|
510 | }
|
511 | if (min === void 0) {
|
512 | min = 0;
|
513 | }
|
514 | if (max === void 0) {
|
515 | max = 1e4;
|
516 | }
|
517 | var rand = Math.floor(Math.random() * (max - min) + min);
|
518 | return asStr ? rand + "" : rand;
|
519 | }
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 | function findIndex(arr, v, start, end, isRotated) {
|
532 | if (start > end) {
|
533 | return -1;
|
534 | }
|
535 | var mid = Math.floor((start + end) / 2),
|
536 | _arr$mid = arr[mid],
|
537 | x = _arr$mid.x,
|
538 | _arr$mid$w = _arr$mid.w,
|
539 | w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
|
540 | if (isRotated) {
|
541 | x = arr[mid].y;
|
542 | w = arr[mid].h;
|
543 | }
|
544 | if (v >= x && v <= x + w) {
|
545 | return mid;
|
546 | }
|
547 | return v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
|
548 | }
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 | function brushEmpty(ctx) {
|
557 | var selection = getBrushSelection(ctx);
|
558 | if (selection) {
|
559 |
|
560 |
|
561 |
|
562 | return selection[0] === selection[1];
|
563 | }
|
564 | return !0;
|
565 | }
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 | function deepClone() {
|
574 | for (var _this6 = this, clone = function (v) {
|
575 | _newArrowCheck(this, _this6);
|
576 | if (isObject(v) && v.constructor) {
|
577 | var r = new v.constructor();
|
578 | for (var k in v) {
|
579 | r[k] = clone(v[k]);
|
580 | }
|
581 | return r;
|
582 | }
|
583 | return v;
|
584 | }.bind(this), _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
585 | objectN[_key3] = arguments[_key3];
|
586 | }
|
587 | return objectN.map(function (v) {
|
588 | _newArrowCheck(this, _this6);
|
589 | return clone(v);
|
590 | }.bind(this)).reduce(function (a, c) {
|
591 | _newArrowCheck(this, _this6);
|
592 | return _objectSpread(_objectSpread({}, a), c);
|
593 | }.bind(this));
|
594 | }
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 | function extend(target, source) {
|
604 | var _this7 = this;
|
605 | if (target === void 0) {
|
606 | target = {};
|
607 | }
|
608 | if (isArray(source)) {
|
609 | source.forEach(function (v) {
|
610 | _newArrowCheck(this, _this7);
|
611 | return extend(target, v);
|
612 | }.bind(this));
|
613 | }
|
614 |
|
615 |
|
616 | for (var p in source) {
|
617 | if (/^\d+$/.test(p) || p in target) {
|
618 | continue;
|
619 | }
|
620 | target[p] = source[p];
|
621 | }
|
622 | return target;
|
623 | }
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 | var capitalize = function (str) {
|
632 | _newArrowCheck(this, util_this);
|
633 | return str.charAt(0).toUpperCase() + str.slice(1);
|
634 | }.bind(undefined);
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 | function camelize(str, separator) {
|
644 | var _this8 = this;
|
645 | if (separator === void 0) {
|
646 | separator = "-";
|
647 | }
|
648 | return str.split(separator).map(function (v, i) {
|
649 | _newArrowCheck(this, _this8);
|
650 | return i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase();
|
651 | }.bind(this)).join("");
|
652 | }
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 | var toArray = function (v) {
|
661 | _newArrowCheck(this, util_this);
|
662 | return [].slice.call(v);
|
663 | }.bind(undefined);
|
664 |
|
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 | function addCssRules(style, selector, prop) {
|
674 | var _this9 = this,
|
675 | rootSelctor = style.rootSelctor,
|
676 | sheet = style.sheet,
|
677 | getSelector = function (s) {
|
678 | _newArrowCheck(this, _this9);
|
679 | return s.replace(/\s?(bb-)/g, ".$1").replace(/\.+/g, ".");
|
680 | }.bind(this),
|
681 | rule = rootSelctor + " " + getSelector(selector) + " {" + prop.join(";") + "}";
|
682 | return sheet[sheet.insertRule ? "insertRule" : "addRule"](rule, sheet.cssRules.length);
|
683 | }
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 |
|
691 | function getCssRules(styleSheets) {
|
692 | var _this10 = this,
|
693 | rules = [];
|
694 | styleSheets.forEach(function (sheet) {
|
695 | _newArrowCheck(this, _this10);
|
696 | try {
|
697 | if (sheet.cssRules && sheet.cssRules.length) {
|
698 | rules = rules.concat(toArray(sheet.cssRules));
|
699 | }
|
700 | } catch (e) {
|
701 | console.error("Error while reading rules from " + sheet.href + ": " + e.toString());
|
702 | }
|
703 | }.bind(this));
|
704 | return rules;
|
705 | }
|
706 |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 |
|
713 | function getTranslation(node) {
|
714 | var transform = node ? node.transform : null,
|
715 | baseVal = transform && transform.baseVal;
|
716 | return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
|
717 | a: 0,
|
718 | b: 0,
|
719 | c: 0,
|
720 | d: 0,
|
721 | e: 0,
|
722 | f: 0
|
723 | };
|
724 | }
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 | function getUnique(data) {
|
733 | var _this11 = this,
|
734 | isDate = data[0] instanceof Date,
|
735 | d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
|
736 | _newArrowCheck(this, _this11);
|
737 | return self.indexOf(v) === i;
|
738 | }.bind(this));
|
739 | return isDate ? d.map(function (v) {
|
740 | _newArrowCheck(this, _this11);
|
741 | return new Date(v);
|
742 | }.bind(this)) : d;
|
743 | }
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 | function mergeArray(arr) {
|
752 | var _this12 = this;
|
753 | return arr && arr.length ? arr.reduce(function (p, c) {
|
754 | _newArrowCheck(this, _this12);
|
755 | return p.concat(c);
|
756 | }.bind(this)) : [];
|
757 | }
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 | function mergeObj(target) {
|
767 | for (var _this13 = this, _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
768 | objectN[_key4 - 1] = arguments[_key4];
|
769 | }
|
770 | if (!objectN.length || objectN.length === 1 && !objectN[0]) {
|
771 | return target;
|
772 | }
|
773 | var source = objectN.shift();
|
774 | if (isObject(target) && isObject(source)) {
|
775 | Object.keys(source).forEach(function (key) {
|
776 | _newArrowCheck(this, _this13);
|
777 | var value = source[key];
|
778 | if (isObject(value)) {
|
779 | target[key] || (target[key] = {});
|
780 | target[key] = mergeObj(target[key], value);
|
781 | } else {
|
782 | target[key] = isArray(value) ? value.concat() : value;
|
783 | }
|
784 | }.bind(this));
|
785 | }
|
786 | return mergeObj.apply(void 0, [target].concat(objectN));
|
787 | }
|
788 |
|
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 |
|
795 |
|
796 | function sortValue(data, isAsc) {
|
797 | var _this14 = this;
|
798 | if (isAsc === void 0) {
|
799 | isAsc = !0;
|
800 | }
|
801 | var fn;
|
802 | if (data[0] instanceof Date) {
|
803 | fn = isAsc ? function (a, b) {
|
804 | _newArrowCheck(this, _this14);
|
805 | return a - b;
|
806 | }.bind(this) : function (a, b) {
|
807 | _newArrowCheck(this, _this14);
|
808 | return b - a;
|
809 | }.bind(this);
|
810 | } else {
|
811 | if (isAsc && !data.every(isNaN)) {
|
812 | fn = function (a, b) {
|
813 | _newArrowCheck(this, _this14);
|
814 | return a - b;
|
815 | }.bind(this);
|
816 | } else if (!isAsc) {
|
817 | fn = function (a, b) {
|
818 | _newArrowCheck(this, _this14);
|
819 | return a > b && -1 || a < b && 1 || a === b && 0;
|
820 | }.bind(this);
|
821 | }
|
822 | }
|
823 | return data.concat().sort(fn);
|
824 | }
|
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 |
|
833 | function getMinMax(type, data) {
|
834 | var _this15 = this,
|
835 | res = data.filter(function (v) {
|
836 | _newArrowCheck(this, _this15);
|
837 | return notEmpty(v);
|
838 | }.bind(this));
|
839 | if (res.length) {
|
840 | if (isNumber(res[0])) {
|
841 | res = Math[type].apply(Math, res);
|
842 | } else if (res[0] instanceof Date) {
|
843 | res = sortValue(res, type === "min")[0];
|
844 | }
|
845 | } else {
|
846 | res = undefined;
|
847 | }
|
848 | return res;
|
849 | }
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 | var getRange = function (start, end, step) {
|
860 | if (step === void 0) {
|
861 | step = 1;
|
862 | }
|
863 | _newArrowCheck(this, util_this);
|
864 | var res = [],
|
865 | n = Math.max(0, Math.ceil((end - start) / step)) | 0;
|
866 | for (var i = start; i < n; i++) {
|
867 | res.push(start + i * step);
|
868 | }
|
869 | return res;
|
870 | }.bind(undefined),
|
871 | emulateEvent = {
|
872 | mouse: function () {
|
873 | var _this16 = this;
|
874 | _newArrowCheck(this, util_this);
|
875 | var getParams = function () {
|
876 | _newArrowCheck(this, _this16);
|
877 | return {
|
878 | bubbles: !1,
|
879 | cancelable: !1,
|
880 | screenX: 0,
|
881 | screenY: 0,
|
882 | clientX: 0,
|
883 | clientY: 0
|
884 | };
|
885 | }.bind(this);
|
886 | try {
|
887 |
|
888 | new MouseEvent("t");
|
889 | return function (el, eventType, params) {
|
890 | if (params === void 0) {
|
891 | params = getParams();
|
892 | }
|
893 | _newArrowCheck(this, _this16);
|
894 | el.dispatchEvent(new MouseEvent(eventType, params));
|
895 | }.bind(this);
|
896 | } catch (e) {
|
897 |
|
898 | return function (el, eventType, params) {
|
899 | if (params === void 0) {
|
900 | params = getParams();
|
901 | }
|
902 | _newArrowCheck(this, _this16);
|
903 | var mouseEvent = doc.createEvent("MouseEvent");
|
904 |
|
905 |
|
906 | mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0,
|
907 |
|
908 | params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null);
|
909 | el.dispatchEvent(mouseEvent);
|
910 | }.bind(this);
|
911 | }
|
912 | }.bind(undefined)(),
|
913 | touch: function touch(el, eventType, params) {
|
914 | _newArrowCheck(this, util_this);
|
915 | var touchObj = new Touch(mergeObj({
|
916 | identifier: Date.now(),
|
917 | target: el,
|
918 | radiusX: 2.5,
|
919 | radiusY: 2.5,
|
920 | rotationAngle: 10,
|
921 | force: .5
|
922 | }, params));
|
923 | el.dispatchEvent(new TouchEvent(eventType, {
|
924 | cancelable: !0,
|
925 | bubbles: !0,
|
926 | shiftKey: !0,
|
927 | touches: [touchObj],
|
928 | targetTouches: [],
|
929 | changedTouches: [touchObj]
|
930 | }));
|
931 | }.bind(undefined)
|
932 | };
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 | function tplProcess(tpl, data) {
|
941 | var res = tpl;
|
942 | for (var x in data) {
|
943 | res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
|
944 | }
|
945 | return res;
|
946 | }
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 | function parseDate(date) {
|
956 | var parsedDate;
|
957 | if (date instanceof Date) {
|
958 | parsedDate = date;
|
959 | } else if (isString(date)) {
|
960 | var _format$dataTime,
|
961 | config = this.config,
|
962 | format = this.format;
|
963 |
|
964 |
|
965 | parsedDate = (_format$dataTime = format.dataTime(config.data_xFormat)(date)) != null ? _format$dataTime : new Date(date);
|
966 | } else if (isNumber(date) && !isNaN(date)) {
|
967 | parsedDate = new Date(+date);
|
968 | }
|
969 | if (!parsedDate || isNaN(+parsedDate)) {
|
970 | console && console.error && console.error("Failed to parse x '" + date + "' to Date object");
|
971 | }
|
972 | return parsedDate;
|
973 | }
|
974 |
|
975 |
|
976 |
|
977 |
|
978 |
|
979 |
|
980 | function isTabVisible() {
|
981 | return (doc == null ? void 0 : doc.hidden) === !1 || (doc == null ? void 0 : doc.visibilityState) === "visible";
|
982 | }
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 | function convertInputType(mouse, touch) {
|
992 | var _this17 = this,
|
993 | DocumentTouch = win.DocumentTouch,
|
994 | matchMedia = win.matchMedia,
|
995 | navigator = win.navigator,
|
996 | hasTouch = !1;
|
997 | if (touch) {
|
998 |
|
999 | if (navigator && "maxTouchPoints" in navigator) {
|
1000 | hasTouch = navigator.maxTouchPoints > 0;
|
1001 |
|
1002 |
|
1003 |
|
1004 | } else if ("ontouchmove" in win || DocumentTouch && doc instanceof DocumentTouch) {
|
1005 | hasTouch = !0;
|
1006 | } else {
|
1007 |
|
1008 | if (matchMedia != null && matchMedia("(pointer:coarse)").matches) {
|
1009 | hasTouch = !0;
|
1010 | } else {
|
1011 |
|
1012 | var UA = navigator.userAgent;
|
1013 | hasTouch = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
|
1014 | }
|
1015 | }
|
1016 | }
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 | var hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some(function (v) {
|
1022 | _newArrowCheck(this, _this17);
|
1023 | return matchMedia == null ? void 0 : matchMedia("(" + v + ")").matches;
|
1024 | }.bind(this));
|
1025 |
|
1026 |
|
1027 | return hasMouse && "mouse" || hasTouch && "touch" || "mouse";
|
1028 | }
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 | function runUntil(fn, conditionFn) {
|
1037 | var _this18 = this;
|
1038 | if (conditionFn() === !1) {
|
1039 | win.requestAnimationFrame(function () {
|
1040 | _newArrowCheck(this, _this18);
|
1041 | return runUntil(fn, conditionFn);
|
1042 | }.bind(this));
|
1043 | } else {
|
1044 | fn();
|
1045 | }
|
1046 | }
|
1047 | ;
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 | function loadConfig(config) {
|
1060 | var _this = this,
|
1061 | thisConfig = this.config,
|
1062 | target,
|
1063 | keys,
|
1064 | read,
|
1065 | find = function () {
|
1066 | _newArrowCheck(this, _this);
|
1067 | var key = keys.shift();
|
1068 | if (key && target && isObjectType(target) && key in target) {
|
1069 | target = target[key];
|
1070 | return find();
|
1071 | } else if (!key) {
|
1072 | return target;
|
1073 | }
|
1074 | return undefined;
|
1075 | }.bind(this);
|
1076 | Object.keys(thisConfig).forEach(function (key) {
|
1077 | _newArrowCheck(this, _this);
|
1078 | target = config;
|
1079 | keys = key.split("_");
|
1080 | read = find();
|
1081 | if (isDefined(read)) {
|
1082 | thisConfig[key] = read;
|
1083 | }
|
1084 | }.bind(this));
|
1085 |
|
1086 |
|
1087 | if (this.api) {
|
1088 | this.state.orgConfig = config;
|
1089 | }
|
1090 | }
|
1091 | ;
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 | var Plugin = function () {
|
1111 | |
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 | function Plugin(options) {
|
1117 | if (options === void 0) {
|
1118 | options = {};
|
1119 | }
|
1120 | this.$$ = void 0;
|
1121 | this.options = void 0;
|
1122 | this.options = options;
|
1123 | }
|
1124 |
|
1125 | |
1126 |
|
1127 |
|
1128 |
|
1129 | var _proto = Plugin.prototype;
|
1130 | _proto.$beforeInit = function $beforeInit() {}
|
1131 |
|
1132 | |
1133 |
|
1134 |
|
1135 | ;
|
1136 | _proto.$init = function $init() {}
|
1137 |
|
1138 | |
1139 |
|
1140 |
|
1141 | ;
|
1142 | _proto.$afterInit = function $afterInit() {}
|
1143 |
|
1144 | |
1145 |
|
1146 |
|
1147 | ;
|
1148 | _proto.$redraw = function $redraw() {}
|
1149 |
|
1150 | |
1151 |
|
1152 |
|
1153 | ;
|
1154 | _proto.$willDestroy = function $willDestroy() {
|
1155 | var _this = this;
|
1156 | Object.keys(this).forEach(function (key) {
|
1157 | _newArrowCheck(this, _this);
|
1158 | this[key] = null;
|
1159 | delete this[key];
|
1160 | }.bind(this));
|
1161 | };
|
1162 | return Plugin;
|
1163 | }();
|
1164 | Plugin.version = "3.6.3";
|
1165 |
|
1166 | ;
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 | var Options = function () {
|
1180 | return {
|
1181 | |
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 | selector: undefined,
|
1193 | |
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 | extent: 1,
|
1203 | |
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 | area: 0
|
1213 | };
|
1214 | };
|
1215 |
|
1216 | ;
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 | var TextOverlap = function (_Plugin) {
|
1275 | _inheritsLoose(TextOverlap, _Plugin);
|
1276 | function TextOverlap(options) {
|
1277 | var _this = _Plugin.call(this, options) || this;
|
1278 | _this.config = void 0;
|
1279 | _this.config = new Options();
|
1280 | return _assertThisInitialized(_this) || _assertThisInitialized(_this);
|
1281 | }
|
1282 | var _proto = TextOverlap.prototype;
|
1283 | _proto.$init = function $init() {
|
1284 | loadConfig.call(this, this.options);
|
1285 | };
|
1286 | _proto.$redraw = function $redraw() {
|
1287 | var $el = this.$$.$el,
|
1288 | selector = this.config.selector,
|
1289 | text = selector ? $el.main.selectAll(selector) : $el.text;
|
1290 | text.empty() || this.preventLabelOverlap(text);
|
1291 | }
|
1292 |
|
1293 | |
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 | ;
|
1299 | _proto.generateVoronoi = function generateVoronoi(points) {
|
1300 | var _this2 = this,
|
1301 | $$ = this.$$,
|
1302 | scale = $$.scale,
|
1303 | _map = ["x", "y"].map(function (v) {
|
1304 | _newArrowCheck(this, _this2);
|
1305 | return scale[v].domain();
|
1306 | }.bind(this)),
|
1307 | min = _map[0],
|
1308 | max = _map[1],
|
1309 | _ref = [max[0], min[1]];
|
1310 | min[1] = _ref[0];
|
1311 | max[0] = _ref[1];
|
1312 | return external_commonjs_d3_delaunay_commonjs2_d3_delaunay_amd_d3_delaunay_root_d3_.Delaunay.from(points).voronoi([].concat(min, max));
|
1313 | }
|
1314 |
|
1315 | |
1316 |
|
1317 |
|
1318 |
|
1319 | ;
|
1320 | _proto.preventLabelOverlap = function preventLabelOverlap(text) {
|
1321 | var _this3 = this,
|
1322 | _this$config = this.config,
|
1323 | extent = _this$config.extent,
|
1324 | area = _this$config.area,
|
1325 | points = text.data().map(function (v) {
|
1326 | _newArrowCheck(this, _this3);
|
1327 | return [v.index, v.value];
|
1328 | }.bind(this)),
|
1329 | voronoi = this.generateVoronoi(points),
|
1330 | i = 0;
|
1331 | text.each(function () {
|
1332 | var cell = voronoi.cellPolygon(i);
|
1333 | if (cell && this) {
|
1334 | var _points$i = points[i],
|
1335 | x = _points$i[0],
|
1336 | y = _points$i[1],
|
1337 | _d3PolygonCentroid = (0,external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_.polygonCentroid)(cell),
|
1338 | cx = _d3PolygonCentroid[0],
|
1339 | cy = _d3PolygonCentroid[1],
|
1340 | polygonArea = Math.abs((0,external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_.polygonArea)(cell)),
|
1341 | angle = Math.round(Math.atan2(cy - y, cx - x) / Math.PI * 2),
|
1342 | xTranslate = extent * (angle === 0 ? 1 : -1),
|
1343 | yTranslate = angle === -1 ? -extent : extent + 5,
|
1344 | txtAnchor = Math.abs(angle) === 1 ? "middle" : angle === 0 ? "start" : "end";
|
1345 | this.style.display = polygonArea < area ? "none" : "";
|
1346 | this.setAttribute("text-anchor", txtAnchor);
|
1347 | this.setAttribute("dy", "0." + (angle === 1 ? 71 : 35) + "em");
|
1348 | this.setAttribute("transform", "translate(" + xTranslate + ", " + yTranslate + ")");
|
1349 | }
|
1350 | i++;
|
1351 | });
|
1352 | };
|
1353 | return TextOverlap;
|
1354 | }(Plugin);
|
1355 |
|
1356 | }();
|
1357 | __webpack_exports__ = __webpack_exports__["default"];
|
1358 | return __webpack_exports__;
|
1359 | })()
|
1360 | ;
|
1361 | }); |
\ | No newline at end of file |