UNPKG

6.26 kBJavaScriptView Raw
1/*!
2 * Copyright (c) 2017 ~ present NAVER Corp.
3 * billboard.js project is licensed under the MIT license
4 *
5 * billboard.js, JavaScript chart library
6 * http://naver.github.io/billboard.js/
7 *
8 * @version 1.12.1
9 * @requires billboard.js
10 * @summary billboard.js plugin
11 */
12!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("d3-selection"),require("d3-voronoi"),require("d3-polygon")):"function"==typeof define&&define.amd?define("textoverlap",["d3-selection","d3-voronoi","d3-polygon"],e):"object"==typeof exports?exports.textoverlap=e(require("d3-selection"),require("d3-voronoi"),require("d3-polygon")):(t.bb=t.bb||{},t.bb.plugin=t.bb.plugin||{},t.bb.plugin.textoverlap=e(t.d3,t.d3,t.d3))}(this,(function(t,e,n){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=21)}([,function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}n.d(e,"a",(function(){return r}))},function(t,e,n){"use strict";function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}n.d(e,"a",(function(){return o}))},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(4),o=n(5);function i(t,e){return!e||"object"!==Object(r.a)(e)&&"function"!=typeof e?Object(o.a)(t):e}},function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}n.d(e,"a",(function(){return r}))},function(t,e,n){"use strict";function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}n.d(e,"a",(function(){return r}))},function(t,e,n){"use strict";function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}n.d(e,"a",(function(){return r}))},function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}n.d(e,"a",(function(){return r}))},function(e,n){e.exports=t},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(1),o=n(2),i=n(7),u=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(r.a)(this,t),this.options=e}return Object(o.a)(t,[{key:"$beforeInit",value:function(){}},{key:"$init",value:function(){}},{key:"$afterInit",value:function(){}},{key:"$redraw",value:function(){}},{key:"$willDestroy",value:function(){var t=this;Object.keys(this).forEach((function(e){t[e]=null,delete t[e]}))}}]),t}();Object(i.a)(u,"version","1.12.1")},,,,,,,,function(t,n){t.exports=e},function(t,e){t.exports=n},,function(t,e,n){"use strict";function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],r=!0,o=!1,i=void 0;try{for(var u,c=t[Symbol.iterator]();!(r=(u=c.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}n.d(e,"a",(function(){return r}))},function(t,e,n){"use strict";n.r(e),n.d(e,"default",(function(){return d}));var r=n(20),o=n(1),i=n(2),u=n(3),c=n(6),a=n(5),f=n(22),l=n(17),s=n(18),b=n(8),p=n(9),y=function t(){return Object(o.a)(this,t),{selector:".bb-texts text",extent:1,area:0}},d=function(t){function e(t){var n;return Object(o.a)(this,e),(n=Object(u.a)(this,Object(c.a)(e).call(this,t))).config=new y,Object(u.a)(n,Object(a.a)(n))}return Object(f.a)(e,t),Object(i.a)(e,[{key:"$init",value:function(){this.$$.loadConfig.bind(this)(this.options)}},{key:"$redraw",value:function(){var t=Object(b.selectAll)(this.config.selector);t.empty()||this.preventLabelOverlap(t)}},{key:"generateVoronoi",value:function(t){var e=this.$$,n=["x","y"].map((function(t){return e[t].domain()})),o=Object(r.a)(n,2),i=o[0],u=o[1],c=[u[0],i[1]];return i[1]=c[0],u[0]=c[1],Object(l.voronoi)().extent([i,u]).polygons(t)}},{key:"preventLabelOverlap",value:function(t){var e=this.config,n=e.extent,o=e.area,i=this.generateVoronoi(t.data().map((function(t){return[t.x,t.value]}))),u=0;t.each((function(){var t=i[u++];if(t&&this){var e=Object(r.a)(t.data,2),c=e[0],a=e[1],f=Object(s.polygonCentroid)(t),l=Object(r.a)(f,2),p=l[0],y=l[1],d=Math.round(Math.atan2(y-a,p-c)/Math.PI*2),v=n*(0===d?1:-1),O=-1===d?-n:n+5,j=1===Math.abs(d)?"middle":0===d?"start":"end";Object(b.select)(this).attr("display",Object(s.polygonArea)(t)<o?"none":null).attr("text-anchor",j).attr("dy","0.".concat(1===d?71:35,"em")).attr("transform","translate(".concat(v,", ").concat(O,")"))}}))}}]),e}(p.a)},function(t,e,n){"use strict";function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}n.d(e,"a",(function(){return o}))}]).default}));
\No newline at end of file