billboard.js 3.11.3 → 3.12.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +1 -5
  2. package/dist/billboard.css +13 -1
  3. package/dist/billboard.js +19672 -24210
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +26 -3
  6. package/dist/billboard.pkgd.js +24515 -30430
  7. package/dist/billboard.pkgd.min.js +33 -3
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +77 -175
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +429 -1134
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.js +666 -1524
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +15 -3
  14. package/dist/plugin/billboardjs-plugin-tableview.js +503 -1175
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +30 -3
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +351 -1055
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -3
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1387 -1854
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2760 -3959
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3504 -5057
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2906 -4072
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +3076 -4506
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
  28. package/dist/theme/dark.css +12 -1
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +12 -1
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +12 -1
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +12 -1
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist/theme/modern.css +12 -1
  37. package/dist/theme/modern.min.css +3 -4
  38. package/dist-esm/billboard.js +9297 -8527
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +20 -27
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +155 -149
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +302 -289
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +236 -236
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +41 -43
  44. package/package.json +29 -49
  45. package/src/Chart/api/axis.ts +6 -13
  46. package/src/Chart/api/chart.ts +12 -11
  47. package/src/Chart/api/data.ts +8 -7
  48. package/src/Chart/api/export.ts +28 -21
  49. package/src/Chart/api/flow.ts +4 -2
  50. package/src/Chart/api/grid.ts +1 -5
  51. package/src/Chart/api/load.ts +2 -2
  52. package/src/Chart/api/regions.ts +29 -5
  53. package/src/Chart/api/selection.ts +2 -2
  54. package/src/Chart/api/show.ts +2 -3
  55. package/src/Chart/api/subchart.ts +2 -2
  56. package/src/Chart/api/tooltip.ts +8 -9
  57. package/src/Chart/api/x.ts +2 -2
  58. package/src/Chart/api/zoom.ts +2 -2
  59. package/src/ChartInternal/Axis/Axis.ts +119 -44
  60. package/src/ChartInternal/Axis/AxisRenderer.ts +53 -38
  61. package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
  62. package/src/ChartInternal/ChartInternal.ts +87 -55
  63. package/src/ChartInternal/data/IData.ts +31 -31
  64. package/src/ChartInternal/data/convert.helper.ts +66 -68
  65. package/src/ChartInternal/data/convert.ts +11 -11
  66. package/src/ChartInternal/data/data.ts +51 -27
  67. package/src/ChartInternal/data/load.ts +7 -6
  68. package/src/ChartInternal/interactions/drag.ts +2 -1
  69. package/src/ChartInternal/interactions/eventrect.ts +84 -32
  70. package/src/ChartInternal/interactions/flow.ts +14 -4
  71. package/src/ChartInternal/interactions/interaction.ts +51 -22
  72. package/src/ChartInternal/interactions/subchart.ts +27 -25
  73. package/src/ChartInternal/interactions/zoom.ts +29 -18
  74. package/src/ChartInternal/internals/category.ts +1 -1
  75. package/src/ChartInternal/internals/class.ts +6 -6
  76. package/src/ChartInternal/internals/clip.ts +8 -4
  77. package/src/ChartInternal/internals/color.ts +70 -42
  78. package/src/ChartInternal/internals/domain.ts +59 -28
  79. package/src/ChartInternal/internals/format.ts +5 -5
  80. package/src/ChartInternal/internals/grid.ts +131 -47
  81. package/src/ChartInternal/internals/legend.ts +93 -61
  82. package/src/ChartInternal/internals/redraw.ts +6 -2
  83. package/src/ChartInternal/internals/region.ts +5 -3
  84. package/src/ChartInternal/internals/scale.ts +28 -15
  85. package/src/ChartInternal/internals/selection.ts +14 -13
  86. package/src/ChartInternal/internals/size.axis.ts +18 -10
  87. package/src/ChartInternal/internals/size.ts +98 -67
  88. package/src/ChartInternal/internals/style.ts +21 -19
  89. package/src/ChartInternal/internals/text.ts +79 -43
  90. package/src/ChartInternal/internals/title.ts +2 -2
  91. package/src/ChartInternal/internals/tooltip.ts +78 -32
  92. package/src/ChartInternal/internals/transform.ts +4 -4
  93. package/src/ChartInternal/internals/type.ts +17 -12
  94. package/src/ChartInternal/shape/arc.ts +78 -44
  95. package/src/ChartInternal/shape/area.ts +19 -22
  96. package/src/ChartInternal/shape/bar.ts +41 -31
  97. package/src/ChartInternal/shape/bubble.ts +5 -5
  98. package/src/ChartInternal/shape/candlestick.ts +15 -13
  99. package/src/ChartInternal/shape/funnel.ts +317 -0
  100. package/src/ChartInternal/shape/gauge.ts +16 -9
  101. package/src/ChartInternal/shape/line.ts +62 -46
  102. package/src/ChartInternal/shape/point.common.ts +1 -4
  103. package/src/ChartInternal/shape/point.ts +54 -34
  104. package/src/ChartInternal/shape/polar.ts +4 -2
  105. package/src/ChartInternal/shape/radar.ts +40 -22
  106. package/src/ChartInternal/shape/shape.ts +84 -58
  107. package/src/ChartInternal/shape/treemap.ts +31 -20
  108. package/src/Plugin/bubblecompare/index.ts +1 -3
  109. package/src/Plugin/sparkline/index.ts +3 -4
  110. package/src/Plugin/stanford/ColorScale.ts +3 -2
  111. package/src/Plugin/stanford/Elements.ts +15 -6
  112. package/src/Plugin/stanford/Options.ts +5 -5
  113. package/src/Plugin/stanford/index.ts +13 -9
  114. package/src/Plugin/tableview/Options.ts +1 -1
  115. package/src/Plugin/tableview/const.ts +1 -4
  116. package/src/Plugin/tableview/index.ts +11 -9
  117. package/src/Plugin/textoverlap/index.ts +4 -6
  118. package/src/config/Options/Options.ts +3 -3
  119. package/src/config/Options/axis/axis.ts +36 -0
  120. package/src/config/Options/axis/x.ts +34 -14
  121. package/src/config/Options/axis/y.ts +13 -13
  122. package/src/config/Options/axis/y2.ts +23 -10
  123. package/src/config/Options/common/color.ts +4 -4
  124. package/src/config/Options/common/grid.ts +4 -4
  125. package/src/config/Options/common/legend.ts +12 -13
  126. package/src/config/Options/common/main.ts +23 -23
  127. package/src/config/Options/common/point.ts +17 -18
  128. package/src/config/Options/common/title.ts +2 -2
  129. package/src/config/Options/common/tooltip.ts +13 -11
  130. package/src/config/Options/data/axis.ts +2 -2
  131. package/src/config/Options/data/data.ts +48 -45
  132. package/src/config/Options/interaction/interaction.ts +1 -1
  133. package/src/config/Options/interaction/subchart.ts +2 -2
  134. package/src/config/Options/interaction/zoom.ts +9 -9
  135. package/src/config/Options/shape/arc.ts +10 -13
  136. package/src/config/Options/shape/area.ts +5 -7
  137. package/src/config/Options/shape/bar.ts +8 -10
  138. package/src/config/Options/shape/bubble.ts +1 -1
  139. package/src/config/Options/shape/candlestick.ts +2 -2
  140. package/src/config/Options/shape/donut.ts +4 -4
  141. package/src/config/Options/shape/funnel.ts +38 -0
  142. package/src/config/Options/shape/gauge.ts +6 -6
  143. package/src/config/Options/shape/line.ts +3 -3
  144. package/src/config/Options/shape/pie.ts +5 -5
  145. package/src/config/Options/shape/polar.ts +3 -3
  146. package/src/config/Options/shape/radar.ts +2 -2
  147. package/src/config/Options/shape/scatter.ts +1 -1
  148. package/src/config/Options/shape/treemap.ts +1 -1
  149. package/src/config/Store/Element.ts +8 -5
  150. package/src/config/Store/State.ts +20 -13
  151. package/src/config/classes.ts +14 -4
  152. package/src/config/config.ts +1 -1
  153. package/src/config/const.ts +2 -0
  154. package/src/config/resolver/axis.ts +4 -4
  155. package/src/config/resolver/interaction.ts +3 -7
  156. package/src/config/resolver/shape.ts +17 -12
  157. package/src/core.ts +2 -3
  158. package/src/index.esm.ts +3 -6
  159. package/src/index.ts +2 -2
  160. package/src/module/Cache.ts +2 -3
  161. package/src/module/browser.ts +15 -10
  162. package/src/module/error.ts +9 -8
  163. package/src/module/generator.ts +3 -5
  164. package/src/module/util.ts +62 -39
  165. package/src/module/worker.ts +14 -11
  166. package/src/scss/billboard.scss +18 -0
  167. package/src/scss/theme/dark.scss +17 -0
  168. package/src/scss/theme/datalab.scss +17 -0
  169. package/src/scss/theme/graph.scss +17 -0
  170. package/src/scss/theme/insight.scss +17 -0
  171. package/src/scss/theme/modern.scss +17 -0
  172. package/types/axis.d.ts +17 -0
  173. package/types/bb.d.ts +1 -0
  174. package/types/index.d.ts +1 -0
  175. package/types/options.d.ts +9 -0
  176. package/types/options.shape.d.ts +26 -1
  177. package/types/types.d.ts +1 -0
@@ -5,20 +5,20 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.11.3
8
+ * @version 3.12.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
12
12
  (function webpackUniversalModuleDefinition(root, factory) {
13
13
  if(typeof exports === 'object' && typeof module === 'object')
14
- module.exports = factory(require("d3-delaunay"), require("d3-polygon"), require("d3-selection"), require("d3-brush"));
14
+ module.exports = factory(require("d3-delaunay"), require("d3-polygon"), require("d3-brush"), require("d3-selection"));
15
15
  else if(typeof define === 'function' && define.amd)
16
- define("bb", ["d3-delaunay", "d3-polygon", "d3-selection", "d3-brush"], factory);
16
+ define("bb", ["d3-delaunay", "d3-polygon", "d3-brush", "d3-selection"], factory);
17
17
  else if(typeof exports === 'object')
18
- exports["bb"] = factory(require("d3-delaunay"), require("d3-polygon"), require("d3-selection"), require("d3-brush"));
18
+ exports["bb"] = factory(require("d3-delaunay"), require("d3-polygon"), require("d3-brush"), require("d3-selection"));
19
19
  else
20
20
  root["bb"] = root["bb"] || {}, root["bb"]["plugin"] = root["bb"]["plugin"] || {}, root["bb"]["plugin"]["textoverlap"] = factory(root["d3"], root["d3"], root["d3"], root["d3"]);
21
- })(this, function(__WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__13__, __WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__3__) {
21
+ })(this, function(__WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__13__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__1__) {
22
22
  return /******/ (function() { // webpackBootstrap
23
23
  /******/ "use strict";
24
24
  /******/ var __webpack_modules__ = ({
@@ -105,506 +105,183 @@ __webpack_require__.d(__webpack_exports__, {
105
105
  "default": function() { return /* binding */ TextOverlap; }
106
106
  });
107
107
 
108
- ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/newArrowCheck.js
109
- function _newArrowCheck(innerThis, boundThis) {
110
- if (innerThis !== boundThis) {
111
- throw new TypeError("Cannot instantiate an arrow function");
112
- }
113
- }
114
- ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
115
- function _assertThisInitialized(self) {
116
- if (self === void 0) {
117
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
118
- }
119
- return self;
120
- }
121
- ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
122
- function _setPrototypeOf(o, p) {
123
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
124
- o.__proto__ = p;
125
- return o;
126
- };
127
- return _setPrototypeOf(o, p);
128
- }
129
- ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js
130
-
131
- function _inheritsLoose(subClass, superClass) {
132
- subClass.prototype = Object.create(superClass.prototype);
133
- subClass.prototype.constructor = subClass;
134
- _setPrototypeOf(subClass, superClass);
135
- }
136
108
  // EXTERNAL MODULE: external {"commonjs":"d3-delaunay","commonjs2":"d3-delaunay","amd":"d3-delaunay","root":"d3"}
137
109
  var external_commonjs_d3_delaunay_commonjs2_d3_delaunay_amd_d3_delaunay_root_d3_ = __webpack_require__(12);
138
110
  // EXTERNAL MODULE: external {"commonjs":"d3-polygon","commonjs2":"d3-polygon","amd":"d3-polygon","root":"d3"}
139
111
  var external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_ = __webpack_require__(13);
140
- ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
141
- function _typeof(o) {
142
- "@babel/helpers - typeof";
143
-
144
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
145
- return typeof o;
146
- } : function (o) {
147
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
148
- }, _typeof(o);
149
- }
150
- ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPrimitive.js
151
-
152
- function toPrimitive(t, r) {
153
- if ("object" != _typeof(t) || !t) return t;
154
- var e = t[Symbol.toPrimitive];
155
- if (void 0 !== e) {
156
- var i = e.call(t, r || "default");
157
- if ("object" != _typeof(i)) return i;
158
- throw new TypeError("@@toPrimitive must return a primitive value.");
159
- }
160
- return ("string" === r ? String : Number)(t);
161
- }
162
- ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
163
-
164
-
165
- function toPropertyKey(t) {
166
- var i = toPrimitive(t, "string");
167
- return "symbol" == _typeof(i) ? i : String(i);
168
- }
169
- ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
170
-
171
- function _defineProperty(obj, key, value) {
172
- key = toPropertyKey(key);
173
- if (key in obj) {
174
- Object.defineProperty(obj, key, {
175
- value: value,
176
- enumerable: true,
177
- configurable: true,
178
- writable: true
179
- });
180
- } else {
181
- obj[key] = value;
182
- }
183
- return obj;
184
- }
185
- // EXTERNAL MODULE: external {"commonjs":"d3-selection","commonjs2":"d3-selection","amd":"d3-selection","root":"d3"}
186
- var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(1);
187
112
  // EXTERNAL MODULE: external {"commonjs":"d3-brush","commonjs2":"d3-brush","amd":"d3-brush","root":"d3"}
188
113
  var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(3);
114
+ // EXTERNAL MODULE: external {"commonjs":"d3-selection","commonjs2":"d3-selection","amd":"d3-selection","root":"d3"}
115
+ var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(1);
189
116
  ;// CONCATENATED MODULE: ./src/module/browser.ts
190
-
191
- /**
192
- * Copyright (c) 2017 ~ present NAVER Corp.
193
- * billboard.js project is licensed under the MIT license
194
- */
195
- /**
196
- * Window object
197
- * @private
198
- */
199
- /* eslint-disable no-new-func, no-undef */
200
-
201
-
202
- /**
203
- * Get global object
204
- * @returns {object} window object
205
- * @private
206
- */
207
117
  function getGlobal() {
208
118
  return typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis || typeof global === "object" && global !== null && global.Object === Object && global || typeof self === "object" && self !== null && self.Object === Object && self || Function("return this")();
209
119
  }
210
-
211
- /**
212
- * Get fallback object
213
- * @param {object} w global object
214
- * @returns {Array} fallback object array
215
- * @private
216
- */
217
120
  function getFallback(w) {
218
- var _this = this;
219
- const hasRAF = typeof (w == null ? void 0 : w.requestAnimationFrame) === "function" && typeof (w == null ? void 0 : w.cancelAnimationFrame) === "function",
220
- hasRIC = typeof (w == null ? void 0 : w.requestIdleCallback) === "function" && typeof (w == null ? void 0 : w.cancelIdleCallback) === "function",
221
- request = function (cb) {
222
- _newArrowCheck(this, _this);
223
- return setTimeout(cb, 1);
224
- }.bind(this),
225
- cancel = function (id) {
226
- _newArrowCheck(this, _this);
227
- return clearTimeout(id);
228
- }.bind(this);
229
- return [hasRAF ? w.requestAnimationFrame : request, hasRAF ? w.cancelAnimationFrame : cancel, hasRIC ? w.requestIdleCallback : request, hasRIC ? w.cancelIdleCallback : cancel];
121
+ const hasRAF = typeof (w == null ? void 0 : w.requestAnimationFrame) === "function" && typeof (w == null ? void 0 : w.cancelAnimationFrame) === "function";
122
+ const hasRIC = typeof (w == null ? void 0 : w.requestIdleCallback) === "function" && typeof (w == null ? void 0 : w.cancelIdleCallback) === "function";
123
+ const request = (cb) => setTimeout(cb, 1);
124
+ const cancel = (id) => clearTimeout(id);
125
+ return [
126
+ hasRAF ? w.requestAnimationFrame : request,
127
+ hasRAF ? w.cancelAnimationFrame : cancel,
128
+ hasRIC ? w.requestIdleCallback : request,
129
+ hasRIC ? w.cancelIdleCallback : cancel
130
+ ];
230
131
  }
231
- const win = getGlobal(),
232
- doc = win == null ? void 0 : win.document,
233
- _getFallback = getFallback(win),
234
- requestAnimationFrame = _getFallback[0],
235
- cancelAnimationFrame = _getFallback[1],
236
- requestIdleCallback = _getFallback[2],
237
- cancelIdleCallback = _getFallback[3];
238
- ;// CONCATENATED MODULE: ./src/module/util.ts
132
+ const win = getGlobal();
133
+ const doc = win == null ? void 0 : win.document;
134
+ const [
135
+ requestAnimationFrame,
136
+ cancelAnimationFrame,
137
+ requestIdleCallback,
138
+ cancelIdleCallback
139
+ ] = getFallback(win);
239
140
 
240
141
 
241
- var _this = undefined;
242
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
243
- function _objectSpread(e) { for (var r = 1, t; r < arguments.length; r++) { t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
244
- /**
245
- * Copyright (c) 2017 ~ present NAVER Corp.
246
- * billboard.js project is licensed under the MIT license
247
- * @ignore
248
- */
142
+ ;// CONCATENATED MODULE: ./src/module/util.ts
143
+ var __defProp = Object.defineProperty;
144
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
145
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
146
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
147
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
148
+ var __spreadValues = (a, b) => {
149
+ for (var prop in b || (b = {}))
150
+ if (__hasOwnProp.call(b, prop))
151
+ __defNormalProp(a, prop, b[prop]);
152
+ if (__getOwnPropSymbols)
153
+ for (var prop of __getOwnPropSymbols(b)) {
154
+ if (__propIsEnum.call(b, prop))
155
+ __defNormalProp(a, prop, b[prop]);
156
+ }
157
+ return a;
158
+ };
249
159
 
250
160
 
251
161
 
252
162
 
253
- const isValue = function (v) {
254
- _newArrowCheck(this, _this);
255
- return v || v === 0;
256
- }.bind(undefined),
257
- isFunction = function (v) {
258
- _newArrowCheck(this, _this);
259
- return typeof v === "function";
260
- }.bind(undefined),
261
- isString = function (v) {
262
- _newArrowCheck(this, _this);
263
- return typeof v === "string";
264
- }.bind(undefined),
265
- isNumber = function (v) {
266
- _newArrowCheck(this, _this);
267
- return typeof v === "number";
268
- }.bind(undefined),
269
- isUndefined = function (v) {
270
- _newArrowCheck(this, _this);
271
- return typeof v === "undefined";
272
- }.bind(undefined),
273
- isDefined = function (v) {
274
- _newArrowCheck(this, _this);
275
- return typeof v !== "undefined";
276
- }.bind(undefined),
277
- isboolean = function (v) {
278
- _newArrowCheck(this, _this);
279
- return typeof v === "boolean";
280
- }.bind(undefined),
281
- ceil10 = function (v) {
282
- _newArrowCheck(this, _this);
283
- return Math.ceil(v / 10) * 10;
284
- }.bind(undefined),
285
- asHalfPixel = function (n) {
286
- _newArrowCheck(this, _this);
287
- return Math.ceil(n) + .5;
288
- }.bind(undefined),
289
- diffDomain = function (d) {
290
- _newArrowCheck(this, _this);
291
- return d[1] - d[0];
292
- }.bind(undefined),
293
- isObjectType = function (v) {
294
- _newArrowCheck(this, _this);
295
- return typeof v === "object";
296
- }.bind(undefined),
297
- isEmpty = function (o) {
298
- _newArrowCheck(this, _this);
299
- return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
300
- }.bind(undefined),
301
- notEmpty = function (o) {
302
- _newArrowCheck(this, _this);
303
- return !isEmpty(o);
304
- }.bind(undefined),
305
- isArray = function (arr) {
306
- _newArrowCheck(this, _this);
307
- return Array.isArray(arr);
308
- }.bind(undefined),
309
- isObject = function (obj) {
310
- _newArrowCheck(this, _this);
311
- return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
312
- }.bind(undefined);
313
- /**
314
- * Check if is array
315
- * @param {Array} arr Data to be checked
316
- * @returns {boolean}
317
- * @private
318
- */
319
- /**
320
- * Check if is object
321
- * @param {object} obj Data to be checked
322
- * @returns {boolean}
323
- * @private
324
- */
325
- /**
326
- * Get specified key value from object
327
- * If default value is given, will return if given key value not found
328
- * @param {object} options Source object
329
- * @param {string} key Key value
330
- * @param {*} defaultValue Default value
331
- * @returns {*}
332
- * @private
333
- */
163
+ const isValue = (v) => v || v === 0;
164
+ const isFunction = (v) => typeof v === "function";
165
+ const isString = (v) => typeof v === "string";
166
+ const isNumber = (v) => typeof v === "number";
167
+ const isUndefined = (v) => typeof v === "undefined";
168
+ const isDefined = (v) => typeof v !== "undefined";
169
+ const isBoolean = (v) => typeof v === "boolean";
170
+ const ceil10 = (v) => Math.ceil(v / 10) * 10;
171
+ const asHalfPixel = (n) => Math.ceil(n) + 0.5;
172
+ const diffDomain = (d) => d[1] - d[0];
173
+ const isObjectType = (v) => typeof v === "object";
174
+ const isEmpty = (o) => isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
175
+ const notEmpty = (o) => !isEmpty(o);
176
+ const isArray = (arr) => Array.isArray(arr);
177
+ const isObject = (obj) => obj && !(obj == null ? void 0 : obj.nodeType) && isObjectType(obj) && !isArray(obj);
334
178
  function getOption(options, key, defaultValue) {
335
179
  return isDefined(options[key]) ? options[key] : defaultValue;
336
180
  }
337
-
338
- /**
339
- * Check if value exist in the given object
340
- * @param {object} dict Target object to be checked
341
- * @param {*} value Value to be checked
342
- * @returns {boolean}
343
- * @private
344
- */
345
181
  function hasValue(dict, value) {
346
- var _this2 = this;
347
- let found = !1;
348
- Object.keys(dict).forEach(function (key) {
349
- _newArrowCheck(this, _this2);
350
- return dict[key] === value && (found = !0);
351
- }.bind(this));
182
+ let found = false;
183
+ Object.keys(dict).forEach((key) => dict[key] === value && (found = true));
352
184
  return found;
353
185
  }
354
-
355
- /**
356
- * Call function with arguments
357
- * @param {Function} fn Function to be called
358
- * @param {*} thisArg "this" value for fn
359
- * @param {*} args Arguments for fn
360
- * @returns {boolean} true: fn is function, false: fn is not function
361
- * @private
362
- */
363
- function callFn(fn, thisArg) {
186
+ function callFn(fn, thisArg, ...args) {
364
187
  const isFn = isFunction(fn);
365
- for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
366
- args[_key - 2] = arguments[_key];
367
- }
368
- isFn && fn.call.apply(fn, [thisArg].concat(args));
188
+ isFn && fn.call(thisArg, ...args);
369
189
  return isFn;
370
190
  }
371
-
372
- /**
373
- * Call function after all transitions ends
374
- * @param {d3.transition} transition Transition
375
- * @param {Fucntion} cb Callback function
376
- * @private
377
- */
378
191
  function endall(transition, cb) {
379
- var _this3 = this;
380
192
  let n = 0;
381
- const end = function () {
382
- for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
383
- args[_key2] = arguments[_key2];
384
- }
385
- --n || cb.apply.apply(cb, [this].concat(args));
193
+ const end = function(...args) {
194
+ !--n && cb.apply(this, ...args);
386
195
  };
387
-
388
- // if is transition selection
389
196
  if ("duration" in transition) {
390
- transition.each(function () {
391
- _newArrowCheck(this, _this3);
392
- return ++n;
393
- }.bind(this)).on("end", end);
197
+ transition.each(() => ++n).on("end", end);
394
198
  } else {
395
199
  ++n;
396
200
  transition.call(end);
397
201
  }
398
202
  }
399
-
400
- /**
401
- * Replace tag sign to html entity
402
- * @param {string} str Target string value
403
- * @returns {string}
404
- * @private
405
- */
406
203
  function sanitize(str) {
407
204
  return isString(str) ? str.replace(/<(script|img)?/ig, "&lt;").replace(/(script)?>/ig, "&gt;") : str;
408
205
  }
409
-
410
- /**
411
- * Set text value. If there's multiline add nodes.
412
- * @param {d3Selection} node Text node
413
- * @param {string} text Text value string
414
- * @param {Array} dy dy value for multilined text
415
- * @param {boolean} toMiddle To be alingned vertically middle
416
- * @private
417
- */
418
- function setTextValue(node, text, dy, toMiddle) {
419
- var _this4 = this;
420
- if (dy === void 0) {
421
- dy = [-1, 1];
422
- }
423
- if (toMiddle === void 0) {
424
- toMiddle = !1;
425
- }
206
+ function setTextValue(node, text, dy = [-1, 1], toMiddle = false) {
426
207
  if (!node || !isString(text)) {
427
208
  return;
428
209
  }
429
210
  if (text.indexOf("\n") === -1) {
430
211
  node.text(text);
431
212
  } else {
432
- const diff = [node.text(), text].map(function (v) {
433
- _newArrowCheck(this, _this4);
434
- return v.replace(/[\s\n]/g, "");
435
- }.bind(this));
213
+ const diff = [node.text(), text].map((v) => v.replace(/[\s\n]/g, ""));
436
214
  if (diff[0] !== diff[1]) {
437
- const multiline = text.split("\n"),
438
- len = toMiddle ? multiline.length - 1 : 1;
439
- // reset possible text
215
+ const multiline = text.split("\n");
216
+ const len = toMiddle ? multiline.length - 1 : 1;
440
217
  node.html("");
441
- multiline.forEach(function (v, i) {
442
- _newArrowCheck(this, _this4);
443
- node.append("tspan").attr("x", 0).attr("dy", (i === 0 ? dy[0] * len : dy[1]) + "em").text(v);
444
- }.bind(this));
218
+ multiline.forEach((v, i) => {
219
+ node.append("tspan").attr("x", 0).attr("dy", `${i === 0 ? dy[0] * len : dy[1]}em`).text(v);
220
+ });
445
221
  }
446
222
  }
447
223
  }
448
-
449
- /**
450
- * Substitution of SVGPathSeg API polyfill
451
- * @param {SVGGraphicsElement} path Target svg element
452
- * @returns {Array}
453
- * @private
454
- */
455
224
  function getRectSegList(path) {
456
- /*
457
- * seg1 ---------- seg2
458
- * | |
459
- * | |
460
- * | |
461
- * seg0 ---------- seg3
462
- * */
463
- const _path$getBBox = path.getBBox(),
464
- x = _path$getBBox.x,
465
- y = _path$getBBox.y,
466
- width = _path$getBBox.width,
467
- height = _path$getBBox.height;
468
- return [{
469
- x: x,
470
- y: y + height
471
- },
472
- // seg0
473
- {
474
- x: x,
475
- y: y
476
- },
477
- // seg1
478
- {
479
- x: x + width,
480
- y: y
481
- },
482
- // seg2
483
- {
484
- x: x + width,
485
- y: y + height
486
- } // seg3
225
+ const { x, y, width, height } = path.getBBox();
226
+ return [
227
+ { x, y: y + height },
228
+ // seg0
229
+ { x, y },
230
+ // seg1
231
+ { x: x + width, y },
232
+ // seg2
233
+ { x: x + width, y: y + height }
234
+ // seg3
487
235
  ];
488
236
  }
489
-
490
- /**
491
- * Get svg bounding path box dimension
492
- * @param {SVGGraphicsElement} path Target svg element
493
- * @returns {object}
494
- * @private
495
- */
496
237
  function getPathBox(path) {
497
- const _path$getBoundingClie = path.getBoundingClientRect(),
498
- width = _path$getBoundingClie.width,
499
- height = _path$getBoundingClie.height,
500
- items = getRectSegList(path),
501
- x = items[0].x,
502
- y = Math.min(items[0].y, items[1].y);
238
+ const { width, height } = path.getBoundingClientRect();
239
+ const items = getRectSegList(path);
240
+ const x = items[0].x;
241
+ const y = Math.min(items[0].y, items[1].y);
503
242
  return {
504
- x: x,
505
- y: y,
506
- width: width,
507
- height: height
243
+ x,
244
+ y,
245
+ width,
246
+ height
508
247
  };
509
248
  }
510
-
511
- /**
512
- * Get event's current position coordinates
513
- * @param {object} event Event object
514
- * @param {SVGElement|HTMLElement} element Target element
515
- * @returns {Array} [x, y] Coordinates x, y array
516
- * @private
517
- */
518
249
  function getPointer(event, element) {
519
- var _ref,
520
- _this5 = this;
521
- const touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]);
250
+ var _a;
251
+ const touches = event && ((_a = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _a[0]);
522
252
  let pointer = [0, 0];
523
253
  try {
524
254
  pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element);
525
- } catch (e) {}
526
- return pointer.map(function (v) {
527
- _newArrowCheck(this, _this5);
528
- return isNaN(v) ? 0 : v;
529
- }.bind(this));
255
+ } catch (e) {
256
+ }
257
+ return pointer.map((v) => isNaN(v) ? 0 : v);
530
258
  }
531
-
532
- /**
533
- * Return brush selection array
534
- * @param {object} ctx Current instance
535
- * @returns {d3.brushSelection}
536
- * @private
537
- */
538
259
  function getBrushSelection(ctx) {
539
- const event = ctx.event,
540
- $el = ctx.$el,
541
- main = $el.subchart.main || $el.main;
260
+ const { event, $el } = ctx;
261
+ const main = $el.subchart.main || $el.main;
542
262
  let selection;
543
-
544
- // check from event
545
263
  if (event && event.type === "brush") {
546
264
  selection = event.selection;
547
- // check from brush area selection
548
265
  } else if (main && (selection = main.select(".bb-brush").node())) {
549
266
  selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection);
550
267
  }
551
268
  return selection;
552
269
  }
553
-
554
- /**
555
- * Get boundingClientRect.
556
- * Cache the evaluated value once it was called.
557
- * @param {HTMLElement} node Target element
558
- * @returns {object}
559
- * @private
560
- */
561
270
  function getBoundingRect(node) {
562
271
  const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
563
272
  return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
564
273
  }
565
-
566
- /**
567
- * Retrun random number
568
- * @param {boolean} asStr Convert returned value as string
569
- * @param {number} min Minimum value
570
- * @param {number} max Maximum value
571
- * @returns {number|string}
572
- * @private
573
- */
574
- function getRandom(asStr, min, max) {
575
- if (asStr === void 0) {
576
- asStr = !0;
577
- }
578
- if (min === void 0) {
579
- min = 0;
580
- }
581
- if (max === void 0) {
582
- max = 1e4;
583
- }
584
- const crpt = win.crypto || win.msCrypto,
585
- rand = crpt ? min + crpt.getRandomValues(new Uint32Array(1))[0] % (max - min + 1) : Math.floor(Math.random() * (max - min) + min);
586
- return asStr ? rand + "" : rand;
274
+ function getRandom(asStr = true, min = 0, max = 1e4) {
275
+ const crpt = win.crypto || win.msCrypto;
276
+ const rand = crpt ? min + crpt.getRandomValues(new Uint32Array(1))[0] % (max - min + 1) : Math.floor(Math.random() * (max - min) + min);
277
+ return asStr ? String(rand) : rand;
587
278
  }
588
-
589
- /**
590
- * Find index based on binary search
591
- * @param {Array} arr Data array
592
- * @param {number} v Target number to find
593
- * @param {number} start Start index of data array
594
- * @param {number} end End index of data arr
595
- * @param {boolean} isRotated Weather is roted axis
596
- * @returns {number} Index number
597
- * @private
598
- */
599
279
  function findIndex(arr, v, start, end, isRotated) {
600
280
  if (start > end) {
601
281
  return -1;
602
282
  }
603
283
  const mid = Math.floor((start + end) / 2);
604
- let _arr$mid = arr[mid],
605
- x = _arr$mid.x,
606
- _arr$mid$w = _arr$mid.w,
607
- w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
284
+ let { x, w = 0 } = arr[mid];
608
285
  if (isRotated) {
609
286
  x = arr[mid].y;
610
287
  w = arr[mid].h;
@@ -614,75 +291,30 @@ function findIndex(arr, v, start, end, isRotated) {
614
291
  }
615
292
  return v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
616
293
  }
617
-
618
- /**
619
- * Check if brush is empty
620
- * @param {object} ctx Bursh context
621
- * @returns {boolean}
622
- * @private
623
- */
624
294
  function brushEmpty(ctx) {
625
295
  const selection = getBrushSelection(ctx);
626
296
  if (selection) {
627
- // brush selected area
628
- // two-dimensional: [[x0, y0], [x1, y1]]
629
- // one-dimensional: [x0, x1] or [y0, y1]
630
297
  return selection[0] === selection[1];
631
298
  }
632
- return !0;
299
+ return true;
633
300
  }
634
-
635
- /**
636
- * Deep copy object
637
- * @param {object} objectN Source object
638
- * @returns {object} Cloned object
639
- * @private
640
- */
641
- function deepClone() {
642
- var _this6 = this;
643
- const _clone = function clone(v) {
644
- _newArrowCheck(this, _this6);
301
+ function deepClone(...objectN) {
302
+ const clone = (v) => {
645
303
  if (isObject(v) && v.constructor) {
646
304
  const r = new v.constructor();
647
305
  for (const k in v) {
648
- r[k] = _clone(v[k]);
306
+ r[k] = clone(v[k]);
649
307
  }
650
308
  return r;
651
309
  }
652
310
  return v;
653
- }.bind(this);
654
- for (var _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
655
- objectN[_key3] = arguments[_key3];
656
- }
657
- return objectN.map(function (v) {
658
- _newArrowCheck(this, _this6);
659
- return _clone(v);
660
- }.bind(this)).reduce(function (a, c) {
661
- _newArrowCheck(this, _this6);
662
- return _objectSpread(_objectSpread({}, a), c);
663
- }.bind(this));
311
+ };
312
+ return objectN.map((v) => clone(v)).reduce((a, c) => __spreadValues(__spreadValues({}, a), c));
664
313
  }
665
-
666
- /**
667
- * Extend target from source object
668
- * @param {object} target Target object
669
- * @param {object|Array} source Source object
670
- * @returns {object}
671
- * @private
672
- */
673
- function extend(target, source) {
674
- var _this7 = this;
675
- if (target === void 0) {
676
- target = {};
677
- }
314
+ function extend(target = {}, source) {
678
315
  if (isArray(source)) {
679
- source.forEach(function (v) {
680
- _newArrowCheck(this, _this7);
681
- return extend(target, v);
682
- }.bind(this));
316
+ source.forEach((v) => extend(target, v));
683
317
  }
684
-
685
- // exclude name with only numbers
686
318
  for (const p in source) {
687
319
  if (/^\d+$/.test(p) || p in target) {
688
320
  continue;
@@ -691,753 +323,417 @@ function extend(target, source) {
691
323
  }
692
324
  return target;
693
325
  }
694
-
695
- /**
696
- * Return first letter capitalized
697
- * @param {string} str Target string
698
- * @returns {string} capitalized string
699
- * @private
700
- */
701
- const capitalize = function (str) {
702
- _newArrowCheck(this, _this);
703
- return str.charAt(0).toUpperCase() + str.slice(1);
704
- }.bind(undefined);
705
-
706
- /**
707
- * Camelize from kebob style string
708
- * @param {string} str Target string
709
- * @param {string} separator Separator string
710
- * @returns {string} camelized string
711
- * @private
712
- */
713
- function camelize(str, separator) {
714
- var _this8 = this;
715
- if (separator === void 0) {
716
- separator = "-";
717
- }
718
- return str.split(separator).map(function (v, i) {
719
- _newArrowCheck(this, _this8);
720
- return i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase();
721
- }.bind(this)).join("");
326
+ const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
327
+ function camelize(str, separator = "-") {
328
+ return str.split(separator).map((v, i) => i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase()).join("");
722
329
  }
723
-
724
- /**
725
- * Convert to array
726
- * @param {object} v Target to be converted
727
- * @returns {Array}
728
- * @private
729
- */
730
- const toArray = function (v) {
731
- _newArrowCheck(this, _this);
732
- return [].slice.call(v);
733
- }.bind(undefined);
734
-
735
- /**
736
- * Add CSS rules
737
- * @param {object} style Style object
738
- * @param {string} selector Selector string
739
- * @param {Array} prop Prps arrary
740
- * @returns {number} Newely added rule index
741
- * @private
742
- */
330
+ const toArray = (v) => [].slice.call(v);
743
331
  function addCssRules(style, selector, prop) {
744
- var _this9 = this;
745
- const _style$rootSelector = style.rootSelector,
746
- rootSelector = _style$rootSelector === void 0 ? "" : _style$rootSelector,
747
- sheet = style.sheet,
748
- getSelector = function (s) {
749
- _newArrowCheck(this, _this9);
750
- return s.replace(/\s?(bb-)/g, ".$1").replace(/\.+/g, ".");
751
- }.bind(this),
752
- rule = rootSelector + " " + getSelector(selector) + " {" + prop.join(";") + "}";
753
- return sheet[sheet.insertRule ? "insertRule" : "addRule"](rule, sheet.cssRules.length);
332
+ const { rootSelector = "", sheet } = style;
333
+ const getSelector = (s) => s.replace(/\s?(bb-)/g, ".$1").replace(/\.+/g, ".");
334
+ const rule = `${rootSelector} ${getSelector(selector)} {${prop.join(";")}}`;
335
+ return sheet[sheet.insertRule ? "insertRule" : "addRule"](
336
+ rule,
337
+ sheet.cssRules.length
338
+ );
754
339
  }
755
-
756
- /**
757
- * Get css rules for specified stylesheets
758
- * @param {Array} styleSheets The stylesheets to get the rules from
759
- * @returns {Array}
760
- * @private
761
- */
762
340
  function getCssRules(styleSheets) {
763
- var _this10 = this;
764
341
  let rules = [];
765
- styleSheets.forEach(function (sheet) {
766
- _newArrowCheck(this, _this10);
342
+ styleSheets.forEach((sheet) => {
343
+ var _a;
767
344
  try {
768
345
  if (sheet.cssRules && sheet.cssRules.length) {
769
346
  rules = rules.concat(toArray(sheet.cssRules));
770
347
  }
771
348
  } catch (e) {
772
- var _window$console;
773
- (_window$console = win.console) == null || _window$console.warn("Error while reading rules from " + sheet.href + ": " + e.toString());
349
+ (_a = win.console) == null ? void 0 : _a.warn(`Error while reading rules from ${sheet.href}: ${e.toString()}`);
774
350
  }
775
- }.bind(this));
351
+ });
776
352
  return rules;
777
353
  }
778
-
779
- /**
780
- * Get current window and container scroll position
781
- * @param {HTMLElement} node Target element
782
- * @returns {object} window scroll position
783
- * @private
784
- */
785
354
  function getScrollPosition(node) {
786
- var _ref2, _ref3, _window$pageXOffset, _ref4, _ref5, _window$pageYOffset;
355
+ var _a, _b, _c, _d;
787
356
  return {
788
- x: (_ref2 = ((_ref3 = (_window$pageXOffset = win.pageXOffset) != null ? _window$pageXOffset : win.scrollX) != null ? _ref3 : 0) + node.scrollLeft) != null ? _ref2 : 0,
789
- y: (_ref4 = ((_ref5 = (_window$pageYOffset = win.pageYOffset) != null ? _window$pageYOffset : win.scrollY) != null ? _ref5 : 0) + node.scrollTop) != null ? _ref4 : 0
357
+ x: ((_b = (_a = win.pageXOffset) != null ? _a : win.scrollX) != null ? _b : 0) + node.scrollLeft,
358
+ y: ((_d = (_c = win.pageYOffset) != null ? _c : win.scrollY) != null ? _d : 0) + node.scrollTop
790
359
  };
791
360
  }
792
-
793
- /**
794
- * Gets the SVGMatrix of an SVGGElement
795
- * @param {SVGElement} node Node element
796
- * @returns {SVGMatrix} matrix
797
- * @private
798
- */
799
361
  function getTranslation(node) {
800
- const transform = node ? node.transform : null,
801
- baseVal = transform && transform.baseVal;
802
- return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
803
- a: 0,
804
- b: 0,
805
- c: 0,
806
- d: 0,
807
- e: 0,
808
- f: 0
809
- };
362
+ const transform = node ? node.transform : null;
363
+ const baseVal = transform && transform.baseVal;
364
+ return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : { a: 0, b: 0, c: 0, d: 0, e: 0, f: 0 };
810
365
  }
811
-
812
- /**
813
- * Get unique value from array
814
- * @param {Array} data Source data
815
- * @returns {Array} Unique array value
816
- * @private
817
- */
818
366
  function getUnique(data) {
819
- var _this11 = this;
820
- const isDate = data[0] instanceof Date,
821
- d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
822
- _newArrowCheck(this, _this11);
823
- return self.indexOf(v) === i;
824
- }.bind(this));
825
- return isDate ? d.map(function (v) {
826
- _newArrowCheck(this, _this11);
827
- return new Date(v);
828
- }.bind(this)) : d;
367
+ const isDate = data[0] instanceof Date;
368
+ const d = (isDate ? data.map(Number) : data).filter((v, i, self) => self.indexOf(v) === i);
369
+ return isDate ? d.map((v) => new Date(v)) : d;
829
370
  }
830
-
831
- /**
832
- * Merge array
833
- * @param {Array} arr Source array
834
- * @returns {Array}
835
- * @private
836
- */
837
371
  function mergeArray(arr) {
838
- var _this12 = this;
839
- return arr && arr.length ? arr.reduce(function (p, c) {
840
- _newArrowCheck(this, _this12);
841
- return p.concat(c);
842
- }.bind(this)) : [];
372
+ return arr && arr.length ? arr.reduce((p, c) => p.concat(c)) : [];
843
373
  }
844
-
845
- /**
846
- * Merge object returning new object
847
- * @param {object} target Target object
848
- * @param {object} objectN Source object
849
- * @returns {object} merged target object
850
- * @private
851
- */
852
- function mergeObj(target) {
853
- for (var _this13 = this, _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
854
- objectN[_key4 - 1] = arguments[_key4];
855
- }
374
+ function mergeObj(target, ...objectN) {
856
375
  if (!objectN.length || objectN.length === 1 && !objectN[0]) {
857
376
  return target;
858
377
  }
859
378
  const source = objectN.shift();
860
379
  if (isObject(target) && isObject(source)) {
861
- Object.keys(source).forEach(function (key) {
862
- _newArrowCheck(this, _this13);
380
+ Object.keys(source).forEach((key) => {
863
381
  const value = source[key];
864
382
  if (isObject(value)) {
865
- target[key] || (target[key] = {});
383
+ !target[key] && (target[key] = {});
866
384
  target[key] = mergeObj(target[key], value);
867
385
  } else {
868
386
  target[key] = isArray(value) ? value.concat() : value;
869
387
  }
870
- }.bind(this));
388
+ });
871
389
  }
872
- return mergeObj.apply(void 0, [target].concat(objectN));
390
+ return mergeObj(target, ...objectN);
873
391
  }
874
-
875
- /**
876
- * Sort value
877
- * @param {Array} data value to be sorted
878
- * @param {boolean} isAsc true: asc, false: desc
879
- * @returns {number|string|Date} sorted date
880
- * @private
881
- */
882
- function sortValue(data, isAsc) {
883
- var _this14 = this;
884
- if (isAsc === void 0) {
885
- isAsc = !0;
886
- }
392
+ function sortValue(data, isAsc = true) {
887
393
  let fn;
888
394
  if (data[0] instanceof Date) {
889
- fn = isAsc ? function (a, b) {
890
- _newArrowCheck(this, _this14);
891
- return a - b;
892
- }.bind(this) : function (a, b) {
893
- _newArrowCheck(this, _this14);
894
- return b - a;
895
- }.bind(this);
395
+ fn = isAsc ? (a, b) => a - b : (a, b) => b - a;
896
396
  } else {
897
397
  if (isAsc && !data.every(isNaN)) {
898
- fn = function (a, b) {
899
- _newArrowCheck(this, _this14);
900
- return a - b;
901
- }.bind(this);
398
+ fn = (a, b) => a - b;
902
399
  } else if (!isAsc) {
903
- fn = function (a, b) {
904
- _newArrowCheck(this, _this14);
905
- return a > b && -1 || a < b && 1 || a === b && 0;
906
- }.bind(this);
400
+ fn = (a, b) => a > b && -1 || a < b && 1 || a === b && 0;
907
401
  }
908
402
  }
909
403
  return data.concat().sort(fn);
910
404
  }
911
-
912
- /**
913
- * Get min/max value
914
- * @param {string} type 'min' or 'max'
915
- * @param {Array} data Array data value
916
- * @returns {number|Date|undefined}
917
- * @private
918
- */
919
405
  function getMinMax(type, data) {
920
- var _this15 = this;
921
- let res = data.filter(function (v) {
922
- _newArrowCheck(this, _this15);
923
- return notEmpty(v);
924
- }.bind(this));
406
+ let res = data.filter((v) => notEmpty(v));
925
407
  if (res.length) {
926
408
  if (isNumber(res[0])) {
927
- res = Math[type].apply(Math, res);
409
+ res = Math[type](...res);
928
410
  } else if (res[0] instanceof Date) {
929
411
  res = sortValue(res, type === "min")[0];
930
412
  }
931
413
  } else {
932
- res = undefined;
414
+ res = void 0;
933
415
  }
934
416
  return res;
935
417
  }
936
-
937
- /**
938
- * Get range
939
- * @param {number} start Start number
940
- * @param {number} end End number
941
- * @param {number} step Step number
942
- * @returns {Array}
943
- * @private
944
- */
945
- const getRange = function (start, end, step) {
946
- if (step === void 0) {
947
- step = 1;
948
- }
949
- _newArrowCheck(this, _this);
950
- const res = [],
951
- n = Math.max(0, Math.ceil((end - start) / step)) | 0;
952
- for (let i = start; i < n; i++) {
953
- res.push(start + i * step);
954
- }
955
- return res;
956
- }.bind(undefined),
957
- emulateEvent = {
958
- mouse: function () {
959
- var _this16 = this;
960
- _newArrowCheck(this, _this);
961
- const getParams = function () {
962
- _newArrowCheck(this, _this16);
963
- return {
964
- bubbles: !1,
965
- cancelable: !1,
966
- screenX: 0,
967
- screenY: 0,
968
- clientX: 0,
969
- clientY: 0
970
- };
971
- }.bind(this);
972
- try {
973
- // eslint-disable-next-line no-new
974
- new MouseEvent("t");
975
- return function (el, eventType, params) {
976
- if (params === void 0) {
977
- params = getParams();
978
- }
979
- _newArrowCheck(this, _this16);
980
- el.dispatchEvent(new MouseEvent(eventType, params));
981
- }.bind(this);
982
- } catch (e) {
983
- // Polyfills DOM4 MouseEvent
984
- return function (el, eventType, params) {
985
- if (params === void 0) {
986
- params = getParams();
987
- }
988
- _newArrowCheck(this, _this16);
989
- const mouseEvent = doc.createEvent("MouseEvent");
990
-
991
- // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
992
- mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0,
418
+ const getRange = (start, end, step = 1) => {
419
+ const res = [];
420
+ const n = Math.max(0, Math.ceil((end - start) / step)) | 0;
421
+ for (let i = start; i < n; i++) {
422
+ res.push(start + i * step);
423
+ }
424
+ return res;
425
+ };
426
+ const emulateEvent = {
427
+ mouse: (() => {
428
+ const getParams = () => ({
429
+ bubbles: false,
430
+ cancelable: false,
431
+ screenX: 0,
432
+ screenY: 0,
433
+ clientX: 0,
434
+ clientY: 0
435
+ });
436
+ try {
437
+ new MouseEvent("t");
438
+ return (el, eventType, params = getParams()) => {
439
+ el.dispatchEvent(new MouseEvent(eventType, params));
440
+ };
441
+ } catch (e) {
442
+ return (el, eventType, params = getParams()) => {
443
+ const mouseEvent = doc.createEvent("MouseEvent");
444
+ mouseEvent.initMouseEvent(
445
+ eventType,
446
+ params.bubbles,
447
+ params.cancelable,
448
+ win,
449
+ 0,
993
450
  // the event's mouse click count
994
- params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null);
995
- el.dispatchEvent(mouseEvent);
996
- }.bind(this);
997
- }
998
- }.bind(undefined)(),
999
- touch: function touch(el, eventType, params) {
1000
- _newArrowCheck(this, _this);
1001
- const touchObj = new Touch(mergeObj({
1002
- identifier: Date.now(),
1003
- target: el,
1004
- radiusX: 2.5,
1005
- radiusY: 2.5,
1006
- rotationAngle: 10,
1007
- force: .5
1008
- }, params));
1009
- el.dispatchEvent(new TouchEvent(eventType, {
1010
- cancelable: !0,
1011
- bubbles: !0,
1012
- shiftKey: !0,
1013
- touches: [touchObj],
1014
- targetTouches: [],
1015
- changedTouches: [touchObj]
1016
- }));
1017
- }.bind(undefined)
1018
- }; // emulate event
1019
- /**
1020
- * Process the template & return bound string
1021
- * @param {string} tpl Template string
1022
- * @param {object} data Data value to be replaced
1023
- * @returns {string}
1024
- * @private
1025
- */
451
+ params.screenX,
452
+ params.screenY,
453
+ params.clientX,
454
+ params.clientY,
455
+ false,
456
+ false,
457
+ false,
458
+ false,
459
+ 0,
460
+ null
461
+ );
462
+ el.dispatchEvent(mouseEvent);
463
+ };
464
+ }
465
+ })(),
466
+ touch: (el, eventType, params) => {
467
+ const touchObj = new Touch(mergeObj({
468
+ identifier: Date.now(),
469
+ target: el,
470
+ radiusX: 2.5,
471
+ radiusY: 2.5,
472
+ rotationAngle: 10,
473
+ force: 0.5
474
+ }, params));
475
+ el.dispatchEvent(new TouchEvent(eventType, {
476
+ cancelable: true,
477
+ bubbles: true,
478
+ shiftKey: true,
479
+ touches: [touchObj],
480
+ targetTouches: [],
481
+ changedTouches: [touchObj]
482
+ }));
483
+ }
484
+ };
1026
485
  function tplProcess(tpl, data) {
1027
486
  let res = tpl;
1028
487
  for (const x in data) {
1029
- res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
488
+ res = res.replace(new RegExp(`{=${x}}`, "g"), data[x]);
1030
489
  }
1031
490
  return res;
1032
491
  }
1033
-
1034
- /**
1035
- * Get parsed date value
1036
- * (It must be called in 'ChartInternal' context)
1037
- * @param {Date|string|number} date Value of date to be parsed
1038
- * @returns {Date}
1039
- * @private
1040
- */
1041
492
  function parseDate(date) {
493
+ var _a;
1042
494
  let parsedDate;
1043
495
  if (date instanceof Date) {
1044
496
  parsedDate = date;
1045
497
  } else if (isString(date)) {
1046
- var _format$dataTime;
1047
- const config = this.config,
1048
- format = this.format;
1049
-
1050
- // if fails to parse, try by new Date()
1051
- // https://github.com/naver/billboard.js/issues/1714
1052
- parsedDate = (_format$dataTime = format.dataTime(config.data_xFormat)(date)) != null ? _format$dataTime : new Date(date);
498
+ const { config, format } = this;
499
+ parsedDate = (_a = format.dataTime(config.data_xFormat)(date)) != null ? _a : new Date(date);
1053
500
  } else if (isNumber(date) && !isNaN(date)) {
1054
- parsedDate = new Date(+date);
501
+ parsedDate = /* @__PURE__ */ new Date(+date);
1055
502
  }
1056
503
  if (!parsedDate || isNaN(+parsedDate)) {
1057
- console && console.error && console.error("Failed to parse x '" + date + "' to Date object");
504
+ console && console.error && console.error(`Failed to parse x '${date}' to Date object`);
1058
505
  }
1059
506
  return parsedDate;
1060
507
  }
1061
-
1062
- /**
1063
- * Return if the current doc is visible or not
1064
- * @returns {boolean}
1065
- * @private
1066
- */
1067
508
  function isTabVisible() {
1068
- return (doc == null ? void 0 : doc.hidden) === !1 || (doc == null ? void 0 : doc.visibilityState) === "visible";
509
+ var _a, _b;
510
+ return ((_a = doc) == null ? void 0 : _a.hidden) === false || ((_b = doc) == null ? void 0 : _b.visibilityState) === "visible";
1069
511
  }
1070
-
1071
- /**
1072
- * Get the current input type
1073
- * @param {boolean} mouse Config value: interaction.inputType.mouse
1074
- * @param {boolean} touch Config value: interaction.inputType.touch
1075
- * @returns {string} "mouse" | "touch" | null
1076
- * @private
1077
- */
1078
512
  function convertInputType(mouse, touch) {
1079
- var _this17 = this;
1080
- const DocumentTouch = win.DocumentTouch,
1081
- matchMedia = win.matchMedia,
1082
- navigator = win.navigator;
1083
- let hasTouch = !1;
513
+ const { DocumentTouch, matchMedia, navigator } = win;
514
+ let hasTouch = false;
1084
515
  if (touch) {
1085
- // Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
1086
516
  if (navigator && "maxTouchPoints" in navigator) {
1087
517
  hasTouch = navigator.maxTouchPoints > 0;
1088
-
1089
- // Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
1090
- // On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
1091
518
  } else if ("ontouchmove" in win || DocumentTouch && doc instanceof DocumentTouch) {
1092
- hasTouch = !0;
519
+ hasTouch = true;
1093
520
  } else {
1094
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#avoiding_user_agent_detection
1095
- if (matchMedia != null && matchMedia("(pointer:coarse)").matches) {
1096
- hasTouch = !0;
521
+ if (matchMedia == null ? void 0 : matchMedia("(pointer:coarse)").matches) {
522
+ hasTouch = true;
1097
523
  } else {
1098
- // Only as a last resort, fall back to user agent sniffing
1099
524
  const UA = navigator.userAgent;
1100
525
  hasTouch = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
1101
526
  }
1102
527
  }
1103
528
  }
1104
-
1105
- // Check if agent has mouse using any-hover, touch devices (e.g iPad) with external mouse will return true as long as mouse is connected
1106
- // https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-testing-the-capabilities-of-all-inputs
1107
- // Demo: https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/
1108
- const hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some(function (v) {
1109
- _newArrowCheck(this, _this17);
1110
- return matchMedia == null ? void 0 : matchMedia("(" + v + ")").matches;
1111
- }.bind(this));
1112
-
1113
- // fallback to 'mouse' if no input type is detected.
529
+ const hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some((v) => matchMedia == null ? void 0 : matchMedia(`(${v})`).matches);
1114
530
  return hasMouse && "mouse" || hasTouch && "touch" || "mouse";
1115
531
  }
1116
-
1117
- /**
1118
- * Run function until given condition function return true
1119
- * @param {Function} fn Function to be executed when condition is true
1120
- * @param {Function} conditionFn Condition function to check if condition is true
1121
- * @private
1122
- */
1123
532
  function runUntil(fn, conditionFn) {
1124
- var _this18 = this;
1125
- if (conditionFn() === !1) {
1126
- requestAnimationFrame(function () {
1127
- _newArrowCheck(this, _this18);
1128
- return runUntil(fn, conditionFn);
1129
- }.bind(this));
533
+ if (conditionFn() === false) {
534
+ requestAnimationFrame(() => runUntil(fn, conditionFn));
1130
535
  } else {
1131
536
  fn();
1132
537
  }
1133
538
  }
1134
- ;// CONCATENATED MODULE: ./src/config/config.ts
1135
539
 
1136
- /**
1137
- * Copyright (c) 2017 ~ present NAVER Corp.
1138
- * billboard.js project is licensed under the MIT license
1139
- */
540
+ ;// CONCATENATED MODULE: ./src/config/config.ts
1140
541
 
1141
- /**
1142
- * Load configuration option
1143
- * @param {object} config User's generation config value
1144
- * @private
1145
- */
1146
542
  function loadConfig(config) {
1147
- var _this = this;
1148
543
  const thisConfig = this.config;
1149
- let target, keys, read;
1150
- const _find = function find() {
1151
- _newArrowCheck(this, _this);
544
+ let target;
545
+ let keys;
546
+ let read;
547
+ const find = () => {
1152
548
  const key = keys.shift();
1153
549
  if (key && target && isObjectType(target) && key in target) {
1154
550
  target = target[key];
1155
- return _find();
551
+ return find();
1156
552
  } else if (!key) {
1157
553
  return target;
1158
554
  }
1159
- return undefined;
1160
- }.bind(this);
1161
- Object.keys(thisConfig).forEach(function (key) {
1162
- _newArrowCheck(this, _this);
555
+ return void 0;
556
+ };
557
+ Object.keys(thisConfig).forEach((key) => {
1163
558
  target = config;
1164
559
  keys = key.split("_");
1165
- read = _find();
560
+ read = find();
1166
561
  if (isDefined(read)) {
1167
562
  thisConfig[key] = read;
1168
563
  }
1169
- }.bind(this));
1170
-
1171
- // only should run in the ChartInternal context
564
+ });
1172
565
  if (this.api) {
1173
566
  this.state.orgConfig = config;
1174
567
  }
1175
568
  }
1176
- ;// CONCATENATED MODULE: ./src/Plugin/Plugin.ts
1177
569
 
1178
- /**
1179
- * Copyright (c) 2017 ~ present NAVER Corp.
1180
- * billboard.js project is licensed under the MIT license
1181
- */
1182
- /**
1183
- * Base class to generate billboard.js plugin
1184
- * @class Plugin
1185
- */
1186
- /**
1187
- * Version info string for plugin
1188
- * @name version
1189
- * @static
1190
- * @memberof Plugin
1191
- * @type {string}
1192
- * @example
1193
- * bb.plugin.stanford.version; // ex) 1.9.0
1194
- */
1195
- let Plugin = /*#__PURE__*/function () {
570
+ ;// CONCATENATED MODULE: ./src/Plugin/Plugin.ts
571
+ var Plugin_defProp = Object.defineProperty;
572
+ var Plugin_defNormalProp = (obj, key, value) => key in obj ? Plugin_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
573
+ var __publicField = (obj, key, value) => {
574
+ Plugin_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
575
+ return value;
576
+ };
577
+ class Plugin {
1196
578
  /**
1197
579
  * Constructor
1198
580
  * @param {Any} options config option object
1199
581
  * @private
1200
582
  */
1201
- function Plugin(options) {
1202
- if (options === void 0) {
1203
- options = {};
1204
- }
1205
- this.$$ = void 0;
1206
- this.options = void 0;
583
+ constructor(options = {}) {
584
+ __publicField(this, "$$");
585
+ __publicField(this, "options");
1207
586
  this.options = options;
1208
587
  }
1209
-
1210
588
  /**
1211
589
  * Lifecycle hook for 'beforeInit' phase.
1212
590
  * @private
1213
591
  */
1214
- var _proto = Plugin.prototype;
1215
- _proto.$beforeInit = function $beforeInit() {}
1216
-
592
+ $beforeInit() {
593
+ }
1217
594
  /**
1218
595
  * Lifecycle hook for 'init' phase.
1219
596
  * @private
1220
- */;
1221
- _proto.$init = function $init() {}
1222
-
597
+ */
598
+ $init() {
599
+ }
1223
600
  /**
1224
601
  * Lifecycle hook for 'afterInit' phase.
1225
602
  * @private
1226
- */;
1227
- _proto.$afterInit = function $afterInit() {}
1228
-
603
+ */
604
+ $afterInit() {
605
+ }
1229
606
  /**
1230
607
  * Lifecycle hook for 'redraw' phase.
1231
608
  * @private
1232
- */;
1233
- _proto.$redraw = function $redraw() {}
1234
-
609
+ */
610
+ $redraw() {
611
+ }
1235
612
  /**
1236
613
  * Lifecycle hook for 'willDestroy' phase.
1237
614
  * @private
1238
- */;
1239
- _proto.$willDestroy = function $willDestroy() {
1240
- var _this = this;
1241
- Object.keys(this).forEach(function (key) {
1242
- _newArrowCheck(this, _this);
615
+ */
616
+ $willDestroy() {
617
+ Object.keys(this).forEach((key) => {
1243
618
  this[key] = null;
1244
619
  delete this[key];
1245
- }.bind(this));
1246
- };
1247
- return Plugin;
1248
- }();
1249
- Plugin.version = "3.11.3";
620
+ });
621
+ }
622
+ }
623
+ __publicField(Plugin, "version", "3.12.0-next.2");
1250
624
 
1251
625
  ;// CONCATENATED MODULE: ./src/Plugin/textoverlap/Options.ts
1252
- /**
1253
- * Copyright (c) 2017 ~ present NAVER Corp.
1254
- * billboard.js project is licensed under the MIT license
1255
- */
1256
- /**
1257
- * TextOverlap plugin option class
1258
- * @class TextOverlapOptions
1259
- * @param {Options} options TextOverlap plugin options
1260
- * @augments Plugin
1261
- * @returns {TextOverlapOptions}
1262
- * @private
1263
- */
1264
- let Options = function () {
1265
- return {
1266
- /**
1267
- * Selector string for target text nodes within chart element.
1268
- * - **NOTE:** If no value is given, defaults to data label text elements.
1269
- * @name selector
1270
- * @memberof plugin-textoverlap
1271
- * @type {string}
1272
- * @default undefined
1273
- * @example
1274
- * // selector for data label text nodes
1275
- * selector: ".bb-texts text"
1276
- */
1277
- selector: undefined,
1278
- /**
1279
- * Extent of label overlap prevention.
1280
- * @name extent
1281
- * @memberof plugin-textoverlap
1282
- * @type {number}
1283
- * @default 1
1284
- * @example
1285
- * extent: 1
1286
- */
1287
- extent: 1,
1288
- /**
1289
- * Minimum area needed to show a data label.
1290
- * @name area
1291
- * @memberof plugin-textoverlap
1292
- * @type {number}
1293
- * @default 0
1294
- * @example
1295
- * area: 0
1296
- */
1297
- area: 0
1298
- };
1299
- };
626
+ class Options {
627
+ constructor() {
628
+ return {
629
+ /**
630
+ * Selector string for target text nodes within chart element.
631
+ * - **NOTE:** If no value is given, defaults to data label text elements.
632
+ * @name selector
633
+ * @memberof plugin-textoverlap
634
+ * @type {string}
635
+ * @default undefined
636
+ * @example
637
+ * // selector for data label text nodes
638
+ * selector: ".bb-texts text"
639
+ */
640
+ selector: void 0,
641
+ /**
642
+ * Extent of label overlap prevention.
643
+ * @name extent
644
+ * @memberof plugin-textoverlap
645
+ * @type {number}
646
+ * @default 1
647
+ * @example
648
+ * extent: 1
649
+ */
650
+ extent: 1,
651
+ /**
652
+ * Minimum area needed to show a data label.
653
+ * @name area
654
+ * @memberof plugin-textoverlap
655
+ * @type {number}
656
+ * @default 0
657
+ * @example
658
+ * area: 0
659
+ */
660
+ area: 0
661
+ };
662
+ }
663
+ }
1300
664
 
1301
665
  ;// CONCATENATED MODULE: ./src/Plugin/textoverlap/index.ts
1302
-
1303
-
1304
-
1305
- /**
1306
- * Copyright (c) 2017 ~ present NAVER Corp.
1307
- * billboard.js project is licensed under the MIT license
1308
- */
1309
-
1310
-
666
+ var textoverlap_defProp = Object.defineProperty;
667
+ var textoverlap_defNormalProp = (obj, key, value) => key in obj ? textoverlap_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
668
+ var textoverlap_publicField = (obj, key, value) => {
669
+ textoverlap_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
670
+ return value;
671
+ };
1311
672
 
1312
673
 
1313
674
 
1314
675
 
1315
676
 
1316
- /**
1317
- * TextOverlap plugin<br>
1318
- * Prevents label overlap using [Voronoi layout](https://en.wikipedia.org/wiki/Voronoi_diagram).
1319
- * - **NOTE:**
1320
- * - Plugins aren't built-in. Need to be loaded or imported to be used.
1321
- * - Non required modules from billboard.js core, need to be installed separately.
1322
- * - Appropriate and works for axis based chart.
1323
- * - **Required modules:**
1324
- * - [d3-polygon](https://github.com/d3/d3-polygon)
1325
- * - [d3-delaunay](https://github.com/d3/d3-delaunay)
1326
- * @class plugin-textoverlap
1327
- * @requires d3-polygon
1328
- * @requires d3-delaunay
1329
- * @param {object} options TextOverlap plugin options
1330
- * @augments Plugin
1331
- * @returns {TextOverlap}
1332
- * @example
1333
- * // Plugin must be loaded before the use.
1334
- * <script src="$YOUR_PATH/plugin/billboardjs-plugin-textoverlap.js"></script>
1335
- *
1336
- * var chart = bb.generate({
1337
- * data: {
1338
- * columns: [ ... ]
1339
- * },
1340
- * ...
1341
- * plugins: [
1342
- * new bb.plugin.textoverlap({
1343
- * selector: ".bb-texts text",
1344
- * extent: 8,
1345
- * area: 3
1346
- * })
1347
- * ]
1348
- * });
1349
- * @example
1350
- * import {bb} from "billboard.js";
1351
- * import TextOverlap from "billboard.js/dist/billboardjs-plugin-textoverlap";
1352
- *
1353
- * bb.generate({
1354
- * plugins: [
1355
- * new TextOverlap({ ... })
1356
- * ]
1357
- * })
1358
- */
1359
- let TextOverlap = /*#__PURE__*/function (_Plugin) {
1360
- _inheritsLoose(TextOverlap, _Plugin);
1361
- function TextOverlap(options) {
1362
- var _this = _Plugin.call(this, options) || this;
1363
- _this.config = void 0;
1364
- _this.config = new Options();
1365
- return _assertThisInitialized(_this) || _assertThisInitialized(_this);
677
+ class TextOverlap extends Plugin {
678
+ constructor(options) {
679
+ super(options);
680
+ textoverlap_publicField(this, "config");
681
+ this.config = new Options();
682
+ return this;
1366
683
  }
1367
- var _proto = TextOverlap.prototype;
1368
- _proto.$init = function $init() {
684
+ $init() {
1369
685
  loadConfig.call(this, this.options);
1370
- };
1371
- _proto.$redraw = function $redraw() {
1372
- const $el = this.$$.$el,
1373
- selector = this.config.selector,
1374
- text = selector ? $el.main.selectAll(selector) : $el.text;
1375
- text.empty() || this.preventLabelOverlap(text);
1376
686
  }
1377
-
687
+ $redraw() {
688
+ const { $$: { $el }, config: { selector } } = this;
689
+ const text = selector ? $el.main.selectAll(selector) : $el.text;
690
+ !text.empty() && this.preventLabelOverlap(text);
691
+ }
1378
692
  /**
1379
693
  * Generates the voronoi layout for data labels
1380
694
  * @param {Array} points Indices values
1381
695
  * @returns {object} Voronoi layout points and corresponding Data points
1382
696
  * @private
1383
- */;
1384
- _proto.generateVoronoi = function generateVoronoi(points) {
1385
- var _this2 = this;
1386
- const $$ = this.$$,
1387
- scale = $$.scale,
1388
- _map = ["x", "y"].map(function (v) {
1389
- _newArrowCheck(this, _this2);
1390
- return scale[v].domain();
1391
- }.bind(this)),
1392
- min = _map[0],
1393
- max = _map[1];
1394
- var _ref = [max[0], min[1]];
1395
- min[1] = _ref[0];
1396
- max[0] = _ref[1];
1397
- return external_commonjs_d3_delaunay_commonjs2_d3_delaunay_amd_d3_delaunay_root_d3_.Delaunay.from(points).voronoi([].concat(min, max)); // bounds = [xmin, ymin, xmax, ymax], default value: [0, 0, 960, 500]
697
+ */
698
+ generateVoronoi(points) {
699
+ const { $$ } = this;
700
+ const { scale } = $$;
701
+ const [min, max] = ["x", "y"].map((v) => scale[v].domain());
702
+ [min[1], max[0]] = [max[0], min[1]];
703
+ return external_commonjs_d3_delaunay_commonjs2_d3_delaunay_amd_d3_delaunay_root_d3_.Delaunay.from(points).voronoi([
704
+ ...min,
705
+ ...max
706
+ ]);
1398
707
  }
1399
-
1400
708
  /**
1401
709
  * Set text label's position to preventg overlap.
1402
710
  * @param {d3Selection} text target text selection
1403
711
  * @private
1404
- */;
1405
- _proto.preventLabelOverlap = function preventLabelOverlap(text) {
1406
- var _this3 = this;
1407
- const _this$config = this.config,
1408
- extent = _this$config.extent,
1409
- area = _this$config.area,
1410
- points = text.data().map(function (v) {
1411
- _newArrowCheck(this, _this3);
1412
- return [v.index, v.value];
1413
- }.bind(this)),
1414
- voronoi = this.generateVoronoi(points);
712
+ */
713
+ preventLabelOverlap(text) {
714
+ const { extent, area } = this.config;
715
+ const points = text.data().map((v) => [v.index, v.value]);
716
+ const voronoi = this.generateVoronoi(points);
1415
717
  let i = 0;
1416
- text.each(function () {
718
+ text.each(function() {
1417
719
  const cell = voronoi.cellPolygon(i);
1418
720
  if (cell && this) {
1419
- const _points$i = points[i],
1420
- x = _points$i[0],
1421
- y = _points$i[1],
1422
- _d3PolygonCentroid = (0,external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_.polygonCentroid)(cell),
1423
- cx = _d3PolygonCentroid[0],
1424
- cy = _d3PolygonCentroid[1],
1425
- polygonArea = Math.abs((0,external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_.polygonArea)(cell)),
1426
- angle = Math.round(Math.atan2(cy - y, cx - x) / Math.PI * 2),
1427
- xTranslate = extent * (angle === 0 ? 1 : -1),
1428
- yTranslate = angle === -1 ? -extent : extent + 5,
1429
- txtAnchor = Math.abs(angle) === 1 ? "middle" : angle === 0 ? "start" : "end"; // @ts-ignore wrong type definiton for d3PolygonCentroid
1430
- // @ts-ignore wrong type definiton for d3PolygonArea
721
+ const [x, y] = points[i];
722
+ const [cx, cy] = (0,external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_.polygonCentroid)(cell);
723
+ const polygonArea = Math.abs((0,external_commonjs_d3_polygon_commonjs2_d3_polygon_amd_d3_polygon_root_d3_.polygonArea)(cell));
724
+ const angle = Math.round(Math.atan2(cy - y, cx - x) / Math.PI * 2);
725
+ const xTranslate = extent * (angle === 0 ? 1 : -1);
726
+ const yTranslate = angle === -1 ? -extent : extent + 5;
727
+ const txtAnchor = Math.abs(angle) === 1 ? "middle" : angle === 0 ? "start" : "end";
1431
728
  this.style.display = polygonArea < area ? "none" : "";
1432
729
  this.setAttribute("text-anchor", txtAnchor);
1433
- this.setAttribute("dy", "0." + (angle === 1 ? 71 : 35) + "em");
1434
- this.setAttribute("transform", "translate(" + xTranslate + ", " + yTranslate + ")");
730
+ this.setAttribute("dy", `0.${angle === 1 ? 71 : 35}em`);
731
+ this.setAttribute("transform", `translate(${xTranslate}, ${yTranslate})`);
1435
732
  }
1436
733
  i++;
1437
734
  });
1438
- };
1439
- return TextOverlap;
1440
- }(Plugin);
735
+ }
736
+ }
1441
737
 
1442
738
  }();
1443
739
  __webpack_exports__ = __webpack_exports__["default"];