UNPKG

3.99 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 * https://naver.github.io/billboard.js/
7 *
8 * @version 3.0.2
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-voronoi"),require("d3-polygon"),require("d3-selection"),require("d3-brush")):"function"==typeof define&&define.amd?define("bb",["d3-voronoi","d3-polygon","d3-selection","d3-brush"],e):"object"==typeof exports?exports.bb=e(require("d3-voronoi"),require("d3-polygon"),require("d3-selection"),require("d3-brush")):(t.bb=t.bb||{},t.bb.plugin=t.bb.plugin||{},t.bb.plugin.textoverlap=e(t.d3,t.d3,t.d3,t.d3))}(this,(function(t,e,n,o){return function(){"use strict";var r=[,function(t){t.exports=n},,,,,function(t){t.exports=o},,,,function(e){e.exports=t},function(t){t.exports=e}],i={};function c(t){var e=i[t];if(void 0!==e)return e.exports;var n=i[t]={exports:{}};return r[t](n,n.exports,c),n.exports}c.d=function(t,e){for(var n in e)c.o(e,n)&&!c.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},c.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var u={};return function(){function t(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function e(t,n){return(e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,n)}c.d(u,{default:function(){return d}});var n=c(10),o=c(11),r=c(1);c(6);var i="object"==typeof globalThis&&null!==globalThis&&globalThis.Object===Object&&globalThis||"object"==typeof global&&null!==global&&global.Object===Object&&global||"object"==typeof self&&null!==self&&self.Object===Object&&self||Function("return this")(),a=i&&i.document;var l=function(t){return void 0!==t},s=function(t){return"object"==typeof t};!function(){try{new MouseEvent("t")}catch(t){return function(t,e,n){void 0===n&&(n={bubbles:!1,cancelable:!1,screenX:0,screenY:0,clientX:0,clientY:0});var o=a.createEvent("MouseEvent");o.initMouseEvent(e,n.bubbles,n.cancelable,i,0,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),t.dispatchEvent(o)}}}();function f(t){var e,n,o,r=this.config,i=function(){var t=n.shift();return t&&e&&s(e)&&t in e?(e=e[t],i()):t?void 0:e};Object.keys(r).forEach((function(c){e=t,n=c.split("_"),o=i(),l(o)&&(r[c]=o)}))}var b=function(){function t(t){void 0===t&&(t={}),this.$$=void 0,this.options=void 0,this.options=t}var e=t.prototype;return e.$beforeInit=function(){},e.$init=function(){},e.$afterInit=function(){},e.$redraw=function(){},e.$willDestroy=function(){var t=this;Object.keys(this).forEach((function(e){t[e]=null,delete t[e]}))},t}();b.version="3.0.1";var p=function(){return{selector:".bb-texts text",extent:1,area:0}},d=function(i){function c(e){var n;return(n=i.call(this,e)||this).config=void 0,n.config=new p,t(n)||t(n)}var u,a;a=i,(u=c).prototype=Object.create(a.prototype),u.prototype.constructor=u,e(u,a);var l=c.prototype;return l.$init=function(){f.call(this,this.options)},l.$redraw=function(){var t=(0,r.selectAll)(this.config.selector);t.empty()||this.preventLabelOverlap(t)},l.generateVoronoi=function(t){var e=this.$$.scale,o=["x","y"].map((function(t){return e[t].domain()})),r=o[0],i=o[1],c=[i[0],r[1]];return r[1]=c[0],i[0]=c[1],(0,n.voronoi)().extent([r,i]).polygons(t)},l.preventLabelOverlap=function(t){var e=this.config,n=e.extent,i=e.area,c=this.generateVoronoi(t.data().map((function(t){return[t.x,t.value]}))),u=0;t.each((function(){var t=c[u++];if(t&&this){var e=t.data,a=e[0],l=e[1],s=(0,o.polygonCentroid)(t),f=s[0],b=s[1],p=Math.round(Math.atan2(b-l,f-a)/Math.PI*2),d=n*(0===p?1:-1),v=-1===p?-n:n+5,h=1===Math.abs(p)?"middle":0===p?"start":"end";(0,r.select)(this).attr("display",(0,o.polygonArea)(t)<i?"none":null).attr("text-anchor",h).attr("dy","0."+(1===p?71:35)+"em").attr("transform","translate("+d+", "+v+")")}}))},c}(b)}(),u=u.default}()}));
\No newline at end of file