billboard.js
Version:
Re-usable easy interface JavaScript chart library, based on D3 v4+
12 lines (11 loc) • 3.46 kB
JavaScript
/*!
* 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.1.1
* @requires billboard.js
* @summary billboard.js plugin
*/(function(u,b){typeof exports=="object"&&typeof module=="object"?module.exports=b(require("d3-selection")):typeof define=="function"&&define.amd?define("bb",["d3-selection"],b):typeof exports=="object"?exports.bb=b(require("d3-selection")):(u.bb=u.bb||{},u.bb.plugin=u.bb.plugin||{},u.bb.plugin.bubblecompare=b(u.d3))})(this,function(_){return(function(){var u={747:(function(i){"use strict";i.exports=_})},b={};function p(i){var o=b[i];if(o!==void 0)return o.exports;var a=b[i]={exports:{}};return u[i](a,a.exports,p),a.exports}p.d=function(i,o){for(var a in o)p.o(o,a)&&!p.o(i,a)&&Object.defineProperty(i,a,{enumerable:!0,get:o[a]})},p.o=function(i,o){return Object.prototype.hasOwnProperty.call(i,o)};var f={};return(function(){"use strict";p.d(f,{default:function(){return F}});var i=p(747);const o=e=>e||e===0,a=e=>typeof e=="function",x=e=>typeof e=="string",v=e=>typeof e=="number",B=e=>typeof e=="undefined",P=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],h=e=>typeof e=="object",C=e=>{for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},O=e=>B(e)||e===null||x(e)&&e.length===0||h(e)&&!(e instanceof Date)&&C(e)||v(e)&&isNaN(e),V=e=>!O(e),R=e=>Array.isArray(e),H=e=>e&&!(e!=null&&e.nodeType)&&h(e)&&!R(e);function w(e){const t=this.config;let n,c,s;const l=()=>{const r=c.shift();if(r&&n&&h(n)&&r in n)return n=n[r],l();if(!r)return n};Object.keys(t).forEach(r=>{n=e,c=r.split("_"),s=l(),P(s)&&(t[r]=s)}),this.api&&(this.state.orgConfig=e)}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,d=(e,t,n)=>E(e,typeof t!="symbol"?t+"":t,n);class m{constructor(t={}){d(this,"$$"),d(this,"options"),d(this,"config"),this.options=t}loadConfig(){w.call(this,this.options)}$beforeInit(){}$init(){}$afterInit(){}$redraw(){}$willDestroy(){Object.keys(this).forEach(t=>{this[t]=null,delete this[t]})}}d(m,"version","4.1.1");var j=Object.defineProperty,M=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N=(e,t,n)=>M(e,typeof t!="symbol"?t+"":t,n);const g=class $ extends m{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:c=1}=this.options;return $.raiseFocusedBubbleLayer(t),this.changeCursorPoint(),n*c}static raiseFocusedBubbleLayer(t){t.raise&&(0,i.select)(t.node().parentNode.parentNode).raise()}changeCursorPoint(){this.$$.$el.eventRect.style("cursor","pointer")}findClosest(t,n){const{$$:c}=this;return t.filter(s=>s&&!c.isBarType(s.id)).reduce((s,l)=>c.dist(l,n)<this.getBubbleR(l)?l:s,0)}getBubbleR(t){const{minR:n,maxR:c}=this.options,s=this.getZData(t);if(!s)return n;const[l,r]=this.$$.data.targets.reduce(([T,q],A)=>{const y=this.getZData(A.values[0]);return[Math.min(T,y),Math.max(q,y)]},[1e4,0]),Z=l>0&&r===l?0:s/r;return Math.abs(Z)*(c-n)+n}getZData(t){return this.$$.isBubbleZType(t)?this.$$.getBubbleZData(t.value,"z"):t.value}};N(g,"version","0.0.1");let F=g})(),f=f.default,f})()});