UNPKG

6.87 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.14.2
9 * @requires billboard.js
10 * @summary billboard.js plugin
11 */
12(function webpackUniversalModuleDefinition(root, factory) {
13 if(typeof exports === 'object' && typeof module === 'object')
14 module.exports = factory(require("d3-selection"));
15 else if(typeof define === 'function' && define.amd)
16 define("bb", ["d3-selection"], factory);
17 else if(typeof exports === 'object')
18 exports["bb"] = factory(require("d3-selection"));
19 else
20 root["bb"] = root["bb"] || {}, root["bb"]["plugin"] = root["bb"]["plugin"] || {}, root["bb"]["plugin"]["bubblecompare"] = factory(root["d3"]);
21})(this, function(__WEBPACK_EXTERNAL_MODULE__1__) {
22return /******/ (function() { // webpackBootstrap
23/******/ "use strict";
24/******/ var __webpack_modules__ = ([
25/* 0 */,
26/* 1 */
27/***/ (function(module) {
28
29module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
30
31/***/ })
32/******/ ]);
33/************************************************************************/
34/******/ // The module cache
35/******/ var __webpack_module_cache__ = {};
36/******/
37/******/ // The require function
38/******/ function __webpack_require__(moduleId) {
39/******/ // Check if module is in cache
40/******/ var cachedModule = __webpack_module_cache__[moduleId];
41/******/ if (cachedModule !== undefined) {
42/******/ return cachedModule.exports;
43/******/ }
44/******/ // Create a new module (and put it into the cache)
45/******/ var module = __webpack_module_cache__[moduleId] = {
46/******/ // no module.id needed
47/******/ // no module.loaded needed
48/******/ exports: {}
49/******/ };
50/******/
51/******/ // Execute the module function
52/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
53/******/
54/******/ // Return the exports of the module
55/******/ return module.exports;
56/******/ }
57/******/
58/************************************************************************/
59/******/ /* webpack/runtime/define property getters */
60/******/ !function() {
61/******/ // define getter functions for harmony exports
62/******/ __webpack_require__.d = function(exports, definition) {
63/******/ for(var key in definition) {
64/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
65/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
66/******/ }
67/******/ }
68/******/ };
69/******/ }();
70/******/
71/******/ /* webpack/runtime/hasOwnProperty shorthand */
72/******/ !function() {
73/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
74/******/ }();
75/******/
76/************************************************************************/
77var __webpack_exports__ = {};
78// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
79!function() {
80
81// EXPORTS
82__webpack_require__.d(__webpack_exports__, {
83 "default": function() { return /* binding */ BubbleCompare; }
84});
85
86// EXTERNAL MODULE: external {"commonjs":"d3-selection","commonjs2":"d3-selection","amd":"d3-selection","root":"d3"}
87var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(1);
88;// ./src/Plugin/Plugin.ts
89var __defProp = Object.defineProperty;
90var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
91var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
92class Plugin {
93 /**
94 * Constructor
95 * @param {Any} options config option object
96 * @private
97 */
98 constructor(options = {}) {
99 __publicField(this, "$$");
100 __publicField(this, "options");
101 this.options = options;
102 }
103 /**
104 * Lifecycle hook for 'beforeInit' phase.
105 * @private
106 */
107 $beforeInit() {
108 }
109 /**
110 * Lifecycle hook for 'init' phase.
111 * @private
112 */
113 $init() {
114 }
115 /**
116 * Lifecycle hook for 'afterInit' phase.
117 * @private
118 */
119 $afterInit() {
120 }
121 /**
122 * Lifecycle hook for 'redraw' phase.
123 * @private
124 */
125 $redraw() {
126 }
127 /**
128 * Lifecycle hook for 'willDestroy' phase.
129 * @private
130 */
131 $willDestroy() {
132 Object.keys(this).forEach((key) => {
133 this[key] = null;
134 delete this[key];
135 });
136 }
137}
138__publicField(Plugin, "version", "3.14.2");
139
140;// ./src/Plugin/bubblecompare/index.ts
141var bubblecompare_defProp = Object.defineProperty;
142var bubblecompare_defNormalProp = (obj, key, value) => key in obj ? bubblecompare_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
143var bubblecompare_publicField = (obj, key, value) => bubblecompare_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
144
145
146const _BubbleCompare = class _BubbleCompare extends Plugin {
147 constructor(options) {
148 super(options);
149 bubblecompare_publicField(this, "$$");
150 return this;
151 }
152 $init() {
153 const { $$ } = this;
154 $$.findClosest = this.findClosest.bind(this);
155 $$.getBubbleR = this.getBubbleR.bind(this);
156 $$.pointExpandedR = this.pointExpandedR.bind(this);
157 }
158 pointExpandedR(d) {
159 const baseR = this.getBubbleR(d);
160 const { expandScale = 1 } = this.options;
161 _BubbleCompare.raiseFocusedBubbleLayer(d);
162 this.changeCursorPoint();
163 return baseR * expandScale;
164 }
165 static raiseFocusedBubbleLayer(d) {
166 d.raise && (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(d.node().parentNode.parentNode).raise();
167 }
168 changeCursorPoint() {
169 this.$$.$el.eventRect.style("cursor", "pointer");
170 }
171 findClosest(values, pos) {
172 const { $$ } = this;
173 return values.filter((v) => v && !$$.isBarType(v.id)).reduce((acc, cur) => {
174 const d = $$.dist(cur, pos);
175 return d < this.getBubbleR(cur) ? cur : acc;
176 }, 0);
177 }
178 getBubbleR(d) {
179 const { minR, maxR } = this.options;
180 const curVal = this.getZData(d);
181 if (!curVal) return minR;
182 const [min, max] = this.$$.data.targets.reduce(
183 ([accMin, accMax], cur) => {
184 const val = this.getZData(cur.values[0]);
185 return [Math.min(accMin, val), Math.max(accMax, val)];
186 },
187 [1e4, 0]
188 );
189 const size = min > 0 && max === min ? 0 : curVal / max;
190 return Math.abs(size) * (maxR - minR) + minR;
191 }
192 getZData(d) {
193 return this.$$.isBubbleZType(d) ? this.$$.getBubbleZData(d.value, "z") : d.value;
194 }
195};
196bubblecompare_publicField(_BubbleCompare, "version", `0.0.1`);
197let BubbleCompare = _BubbleCompare;
198
199
200}();
201__webpack_exports__ = __webpack_exports__["default"];
202/******/ return __webpack_exports__;
203/******/ })()
204;
205});
\No newline at end of file