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"), require("d3-voronoi"), require("d3-polygon"));
|
15 | else if(typeof define === 'function' && define.amd)
|
16 | define("textoverlap", ["d3-selection", "d3-voronoi", "d3-polygon"], factory);
|
17 | else if(typeof exports === 'object')
|
18 | exports["textoverlap"] = factory(require("d3-selection"), require("d3-voronoi"), require("d3-polygon"));
|
19 | else
|
20 | root["bb"] = root["bb"] || {}, root["bb"]["plugin"] = root["bb"]["plugin"] || {}, root["bb"]["plugin"]["textoverlap"] = factory(root["d3"], root["d3"], root["d3"]);
|
21 | })(this, function(__WEBPACK_EXTERNAL_MODULE__8__, __WEBPACK_EXTERNAL_MODULE__17__, __WEBPACK_EXTERNAL_MODULE__18__) {
|
22 | return (function(modules) {
|
23 |
|
24 | var installedModules = {};
|
25 |
|
26 |
|
27 | function __webpack_require__(moduleId) {
|
28 |
|
29 |
|
30 | if(installedModules[moduleId]) {
|
31 | return installedModules[moduleId].exports;
|
32 | }
|
33 |
|
34 | var module = installedModules[moduleId] = {
|
35 | i: moduleId,
|
36 | l: false,
|
37 | exports: {}
|
38 | };
|
39 |
|
40 |
|
41 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
42 |
|
43 |
|
44 | module.l = true;
|
45 |
|
46 |
|
47 | return module.exports;
|
48 | }
|
49 |
|
50 |
|
51 |
|
52 | __webpack_require__.m = modules;
|
53 |
|
54 |
|
55 | __webpack_require__.c = installedModules;
|
56 |
|
57 |
|
58 | __webpack_require__.d = function(exports, name, getter) {
|
59 | if(!__webpack_require__.o(exports, name)) {
|
60 | Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
61 | }
|
62 | };
|
63 |
|
64 |
|
65 | __webpack_require__.r = function(exports) {
|
66 | if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
67 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
68 | }
|
69 | Object.defineProperty(exports, '__esModule', { value: true });
|
70 | };
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | __webpack_require__.t = function(value, mode) {
|
78 | if(mode & 1) value = __webpack_require__(value);
|
79 | if(mode & 8) return value;
|
80 | if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
81 | var ns = Object.create(null);
|
82 | __webpack_require__.r(ns);
|
83 | Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
84 | if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
85 | return ns;
|
86 | };
|
87 |
|
88 |
|
89 | __webpack_require__.n = function(module) {
|
90 | var getter = module && module.__esModule ?
|
91 | function getDefault() { return module['default']; } :
|
92 | function getModuleExports() { return module; };
|
93 | __webpack_require__.d(getter, 'a', getter);
|
94 | return getter;
|
95 | };
|
96 |
|
97 |
|
98 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
99 |
|
100 |
|
101 | __webpack_require__.p = "";
|
102 |
|
103 |
|
104 |
|
105 | return __webpack_require__(__webpack_require__.s = 21);
|
106 | })
|
107 |
|
108 | ([
|
109 | ,
|
110 |
|
111 | (function(module, __webpack_exports__, __webpack_require__) {
|
112 |
|
113 | "use strict";
|
114 | __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
|
115 | function _classCallCheck(instance, Constructor) {
|
116 | if (!(instance instanceof Constructor)) {
|
117 | throw new TypeError("Cannot call a class as a function");
|
118 | }
|
119 | }
|
120 |
|
121 | }),
|
122 |
|
123 | (function(module, __webpack_exports__, __webpack_require__) {
|
124 |
|
125 | "use strict";
|
126 | __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
|
127 | function _defineProperties(target, props) {
|
128 | for (var i = 0; i < props.length; i++) {
|
129 | var descriptor = props[i];
|
130 | descriptor.enumerable = descriptor.enumerable || false;
|
131 | descriptor.configurable = true;
|
132 | if ("value" in descriptor) descriptor.writable = true;
|
133 | Object.defineProperty(target, descriptor.key, descriptor);
|
134 | }
|
135 | }
|
136 |
|
137 | function _createClass(Constructor, protoProps, staticProps) {
|
138 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
139 | if (staticProps) _defineProperties(Constructor, staticProps);
|
140 | return Constructor;
|
141 | }
|
142 |
|
143 | }),
|
144 |
|
145 | (function(module, __webpack_exports__, __webpack_require__) {
|
146 |
|
147 | "use strict";
|
148 | __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
|
149 | var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
|
150 | var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
|
151 |
|
152 |
|
153 | function _possibleConstructorReturn(self, call) {
|
154 | if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[ "a"])(call) === "object" || typeof call === "function")) {
|
155 | return call;
|
156 | }
|
157 |
|
158 | return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[ "a"])(self);
|
159 | }
|
160 |
|
161 | }),
|
162 |
|
163 | (function(module, __webpack_exports__, __webpack_require__) {
|
164 |
|
165 | "use strict";
|
166 | __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
|
167 | function _typeof(obj) {
|
168 | "@babel/helpers - typeof";
|
169 |
|
170 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
171 | _typeof = function _typeof(obj) {
|
172 | return typeof obj;
|
173 | };
|
174 | } else {
|
175 | _typeof = function _typeof(obj) {
|
176 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
177 | };
|
178 | }
|
179 |
|
180 | return _typeof(obj);
|
181 | }
|
182 |
|
183 | }),
|
184 |
|
185 | (function(module, __webpack_exports__, __webpack_require__) {
|
186 |
|
187 | "use strict";
|
188 | __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
|
189 | function _assertThisInitialized(self) {
|
190 | if (self === void 0) {
|
191 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
192 | }
|
193 |
|
194 | return self;
|
195 | }
|
196 |
|
197 | }),
|
198 |
|
199 | (function(module, __webpack_exports__, __webpack_require__) {
|
200 |
|
201 | "use strict";
|
202 | __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
|
203 | function _getPrototypeOf(o) {
|
204 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
205 | return o.__proto__ || Object.getPrototypeOf(o);
|
206 | };
|
207 | return _getPrototypeOf(o);
|
208 | }
|
209 |
|
210 | }),
|
211 |
|
212 | (function(module, __webpack_exports__, __webpack_require__) {
|
213 |
|
214 | "use strict";
|
215 | __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
|
216 | function _defineProperty(obj, key, value) {
|
217 | if (key in obj) {
|
218 | Object.defineProperty(obj, key, {
|
219 | value: value,
|
220 | enumerable: true,
|
221 | configurable: true,
|
222 | writable: true
|
223 | });
|
224 | } else {
|
225 | obj[key] = value;
|
226 | }
|
227 |
|
228 | return obj;
|
229 | }
|
230 |
|
231 | }),
|
232 |
|
233 | (function(module, exports) {
|
234 |
|
235 | module.exports = __WEBPACK_EXTERNAL_MODULE__8__;
|
236 |
|
237 | }),
|
238 |
|
239 | (function(module, __webpack_exports__, __webpack_require__) {
|
240 |
|
241 | "use strict";
|
242 | __webpack_require__.d(__webpack_exports__, "a", function() { return Plugin; });
|
243 | var _babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
244 | var _babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
|
245 | var _babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 | var Plugin = function () {
|
260 | |
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 | |
271 |
|
272 |
|
273 |
|
274 |
|
275 | function Plugin() {
|
276 | var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
277 | Object(_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__[ "a"])(this, Plugin), this.options = options;
|
278 | }
|
279 | |
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 | return Object(_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__[ "a"])(Plugin, [{
|
286 | key: "$beforeInit",
|
287 | value: function $beforeInit() {}
|
288 | |
289 |
|
290 |
|
291 |
|
292 |
|
293 | }, {
|
294 | key: "$init",
|
295 | value: function $init() {}
|
296 | |
297 |
|
298 |
|
299 |
|
300 |
|
301 | }, {
|
302 | key: "$afterInit",
|
303 | value: function $afterInit() {}
|
304 | |
305 |
|
306 |
|
307 |
|
308 |
|
309 | }, {
|
310 | key: "$redraw",
|
311 | value: function $redraw() {}
|
312 | |
313 |
|
314 |
|
315 |
|
316 |
|
317 | }, {
|
318 | key: "$willDestroy",
|
319 | value: function $willDestroy() {
|
320 | var _this = this;
|
321 |
|
322 | Object.keys(this).forEach(function (key) {
|
323 | _this[key] = null, delete _this[key];
|
324 | });
|
325 | }
|
326 | }]), Plugin;
|
327 | }();
|
328 |
|
329 | Object(_babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_2__[ "a"])(Plugin, "version", "1.12.1");
|
330 |
|
331 |
|
332 |
|
333 | }),
|
334 | ,
|
335 | ,
|
336 | ,
|
337 | ,
|
338 | ,
|
339 | ,
|
340 | ,
|
341 |
|
342 | (function(module, exports) {
|
343 |
|
344 | module.exports = __WEBPACK_EXTERNAL_MODULE__17__;
|
345 |
|
346 | }),
|
347 |
|
348 | (function(module, exports) {
|
349 |
|
350 | module.exports = __WEBPACK_EXTERNAL_MODULE__18__;
|
351 |
|
352 | }),
|
353 | ,
|
354 |
|
355 | (function(module, __webpack_exports__, __webpack_require__) {
|
356 |
|
357 | "use strict";
|
358 |
|
359 |
|
360 | __webpack_require__.d(__webpack_exports__, "a", function() { return _slicedToArray; });
|
361 |
|
362 |
|
363 | function _arrayWithHoles(arr) {
|
364 | if (Array.isArray(arr)) return arr;
|
365 | }
|
366 |
|
367 | function _iterableToArrayLimit(arr, i) {
|
368 | if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
|
369 | return;
|
370 | }
|
371 |
|
372 | var _arr = [];
|
373 | var _n = true;
|
374 | var _d = false;
|
375 | var _e = undefined;
|
376 |
|
377 | try {
|
378 | for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
379 | _arr.push(_s.value);
|
380 |
|
381 | if (i && _arr.length === i) break;
|
382 | }
|
383 | } catch (err) {
|
384 | _d = true;
|
385 | _e = err;
|
386 | } finally {
|
387 | try {
|
388 | if (!_n && _i["return"] != null) _i["return"]();
|
389 | } finally {
|
390 | if (_d) throw _e;
|
391 | }
|
392 | }
|
393 |
|
394 | return _arr;
|
395 | }
|
396 |
|
397 | function _nonIterableRest() {
|
398 | throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
399 | }
|
400 |
|
401 |
|
402 |
|
403 |
|
404 | function _slicedToArray(arr, i) {
|
405 | return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
406 | }
|
407 |
|
408 | }),
|
409 |
|
410 | (function(module, __webpack_exports__, __webpack_require__) {
|
411 |
|
412 | "use strict";
|
413 |
|
414 | __webpack_require__.r(__webpack_exports__);
|
415 |
|
416 |
|
417 | __webpack_require__.d(__webpack_exports__, "default", function() { return textoverlap_TextOverlap; });
|
418 |
|
419 |
|
420 | var slicedToArray = __webpack_require__(20);
|
421 |
|
422 |
|
423 | var classCallCheck = __webpack_require__(1);
|
424 |
|
425 |
|
426 | var createClass = __webpack_require__(2);
|
427 |
|
428 |
|
429 | var possibleConstructorReturn = __webpack_require__(3);
|
430 |
|
431 |
|
432 | var getPrototypeOf = __webpack_require__(6);
|
433 |
|
434 |
|
435 | var assertThisInitialized = __webpack_require__(5);
|
436 |
|
437 |
|
438 | var inherits = __webpack_require__(22);
|
439 |
|
440 |
|
441 | var external_commonjs_d3_voronoi_commonjs2_d3_voronoi_amd_d3_voronoi_root_d3_ = __webpack_require__(17);
|
442 |
|
443 |
|
444 | var external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_ = __webpack_require__(18);
|
445 |
|
446 |
|
447 | var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(8);
|
448 |
|
449 |
|
450 | var Plugin = __webpack_require__(9);
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 | var Options_Options = function Options() {
|
469 | return Object(classCallCheck["a" ])(this, Options), {
|
470 | |
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 | selector: ".bb-texts text",
|
481 |
|
482 | |
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 | extent: 1,
|
492 |
|
493 | |
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 | area: 0
|
503 | };
|
504 | };
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 | var textoverlap_TextOverlap = function (_Plugin) {
|
567 | function TextOverlap(options) {
|
568 | var _this;
|
569 |
|
570 | return Object(classCallCheck["a" ])(this, TextOverlap), _this = Object(possibleConstructorReturn["a" ])(this, Object(getPrototypeOf["a" ])(TextOverlap).call(this, options)), _this.config = new Options_Options(), Object(possibleConstructorReturn["a" ])(_this, Object(assertThisInitialized["a" ])(_this));
|
571 | }
|
572 |
|
573 | return Object(inherits["a" ])(TextOverlap, _Plugin), Object(createClass["a" ])(TextOverlap, [{
|
574 | key: "$init",
|
575 | value: function $init() {
|
576 | var $$ = this.$$;
|
577 | $$.loadConfig.bind(this)(this.options);
|
578 | }
|
579 | }, {
|
580 | key: "$redraw",
|
581 | value: function $redraw() {
|
582 | var text = Object(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_["selectAll"])(this.config.selector);
|
583 | text.empty() || this.preventLabelOverlap(text);
|
584 | }
|
585 | |
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 | }, {
|
593 | key: "generateVoronoi",
|
594 | value: function generateVoronoi(data) {
|
595 | var $$ = this.$$,
|
596 | _map = ["x", "y"].map(function (v) {
|
597 | return $$[v].domain();
|
598 | }),
|
599 | _map2 = Object(slicedToArray["a" ])(_map, 2),
|
600 | min = _map2[0],
|
601 | max = _map2[1],
|
602 | _ref = [max[0], min[1]];
|
603 |
|
604 | return min[1] = _ref[0], max[0] = _ref[1], Object(external_commonjs_d3_voronoi_commonjs2_d3_voronoi_amd_d3_voronoi_root_d3_["voronoi"])().extent([min, max]).polygons(data);
|
605 | }
|
606 | |
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 | }, {
|
613 | key: "preventLabelOverlap",
|
614 | value: function preventLabelOverlap(text) {
|
615 | var _this$config = this.config,
|
616 | extent = _this$config.extent,
|
617 | area = _this$config.area,
|
618 | cells = this.generateVoronoi(text.data().map(function (v) {
|
619 | return [v.x, v.value];
|
620 | })),
|
621 | i = 0;
|
622 | text.each(function () {
|
623 | var cell = cells[i++];
|
624 |
|
625 | if (cell && this) {
|
626 | var _cell$data = Object(slicedToArray["a" ])(cell.data, 2),
|
627 | x = _cell$data[0],
|
628 | y = _cell$data[1],
|
629 | _d3PolygonCentroid = Object(external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_["polygonCentroid"])(cell),
|
630 | _d3PolygonCentroid2 = Object(slicedToArray["a" ])(_d3PolygonCentroid, 2),
|
631 | cx = _d3PolygonCentroid2[0],
|
632 | cy = _d3PolygonCentroid2[1],
|
633 | angle = Math.round(Math.atan2(cy - y, cx - x) / Math.PI * 2),
|
634 | xTranslate = extent * (angle === 0 ? 1 : -1),
|
635 | yTranslate = angle === -1 ? -extent : extent + 5,
|
636 | txtAnchor = Math.abs(angle) === 1 ? "middle" : angle === 0 ? "start" : "end";
|
637 |
|
638 | Object(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_["select"])(this).attr("display", Object(external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_["polygonArea"])(cell) < area ? "none" : null).attr("text-anchor", txtAnchor).attr("dy", "0.".concat(angle === 1 ? 71 : 35, "em")).attr("transform", "translate(".concat(xTranslate, ", ").concat(yTranslate, ")"));
|
639 | }
|
640 | });
|
641 | }
|
642 | }]), TextOverlap;
|
643 | }(Plugin["a" ]);
|
644 |
|
645 |
|
646 |
|
647 | }),
|
648 |
|
649 | (function(module, __webpack_exports__, __webpack_require__) {
|
650 |
|
651 | "use strict";
|
652 |
|
653 |
|
654 | __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
|
655 |
|
656 |
|
657 | function _setPrototypeOf(o, p) {
|
658 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
659 | o.__proto__ = p;
|
660 | return o;
|
661 | };
|
662 |
|
663 | return _setPrototypeOf(o, p);
|
664 | }
|
665 |
|
666 |
|
667 | function _inherits(subClass, superClass) {
|
668 | if (typeof superClass !== "function" && superClass !== null) {
|
669 | throw new TypeError("Super expression must either be null or a function");
|
670 | }
|
671 |
|
672 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
673 | constructor: {
|
674 | value: subClass,
|
675 | writable: true,
|
676 | configurable: true
|
677 | }
|
678 | });
|
679 | if (superClass) _setPrototypeOf(subClass, superClass);
|
680 | }
|
681 |
|
682 | })
|
683 | ])["default"];
|
684 | }); |
\ | No newline at end of file |