UNPKG

billboard.js

Version:

Re-usable easy interface JavaScript chart library, based on D3 v4+

12 lines (11 loc) 3.42 kB
/*! * Copyright (c) 2017 ~ present NAVER Corp. * billboard.js project is licensed under the MIT license * * billboard.js, JavaScript chart library * https://naver.github.io/billboard.js/ * * @version 4.0.1 * @requires billboard.js * @summary billboard.js plugin */(function(a,c){typeof exports=="object"&&typeof module=="object"?module.exports=c(require("d3-selection")):typeof define=="function"&&define.amd?define("bb",["d3-selection"],c):typeof exports=="object"?exports.bb=c(require("d3-selection")):(a.bb=a.bb||{},a.bb.plugin=a.bb.plugin||{},a.bb.plugin.bubblecompare=c(a.d3))})(this,function(f){return(function(){"use strict";var a={747:(function(e){e.exports=f})},c={};function u(e){var t=c[e];if(t!==void 0)return t.exports;var n=c[e]={exports:{}};return a[e](n,n.exports,u),n.exports}(function(){u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}})(),(function(){u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}})();var l={};u.d(l,{default:function(){return M}});var g=u(747);const q=e=>e||e===0,A=e=>typeof e=="function",y=e=>typeof e=="string",$=e=>typeof e=="number",x=e=>typeof e=="undefined",v=e=>typeof e!="undefined",z=e=>typeof e=="boolean",L=e=>Math.ceil(e/10)*10,S=e=>Math.ceil(e)+.5,U=e=>e[1]-e[0],p=e=>typeof e=="object",B=e=>{for(const t in e)return!1;return!0},C=e=>x(e)||e===null||y(e)&&e.length===0||p(e)&&!(e instanceof Date)&&B(e)||$(e)&&isNaN(e),V=e=>!C(e),P=e=>Array.isArray(e),H=e=>e&&!(e!=null&&e.nodeType)&&p(e)&&!P(e);function R(e){const t=this.config;let n,r,i;const o=()=>{const s=r.shift();if(s&&n&&p(n)&&s in n)return n=n[s],o();if(!s)return n};Object.keys(t).forEach(s=>{n=e,r=s.split("_"),i=o(),v(i)&&(t[s]=i)}),this.api&&(this.state.orgConfig=e)}var w=Object.defineProperty,O=(e,t,n)=>t in e?w(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t,n)=>O(e,typeof t!="symbol"?t+"":t,n);class d{constructor(t={}){b(this,"$$"),b(this,"options"),b(this,"config"),this.options=t}loadConfig(){R.call(this,this.options)}$beforeInit(){}$init(){}$afterInit(){}$redraw(){}$willDestroy(){Object.keys(this).forEach(t=>{this[t]=null,delete this[t]})}}b(d,"version","4.0.1");var D=Object.defineProperty,E=(e,t,n)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,j=(e,t,n)=>E(e,typeof t!="symbol"?t+"":t,n);const h=class m extends d{constructor(t){return super(t),this}$init(){const{$$:t}=this;t.findClosest=this.findClosest.bind(this),t.getBubbleR=this.getBubbleR.bind(this),t.pointExpandedR=this.pointExpandedR.bind(this)}pointExpandedR(t){const n=this.getBubbleR(t),{expandScale:r=1}=this.options;return m.raiseFocusedBubbleLayer(t),this.changeCursorPoint(),n*r}static raiseFocusedBubbleLayer(t){t.raise&&(0,g.select)(t.node().parentNode.parentNode).raise()}changeCursorPoint(){this.$$.$el.eventRect.style("cursor","pointer")}findClosest(t,n){const{$$:r}=this;return t.filter(i=>i&&!r.isBarType(i.id)).reduce((i,o)=>r.dist(o,n)<this.getBubbleR(o)?o:i,0)}getBubbleR(t){const{minR:n,maxR:r}=this.options,i=this.getZData(t);if(!i)return n;const[o,s]=this.$$.data.targets.reduce(([F,Z],T)=>{const _=this.getZData(T.values[0]);return[Math.min(F,_),Math.max(Z,_)]},[1e4,0]),N=o>0&&s===o?0:i/s;return Math.abs(N)*(r-n)+n}getZData(t){return this.$$.isBubbleZType(t)?this.$$.getBubbleZData(t.value,"z"):t.value}};j(h,"version","0.0.1");let M=h;return l=l.default,l})()});