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