UNPKG

801 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.6.3
9 */
10(function webpackUniversalModuleDefinition(root, factory) {
11 if(typeof exports === 'object' && typeof module === 'object')
12 module.exports = factory(require("d3-axis"), require("d3-brush"), require("d3-drag"), require("d3-dsv"), require("d3-ease"), require("d3-interpolate"), require("d3-scale"), require("d3-selection"), require("d3-shape"), require("d3-time-format"), require("d3-transition"), require("d3-zoom"));
13 else if(typeof define === 'function' && define.amd)
14 define(["d3-axis", "d3-brush", "d3-drag", "d3-dsv", "d3-ease", "d3-interpolate", "d3-scale", "d3-selection", "d3-shape", "d3-time-format", "d3-transition", "d3-zoom"], factory);
15 else {
16 var a = typeof exports === 'object' ? factory(require("d3-axis"), require("d3-brush"), require("d3-drag"), require("d3-dsv"), require("d3-ease"), require("d3-interpolate"), require("d3-scale"), require("d3-selection"), require("d3-shape"), require("d3-time-format"), require("d3-transition"), require("d3-zoom")) : factory(root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"]);
17 for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
18 }
19})(this, function(__WEBPACK_EXTERNAL_MODULE__10__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__5__, __WEBPACK_EXTERNAL_MODULE__11__, __WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__2__, __WEBPACK_EXTERNAL_MODULE__9__, __WEBPACK_EXTERNAL_MODULE__4__, __WEBPACK_EXTERNAL_MODULE__8__, __WEBPACK_EXTERNAL_MODULE__13__) {
20return /******/ (function() { // webpackBootstrap
21/******/ "use strict";
22/******/ var __webpack_modules__ = ([
23/* 0 */,
24/* 1 */,
25/* 2 */
26/***/ (function(module) {
27
28module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
29
30/***/ }),
31/* 3 */
32/***/ (function(module) {
33
34module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
35
36/***/ }),
37/* 4 */
38/***/ (function(module) {
39
40module.exports = __WEBPACK_EXTERNAL_MODULE__4__;
41
42/***/ }),
43/* 5 */
44/***/ (function(module) {
45
46module.exports = __WEBPACK_EXTERNAL_MODULE__5__;
47
48/***/ }),
49/* 6 */
50/***/ (function(module) {
51
52module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
53
54/***/ }),
55/* 7 */
56/***/ (function(module) {
57
58module.exports = __WEBPACK_EXTERNAL_MODULE__7__;
59
60/***/ }),
61/* 8 */
62/***/ (function(module) {
63
64module.exports = __WEBPACK_EXTERNAL_MODULE__8__;
65
66/***/ }),
67/* 9 */
68/***/ (function(module) {
69
70module.exports = __WEBPACK_EXTERNAL_MODULE__9__;
71
72/***/ }),
73/* 10 */
74/***/ (function(module) {
75
76module.exports = __WEBPACK_EXTERNAL_MODULE__10__;
77
78/***/ }),
79/* 11 */
80/***/ (function(module) {
81
82module.exports = __WEBPACK_EXTERNAL_MODULE__11__;
83
84/***/ }),
85/* 12 */
86/***/ (function(module) {
87
88module.exports = __WEBPACK_EXTERNAL_MODULE__12__;
89
90/***/ }),
91/* 13 */
92/***/ (function(module) {
93
94module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
95
96/***/ })
97/******/ ]);
98/************************************************************************/
99/******/ // The module cache
100/******/ var __webpack_module_cache__ = {};
101/******/
102/******/ // The require function
103/******/ function __webpack_require__(moduleId) {
104/******/ // Check if module is in cache
105/******/ var cachedModule = __webpack_module_cache__[moduleId];
106/******/ if (cachedModule !== undefined) {
107/******/ return cachedModule.exports;
108/******/ }
109/******/ // Create a new module (and put it into the cache)
110/******/ var module = __webpack_module_cache__[moduleId] = {
111/******/ // no module.id needed
112/******/ // no module.loaded needed
113/******/ exports: {}
114/******/ };
115/******/
116/******/ // Execute the module function
117/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
118/******/
119/******/ // Return the exports of the module
120/******/ return module.exports;
121/******/ }
122/******/
123/************************************************************************/
124/******/ /* webpack/runtime/define property getters */
125/******/ !function() {
126/******/ // define getter functions for harmony exports
127/******/ __webpack_require__.d = function(exports, definition) {
128/******/ for(var key in definition) {
129/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
130/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
131/******/ }
132/******/ }
133/******/ };
134/******/ }();
135/******/
136/******/ /* webpack/runtime/hasOwnProperty shorthand */
137/******/ !function() {
138/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
139/******/ }();
140/******/
141/******/ /* webpack/runtime/make namespace object */
142/******/ !function() {
143/******/ // define __esModule on exports
144/******/ __webpack_require__.r = function(exports) {
145/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
146/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
147/******/ }
148/******/ Object.defineProperty(exports, '__esModule', { value: true });
149/******/ };
150/******/ }();
151/******/
152/************************************************************************/
153var __webpack_exports__ = {};
154// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
155!function() {
156// extracted by mini-css-extract-plugin
157
158}();
159// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
160!function() {
161// ESM COMPAT FLAG
162__webpack_require__.r(__webpack_exports__);
163
164// EXPORTS
165__webpack_require__.d(__webpack_exports__, {
166 "bb": function() { return /* reexport */ bb; },
167 "default": function() { return /* reexport */ bb; }
168});
169
170// NAMESPACE OBJECT: ./src/config/resolver/shape.ts
171var resolver_shape_namespaceObject = {};
172__webpack_require__.r(resolver_shape_namespaceObject);
173__webpack_require__.d(resolver_shape_namespaceObject, {
174 "area": function() { return _area; },
175 "areaLineRange": function() { return areaLineRange; },
176 "areaSpline": function() { return areaSpline; },
177 "areaSplineRange": function() { return areaSplineRange; },
178 "areaStep": function() { return areaStep; },
179 "bar": function() { return resolver_shape_bar; },
180 "bubble": function() { return resolver_shape_bubble; },
181 "candlestick": function() { return resolver_shape_candlestick; },
182 "donut": function() { return shape_donut; },
183 "gauge": function() { return resolver_shape_gauge; },
184 "line": function() { return resolver_shape_line; },
185 "pie": function() { return shape_pie; },
186 "polar": function() { return resolver_shape_polar; },
187 "radar": function() { return resolver_shape_radar; },
188 "scatter": function() { return shape_scatter; },
189 "spline": function() { return shape_spline; },
190 "step": function() { return step; }
191});
192
193// NAMESPACE OBJECT: ./src/config/resolver/interaction.ts
194var resolver_interaction_namespaceObject = {};
195__webpack_require__.r(resolver_interaction_namespaceObject);
196__webpack_require__.d(resolver_interaction_namespaceObject, {
197 "selection": function() { return _selectionModule; },
198 "subchart": function() { return subchartModule; },
199 "zoom": function() { return zoomModule; }
200});
201
202;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/newArrowCheck.js
203function _newArrowCheck(innerThis, boundThis) {
204 if (innerThis !== boundThis) {
205 throw new TypeError("Cannot instantiate an arrow function");
206 }
207}
208// EXTERNAL MODULE: external {"commonjs":"d3-time-format","commonjs2":"d3-time-format","amd":"d3-time-format","root":"d3"}
209var external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_ = __webpack_require__(4);
210// EXTERNAL MODULE: external {"commonjs":"d3-selection","commonjs2":"d3-selection","amd":"d3-selection","root":"d3"}
211var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(2);
212;// CONCATENATED MODULE: ./src/module/browser.ts
213
214var _this = undefined;
215/**
216 * Copyright (c) 2017 ~ present NAVER Corp.
217 * billboard.js project is licensed under the MIT license
218 */
219/**
220 * Window object
221 * @private
222 */
223/* eslint-disable no-new-func, no-undef */
224
225var win = function () {
226 _newArrowCheck(this, _this);
227 var root = 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;
228 return root || Function("return this")();
229}.bind(undefined)();
230/* eslint-enable no-new-func, no-undef */
231
232// fallback for non-supported environments
233win.requestIdleCallback = win.requestIdleCallback || function (cb) {
234 _newArrowCheck(this, _this);
235 return setTimeout(cb, 1);
236}.bind(undefined);
237// win.cancelIdleCallback = win.cancelIdleCallback || (id => clearTimeout(id));
238win.requestAnimationFrame = win.requestAnimationFrame || function (cb) {
239 _newArrowCheck(this, _this);
240 return setTimeout(cb, 1);
241}.bind(undefined);
242var browser_doc = win == null ? void 0 : win.document;
243;// CONCATENATED MODULE: ./src/config/const.ts
244/**
245 * Copyright (c) 2017 ~ present NAVER Corp.
246 * billboard.js project is licensed under the MIT license
247 */
248/**
249 * Chart type constant
250 * @private
251 */
252var TYPE = {
253 AREA: "area",
254 AREA_LINE_RANGE: "area-line-range",
255 AREA_SPLINE: "area-spline",
256 AREA_SPLINE_RANGE: "area-spline-range",
257 AREA_STEP: "area-step",
258 BAR: "bar",
259 BUBBLE: "bubble",
260 CANDLESTICK: "candlestick",
261 DONUT: "donut",
262 GAUGE: "gauge",
263 LINE: "line",
264 PIE: "pie",
265 POLAR: "polar",
266 RADAR: "radar",
267 SCATTER: "scatter",
268 SPLINE: "spline",
269 STEP: "step"
270};
271
272/**
273 * Chart type module and its method from ChartInternal class, needed to be initialized.
274 * @private
275 */
276var TYPE_METHOD_NEEDED = {
277 AREA: "initArea",
278 AREA_LINE_RANGE: "initArea",
279 AREA_SPLINE: "initArea",
280 AREA_SPLINE_RANGE: "initArea",
281 AREA_STEP: "initArea",
282 BAR: "initBar",
283 BUBBLE: "initCircle",
284 CANDLESTICK: "initCandlestick",
285 DONUT: "initArc",
286 GAUGE: "initArc",
287 LINE: "initLine",
288 PIE: "initArc",
289 POLAR: "initPolar",
290 RADAR: "initCircle",
291 SCATTER: "initCircle",
292 SPLINE: "initLine",
293 STEP: "initLine"
294};
295
296/**
297 * chart types by category
298 * @private
299 */
300var TYPE_BY_CATEGORY = {
301 Area: [TYPE.AREA, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE, TYPE.AREA_STEP],
302 AreaRange: [TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE],
303 Arc: [TYPE.PIE, TYPE.DONUT, TYPE.GAUGE, TYPE.POLAR, TYPE.RADAR],
304 Line: [TYPE.LINE, TYPE.SPLINE, TYPE.AREA, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE, TYPE.STEP, TYPE.AREA_STEP],
305 Step: [TYPE.STEP, TYPE.AREA_STEP],
306 Spline: [TYPE.SPLINE, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE]
307};
308;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
309function _defineProperty(obj, key, value) {
310 if (key in obj) {
311 Object.defineProperty(obj, key, {
312 value: value,
313 enumerable: true,
314 configurable: true,
315 writable: true
316 });
317 } else {
318 obj[key] = value;
319 }
320 return obj;
321}
322// EXTERNAL MODULE: external {"commonjs":"d3-brush","commonjs2":"d3-brush","amd":"d3-brush","root":"d3"}
323var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(3);
324;// CONCATENATED MODULE: ./src/module/util.ts
325
326
327var util_this = undefined;
328function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
329function _objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
330/**
331 * Copyright (c) 2017 ~ present NAVER Corp.
332 * billboard.js project is licensed under the MIT license
333 * @ignore
334 */
335
336
337
338
339var isValue = function (v) {
340 _newArrowCheck(this, util_this);
341 return v || v === 0;
342 }.bind(undefined),
343 isFunction = function (v) {
344 _newArrowCheck(this, util_this);
345 return typeof v === "function";
346 }.bind(undefined),
347 isString = function (v) {
348 _newArrowCheck(this, util_this);
349 return typeof v === "string";
350 }.bind(undefined),
351 isNumber = function (v) {
352 _newArrowCheck(this, util_this);
353 return typeof v === "number";
354 }.bind(undefined),
355 isUndefined = function (v) {
356 _newArrowCheck(this, util_this);
357 return typeof v === "undefined";
358 }.bind(undefined),
359 isDefined = function (v) {
360 _newArrowCheck(this, util_this);
361 return typeof v !== "undefined";
362 }.bind(undefined),
363 isboolean = function (v) {
364 _newArrowCheck(this, util_this);
365 return typeof v === "boolean";
366 }.bind(undefined),
367 ceil10 = function (v) {
368 _newArrowCheck(this, util_this);
369 return Math.ceil(v / 10) * 10;
370 }.bind(undefined),
371 asHalfPixel = function (n) {
372 _newArrowCheck(this, util_this);
373 return Math.ceil(n) + .5;
374 }.bind(undefined),
375 diffDomain = function (d) {
376 _newArrowCheck(this, util_this);
377 return d[1] - d[0];
378 }.bind(undefined),
379 isObjectType = function (v) {
380 _newArrowCheck(this, util_this);
381 return typeof v === "object";
382 }.bind(undefined),
383 isEmpty = function (o) {
384 _newArrowCheck(this, util_this);
385 return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
386 }.bind(undefined),
387 notEmpty = function (o) {
388 _newArrowCheck(this, util_this);
389 return !isEmpty(o);
390 }.bind(undefined),
391 isArray = function (arr) {
392 _newArrowCheck(this, util_this);
393 return Array.isArray(arr);
394 }.bind(undefined),
395 isObject = function (obj) {
396 _newArrowCheck(this, util_this);
397 return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
398 }.bind(undefined);
399/**
400 * Get specified key value from object
401 * If default value is given, will return if given key value not found
402 * @param {object} options Source object
403 * @param {string} key Key value
404 * @param {*} defaultValue Default value
405 * @returns {*}
406 * @private
407 */
408function getOption(options, key, defaultValue) {
409 return isDefined(options[key]) ? options[key] : defaultValue;
410}
411
412/**
413 * Check if value exist in the given object
414 * @param {object} dict Target object to be checked
415 * @param {*} value Value to be checked
416 * @returns {boolean}
417 * @private
418 */
419function hasValue(dict, value) {
420 var _this2 = this,
421 found = !1;
422 Object.keys(dict).forEach(function (key) {
423 _newArrowCheck(this, _this2);
424 return dict[key] === value && (found = !0);
425 }.bind(this));
426 return found;
427}
428
429/**
430 * Call function with arguments
431 * @param {Function} fn Function to be called
432 * @param {*} thisArg "this" value for fn
433 * @param {*} args Arguments for fn
434 * @returns {boolean} true: fn is function, false: fn is not function
435 * @private
436 */
437function callFn(fn, thisArg) {
438 for (var isFn = isFunction(fn), _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
439 args[_key - 2] = arguments[_key];
440 }
441 isFn && fn.call.apply(fn, [thisArg].concat(args));
442 return isFn;
443}
444
445/**
446 * Call function after all transitions ends
447 * @param {d3.transition} transition Transition
448 * @param {Fucntion} cb Callback function
449 * @private
450 */
451function endall(transition, cb) {
452 var _this3 = this,
453 n = 0,
454 end = function () {
455 for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
456 args[_key2] = arguments[_key2];
457 }
458 --n || cb.apply.apply(cb, [this].concat(args));
459 };
460 // if is transition selection
461 if ("duration" in transition) {
462 transition.each(function () {
463 _newArrowCheck(this, _this3);
464 return ++n;
465 }.bind(this)).on("end", end);
466 } else {
467 ++n;
468 transition.call(end);
469 }
470}
471
472/**
473 * Replace tag sign to html entity
474 * @param {string} str Target string value
475 * @returns {string}
476 * @private
477 */
478function sanitise(str) {
479 return isString(str) ? str.replace(/</g, "&lt;").replace(/>/g, "&gt;") : str;
480}
481
482/**
483 * Set text value. If there's multiline add nodes.
484 * @param {d3Selection} node Text node
485 * @param {string} text Text value string
486 * @param {Array} dy dy value for multilined text
487 * @param {boolean} toMiddle To be alingned vertically middle
488 * @private
489 */
490function setTextValue(node, text, dy, toMiddle) {
491 var _this4 = this;
492 if (dy === void 0) {
493 dy = [-1, 1];
494 }
495 if (toMiddle === void 0) {
496 toMiddle = !1;
497 }
498 if (!node || !isString(text)) {
499 return;
500 }
501 if (text.indexOf("\n") === -1) {
502 node.text(text);
503 } else {
504 var diff = [node.text(), text].map(function (v) {
505 _newArrowCheck(this, _this4);
506 return v.replace(/[\s\n]/g, "");
507 }.bind(this));
508 if (diff[0] !== diff[1]) {
509 var multiline = text.split("\n"),
510 len = toMiddle ? multiline.length - 1 : 1;
511 // reset possible text
512 node.html("");
513 multiline.forEach(function (v, i) {
514 _newArrowCheck(this, _this4);
515 node.append("tspan").attr("x", 0).attr("dy", (i === 0 ? dy[0] * len : dy[1]) + "em").text(v);
516 }.bind(this));
517 }
518 }
519}
520
521/**
522 * Substitution of SVGPathSeg API polyfill
523 * @param {SVGGraphicsElement} path Target svg element
524 * @returns {Array}
525 * @private
526 */
527function getRectSegList(path) {
528 /*
529 * seg1 ---------- seg2
530 * | |
531 * | |
532 * | |
533 * seg0 ---------- seg3
534 * */
535 var _path$getBBox = path.getBBox(),
536 x = _path$getBBox.x,
537 y = _path$getBBox.y,
538 width = _path$getBBox.width,
539 height = _path$getBBox.height;
540 return [{
541 x: x,
542 y: y + height
543 },
544 // seg0
545 {
546 x: x,
547 y: y
548 },
549 // seg1
550 {
551 x: x + width,
552 y: y
553 },
554 // seg2
555 {
556 x: x + width,
557 y: y + height
558 } // seg3
559 ];
560}
561
562/**
563 * Get svg bounding path box dimension
564 * @param {SVGGraphicsElement} path Target svg element
565 * @returns {object}
566 * @private
567 */
568function getPathBox(path) {
569 var _path$getBoundingClie = path.getBoundingClientRect(),
570 width = _path$getBoundingClie.width,
571 height = _path$getBoundingClie.height,
572 items = getRectSegList(path),
573 x = items[0].x,
574 y = Math.min(items[0].y, items[1].y);
575 return {
576 x: x,
577 y: y,
578 width: width,
579 height: height
580 };
581}
582
583/**
584 * Get event's current position coordinates
585 * @param {object} event Event object
586 * @param {SVGElement|HTMLElement} element Target element
587 * @returns {Array} [x, y] Coordinates x, y array
588 * @private
589 */
590function getPointer(event, element) {
591 var _ref,
592 touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]),
593 pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element),
594 _this5 = this;
595 return pointer.map(function (v) {
596 _newArrowCheck(this, _this5);
597 return isNaN(v) ? 0 : v;
598 }.bind(this));
599}
600
601/**
602 * Return brush selection array
603 * @param {object} ctx Current instance
604 * @returns {d3.brushSelection}
605 * @private
606 */
607function getBrushSelection(ctx) {
608 var event = ctx.event,
609 $el = ctx.$el,
610 main = $el.subchart.main || $el.main,
611 selection;
612 // check from event
613 if (event && event.type === "brush") {
614 selection = event.selection;
615 // check from brush area selection
616 } else if (main && (selection = main.select(".bb-brush").node())) {
617 selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection);
618 }
619 return selection;
620}
621
622/**
623 * Get boundingClientRect.
624 * Cache the evaluated value once it was called.
625 * @param {HTMLElement} node Target element
626 * @returns {object}
627 * @private
628 */
629function getBoundingRect(node) {
630 var needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
631 return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
632}
633
634/**
635 * Retrun random number
636 * @param {boolean} asStr Convert returned value as string
637 * @param {number} min Minimum value
638 * @param {number} max Maximum value
639 * @returns {number|string}
640 * @private
641 */
642function getRandom(asStr, min, max) {
643 if (asStr === void 0) {
644 asStr = !0;
645 }
646 if (min === void 0) {
647 min = 0;
648 }
649 if (max === void 0) {
650 max = 1e4;
651 }
652 var rand = Math.floor(Math.random() * (max - min) + min);
653 return asStr ? rand + "" : rand;
654}
655
656/**
657 * Find index based on binary search
658 * @param {Array} arr Data array
659 * @param {number} v Target number to find
660 * @param {number} start Start index of data array
661 * @param {number} end End index of data arr
662 * @param {boolean} isRotated Weather is roted axis
663 * @returns {number} Index number
664 * @private
665 */
666function findIndex(arr, v, start, end, isRotated) {
667 if (start > end) {
668 return -1;
669 }
670 var mid = Math.floor((start + end) / 2),
671 _arr$mid = arr[mid],
672 x = _arr$mid.x,
673 _arr$mid$w = _arr$mid.w,
674 w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
675 if (isRotated) {
676 x = arr[mid].y;
677 w = arr[mid].h;
678 }
679 if (v >= x && v <= x + w) {
680 return mid;
681 }
682 return v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
683}
684
685/**
686 * Check if brush is empty
687 * @param {object} ctx Bursh context
688 * @returns {boolean}
689 * @private
690 */
691function brushEmpty(ctx) {
692 var selection = getBrushSelection(ctx);
693 if (selection) {
694 // brush selected area
695 // two-dimensional: [[x0, y0], [x1, y1]]
696 // one-dimensional: [x0, x1] or [y0, y1]
697 return selection[0] === selection[1];
698 }
699 return !0;
700}
701
702/**
703 * Deep copy object
704 * @param {object} objectN Source object
705 * @returns {object} Cloned object
706 * @private
707 */
708function deepClone() {
709 for (var _this6 = this, clone = function (v) {
710 _newArrowCheck(this, _this6);
711 if (isObject(v) && v.constructor) {
712 var r = new v.constructor();
713 for (var k in v) {
714 r[k] = clone(v[k]);
715 }
716 return r;
717 }
718 return v;
719 }.bind(this), _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
720 objectN[_key3] = arguments[_key3];
721 }
722 return objectN.map(function (v) {
723 _newArrowCheck(this, _this6);
724 return clone(v);
725 }.bind(this)).reduce(function (a, c) {
726 _newArrowCheck(this, _this6);
727 return _objectSpread(_objectSpread({}, a), c);
728 }.bind(this));
729}
730
731/**
732 * Extend target from source object
733 * @param {object} target Target object
734 * @param {object|Array} source Source object
735 * @returns {object}
736 * @private
737 */
738function extend(target, source) {
739 var _this7 = this;
740 if (target === void 0) {
741 target = {};
742 }
743 if (isArray(source)) {
744 source.forEach(function (v) {
745 _newArrowCheck(this, _this7);
746 return extend(target, v);
747 }.bind(this));
748 }
749
750 // exclude name with only numbers
751 for (var p in source) {
752 if (/^\d+$/.test(p) || p in target) {
753 continue;
754 }
755 target[p] = source[p];
756 }
757 return target;
758}
759
760/**
761 * Return first letter capitalized
762 * @param {string} str Target string
763 * @returns {string} capitalized string
764 * @private
765 */
766var capitalize = function (str) {
767 _newArrowCheck(this, util_this);
768 return str.charAt(0).toUpperCase() + str.slice(1);
769}.bind(undefined);
770
771/**
772 * Camelize from kebob style string
773 * @param {string} str Target string
774 * @param {string} separator Separator string
775 * @returns {string} camelized string
776 * @private
777 */
778function camelize(str, separator) {
779 var _this8 = this;
780 if (separator === void 0) {
781 separator = "-";
782 }
783 return str.split(separator).map(function (v, i) {
784 _newArrowCheck(this, _this8);
785 return i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase();
786 }.bind(this)).join("");
787}
788
789/**
790 * Convert to array
791 * @param {object} v Target to be converted
792 * @returns {Array}
793 * @private
794 */
795var toArray = function (v) {
796 _newArrowCheck(this, util_this);
797 return [].slice.call(v);
798}.bind(undefined);
799
800/**
801 * Add CSS rules
802 * @param {object} style Style object
803 * @param {string} selector Selector string
804 * @param {Array} prop Prps arrary
805 * @returns {number} Newely added rule index
806 * @private
807 */
808function addCssRules(style, selector, prop) {
809 var _this9 = this,
810 rootSelctor = style.rootSelctor,
811 sheet = style.sheet,
812 getSelector = function (s) {
813 _newArrowCheck(this, _this9);
814 return s.replace(/\s?(bb-)/g, ".$1").replace(/\.+/g, ".");
815 }.bind(this),
816 rule = rootSelctor + " " + getSelector(selector) + " {" + prop.join(";") + "}";
817 return sheet[sheet.insertRule ? "insertRule" : "addRule"](rule, sheet.cssRules.length);
818}
819
820/**
821 * Get css rules for specified stylesheets
822 * @param {Array} styleSheets The stylesheets to get the rules from
823 * @returns {Array}
824 * @private
825 */
826function getCssRules(styleSheets) {
827 var _this10 = this,
828 rules = [];
829 styleSheets.forEach(function (sheet) {
830 _newArrowCheck(this, _this10);
831 try {
832 if (sheet.cssRules && sheet.cssRules.length) {
833 rules = rules.concat(toArray(sheet.cssRules));
834 }
835 } catch (e) {
836 console.error("Error while reading rules from " + sheet.href + ": " + e.toString());
837 }
838 }.bind(this));
839 return rules;
840}
841
842/**
843 * Gets the SVGMatrix of an SVGGElement
844 * @param {SVGElement} node Node element
845 * @returns {SVGMatrix} matrix
846 * @private
847 */
848function getTranslation(node) {
849 var transform = node ? node.transform : null,
850 baseVal = transform && transform.baseVal;
851 return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
852 a: 0,
853 b: 0,
854 c: 0,
855 d: 0,
856 e: 0,
857 f: 0
858 };
859}
860
861/**
862 * Get unique value from array
863 * @param {Array} data Source data
864 * @returns {Array} Unique array value
865 * @private
866 */
867function getUnique(data) {
868 var _this11 = this,
869 isDate = data[0] instanceof Date,
870 d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
871 _newArrowCheck(this, _this11);
872 return self.indexOf(v) === i;
873 }.bind(this));
874 return isDate ? d.map(function (v) {
875 _newArrowCheck(this, _this11);
876 return new Date(v);
877 }.bind(this)) : d;
878}
879
880/**
881 * Merge array
882 * @param {Array} arr Source array
883 * @returns {Array}
884 * @private
885 */
886function mergeArray(arr) {
887 var _this12 = this;
888 return arr && arr.length ? arr.reduce(function (p, c) {
889 _newArrowCheck(this, _this12);
890 return p.concat(c);
891 }.bind(this)) : [];
892}
893
894/**
895 * Merge object returning new object
896 * @param {object} target Target object
897 * @param {object} objectN Source object
898 * @returns {object} merged target object
899 * @private
900 */
901function mergeObj(target) {
902 for (var _this13 = this, _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
903 objectN[_key4 - 1] = arguments[_key4];
904 }
905 if (!objectN.length || objectN.length === 1 && !objectN[0]) {
906 return target;
907 }
908 var source = objectN.shift();
909 if (isObject(target) && isObject(source)) {
910 Object.keys(source).forEach(function (key) {
911 _newArrowCheck(this, _this13);
912 var value = source[key];
913 if (isObject(value)) {
914 target[key] || (target[key] = {});
915 target[key] = mergeObj(target[key], value);
916 } else {
917 target[key] = isArray(value) ? value.concat() : value;
918 }
919 }.bind(this));
920 }
921 return mergeObj.apply(void 0, [target].concat(objectN));
922}
923
924/**
925 * Sort value
926 * @param {Array} data value to be sorted
927 * @param {boolean} isAsc true: asc, false: desc
928 * @returns {number|string|Date} sorted date
929 * @private
930 */
931function sortValue(data, isAsc) {
932 var _this14 = this;
933 if (isAsc === void 0) {
934 isAsc = !0;
935 }
936 var fn;
937 if (data[0] instanceof Date) {
938 fn = isAsc ? function (a, b) {
939 _newArrowCheck(this, _this14);
940 return a - b;
941 }.bind(this) : function (a, b) {
942 _newArrowCheck(this, _this14);
943 return b - a;
944 }.bind(this);
945 } else {
946 if (isAsc && !data.every(isNaN)) {
947 fn = function (a, b) {
948 _newArrowCheck(this, _this14);
949 return a - b;
950 }.bind(this);
951 } else if (!isAsc) {
952 fn = function (a, b) {
953 _newArrowCheck(this, _this14);
954 return a > b && -1 || a < b && 1 || a === b && 0;
955 }.bind(this);
956 }
957 }
958 return data.concat().sort(fn);
959}
960
961/**
962 * Get min/max value
963 * @param {string} type 'min' or 'max'
964 * @param {Array} data Array data value
965 * @returns {number|Date|undefined}
966 * @private
967 */
968function getMinMax(type, data) {
969 var _this15 = this,
970 res = data.filter(function (v) {
971 _newArrowCheck(this, _this15);
972 return notEmpty(v);
973 }.bind(this));
974 if (res.length) {
975 if (isNumber(res[0])) {
976 res = Math[type].apply(Math, res);
977 } else if (res[0] instanceof Date) {
978 res = sortValue(res, type === "min")[0];
979 }
980 } else {
981 res = undefined;
982 }
983 return res;
984}
985
986/**
987 * Get range
988 * @param {number} start Start number
989 * @param {number} end End number
990 * @param {number} step Step number
991 * @returns {Array}
992 * @private
993 */
994var getRange = function (start, end, step) {
995 if (step === void 0) {
996 step = 1;
997 }
998 _newArrowCheck(this, util_this);
999 var res = [],
1000 n = Math.max(0, Math.ceil((end - start) / step)) | 0;
1001 for (var i = start; i < n; i++) {
1002 res.push(start + i * step);
1003 }
1004 return res;
1005 }.bind(undefined),
1006 emulateEvent = {
1007 mouse: function () {
1008 var _this16 = this;
1009 _newArrowCheck(this, util_this);
1010 var getParams = function () {
1011 _newArrowCheck(this, _this16);
1012 return {
1013 bubbles: !1,
1014 cancelable: !1,
1015 screenX: 0,
1016 screenY: 0,
1017 clientX: 0,
1018 clientY: 0
1019 };
1020 }.bind(this);
1021 try {
1022 // eslint-disable-next-line no-new
1023 new MouseEvent("t");
1024 return function (el, eventType, params) {
1025 if (params === void 0) {
1026 params = getParams();
1027 }
1028 _newArrowCheck(this, _this16);
1029 el.dispatchEvent(new MouseEvent(eventType, params));
1030 }.bind(this);
1031 } catch (e) {
1032 // Polyfills DOM4 MouseEvent
1033 return function (el, eventType, params) {
1034 if (params === void 0) {
1035 params = getParams();
1036 }
1037 _newArrowCheck(this, _this16);
1038 var mouseEvent = browser_doc.createEvent("MouseEvent");
1039
1040 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
1041 mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0,
1042 // the event's mouse click count
1043 params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null);
1044 el.dispatchEvent(mouseEvent);
1045 }.bind(this);
1046 }
1047 }.bind(undefined)(),
1048 touch: function touch(el, eventType, params) {
1049 _newArrowCheck(this, util_this);
1050 var touchObj = new Touch(mergeObj({
1051 identifier: Date.now(),
1052 target: el,
1053 radiusX: 2.5,
1054 radiusY: 2.5,
1055 rotationAngle: 10,
1056 force: .5
1057 }, params));
1058 el.dispatchEvent(new TouchEvent(eventType, {
1059 cancelable: !0,
1060 bubbles: !0,
1061 shiftKey: !0,
1062 touches: [touchObj],
1063 targetTouches: [],
1064 changedTouches: [touchObj]
1065 }));
1066 }.bind(undefined)
1067 }; // emulate event
1068/**
1069 * Process the template & return bound string
1070 * @param {string} tpl Template string
1071 * @param {object} data Data value to be replaced
1072 * @returns {string}
1073 * @private
1074 */
1075function tplProcess(tpl, data) {
1076 var res = tpl;
1077 for (var x in data) {
1078 res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
1079 }
1080 return res;
1081}
1082
1083/**
1084 * Get parsed date value
1085 * (It must be called in 'ChartInternal' context)
1086 * @param {Date|string|number} date Value of date to be parsed
1087 * @returns {Date}
1088 * @private
1089 */
1090function parseDate(date) {
1091 var parsedDate;
1092 if (date instanceof Date) {
1093 parsedDate = date;
1094 } else if (isString(date)) {
1095 var _format$dataTime,
1096 config = this.config,
1097 format = this.format;
1098 // if fails to parse, try by new Date()
1099 // https://github.com/naver/billboard.js/issues/1714
1100 parsedDate = (_format$dataTime = format.dataTime(config.data_xFormat)(date)) != null ? _format$dataTime : new Date(date);
1101 } else if (isNumber(date) && !isNaN(date)) {
1102 parsedDate = new Date(+date);
1103 }
1104 if (!parsedDate || isNaN(+parsedDate)) {
1105 console && console.error && console.error("Failed to parse x '" + date + "' to Date object");
1106 }
1107 return parsedDate;
1108}
1109
1110/**
1111 * Return if the current doc is visible or not
1112 * @returns {boolean}
1113 * @private
1114 */
1115function isTabVisible() {
1116 return (browser_doc == null ? void 0 : browser_doc.hidden) === !1 || (browser_doc == null ? void 0 : browser_doc.visibilityState) === "visible";
1117}
1118
1119/**
1120 * Get the current input type
1121 * @param {boolean} mouse Config value: interaction.inputType.mouse
1122 * @param {boolean} touch Config value: interaction.inputType.touch
1123 * @returns {string} "mouse" | "touch" | null
1124 * @private
1125 */
1126function convertInputType(mouse, touch) {
1127 var _this17 = this,
1128 DocumentTouch = win.DocumentTouch,
1129 matchMedia = win.matchMedia,
1130 navigator = win.navigator,
1131 hasTouch = !1;
1132 if (touch) {
1133 // Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
1134 if (navigator && "maxTouchPoints" in navigator) {
1135 hasTouch = navigator.maxTouchPoints > 0;
1136
1137 // Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
1138 // On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
1139 } else if ("ontouchmove" in win || DocumentTouch && browser_doc instanceof DocumentTouch) {
1140 hasTouch = !0;
1141 } else {
1142 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#avoiding_user_agent_detection
1143 if (matchMedia != null && matchMedia("(pointer:coarse)").matches) {
1144 hasTouch = !0;
1145 } else {
1146 // Only as a last resort, fall back to user agent sniffing
1147 var UA = navigator.userAgent;
1148 hasTouch = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
1149 }
1150 }
1151 }
1152
1153 // 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
1154 // https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-testing-the-capabilities-of-all-inputs
1155 // Demo: https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/
1156 var hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some(function (v) {
1157 _newArrowCheck(this, _this17);
1158 return matchMedia == null ? void 0 : matchMedia("(" + v + ")").matches;
1159 }.bind(this));
1160
1161 // fallback to 'mouse' if no input type is detected.
1162 return hasMouse && "mouse" || hasTouch && "touch" || "mouse";
1163}
1164
1165/**
1166 * Run function until given condition function return true
1167 * @param {Function} fn Function to be executed when condition is true
1168 * @param {Function} conditionFn Condition function to check if condition is true
1169 * @private
1170 */
1171function runUntil(fn, conditionFn) {
1172 var _this18 = this;
1173 if (conditionFn() === !1) {
1174 win.requestAnimationFrame(function () {
1175 _newArrowCheck(this, _this18);
1176 return runUntil(fn, conditionFn);
1177 }.bind(this));
1178 } else {
1179 fn();
1180 }
1181}
1182;// CONCATENATED MODULE: ./src/module/error.ts
1183
1184
1185
1186
1187/**
1188 * Copyright (c) 2021 ~ present NAVER Corp.
1189 * billboard.js project is licensed under the MIT license
1190 */
1191/* eslint no-console: "off" */
1192
1193
1194/**
1195 * Check chart type module imports.
1196 * @param {ChartInternal} ctx Context
1197 * @private
1198 */
1199function checkModuleImport(ctx) {
1200 var $$ = ctx,
1201 config = $$.config,
1202 type = "";
1203 if (isEmpty(config.data_type || config.data_types) && !$$[TYPE_METHOD_NEEDED.LINE]) {
1204 type = "line";
1205 } else {
1206 for (var x in TYPE_METHOD_NEEDED) {
1207 var t = TYPE[x];
1208 if ($$.hasType(t) && !$$[TYPE_METHOD_NEEDED[x]]) {
1209 type = t;
1210 break;
1211 }
1212 }
1213 }
1214 type && logError("Please, make sure if %c" + camelize(type), "module has been imported and specified correctly.");
1215}
1216
1217/**
1218 * Log error and throw error
1219 * @param {string} head Message header
1220 * @param {string} tail Message tail
1221 * @private
1222 */
1223function logError(head, tail) {
1224 var _window$console,
1225 prefix = "[billboard.js]",
1226 hasConsole = (_window$console = win.console) == null ? void 0 : _window$console.error;
1227 if (hasConsole) {
1228 console.error("\u274C " + prefix + " " + head, "background:red;color:white;display:block;font-size:15px", tail);
1229 console.info("%cℹ️", "font-size:15px", "https://github.com/naver/billboard.js/wiki/CHANGELOG-v2#modularization-by-its-functionality");
1230 }
1231 throw Error(prefix + " " + head.replace(/\%c([a-z-]+)/i, "'$1' ") + " " + tail);
1232}
1233;// CONCATENATED MODULE: ./src/config/classes.ts
1234
1235function classes_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1236function classes_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? classes_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : classes_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1237/**
1238 * Copyright (c) 2017 ~ present NAVER Corp.
1239 * billboard.js project is licensed under the MIT license
1240 */
1241/**
1242 * CSS class names definition
1243 * @private
1244 */
1245var $COMMON = {
1246 button: "bb-button",
1247 chart: "bb-chart",
1248 empty: "bb-empty",
1249 main: "bb-main",
1250 target: "bb-target",
1251 EXPANDED: "_expanded_"
1252};
1253var $ARC = {
1254 arc: "bb-arc",
1255 arcLabelLine: "bb-arc-label-line",
1256 arcs: "bb-arcs",
1257 chartArc: "bb-chart-arc",
1258 chartArcs: "bb-chart-arcs",
1259 chartArcsBackground: "bb-chart-arcs-background",
1260 chartArcsTitle: "bb-chart-arcs-title"
1261};
1262var $AREA = {
1263 area: "bb-area",
1264 areas: "bb-areas"
1265};
1266var $AXIS = {
1267 axis: "bb-axis",
1268 axisX: "bb-axis-x",
1269 axisXLabel: "bb-axis-x-label",
1270 axisY: "bb-axis-y",
1271 axisY2: "bb-axis-y2",
1272 axisY2Label: "bb-axis-y2-label",
1273 axisYLabel: "bb-axis-y-label"
1274};
1275var $BAR = {
1276 bar: "bb-bar",
1277 bars: "bb-bars",
1278 chartBar: "bb-chart-bar",
1279 chartBars: "bb-chart-bars"
1280};
1281var $CANDLESTICK = {
1282 candlestick: "bb-candlestick",
1283 candlesticks: "bb-candlesticks",
1284 chartCandlestick: "bb-chart-candlestick",
1285 chartCandlesticks: "bb-chart-candlesticks",
1286 valueDown: "bb-value-down",
1287 valueUp: "bb-value-up"
1288};
1289var $CIRCLE = {
1290 chartCircles: "bb-chart-circles",
1291 circle: "bb-circle",
1292 circles: "bb-circles"
1293};
1294var $COLOR = {
1295 colorPattern: "bb-color-pattern",
1296 colorScale: "bb-colorscale"
1297};
1298var $DRAG = {
1299 dragarea: "bb-dragarea",
1300 INCLUDED: "_included_"
1301};
1302var $GAUGE = {
1303 chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
1304 chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
1305 chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
1306 chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
1307 gaugeValue: "bb-gauge-value"
1308};
1309var $LEGEND = {
1310 legend: "bb-legend",
1311 legendBackground: "bb-legend-background",
1312 legendItem: "bb-legend-item",
1313 legendItemEvent: "bb-legend-item-event",
1314 legendItemHidden: "bb-legend-item-hidden",
1315 legendItemPoint: "bb-legend-item-point",
1316 legendItemTile: "bb-legend-item-tile"
1317};
1318var $LINE = {
1319 chartLine: "bb-chart-line",
1320 chartLines: "bb-chart-lines",
1321 line: "bb-line",
1322 lines: "bb-lines"
1323};
1324var $EVENT = {
1325 eventRect: "bb-event-rect",
1326 eventRects: "bb-event-rects",
1327 eventRectsMultiple: "bb-event-rects-multiple",
1328 eventRectsSingle: "bb-event-rects-single"
1329};
1330var $FOCUS = {
1331 focused: "bb-focused",
1332 defocused: "bb-defocused",
1333 legendItemFocused: "bb-legend-item-focused",
1334 xgridFocus: "bb-xgrid-focus",
1335 ygridFocus: "bb-ygrid-focus"
1336};
1337var $GRID = {
1338 grid: "bb-grid",
1339 gridLines: "bb-grid-lines",
1340 xgrid: "bb-xgrid",
1341 xgridLine: "bb-xgrid-line",
1342 xgridLines: "bb-xgrid-lines",
1343 xgrids: "bb-xgrids",
1344 ygrid: "bb-ygrid",
1345 ygridLine: "bb-ygrid-line",
1346 ygridLines: "bb-ygrid-lines",
1347 ygrids: "bb-ygrids"
1348};
1349var $LEVEL = {
1350 level: "bb-level",
1351 levels: "bb-levels"
1352};
1353var $RADAR = {
1354 chartRadar: "bb-chart-radar",
1355 chartRadars: "bb-chart-radars"
1356};
1357var $REGION = {
1358 region: "bb-region",
1359 regions: "bb-regions"
1360};
1361var $SELECT = {
1362 selectedCircle: "bb-selected-circle",
1363 selectedCircles: "bb-selected-circles",
1364 SELECTED: "_selected_"
1365};
1366var $SHAPE = {
1367 shape: "bb-shape",
1368 shapes: "bb-shapes"
1369};
1370var $SUBCHART = {
1371 brush: "bb-brush",
1372 subchart: "bb-subchart"
1373};
1374var $TEXT = {
1375 chartText: "bb-chart-text",
1376 chartTexts: "bb-chart-texts",
1377 text: "bb-text",
1378 texts: "bb-texts",
1379 title: "bb-title",
1380 TextOverlapping: "text-overlapping"
1381};
1382var $TOOLTIP = {
1383 tooltip: "bb-tooltip",
1384 tooltipContainer: "bb-tooltip-container",
1385 tooltipName: "bb-tooltip-name"
1386};
1387var $ZOOM = {
1388 buttonZoomReset: "bb-zoom-reset",
1389 zoomBrush: "bb-zoom-brush"
1390};
1391/* harmony default export */ var classes = (classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread(classes_objectSpread({}, $COMMON), $ARC), $AREA), $AXIS), $BAR), $CANDLESTICK), $CIRCLE), $COLOR), $DRAG), $GAUGE), $LEGEND), $LINE), $EVENT), $FOCUS), $GRID), $RADAR), $REGION), $SELECT), $SHAPE), $SUBCHART), $TEXT), $TOOLTIP), $ZOOM));
1392;// CONCATENATED MODULE: ./src/config/Store/Element.ts
1393/**
1394 * Copyright (c) 2017 ~ present NAVER Corp.
1395 * billboard.js project is licensed under the MIT license
1396 */
1397/**
1398 * Elements class.
1399 * @class Elements
1400 * @ignore
1401 * @private
1402 */
1403var Element = function () {
1404 return {
1405 chart: null,
1406 main: null,
1407 svg: null,
1408 axis: {
1409 // axes
1410 x: null,
1411 y: null,
1412 y2: null,
1413 subX: null
1414 },
1415 defs: null,
1416 tooltip: null,
1417 legend: null,
1418 title: null,
1419 subchart: {
1420 main: null,
1421 // $$.context
1422 bar: null,
1423 // $$.contextBar
1424 line: null,
1425 // $$.contextLine
1426 area: null // $$.contextArea
1427 },
1428
1429 arcs: null,
1430 bar: null,
1431 // mainBar,
1432 candlestick: null,
1433 line: null,
1434 // mainLine,
1435 area: null,
1436 // mainArea,
1437 circle: null,
1438 // mainCircle,
1439 radar: null,
1440 text: null,
1441 // mainText,
1442 grid: {
1443 main: null,
1444 // grid (also focus)
1445 x: null,
1446 // xgrid,
1447 y: null // ygrid,
1448 },
1449
1450 gridLines: {
1451 main: null,
1452 // gridLines
1453 x: null,
1454 // xgridLines,
1455 y: null // ygridLines
1456 },
1457
1458 region: {
1459 main: null,
1460 // region
1461 list: null // mainRegion
1462 },
1463
1464 eventRect: null,
1465 zoomResetBtn: null // drag zoom reset button
1466 };
1467};
1468
1469;// CONCATENATED MODULE: ./src/config/Store/State.ts
1470/**
1471 * Copyright (c) 2017 ~ present NAVER Corp.
1472 * billboard.js project is licensed under the MIT license
1473 */
1474/**
1475 * State class.
1476 * @class State
1477 * @ignore
1478 * @private
1479 */
1480var State = function () {
1481 return {
1482 // chart drawn area dimension, excluding axes
1483 width: 0,
1484 width2: 0,
1485 height: 0,
1486 height2: 0,
1487 margin: {
1488 top: 0,
1489 bottom: 0,
1490 left: 0,
1491 right: 0
1492 },
1493 margin2: {
1494 top: 0,
1495 bottom: 0,
1496 left: 0,
1497 right: 0
1498 },
1499 margin3: {
1500 top: 0,
1501 bottom: 0,
1502 left: 0,
1503 right: 0
1504 },
1505 arcWidth: 0,
1506 arcHeight: 0,
1507 xAxisHeight: 0,
1508 hasAxis: !1,
1509 hasRadar: !1,
1510 // for data CSS rule index (used when boost.useCssRule is true)
1511 cssRule: {},
1512 current: {
1513 // chart whole dimension
1514 width: 0,
1515 height: 0,
1516 dataMax: 0,
1517 maxTickWidths: {
1518 x: {
1519 size: 0,
1520 ticks: [],
1521 clipPath: 0,
1522 domain: ""
1523 },
1524 y: {
1525 size: 0,
1526 domain: ""
1527 },
1528 y2: {
1529 size: 0,
1530 domain: ""
1531 }
1532 },
1533 // current used chart type list
1534 types: []
1535 },
1536 // legend
1537 isLegendRight: !1,
1538 isLegendInset: !1,
1539 isLegendTop: !1,
1540 isLegendLeft: !1,
1541 legendStep: 0,
1542 legendItemWidth: 0,
1543 legendItemHeight: 0,
1544 legendHasRendered: !1,
1545 eventReceiver: {
1546 currentIdx: -1,
1547 // current event interaction index
1548 rect: {},
1549 // event rect's clientBoundingRect
1550 data: [],
1551 // event data bound of previoous eventRect
1552 coords: [] // coordination value of previous eventRect
1553 },
1554
1555 axis: {
1556 x: {
1557 padding: {
1558 left: 0,
1559 right: 0
1560 },
1561 tickCount: 0
1562 }
1563 },
1564 rotatedPadding: {
1565 left: 30,
1566 right: 0,
1567 top: 5
1568 },
1569 withoutFadeIn: {},
1570 inputType: "",
1571 datetimeId: "",
1572 // clip id string
1573 clip: {
1574 id: "",
1575 idXAxis: "",
1576 idYAxis: "",
1577 idXAxisTickTexts: "",
1578 idGrid: "",
1579 idSubchart: "",
1580 // clipIdForSubchart
1581 path: "",
1582 pathXAxis: "",
1583 pathYAxis: "",
1584 pathXAxisTickTexts: "",
1585 pathGrid: ""
1586 },
1587 // status
1588 event: null,
1589 // event object
1590 dragStart: null,
1591 dragging: !1,
1592 flowing: !1,
1593 cancelClick: !1,
1594 mouseover: !1,
1595 rendered: !1,
1596 transiting: !1,
1597 redrawing: !1,
1598 // if redraw() is on process
1599 resizing: !1,
1600 // resize event called
1601 toggling: !1,
1602 // legend toggle
1603 zooming: !1,
1604 hasNegativeValue: !1,
1605 hasPositiveValue: !0,
1606 orgAreaOpacity: "0.2",
1607 orgConfig: {},
1608 // user original genration config
1609
1610 // ID strings
1611 hiddenTargetIds: [],
1612 hiddenLegendIds: [],
1613 focusedTargetIds: [],
1614 defocusedTargetIds: [],
1615 // value for Arc
1616 radius: 0,
1617 innerRadius: 0,
1618 outerRadius: undefined,
1619 innerRadiusRatio: 0,
1620 gaugeArcWidth: 0,
1621 radiusExpanded: 0,
1622 // xgrid attribute
1623 xgridAttr: {
1624 x1: null,
1625 x2: null,
1626 y1: null,
1627 y2: null
1628 }
1629 };
1630};
1631
1632;// CONCATENATED MODULE: ./src/config/Store/Store.ts
1633
1634/**
1635 * Copyright (c) 2017 ~ present NAVER Corp.
1636 * billboard.js project is licensed under the MIT license
1637 */
1638
1639
1640
1641// mapping
1642var Store_classes = {
1643 element: Element,
1644 state: State
1645};
1646
1647/**
1648 * Internal store class.
1649 * @class Store
1650 * @ignore
1651 * @private
1652 */
1653var Store = /*#__PURE__*/function () {
1654 function Store() {
1655 var _this = this;
1656 Object.keys(Store_classes).forEach(function (v) {
1657 _newArrowCheck(this, _this);
1658 this[v] = new Store_classes[v]();
1659 }.bind(this));
1660 }
1661 var _proto = Store.prototype;
1662 _proto.getStore = function getStore(name) {
1663 return this[name];
1664 };
1665 return Store;
1666}();
1667
1668;// CONCATENATED MODULE: ./src/config/Options/common/main.ts
1669/**
1670 * Copyright (c) 2017 ~ present NAVER Corp.
1671 * billboard.js project is licensed under the MIT license
1672 */
1673/**
1674 * main config options
1675 */
1676/* harmony default export */ var main = ({
1677 /**
1678 * Specify the CSS selector or the element which the chart will be set to. D3 selection object can be specified also.<br>
1679 * If other chart is set already, it will be replaced with the new one (only one chart can be set in one element).
1680 * - **NOTE:** In case of element doesn't exist or not specified, will add a `<div>` element to the body.
1681 * @name bindto
1682 * @memberof Options
1683 * @property {string|HTMLElement|d3.selection|object} [bindto="#chart"] Specify the element where chart will be drawn.
1684 * @property {string|HTMLElement|d3.selection} bindto.element="#chart" Specify the element where chart will be drawn.
1685 * @property {string} [bindto.classname=bb] Specify the class name of bind element.<br>
1686 * **NOTE:** When class name isn't `bb`, then you also need to update the default CSS to be rendered correctly.
1687 * @default #chart
1688 * @example
1689 * bindto: "#myContainer"
1690 *
1691 * // or HTMLElement
1692 * bindto: document.getElementById("myContainer")
1693 *
1694 * // or D3 selection object
1695 * bindto: d3.select("#myContainer")
1696 *
1697 * // or to change default classname
1698 * bindto: {
1699 * element: "#chart",
1700 * classname: "bill-board" // ex) <div id='chart' class='bill-board'>
1701 * }
1702 */
1703 bindto: "#chart",
1704 /**
1705 * Set chart background.
1706 * @name background
1707 * @memberof Options
1708 * @property {object} background background object
1709 * @property {string} background.class Specify the class name for background element.
1710 * @property {string} background.color Specify the fill color for background element.<br>**NOTE:** Will be ignored if `imgUrl` option is set.
1711 * @property {string} background.imgUrl Specify the image url string for background.
1712 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.Background)
1713 * @example
1714 * background: {
1715 * class: "myClass",
1716 * color: "red",
1717 *
1718 * // Set image url for background.
1719 * // If specified, 'color' option will be ignored.
1720 * imgUrl: "https://naver.github.io/billboard.js/img/logo/billboard.js.svg",
1721 * }
1722 */
1723 background: {},
1724 /**
1725 * Set 'clip-path' attribute for chart element
1726 * - **NOTE:**
1727 * > When is false, chart node element is positioned after the axis node in DOM tree hierarchy.
1728 * > Is to make chart element positioned over axis element.
1729 * @name clipPath
1730 * @memberof Options
1731 * @type {boolean}
1732 * @default true
1733 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.clipPath)
1734 * @example
1735 * // don't set 'clip-path' attribute
1736 * clipPath: false
1737 */
1738 clipPath: !0,
1739 /**
1740 * Set svg element's class name
1741 * @name svg
1742 * @memberof Options
1743 * @type {object}
1744 * @property {object} [svg] svg object
1745 * @property {string} [svg.classname] class name for svg element
1746 * @example
1747 * svg: {
1748 * classname: "test_class"
1749 * }
1750 */
1751 svg_classname: undefined,
1752 /**
1753 * The desired size of the chart element.
1754 * If value is not specified, the width of the chart will be calculated by the size of the parent element it's appended to.
1755 * @name size
1756 * @memberof Options
1757 * @type {object}
1758 * @property {object} [size] size object
1759 * @property {number} [size.width] width of the chart element
1760 * @property {number} [size.height] height of the chart element
1761 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.ChartSize)
1762 * @example
1763 * size: {
1764 * width: 640,
1765 * height: 480
1766 * }
1767 */
1768 size_width: undefined,
1769 size_height: undefined,
1770 /**
1771 * The padding of the chart element.
1772 * @name padding
1773 * @memberof Options
1774 * @type {object}
1775 * @property {object|boolean} [padding=true] Set padding of chart, and accepts object or boolean type.
1776 * - `Object`: Specify each side's padding.
1777 * - `false`: Remove padding completely and make shape to fully occupy the container element.
1778 * - In this case, axes and subchart will be hidden.
1779 * - To adjust some padding from this state, use `axis.[x|y].padding` option.
1780 * @property {number} [padding.top] padding on the top of chart
1781 * @property {number} [padding.right] padding on the right of chart
1782 * @property {number} [padding.bottom] padding on the bottom of chart
1783 * @property {number} [padding.left] padding on the left of chart
1784 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.Padding)
1785 * @example
1786 * // remove padding completely.
1787 * padding: false,
1788 *
1789 * // or specify padding value for each side
1790 * padding: {
1791 * top: 20,
1792 * right: 20,
1793 * bottom: 20,
1794 * left: 20
1795 * }
1796 */
1797 padding: !0,
1798 padding_left: undefined,
1799 padding_right: undefined,
1800 padding_top: undefined,
1801 padding_bottom: undefined,
1802 /**
1803 * Set chart resize options
1804 * @name resize
1805 * @memberof Options
1806 * @type {object}
1807 * @property {object} [resize] resize object
1808 * @property {boolean} [resize.auto=true] Set chart resize automatically on viewport changes.
1809 * @property {boolean|number} [resize.timer=true] Set resize timer option.
1810 * - **NOTE:**
1811 * - The resize function will be called using: true - `setTimeout()`, false - `requestIdleCallback()`.
1812 * - Given number(delay in ms) value, resize function will be triggered using `setTimer()` with given delay.
1813 * @example
1814 * resize: {
1815 * auto: false,
1816 *
1817 * // set resize function will be triggered using `setTimer()`
1818 * timer: true,
1819 *
1820 * // set resize function will be triggered using `requestIdleCallback()`
1821 * timer: false,
1822 *
1823 * // set resize function will be triggered using `setTimer()` with a delay of `100ms`.
1824 * timer: 100
1825 * }
1826 */
1827 resize_auto: !0,
1828 resize_timer: !0,
1829 /**
1830 * Set a callback to execute when the chart is clicked.
1831 * @name onclick
1832 * @memberof Options
1833 * @type {Function}
1834 * @default undefined
1835 * @example
1836 * onclick: function(event) {
1837 * this; // chart instance itself
1838 * event; // native event object
1839 * ...
1840 * }
1841 */
1842 onclick: undefined,
1843 /**
1844 * Set a callback to execute when mouse/touch enters the chart.
1845 * @name onover
1846 * @memberof Options
1847 * @type {Function}
1848 * @default undefined
1849 * @example
1850 * onover: function(event) {
1851 * this; // chart instance itself
1852 * event; // native event object
1853 * ...
1854 * }
1855 */
1856 onover: undefined,
1857 /**
1858 * Set a callback to execute when mouse/touch leaves the chart.
1859 * @name onout
1860 * @memberof Options
1861 * @type {Function}
1862 * @default undefined
1863 * @example
1864 * onout: function(event) {
1865 * this; // chart instance itself
1866 * event; // native event object
1867 * ...
1868 * }
1869 */
1870 onout: undefined,
1871 /**
1872 * Set a callback to execute when user resizes the screen.
1873 * @name onresize
1874 * @memberof Options
1875 * @type {Function}
1876 * @default undefined
1877 * @example
1878 * onresize: function() {
1879 * this; // chart instance itself
1880 * ...
1881 * }
1882 */
1883 onresize: undefined,
1884 /**
1885 * Set a callback to execute when screen resize finished.
1886 * @name onresized
1887 * @memberof Options
1888 * @type {Function}
1889 * @default undefined
1890 * @example
1891 * onresized: function() {
1892 * this; // chart instance itself
1893 * ...
1894 * }
1895 */
1896 onresized: undefined,
1897 /**
1898 * Set a callback to execute before the chart is initialized
1899 * @name onbeforeinit
1900 * @memberof Options
1901 * @type {Function}
1902 * @default undefined
1903 * @example
1904 * onbeforeinit: function() {
1905 * this; // chart instance itself
1906 * ...
1907 * }
1908 */
1909 onbeforeinit: undefined,
1910 /**
1911 * Set a callback to execute when the chart is initialized.
1912 * @name oninit
1913 * @memberof Options
1914 * @type {Function}
1915 * @default undefined
1916 * @example
1917 * oninit: function() {
1918 * this; // chart instance itself
1919 * ...
1920 * }
1921 */
1922 oninit: undefined,
1923 /**
1924 * Set a callback to execute after the chart is initialized
1925 * @name onafterinit
1926 * @memberof Options
1927 * @type {Function}
1928 * @default undefined
1929 * @example
1930 * onafterinit: function() {
1931 * this; // chart instance itself
1932 * ...
1933 * }
1934 */
1935 onafterinit: undefined,
1936 /**
1937 * Set a callback which is executed when the chart is rendered. Basically, this callback will be called in each time when the chart is redrawed.
1938 * @name onrendered
1939 * @memberof Options
1940 * @type {Function}
1941 * @default undefined
1942 * @example
1943 * onrendered: function() {
1944 * this; // chart instance itself
1945 * ...
1946 * }
1947 */
1948 onrendered: undefined,
1949 /**
1950 * Set duration of transition (in milliseconds) for chart animation.<br><br>
1951 * - **NOTE:** If `0 `or `null` set, transition will be skipped. So, this makes initial rendering faster especially in case you have a lot of data.
1952 * @name transition
1953 * @memberof Options
1954 * @type {object}
1955 * @property {object} [transition] transition object
1956 * @property {number} [transition.duration=350] duration in milliseconds
1957 * @example
1958 * transition: {
1959 * duration: 500
1960 * }
1961 */
1962 transition_duration: 250,
1963 /**
1964 * Set plugins
1965 * @name plugins
1966 * @memberof Options
1967 * @type {Array}
1968 * @example
1969 * plugins: [
1970 * new bb.plugin.stanford({ ... }),
1971 * new PluginA(),
1972 * ...
1973 * ]
1974 */
1975 plugins: [],
1976 /**
1977 * Control the render timing
1978 * @name render
1979 * @memberof Options
1980 * @type {object}
1981 * @property {object} [render] render object
1982 * @property {boolean} [render.lazy=true] Make to not render at initialization (enabled by default when bind element's visibility is hidden).
1983 * @property {boolean} [render.observe=true] Observe bind element's visibility(`display` or `visiblity` inline css property or class value) & render when is visible automatically (for IEs, only works IE11+). When set to **false**, call [`.flush()`](./Chart.html#flush) to render.
1984 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.LazyRender)
1985 * @example
1986 * render: {
1987 * lazy: true,
1988 * observe: true
1989 * }
1990 *
1991 * @example
1992 * // <!-- render.lazy will detect visibility defined -->
1993 * // (a) <div id='chart' class='hide'></div>
1994 * // (b) <div id='chart' style='display:none'></div>
1995 *
1996 * // render.lazy enabled by default when element is hidden
1997 * var chart = bb.generate({ ... });
1998 *
1999 * // chart will be rendered automatically when element's visibility changes
2000 * // Note: works only for inlined css property or class attribute changes
2001 * document.getElementById('chart').classList.remove('hide') // (a)
2002 * document.getElementById('chart').style.display = 'block'; // (b)
2003 *
2004 * @example
2005 * // chart won't be rendered and not observing bind element's visiblity changes
2006 * var chart = bb.generate({
2007 * render: {
2008 * lazy: true,
2009 * observe: false
2010 * }
2011 * });
2012 *
2013 * // call at any point when you want to render
2014 * chart.flush();
2015 */
2016 render: {},
2017 /**
2018 * Show rectangles inside the chart.<br><br>
2019 * This option accepts array including object that has axis, start, end and class.
2020 * The keys start, end and class are optional.
2021 * axis must be x, y or y2. start and end should be the value where regions start and end.
2022 * If not specified, the edge values will be used.
2023 * If timeseries x axis, date string, Date object and unixtime integer can be used.
2024 * If class is set, the region element will have it as class.
2025 * @name regions
2026 * @memberof Options
2027 * @type {Array}
2028 * @default []
2029 * @example
2030 * regions: [
2031 * {
2032 * axis: "x",
2033 * start: 1,
2034 * end: 4,
2035 * class: "region-1-4"
2036 * }
2037 * ]
2038 */
2039 regions: []
2040});
2041;// CONCATENATED MODULE: ./src/config/Options/common/boost.ts
2042/**
2043 * Copyright (c) 2017 ~ present NAVER Corp.
2044 * billboard.js project is licensed under the MIT license
2045 */
2046/**
2047 * boost config options
2048 */
2049/* harmony default export */ var boost = ({
2050 /**
2051 * Set boost options
2052 * @name boost
2053 * @memberof Options
2054 * @type {object}
2055 * @property {object} boost boost object
2056 * @property {boolean} [boost.useCssRule=false] Avoid setting inline styles for each shape elements.
2057 * - **NOTE:**
2058 * - Will append &lt;style> to the head tag and will add shpes' CSS rules dynamically.
2059 * - For now, covers colors related properties (fill, stroke, etc.) only.
2060 * @property {boolean} [boost.useWorker=false] Use Web Worker as possible for processing.
2061 * - **NOTE:**
2062 * - For now, only applies for data conversion at the initial time.
2063 * - As of Web Worker's async nature, handling chart instance synchrously is not recommended.
2064 * @example
2065 * boost: {
2066 * useCssRule: true,
2067 * useWorker: false
2068 * }
2069 */
2070 boost_useCssRule: !1,
2071 boost_useWorker: !1
2072});
2073;// CONCATENATED MODULE: ./src/config/Options/data/data.ts
2074
2075var data_this = undefined;
2076/**
2077 * Copyright (c) 2017 ~ present NAVER Corp.
2078 * billboard.js project is licensed under the MIT license
2079 */
2080
2081/**
2082 * data config options
2083 */
2084/* harmony default export */ var data = ({
2085 /**
2086 * Specify the key of x values in the data.<br><br>
2087 * We can show the data with non-index x values by this option. This option is required when the type of x axis is timeseries. If this option is set on category axis, the values of the data on the key will be used for category names.
2088 * @name data․x
2089 * @memberof Options
2090 * @type {string}
2091 * @default undefined
2092 * @example
2093 * data: {
2094 * x: "date"
2095 * }
2096 */
2097 data_x: undefined,
2098 /**
2099 * Converts data id value
2100 * @name data․idConverter
2101 * @memberof Options
2102 * @type {Function}
2103 * @default function(id) { return id; }
2104 * @example
2105 * data: {
2106 * idConverter: function(id) {
2107 * // when id is 'data1', converts to be 'data2'
2108 * // 'data2' should be given as the initial data value
2109 * if (id === "data1") {
2110 * return "data2";
2111 * } else {
2112 * return id;
2113 * }
2114 * }
2115 * }
2116 */
2117 data_idConverter: function data_idConverter(id) {
2118 _newArrowCheck(this, data_this);
2119 return id;
2120 }.bind(undefined),
2121 /**
2122 * Set custom data name.
2123 * If a name is set to `null`, the series is omitted from the legend.
2124 * @name data․names
2125 * @memberof Options
2126 * @type {object}
2127 * @default {}
2128 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataName)
2129 * @example
2130 * data: {
2131 * names: {
2132 * data1: "Data Name 1",
2133 * data2: "Data Name 2"
2134 * }
2135 * }
2136 */
2137 data_names: {},
2138 /**
2139 * Set custom data class.<br><br>
2140 * If this option is specified, the element g for the data has an additional class that has the prefix 'bb-target-' (eg. bb-target-additional-data1-class).
2141 * @name data․classes
2142 * @memberof Options
2143 * @type {object}
2144 * @default {}
2145 * @example
2146 * data: {
2147 * classes: {
2148 * data1: "additional-data1-class",
2149 * data2: "additional-data2-class"
2150 * }
2151 * }
2152 */
2153 data_classes: {},
2154 /**
2155 * Set chart type at once.<br><br>
2156 * If this option is specified, the type will be applied to every data. This setting can be overwritten by data.types.<br><br>
2157 * **Available Values:**
2158 * - area
2159 * - area-line-range
2160 * - area-spline
2161 * - area-spline-range
2162 * - area-step
2163 * - bar
2164 * - bubble
2165 * - candlestick
2166 * - donut
2167 * - gauge
2168 * - line
2169 * - pie
2170 * - polar
2171 * - radar
2172 * - scatter
2173 * - spline
2174 * - step
2175 * @name data․type
2176 * @memberof Options
2177 * @type {string}
2178 * @default "line"<br>NOTE: When importing shapes by ESM, `line()` should be specified for type.
2179 * @example
2180 * data: {
2181 * type: "bar"
2182 * }
2183 * @example
2184 * // Generate chart by importing ESM
2185 * // Import types to be used only, where this will make smaller bundle size.
2186 * import bb, {
2187 * area,
2188 * areaLineRange,
2189 * areaSpline,
2190 * areaSplineRange,
2191 * areaStep,
2192 * bar,
2193 * bubble,
2194 * candlestick,
2195 * donut,
2196 * gauge,
2197 * line,
2198 * pie,
2199 * polar,
2200 * radar,
2201 * scatter,
2202 * spline,
2203 * step
2204 * }
2205 *
2206 * bb.generate({
2207 * ...,
2208 * data: {
2209 * type: bar()
2210 * }
2211 * });
2212 */
2213 data_type: undefined,
2214 /**
2215 * Set chart type for each data.<br>
2216 * This setting overwrites data.type setting.
2217 * - **NOTE:** `radar` type can't be combined with other types.
2218 * @name data․types
2219 * @memberof Options
2220 * @type {object}
2221 * @default {}
2222 * @example
2223 * data: {
2224 * types: {
2225 * data1: "bar",
2226 * data2: "spline"
2227 * }
2228 * }
2229 * @example
2230 * // Generate chart by importing ESM
2231 * // Import types to be used only, where this will make smaller bundle size.
2232 * import bb, {
2233 * area,
2234 * areaLineRange,
2235 * areaSpline,
2236 * areaSplineRange,
2237 * areaStep,
2238 * bar,
2239 * bubble,
2240 * candlestick,
2241 * donut,
2242 * gauge,
2243 * line,
2244 * pie,
2245 * polar,
2246 * radar,
2247 * scatter,
2248 * spline,
2249 * step
2250 * }
2251 *
2252 * bb.generate({
2253 * ...,
2254 * data: {
2255 * types: {
2256 * data1: bar(),
2257 * data1: spline()
2258 * }
2259 * }
2260 * });
2261 */
2262 data_types: {},
2263 /**
2264 * This option changes the order of stacking data and pieces of pie/donut.
2265 * - If `null` specified, it will be the order the data loaded.
2266 * - If function specified, it will be used as [Array.sort compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters)<br><br>
2267 *
2268 * **Available Values:**
2269 * - `desc`: In descending order
2270 * - `asc`: In ascending order
2271 * - `null`: It keeps the data load order
2272 * - `function(data1, data2) { ... }`: Array.sort compareFunction
2273 *
2274 * **NOTE**: order function, only works for Axis based types & Arc types, except `Radar` type.
2275 * @name data․order
2276 * @memberof Options
2277 * @type {string|Function|null}
2278 * @default desc
2279 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataOrder)
2280 * @example
2281 * data: {
2282 * // in descending order (default)
2283 * order: "desc"
2284 *
2285 * // in ascending order
2286 * order: "asc"
2287 *
2288 * // keeps data input order
2289 * order: null
2290 *
2291 * // specifying sort function
2292 * order: function(a, b) {
2293 * // param data passed format
2294 * // {
2295 * // id: "data1", id_org: "data1", values: [
2296 * // {x: 5, value: 250, id: "data1", index: 5, name: "data1"},
2297 * // ...
2298 * // ]
2299 * // }
2300 *
2301 * const reducer = (p, c) => p + Math.abs(c.value);
2302 * const aSum = a.values.reduce(reducer, 0);
2303 * const bSum = b.values.reduce(reducer, 0);
2304 *
2305 * // ascending order
2306 * return aSum - bSum;
2307 *
2308 * // descending order
2309 * // return bSum - aSum;
2310 * }
2311 * }
2312 */
2313 data_order: "desc",
2314 /**
2315 * Set groups for the data for stacking.
2316 * @name data․groups
2317 * @memberof Options
2318 * @type {Array}
2319 * @default []
2320 * @example
2321 * data: {
2322 * groups: [
2323 * ["data1", "data2"],
2324 * ["data3"]
2325 * ]
2326 * }
2327 */
2328 data_groups: [],
2329 /**
2330 * Set how zero value will be treated on groups.<br>
2331 * Possible values:
2332 * - `zero`: 0 will be positioned at absolute axis zero point.
2333 * - `positive`: 0 will be positioned at the top of a stack.
2334 * - `negative`: 0 will be positioned at the bottom of a stack.
2335 * @name data․groupsZeroAs
2336 * @memberof Options
2337 * @type {string}
2338 * @default "positive"
2339 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.Groups)
2340 * @example
2341 * data: {
2342 * groupsZeroAs: "zero" // "positive" or "negative"
2343 * }
2344 */
2345 data_groupsZeroAs: "positive",
2346 /**
2347 * Set color converter function.<br><br>
2348 * This option should a function and the specified function receives color (e.g. '#ff0000') and d that has data parameters like id, value, index, etc. And it must return a string that represents color (e.g. '#00ff00').
2349 * @name data․color
2350 * @memberof Options
2351 * @type {Function}
2352 * @default undefined
2353 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataColor)
2354 * @example
2355 * data: {
2356 * color: function(color, d) { ... }
2357 * }
2358 */
2359 data_color: undefined,
2360 /**
2361 * Set color for each data.
2362 * @name data․colors
2363 * @memberof Options
2364 * @type {object}
2365 * @default {}
2366 * @example
2367 * data: {
2368 * colors: {
2369 * data1: "#ff0000",
2370 * data2: function(d) {
2371 * return "#000";
2372 * }
2373 * ...
2374 * }
2375 * }
2376 */
2377 data_colors: {},
2378 /**
2379 * Set labels options
2380 * @name data․labels
2381 * @memberof Options
2382 * @type {object}
2383 * @property {object} data Data object
2384 * @property {boolean} [data.labels=false] Show or hide labels on each data points
2385 * @property {boolean} [data.labels.centered=false] Centerize labels on `bar` shape. (**NOTE:** works only for 'bar' type)
2386 * @property {Function} [data.labels.format] Set formatter function for data labels.<br>
2387 * The formatter function receives 4 arguments such as v, id, i, j and it **must return a string**(`\n` character will be used as line break) that will be shown as the label.<br><br>
2388 * The arguments are:<br>
2389 * - `v` is the value of the data point where the label is shown.
2390 * - `id` is the id of the data where the label is shown.
2391 * - `i` is the index of the data series point where the label is shown.
2392 * - `texts` is the array of whole corresponding data series' text labels.<br><br>
2393 * Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
2394 * @property {string|object} [data.labels.backgroundColors] Set label text background colors.
2395 * @property {string|object|Function} [data.labels.colors] Set label text colors.
2396 * @property {object} [data.labels.position] Set each dataset position, relative the original.
2397 * @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
2398 * @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
2399 * @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
2400 * - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
2401 * @memberof Options
2402 * @type {object}
2403 * @default {}
2404 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataLabel)
2405 * @see [Demo: label colors](https://naver.github.io/billboard.js/demo/#Data.DataLabelColors)
2406 * @see [Demo: label format](https://naver.github.io/billboard.js/demo/#Data.DataLabelFormat)
2407 * @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
2408 * @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
2409 * @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
2410 * @see [Demo: label rotate](https://naver.github.io/billboard.js/demo/#Data.DataLabelRotate)
2411 * @example
2412 * data: {
2413 * labels: true,
2414 *
2415 * // or set specific options
2416 * labels: {
2417 * format: function(v, id, i, j) {
2418 * ...
2419 * // to multiline, return with '\n' character
2420 * return "Line1\nLine2";
2421 * },
2422 *
2423 * // it's possible to set for each data
2424 * format: {
2425 * data1: function(v, id, i, texts) { ... },
2426 * ...
2427 * },
2428 *
2429 * // align text to center of the 'bar' shape (works only for 'bar' type)
2430 * centered: true,
2431 *
2432 * // apply backgound color for label texts
2433 * backgroundColors: "red",
2434 *
2435 * // set differenct backround colors per dataset
2436 * backgroundColors: {
2437 * data1: "green",
2438 * data2: "yellow"
2439 * }
2440 *
2441 * // apply for all label texts
2442 * colors: "red",
2443 *
2444 * // set different colors per dataset
2445 * // for not specified dataset, will have the default color value
2446 * colors: {
2447 * data1: "yellow",
2448 * data3: "green"
2449 * },
2450 *
2451 * // call back for label text color
2452 * colors: function(color, d) {
2453 * // color: the default data label color string
2454 * // data: ex) {x: 0, value: 200, id: "data3", index: 0}
2455 * ....
2456 * return d.value > 200 ? "cyan" : color;
2457 * },
2458 *
2459 * // set x, y coordinate position
2460 * position: {
2461 * x: -10,
2462 * y: 10
2463 * },
2464 *
2465 * // or set x, y coordinate position by each dataset
2466 * position: {
2467 * data1: {x: 5, y: 5},
2468 * data2: {x: 10, y: -20}
2469 * },
2470 *
2471 * // rotate degree for label text
2472 * rotate: 90
2473 * }
2474 * }
2475 */
2476 data_labels: {},
2477 data_labels_backgroundColors: undefined,
2478 data_labels_colors: undefined,
2479 data_labels_position: {},
2480 /**
2481 * Hide each data when the chart appears.<br><br>
2482 * If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
2483 * @name data․hide
2484 * @memberof Options
2485 * @type {boolean|Array}
2486 * @default false
2487 * @example
2488 * data: {
2489 * // all of data will be hidden
2490 * hide: true
2491 *
2492 * // specified data will be hidden
2493 * hide: ["data1", ...]
2494 * }
2495 */
2496 data_hide: !1,
2497 /**
2498 * Filter values to be shown
2499 * The data value is the same as the returned by `.data()`.
2500 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
2501 * @name data․filter
2502 * @memberof Options
2503 * @type {Function}
2504 * @default undefined
2505 * @example
2506 * data: {
2507 * // filter for id value
2508 * filter: function(v) {
2509 * // v: [{id: "data1", id_org: "data1", values: [
2510 * // {x: 0, value: 130, id: "data2", index: 0}, ...]
2511 * // }, ...]
2512 * return v.id !== "data1";
2513 * }
2514 */
2515 data_filter: undefined,
2516 /**
2517 * Set a callback for click event on each data point.<br><br>
2518 * This callback will be called when each data point clicked and will receive `d` and element as the arguments.
2519 * - `d` is the data clicked and element is the element clicked.
2520 * - `element` is the current interacting svg element.
2521 * - In this callback, `this` will be the Chart object.
2522 * @name data․onclick
2523 * @memberof Options
2524 * @type {Function}
2525 * @default function() {}
2526 * @example
2527 * data: {
2528 * onclick: function(d, element) {
2529 * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
2530 * // element - <circle>
2531 * ...
2532 * }
2533 * }
2534 */
2535 data_onclick: function data_onclick() {
2536 _newArrowCheck(this, data_this);
2537 }.bind(undefined),
2538 /**
2539 * Set a callback for mouse/touch over event on each data point.<br><br>
2540 * This callback will be called when mouse cursor or via touch moves onto each data point and will receive `d` and `element` as the argument.
2541 * - `d` is the data where mouse cursor moves onto.
2542 * - `element` is the current interacting svg element.
2543 * - In this callback, `this` will be the Chart object.
2544 * @name data․onover
2545 * @memberof Options
2546 * @type {Function}
2547 * @default function() {}
2548 * @example
2549 * data: {
2550 * onover: function(d, element) {
2551 * // d - ex) {x: 4, value: 150, id: "data1", index: 4}
2552 * // element - <circle>
2553 * ...
2554 * }
2555 * }
2556 */
2557 data_onover: function data_onover() {
2558 _newArrowCheck(this, data_this);
2559 }.bind(undefined),
2560 /**
2561 * Set a callback for mouse/touch out event on each data point.<br><br>
2562 * This callback will be called when mouse cursor or via touch moves out each data point and will receive `d` as the argument.
2563 * - `d` is the data where mouse cursor moves out.
2564 * - `element` is the current interacting svg element.
2565 * - In this callback, `this` will be the Chart object.
2566 * @name data․onout
2567 * @memberof Options
2568 * @type {Function}
2569 * @default function() {}
2570 * @example
2571 * data: {
2572 * onout: function(d, element) {
2573 * // d - ex) {x: 4, value: 150, id: "data1", index: 4}
2574 * // element - <circle>
2575 * ...
2576 * }
2577 * }
2578 */
2579 data_onout: function data_onout() {
2580 _newArrowCheck(this, data_this);
2581 }.bind(undefined),
2582 /**
2583 * Set a callback for when data is shown.<br>
2584 * The callback will receive shown data ids in array.
2585 * @name data․onshown
2586 * @memberof Options
2587 * @type {Function}
2588 * @default undefined
2589 * @example
2590 * data: {
2591 * onshown: function(ids) {
2592 * // ids - ["data1", "data2", ...]
2593 * ...
2594 * }
2595 * }
2596 */
2597 data_onshown: undefined,
2598 /**
2599 * Set a callback for when data is hidden.<br>
2600 * The callback will receive hidden data ids in array.
2601 * @name data․onhidden
2602 * @memberof Options
2603 * @type {Function}
2604 * @default undefined
2605 * @example
2606 * data: {
2607 * onhidden: function(ids) {
2608 * // ids - ["data1", "data2", ...]
2609 * ...
2610 * }
2611 * }
2612 */
2613 data_onhidden: undefined,
2614 /**
2615 * Set a callback for minimum data
2616 * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
2617 * @name data․onmin
2618 * @memberof Options
2619 * @type {Function}
2620 * @default undefined
2621 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
2622 * @example
2623 * onmin: function(data) {
2624 * // data - ex) [{x: 3, value: 400, id: "data1", index: 3}, ... ]
2625 * ...
2626 * }
2627 */
2628 data_onmin: undefined,
2629 /**
2630 * Set a callback for maximum data
2631 * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
2632 * @name data․onmax
2633 * @memberof Options
2634 * @type {Function}
2635 * @default undefined
2636 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
2637 * @example
2638 * onmax: function(data) {
2639 * // data - ex) [{x: 3, value: 400, id: "data1", index: 3}, ... ]
2640 * ...
2641 * }
2642 */
2643 data_onmax: undefined,
2644 /**
2645 * Load a CSV or JSON file from a URL. NOTE that this will not work if loading via the "file://" protocol as the most browsers will block XMLHTTPRequests.
2646 * @name data․url
2647 * @memberof Options
2648 * @type {string}
2649 * @default undefined
2650 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.LoadData)
2651 * @example
2652 * data: {
2653 * url: "/data/test.csv"
2654 * }
2655 */
2656 data_url: undefined,
2657 /**
2658 * XHR header value
2659 * - **NOTE:** Should be used with `data.url` option
2660 * @name data․headers
2661 * @memberof Options
2662 * @type {string}
2663 * @default undefined
2664 * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
2665 * @example
2666 * data: {
2667 * url: "/data/test.csv",
2668 * headers: {
2669 * "Content-Type": "text/xml",
2670 * ...
2671 * }
2672 * }
2673 */
2674 data_headers: undefined,
2675 /**
2676 * Parse a JSON object for data. See also data.keys.
2677 * @name data․json
2678 * @memberof Options
2679 * @type {Array}
2680 * @default undefined
2681 * @see [data․keys](#.data%25E2%2580%25A4keys)
2682 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.JSONData)
2683 * @example
2684 * data: {
2685 * json: [
2686 * {name: "www.site1.com", upload: 200, download: 200, total: 400},
2687 * {name: "www.site2.com", upload: 100, download: 300, total: 400},
2688 * {name: "www.site3.com", upload: 300, download: 200, total: 500},
2689 * {name: "www.site4.com", upload: 400, download: 100, total: 500}
2690 * ],
2691 * keys: {
2692 * // x: "name", // it's possible to specify 'x' when category axis
2693 * value: ["upload", "download"]
2694 * }
2695 * }
2696 */
2697 data_json: undefined,
2698 /**
2699 * Load data from a multidimensional array, with the first element containing the data names, the following containing related data in that order.
2700 * @name data․rows
2701 * @memberof Options
2702 * @type {Array}
2703 * @default undefined
2704 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.RowOrientedData)
2705 * @example
2706 * data: {
2707 * rows: [
2708 * ["A", "B", "C"],
2709 * [90, 120, 300],
2710 * [40, 160, 240],
2711 * [50, 200, 290],
2712 * [120, 160, 230],
2713 * [80, 130, 300],
2714 * [90, 220, 320]
2715 * ]
2716 * }
2717 *
2718 * // for 'bar' type, data can contain:
2719 * // - an array of [start, end] data following the order
2720 * data: {
2721 * rows: [
2722 * ["data1", "data2"],
2723 * [[100, 150], 120],
2724 * [[200, 300], 55],
2725 * [[-400, 500], 60]
2726 * ],
2727 * type: "bar"
2728 * }
2729 *
2730 * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
2731 * // - an array of [high, mid, low] data following the order
2732 * // - or an object with 'high', 'mid' and 'low' key value
2733 * data: {
2734 * rows: [
2735 * ["data1", "data2"],
2736 * [
2737 * // or {high:150, mid: 140, low: 110}, 120
2738 * [150, 140, 110], 120
2739 * ],
2740 * [[155, 130, 115], 55],
2741 * [[160, 135, 120], 60]
2742 * ],
2743 * types: {
2744 * data1: "area-line-range",
2745 * data2: "line"
2746 * }
2747 * }
2748 *
2749 * // for 'bubble' type, data can contain dimension value:
2750 * // - an array of [y, z] data following the order
2751 * // - or an object with 'y' and 'z' key value
2752 * // 'y' is for y axis coordination and 'z' is the bubble radius value
2753 * data: {
2754 * rows: [
2755 * ["data1", "data2"],
2756 * [
2757 * // or {y:10, z: 140}, 120
2758 * [10, 140], 120
2759 * ],
2760 * [[100, 30], 55],
2761 * [[50, 100], 60]
2762 * ],
2763 * types: {
2764 * data1: "bubble",
2765 * data2: "line"
2766 * }
2767 * }
2768 *
2769 * // for 'canlestick' type, data should contain:
2770 * // - an array of [open, high, low, close, volume(optional)] data following the order
2771 * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
2772 * data: {
2773 * rows: [
2774 * ["data1", "data2"],
2775 * [
2776 * // open, high, low, close, volume (optional)
2777 * {open: 1300, high: 1369, low: 1200, close: 1339, volume: 100},
2778 * [1000, 1100, 850, 870]
2779 * ],
2780 * [
2781 * {open: 1348, high: 1371, low: 1271, close: 1320},
2782 * [870, 1250, 830, 1200, 50]
2783 * ]
2784 * ],
2785 * type: "candlestick"
2786 * }
2787 */
2788 data_rows: undefined,
2789 /**
2790 * Load data from a multidimensional array, with each element containing an array consisting of a datum name and associated data values.
2791 * @name data․columns
2792 * @memberof Options
2793 * @type {Array}
2794 * @default undefined
2795 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.ColumnOrientedData)
2796 * @example
2797 * data: {
2798 * columns: [
2799 * ["data1", 30, 20, 50, 40, 60, 50],
2800 * ["data2", 200, 130, 90, 240, 130, 220],
2801 * ["data3", 300, 200, 160, 400, 250, 250]
2802 * ]
2803 * }
2804 *
2805 * // for 'bar' type, data can contain:
2806 * // - an array of [start, end] data following the order
2807 * data: {
2808 * columns: [
2809 * ["data1", -100, 50, [100, 200], [200, 300]],
2810 * ["data2", -200, 300, [-100, 100], [-50, -30]],
2811 * ],
2812 * type: "bar"
2813 * }
2814 *
2815 * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
2816 * // - an array of [high, mid, low] data following the order
2817 * // - or an object with 'high', 'mid' and 'low' key value
2818 * data: {
2819 * columns: [
2820 * ["data1",
2821 * [150, 140, 110], // or {high:150, mid: 140, low: 110}
2822 * [150, 140, 110],
2823 * [150, 140, 110]
2824 * ]
2825 * ],
2826 * type: "area-line-range"
2827 * }
2828 *
2829 * // for 'bubble' type, data can contain dimension value:
2830 * // - an array of [y, z] data following the order
2831 * // - or an object with 'y' and 'z' key value
2832 * // 'y' is for y axis coordination and 'z' is the bubble radius value
2833 * data: {
2834 * columns: [
2835 * ["data1",
2836 * [10, 140], // or {y:10, z: 140}
2837 * [100, 30],
2838 * [50, 100]
2839 * ]
2840 * ],
2841 * type: "bubble"
2842 * }
2843 *
2844 * // for 'canlestick' type, data should contain:
2845 * // - an array of [open, high, low, close, volume(optional)] data following the order
2846 * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
2847 * data: {
2848 * columns: [
2849 * ["data1",
2850 * [1000, 1100, 850, 870, 100], // or {open:1000, high: 1100, low: 870, volume: 100}
2851 * [870, 1250, 830, 1200] // 'volume' can be omitted
2852 * ]
2853 * ],
2854 * type: "candlestick"
2855 * }
2856 */
2857 data_columns: undefined,
2858 /**
2859 * Used if loading JSON via data.url.
2860 * - **Available Values:**
2861 * - json
2862 * - csv
2863 * - tsv
2864 * @name data․mimeType
2865 * @memberof Options
2866 * @type {string}
2867 * @default csv
2868 * @example
2869 * data: {
2870 * mimeType: "json"
2871 * }
2872 */
2873 data_mimeType: "csv",
2874 /**
2875 * Choose which JSON object keys correspond to desired data.
2876 * - **NOTE:** Only for JSON object given as array.
2877 * @name data․keys
2878 * @memberof Options
2879 * @type {string}
2880 * @default undefined
2881 * @example
2882 * data: {
2883 * json: [
2884 * {name: "www.site1.com", upload: 200, download: 200, total: 400},
2885 * {name: "www.site2.com", upload: 100, download: 300, total: 400},
2886 * {name: "www.site3.com", upload: 300, download: 200, total: 500},
2887 * {name: "www.site4.com", upload: 400, download: 100, total: 500}
2888 * ],
2889 * keys: {
2890 * // x: "name", // it's possible to specify 'x' when category axis
2891 * value: ["upload", "download"]
2892 * }
2893 * }
2894 */
2895 data_keys: undefined,
2896 /**
2897 * Set text label to be displayed when there's no data to show.
2898 * - ex. Toggling all visible data to not be shown, unloading all current data, etc.
2899 * @name data․empty․label․text
2900 * @memberof Options
2901 * @type {string}
2902 * @default ""
2903 * @example
2904 * data: {
2905 * empty: {
2906 * label: {
2907 * text: "No Data"
2908 * }
2909 * }
2910 * }
2911 */
2912 data_empty_label_text: ""
2913});
2914;// CONCATENATED MODULE: ./src/config/Options/common/color.ts
2915/**
2916 * Copyright (c) 2017 ~ present NAVER Corp.
2917 * billboard.js project is licensed under the MIT license
2918 */
2919/**
2920 * color config options
2921 */
2922/* harmony default export */ var color = ({
2923 /**
2924 * Set color of the data values
2925 * @name color
2926 * @memberof Options
2927 * @type {object}
2928 * @property {object} color color object
2929 * @property {string|object|Function} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
2930 * @property {Array|null} [color.pattern=[]] Set custom color pattern. Passing `null` will not set a color for these elements, which requires the usage of custom CSS-based theming to work.
2931 * @property {Function} [color.tiles] if defined, allows use svg's patterns to fill data area. It should return an array of [SVGPatternElement](https://developer.mozilla.org/en-US/docs/Web/API/SVGPatternElement).
2932 * - **NOTE:** The pattern element's id will be defined as `bb-colorize-pattern-$COLOR-VALUE`.<br>
2933 * ex. When color pattern value is `['red', '#fff']` and defined 2 patterns,then ids for pattern elements are:<br>
2934 * - `bb-colorize-pattern-red`
2935 * - `bb-colorize-pattern-fff`
2936 * @property {object} [color.threshold] color threshold for gauge and tooltip color
2937 * @property {string} [color.threshold.unit] If set to `value`, the threshold will be based on the data value. Otherwise it'll be based on equation of the `threshold.max` option value.
2938 * @property {Array} [color.threshold.values] Threshold values for each steps
2939 * @property {number} [color.threshold.max=100] The base value to determine threshold step value condition. When the given value is 15 and max 10, then the value for threshold is `15*100/10`.
2940 * @example
2941 * color: {
2942 * pattern: ["#1f77b4", "#aec7e8", ...],
2943 *
2944 * // Set colors' patterns
2945 * // it should return an array of SVGPatternElement
2946 * tiles: function() {
2947 * var pattern = document.createElementNS("http://www.w3.org/2000/svg", "pattern");
2948 * var g = document.createElementNS("http://www.w3.org/2000/svg", "g");
2949 * var circle1 = document.createElementNS("http://www.w3.org/2000/svg", "circle");
2950 *
2951 * pattern.setAttribute("patternUnits", "userSpaceOnUse");
2952 * pattern.setAttribute("width", "32");
2953 * pattern.setAttribute("height", "32");
2954 *
2955 * g.style.fill = "#000";
2956 * g.style.opacity = "0.2";
2957 *
2958 * circle1.setAttribute("cx", "3");
2959 * circle1.setAttribute("cy", "3");
2960 * circle1.setAttribute("r", "3");
2961 *
2962 * g.appendChild(circle1);
2963 * pattern.appendChild(g);
2964 *
2965 * return [pattern];
2966 * },
2967 *
2968 * // for threshold usage, pattern values should be set for each steps
2969 * pattern: ["grey", "green", "yellow", "orange", "red"],
2970 * threshold: {
2971 * unit: "value",
2972 *
2973 * // when value is 20 => 'green', value is 40 => 'orange' will be set.
2974 * values: [10, 20, 30, 40, 50],
2975 *
2976 * // the equation for max:
2977 * // - unit == 'value': max => 30
2978 * // - unit != 'value': max => value*100/30
2979 * max: 30
2980 * },
2981 *
2982 * // set all data to 'red'
2983 * onover: "red",
2984 *
2985 * // set different color for data
2986 * onover: {
2987 * data1: "red",
2988 * data2: "yellow"
2989 * },
2990 *
2991 * // will pass data object to the callback
2992 * onover: function(d) {
2993 * return d.id === "data1" ? "red" : "green";
2994 * }
2995 * }
2996 */
2997 color_pattern: [],
2998 color_tiles: undefined,
2999 color_threshold: {},
3000 color_onover: undefined
3001});
3002;// CONCATENATED MODULE: ./src/config/Options/interaction/interaction.ts
3003/**
3004 * Copyright (c) 2017 ~ present NAVER Corp.
3005 * billboard.js project is licensed under the MIT license
3006 */
3007/**
3008 * interaction config options
3009 */
3010/* harmony default export */ var interaction = ({
3011 /**
3012 * Interaction options
3013 * @name interaction
3014 * @memberof Options
3015 * @type {object}
3016 * @property {object} interaction Intersection object
3017 * @property {boolean} [interaction.enabled=true] Indicate if the chart should have interactions.<br>
3018 * If `false` is set, all of interactions (showing/hiding tooltip, selection, mouse events, etc) will be disabled.
3019 * @property {boolean} [interaction.brighten=true] Make brighter for the selected area (ex. 'pie' type data selected area)
3020 * @property {boolean} [interaction.inputType.mouse=true] enable or disable mouse interaction
3021 * @property {boolean} [interaction.inputType.touch=true] enable or disable touch interaction
3022 * @property {boolean|number} [interaction.inputType.touch.preventDefault=false] enable or disable to call event.preventDefault on touchstart & touchmove event. It's usually used to prevent document scrolling.
3023 * @see [Demo: touch.preventDefault](https://naver.github.io/billboard.js/demo/#Interaction.PreventScrollOnTouch)
3024 * @example
3025 * interaction: {
3026 * enabled: false,
3027 * brighten: false,
3028 * inputType: {
3029 * mouse: true,
3030 * touch: false
3031 *
3032 * // or declare preventDefault explicitly.
3033 * // In this case touch inputType is enabled by default
3034 * touch: {
3035 * preventDefault: true
3036 *
3037 * // or threshold pixel value (pixel moved from touchstart to touchmove)
3038 * preventDefault: 5
3039 * }
3040 * }
3041 * }
3042 */
3043 interaction_enabled: !0,
3044 interaction_brighten: !0,
3045 interaction_inputType_mouse: !0,
3046 interaction_inputType_touch: {}
3047});
3048;// CONCATENATED MODULE: ./src/config/Options/common/legend.ts
3049/**
3050 * Copyright (c) 2017 ~ present NAVER Corp.
3051 * billboard.js project is licensed under the MIT license
3052 */
3053/**
3054 * legend config options
3055 */
3056/* harmony default export */ var legend = ({
3057 /**
3058 * Legend options
3059 * @name legend
3060 * @memberof Options
3061 * @type {object}
3062 * @property {object} legend Legend object
3063 * @property {boolean} [legend.show=true] Show or hide legend.
3064 * @property {boolean} [legend.hide=false] Hide legend
3065 * If true given, all legend will be hidden. If string or array given, only the legend that has the id will be hidden.
3066 * @property {string|HTMLElement} [legend.contents.bindto=undefined] Set CSS selector or element reference to bind legend items.
3067 * - **NOTE:** Should be used along with `legend.contents.template`.
3068 * @property {string|Function} [legend.contents.template="<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>"] Set item's template.<br>
3069 * - If set `string` value, within template the 'color' and 'title' can be replaced using template-like syntax string:
3070 * - {=COLOR}: data color value
3071 * - {=TITLE}: data title value
3072 * - If set `function` value, will pass following arguments to the given function:
3073 * - title {string}: data's id value
3074 * - color {string}: color string
3075 * - data {Array}: data array
3076 * @property {string} [legend.position=bottom] Change the position of legend.<br>
3077 * Available values are: `bottom`, `right` and `inset` are supported.
3078 * @property {object} [legend.inset={anchor: 'top-left',x: 10,y: 0,step: undefined}] Change inset legend attributes.<br>
3079 * This option accepts object that has the keys `anchor`, `x`, `y` and `step`.
3080 * - **anchor** decides the position of the legend:
3081 * - top-left
3082 * - top-right
3083 * - bottom-left
3084 * - bottom-right
3085 * - **x** and **y**:
3086 * - set the position of the legend based on the anchor.
3087 * - **step**:
3088 * - defines the max step the legend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).
3089 * @property {boolean} [legend.equally=false] Set to all items have same width size.
3090 * @property {boolean} [legend.padding=0] Set padding value
3091 * @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
3092 * @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
3093 * @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
3094 * @property {number} [legend.item.tile.width=10] Set width for 'rectangle' legend item tile element.
3095 * @property {number} [legend.item.tile.height=10] ㄹ
3096 * @property {number} [legend.item.tile.r=5] Set the radius for 'circle' legend item tile type.
3097 * @property {string} [legend.item.tile.type="rectangle"] Set legend item shape type.<br>
3098 * - **Available Values:**
3099 * - circle
3100 * - rectangle
3101 * @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
3102 * @see [Demo: item.tile.type](https://naver.github.io/billboard.js/demo/#Legend.LegendItemTileType)
3103 * @see [Demo: position](https://naver.github.io/billboard.js/demo/#Legend.LegendPosition)
3104 * @see [Demo: contents.template](https://naver.github.io/billboard.js/demo/#Legend.LegendTemplate1)
3105 * @see [Demo: usePoint](https://naver.github.io/billboard.js/demo/#Legend.usePoint)
3106 * @example
3107 * legend: {
3108 * show: true,
3109 * hide: true,
3110 * //or hide: "data1"
3111 * //or hide: ["data1", "data2"]
3112 * contents: {
3113 * bindto: "#legend", // <ul id='legend'></ul>
3114 *
3115 * // will be as: <li style='background-color:#1f77b4'>data1</li>
3116 * template: "<li style='background-color:{=COLOR}'>{=TITLE}</li>"
3117 *
3118 * // or using function
3119 * template: function(id, color, data) {
3120 * // if you want omit some legend, return falsy value
3121 * if (id !== "data1") {
3122 * return "<li style='background-color:"+ color +">"+ id +"</li>";
3123 * }
3124 * }
3125 * },
3126 * position: "bottom", // bottom, right, inset
3127 * inset: {
3128 * anchor: "top-right" // top-left, top-right, bottom-left, bottom-right
3129 * x: 20,
3130 * y: 10,
3131 * step: 2
3132 * },
3133 * equally: false,
3134 * padding: 10,
3135 * item: {
3136 * onclick: function(id) { ... },
3137 * onover: function(id) { ... },
3138 * onout: function(id) { ... },
3139 *
3140 * // set tile's size
3141 * tile: {
3142 * // set tile type
3143 * type: "circle" // or "rectangle" (default)
3144 *
3145 * // width & height, are only applicable for 'rectangle' legend type
3146 * width: 15,
3147 * height: 15
3148 *
3149 * // radis is only applicable for 'circle' legend type
3150 * r: 10
3151 * }
3152 * },
3153 * usePoint: true
3154 * }
3155 */
3156 legend_show: !0,
3157 legend_hide: !1,
3158 legend_contents_bindto: undefined,
3159 legend_contents_template: "<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>",
3160 legend_position: "bottom",
3161 legend_inset_anchor: "top-left",
3162 legend_inset_x: 10,
3163 legend_inset_y: 0,
3164 legend_inset_step: undefined,
3165 legend_item_onclick: undefined,
3166 legend_item_onover: undefined,
3167 legend_item_onout: undefined,
3168 legend_equally: !1,
3169 legend_padding: 0,
3170 legend_item_tile_width: 10,
3171 legend_item_tile_height: 10,
3172 legend_item_tile_r: 5,
3173 legend_item_tile_type: "rectangle",
3174 legend_usePoint: !1
3175});
3176;// CONCATENATED MODULE: ./src/config/Options/common/title.ts
3177/**
3178 * Copyright (c) 2017 ~ present NAVER Corp.
3179 * billboard.js project is licensed under the MIT license
3180 */
3181/**
3182 * title config options
3183 */
3184/* harmony default export */ var title = ({
3185 /**
3186 * Set title options
3187 * @name title
3188 * @memberof Options
3189 * @type {object}
3190 * @property {object} title Title object
3191 * @property {string} [title.text] Title text. If contains `\n`, it's used as line break allowing multiline title.
3192 * @property {number} [title.padding.top=0] Top padding value.
3193 * @property {number} [title.padding.right=0] Right padding value.
3194 * @property {number} [title.padding.bottom=0] Bottom padding value.
3195 * @property {number} [title.padding.left=0] Left padding value.
3196 * @property {string} [title.position=center] Available values are: 'center', 'right' and 'left'.
3197 * @see [Demo](https://naver.github.io/billboard.js/demo/#Title.MultilinedTitle)
3198 * @example
3199 * title: {
3200 * text: "Title Text",
3201 *
3202 * // or Multiline title text
3203 * text: "Main title text\nSub title text",
3204 *
3205 * padding: {
3206 * top: 10,
3207 * right: 10,
3208 * bottom: 10,
3209 * left: 10
3210 * },
3211 * position: "center"
3212 * }
3213 */
3214 title_text: undefined,
3215 title_padding: {
3216 top: 0,
3217 right: 0,
3218 bottom: 0,
3219 left: 0
3220 },
3221 title_position: "center"
3222});
3223;// CONCATENATED MODULE: ./src/config/Options/common/tooltip.ts
3224
3225var tooltip_this = undefined;
3226/**
3227 * Copyright (c) 2017 ~ present NAVER Corp.
3228 * billboard.js project is licensed under the MIT license
3229 */
3230/**
3231 * tooltip config options
3232 */
3233/* harmony default export */ var tooltip = ({
3234 /**
3235 * Tooltip options
3236 * @name tooltip
3237 * @memberof Options
3238 * @type {object}
3239 * @property {object} tooltip Tooltip object
3240 * @property {boolean} [tooltip.show=true] Show or hide tooltip.
3241 * @property {boolean} [tooltip.doNotHide=false] Make tooltip keep showing not hiding on interaction.
3242 * @property {boolean} [tooltip.grouped=true] Set if tooltip is grouped or not for the data points.
3243 * - **NOTE:** The overlapped data points will be displayed as grouped even if set false.
3244 * @property {boolean} [tooltip.linked=false] Set if tooltips on all visible charts with like x points are shown together when one is shown.
3245 * @property {string} [tooltip.linked.name=""] Groping name for linked tooltip.<br>If specified, linked tooltip will be groped interacting to be worked only with the same name.
3246 * @property {Function} [tooltip.format.title] Set format for the title of tooltip.<br>
3247 * Specified function receives x of the data point to show.
3248 * @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
3249 * Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
3250 * @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip.<br>
3251 * Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
3252 * If undefined returned, the row of that value will be skipped.
3253 * @property {Function} [tooltip.position] Set custom position function for the tooltip.<br>
3254 * This option can be used to modify the tooltip position by returning object that has top and left.
3255 * - Will pass following arguments to the given function:
3256 * - `data {Array}`: Current selected data array object.
3257 * - `width {number}`: Width of tooltip.
3258 * - `height {number}`: Height of tooltip.
3259 * - `element {SVGElement}`: Tooltip event bound element
3260 * - `pos {object}`: Current position of the tooltip.
3261 * @property {Function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
3262 * If tooltip.grouped is true, data includes multiple data points.<br><br>
3263 * Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
3264 * - **Note:**
3265 * - defaultTitleFormat:
3266 * - if `axis.x.tick.format` option will be used if set.
3267 * - otherwise, will return function based on tick format type(category, timeseries).
3268 * - defaultValueFormat:
3269 * - for Arc type (except gauge, radar), the function will return value from `(ratio * 100).toFixed(1)`.
3270 * - for Axis based types, will be used `axis.[y|y2].tick.format` option value if is set.
3271 * - otherwise, will parse value and return as number.
3272 * @property {string|HTMLElement} [tooltip.contents.bindto=undefined] Set CSS selector or element reference to bind tooltip.
3273 * - **NOTE:** When is specified, will not be updating tooltip's position.
3274 * @property {string} [tooltip.contents.template=undefined] Set tooltip's template.<br><br>
3275 * Within template, below syntax will be replaced using template-like syntax string:
3276 * - **{{ ... }}**: the doubly curly brackets indicate loop block for data rows.
3277 * - **{=CLASS_TOOLTIP}**: default tooltip class name `bb-tooltip`.
3278 * - **{=CLASS_TOOLTIP_NAME}**: default tooltip data class name (ex. `bb-tooltip-name-data1`)
3279 * - **{=TITLE}**: title value.
3280 * - **{=COLOR}**: data color.
3281 * - **{=VALUE}**: data value.
3282 * @property {object} [tooltip.contents.text=undefined] Set additional text content within data loop, using template syntax.
3283 * - **NOTE:** It should contain `{ key: Array, ... }` value
3284 * - 'key' name is used as substitution within template as '{=KEY}'
3285 * - The value array length should match with the data length
3286 * @property {boolean} [tooltip.init.show=false] Show tooltip at the initialization.
3287 * @property {number} [tooltip.init.x=0] Set x Axis index(or index for Arc(donut, gauge, pie) types) to be shown at the initialization.
3288 * @property {object} [tooltip.init.position={top: "0px",left: "50px"}] Set the position of tooltip at the initialization.
3289 * @property {Function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
3290 * @property {Function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
3291 * @property {Function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
3292 * @property {Function} [tooltip.onhidden] Set a callback that will be invoked after the tooltip is hidden.
3293 * @property {string|Function|null} [tooltip.order=null] Set tooltip data display order.<br><br>
3294 * **Available Values:**
3295 * - `desc`: In descending data value order
3296 * - `asc`: In ascending data value order
3297 * - `null`: It keeps the data display order<br>
3298 * **NOTE:** When `data.groups` is set, the order will follow as the stacked graph order.<br>
3299 * If want to order as data bound, set any value rather than asc, desc or null. (ex. empty string "")
3300 * - `function(data1, data2) { ... }`: [Array.sort compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters)
3301 * @see [Demo: Hide Tooltip](https://naver.github.io/billboard.js/demo/#Tooltip.HideTooltip)
3302 * @see [Demo: Tooltip Grouping](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipGrouping)
3303 * @see [Demo: Tooltip Format](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipFormat)
3304 * @see [Demo: Linked Tooltip](https://naver.github.io/billboard.js/demo/#Tooltip.LinkedTooltips)
3305 * @see [Demo: Tooltip Template](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipTemplate)
3306 * @example
3307 * tooltip: {
3308 * show: true,
3309 * doNotHide: true,
3310 * grouped: false,
3311 * format: {
3312 * title: function(x) { return "Data " + x; },
3313 * name: function(name, ratio, id, index) { return name; },
3314 * value: function(value, ratio, id, index) { return ratio; }
3315 * },
3316 * position: function(data, width, height, element, pos) {
3317 * // data: [{x, index, id, name, value}, ...]
3318 * // width: Tooltip width
3319 * // height: Tooltip height
3320 * // element: Tooltip event bound element
3321 * // pos: {
3322 * // x: Current mouse event x position,
3323 * // y: Current mouse event y position,
3324 * // xAxis: Current x Axis position (the value is given for axis based chart type only)
3325 * // }
3326 * return {top: 0, left: 0}
3327 * },
3328 *
3329 * contents: function(d, defaultTitleFormat, defaultValueFormat, color) {
3330 * return ... // formatted html as you want
3331 * },
3332 *
3333 * // specify tooltip contents using template
3334 * // - example of HTML returned:
3335 * // <ul class="bb-tooltip">
3336 * // <li class="bb-tooltip-name-data1"><span>250</span><br><span style="color:#00c73c">data1</span></li>
3337 * // <li class="bb-tooltip-name-data2"><span>50</span><br><span style="color:#fa7171">data2</span></li>
3338 * // </ul>
3339 * contents: {
3340 * bindto: "#tooltip",
3341 * template: '<ul class={=CLASS_TOOLTIP}>{{' +
3342 * '<li class="{=CLASS_TOOLTIP_NAME}"><span>{=VALUE}</span><br>' +
3343 * '<span style=color:{=COLOR}>{=NAME}</span></li>' +
3344 * '}}</ul>'
3345 * }
3346 *
3347 * // with additional text value
3348 * // - example of HTML returned:
3349 * // <ul class="bb-tooltip">
3350 * // <li class="bb-tooltip-name-data1"><span>250</span><br>comment1<span style="color:#00c73c">data1</span>text1</li>
3351 * // <li class="bb-tooltip-name-data2"><span>50</span><br>comment2<span style="color:#fa7171">data2</span>text2</li>
3352 * // </ul>
3353 * contents: {
3354 * bindto: "#tooltip",
3355 * text: {
3356 * // a) 'key' name is used as substitution within template as '{=KEY}'
3357 * // b) the length should match with the data length
3358 * VAR1: ["text1", "text2"],
3359 * VAR2: ["comment1", "comment2"],
3360 * },
3361 * template: '<ul class={=CLASS_TOOLTIP}>{{' +
3362 * '<li class="{=CLASS_TOOLTIP_NAME}"><span>{=VALUE}</span>{=VAR2}<br>' +
3363 * '<span style=color:{=COLOR}>{=NAME}</span>{=VAR1}</li>' +
3364 * '}}</ul>'
3365 * }
3366 *
3367 * // sort tooltip data value display in ascending order
3368 * order: "asc",
3369 *
3370 * // specifying sort function
3371 * order: function(a, b) {
3372 * // param data passed format
3373 * {x: 5, value: 250, id: "data1", index: 5, name: "data1"}
3374 * ...
3375 * },
3376 *
3377 * // show at the initialization
3378 * init: {
3379 * show: true,
3380 * x: 2, // x Axis index(or index for Arc(donut, gauge, pie) types)
3381 * position: {
3382 * top: "150px",
3383 * left: "250px"
3384 * }
3385 * },
3386 *
3387 * // fires prior tooltip is shown
3388 * onshow: function(selectedData) {
3389 * // current dataset selected
3390 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
3391 * selectedData;
3392 * },
3393 *
3394 * // fires prior tooltip is hidden
3395 * onhide: function(selectedData) {
3396 * // current dataset selected
3397 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
3398 * selectedData;
3399 * },
3400 *
3401 * // fires after tooltip is shown
3402 * onshown: function(selectedData) {
3403 * // current dataset selected
3404 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
3405 * selectedData;
3406 * },
3407 *
3408 * // fires after tooltip is hidden
3409 * onhidden: function(selectedData) {
3410 * // current dataset selected
3411 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
3412 * selectedData;
3413 * },
3414 *
3415 * // Link any tooltips when multiple charts are on the screen where same x coordinates are available
3416 * // Useful for timeseries correlation
3417 * linked: true,
3418 *
3419 * // Specify name to interact those with the same name only.
3420 * linked: {
3421 * name: "some-group"
3422 * }
3423 * }
3424 */
3425 tooltip_show: !0,
3426 tooltip_doNotHide: !1,
3427 tooltip_grouped: !0,
3428 tooltip_format_title: undefined,
3429 tooltip_format_name: undefined,
3430 tooltip_format_value: undefined,
3431 tooltip_position: undefined,
3432 tooltip_contents: {},
3433 tooltip_init_show: !1,
3434 tooltip_init_x: 0,
3435 tooltip_init_position: {
3436 top: "0px",
3437 left: "50px"
3438 },
3439 tooltip_linked: !1,
3440 tooltip_linked_name: "",
3441 tooltip_onshow: function tooltip_onshow() {
3442 _newArrowCheck(this, tooltip_this);
3443 }.bind(undefined),
3444 tooltip_onhide: function tooltip_onhide() {
3445 _newArrowCheck(this, tooltip_this);
3446 }.bind(undefined),
3447 tooltip_onshown: function tooltip_onshown() {
3448 _newArrowCheck(this, tooltip_this);
3449 }.bind(undefined),
3450 tooltip_onhidden: function tooltip_onhidden() {
3451 _newArrowCheck(this, tooltip_this);
3452 }.bind(undefined),
3453 tooltip_order: null
3454});
3455;// CONCATENATED MODULE: ./src/config/Options/Options.ts
3456
3457
3458function Options_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3459function Options_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? Options_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : Options_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3460/**
3461 * Copyright (c) 2017 ~ present NAVER Corp.
3462 * billboard.js project is licensed under the MIT license
3463 */
3464// common
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475/**
3476 * Class to set options on generating chart.
3477 * - It's instantiated internally, not exposed for public.
3478 * @class Options
3479 * @see {@link bb.generate} to use these options on generating the chart
3480 */
3481var Options = /*#__PURE__*/function () {
3482 Options.setOptions = function setOptions(options) {
3483 var _this = this;
3484 this.data = options.reduce(function (a, c) {
3485 _newArrowCheck(this, _this);
3486 return Options_objectSpread(Options_objectSpread({}, a), c);
3487 }.bind(this), this.data);
3488 };
3489 function Options() {
3490 return deepClone(main, boost, data, color, interaction, legend, title, tooltip, Options.data);
3491 }
3492 return Options;
3493}();
3494Options.data = {};
3495
3496;// CONCATENATED MODULE: ./src/module/Cache.ts
3497
3498/**
3499 * Copyright (c) 2017 ~ present NAVER Corp.
3500 * billboard.js project is licensed under the MIT license
3501 */
3502
3503/**
3504 * Constant for cache key
3505 * - NOTE: Prefixed with '$', will be resetted when .load() is called
3506 * @private
3507 */
3508var KEY = {
3509 bubbleBaseLength: "$baseLength",
3510 colorPattern: "__colorPattern__",
3511 dataMinMax: "$dataMinMax",
3512 dataTotalSum: "$dataTotalSum",
3513 dataTotalPerIndex: "$totalPerIndex",
3514 legendItemTextBox: "legendItemTextBox",
3515 radarPoints: "$radarPoints",
3516 setOverOut: "setOverOut",
3517 callOverOutForTouch: "callOverOutForTouch",
3518 textRect: "textRect"
3519};
3520var Cache = /*#__PURE__*/function () {
3521 function Cache() {
3522 this.cache = {};
3523 }
3524 var _proto = Cache.prototype;
3525 /**
3526 * Add cache
3527 * @param {string} key Cache key
3528 * @param {*} value Value to be stored
3529 * @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
3530 * @returns {*} Added data value
3531 * @private
3532 */
3533 _proto.add = function add(key, value, isDataType) {
3534 if (isDataType === void 0) {
3535 isDataType = !1;
3536 }
3537 this.cache[key] = isDataType ? this.cloneTarget(value) : value;
3538 return this.cache[key];
3539 }
3540
3541 /**
3542 * Remove cache
3543 * @param {string|Array} key Cache key
3544 * @private
3545 */;
3546 _proto.remove = function remove(key) {
3547 var _this = this;
3548 toArray(key).forEach(function (v) {
3549 _newArrowCheck(this, _this);
3550 return delete this.cache[v];
3551 }.bind(this));
3552 }
3553
3554 /**
3555 * Get cahce
3556 * @param {string|Array} key Cache key
3557 * @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
3558 * @returns {*}
3559 * @private
3560 */;
3561 _proto.get = function get(key, isDataType) {
3562 if (isDataType === void 0) {
3563 isDataType = !1;
3564 }
3565 if (isDataType) {
3566 var targets = [];
3567 for (var i = 0, id; id = key[i]; i++) {
3568 if (id in this.cache) {
3569 targets.push(this.cloneTarget(this.cache[id]));
3570 }
3571 }
3572 return targets;
3573 } else {
3574 var value = this.cache[key];
3575 return isValue(value) ? value : null;
3576 }
3577 }
3578
3579 /**
3580 * Reset cached data
3581 * @param {boolean} all true: reset all data, false: reset only '$' prefixed key data
3582 * @private
3583 */;
3584 _proto.reset = function reset(all) {
3585 var $$ = this;
3586 for (var x in $$.cache) {
3587 // reset the prefixed '$' key(which is internal use data) only.
3588 if (all || /^\$/.test(x)) {
3589 $$.cache[x] = null;
3590 }
3591 }
3592 }
3593
3594 /**
3595 * Clone data target object
3596 * @param {object} target Data object
3597 * @returns {object}
3598 * @private
3599 */
3600 // eslint-disable-next-line camelcase
3601 ;
3602 _proto.cloneTarget = function cloneTarget(target) {
3603 var _this2 = this;
3604 return {
3605 id: target.id,
3606 id_org: target.id_org,
3607 values: target.values.map(function (d) {
3608 _newArrowCheck(this, _this2);
3609 return {
3610 x: d.x,
3611 value: d.value,
3612 id: d.id
3613 };
3614 }.bind(this))
3615 };
3616 };
3617 return Cache;
3618}();
3619
3620;// CONCATENATED MODULE: ./src/module/generator.ts
3621
3622/**
3623 * Copyright (c) 2017 ~ present NAVER Corp.
3624 * billboard.js project is licensed under the MIT license
3625 */
3626
3627
3628
3629var generator_setTimeout = win.setTimeout,
3630 generator_clearTimeout = win.clearTimeout;
3631
3632/**
3633 * Generate resize queue function
3634 * @param {boolean|number} option Resize option
3635 * @returns {Fucntion}
3636 * @private
3637 */
3638function generateResize(option) {
3639 var _this4 = this,
3640 fn = [],
3641 timeout,
3642 callResizeFn = function () {
3643 var _this = this;
3644 // Delay all resize functions call, to prevent unintended excessive call from resize event
3645 callResizeFn.clear();
3646 if (option === !1 && win.requestIdleCallback) {
3647 requestIdleCallback(function () {
3648 var _this2 = this;
3649 _newArrowCheck(this, _this);
3650 fn.forEach(function (f) {
3651 _newArrowCheck(this, _this2);
3652 return f();
3653 }.bind(this));
3654 }.bind(this), {
3655 timeout: 200
3656 });
3657 } else {
3658 timeout = generator_setTimeout(function () {
3659 var _this3 = this;
3660 _newArrowCheck(this, _this);
3661 fn.forEach(function (f) {
3662 _newArrowCheck(this, _this3);
3663 return f();
3664 }.bind(this));
3665 }.bind(this), isNumber(option) ? option : 200);
3666 }
3667 };
3668 callResizeFn.clear = function () {
3669 _newArrowCheck(this, _this4);
3670 if (timeout) {
3671 generator_clearTimeout(timeout);
3672 timeout = null;
3673 }
3674 }.bind(this);
3675 callResizeFn.add = function (f) {
3676 _newArrowCheck(this, _this4);
3677 return fn.push(f);
3678 }.bind(this);
3679 callResizeFn.remove = function (f) {
3680 _newArrowCheck(this, _this4);
3681 return fn.splice(fn.indexOf(f), 1);
3682 }.bind(this);
3683 return callResizeFn;
3684}
3685/**
3686 * Generate transition queue function
3687 * @returns {Function}
3688 * @private
3689 */
3690function generateWait() {
3691 var transitionsToWait = [],
3692 f = function (selection, callback) {
3693 var _this5 = this;
3694 /**
3695 * Check if transition is complete
3696 * @returns {boolean} Whether transition is complete
3697 * @private
3698 */
3699 function loop() {
3700 var done = 0;
3701 for (var i = 0, t; t = transitionsToWait[i]; i++) {
3702 if (t === !0 || t.empty != null && t.empty()) {
3703 done++;
3704 continue;
3705 }
3706
3707 // when tab isn't visible exit loop
3708 if (isTabVisible() === !1) {
3709 done = transitionsToWait.length;
3710 break;
3711 }
3712 try {
3713 t.transition();
3714 } catch (e) {
3715 done++;
3716 }
3717 }
3718 return done === transitionsToWait.length;
3719 }
3720 runUntil(function () {
3721 _newArrowCheck(this, _this5);
3722 callback == null ? void 0 : callback();
3723 }.bind(this), loop);
3724 }; // 'f' is called as selection.call(f, ...);
3725 f.add = function (t) {
3726 isArray(t) ? transitionsToWait = transitionsToWait.concat(t) : transitionsToWait.push(t);
3727 };
3728 return f;
3729}
3730;// CONCATENATED MODULE: ./src/module/worker.ts
3731/**
3732 * Copyright (c) 2017 ~ present NAVER Corp.
3733 * billboard.js project is licensed under the MIT license
3734 */
3735
3736
3737// Store blob in memory
3738var blob = {};
3739
3740/**
3741 * Get Object URL
3742 * @param {Function} fn Function to be executed in worker
3743 * @param {Array} depsFn Dependency functions to run given function(fn).
3744 * @returns {string}
3745 * @private
3746 */
3747function getObjectURL(fn, depsFn) {
3748 var fnString = fn.toString(),
3749 key = fnString.replace(/(function|[\s\W\n])/g, "").substring(0, 15);
3750 if (!(key in blob)) {
3751 var _depsFn$map$join;
3752 // Web Worker body
3753 blob[key] = new win.Blob([((_depsFn$map$join = depsFn == null ? void 0 : depsFn.map(String).join(";")) != null ? _depsFn$map$join : "") + "\n\n\t\t\tself.onmessage=function({data}) {\n\t\t\t\tconst result = (" + fnString + ").apply(null, data);\n\t\t\t\tself.postMessage(result);\n\t\t\t};"], {
3754 type: "text/javascript"
3755 });
3756 }
3757 return win.URL.createObjectURL(blob[key]);
3758}
3759
3760/**
3761 * Create and run on Web Worker
3762 * @param {boolean} useWorker Use Web Worker
3763 * @param {Function} fn Function to be executed in worker
3764 * @param {Function} callback Callback function to receive result from worker
3765 * @param {Array} depsFn Dependency functions to run given function(fn).
3766 * @returns {object}
3767 * @example
3768 * const worker = runWorker(function(arg) {
3769 * // do some tasks...
3770 * console.log("param:", A(arg));
3771 *
3772 * return 1234;
3773 * }, function(data) {
3774 * // callback after worker is done
3775 * console.log("result:", data);
3776 * },
3777 * [function A(){}]
3778 * );
3779 *
3780 * worker(11111);
3781 * @private
3782 */
3783function runWorker(useWorker, fn, callback, depsFn) {
3784 if (useWorker === void 0) {
3785 useWorker = !0;
3786 }
3787 var runFn;
3788 if (win.Worker && useWorker) {
3789 var src = getObjectURL(fn, depsFn),
3790 worker = new win.Worker(src);
3791 runFn = function () {
3792 for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
3793 args[_key] = arguments[_key];
3794 }
3795 // trigger worker
3796 worker.postMessage(args);
3797
3798 // listen worker
3799 worker.onmessage = function (e) {
3800 // release object URL from memory
3801 win.URL.revokeObjectURL(src);
3802 return callback(e.data);
3803 };
3804
3805 // handle error
3806 worker.onerror = function (e) {
3807 console.error(e);
3808 };
3809
3810 // return new Promise((resolve, reject) => {
3811 // worker.onmessage = ({data}) => resolve(data);
3812 // worker.onerror = reject;
3813 // });
3814 };
3815 } else {
3816 runFn = function () {
3817 var res = fn.apply(void 0, arguments);
3818 callback(res);
3819 };
3820 }
3821 return runFn;
3822}
3823// EXTERNAL MODULE: external {"commonjs":"d3-dsv","commonjs2":"d3-dsv","amd":"d3-dsv","root":"d3"}
3824var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_require__(5);
3825;// CONCATENATED MODULE: ./src/ChartInternal/data/convert.helper.ts
3826
3827/**
3828 * Copyright (c) 2017 ~ present NAVER Corp.
3829 * billboard.js project is licensed under the MIT license
3830 */
3831
3832/* eslint-disable */
3833
3834
3835
3836/***** Functions to be executed on Web Worker *****
3837 * NOTE: Don't allowed to use
3838 * - arrow function syntax
3839 * - Utils functions
3840 */
3841/**
3842 * Convert Columns data
3843 * @param {object} columns
3844 * @returns {Array}
3845 * @private
3846 */
3847function columns(columns) {
3848 var newRows = [];
3849 columns.forEach(function (col, i) {
3850 var key = col[0];
3851 col.forEach(function (v, j) {
3852 if (j > 0) {
3853 if (typeof newRows[j - 1] === "undefined") {
3854 newRows[j - 1] = {};
3855 }
3856 if (typeof v === "undefined") {
3857 throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
3858 }
3859 newRows[j - 1][key] = v;
3860 }
3861 });
3862 });
3863 return newRows;
3864}
3865
3866/**
3867 * Convert Rows data
3868 * @param {object} columns
3869 * @returns {Array}
3870 * @private
3871 */
3872function rows(rows) {
3873 var keys = rows[0],
3874 newRows = [];
3875 rows.forEach(function (row, i) {
3876 if (i > 0) {
3877 var newRow = {};
3878 row.forEach(function (v, j) {
3879 if (typeof v === "undefined") {
3880 throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
3881 }
3882 newRow[keys[j]] = v;
3883 });
3884 newRows.push(newRow);
3885 }
3886 });
3887 return newRows;
3888}
3889
3890/**
3891 * Convert JSON data
3892 * @param {object} columns
3893 * @returns {Array}
3894 * @private
3895 */
3896function json(json, keysParam) {
3897 var newRows = [],
3898 findValueInJson = function (object, path) {
3899 if (object[path] !== undefined) {
3900 return object[path];
3901 }
3902 var convertedPath = path.replace(/\[(\w+)\]/g, ".$1"),
3903 pathArray = convertedPath.replace(/^\./, "").split("."),
3904 target = object; // convert indexes to properties (replace [] with .)
3905 pathArray.some(function (k) {
3906 return !(target = target && k in target ? target[k] : undefined);
3907 });
3908 return target;
3909 },
3910 targetKeys,
3911 data;
3912 if (Array.isArray(json)) {
3913 if (keysParam.x) {
3914 targetKeys = keysParam.value.concat(keysParam.x);
3915 } else {
3916 targetKeys = keysParam.value;
3917 }
3918 newRows.push(targetKeys);
3919 json.forEach(function (o) {
3920 var newRow = targetKeys.map(function (key) {
3921 // convert undefined to null because undefined data will be removed in convertDataToTargets()
3922 var v = findValueInJson(o, key);
3923 if (typeof v === "undefined") {
3924 v = null;
3925 }
3926 return v;
3927 });
3928 newRows.push(newRow);
3929 });
3930 data = rows(newRows);
3931 } else {
3932 Object.keys(json).forEach(function (key) {
3933 var tmp = json[key].concat();
3934 tmp.unshift(key);
3935 newRows.push(tmp);
3936 });
3937 data = columns(newRows);
3938 }
3939 return data;
3940}
3941
3942/***** Functions can't be executed on Web Worker *****/
3943/**
3944 * Convert URL data
3945 * @param {string} url Remote URL
3946 * @param {string} mimeType MIME type string: json | csv | tsv
3947 * @param {object} headers Header object
3948 * @param {object} keys Key object
3949 * @param {Function} done Callback function
3950 * @private
3951 */
3952function url(url, mimeType, headers, keys, done) {
3953 if (mimeType === void 0) {
3954 mimeType = "csv";
3955 }
3956 var req = new XMLHttpRequest(),
3957 converter = {
3958 csv: csv,
3959 tsv: tsv,
3960 json: json
3961 };
3962 req.open("GET", url);
3963 if (headers) {
3964 Object.keys(headers).forEach(function (key) {
3965 req.setRequestHeader(key, headers[key]);
3966 });
3967 }
3968 req.onreadystatechange = function () {
3969 if (req.readyState === 4) {
3970 if (req.status === 200) {
3971 var response = req.responseText;
3972 response && done.call(this, converter[mimeType](mimeType === "json" ? JSON.parse(response) : response, keys));
3973 } else {
3974 throw new Error(url + ": Something went wrong loading!");
3975 }
3976 }
3977 };
3978 req.send();
3979}
3980
3981/**
3982 * Convert CSV/TSV data
3983 * @param {object} parser Parser object
3984 * @param {object} xsv Data
3985 * @returns {object}
3986 * @private
3987 */
3988function convertCsvTsvToData(parser, xsv) {
3989 var _this = this,
3990 rows = parser.rows(xsv),
3991 d;
3992 if (rows.length === 1) {
3993 d = [{}];
3994 rows[0].forEach(function (id) {
3995 _newArrowCheck(this, _this);
3996 d[0][id] = null;
3997 }.bind(this));
3998 } else {
3999 d = parser.parse(xsv);
4000 }
4001 return d;
4002}
4003function csv(xsv) {
4004 return convertCsvTsvToData({
4005 rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParseRows,
4006 parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParse
4007 }, xsv);
4008}
4009function tsv(tsv) {
4010 return convertCsvTsvToData({
4011 rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParseRows,
4012 parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParse
4013 }, tsv);
4014}
4015;// CONCATENATED MODULE: ./src/ChartInternal/data/convert.ts
4016
4017/**
4018 * Copyright (c) 2017 ~ present NAVER Corp.
4019 * billboard.js project is licensed under the MIT license
4020 */
4021
4022
4023
4024/**
4025 * Get data key for JSON
4026 * @param {string|object} keysParam Key params
4027 * @param {object} config Config object
4028 * @returns {string} Data key
4029 * @private
4030 */
4031function getDataKeyForJson(keysParam, config) {
4032 var keys = keysParam || (config == null ? void 0 : config.data_keys);
4033 if (keys != null && keys.x) {
4034 config.data_x = keys.x;
4035 }
4036 return keys;
4037}
4038
4039/**
4040 * Data convert
4041 * @memberof ChartInternal
4042 * @private
4043 */
4044/* harmony default export */ var convert = ({
4045 /**
4046 * Convert data according its type
4047 * @param {object} args data object
4048 * @param {Function} [callback] callback for url(XHR) type loading
4049 * @private
4050 */
4051 convertData: function convertData(args, callback) {
4052 var _this = this,
4053 config = this.config,
4054 useWorker = config.boost_useWorker,
4055 data = args;
4056 if (args.bindto) {
4057 data = {};
4058 ["url", "mimeType", "headers", "keys", "json", "keys", "rows", "columns"].forEach(function (v) {
4059 _newArrowCheck(this, _this);
4060 var key = "data_" + v;
4061 if (key in args) {
4062 data[v] = args[key];
4063 }
4064 }.bind(this));
4065 }
4066 if (data.url && callback) {
4067 url(data.url, data.mimeType, data.headers, getDataKeyForJson(data.keys, config), callback);
4068 } else if (data.json) {
4069 runWorker(useWorker, json, callback, [columns, rows])(data.json, getDataKeyForJson(data.keys, config));
4070 } else if (data.rows) {
4071 runWorker(useWorker, rows, callback)(data.rows);
4072 } else if (data.columns) {
4073 runWorker(useWorker, columns, callback)(data.columns);
4074 } else if (args.bindto) {
4075 throw Error("url or json or rows or columns is required.");
4076 }
4077 },
4078 convertDataToTargets: function convertDataToTargets(data, appendXs) {
4079 var _this2 = this,
4080 $$ = this,
4081 axis = $$.axis,
4082 config = $$.config,
4083 state = $$.state,
4084 isCategorized = !1,
4085 isTimeSeries = !1,
4086 isCustomX = !1;
4087 if (axis) {
4088 isCategorized = axis.isCategorized();
4089 isTimeSeries = axis.isTimeSeries();
4090 isCustomX = axis.isCustomX();
4091 }
4092 var dataKeys = Object.keys(data[0] || {}),
4093 ids = dataKeys.length ? dataKeys.filter($$.isNotX, $$) : [],
4094 xs = dataKeys.length ? dataKeys.filter($$.isX, $$) : [],
4095 xsData;
4096 // save x for update data by load when custom x and bb.x API
4097 ids.forEach(function (id) {
4098 var _this3 = this;
4099 _newArrowCheck(this, _this2);
4100 var xKey = this.getXKey(id);
4101 if (isCustomX || isTimeSeries) {
4102 // if included in input data
4103 if (xs.indexOf(xKey) >= 0) {
4104 xsData = (appendXs && $$.data.xs[id] || []).concat(data.map(function (d) {
4105 _newArrowCheck(this, _this3);
4106 return d[xKey];
4107 }.bind(this)).filter(isValue).map(function (rawX, i) {
4108 _newArrowCheck(this, _this3);
4109 return $$.generateTargetX(rawX, id, i);
4110 }.bind(this)));
4111 } else if (config.data_x) {
4112 // if not included in input data, find from preloaded data of other id's x
4113 xsData = this.getOtherTargetXs();
4114 } else if (notEmpty(config.data_xs)) {
4115 // if not included in input data, find from preloaded data
4116 xsData = $$.getXValuesOfXKey(xKey, $$.data.targets);
4117 }
4118 // MEMO: if no x included, use same x of current will be used
4119 } else {
4120 xsData = data.map(function (d, i) {
4121 _newArrowCheck(this, _this3);
4122 return i;
4123 }.bind(this));
4124 }
4125 xsData && (this.data.xs[id] = xsData);
4126 }.bind(this));
4127
4128 // check x is defined
4129 ids.forEach(function (id) {
4130 _newArrowCheck(this, _this2);
4131 if (!this.data.xs[id]) {
4132 throw new Error("x is not defined for id = \"" + id + "\".");
4133 }
4134 }.bind(this));
4135
4136 // convert to target
4137 var targets = ids.map(function (id, index) {
4138 var _this4 = this;
4139 _newArrowCheck(this, _this2);
4140 var convertedId = config.data_idConverter.bind($$.api)(id),
4141 xKey = $$.getXKey(id),
4142 isCategory = isCustomX && isCategorized,
4143 hasCategory = isCategory && data.map(function (v) {
4144 _newArrowCheck(this, _this4);
4145 return v.x;
4146 }.bind(this)).every(function (v) {
4147 _newArrowCheck(this, _this4);
4148 return config.axis_x_categories.indexOf(v) > -1;
4149 }.bind(this)),
4150 isDataAppend = data.__append__,
4151 xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0;
4152 return {
4153 id: convertedId,
4154 id_org: id,
4155 values: data.map(function (d, i) {
4156 _newArrowCheck(this, _this4);
4157 var rawX = d[xKey],
4158 value = d[id],
4159 x;
4160 value = value !== null && !isNaN(value) && !isObject(value) ? +value : isArray(value) || isObject(value) ? value : null;
4161
4162 // use x as categories if custom x and categorized
4163 if ((isCategory || state.hasRadar) && index === 0 && !isUndefined(rawX)) {
4164 if (!hasCategory && index === 0 && i === 0 && !isDataAppend) {
4165 config.axis_x_categories = [];
4166 }
4167 x = config.axis_x_categories.indexOf(rawX);
4168 if (x === -1) {
4169 x = config.axis_x_categories.length;
4170 config.axis_x_categories.push(rawX);
4171 }
4172 } else {
4173 x = $$.generateTargetX(rawX, id, xIndex + i);
4174 }
4175
4176 // mark as x = undefined if value is undefined and filter to remove after mapped
4177 if (isUndefined(value) || $$.data.xs[id].length <= i) {
4178 x = undefined;
4179 }
4180 return {
4181 x: x,
4182 value: value,
4183 id: convertedId,
4184 index: -1
4185 };
4186 }.bind(this)).filter(function (v) {
4187 _newArrowCheck(this, _this4);
4188 return isDefined(v.x);
4189 }.bind(this))
4190 };
4191 }.bind(this));
4192
4193 // finish targets
4194 targets.forEach(function (t) {
4195 var _this5 = this,
4196 _$$$data$xs$t$id;
4197 _newArrowCheck(this, _this2);
4198 // sort values by its x
4199 if (config.data_xSort) {
4200 t.values = t.values.sort(function (v1, v2) {
4201 _newArrowCheck(this, _this5);
4202 var x1 = v1.x || v1.x === 0 ? v1.x : Infinity,
4203 x2 = v2.x || v2.x === 0 ? v2.x : Infinity;
4204 return x1 - x2;
4205 }.bind(this));
4206 }
4207
4208 // indexing each value
4209 t.values.forEach(function (v, i) {
4210 _newArrowCheck(this, _this5);
4211 return v.index = i;
4212 }.bind(this));
4213
4214 // this needs to be sorted because its index and value.index is identical
4215 (_$$$data$xs$t$id = $$.data.xs[t.id]) == null ? void 0 : _$$$data$xs$t$id.sort(function (v1, v2) {
4216 _newArrowCheck(this, _this5);
4217 return v1 - v2;
4218 }.bind(this));
4219 }.bind(this));
4220
4221 // cache information about values
4222 state.hasNegativeValue = $$.hasNegativeValueInTargets(targets);
4223 state.hasPositiveValue = $$.hasPositiveValueInTargets(targets);
4224
4225 // set target types
4226 if (config.data_type) {
4227 $$.setTargetType($$.mapToIds(targets).filter(function (id) {
4228 _newArrowCheck(this, _this2);
4229 return !(id in config.data_types);
4230 }.bind(this)), config.data_type);
4231 }
4232
4233 // cache as original id keyed
4234 targets.forEach(function (d) {
4235 _newArrowCheck(this, _this2);
4236 return $$.cache.add(d.id_org, d, !0);
4237 }.bind(this));
4238 return targets;
4239 }
4240});
4241;// CONCATENATED MODULE: ./src/ChartInternal/data/data.ts
4242
4243/**
4244 * Copyright (c) 2017 ~ present NAVER Corp.
4245 * billboard.js project is licensed under the MIT license
4246 */
4247
4248
4249
4250/* harmony default export */ var data_data = ({
4251 isX: function isX(key) {
4252 var $$ = this,
4253 config = $$.config,
4254 dataKey = config.data_x && key === config.data_x,
4255 existValue = notEmpty(config.data_xs) && hasValue(config.data_xs, key);
4256 return dataKey || existValue;
4257 },
4258 isNotX: function isNotX(key) {
4259 return !this.isX(key);
4260 },
4261 isStackNormalized: function isStackNormalized() {
4262 var config = this.config;
4263 return !!(config.data_stack_normalize && config.data_groups.length);
4264 },
4265 isGrouped: function isGrouped(id) {
4266 var _this = this,
4267 groups = this.config.data_groups;
4268 return id ? groups.some(function (v) {
4269 _newArrowCheck(this, _this);
4270 return v.indexOf(id) >= 0 && v.length > 1;
4271 }.bind(this)) : groups.length > 0;
4272 },
4273 getXKey: function getXKey(id) {
4274 var $$ = this,
4275 config = $$.config;
4276 return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null;
4277 },
4278 getXValuesOfXKey: function getXValuesOfXKey(key, targets) {
4279 var _this2 = this,
4280 $$ = this,
4281 ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : [],
4282 xValues;
4283 ids.forEach(function (id) {
4284 _newArrowCheck(this, _this2);
4285 if ($$.getXKey(id) === key) {
4286 xValues = $$.data.xs[id];
4287 }
4288 }.bind(this));
4289 return xValues;
4290 },
4291 /**
4292 * Get index number based on given x Axis value
4293 * @param {Date|number|string} x x Axis to be compared
4294 * @param {Array} basedX x Axis list to be based on
4295 * @returns {number} index number
4296 * @private
4297 */
4298 getIndexByX: function getIndexByX(x, basedX) {
4299 var $$ = this;
4300 return basedX ? basedX.indexOf(isString(x) ? x : +x) : ($$.filterByX($$.data.targets, x)[0] || {
4301 index: null
4302 }).index;
4303 },
4304 getXValue: function getXValue(id, i) {
4305 var $$ = this;
4306 return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i;
4307 },
4308 getOtherTargetXs: function getOtherTargetXs() {
4309 var $$ = this,
4310 idsForX = Object.keys($$.data.xs);
4311 return idsForX.length ? $$.data.xs[idsForX[0]] : null;
4312 },
4313 getOtherTargetX: function getOtherTargetX(index) {
4314 var xs = this.getOtherTargetXs();
4315 return xs && index < xs.length ? xs[index] : null;
4316 },
4317 addXs: function addXs(xs) {
4318 var _this3 = this,
4319 $$ = this,
4320 config = $$.config;
4321 Object.keys(xs).forEach(function (id) {
4322 _newArrowCheck(this, _this3);
4323 config.data_xs[id] = xs[id];
4324 }.bind(this));
4325 },
4326 isMultipleX: function isMultipleX() {
4327 return notEmpty(this.config.data_xs) || !this.config.data_xSort || this.hasType("bubble") || this.hasType("scatter");
4328 },
4329 addName: function addName(data) {
4330 var $$ = this,
4331 config = $$.config,
4332 name;
4333 if (data) {
4334 name = config.data_names[data.id];
4335 data.name = name !== undefined ? name : data.id;
4336 }
4337 return data;
4338 },
4339 /**
4340 * Get all values on given index
4341 * @param {number} index Index
4342 * @param {boolean} filterNull Filter nullish value
4343 * @returns {Array}
4344 * @private
4345 */
4346 getAllValuesOnIndex: function getAllValuesOnIndex(index, filterNull) {
4347 var _this4 = this;
4348 if (filterNull === void 0) {
4349 filterNull = !1;
4350 }
4351 var $$ = this,
4352 value = $$.filterTargetsToShow($$.data.targets).map(function (t) {
4353 _newArrowCheck(this, _this4);
4354 return $$.addName($$.getValueOnIndex(t.values, index));
4355 }.bind(this));
4356 if (filterNull) {
4357 value = value.filter(function (v) {
4358 _newArrowCheck(this, _this4);
4359 return v && "value" in v && isValue(v.value);
4360 }.bind(this));
4361 }
4362 return value;
4363 },
4364 getValueOnIndex: function getValueOnIndex(values, index) {
4365 var _this5 = this,
4366 valueOnIndex = values.filter(function (v) {
4367 _newArrowCheck(this, _this5);
4368 return v.index === index;
4369 }.bind(this));
4370 return valueOnIndex.length ? valueOnIndex[0] : null;
4371 },
4372 updateTargetX: function updateTargetX(targets, x) {
4373 var _this6 = this,
4374 $$ = this;
4375 targets.forEach(function (t) {
4376 var _this7 = this;
4377 _newArrowCheck(this, _this6);
4378 t.values.forEach(function (v, i) {
4379 _newArrowCheck(this, _this7);
4380 v.x = $$.generateTargetX(x[i], t.id, i);
4381 }.bind(this));
4382 $$.data.xs[t.id] = x;
4383 }.bind(this));
4384 },
4385 updateTargetXs: function updateTargetXs(targets, xs) {
4386 var _this8 = this,
4387 $$ = this;
4388 targets.forEach(function (t) {
4389 _newArrowCheck(this, _this8);
4390 xs[t.id] && $$.updateTargetX([t], xs[t.id]);
4391 }.bind(this));
4392 },
4393 generateTargetX: function generateTargetX(rawX, id, index) {
4394 var $$ = this,
4395 axis = $$.axis,
4396 x = axis != null && axis.isCategorized() ? index : rawX || index;
4397 if (axis != null && axis.isTimeSeries()) {
4398 var fn = parseDate.bind($$);
4399 x = rawX ? fn(rawX) : fn($$.getXValue(id, index));
4400 } else if (axis != null && axis.isCustomX() && !(axis != null && axis.isCategorized())) {
4401 x = isValue(rawX) ? +rawX : $$.getXValue(id, index);
4402 }
4403 return x;
4404 },
4405 updateXs: function updateXs(values) {
4406 var _this9 = this;
4407 if (values.length) {
4408 this.axis.xs = values.map(function (v) {
4409 _newArrowCheck(this, _this9);
4410 return v.x;
4411 }.bind(this));
4412 }
4413 },
4414 getPrevX: function getPrevX(i) {
4415 var x = this.axis.xs[i - 1];
4416 return isDefined(x) ? x : null;
4417 },
4418 getNextX: function getNextX(i) {
4419 var x = this.axis.xs[i + 1];
4420 return isDefined(x) ? x : null;
4421 },
4422 /**
4423 * Get base value isAreaRangeType
4424 * @param {object} data Data object
4425 * @returns {number}
4426 * @private
4427 */
4428 getBaseValue: function getBaseValue(data) {
4429 var $$ = this,
4430 hasAxis = $$.state.hasAxis,
4431 value = data.value;
4432 // In case of area-range, data is given as: [low, mid, high] or {low, mid, high}
4433 // will take the 'mid' as the base value
4434 if (value && hasAxis) {
4435 if ($$.isAreaRangeType(data)) {
4436 value = $$.getRangedData(data, "mid");
4437 } else if ($$.isBubbleZType(data)) {
4438 value = $$.getBubbleZData(value, "y");
4439 }
4440 }
4441 return value;
4442 },
4443 /**
4444 * Get min/max value from the data
4445 * @private
4446 * @param {Array} data array data to be evaluated
4447 * @returns {{min: {number}, max: {number}}}
4448 */
4449 getMinMaxValue: function getMinMaxValue(data) {
4450 var _this10 = this,
4451 getBaseValue = this.getBaseValue.bind(this),
4452 min,
4453 max;
4454 (data || this.data.targets.map(function (t) {
4455 _newArrowCheck(this, _this10);
4456 return t.values;
4457 }.bind(this))).forEach(function (v, i) {
4458 _newArrowCheck(this, _this10);
4459 var value = v.map(getBaseValue).filter(isNumber);
4460 min = Math.min.apply(Math, [i ? min : Infinity].concat(value));
4461 max = Math.max.apply(Math, [i ? max : -Infinity].concat(value));
4462 }.bind(this));
4463 return {
4464 min: min,
4465 max: max
4466 };
4467 },
4468 /**
4469 * Get the min/max data
4470 * @private
4471 * @returns {{min: Array, max: Array}}
4472 */
4473 getMinMaxData: function getMinMaxData() {
4474 var _this11 = this,
4475 $$ = this,
4476 cacheKey = KEY.dataMinMax,
4477 minMaxData = $$.cache.get(cacheKey);
4478 if (!minMaxData) {
4479 var data = $$.data.targets.map(function (t) {
4480 _newArrowCheck(this, _this11);
4481 return t.values;
4482 }.bind(this)),
4483 minMax = $$.getMinMaxValue(data),
4484 _min = [],
4485 _max = [];
4486 data.forEach(function (v) {
4487 _newArrowCheck(this, _this11);
4488 var minData = $$.getFilteredDataByValue(v, minMax.min),
4489 maxData = $$.getFilteredDataByValue(v, minMax.max);
4490 if (minData.length) {
4491 _min = _min.concat(minData);
4492 }
4493 if (maxData.length) {
4494 _max = _max.concat(maxData);
4495 }
4496 }.bind(this));
4497
4498 // update the cached data
4499 $$.cache.add(cacheKey, minMaxData = {
4500 min: _min,
4501 max: _max
4502 });
4503 }
4504 return minMaxData;
4505 },
4506 /**
4507 * Get sum of data per index
4508 * @private
4509 * @returns {Array}
4510 */
4511 getTotalPerIndex: function getTotalPerIndex() {
4512 var _this12 = this,
4513 $$ = this,
4514 cacheKey = KEY.dataTotalPerIndex,
4515 sum = $$.cache.get(cacheKey);
4516 if ($$.isStackNormalized() && !sum) {
4517 sum = [];
4518 $$.data.targets.forEach(function (row) {
4519 var _this13 = this;
4520 _newArrowCheck(this, _this12);
4521 row.values.forEach(function (v, i) {
4522 _newArrowCheck(this, _this13);
4523 if (!sum[i]) {
4524 sum[i] = 0;
4525 }
4526 sum[i] += isNumber(v.value) ? v.value : 0;
4527 }.bind(this));
4528 }.bind(this));
4529 }
4530 return sum;
4531 },
4532 /**
4533 * Get total data sum
4534 * @param {boolean} subtractHidden Subtract hidden data from total
4535 * @returns {number}
4536 * @private
4537 */
4538 getTotalDataSum: function getTotalDataSum(subtractHidden) {
4539 var _this14 = this,
4540 $$ = this,
4541 cacheKey = KEY.dataTotalSum,
4542 total = $$.cache.get(cacheKey);
4543 if (!isNumber(total)) {
4544 var _sum = mergeArray($$.data.targets.map(function (t) {
4545 _newArrowCheck(this, _this14);
4546 return t.values;
4547 }.bind(this))).map(function (v) {
4548 _newArrowCheck(this, _this14);
4549 return v.value;
4550 }.bind(this)).reduce(function (p, c) {
4551 _newArrowCheck(this, _this14);
4552 return p + c;
4553 }.bind(this));
4554 $$.cache.add(cacheKey, total = _sum);
4555 }
4556 if (subtractHidden) {
4557 total -= $$.getHiddenTotalDataSum();
4558 }
4559 return total;
4560 },
4561 /**
4562 * Get total hidden data sum
4563 * @returns {number}
4564 * @private
4565 */
4566 getHiddenTotalDataSum: function getHiddenTotalDataSum() {
4567 var _this15 = this,
4568 $$ = this,
4569 api = $$.api,
4570 hiddenTargetIds = $$.state.hiddenTargetIds,
4571 total = 0;
4572 if (hiddenTargetIds.length) {
4573 total = api.data.values.bind(api)(hiddenTargetIds).reduce(function (p, c) {
4574 _newArrowCheck(this, _this15);
4575 return p + c;
4576 }.bind(this));
4577 }
4578 return total;
4579 },
4580 /**
4581 * Get filtered data by value
4582 * @param {object} data Data
4583 * @param {number} value Value to be filtered
4584 * @returns {Array} filtered array data
4585 * @private
4586 */
4587 getFilteredDataByValue: function getFilteredDataByValue(data, value) {
4588 var _this16 = this;
4589 return data.filter(function (t) {
4590 _newArrowCheck(this, _this16);
4591 return this.getBaseValue(t) === value;
4592 }.bind(this));
4593 },
4594 /**
4595 * Return the max length of the data
4596 * @returns {number} max data length
4597 * @private
4598 */
4599 getMaxDataCount: function getMaxDataCount() {
4600 var _this17 = this;
4601 return Math.max.apply(Math, this.data.targets.map(function (t) {
4602 _newArrowCheck(this, _this17);
4603 return t.values.length;
4604 }.bind(this)));
4605 },
4606 getMaxDataCountTarget: function getMaxDataCountTarget() {
4607 var _this18 = this,
4608 target = this.filterTargetsToShow() || [],
4609 length = target.length;
4610 if (length > 1) {
4611 target = target.map(function (t) {
4612 _newArrowCheck(this, _this18);
4613 return t.values;
4614 }.bind(this)).reduce(function (a, b) {
4615 _newArrowCheck(this, _this18);
4616 return a.concat(b);
4617 }.bind(this)).map(function (v) {
4618 _newArrowCheck(this, _this18);
4619 return v.x;
4620 }.bind(this));
4621 target = sortValue(getUnique(target)).map(function (x, index) {
4622 _newArrowCheck(this, _this18);
4623 return {
4624 x: x,
4625 index: index
4626 };
4627 }.bind(this));
4628 } else if (length) {
4629 target = target[0].values;
4630 }
4631 return target;
4632 },
4633 mapToIds: function mapToIds(targets) {
4634 var _this19 = this;
4635 return targets.map(function (d) {
4636 _newArrowCheck(this, _this19);
4637 return d.id;
4638 }.bind(this));
4639 },
4640 mapToTargetIds: function mapToTargetIds(ids) {
4641 var $$ = this;
4642 return ids ? isArray(ids) ? ids.concat() : [ids] : $$.mapToIds($$.data.targets);
4643 },
4644 hasTarget: function hasTarget(targets, id) {
4645 var ids = this.mapToIds(targets);
4646 for (var i = 0, val; val = ids[i]; i++) {
4647 if (val === id) {
4648 return !0;
4649 }
4650 }
4651 return !1;
4652 },
4653 isTargetToShow: function isTargetToShow(targetId) {
4654 return this.state.hiddenTargetIds.indexOf(targetId) < 0;
4655 },
4656 isLegendToShow: function isLegendToShow(targetId) {
4657 return this.state.hiddenLegendIds.indexOf(targetId) < 0;
4658 },
4659 filterTargetsToShow: function filterTargetsToShow(targets) {
4660 var _this20 = this,
4661 $$ = this;
4662 return (targets || $$.data.targets).filter(function (t) {
4663 _newArrowCheck(this, _this20);
4664 return $$.isTargetToShow(t.id);
4665 }.bind(this));
4666 },
4667 mapTargetsToUniqueXs: function mapTargetsToUniqueXs(targets) {
4668 var _this21 = this,
4669 $$ = this,
4670 axis = $$.axis,
4671 xs = [];
4672 if (targets != null && targets.length) {
4673 xs = getUnique(mergeArray(targets.map(function (t) {
4674 var _this22 = this;
4675 _newArrowCheck(this, _this21);
4676 return t.values.map(function (v) {
4677 _newArrowCheck(this, _this22);
4678 return +v.x;
4679 }.bind(this));
4680 }.bind(this))));
4681 xs = axis != null && axis.isTimeSeries() ? xs.map(function (x) {
4682 _newArrowCheck(this, _this21);
4683 return new Date(+x);
4684 }.bind(this)) : xs.map(Number);
4685 }
4686 return sortValue(xs);
4687 },
4688 /**
4689 * Add to the state target Ids
4690 * @param {string} type State's prop name
4691 * @param {Array|string} targetIds Target ids array
4692 * @private
4693 */
4694 addTargetIds: function addTargetIds(type, targetIds) {
4695 var _this23 = this,
4696 state = this.state,
4697 ids = isArray(targetIds) ? targetIds : [targetIds];
4698 ids.forEach(function (v) {
4699 _newArrowCheck(this, _this23);
4700 state[type].indexOf(v) < 0 && state[type].push(v);
4701 }.bind(this));
4702 },
4703 /**
4704 * Remove from the state target Ids
4705 * @param {string} type State's prop name
4706 * @param {Array|string} targetIds Target ids array
4707 * @private
4708 */
4709 removeTargetIds: function removeTargetIds(type, targetIds) {
4710 var _this24 = this,
4711 state = this.state,
4712 ids = isArray(targetIds) ? targetIds : [targetIds];
4713 ids.forEach(function (v) {
4714 _newArrowCheck(this, _this24);
4715 var index = state[type].indexOf(v);
4716 index >= 0 && state[type].splice(index, 1);
4717 }.bind(this));
4718 },
4719 addHiddenTargetIds: function addHiddenTargetIds(targetIds) {
4720 this.addTargetIds("hiddenTargetIds", targetIds);
4721 },
4722 removeHiddenTargetIds: function removeHiddenTargetIds(targetIds) {
4723 this.removeTargetIds("hiddenTargetIds", targetIds);
4724 },
4725 addHiddenLegendIds: function addHiddenLegendIds(targetIds) {
4726 this.addTargetIds("hiddenLegendIds", targetIds);
4727 },
4728 removeHiddenLegendIds: function removeHiddenLegendIds(targetIds) {
4729 this.removeTargetIds("hiddenLegendIds", targetIds);
4730 },
4731 getValuesAsIdKeyed: function getValuesAsIdKeyed(targets) {
4732 var _this25 = this,
4733 $$ = this,
4734 hasAxis = $$.state.hasAxis,
4735 ys = {},
4736 isMultipleX = $$.isMultipleX(),
4737 xs = isMultipleX ? $$.mapTargetsToUniqueXs(targets).map(function (v) {
4738 _newArrowCheck(this, _this25);
4739 return isString(v) ? v : +v;
4740 }.bind(this)) : null;
4741 targets.forEach(function (t) {
4742 var _this26 = this;
4743 _newArrowCheck(this, _this25);
4744 var data = [];
4745 t.values.filter(function (_ref) {
4746 var value = _ref.value;
4747 _newArrowCheck(this, _this26);
4748 return isValue(value) || value === null;
4749 }.bind(this)).forEach(function (v) {
4750 _newArrowCheck(this, _this26);
4751 var value = v.value;
4752
4753 // exclude 'volume' value to correct mis domain calculation
4754 if (value !== null && $$.isCandlestickType(v)) {
4755 value = isArray(value) ? value.slice(0, 4) : [value.open, value.high, value.low, value.close];
4756 }
4757 if (isArray(value)) {
4758 data.push.apply(data, value);
4759 } else if (isObject(value) && "high" in value) {
4760 data.push.apply(data, Object.values(value));
4761 } else if ($$.isBubbleZType(v)) {
4762 data.push(hasAxis && $$.getBubbleZData(value, "y"));
4763 } else {
4764 if (isMultipleX) {
4765 data[$$.getIndexByX(v.x, xs)] = value;
4766 } else {
4767 data.push(value);
4768 }
4769 }
4770 }.bind(this));
4771 ys[t.id] = data;
4772 }.bind(this));
4773 return ys;
4774 },
4775 checkValueInTargets: function checkValueInTargets(targets, checker) {
4776 var ids = Object.keys(targets),
4777 values;
4778 for (var i = 0; i < ids.length; i++) {
4779 values = targets[ids[i]].values;
4780 for (var j = 0; j < values.length; j++) {
4781 if (checker(values[j].value)) {
4782 return !0;
4783 }
4784 }
4785 }
4786 return !1;
4787 },
4788 hasMultiTargets: function hasMultiTargets() {
4789 return this.filterTargetsToShow().length > 1;
4790 },
4791 hasNegativeValueInTargets: function hasNegativeValueInTargets(targets) {
4792 var _this27 = this;
4793 return this.checkValueInTargets(targets, function (v) {
4794 _newArrowCheck(this, _this27);
4795 return v < 0;
4796 }.bind(this));
4797 },
4798 hasPositiveValueInTargets: function hasPositiveValueInTargets(targets) {
4799 var _this28 = this;
4800 return this.checkValueInTargets(targets, function (v) {
4801 _newArrowCheck(this, _this28);
4802 return v > 0;
4803 }.bind(this));
4804 },
4805 /**
4806 * Sort targets data
4807 * Note: For stacked bar, will sort from the total sum of data series, not for each stacked bar
4808 * @param {Array} targetsValue Target value
4809 * @returns {Array}
4810 * @private
4811 */
4812 orderTargets: function orderTargets(targetsValue) {
4813 var $$ = this,
4814 targets = [].concat(targetsValue),
4815 fn = $$.getSortCompareFn();
4816 fn && targets.sort(fn);
4817 return targets;
4818 },
4819 /**
4820 * Get data.order compare function
4821 * @param {boolean} isArc Is for Arc type sort or not
4822 * @returns {Function} compare function
4823 * @private
4824 */
4825 getSortCompareFn: function getSortCompareFn(isArc) {
4826 var _this29 = this;
4827 if (isArc === void 0) {
4828 isArc = !1;
4829 }
4830 var $$ = this,
4831 config = $$.config,
4832 order = config.data_order,
4833 orderAsc = /asc/i.test(order),
4834 orderDesc = /desc/i.test(order),
4835 fn;
4836 if (orderAsc || orderDesc) {
4837 var reducer = function (p, c) {
4838 _newArrowCheck(this, _this29);
4839 return p + Math.abs(c.value);
4840 }.bind(this);
4841 fn = function (t1, t2) {
4842 _newArrowCheck(this, _this29);
4843 var t1Sum = "values" in t1 ? t1.values.reduce(reducer, 0) : t1.value,
4844 t2Sum = "values" in t2 ? t2.values.reduce(reducer, 0) : t2.value;
4845 return isArc ? orderAsc ? t1Sum - t2Sum : t2Sum - t1Sum : orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum;
4846 }.bind(this);
4847 } else if (isFunction(order)) {
4848 fn = order.bind($$.api);
4849 }
4850 return fn || null;
4851 },
4852 filterByX: function filterByX(targets, x) {
4853 var _this30 = this;
4854 return mergeArray(targets.map(function (t) {
4855 _newArrowCheck(this, _this30);
4856 return t.values;
4857 }.bind(this))).filter(function (v) {
4858 _newArrowCheck(this, _this30);
4859 return v.x - x === 0;
4860 }.bind(this));
4861 },
4862 filterRemoveNull: function filterRemoveNull(data) {
4863 var _this31 = this;
4864 return data.filter(function (d) {
4865 _newArrowCheck(this, _this31);
4866 return isValue(this.getBaseValue(d));
4867 }.bind(this));
4868 },
4869 filterByXDomain: function filterByXDomain(targets, xDomain) {
4870 var _this32 = this;
4871 return targets.map(function (t) {
4872 var _this33 = this;
4873 _newArrowCheck(this, _this32);
4874 return {
4875 id: t.id,
4876 id_org: t.id_org,
4877 values: t.values.filter(function (v) {
4878 _newArrowCheck(this, _this33);
4879 return xDomain[0] <= v.x && v.x <= xDomain[1];
4880 }.bind(this))
4881 };
4882 }.bind(this));
4883 },
4884 hasDataLabel: function hasDataLabel() {
4885 var dataLabels = this.config.data_labels;
4886 return isboolean(dataLabels) && dataLabels || isObjectType(dataLabels) && notEmpty(dataLabels);
4887 },
4888 /**
4889 * Get data index from the event coodinates
4890 * @param {Event} event Event object
4891 * @returns {number}
4892 */
4893 getDataIndexFromEvent: function getDataIndexFromEvent(event) {
4894 var $$ = this,
4895 config = $$.config,
4896 _$$$state = $$.state,
4897 inputType = _$$$state.inputType,
4898 _$$$state$eventReceiv = _$$$state.eventReceiver,
4899 coords = _$$$state$eventReceiv.coords,
4900 rect = _$$$state$eventReceiv.rect,
4901 isRotated = config.axis_rotated,
4902 e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event,
4903 index = findIndex(coords, isRotated ? e.clientY - rect.top : e.clientX - rect.left, 0, coords.length - 1, isRotated);
4904 return index;
4905 },
4906 getDataLabelLength: function getDataLabelLength(min, max, key) {
4907 var _this34 = this,
4908 $$ = this,
4909 lengths = [0, 0];
4910 $$.$el.chart.select("svg").selectAll(".dummy").data([min, max]).enter().append("text").text(function (d) {
4911 _newArrowCheck(this, _this34);
4912 return $$.dataLabelFormat(d.id)(d);
4913 }.bind(this)).each(function (d, i) {
4914 lengths[i] = this.getBoundingClientRect()[key] * 1.3;
4915 }).remove();
4916 return lengths;
4917 },
4918 isNoneArc: function isNoneArc(d) {
4919 return this.hasTarget(this.data.targets, d.id);
4920 },
4921 isArc: function isArc(d) {
4922 return "data" in d && this.hasTarget(this.data.targets, d.data.id);
4923 },
4924 findSameXOfValues: function findSameXOfValues(values, index) {
4925 var targetX = values[index].x,
4926 sames = [],
4927 i;
4928 for (i = index - 1; i >= 0; i--) {
4929 if (targetX !== values[i].x) {
4930 break;
4931 }
4932 sames.push(values[i]);
4933 }
4934 for (i = index; i < values.length; i++) {
4935 if (targetX !== values[i].x) {
4936 break;
4937 }
4938 sames.push(values[i]);
4939 }
4940 return sames;
4941 },
4942 findClosestFromTargets: function findClosestFromTargets(targets, pos) {
4943 var _this35 = this,
4944 $$ = this,
4945 candidates = targets.map(function (target) {
4946 _newArrowCheck(this, _this35);
4947 return $$.findClosest(target.values, pos);
4948 }.bind(this));
4949 // map to array of closest points of each target
4950
4951 // decide closest point and return
4952 return $$.findClosest(candidates, pos);
4953 },
4954 findClosest: function findClosest(values, pos) {
4955 var _this36 = this,
4956 $$ = this,
4957 config = $$.config,
4958 main = $$.$el.main,
4959 data = values.filter(function (v) {
4960 _newArrowCheck(this, _this36);
4961 return v && isValue(v.value);
4962 }.bind(this)),
4963 minDist = config.point_sensitivity,
4964 closest;
4965 // find mouseovering bar/candlestick
4966 // https://github.com/naver/billboard.js/issues/2434
4967 data.filter(function (v) {
4968 _newArrowCheck(this, _this36);
4969 return $$.isBarType(v.id) || $$.isCandlestickType(v.id);
4970 }.bind(this)).forEach(function (v) {
4971 _newArrowCheck(this, _this36);
4972 var selector = $$.isBarType(v.id) ? "." + $BAR.chartBar + "." + $COMMON.target + $$.getTargetSelectorSuffix(v.id) + " ." + $BAR.bar + "-" + v.index : "." + $CANDLESTICK.chartCandlestick + "." + $COMMON.target + $$.getTargetSelectorSuffix(v.id) + " ." + $CANDLESTICK.candlestick + "-" + v.index + " path";
4973 if (!closest && $$.isWithinBar(main.select(selector).node())) {
4974 closest = v;
4975 }
4976 }.bind(this));
4977
4978 // find closest point from non-bar/candlestick
4979 data.filter(function (v) {
4980 _newArrowCheck(this, _this36);
4981 return !$$.isBarType(v.id) && !$$.isCandlestickType(v.id);
4982 }.bind(this)).forEach(function (v) {
4983 _newArrowCheck(this, _this36);
4984 var d = $$.dist(v, pos);
4985 if (d < minDist) {
4986 minDist = d;
4987 closest = v;
4988 }
4989 }.bind(this));
4990 return closest;
4991 },
4992 dist: function dist(data, pos) {
4993 var $$ = this,
4994 isRotated = $$.config.axis_rotated,
4995 scale = $$.scale,
4996 xIndex = isRotated ? 1 : 0,
4997 yIndex = isRotated ? 0 : 1,
4998 y = $$.circleY(data, data.index),
4999 x = (scale.zoom || scale.x)(data.x);
5000 return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
5001 },
5002 /**
5003 * Convert data for step type
5004 * @param {Array} values Object data values
5005 * @returns {Array}
5006 * @private
5007 */
5008 convertValuesToStep: function convertValuesToStep(values) {
5009 var $$ = this,
5010 axis = $$.axis,
5011 config = $$.config,
5012 stepType = config.line_step_type,
5013 isCategorized = axis ? axis.isCategorized() : !1,
5014 converted = isArray(values) ? values.concat() : [values];
5015 if (!(isCategorized || /step\-(after|before)/.test(stepType))) {
5016 return values;
5017 }
5018
5019 // insert & append cloning first/last value to be fully rendered covering on each gap sides
5020 var head = converted[0],
5021 tail = converted[converted.length - 1],
5022 id = head.id,
5023 x = head.x;
5024 // insert head
5025 converted.unshift({
5026 x: --x,
5027 value: head.value,
5028 id: id
5029 });
5030 isCategorized && stepType === "step-after" && converted.unshift({
5031 x: --x,
5032 value: head.value,
5033 id: id
5034 });
5035
5036 // append tail
5037 x = tail.x;
5038 converted.push({
5039 x: ++x,
5040 value: tail.value,
5041 id: id
5042 });
5043 isCategorized && stepType === "step-before" && converted.push({
5044 x: ++x,
5045 value: tail.value,
5046 id: id
5047 });
5048 return converted;
5049 },
5050 convertValuesToRange: function convertValuesToRange(values) {
5051 var _this37 = this,
5052 converted = isArray(values) ? values.concat() : [values],
5053 ranges = [];
5054 converted.forEach(function (range) {
5055 _newArrowCheck(this, _this37);
5056 var x = range.x,
5057 id = range.id;
5058 ranges.push({
5059 x: x,
5060 id: id,
5061 value: range.value[0]
5062 });
5063 ranges.push({
5064 x: x,
5065 id: id,
5066 value: range.value[2]
5067 });
5068 }.bind(this));
5069 return ranges;
5070 },
5071 updateDataAttributes: function updateDataAttributes(name, attrs) {
5072 var _this38 = this,
5073 $$ = this,
5074 config = $$.config,
5075 current = config["data_" + name];
5076 if (isUndefined(attrs)) {
5077 return current;
5078 }
5079 Object.keys(attrs).forEach(function (id) {
5080 _newArrowCheck(this, _this38);
5081 current[id] = attrs[id];
5082 }.bind(this));
5083 $$.redraw({
5084 withLegend: !0
5085 });
5086 return current;
5087 },
5088 getRangedData: function getRangedData(d, key, type) {
5089 if (key === void 0) {
5090 key = "";
5091 }
5092 if (type === void 0) {
5093 type = "areaRange";
5094 }
5095 var value = d == null ? void 0 : d.value;
5096 if (isArray(value)) {
5097 // @ts-ignore
5098 var index = {
5099 areaRange: ["high", "mid", "low"],
5100 candlestick: ["open", "high", "low", "close", "volume"]
5101 }[type].indexOf(key);
5102 return index >= 0 && value ? value[index] : undefined;
5103 } else if (value) {
5104 return value[key];
5105 }
5106 return value;
5107 },
5108 /**
5109 * Get ratio value
5110 * @param {string} type Ratio for given type
5111 * @param {object} d Data value object
5112 * @param {boolean} asPercent Convert the return as percent or not
5113 * @returns {number} Ratio value
5114 * @private
5115 */
5116 getRatio: function getRatio(type, d, asPercent) {
5117 var _this39 = this;
5118 if (asPercent === void 0) {
5119 asPercent = !1;
5120 }
5121 var $$ = this,
5122 config = $$.config,
5123 state = $$.state,
5124 api = $$.api,
5125 ratio = 0;
5126 if (d && api.data.shown().length) {
5127 ratio = d.ratio || d.value;
5128 if (type === "arc") {
5129 // if has padAngle set, calculate rate based on value
5130 if ($$.pie.padAngle()()) {
5131 ratio = d.value / $$.getTotalDataSum(!0);
5132
5133 // otherwise, based on the rendered angle value
5134 } else {
5135 var gaugeArcLength = config.gauge_fullCircle ? $$.getArcLength() : $$.getStartAngle() * -2,
5136 arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
5137 ratio = (d.endAngle - d.startAngle) / arcLength;
5138 }
5139 } else if (type === "index") {
5140 var dataValues = api.data.values.bind(api),
5141 total = this.getTotalPerIndex();
5142 if (state.hiddenTargetIds.length) {
5143 var hiddenSum = dataValues(state.hiddenTargetIds, !1);
5144 if (hiddenSum.length) {
5145 hiddenSum = hiddenSum.reduce(function (acc, curr) {
5146 var _this40 = this;
5147 _newArrowCheck(this, _this39);
5148 return acc.map(function (v, i) {
5149 _newArrowCheck(this, _this40);
5150 return (isNumber(v) ? v : 0) + curr[i];
5151 }.bind(this));
5152 }.bind(this));
5153 total = total.map(function (v, i) {
5154 _newArrowCheck(this, _this39);
5155 return v - hiddenSum[i];
5156 }.bind(this));
5157 }
5158 }
5159 d.ratio = isNumber(d.value) && total && total[d.index] > 0 ? d.value / total[d.index] : 0;
5160 ratio = d.ratio;
5161 } else if (type === "radar") {
5162 ratio = parseFloat(Math.max(d.value, 0) + "") / state.current.dataMax * config.radar_size_ratio;
5163 } else if (type === "bar") {
5164 var yScale = $$.getYScaleById.bind($$)(d.id),
5165 _max2 = yScale.domain().reduce(function (a, c) {
5166 _newArrowCheck(this, _this39);
5167 return c - a;
5168 }.bind(this));
5169 // when all data are 0, return 0
5170 ratio = _max2 === 0 ? 0 : Math.abs(d.value) / _max2;
5171 }
5172 }
5173 return asPercent && ratio ? ratio * 100 : ratio;
5174 },
5175 /**
5176 * Sort data index to be aligned with x axis.
5177 * @param {Array} tickValues Tick array values
5178 * @private
5179 */
5180 updateDataIndexByX: function updateDataIndexByX(tickValues) {
5181 var _this41 = this,
5182 $$ = this,
5183 tickValueMap = tickValues.reduce(function (out, tick, index) {
5184 _newArrowCheck(this, _this41);
5185 out[+tick.x] = index;
5186 return out;
5187 }.bind(this), {});
5188 $$.data.targets.forEach(function (t) {
5189 var _this42 = this;
5190 _newArrowCheck(this, _this41);
5191 t.values.forEach(function (value, valueIndex) {
5192 _newArrowCheck(this, _this42);
5193 var index = tickValueMap[+value.x];
5194 if (index === undefined) {
5195 index = valueIndex;
5196 }
5197 value.index = index;
5198 }.bind(this));
5199 }.bind(this));
5200 },
5201 /**
5202 * Determine if bubble has dimension data
5203 * @param {object|Array} d data value
5204 * @returns {boolean}
5205 * @private
5206 */
5207 isBubbleZType: function isBubbleZType(d) {
5208 var $$ = this;
5209 return $$.isBubbleType(d) && (isObject(d.value) && ("z" in d.value || "y" in d.value) || isArray(d.value) && d.value.length === 2);
5210 },
5211 /**
5212 * Determine if bar has ranged data
5213 * @param {Array} d data value
5214 * @returns {boolean}
5215 * @private
5216 */
5217 isBarRangeType: function isBarRangeType(d) {
5218 var _this43 = this,
5219 $$ = this,
5220 value = d.value;
5221 return $$.isBarType(d) && isArray(value) && value.length === 2 && value.every(function (v) {
5222 _newArrowCheck(this, _this43);
5223 return isNumber(v);
5224 }.bind(this));
5225 },
5226 /**
5227 * Get data object by id
5228 * @param {string} id data id
5229 * @returns {object}
5230 * @private
5231 */
5232 getDataById: function getDataById(id) {
5233 var _d$,
5234 d = this.cache.get(id) || this.api.data(id);
5235 return (_d$ = d == null ? void 0 : d[0]) != null ? _d$ : d;
5236 }
5237});
5238;// CONCATENATED MODULE: ./src/ChartInternal/data/load.ts
5239
5240/**
5241 * Copyright (c) 2017 ~ present NAVER Corp.
5242 * billboard.js project is licensed under the MIT license
5243 */
5244
5245
5246/* harmony default export */ var load = ({
5247 load: function load(rawTargets, args) {
5248 var _this = this,
5249 _args$done,
5250 $$ = this,
5251 append = args.append,
5252 targets = rawTargets;
5253 if (targets) {
5254 // filter loading targets if needed
5255 if (args.filter) {
5256 targets = targets.filter(args.filter);
5257 }
5258
5259 // set type if args.types || args.type specified
5260 if (args.type || args.types) {
5261 targets.forEach(function (t) {
5262 var _args$types;
5263 _newArrowCheck(this, _this);
5264 var type = ((_args$types = args.types) == null ? void 0 : _args$types[t.id]) || args.type;
5265 $$.setTargetType(t.id, type);
5266 }.bind(this));
5267 }
5268
5269 // Update/Add data
5270 $$.data.targets.forEach(function (d) {
5271 _newArrowCheck(this, _this);
5272 for (var i = 0; i < targets.length; i++) {
5273 if (d.id === targets[i].id) {
5274 d.values = append ? d.values.concat(targets[i].values) : targets[i].values;
5275 targets.splice(i, 1);
5276 break;
5277 }
5278 }
5279 }.bind(this));
5280 $$.data.targets = $$.data.targets.concat(targets); // add remained
5281 }
5282
5283 // Set targets
5284 $$.updateTargets($$.data.targets);
5285
5286 // Redraw with new targets
5287 $$.redraw({
5288 withUpdateOrgXDomain: !0,
5289 withUpdateXDomain: !0,
5290 withLegend: !0
5291 });
5292
5293 // Update current state chart type and elements list after redraw
5294 $$.updateTypesElements();
5295 (_args$done = args.done) == null ? void 0 : _args$done.call($$.api);
5296 },
5297 loadFromArgs: function loadFromArgs(args) {
5298 var _this2 = this,
5299 $$ = this;
5300 // prevent load when chart is already destroyed
5301 if (!$$.config) {
5302 return;
5303 }
5304
5305 // reset internally cached data
5306 $$.cache.reset();
5307 $$.convertData(args, function (d) {
5308 _newArrowCheck(this, _this2);
5309 var data = args.data || d;
5310 args.append && (data.__append__ = !0);
5311 data && $$.load($$.convertDataToTargets(data), args);
5312 }.bind(this));
5313 },
5314 unload: function unload(rawTargetIds, customDoneCb) {
5315 var _this3 = this,
5316 $$ = this,
5317 state = $$.state,
5318 $el = $$.$el,
5319 $T = $$.$T,
5320 done = customDoneCb,
5321 targetIds = rawTargetIds;
5322 // reset internally cached data
5323 $$.cache.reset();
5324 if (!done) {
5325 done = function () {
5326 _newArrowCheck(this, _this3);
5327 }.bind(this);
5328 }
5329
5330 // filter existing target
5331 targetIds = targetIds.filter(function (id) {
5332 _newArrowCheck(this, _this3);
5333 return $$.hasTarget($$.data.targets, id);
5334 }.bind(this));
5335
5336 // If no target, call done and return
5337 if (!targetIds || targetIds.length === 0) {
5338 done();
5339 return;
5340 }
5341 var targets = $el.svg.selectAll(targetIds.map(function (id) {
5342 _newArrowCheck(this, _this3);
5343 return $$.selectorTarget(id);
5344 }.bind(this)));
5345 $T(targets).style("opacity", "0").remove().call(endall, done);
5346 targetIds.forEach(function (id) {
5347 var _this4 = this;
5348 _newArrowCheck(this, _this3);
5349 // Reset fadein for future load
5350 state.withoutFadeIn[id] = !1;
5351
5352 // Remove target's elements
5353 if ($el.legend) {
5354 $el.legend.selectAll("." + $LEGEND.legendItem + $$.getTargetSelectorSuffix(id)).remove();
5355 }
5356
5357 // Remove target
5358 $$.data.targets = $$.data.targets.filter(function (t) {
5359 _newArrowCheck(this, _this4);
5360 return t.id !== id;
5361 }.bind(this));
5362 }.bind(this));
5363
5364 // Update current state chart type and elements list after redraw
5365 $$.updateTypesElements();
5366 }
5367});
5368// EXTERNAL MODULE: external {"commonjs":"d3-drag","commonjs2":"d3-drag","amd":"d3-drag","root":"d3"}
5369var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack_require__(7);
5370;// CONCATENATED MODULE: ./src/ChartInternal/interactions/interaction.ts
5371
5372/**
5373 * Copyright (c) 2017 ~ present NAVER Corp.
5374 * billboard.js project is licensed under the MIT license
5375 */
5376
5377
5378
5379
5380
5381/* harmony default export */ var interactions_interaction = ({
5382 selectRectForSingle: function selectRectForSingle(context, eventRect, index) {
5383 var _this = this,
5384 $$ = this,
5385 config = $$.config,
5386 main = $$.$el.main,
5387 isSelectionEnabled = config.data_selection_enabled,
5388 isSelectionGrouped = config.data_selection_grouped,
5389 isSelectable = config.data_selection_isselectable,
5390 isTooltipGrouped = config.tooltip_grouped,
5391 selectedData = $$.getAllValuesOnIndex(index);
5392 if (isTooltipGrouped) {
5393 $$.showTooltip(selectedData, context);
5394 $$.showGridFocus == null ? void 0 : $$.showGridFocus(selectedData);
5395 if (!isSelectionEnabled || isSelectionGrouped) {
5396 return;
5397 }
5398 }
5399
5400 // remove possible previous focused state
5401 main.selectAll("." + $COMMON.EXPANDED + ":not(." + $SHAPE.shape + "-" + index + ")").classed($COMMON.EXPANDED, !1);
5402 var shapeAtIndex = main.selectAll("." + $SHAPE.shape + "-" + index).classed($COMMON.EXPANDED, !0).style("cursor", isSelectable ? "pointer" : null).filter(function (d) {
5403 return $$.isWithinShape(this, d);
5404 });
5405 if (shapeAtIndex.empty() && !isTooltipGrouped) {
5406 $$.hideGridFocus == null ? void 0 : $$.hideGridFocus();
5407 $$.hideTooltip();
5408 isSelectionGrouped || $$.setExpand(index);
5409 }
5410 shapeAtIndex.call(function (selected) {
5411 var _this2 = this;
5412 _newArrowCheck(this, _this);
5413 var d = selected.data();
5414 if (isSelectionEnabled && (isSelectionGrouped || isSelectable != null && isSelectable.bind($$.api)(d))) {
5415 eventRect.style("cursor", "pointer");
5416 }
5417 if (!isTooltipGrouped) {
5418 $$.showTooltip(d, context);
5419 $$.showGridFocus == null ? void 0 : $$.showGridFocus(d);
5420 $$.unexpandCircles == null ? void 0 : $$.unexpandCircles();
5421 selected.each(function (d) {
5422 _newArrowCheck(this, _this2);
5423 return $$.setExpand(index, d.id);
5424 }.bind(this));
5425 }
5426 }.bind(this));
5427 },
5428 /**
5429 * Expand data shape/point
5430 * @param {number} index Index number
5431 * @param {string} id Data id
5432 * @param {boolean} reset Reset expand state
5433 * @private
5434 */
5435 setExpand: function setExpand(index, id, reset) {
5436 var $$ = this,
5437 config = $$.config,
5438 circle = $$.$el.circle;
5439 circle && config.point_focus_expand_enabled && $$.expandCircles(index, id, reset);
5440
5441 // bar, candlestick
5442 $$.expandBarTypeShapes(!0, index, id, reset);
5443 },
5444 /**
5445 * Expand/Unexpand bar type shapes
5446 * @param {boolean} expand Expand or unexpand
5447 * @param {number} i Shape index
5448 * @param {string} id Data id
5449 * @param {boolean} reset Reset expand style
5450 * @private
5451 */
5452 expandBarTypeShapes: function expandBarTypeShapes(expand, i, id, reset) {
5453 var _this3 = this;
5454 if (expand === void 0) {
5455 expand = !0;
5456 }
5457 var $$ = this;
5458 ["bar", "candlestick"].filter(function (v) {
5459 _newArrowCheck(this, _this3);
5460 return $$.$el[v];
5461 }.bind(this)).forEach(function (v) {
5462 _newArrowCheck(this, _this3);
5463 reset && $$.$el[v].classed($COMMON.EXPANDED, !1);
5464 $$.getShapeByIndex(v, i, id).classed($COMMON.EXPANDED, expand);
5465 }.bind(this));
5466 },
5467 /**
5468 * Handle data.onover/out callback options
5469 * @param {boolean} isOver Over or not
5470 * @param {number|object} d data object
5471 * @private
5472 */
5473 setOverOut: function setOverOut(isOver, d) {
5474 var _this5 = this,
5475 $$ = this,
5476 config = $$.config,
5477 hasRadar = $$.state.hasRadar,
5478 main = $$.$el.main,
5479 isArc = isObject(d);
5480 // Call event handler
5481 if (isArc || d !== -1) {
5482 var callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
5483 config.color_onover && $$.setOverColor(isOver, d, isArc);
5484 if (isArc && "id") {
5485 callback(d, main.select("." + $ARC.arc + $$.getTargetSelectorSuffix(d.id)).node());
5486 } else if (!config.tooltip_grouped) {
5487 var last = $$.cache.get(KEY.setOverOut) || [],
5488 shapesAtIndex = main.selectAll("." + $SHAPE.shape + "-" + d).filter(function (d) {
5489 return $$.isWithinShape(this, d);
5490 }),
5491 shape = shapesAtIndex.filter(function () {
5492 var _this4 = this;
5493 return last.every(function (v) {
5494 _newArrowCheck(this, _this4);
5495 return v !== this;
5496 }.bind(this));
5497 }); // select based on the index
5498 // call onout callback
5499 if (!isOver || shapesAtIndex.empty() || last.length === shape.size() && shape.nodes().every(function (v, i) {
5500 _newArrowCheck(this, _this5);
5501 return v !== last[i];
5502 }.bind(this))) {
5503 while (last.length) {
5504 var target = last.pop();
5505 config.data_onout.bind($$.api)((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum(), target);
5506 }
5507 }
5508
5509 // call onover callback
5510 shape.each(function () {
5511 if (isOver) {
5512 callback((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).datum(), this);
5513 last.push(this);
5514 }
5515 });
5516 $$.cache.add(KEY.setOverOut, last);
5517 } else {
5518 if (isOver) {
5519 config.point_focus_only && hasRadar ? $$.showCircleFocus($$.getAllValuesOnIndex(d, !0)) : $$.setExpand(d, null, !0);
5520 }
5521 $$.isMultipleX() || main.selectAll("." + $SHAPE.shape + "-" + d).each(function (d) {
5522 callback(d, this);
5523 });
5524 }
5525 }
5526 },
5527 /**
5528 * Call data.onover/out callback for touch event
5529 * @param {number|object} d target index or data object for Arc type
5530 * @private
5531 */
5532 callOverOutForTouch: function callOverOutForTouch(d) {
5533 var $$ = this,
5534 last = $$.cache.get(KEY.callOverOutForTouch);
5535 if (isObject(d) && last ? d.id !== last.id : d !== last) {
5536 (last || isNumber(last)) && $$.setOverOut(!1, last);
5537 (d || isNumber(d)) && $$.setOverOut(!0, d);
5538 $$.cache.add(KEY.callOverOutForTouch, d);
5539 }
5540 },
5541 /**
5542 * Return draggable selection function
5543 * @returns {Function}
5544 * @private
5545 */
5546 getDraggableSelection: function getDraggableSelection() {
5547 var _this6 = this,
5548 $$ = this,
5549 config = $$.config,
5550 state = $$.state;
5551 return config.interaction_enabled && config.data_selection_draggable && $$.drag ? (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().on("drag", function (event) {
5552 state.event = event;
5553 $$.drag(getPointer(event, this));
5554 }).on("start", function (event) {
5555 state.event = event;
5556 $$.dragstart(getPointer(event, this));
5557 }).on("end", function (event) {
5558 _newArrowCheck(this, _this6);
5559 state.event = event;
5560 $$.dragend();
5561 }.bind(this)) : function () {
5562 _newArrowCheck(this, _this6);
5563 }.bind(this);
5564 },
5565 /**
5566 * Dispatch a mouse event.
5567 * @private
5568 * @param {string} type event type
5569 * @param {number} index Index of eventRect
5570 * @param {Array} mouse x and y coordinate value
5571 */
5572 dispatchEvent: function dispatchEvent(type, index, mouse) {
5573 var _this7 = this,
5574 $$ = this,
5575 config = $$.config,
5576 _$$$state = $$.state,
5577 eventReceiver = _$$$state.eventReceiver,
5578 hasAxis = _$$$state.hasAxis,
5579 hasRadar = _$$$state.hasRadar,
5580 _$$$$el = $$.$el,
5581 eventRect = _$$$$el.eventRect,
5582 arcs = _$$$$el.arcs,
5583 radar = _$$$$el.radar,
5584 isMultipleX = $$.isMultipleX(),
5585 element = (hasRadar ? radar.axes.select("." + $AXIS.axis + "-" + index + " text") : eventRect || arcs.selectAll("." + $COMMON.target + " path").filter(function (d, i) {
5586 _newArrowCheck(this, _this7);
5587 return i === index;
5588 }.bind(this))).node(),
5589 _element$getBoundingC = element.getBoundingClientRect(),
5590 width = _element$getBoundingC.width,
5591 left = _element$getBoundingC.left,
5592 top = _element$getBoundingC.top;
5593 if (hasAxis && !hasRadar && !isMultipleX) {
5594 var coords = eventReceiver.coords[index];
5595 width = coords.w;
5596 left += coords.x;
5597 top += coords.y;
5598 }
5599 var x = left + (mouse ? mouse[0] : 0) + (isMultipleX || config.axis_rotated ? 0 : width / 2),
5600 y = top + (mouse ? mouse[1] : 0);
5601 emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](element, type, {
5602 screenX: x,
5603 screenY: y,
5604 clientX: x,
5605 clientY: y
5606 });
5607 },
5608 setDragStatus: function setDragStatus(isDragging) {
5609 this.state.dragging = isDragging;
5610 },
5611 /**
5612 * Unbind zoom events
5613 * @private
5614 */
5615 unbindZoomEvent: function unbindZoomEvent() {
5616 var $$ = this,
5617 _$$$$el2 = $$.$el,
5618 eventRect = _$$$$el2.eventRect,
5619 zoomResetBtn = _$$$$el2.zoomResetBtn;
5620 eventRect == null ? void 0 : eventRect.on(".zoom wheel.zoom .drag", null);
5621 zoomResetBtn == null ? void 0 : zoomResetBtn.on("click", null).style("display", "none");
5622 },
5623 /**
5624 * Unbind all attached events
5625 * @private
5626 */
5627 unbindAllEvents: function unbindAllEvents() {
5628 var _this8 = this,
5629 $$ = this,
5630 _$$$$el3 = $$.$el,
5631 arcs = _$$$$el3.arcs,
5632 eventRect = _$$$$el3.eventRect,
5633 legend = _$$$$el3.legend,
5634 region = _$$$$el3.region,
5635 svg = _$$$$el3.svg,
5636 brush = $$.brush;
5637 // detach all possible event types
5638 [svg, eventRect, region == null ? void 0 : region.list, brush == null ? void 0 : brush.getSelection(), arcs == null ? void 0 : arcs.selectAll("path"), legend == null ? void 0 : legend.selectAll("g")].forEach(function (v) {
5639 _newArrowCheck(this, _this8);
5640 return v == null ? void 0 : v.on("wheel click mouseover mousemove mouseout touchstart touchmove touchend touchstart.eventRect touchmove.eventRect touchend.eventRect .brush .drag .zoom wheel.zoom dblclick.zoom", null);
5641 }.bind(this));
5642 $$.unbindZoomEvent == null ? void 0 : $$.unbindZoomEvent();
5643 }
5644});
5645;// CONCATENATED MODULE: ./src/ChartInternal/internals/class.ts
5646
5647/**
5648 * Copyright (c) 2017 ~ present NAVER Corp.
5649 * billboard.js project is licensed under the MIT license
5650 */
5651
5652/* harmony default export */ var internals_class = ({
5653 generateClass: function generateClass(prefix, targetId) {
5654 return " " + prefix + " " + (prefix + this.getTargetSelectorSuffix(targetId));
5655 },
5656 /**
5657 * Get class string
5658 * @param {string} type Shape type
5659 * @param {boolean} withShape Get with shape prefix
5660 * @returns {string} Class string
5661 * @private
5662 */
5663 getClass: function getClass(type, withShape) {
5664 var _this = this,
5665 isPlural = /s$/.test(type),
5666 useIdKey = /^(area|arc|line)s?$/.test(type),
5667 key = isPlural ? "id" : "index";
5668 return function (d) {
5669 _newArrowCheck(this, _this);
5670 var data = d.data || d,
5671 result = (withShape ? this.generateClass(classes[isPlural ? "shapes" : "shape"], data[key]) : "") + this.generateClass(classes[type], data[useIdKey ? "id" : key]);
5672 return result.trim();
5673 }.bind(this);
5674 },
5675 /**
5676 * Get chart class string
5677 * @param {string} type Shape type
5678 * @returns {string} Class string
5679 * @private
5680 */
5681 getChartClass: function getChartClass(type) {
5682 var _this2 = this;
5683 return function (d) {
5684 _newArrowCheck(this, _this2);
5685 return classes["chart" + type] + this.classTarget((d.data ? d.data : d).id);
5686 }.bind(this);
5687 },
5688 generateExtraLineClass: function generateExtraLineClass() {
5689 var $$ = this,
5690 classes = $$.config.line_classes || [],
5691 ids = [];
5692 return function (d) {
5693 var _d$data,
5694 id = d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d;
5695 if (ids.indexOf(id) < 0) {
5696 ids.push(id);
5697 }
5698 return classes[ids.indexOf(id) % classes.length];
5699 };
5700 },
5701 classRegion: function classRegion(d, i) {
5702 return this.generateClass(classes.region, i) + " " + ("class" in d ? d.class : "");
5703 },
5704 classTarget: function classTarget(id) {
5705 var additionalClassSuffix = this.config.data_classes[id],
5706 additionalClass = "";
5707 if (additionalClassSuffix) {
5708 additionalClass = " " + classes.target + "-" + additionalClassSuffix;
5709 }
5710 return this.generateClass(classes.target, id) + additionalClass;
5711 },
5712 classFocus: function classFocus(d) {
5713 return this.classFocused(d) + this.classDefocused(d);
5714 },
5715 classFocused: function classFocused(d) {
5716 return " " + (this.state.focusedTargetIds.indexOf(d.id) >= 0 ? classes.focused : "");
5717 },
5718 classDefocused: function classDefocused(d) {
5719 return " " + (this.state.defocusedTargetIds.indexOf(d.id) >= 0 ? classes.defocused : "");
5720 },
5721 getTargetSelectorSuffix: function getTargetSelectorSuffix(targetId) {
5722 var targetStr = targetId || targetId === 0 ? "-" + targetId : "";
5723 return targetStr.replace(/([\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\])/g, "-");
5724 },
5725 selectorTarget: function selectorTarget(id, prefix) {
5726 var pfx = prefix || "",
5727 target = this.getTargetSelectorSuffix(id);
5728 // select target & circle
5729 return pfx + "." + (classes.target + target) + ", " + pfx + "." + (classes.circles + target);
5730 },
5731 selectorTargets: function selectorTargets(idsValue, prefix) {
5732 var _this3 = this,
5733 ids = idsValue || [];
5734 return ids.length ? ids.map(function (id) {
5735 _newArrowCheck(this, _this3);
5736 return this.selectorTarget(id, prefix);
5737 }.bind(this)) : null;
5738 },
5739 selectorLegend: function selectorLegend(id) {
5740 return "." + (classes.legendItem + this.getTargetSelectorSuffix(id));
5741 },
5742 selectorLegends: function selectorLegends(ids) {
5743 var _this4 = this;
5744 return ids != null && ids.length ? ids.map(function (id) {
5745 _newArrowCheck(this, _this4);
5746 return this.selectorLegend(id);
5747 }.bind(this)) : null;
5748 }
5749});
5750;// CONCATENATED MODULE: ./src/ChartInternal/internals/category.ts
5751/**
5752 * Copyright (c) 2017 ~ present NAVER Corp.
5753 * billboard.js project is licensed under the MIT license
5754 */
5755/* harmony default export */ var category = ({
5756 /**
5757 * Category Name
5758 * @param {number} i Index number
5759 * @returns {string} category Name
5760 * @private
5761 */
5762 categoryName: function categoryName(i) {
5763 var categories = this.config.axis_x_categories;
5764 return i < (categories == null ? void 0 : categories.length) ? categories[i] : i;
5765 }
5766});
5767// EXTERNAL MODULE: external {"commonjs":"d3-scale","commonjs2":"d3-scale","amd":"d3-scale","root":"d3"}
5768var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webpack_require__(6);
5769;// CONCATENATED MODULE: ./src/ChartInternal/internals/color.ts
5770
5771var color_this = undefined;
5772/**
5773 * Copyright (c) 2017 ~ present NAVER Corp.
5774 * billboard.js project is licensed under the MIT license
5775 */
5776
5777
5778
5779
5780
5781
5782/**
5783 * Set pattern's background color
5784 * (it adds a <rect> element to simulate bg-color)
5785 * @param {SVGPatternElement} pattern SVG pattern element
5786 * @param {string} color Color string
5787 * @param {string} id ID to be set
5788 * @returns {{id: string, node: SVGPatternElement}}
5789 * @private
5790 */
5791var colorizePattern = function (pattern, color, id) {
5792 _newArrowCheck(this, color_this);
5793 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(!0));
5794 node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color);
5795 return {
5796 id: id,
5797 node: node.node()
5798 };
5799}.bind(undefined);
5800
5801/**
5802 * Get color pattern from CSS file
5803 * CSS should be defined as: background-image: url("#00c73c;#fa7171; ...");
5804 * @param {d3Selection} element Chart element
5805 * @returns {Array}
5806 * @private
5807 */
5808function getColorFromCss(element) {
5809 var _this2 = this,
5810 cacheKey = KEY.colorPattern,
5811 body = browser_doc.body,
5812 pattern = body[cacheKey];
5813 if (!pattern) {
5814 var content = element.classed($COLOR.colorPattern, !0).style("background-image");
5815 element.classed($COLOR.colorPattern, !1);
5816 if (content.indexOf(";") > -1) {
5817 pattern = content.replace(/url[^#]*|["'()]|(\s|%20)/g, "").split(";").map(function (v) {
5818 _newArrowCheck(this, _this2);
5819 return v.trim().replace(/[\"'\s]/g, "");
5820 }.bind(this)).filter(Boolean);
5821 body[cacheKey] = pattern;
5822 }
5823 }
5824 return pattern;
5825}
5826
5827// Replacement of d3.schemeCategory10.
5828// Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
5829var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
5830/* harmony default export */ var internals_color = ({
5831 generateColor: function generateColor() {
5832 var _this3 = this,
5833 $$ = this,
5834 $el = $$.$el,
5835 config = $$.config,
5836 colors = config.data_colors,
5837 callback = config.data_color,
5838 ids = [],
5839 pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(getColorFromCss($el.chart) || schemeCategory10).range(),
5840 originalColorPattern = pattern;
5841 if (isFunction(config.color_tiles)) {
5842 var tiles = config.color_tiles.bind($$.api)(),
5843 colorizedPatterns = pattern.map(function (p, index) {
5844 _newArrowCheck(this, _this3);
5845 var color = p.replace(/[#\(\)\s,]/g, ""),
5846 id = $$.state.datetimeId + "-pattern-" + color + "-" + index;
5847 return colorizePattern(tiles[index % tiles.length], p, id);
5848 }.bind(this)); // Add background color to patterns
5849 pattern = colorizedPatterns.map(function (p) {
5850 _newArrowCheck(this, _this3);
5851 return "url(#" + p.id + ")";
5852 }.bind(this));
5853 $$.patterns = colorizedPatterns;
5854 }
5855 return function (d) {
5856 var _data,
5857 id = d.id || ((_data = d.data) == null ? void 0 : _data.id) || d,
5858 isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id],
5859 color;
5860 // if callback function is provided
5861 if (isFunction(colors[id])) {
5862 color = colors[id].bind($$.api)(d);
5863
5864 // if specified, choose that color
5865 } else if (colors[id]) {
5866 color = colors[id];
5867
5868 // if not specified, choose from pattern
5869 } else {
5870 if (ids.indexOf(id) < 0) {
5871 ids.push(id);
5872 }
5873 color = isLine ? originalColorPattern[ids.indexOf(id) % originalColorPattern.length] : pattern[ids.indexOf(id) % pattern.length];
5874 colors[id] = color;
5875 }
5876 return isFunction(callback) ? callback.bind($$.api)(color, d) : color;
5877 };
5878 },
5879 generateLevelColor: function generateLevelColor() {
5880 var $$ = this,
5881 config = $$.config,
5882 colors = config.color_pattern,
5883 threshold = config.color_threshold,
5884 asValue = threshold.unit === "value",
5885 max = threshold.max || 100,
5886 values = threshold.values && threshold.values.length ? threshold.values : [];
5887 return notEmpty(threshold) ? function (value) {
5888 var v = asValue ? value : value * 100 / max,
5889 color = colors[colors.length - 1];
5890 for (var i = 0, l = values.length; i < l; i++) {
5891 if (v <= values[i]) {
5892 color = colors[i];
5893 break;
5894 }
5895 }
5896 return color;
5897 } : null;
5898 },
5899 /**
5900 * Append data backgound color filter definition
5901 * @param {string} color Color string
5902 * @private
5903 */
5904 generateDataLabelBackgroundColorFilter: function generateDataLabelBackgroundColorFilter(color) {
5905 var _this4 = this,
5906 $$ = this,
5907 $el = $$.$el,
5908 config = $$.config,
5909 state = $$.state,
5910 backgroundColors = color || config.data_labels_backgroundColors;
5911 if (backgroundColors) {
5912 var ids = [];
5913 if (isString(backgroundColors)) {
5914 ids.push("");
5915 } else if (isObject(backgroundColors)) {
5916 ids = Object.keys(backgroundColors);
5917 }
5918 ids.forEach(function (v) {
5919 _newArrowCheck(this, _this4);
5920 var id = state.datetimeId + "-labels-bg" + $$.getTargetSelectorSuffix(v) + (color ? $$.getTargetSelectorSuffix(color) : "");
5921 $el.defs.append("filter").attr("x", "0").attr("y", "0").attr("width", "1").attr("height", "1").attr("id", id).html("<feFlood flood-color=\"" + (v === "" ? backgroundColors : backgroundColors[v]) + "\" /><feComposite in=\"SourceGraphic\"/>");
5922 }.bind(this));
5923 }
5924 },
5925 /**
5926 * Get data gradient color url
5927 * @param {string} id Data id
5928 * @returns {string}
5929 * @private
5930 */
5931 getGradienColortUrl: function getGradienColortUrl(id) {
5932 return "url(#" + this.state.datetimeId + "-gradient" + this.getTargetSelectorSuffix(id) + ")";
5933 },
5934 /**
5935 * Update linear gradient definition (for area & bar only)
5936 * @private
5937 */
5938 updateLinearGradient: function updateLinearGradient() {
5939 var _this5 = this,
5940 $$ = this,
5941 config = $$.config,
5942 targets = $$.data.targets,
5943 datetimeId = $$.state.datetimeId,
5944 defs = $$.$el.defs;
5945 targets.forEach(function (d) {
5946 var _this6 = this;
5947 _newArrowCheck(this, _this5);
5948 var id = datetimeId + "-gradient" + $$.getTargetSelectorSuffix(d.id),
5949 supportedType = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar",
5950 isRotated = config.axis_rotated;
5951 if (supportedType && defs.select("#" + id).empty()) {
5952 var color = $$.color(d),
5953 _config = config[supportedType + "_linearGradient"],
5954 _config$x = _config.x,
5955 x = _config$x === void 0 ? isRotated ? [1, 0] : [0, 0] : _config$x,
5956 _config$y = _config.y,
5957 y = _config$y === void 0 ? isRotated ? [0, 0] : [0, 1] : _config$y,
5958 _config$stops = _config.stops,
5959 stops = _config$stops === void 0 ? [[0, color, 1], [1, color, 0]] : _config$stops,
5960 linearGradient = defs.append("linearGradient").attr("id", "" + id).attr("x1", x[0]).attr("x2", x[1]).attr("y1", y[0]).attr("y2", y[1]);
5961 stops.forEach(function (v) {
5962 _newArrowCheck(this, _this6);
5963 var stopColor = isFunction(v[1]) ? v[1].bind($$.api)(d.id) : v[1];
5964 linearGradient.append("stop").attr("offset", v[0]).attr("stop-color", stopColor || color).attr("stop-opacity", v[2]);
5965 }.bind(this));
5966 }
5967 }.bind(this));
5968 },
5969 /**
5970 * Set the data over color.
5971 * When is out, will restate in its previous color value
5972 * @param {boolean} isOver true: set overed color, false: restore
5973 * @param {number|object} d target index or data object for Arc type
5974 * @private
5975 */
5976 setOverColor: function setOverColor(isOver, d) {
5977 var _this7 = this,
5978 $$ = this,
5979 config = $$.config,
5980 main = $$.$el.main,
5981 onover = config.color_onover,
5982 color = isOver ? onover : $$.color;
5983 if (isObject(color)) {
5984 color = function (_ref) {
5985 var id = _ref.id;
5986 _newArrowCheck(this, _this7);
5987 return id in onover ? onover[id] : $$.color(id);
5988 }.bind(this);
5989 } else if (isString(color)) {
5990 color = function () {
5991 _newArrowCheck(this, _this7);
5992 return onover;
5993 }.bind(this);
5994 } else if (isFunction(onover)) {
5995 color = color.bind($$.api);
5996 }
5997 main.selectAll(isObject(d) ? // when is Arc type
5998 "." + $ARC.arc + $$.getTargetSelectorSuffix(d.id) : "." + $SHAPE.shape + "-" + d).style("fill", color);
5999 }
6000});
6001;// CONCATENATED MODULE: ./src/ChartInternal/internals/domain.ts
6002
6003/**
6004 * Copyright (c) 2017 ~ present NAVER Corp.
6005 * billboard.js project is licensed under the MIT license
6006 */
6007
6008
6009/* harmony default export */ var domain = ({
6010 getYDomainMinMax: function getYDomainMinMax(targets, type) {
6011 var _this = this,
6012 $$ = this,
6013 axis = $$.axis,
6014 config = $$.config,
6015 isMin = type === "min",
6016 dataGroups = config.data_groups,
6017 ids = $$.mapToIds(targets),
6018 ys = $$.getValuesAsIdKeyed(targets);
6019 if (dataGroups.length > 0) {
6020 var hasValue = $$["has" + (isMin ? "Negative" : "Positive") + "ValueInTargets"](targets);
6021 dataGroups.forEach(function (groupIds) {
6022 var _this2 = this;
6023 _newArrowCheck(this, _this);
6024 // Determine baseId
6025 var idsInGroup = groupIds.filter(function (v) {
6026 _newArrowCheck(this, _this2);
6027 return ids.indexOf(v) >= 0;
6028 }.bind(this));
6029 if (idsInGroup.length) {
6030 var baseId = idsInGroup[0],
6031 baseAxisId = axis.getId(baseId);
6032 // Initialize base value. Set to 0 if not match with the condition
6033 if (hasValue && ys[baseId]) {
6034 ys[baseId] = ys[baseId].map(function (v) {
6035 _newArrowCheck(this, _this2);
6036 return (isMin ? v < 0 : v > 0) ? v : 0;
6037 }.bind(this));
6038 }
6039 idsInGroup.filter(function (v, i) {
6040 _newArrowCheck(this, _this2);
6041 return i > 0;
6042 }.bind(this)).forEach(function (id) {
6043 var _this3 = this;
6044 _newArrowCheck(this, _this2);
6045 if (ys[id]) {
6046 var axisId = axis.getId(id);
6047 ys[id].forEach(function (v, i) {
6048 _newArrowCheck(this, _this3);
6049 var val = +v,
6050 meetCondition = isMin ? val > 0 : val < 0;
6051 if (axisId === baseAxisId && !(hasValue && meetCondition)) {
6052 ys[baseId][i] += val;
6053 }
6054 }.bind(this));
6055 }
6056 }.bind(this));
6057 }
6058 }.bind(this));
6059 }
6060 return getMinMax(type, Object.keys(ys).map(function (key) {
6061 _newArrowCheck(this, _this);
6062 return getMinMax(type, ys[key]);
6063 }.bind(this)));
6064 },
6065 /**
6066 * Check if hidden targets bound to the given axis id
6067 * @param {string} id ID to be checked
6068 * @returns {boolean}
6069 * @private
6070 */
6071 isHiddenTargetWithYDomain: function isHiddenTargetWithYDomain(id) {
6072 var _this4 = this,
6073 $$ = this;
6074 return $$.state.hiddenTargetIds.some(function (v) {
6075 _newArrowCheck(this, _this4);
6076 return $$.axis.getId(v) === id;
6077 }.bind(this));
6078 },
6079 getYDomain: function getYDomain(targets, axisId, xDomain) {
6080 var _this5 = this,
6081 $$ = this,
6082 axis = $$.axis,
6083 config = $$.config,
6084 scale = $$.scale,
6085 pfx = "axis_" + axisId;
6086 if ($$.isStackNormalized()) {
6087 return [0, 100];
6088 }
6089 var isLog = (scale == null ? void 0 : scale[axisId]) && scale[axisId].type === "log",
6090 targetsByAxisId = targets.filter(function (t) {
6091 _newArrowCheck(this, _this5);
6092 return axis.getId(t.id) === axisId;
6093 }.bind(this)),
6094 yTargets = xDomain ? $$.filterByXDomain(targetsByAxisId, xDomain) : targetsByAxisId;
6095 if (yTargets.length === 0) {
6096 // use domain of the other axis if target of axisId is none
6097 if ($$.isHiddenTargetWithYDomain(axisId)) {
6098 return scale[axisId].domain();
6099 } else {
6100 return axisId === "y2" ? scale.y.domain() :
6101 // When all data bounds to y2, y Axis domain is called prior y2.
6102 // So, it needs to call to get y2 domain here
6103 $$.getYDomain(targets, "y2", xDomain);
6104 }
6105 }
6106 var yMin = config[pfx + "_min"],
6107 yMax = config[pfx + "_max"],
6108 center = config[pfx + "_center"],
6109 isInverted = config[pfx + "_inverted"],
6110 showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated,
6111 showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated,
6112 yDomainMin = $$.getYDomainMinMax(yTargets, "min"),
6113 yDomainMax = $$.getYDomainMinMax(yTargets, "max"),
6114 isZeroBased = [TYPE.BAR, TYPE.BUBBLE, TYPE.SCATTER].concat(TYPE_BY_CATEGORY.Line).some(function (v) {
6115 _newArrowCheck(this, _this5);
6116 var type = v.indexOf("area") > -1 ? "area" : v;
6117 return $$.hasType(v, yTargets, !0) && config[type + "_zerobased"];
6118 }.bind(this));
6119 // MEMO: avoid inverting domain unexpectedly
6120 yDomainMin = isValue(yMin) ? yMin : isValue(yMax) ? yDomainMin < yMax ? yDomainMin : yMax - 10 : yDomainMin;
6121 yDomainMax = isValue(yMax) ? yMax : isValue(yMin) ? yMin < yDomainMax ? yDomainMax : yMin + 10 : yDomainMax;
6122 if (isNaN(yDomainMin)) {
6123 // set minimum to zero when not number
6124 yDomainMin = 0;
6125 }
6126 if (isNaN(yDomainMax)) {
6127 // set maximum to have same value as yDomainMin
6128 yDomainMax = yDomainMin;
6129 }
6130 if (yDomainMin === yDomainMax) {
6131 yDomainMin < 0 ? yDomainMax = 0 : yDomainMin = 0;
6132 }
6133 var isAllPositive = yDomainMin >= 0 && yDomainMax >= 0,
6134 isAllNegative = yDomainMin <= 0 && yDomainMax <= 0;
6135 // Cancel zerobased if axis_*_min / axis_*_max specified
6136 if (isValue(yMin) && isAllPositive || isValue(yMax) && isAllNegative) {
6137 isZeroBased = !1;
6138 }
6139
6140 // Bar/Area chart should be 0-based if all positive|negative
6141 if (isZeroBased) {
6142 isAllPositive && (yDomainMin = 0);
6143 isAllNegative && (yDomainMax = 0);
6144 }
6145 var domainLength = Math.abs(yDomainMax - yDomainMin),
6146 padding = {
6147 top: domainLength * .1,
6148 bottom: domainLength * .1
6149 };
6150 if (isDefined(center)) {
6151 var yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
6152 yDomainMax = center + yDomainAbs;
6153 yDomainMin = center - yDomainAbs;
6154 }
6155
6156 // add padding for data label
6157 if (showHorizontalDataLabel) {
6158 var diff = diffDomain(scale.y.range()),
6159 ratio = $$.getDataLabelLength(yDomainMin, yDomainMax, "width").map(function (v) {
6160 _newArrowCheck(this, _this5);
6161 return v / diff;
6162 }.bind(this));
6163 ["bottom", "top"].forEach(function (v, i) {
6164 _newArrowCheck(this, _this5);
6165 padding[v] += domainLength * (ratio[i] / (1 - ratio[0] - ratio[1]));
6166 }.bind(this));
6167 } else if (showVerticalDataLabel) {
6168 var lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, "height");
6169 ["bottom", "top"].forEach(function (v, i) {
6170 _newArrowCheck(this, _this5);
6171 padding[v] += $$.convertPixelToScale("y", lengths[i], domainLength);
6172 }.bind(this));
6173 }
6174 padding = $$.getResettedPadding(padding);
6175
6176 // if padding is set, the domain will be updated relative the current domain value
6177 // ex) $$.height=300, padding.top=150, domainLength=4 --> domain=6
6178 var p = config[pfx + "_padding"];
6179 if (notEmpty(p)) {
6180 ["bottom", "top"].forEach(function (v) {
6181 _newArrowCheck(this, _this5);
6182 padding[v] = axis.getPadding(p, v, padding[v], domainLength);
6183 }.bind(this));
6184 }
6185
6186 // Bar/Area chart should be 0-based if all positive|negative
6187 if (isZeroBased) {
6188 isAllPositive && (padding.bottom = yDomainMin);
6189 isAllNegative && (padding.top = -yDomainMax);
6190 }
6191 var domain = isLog ? [yDomainMin, yDomainMax].map(function (v) {
6192 _newArrowCheck(this, _this5);
6193 return v < 0 ? 0 : v;
6194 }.bind(this)) : [yDomainMin - padding.bottom, yDomainMax + padding.top];
6195 return isInverted ? domain.reverse() : domain;
6196 },
6197 getXDomainMinMax: function getXDomainMinMax(targets, type) {
6198 var _this6 = this,
6199 $$ = this,
6200 configValue = $$.config["axis_x_" + type],
6201 dataValue = getMinMax(type, targets.map(function (t) {
6202 var _this7 = this;
6203 _newArrowCheck(this, _this6);
6204 return getMinMax(type, t.values.map(function (v) {
6205 _newArrowCheck(this, _this7);
6206 return v.x;
6207 }.bind(this)));
6208 }.bind(this))),
6209 value = isObject(configValue) ? configValue.value : configValue,
6210 _$$$axis;
6211 value = isDefined(value) && (_$$$axis = $$.axis) != null && _$$$axis.isTimeSeries() ? parseDate.bind(this)(value) : value;
6212 if (isObject(configValue) && configValue.fit && (type === "min" && value < dataValue || type === "max" && value > dataValue)) {
6213 value = undefined;
6214 }
6215 return isDefined(value) ? value : dataValue;
6216 },
6217 /**
6218 * Get x Axis padding
6219 * @param {Array} domain x Axis domain
6220 * @param {number} tickCount Tick count
6221 * @returns {object} Padding object values with 'left' & 'right' key
6222 * @private
6223 */
6224 getXDomainPadding: function getXDomainPadding(domain, tickCount) {
6225 var $$ = this,
6226 axis = $$.axis,
6227 config = $$.config,
6228 padding = config.axis_x_padding,
6229 isTimeSeriesTickCount = axis.isTimeSeries() && tickCount,
6230 diff = diffDomain(domain),
6231 defaultValue;
6232 // determine default padding value
6233 if (axis.isCategorized() || isTimeSeriesTickCount) {
6234 defaultValue = 0;
6235 } else if ($$.hasType("bar")) {
6236 var maxDataCount = $$.getMaxDataCount();
6237 defaultValue = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : .5;
6238 } else {
6239 defaultValue = $$.getResettedPadding(diff * .01);
6240 }
6241 var _ref = isNumber(padding) ? {
6242 left: padding,
6243 right: padding
6244 } : padding,
6245 _ref$left = _ref.left,
6246 left = _ref$left === void 0 ? defaultValue : _ref$left,
6247 _ref$right = _ref.right,
6248 right = _ref$right === void 0 ? defaultValue : _ref$right;
6249
6250 // when the unit is pixel, convert pixels to axis scale value
6251 if (padding.unit === "px") {
6252 var domainLength = Math.abs(diff + diff * .2);
6253 left = axis.getPadding(padding, "left", defaultValue, domainLength);
6254 right = axis.getPadding(padding, "right", defaultValue, domainLength);
6255 } else {
6256 var range = diff + left + right;
6257 if (isTimeSeriesTickCount && range) {
6258 var relativeTickWidth = diff / tickCount / range;
6259 left = left / range / relativeTickWidth;
6260 right = right / range / relativeTickWidth;
6261 }
6262 }
6263 return {
6264 left: left,
6265 right: right
6266 };
6267 },
6268 /**
6269 * Get x Axis domain
6270 * @param {Array} targets targets
6271 * @returns {Array} x Axis domain
6272 * @private
6273 */
6274 getXDomain: function getXDomain(targets) {
6275 var $$ = this,
6276 axis = $$.axis,
6277 x = $$.scale.x,
6278 domain = [$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")],
6279 _domain = domain,
6280 _domain$ = _domain[0],
6281 min = _domain$ === void 0 ? 0 : _domain$,
6282 _domain$2 = _domain[1],
6283 max = _domain$2 === void 0 ? 0 : _domain$2;
6284 if (x.type !== "log") {
6285 var isCategorized = axis.isCategorized(),
6286 isTimeSeries = axis.isTimeSeries(),
6287 _padding = $$.getXDomainPadding(domain),
6288 firstX = domain[0],
6289 lastX = domain[1];
6290 // show center of x domain if min and max are the same
6291 if (firstX - lastX === 0 && !isCategorized) {
6292 if (isTimeSeries) {
6293 firstX = new Date(firstX.getTime() * .5);
6294 lastX = new Date(lastX.getTime() * 1.5);
6295 } else {
6296 firstX = firstX === 0 ? 1 : firstX * .5;
6297 lastX = lastX === 0 ? -1 : lastX * 1.5;
6298 }
6299 }
6300 if (firstX || firstX === 0) {
6301 min = isTimeSeries ? new Date(firstX.getTime() - _padding.left) : firstX - _padding.left;
6302 }
6303 if (lastX || lastX === 0) {
6304 max = isTimeSeries ? new Date(lastX.getTime() + _padding.right) : lastX + _padding.right;
6305 }
6306 }
6307 return [min, max];
6308 },
6309 updateXDomain: function updateXDomain(targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
6310 var $$ = this,
6311 config = $$.config,
6312 org = $$.org,
6313 _$$$scale = $$.scale,
6314 x = _$$$scale.x,
6315 subX = _$$$scale.subX,
6316 zoomEnabled = config.zoom_enabled;
6317 if (withUpdateOrgXDomain) {
6318 var _$$$brush;
6319 x.domain(domain || sortValue($$.getXDomain(targets)));
6320 org.xDomain = x.domain();
6321 zoomEnabled && $$.zoom.updateScaleExtent();
6322 subX.domain(x.domain());
6323 (_$$$brush = $$.brush) == null ? void 0 : _$$$brush.scale(subX);
6324 }
6325 if (withUpdateXDomain) {
6326 var domainValue = domain || !$$.brush || brushEmpty($$) ? org.xDomain : getBrushSelection($$).map(subX.invert);
6327 x.domain(domainValue);
6328 zoomEnabled && $$.zoom.updateScaleExtent();
6329 }
6330
6331 // Trim domain when too big by zoom mousemove event
6332 withTrim && x.domain($$.trimXDomain(x.orgDomain()));
6333 return x.domain();
6334 },
6335 trimXDomain: function trimXDomain(domain) {
6336 var zoomDomain = this.getZoomDomain(),
6337 min = zoomDomain[0],
6338 max = zoomDomain[1];
6339 if (domain[0] <= min) {
6340 domain[1] = +domain[1] + (min - domain[0]);
6341 domain[0] = min;
6342 }
6343 if (max <= domain[1]) {
6344 domain[0] = +domain[0] - (domain[1] - max);
6345 domain[1] = max;
6346 }
6347 return domain;
6348 },
6349 /**
6350 * Get zoom domain
6351 * @returns {Array} zoom domain
6352 * @private
6353 */
6354 getZoomDomain: function getZoomDomain() {
6355 var $$ = this,
6356 config = $$.config,
6357 org = $$.org,
6358 _org$xDomain = org.xDomain,
6359 min = _org$xDomain[0],
6360 max = _org$xDomain[1];
6361 if (isDefined(config.zoom_x_min)) {
6362 min = getMinMax("min", [min, config.zoom_x_min]);
6363 }
6364 if (isDefined(config.zoom_x_max)) {
6365 max = getMinMax("max", [max, config.zoom_x_max]);
6366 }
6367 return [min, max];
6368 },
6369 /**
6370 * Converts pixels to axis' scale values
6371 * @param {string} type Axis type
6372 * @param {number} pixels Pixels
6373 * @param {number} domainLength Domain length
6374 * @returns {number}
6375 * @private
6376 */
6377 convertPixelToScale: function convertPixelToScale(type, pixels, domainLength) {
6378 var $$ = this,
6379 config = $$.config,
6380 state = $$.state,
6381 isRotated = config.axis_rotated,
6382 length;
6383 if (type === "x") {
6384 length = isRotated ? "height" : "width";
6385 } else {
6386 length = isRotated ? "width" : "height";
6387 }
6388 return domainLength * (pixels / state[length]);
6389 }
6390});
6391;// CONCATENATED MODULE: ./src/ChartInternal/internals/format.ts
6392
6393/**
6394 * Copyright (c) 2017 ~ present NAVER Corp.
6395 * billboard.js project is licensed under the MIT license
6396 */
6397
6398/**
6399 * Get formatted
6400 * @param {object} $$ Context
6401 * @param {string} typeValue Axis type
6402 * @param {number} v Value to be formatted
6403 * @returns {number | string}
6404 * @private
6405 */
6406function getFormat($$, typeValue, v) {
6407 var config = $$.config,
6408 type = "axis_" + typeValue + "_tick_format",
6409 format = config[type] ? config[type] : $$.defaultValueFormat;
6410 return format(v);
6411}
6412/* harmony default export */ var format = ({
6413 yFormat: function yFormat(v) {
6414 return getFormat(this, "y", v);
6415 },
6416 y2Format: function y2Format(v) {
6417 return getFormat(this, "y2", v);
6418 },
6419 /**
6420 * Get default value format function
6421 * @returns {Function} formatter function
6422 * @private
6423 */
6424 getDefaultValueFormat: function getDefaultValueFormat() {
6425 var $$ = this,
6426 defaultArcValueFormat = $$.defaultArcValueFormat,
6427 yFormat = $$.yFormat,
6428 y2Format = $$.y2Format,
6429 hasArc = $$.hasArcType(null, ["gauge", "polar", "radar"]);
6430 return function (v, ratio, id) {
6431 var format = hasArc ? defaultArcValueFormat : $$.axis && $$.axis.getId(id) === "y2" ? y2Format : yFormat;
6432 return format.call($$, v, ratio);
6433 };
6434 },
6435 defaultValueFormat: function defaultValueFormat(v) {
6436 return isValue(v) ? +v : "";
6437 },
6438 defaultArcValueFormat: function defaultArcValueFormat(v, ratio) {
6439 return (ratio * 100).toFixed(1) + "%";
6440 },
6441 defaultPolarValueFormat: function defaultPolarValueFormat(v) {
6442 return "" + v;
6443 },
6444 dataLabelFormat: function dataLabelFormat(targetId) {
6445 var _this = this,
6446 $$ = this,
6447 dataLabels = $$.config.data_labels,
6448 defaultFormat = function (v) {
6449 _newArrowCheck(this, _this);
6450 return isValue(v) ? +v : "";
6451 }.bind(this),
6452 format = defaultFormat;
6453 // find format according to axis id
6454 if (isFunction(dataLabels.format)) {
6455 format = dataLabels.format;
6456 } else if (isObjectType(dataLabels.format)) {
6457 if (dataLabels.format[targetId]) {
6458 format = dataLabels.format[targetId] === !0 ? defaultFormat : dataLabels.format[targetId];
6459 } else {
6460 format = function () {
6461 _newArrowCheck(this, _this);
6462 return "";
6463 }.bind(this);
6464 }
6465 }
6466 return format.bind($$.api);
6467 }
6468});
6469;// CONCATENATED MODULE: ./src/ChartInternal/internals/legend.ts
6470
6471/**
6472 * Copyright (c) 2017 ~ present NAVER Corp.
6473 * billboard.js project is licensed under the MIT license
6474 */
6475
6476
6477
6478
6479
6480
6481/**
6482 * Get color string for given data id
6483 * @param {string} id Data id
6484 * @returns {string} Color string
6485 * @private
6486 */
6487function getLegendColor(id) {
6488 var $$ = this,
6489 data = $$.getDataById(id),
6490 color = $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
6491 return color;
6492}
6493/* harmony default export */ var internals_legend = ({
6494 /**
6495 * Initialize the legend.
6496 * @private
6497 */
6498 initLegend: function initLegend() {
6499 var $$ = this,
6500 config = $$.config,
6501 $el = $$.$el;
6502 $$.legendItemTextBox = {};
6503 $$.state.legendHasRendered = !1;
6504 if (config.legend_show) {
6505 if (!config.legend_contents_bindto) {
6506 $el.legend = $$.$el.svg.append("g").classed($LEGEND.legend, !0).attr("transform", $$.getTranslate("legend"));
6507 }
6508
6509 // MEMO: call here to update legend box and translate for all
6510 // MEMO: translate will be updated by this, so transform not needed in updateLegend()
6511 $$.updateLegend();
6512 } else {
6513 $$.state.hiddenLegendIds = $$.mapToIds($$.data.targets);
6514 }
6515 },
6516 /**
6517 * Update legend element
6518 * @param {Array} targetIds ID's of target
6519 * @param {object} options withTransform : Whether to use the transform property / withTransitionForTransform: Whether transition is used when using the transform property / withTransition : whether or not to transition.
6520 * @param {object} transitions Return value of the generateTransitions
6521 * @private
6522 */
6523 updateLegend: function updateLegend(targetIds, options, transitions) {
6524 var $$ = this,
6525 config = $$.config,
6526 state = $$.state,
6527 scale = $$.scale,
6528 $el = $$.$el,
6529 optionz = options || {
6530 withTransform: !1,
6531 withTransitionForTransform: !1,
6532 withTransition: !1
6533 };
6534 optionz.withTransition = getOption(optionz, "withTransition", !0);
6535 optionz.withTransitionForTransform = getOption(optionz, "withTransitionForTransform", !0);
6536 if (config.legend_contents_bindto && config.legend_contents_template) {
6537 $$.updateLegendTemplate();
6538 } else {
6539 $$.updateLegendElement(targetIds || $$.mapToIds($$.data.targets), optionz, transitions);
6540 }
6541
6542 // toggle legend state
6543 $el.legend.selectAll("." + $LEGEND.legendItem).classed($LEGEND.legendItemHidden, function (id) {
6544 var hide = !$$.isTargetToShow(id);
6545 if (hide) {
6546 this.style.opacity = null;
6547 }
6548 return hide;
6549 });
6550
6551 // Update size and scale
6552 $$.updateScales(!1, !scale.zoom);
6553 $$.updateSvgSize();
6554
6555 // Update g positions
6556 $$.transformAll(optionz.withTransitionForTransform, transitions);
6557 state.legendHasRendered = !0;
6558 },
6559 /**
6560 * Update legend using template option
6561 * @private
6562 */
6563 updateLegendTemplate: function updateLegendTemplate() {
6564 var _this = this,
6565 $$ = this,
6566 config = $$.config,
6567 $el = $$.$el,
6568 wrapper = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.legend_contents_bindto),
6569 template = config.legend_contents_template;
6570 if (!wrapper.empty()) {
6571 var targets = $$.mapToIds($$.data.targets),
6572 ids = [],
6573 html = "";
6574 targets.forEach(function (v) {
6575 _newArrowCheck(this, _this);
6576 var content = isFunction(template) ? template.bind($$.api)(v, $$.color(v), $$.api.data(v)[0].values) : tplProcess(template, {
6577 COLOR: $$.color(v),
6578 TITLE: v
6579 });
6580 if (content) {
6581 ids.push(v);
6582 html += content;
6583 }
6584 }.bind(this));
6585 var legendItem = wrapper.html(html).selectAll(function () {
6586 return this.childNodes;
6587 }).data(ids);
6588 $$.setLegendItem(legendItem);
6589 $el.legend = wrapper;
6590 }
6591 },
6592 /**
6593 * Update the size of the legend.
6594 * @param {Obejct} size Size object
6595 * @private
6596 */
6597 updateSizeForLegend: function updateSizeForLegend(size) {
6598 var $$ = this,
6599 config = $$.config,
6600 _$$$state = $$.state,
6601 isLegendTop = _$$$state.isLegendTop,
6602 isLegendLeft = _$$$state.isLegendLeft,
6603 isLegendRight = _$$$state.isLegendRight,
6604 isLegendInset = _$$$state.isLegendInset,
6605 current = _$$$state.current,
6606 width = size.width,
6607 height = size.height,
6608 insetLegendPosition = {
6609 top: isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : current.height - height - $$.getCurrentPaddingBottom() - config.legend_inset_y,
6610 left: isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + .5 : current.width - width - $$.getCurrentPaddingRight() - config.legend_inset_x + .5
6611 };
6612 $$.state.margin3 = {
6613 top: isLegendRight ? 0 : isLegendInset ? insetLegendPosition.top : current.height - height,
6614 right: NaN,
6615 bottom: 0,
6616 left: isLegendRight ? current.width - width : isLegendInset ? insetLegendPosition.left : 0
6617 };
6618 },
6619 /**
6620 * Transform Legend
6621 * @param {boolean} withTransition whether or not to transition.
6622 * @private
6623 */
6624 transformLegend: function transformLegend(withTransition) {
6625 var $$ = this,
6626 legend = $$.$el.legend,
6627 $T = $$.$T;
6628 $T(legend, withTransition).attr("transform", $$.getTranslate("legend"));
6629 },
6630 /**
6631 * Update the legend step
6632 * @param {number} step Step value
6633 * @private
6634 */
6635 updateLegendStep: function updateLegendStep(step) {
6636 this.state.legendStep = step;
6637 },
6638 /**
6639 * Update legend item width
6640 * @param {number} width Width value
6641 * @private
6642 */
6643 updateLegendItemWidth: function updateLegendItemWidth(width) {
6644 this.state.legendItemWidth = width;
6645 },
6646 /**
6647 * Update legend item height
6648 * @param {number} height Height value
6649 * @private
6650 */
6651 updateLegendItemHeight: function updateLegendItemHeight(height) {
6652 this.state.legendItemHeight = height;
6653 },
6654 /**
6655 * Update legend item color
6656 * @param {string} id Corresponding data ID value
6657 * @param {string} color Color value
6658 * @private
6659 */
6660 updateLegendItemColor: function updateLegendItemColor(id, color) {
6661 var legend = this.$el.legend;
6662 if (legend) {
6663 legend.select("." + $LEGEND.legendItem + "-" + id + " line").style("stroke", color);
6664 }
6665 },
6666 /**
6667 * Get the width of the legend
6668 * @returns {number} width
6669 * @private
6670 */
6671 getLegendWidth: function getLegendWidth() {
6672 var $$ = this,
6673 _$$$state2 = $$.state,
6674 width = _$$$state2.current.width,
6675 isLegendRight = _$$$state2.isLegendRight,
6676 isLegendInset = _$$$state2.isLegendInset,
6677 legendItemWidth = _$$$state2.legendItemWidth,
6678 legendStep = _$$$state2.legendStep;
6679 return $$.config.legend_show ? isLegendRight || isLegendInset ? legendItemWidth * (legendStep + 1) : width : 0;
6680 },
6681 /**
6682 * Get the height of the legend
6683 * @returns {number} height
6684 * @private
6685 */
6686 getLegendHeight: function getLegendHeight() {
6687 var $$ = this,
6688 _$$$state3 = $$.state,
6689 current = _$$$state3.current,
6690 isLegendRight = _$$$state3.isLegendRight,
6691 legendItemHeight = _$$$state3.legendItemHeight,
6692 legendStep = _$$$state3.legendStep;
6693 return $$.config.legend_show ? isLegendRight ? current.height : Math.max(20, legendItemHeight) * (legendStep + 1) : 0;
6694 },
6695 /**
6696 * Get the opacity of the legend that is unfocused
6697 * @param {d3.selection} legendItem Legend item node
6698 * @returns {string|null} opacity
6699 * @private
6700 */
6701 opacityForUnfocusedLegend: function opacityForUnfocusedLegend(legendItem) {
6702 return legendItem.classed($LEGEND.legendItemHidden) ? null : "0.3";
6703 },
6704 /**
6705 * Toggles the focus of the legend
6706 * @param {Array} targetIds ID's of target
6707 * @param {boolean} focus whether or not to focus.
6708 * @private
6709 */
6710 toggleFocusLegend: function toggleFocusLegend(targetIds, focus) {
6711 var _this2 = this,
6712 $$ = this,
6713 legend = $$.$el.legend,
6714 $T = $$.$T,
6715 targetIdz = $$.mapToTargetIds(targetIds);
6716 legend && $T(legend.selectAll("." + $LEGEND.legendItem).filter(function (id) {
6717 _newArrowCheck(this, _this2);
6718 return targetIdz.indexOf(id) >= 0;
6719 }.bind(this)).classed($FOCUS.legendItemFocused, focus)).style("opacity", function () {
6720 return focus ? null : $$.opacityForUnfocusedLegend.call($$, (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this));
6721 });
6722 },
6723 /**
6724 * Revert the legend to its default state
6725 * @private
6726 */
6727 revertLegend: function revertLegend() {
6728 var $$ = this,
6729 legend = $$.$el.legend,
6730 $T = $$.$T;
6731 legend && $T(legend.selectAll("." + $LEGEND.legendItem).classed($FOCUS.legendItemFocused, !1)).style("opacity", null);
6732 },
6733 /**
6734 * Shows the legend
6735 * @param {Array} targetIds ID's of target
6736 * @private
6737 */
6738 showLegend: function showLegend(targetIds) {
6739 var $$ = this,
6740 config = $$.config,
6741 $el = $$.$el,
6742 $T = $$.$T;
6743 if (!config.legend_show) {
6744 config.legend_show = !0;
6745 $el.legend ? $el.legend.style("visibility", null) : $$.initLegend();
6746 $$.state.legendHasRendered || $$.updateLegend();
6747 }
6748 $$.removeHiddenLegendIds(targetIds);
6749 $T($el.legend.selectAll($$.selectorLegends(targetIds)).style("visibility", null)).style("opacity", null);
6750 },
6751 /**
6752 * Hide the legend
6753 * @param {Array} targetIds ID's of target
6754 * @private
6755 */
6756 hideLegend: function hideLegend(targetIds) {
6757 var $$ = this,
6758 config = $$.config,
6759 legend = $$.$el.legend;
6760 if (config.legend_show && isEmpty(targetIds)) {
6761 config.legend_show = !1;
6762 legend.style("visibility", "hidden");
6763 }
6764 $$.addHiddenLegendIds(targetIds);
6765 legend.selectAll($$.selectorLegends(targetIds)).style("opacity", "0").style("visibility", "hidden");
6766 },
6767 /**
6768 * Get legend item textbox dimension
6769 * @param {string} id Data ID
6770 * @param {HTMLElement|d3.selection} textElement Text node element
6771 * @returns {object} Bounding rect
6772 * @private
6773 */
6774 getLegendItemTextBox: function getLegendItemTextBox(id, textElement) {
6775 var $$ = this,
6776 cache = $$.cache,
6777 state = $$.state,
6778 data,
6779 cacheKey = KEY.legendItemTextBox;
6780 if (id) {
6781 data = !state.redrawing && cache.get(cacheKey) || {};
6782 if (!data[id]) {
6783 data[id] = $$.getTextRect(textElement, $LEGEND.legendItem);
6784 cache.add(cacheKey, data);
6785 }
6786 data = data[id];
6787 }
6788 return data;
6789 },
6790 /**
6791 * Set legend item style & bind events
6792 * @param {d3.selection} item Item node
6793 * @private
6794 */
6795 setLegendItem: function setLegendItem(item) {
6796 var _this3 = this,
6797 $$ = this,
6798 $el = $$.$el,
6799 api = $$.api,
6800 config = $$.config,
6801 state = $$.state,
6802 isTouch = state.inputType === "touch",
6803 hasGauge = $$.hasType("gauge"),
6804 useCssRule = config.boost_useCssRule;
6805 item.attr("class", function (id) {
6806 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
6807 itemClass = !node.empty() && node.attr("class") || "";
6808 return itemClass + $$.generateClass($LEGEND.legendItem, id);
6809 }).style("visibility", function (id) {
6810 _newArrowCheck(this, _this3);
6811 return $$.isLegendToShow(id) ? null : "hidden";
6812 }.bind(this));
6813 if (config.interaction_enabled) {
6814 if (useCssRule) {
6815 [["." + $LEGEND.legendItem, "cursor:pointer"], ["." + $LEGEND.legendItem + " text", "pointer-events:none"], ["." + $LEGEND.legendItemPoint + " text", "pointer-events:none"], ["." + $LEGEND.legendItemTile, "pointer-events:none"], ["." + $LEGEND.legendItemEvent, "fill-opacity:0"]].forEach(function (v) {
6816 _newArrowCheck(this, _this3);
6817 var selector = v[0],
6818 props = v[1];
6819 $$.setCssRule(!1, selector, [props])($el.legend);
6820 }.bind(this));
6821 }
6822 item.style("cursor", $$.getStylePropValue("pointer")).on("click", function (event, id) {
6823 if (!callFn(config.legend_item_onclick, api, id)) {
6824 if (event.altKey) {
6825 api.hide();
6826 api.show(id);
6827 } else {
6828 api.toggle(id);
6829 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused, !1);
6830 }
6831 }
6832 isTouch && $$.hideTooltip();
6833 });
6834 isTouch || item.on("mouseout", function (event, id) {
6835 if (!callFn(config.legend_item_onout, api, id)) {
6836 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused, !1);
6837 if (hasGauge) {
6838 $$.undoMarkOverlapped($$, "." + $GAUGE.gaugeValue);
6839 }
6840 $$.api.revert();
6841 }
6842 }).on("mouseover", function (event, id) {
6843 if (!callFn(config.legend_item_onover, api, id)) {
6844 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused, !0);
6845 if (hasGauge) {
6846 $$.markOverlapped(id, $$, "." + $GAUGE.gaugeValue);
6847 }
6848 if (!state.transiting && $$.isTargetToShow(id)) {
6849 api.focus(id);
6850 }
6851 }
6852 });
6853 }
6854 },
6855 /**
6856 * Update the legend
6857 * @param {Array} targetIds ID's of target
6858 * @param {object} options withTransform : Whether to use the transform property / withTransitionForTransform: Whether transition is used when using the transform property / withTransition : whether or not to transition.
6859 * @private
6860 */
6861 updateLegendElement: function updateLegendElement(targetIds, options) {
6862 var _this4 = this,
6863 $$ = this,
6864 config = $$.config,
6865 state = $$.state,
6866 legend = $$.$el.legend,
6867 $T = $$.$T,
6868 legendType = config.legend_item_tile_type,
6869 isRectangle = legendType !== "circle",
6870 legendItemR = config.legend_item_tile_r,
6871 itemTileSize = {
6872 width: isRectangle ? config.legend_item_tile_width : legendItemR * 2,
6873 height: isRectangle ? config.legend_item_tile_height : legendItemR * 2
6874 },
6875 dimension = {
6876 padding: {
6877 top: 4,
6878 right: 10
6879 },
6880 max: {
6881 width: 0,
6882 height: 0
6883 },
6884 posMin: 10,
6885 step: 0,
6886 tileWidth: itemTileSize.width + 5,
6887 totalLength: 0
6888 },
6889 sizes = {
6890 offsets: {},
6891 widths: {},
6892 heights: {},
6893 margins: [0],
6894 steps: {}
6895 },
6896 xForLegend,
6897 yForLegend,
6898 background,
6899 targetIdz = targetIds.filter(function (id) {
6900 _newArrowCheck(this, _this4);
6901 return !isDefined(config.data_names[id]) || config.data_names[id] !== null;
6902 }.bind(this)),
6903 withTransition = options.withTransition,
6904 updatePositions = $$.getUpdateLegendPositions(targetIdz, dimension, sizes);
6905 if (state.isLegendInset) {
6906 dimension.step = config.legend_inset_step ? config.legend_inset_step : targetIdz.length;
6907 $$.updateLegendStep(dimension.step);
6908 }
6909 if (state.isLegendRight) {
6910 xForLegend = function (id) {
6911 _newArrowCheck(this, _this4);
6912 return dimension.max.width * sizes.steps[id];
6913 }.bind(this);
6914 yForLegend = function (id) {
6915 _newArrowCheck(this, _this4);
6916 return sizes.margins[sizes.steps[id]] + sizes.offsets[id];
6917 }.bind(this);
6918 } else if (state.isLegendInset) {
6919 xForLegend = function (id) {
6920 _newArrowCheck(this, _this4);
6921 return dimension.max.width * sizes.steps[id] + 10;
6922 }.bind(this);
6923 yForLegend = function (id) {
6924 _newArrowCheck(this, _this4);
6925 return sizes.margins[sizes.steps[id]] + sizes.offsets[id];
6926 }.bind(this);
6927 } else {
6928 xForLegend = function (id) {
6929 _newArrowCheck(this, _this4);
6930 return sizes.margins[sizes.steps[id]] + sizes.offsets[id];
6931 }.bind(this);
6932 yForLegend = function (id) {
6933 _newArrowCheck(this, _this4);
6934 return dimension.max.height * sizes.steps[id];
6935 }.bind(this);
6936 }
6937 var posFn = {
6938 xText: function xText(id, i) {
6939 _newArrowCheck(this, _this4);
6940 return xForLegend(id, i) + 4 + itemTileSize.width;
6941 }.bind(this),
6942 xRect: function xRect(id, i) {
6943 _newArrowCheck(this, _this4);
6944 return xForLegend(id, i);
6945 }.bind(this),
6946 x1Tile: function x1Tile(id, i) {
6947 _newArrowCheck(this, _this4);
6948 return xForLegend(id, i) - 2;
6949 }.bind(this),
6950 x2Tile: function x2Tile(id, i) {
6951 _newArrowCheck(this, _this4);
6952 return xForLegend(id, i) - 2 + itemTileSize.width;
6953 }.bind(this),
6954 yText: function yText(id, i) {
6955 _newArrowCheck(this, _this4);
6956 return yForLegend(id, i) + 9;
6957 }.bind(this),
6958 yRect: function yRect(id, i) {
6959 _newArrowCheck(this, _this4);
6960 return yForLegend(id, i) - 5;
6961 }.bind(this),
6962 yTile: function yTile(id, i) {
6963 _newArrowCheck(this, _this4);
6964 return yForLegend(id, i) + 4;
6965 }.bind(this)
6966 };
6967 $$.generateLegendItem(targetIdz, itemTileSize, updatePositions, posFn);
6968
6969 // Set background for inset legend
6970 background = legend.select("." + $LEGEND.legendBackground + " rect");
6971 if (state.isLegendInset && dimension.max.width > 0 && background.size() === 0) {
6972 background = legend.insert("g", "." + $LEGEND.legendItem).attr("class", $LEGEND.legendBackground).append("rect");
6973 }
6974 var texts = legend.selectAll("text").data(targetIdz).text(function (id) {
6975 _newArrowCheck(this, _this4);
6976 return isDefined(config.data_names[id]) ? config.data_names[id] : id;
6977 }.bind(this)) // MEMO: needed for update
6978 .each(function (id, i) {
6979 updatePositions(this, id, i);
6980 });
6981 $T(texts, withTransition).attr("x", posFn.xText).attr("y", posFn.yText);
6982 var rects = legend.selectAll("rect." + $LEGEND.legendItemEvent).data(targetIdz);
6983 $T(rects, withTransition).attr("width", function (id) {
6984 _newArrowCheck(this, _this4);
6985 return sizes.widths[id];
6986 }.bind(this)).attr("height", function (id) {
6987 _newArrowCheck(this, _this4);
6988 return sizes.heights[id];
6989 }.bind(this)).attr("x", posFn.xRect).attr("y", posFn.yRect);
6990
6991 // update legend items position
6992 $$.updateLegendItemPos(targetIdz, withTransition, posFn);
6993 if (background) {
6994 $T(background, withTransition).attr("height", $$.getLegendHeight() - 12).attr("width", dimension.max.width * (dimension.step + 1) + 10);
6995 }
6996
6997 // Update all to reflect change of legend
6998 $$.updateLegendItemWidth(dimension.max.width);
6999 $$.updateLegendItemHeight(dimension.max.height);
7000 $$.updateLegendStep(dimension.step);
7001 },
7002 /**
7003 * Get position update function
7004 * @param {Array} targetIdz Data ids
7005 * @param {object} dimension Dimension object
7006 * @param {object} sizes Size object
7007 * @returns {Function} Update position function
7008 * @private
7009 */
7010 getUpdateLegendPositions: function getUpdateLegendPositions(targetIdz, dimension, sizes) {
7011 var $$ = this,
7012 config = $$.config,
7013 state = $$.state,
7014 isLegendRightOrInset = state.isLegendRight || state.isLegendInset;
7015 return function (textElement, id, index) {
7016 var _this5 = this,
7017 isLast = index === targetIdz.length - 1,
7018 box = $$.getLegendItemTextBox(id, textElement),
7019 itemWidth = box.width + dimension.tileWidth + (isLast && !isLegendRightOrInset ? 0 : dimension.padding.right) + config.legend_padding,
7020 itemHeight = box.height + dimension.padding.top,
7021 itemLength = isLegendRightOrInset ? itemHeight : itemWidth,
7022 areaLength = isLegendRightOrInset ? $$.getLegendHeight() : $$.getLegendWidth(),
7023 margin,
7024 updateValues = function (id2, withoutStep) {
7025 if (!withoutStep) {
7026 margin = (areaLength - dimension.totalLength - itemLength) / 2;
7027 if (margin < dimension.posMin) {
7028 margin = (areaLength - itemLength) / 2;
7029 dimension.totalLength = 0;
7030 dimension.step++;
7031 }
7032 }
7033 sizes.steps[id2] = dimension.step;
7034 sizes.margins[dimension.step] = state.isLegendInset ? 10 : margin;
7035 sizes.offsets[id2] = dimension.totalLength;
7036 dimension.totalLength += itemLength;
7037 };
7038 if (index === 0) {
7039 dimension.totalLength = 0;
7040 dimension.step = 0;
7041 dimension.max.width = 0;
7042 dimension.max.height = 0;
7043 }
7044 if (config.legend_show && !$$.isLegendToShow(id)) {
7045 sizes.widths[id] = 0;
7046 sizes.heights[id] = 0;
7047 sizes.steps[id] = 0;
7048 sizes.offsets[id] = 0;
7049 return;
7050 }
7051 sizes.widths[id] = itemWidth;
7052 sizes.heights[id] = itemHeight;
7053 if (!dimension.max.width || itemWidth >= dimension.max.width) {
7054 dimension.max.width = itemWidth;
7055 }
7056 if (!dimension.max.height || itemHeight >= dimension.max.height) {
7057 dimension.max.height = itemHeight;
7058 }
7059 var maxLength = isLegendRightOrInset ? dimension.max.height : dimension.max.width;
7060 if (config.legend_equally) {
7061 Object.keys(sizes.widths).forEach(function (id2) {
7062 _newArrowCheck(this, _this5);
7063 return sizes.widths[id2] = dimension.max.width;
7064 }.bind(this));
7065 Object.keys(sizes.heights).forEach(function (id2) {
7066 _newArrowCheck(this, _this5);
7067 return sizes.heights[id2] = dimension.max.height;
7068 }.bind(this));
7069 margin = (areaLength - maxLength * targetIdz.length) / 2;
7070 if (margin < dimension.posMin) {
7071 dimension.totalLength = 0;
7072 dimension.step = 0;
7073 targetIdz.forEach(function (id2) {
7074 _newArrowCheck(this, _this5);
7075 return updateValues(id2);
7076 }.bind(this));
7077 } else {
7078 updateValues(id, !0);
7079 }
7080 } else {
7081 updateValues(id);
7082 }
7083 };
7084 },
7085 /**
7086 * Generate legend item elements
7087 * @param {Array} targetIdz Data ids
7088 * @param {object} itemTileSize Item tile size {width, height}
7089 * @param {Function} updatePositions Update position function
7090 * @param {object} posFn Position functions
7091 * @private
7092 */
7093 generateLegendItem: function generateLegendItem(targetIdz, itemTileSize, updatePositions, posFn) {
7094 var _this6 = this,
7095 $$ = this,
7096 config = $$.config,
7097 state = $$.state,
7098 legend = $$.$el.legend,
7099 usePoint = config.legend_usePoint,
7100 legendItemR = config.legend_item_tile_r,
7101 legendType = config.legend_item_tile_type,
7102 isRectangle = legendType !== "circle",
7103 isLegendRightOrInset = state.isLegendRight || state.isLegendInset,
7104 l = legend.selectAll("." + $LEGEND.legendItem).data(targetIdz).enter().append("g");
7105 $$.setLegendItem(l);
7106 l.append("text").text(function (id) {
7107 _newArrowCheck(this, _this6);
7108 return isDefined(config.data_names[id]) ? config.data_names[id] : id;
7109 }.bind(this)).each(function (id, i) {
7110 updatePositions(this, id, i);
7111 }).style("pointer-events", $$.getStylePropValue("none")).attr("x", isLegendRightOrInset ? posFn.xText : -200).attr("y", isLegendRightOrInset ? -200 : posFn.yText);
7112 l.append("rect").attr("class", $LEGEND.legendItemEvent).style("fill-opacity", $$.getStylePropValue("0")).attr("x", isLegendRightOrInset ? posFn.xRect : -200).attr("y", isLegendRightOrInset ? -200 : posFn.yRect);
7113 if (usePoint) {
7114 var _ids = [];
7115 l.append(function (d) {
7116 _newArrowCheck(this, _this6);
7117 var pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
7118 _ids.indexOf(d) === -1 && _ids.push(d);
7119 var point = pattern[_ids.indexOf(d) % pattern.length];
7120 if (point === "rectangle") {
7121 point = "rect";
7122 }
7123 return browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, "hasValidPointType" in $$ && $$.hasValidPointType(point) ? point : "use");
7124 }.bind(this)).attr("class", $LEGEND.legendItemPoint).style("fill", getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).attr("href", function (data, idx, selection) {
7125 _newArrowCheck(this, _this6);
7126 var node = selection[idx],
7127 nodeName = node.nodeName.toLowerCase(),
7128 id = $$.getTargetSelectorSuffix(data);
7129 return nodeName === "use" ? "#" + state.datetimeId + "-point" + id : undefined;
7130 }.bind(this));
7131 } else {
7132 l.append(isRectangle ? "line" : legendType).attr("class", $LEGEND.legendItemTile).style("stroke", getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).call(function (selection) {
7133 _newArrowCheck(this, _this6);
7134 if (legendType === "circle") {
7135 selection.attr("r", legendItemR).style("fill", getLegendColor.bind($$)).attr("cx", isLegendRightOrInset ? posFn.x2Tile : -200).attr("cy", isLegendRightOrInset ? -200 : posFn.yTile);
7136 } else if (isRectangle) {
7137 selection.attr("stroke-width", itemTileSize.height).attr("x1", isLegendRightOrInset ? posFn.x1Tile : -200).attr("y1", isLegendRightOrInset ? -200 : posFn.yTile).attr("x2", isLegendRightOrInset ? posFn.x2Tile : -200).attr("y2", isLegendRightOrInset ? -200 : posFn.yTile);
7138 }
7139 }.bind(this));
7140 }
7141 },
7142 /**
7143 * Update legend item position
7144 * @param {Array} targetIdz Data ids
7145 * @param {boolean} withTransition Whether or not to apply transition
7146 * @param {object} posFn Position functions
7147 * @private
7148 */
7149 updateLegendItemPos: function updateLegendItemPos(targetIdz, withTransition, posFn) {
7150 var _this8 = this,
7151 $$ = this,
7152 config = $$.config,
7153 legend = $$.$el.legend,
7154 $T = $$.$T,
7155 usePoint = config.legend_usePoint,
7156 legendType = config.legend_item_tile_type;
7157 if (usePoint) {
7158 var tiles = legend.selectAll("." + $LEGEND.legendItemPoint).data(targetIdz);
7159 $T(tiles, withTransition).each(function () {
7160 var _this7 = this,
7161 nodeName = this.nodeName.toLowerCase(),
7162 pointR = config.point_r,
7163 x = "x",
7164 y = "y",
7165 xOffset = 2,
7166 yOffset = 2.5,
7167 radius = null,
7168 width = null,
7169 height = null;
7170 if (nodeName === "circle") {
7171 var size = pointR * .2;
7172 x = "cx";
7173 y = "cy";
7174 radius = pointR + size;
7175 xOffset = pointR * 2;
7176 yOffset = -size;
7177 } else if (nodeName === "rect") {
7178 var _size = pointR * 2.5;
7179 width = _size;
7180 height = _size;
7181 yOffset = 3;
7182 }
7183 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).attr(x, function (d) {
7184 _newArrowCheck(this, _this7);
7185 return posFn.x1Tile(d) + xOffset;
7186 }.bind(this)).attr(y, function (d) {
7187 _newArrowCheck(this, _this7);
7188 return posFn.yTile(d) - yOffset;
7189 }.bind(this)).attr("r", radius).attr("width", width).attr("height", height);
7190 });
7191 } else {
7192 var _tiles = legend.selectAll("." + $LEGEND.legendItemTile).data(targetIdz);
7193 $T(_tiles, withTransition).style("stroke", getLegendColor.bind($$)).call(function (selection) {
7194 var _this9 = this;
7195 _newArrowCheck(this, _this8);
7196 if (legendType === "circle") {
7197 selection.attr("cx", function (d) {
7198 _newArrowCheck(this, _this9);
7199 var x2 = posFn.x2Tile(d);
7200 return x2 - (x2 - posFn.x1Tile(d)) / 2;
7201 }.bind(this)).attr("cy", posFn.yTile);
7202 } else if (legendType !== "circle") {
7203 selection.attr("x1", posFn.x1Tile).attr("y1", posFn.yTile).attr("x2", posFn.x2Tile).attr("y2", posFn.yTile);
7204 }
7205 }.bind(this));
7206 }
7207 }
7208});
7209// EXTERNAL MODULE: external {"commonjs":"d3-transition","commonjs2":"d3-transition","amd":"d3-transition","root":"d3"}
7210var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_ = __webpack_require__(8);
7211;// CONCATENATED MODULE: ./src/ChartInternal/internals/redraw.ts
7212
7213/**
7214 * Copyright (c) 2017 ~ present NAVER Corp.
7215 * billboard.js project is licensed under the MIT license
7216 */
7217
7218
7219
7220
7221/* harmony default export */ var redraw = ({
7222 redraw: function redraw(options) {
7223 var _$$$axis,
7224 _this = this;
7225 if (options === void 0) {
7226 options = {};
7227 }
7228 var $$ = this,
7229 config = $$.config,
7230 state = $$.state,
7231 $el = $$.$el,
7232 main = $el.main;
7233 state.redrawing = !0;
7234 var targetsToShow = $$.filterTargetsToShow($$.data.targets),
7235 _options = options,
7236 flow = _options.flow,
7237 initializing = _options.initializing,
7238 wth = $$.getWithOption(options),
7239 duration = wth.Transition ? config.transition_duration : 0,
7240 durationForExit = wth.TransitionForExit ? duration : 0,
7241 durationForAxis = wth.TransitionForAxis ? duration : 0,
7242 transitions = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.generateTransitions(durationForAxis);
7243 $$.updateSizes(initializing);
7244
7245 // update legend and transform each g
7246 if (wth.Legend && config.legend_show) {
7247 options.withTransition = !!duration;
7248 $$.updateLegend($$.mapToIds($$.data.targets), options, transitions);
7249 } else if (wth.Dimension) {
7250 // need to update dimension (e.g. axis.y.tick.values) because y tick values should change
7251 // no need to update axis in it because they will be updated in redraw()
7252 $$.updateDimension(!0);
7253 }
7254
7255 // update circleY based on updated parameters
7256 if (!$$.hasArcType() || state.hasRadar) {
7257 $$.updateCircleY && ($$.circleY = $$.updateCircleY());
7258 }
7259
7260 // update axis
7261 if (state.hasAxis) {
7262 // @TODO: Make 'init' state to be accessible everywhere not passing as argument.
7263 $$.axis.redrawAxis(targetsToShow, wth, transitions, flow, initializing);
7264
7265 // Data empty label positioning and text.
7266 config.data_empty_label_text && main.select("text." + $TEXT.text + "." + $COMMON.empty).attr("x", state.width / 2).attr("y", state.height / 2).text(config.data_empty_label_text).style("display", targetsToShow.length ? "none" : null);
7267
7268 // grid
7269 $$.hasGrid() && $$.updateGrid();
7270
7271 // rect for regions
7272 config.regions.length && $$.updateRegion();
7273 ["bar", "candlestick", "line", "area"].forEach(function (v) {
7274 _newArrowCheck(this, _this);
7275 var name = capitalize(v);
7276 if (/^(line|area)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
7277 $$["update" + name](wth.TransitionForExit);
7278 }
7279 }.bind(this));
7280
7281 // circles for select
7282 $el.text && main.selectAll("." + $SELECT.selectedCircles).filter($$.isBarType.bind($$)).selectAll("circle").remove();
7283
7284 // event rects will redrawn when flow called
7285 if (config.interaction_enabled && !flow && wth.EventRect) {
7286 $$.redrawEventRect();
7287 $$.bindZoomEvent == null ? void 0 : $$.bindZoomEvent();
7288 }
7289 } else {
7290 // arc
7291 $el.arcs && $$.redrawArc(duration, durationForExit, wth.Transform);
7292
7293 // radar
7294 $el.radar && $$.redrawRadar();
7295
7296 // polar
7297 $el.polar && $$.redrawPolar();
7298 }
7299
7300 // @TODO: Axis & Radar type
7301 if (!state.resizing && ($$.hasPointType() || state.hasRadar)) {
7302 $$.updateCircle();
7303 }
7304
7305 // text
7306 $$.hasDataLabel() && !$$.hasArcType(null, ["radar"]) && $$.updateText();
7307
7308 // title
7309 $$.redrawTitle == null ? void 0 : $$.redrawTitle();
7310 initializing && $$.updateTypesElements();
7311 $$.generateRedrawList(targetsToShow, flow, duration, wth.Subchart);
7312 $$.callPluginHook("$redraw", options, duration);
7313 },
7314 /**
7315 * Generate redraw list
7316 * @param {object} targets targets data to be shown
7317 * @param {object} flow flow object
7318 * @param {number} duration duration value
7319 * @param {boolean} withSubchart whether or not to show subchart
7320 * @private
7321 */
7322 generateRedrawList: function generateRedrawList(targets, flow, duration, withSubchart) {
7323 var _this2 = this,
7324 $$ = this,
7325 config = $$.config,
7326 state = $$.state,
7327 shape = $$.getDrawShape();
7328 if (state.hasAxis) {
7329 // subchart
7330 config.subchart_show && $$.redrawSubchart(withSubchart, duration, shape);
7331 }
7332
7333 // generate flow
7334 var flowFn = flow && $$.generateFlow({
7335 targets: targets,
7336 flow: flow,
7337 duration: flow.duration,
7338 shape: shape,
7339 xv: $$.xv.bind($$)
7340 }),
7341 withTransition = (duration || flowFn) && isTabVisible(),
7342 redrawList = $$.getRedrawList(shape, flow, flowFn, withTransition),
7343 afterRedraw = function () {
7344 _newArrowCheck(this, _this2);
7345 flowFn && flowFn();
7346 state.redrawing = !1;
7347 callFn(config.onrendered, $$.api);
7348 }.bind(this);
7349 if (afterRedraw) {
7350 // Only use transition when current tab is visible.
7351 if (withTransition && redrawList.length) {
7352 // Wait for end of transitions for callback
7353 var waitForDraw = generateWait();
7354
7355 // transition should be derived from one transition
7356 (0,external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_.transition)().duration(duration).each(function () {
7357 var _this3 = this;
7358 _newArrowCheck(this, _this2);
7359 redrawList.reduce(function (acc, t1) {
7360 _newArrowCheck(this, _this3);
7361 return acc.concat(t1);
7362 }.bind(this), []).forEach(function (t) {
7363 _newArrowCheck(this, _this3);
7364 return waitForDraw.add(t);
7365 }.bind(this));
7366 }.bind(this)).call(waitForDraw, afterRedraw);
7367 } else if (!state.transiting) {
7368 afterRedraw();
7369 }
7370 }
7371
7372 // update fadein condition
7373 $$.mapToIds($$.data.targets).forEach(function (id) {
7374 _newArrowCheck(this, _this2);
7375 state.withoutFadeIn[id] = !0;
7376 }.bind(this));
7377 },
7378 getRedrawList: function getRedrawList(shape, flow, flowFn, withTransition) {
7379 var _this4 = this,
7380 $$ = this,
7381 config = $$.config,
7382 _$$$state = $$.state,
7383 hasAxis = _$$$state.hasAxis,
7384 hasRadar = _$$$state.hasRadar,
7385 grid = $$.$el.grid,
7386 _shape$pos = shape.pos,
7387 cx = _shape$pos.cx,
7388 cy = _shape$pos.cy,
7389 xForText = _shape$pos.xForText,
7390 yForText = _shape$pos.yForText,
7391 list = [];
7392 if (hasAxis) {
7393 if (config.grid_x_lines.length || config.grid_y_lines.length) {
7394 list.push($$.redrawGrid(withTransition));
7395 }
7396 if (config.regions.length) {
7397 list.push($$.redrawRegion(withTransition));
7398 }
7399 Object.keys(shape.type).forEach(function (v) {
7400 _newArrowCheck(this, _this4);
7401 var name = capitalize(v),
7402 drawFn = shape.type[v];
7403 if (/^(area|line)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
7404 list.push($$["redraw" + name](drawFn, withTransition));
7405 }
7406 }.bind(this));
7407 !flow && grid.main && list.push($$.updateGridFocus());
7408 }
7409 if (!$$.hasArcType() || hasRadar) {
7410 notEmpty(config.data_labels) && config.data_labels !== !1 && list.push($$.redrawText(xForText, yForText, flow, withTransition));
7411 }
7412 if (($$.hasPointType() || hasRadar) && !config.point_focus_only) {
7413 $$.redrawCircle && list.push($$.redrawCircle(cx, cy, withTransition, flowFn));
7414 }
7415 return list;
7416 },
7417 updateAndRedraw: function updateAndRedraw(options) {
7418 if (options === void 0) {
7419 options = {};
7420 }
7421 var $$ = this,
7422 config = $$.config,
7423 state = $$.state,
7424 transitions;
7425 // same with redraw
7426 options.withTransition = getOption(options, "withTransition", !0);
7427 options.withTransform = getOption(options, "withTransform", !1);
7428 options.withLegend = getOption(options, "withLegend", !1);
7429
7430 // NOT same with redraw
7431 options.withUpdateXDomain = !0;
7432 options.withUpdateOrgXDomain = !0;
7433 options.withTransitionForExit = !1;
7434 options.withTransitionForTransform = getOption(options, "withTransitionForTransform", options.withTransition);
7435
7436 // MEMO: called in updateLegend in redraw if withLegend
7437 if (!(options.withLegend && config.legend_show)) {
7438 if (state.hasAxis) {
7439 transitions = $$.axis.generateTransitions(options.withTransitionForAxis ? config.transition_duration : 0);
7440 }
7441
7442 // Update scales
7443 $$.updateScales();
7444 $$.updateSvgSize();
7445
7446 // Update g positions
7447 $$.transformAll(options.withTransitionForTransform, transitions);
7448 }
7449
7450 // Draw with new sizes & scales
7451 $$.redraw(options, transitions);
7452 },
7453 /**
7454 * Redraw without rescale
7455 * @private
7456 */
7457 redrawWithoutRescale: function redrawWithoutRescale() {
7458 this.redraw({
7459 withY: !1,
7460 withDimension: !1,
7461 withLegend: !1,
7462 withSubchart: !1,
7463 withEventRect: !1,
7464 withTransitionForAxis: !1
7465 });
7466 }
7467});
7468;// CONCATENATED MODULE: ./src/ChartInternal/internals/scale.ts
7469
7470/**
7471 * Copyright (c) 2017 ~ present NAVER Corp.
7472 * billboard.js project is licensed under the MIT license
7473 */
7474
7475
7476/**
7477 * Get scale
7478 * @param {string} [type='linear'] Scale type
7479 * @param {number} [min] Min range
7480 * @param {number} [max] Max range
7481 * @returns {d3.scaleLinear|d3.scaleTime} scale
7482 * @private
7483 */
7484function getScale(type, min, max) {
7485 if (type === void 0) {
7486 type = "linear";
7487 }
7488 if (min === void 0) {
7489 min = 0;
7490 }
7491 if (max === void 0) {
7492 max = 1;
7493 }
7494 var scale = {
7495 linear: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear,
7496 log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSymlog,
7497 _log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLog,
7498 time: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleTime,
7499 utc: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleUtc
7500 }[type]();
7501 scale.type = type;
7502 /_?log/.test(type) && scale.clamp(!0);
7503 return scale.range([min, max]);
7504}
7505/* harmony default export */ var scale = ({
7506 /**
7507 * Get x Axis scale function
7508 * @param {number} min Min value
7509 * @param {number} max Max value
7510 * @param {Array} domain Domain value
7511 * @param {Function} offset The offset getter to be sum
7512 * @returns {Function} scale
7513 * @private
7514 */
7515 getXScale: function getXScale(min, max, domain, offset) {
7516 var $$ = this,
7517 scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
7518 return $$.getCustomizedScale(domain ? scale.domain(domain) : scale, offset);
7519 },
7520 /**
7521 * Get y Axis scale function
7522 * @param {string} id Axis id: 'y' or 'y2'
7523 * @param {number} min Min value
7524 * @param {number} max Max value
7525 * @param {Array} domain Domain value
7526 * @returns {Function} Scale function
7527 * @private
7528 */
7529 getYScale: function getYScale(id, min, max, domain) {
7530 var $$ = this,
7531 scale = getScale($$.axis.getAxisType(id), min, max);
7532 domain && scale.domain(domain);
7533 return scale;
7534 },
7535 /**
7536 * Get y Axis scale
7537 * @param {string} id Axis id
7538 * @param {boolean} isSub Weather is sub Axis
7539 * @returns {Function} Scale function
7540 * @private
7541 */
7542 getYScaleById: function getYScaleById(id, isSub) {
7543 if (isSub === void 0) {
7544 isSub = !1;
7545 }
7546 var isY2 = this.axis.getId(id) === "y2",
7547 key = isSub ? isY2 ? "subY2" : "subY" : isY2 ? "y2" : "y";
7548 return this.scale[key];
7549 },
7550 /**
7551 * Get customized scale
7552 * @param {d3.scaleLinear|d3.scaleTime} scaleValue Scale function
7553 * @param {Function} offsetValue Offset getter to be sum
7554 * @returns {Function} Scale function
7555 * @private
7556 */
7557 getCustomizedScale: function getCustomizedScale(scaleValue, offsetValue) {
7558 var _this = this,
7559 $$ = this,
7560 offset = offsetValue || function () {
7561 _newArrowCheck(this, _this);
7562 return $$.axis.x.tickOffset();
7563 }.bind(this),
7564 scale = function (d, raw) {
7565 var v = scaleValue(d) + offset();
7566 return raw ? v : Math.ceil(v);
7567 };
7568 // copy original scale methods
7569 for (var key in scaleValue) {
7570 scale[key] = scaleValue[key];
7571 }
7572 scale.orgDomain = function () {
7573 _newArrowCheck(this, _this);
7574 return scaleValue.domain();
7575 }.bind(this);
7576 scale.orgScale = function () {
7577 _newArrowCheck(this, _this);
7578 return scaleValue;
7579 }.bind(this);
7580
7581 // define custom domain() for categorized axis
7582 if ($$.axis.isCategorized()) {
7583 scale.domain = function (domainValue) {
7584 var domain = domainValue;
7585 if (!arguments.length) {
7586 domain = this.orgDomain();
7587 return [domain[0], domain[1] + 1];
7588 }
7589 scaleValue.domain(domain);
7590 return scale;
7591 };
7592 }
7593 return scale;
7594 },
7595 /**
7596 * Update scale
7597 * @param {boolean} isInit Param is given at the init rendering
7598 * @param {boolean} updateXDomain If update x domain
7599 * @private
7600 */
7601 updateScales: function updateScales(isInit, updateXDomain) {
7602 var _this2 = this;
7603 if (updateXDomain === void 0) {
7604 updateXDomain = !0;
7605 }
7606 var $$ = this,
7607 axis = $$.axis,
7608 config = $$.config,
7609 format = $$.format,
7610 org = $$.org,
7611 scale = $$.scale,
7612 _$$$state = $$.state,
7613 width = _$$$state.width,
7614 height = _$$$state.height,
7615 width2 = _$$$state.width2,
7616 height2 = _$$$state.height2,
7617 hasAxis = _$$$state.hasAxis;
7618 if (hasAxis) {
7619 var _scale$x,
7620 isRotated = config.axis_rotated,
7621 resettedPadding = $$.getResettedPadding(1),
7622 min = {
7623 x: isRotated ? resettedPadding : 0,
7624 y: isRotated ? 0 : height,
7625 subX: isRotated ? 1 : 0,
7626 subY: isRotated ? 0 : height2
7627 },
7628 max = {
7629 x: isRotated ? height : width,
7630 y: isRotated ? width : resettedPadding,
7631 subX: isRotated ? height : width,
7632 subY: isRotated ? width2 : 1
7633 },
7634 xDomain = updateXDomain && ((_scale$x = scale.x) == null ? void 0 : _scale$x.orgDomain()),
7635 xSubDomain = updateXDomain && org.xDomain;
7636 scale.x = $$.getXScale(min.x, max.x, xDomain, function () {
7637 _newArrowCheck(this, _this2);
7638 return axis.x.tickOffset();
7639 }.bind(this));
7640 scale.subX = $$.getXScale(min.x, max.x, xSubDomain, function (d) {
7641 var _axis$subX;
7642 _newArrowCheck(this, _this2);
7643 return d % 1 ? 0 : ((_axis$subX = axis.subX) != null ? _axis$subX : axis.x).tickOffset();
7644 }.bind(this));
7645 format.xAxisTick = axis.getXAxisTickFormat();
7646 format.subXAxisTick = axis.getXAxisTickFormat(!0);
7647 axis.setAxis("x", scale.x, config.axis_x_tick_outer, isInit);
7648 if (config.subchart_show) {
7649 axis.setAxis("subX", scale.subX, config.axis_x_tick_outer, isInit);
7650 }
7651
7652 // y Axis
7653 scale.y = $$.getYScale("y", min.y, max.y, scale.y ? scale.y.domain() : config.axis_y_default);
7654 scale.subY = $$.getYScale("y", min.subY, max.subY, scale.subY ? scale.subY.domain() : config.axis_y_default);
7655 axis.setAxis("y", scale.y, config.axis_y_tick_outer, isInit);
7656
7657 // y2 Axis
7658 if (config.axis_y2_show) {
7659 scale.y2 = $$.getYScale("y2", min.y, max.y, scale.y2 ? scale.y2.domain() : config.axis_y2_default);
7660 scale.subY2 = $$.getYScale("y2", min.subY, max.subY, scale.subY2 ? scale.subY2.domain() : config.axis_y2_default);
7661 axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
7662 }
7663 } else {
7664 // update for arc
7665 $$.updateArc == null ? void 0 : $$.updateArc();
7666 }
7667 },
7668 /**
7669 * Get the zoom or unzoomed scaled value
7670 * @param {Date|number|object} d Data value
7671 * @returns {number|null}
7672 * @private
7673 */
7674 xx: function xx(d) {
7675 var $$ = this,
7676 config = $$.config,
7677 _$$$scale = $$.scale,
7678 x = _$$$scale.x,
7679 zoom = _$$$scale.zoom,
7680 fn = config.zoom_enabled && zoom ? zoom : x;
7681 return d ? fn(isValue(d.x) ? d.x : d) : null;
7682 },
7683 xv: function xv(d) {
7684 var $$ = this,
7685 axis = $$.axis,
7686 config = $$.config,
7687 _$$$scale2 = $$.scale,
7688 x = _$$$scale2.x,
7689 zoom = _$$$scale2.zoom,
7690 fn = config.zoom_enabled && zoom ? zoom : x,
7691 value = $$.getBaseValue(d);
7692 if (axis.isTimeSeries()) {
7693 value = parseDate.call($$, value);
7694 } else if (axis.isCategorized() && isString(value)) {
7695 value = config.axis_x_categories.indexOf(value);
7696 }
7697 return Math.ceil(fn(value));
7698 },
7699 yv: function yv(d) {
7700 var $$ = this,
7701 _$$$scale3 = $$.scale,
7702 y = _$$$scale3.y,
7703 y2 = _$$$scale3.y2,
7704 yScale = d.axis && d.axis === "y2" ? y2 : y;
7705 return Math.ceil(yScale($$.getBaseValue(d)));
7706 },
7707 subxx: function subxx(d) {
7708 return d ? this.scale.subX(d.x) : null;
7709 }
7710});
7711// EXTERNAL MODULE: external {"commonjs":"d3-shape","commonjs2":"d3-shape","amd":"d3-shape","root":"d3"}
7712var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webpack_require__(9);
7713;// CONCATENATED MODULE: ./src/ChartInternal/shape/shape.ts
7714
7715/**
7716 * Copyright (c) 2017 ~ present NAVER Corp.
7717 * billboard.js project is licensed under the MIT license
7718 */
7719
7720
7721
7722
7723/* harmony default export */ var shape = ({
7724 /**
7725 * Get the shape draw function
7726 * @returns {object}
7727 * @private
7728 */
7729 getDrawShape: function getDrawShape() {
7730 var _this = this,
7731 $$ = this,
7732 isRotated = $$.config.axis_rotated,
7733 hasRadar = $$.state.hasRadar,
7734 shape = {
7735 type: {},
7736 indices: {},
7737 pos: {}
7738 };
7739 ["bar", "candlestick", "line", "area"].forEach(function (v) {
7740 _newArrowCheck(this, _this);
7741 var name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
7742 if ($$.hasType(v) || $$.hasTypeOf(name) || v === "line" && ($$.hasType("bubble") || $$.hasType("scatter"))) {
7743 var indices = $$.getShapeIndices($$["is" + name + "Type"]),
7744 drawFn = $$["generateDraw" + name];
7745 shape.indices[v] = indices;
7746 shape.type[v] = drawFn ? drawFn.bind($$)(indices, !1) : undefined;
7747 }
7748 }.bind(this));
7749 if (!$$.hasArcType() || hasRadar) {
7750 // generate circle x/y functions depending on updated params
7751 var cx = hasRadar ? $$.radarCircleX : isRotated ? $$.circleY : $$.circleX,
7752 cy = hasRadar ? $$.radarCircleY : isRotated ? $$.circleX : $$.circleY;
7753 shape.pos = {
7754 xForText: $$.generateXYForText(shape.indices, !0),
7755 yForText: $$.generateXYForText(shape.indices, !1),
7756 cx: (cx || function () {}).bind($$),
7757 cy: (cy || function () {}).bind($$)
7758 };
7759 }
7760 return shape;
7761 },
7762 /**
7763 * Get shape's indices according it's position
7764 *
7765 * From the below example, indices will be:
7766 * ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
7767 *
7768 * data1 data3 data1 data3
7769 * data2 data4 data2 data4
7770 * -------------------------
7771 * 0 1
7772 * @param {Function} typeFilter Chart type filter function
7773 * @returns {object} Indices object with its position
7774 */
7775 getShapeIndices: function getShapeIndices(typeFilter) {
7776 var _this2 = this,
7777 $$ = this,
7778 config = $$.config,
7779 xs = config.data_xs,
7780 hasXs = notEmpty(xs),
7781 indices = {},
7782 i = hasXs ? {} : 0;
7783 if (hasXs) {
7784 getUnique(Object.keys(xs).map(function (v) {
7785 _newArrowCheck(this, _this2);
7786 return xs[v];
7787 }.bind(this))).forEach(function (v) {
7788 _newArrowCheck(this, _this2);
7789 i[v] = 0;
7790 indices[v] = {};
7791 }.bind(this));
7792 }
7793 $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) {
7794 _newArrowCheck(this, _this2);
7795 var xKey = d.id in xs ? xs[d.id] : "",
7796 ind = xKey ? indices[xKey] : indices;
7797 for (var j = 0, groups; groups = config.data_groups[j]; j++) {
7798 if (groups.indexOf(d.id) < 0) {
7799 continue;
7800 }
7801 for (var k = 0, row; row = groups[k]; k++) {
7802 if (row in ind) {
7803 ind[d.id] = ind[row];
7804 break;
7805 }
7806 }
7807 }
7808 if (isUndefined(ind[d.id])) {
7809 ind[d.id] = xKey ? i[xKey]++ : i++;
7810 ind.__max__ = (xKey ? i[xKey] : i) - 1;
7811 }
7812 }.bind(this));
7813 return indices;
7814 },
7815 /**
7816 * Get indices value based on data ID value
7817 * @param {object} indices Indices object
7818 * @param {object} d Data row
7819 * @param {string} caller Caller function name (Used only for 'sparkline' plugin)
7820 * @returns {object} Indices object
7821 * @private
7822 */
7823 getIndices: function getIndices(indices, d) {
7824 var _this3 = this,
7825 $$ = this,
7826 _$$$config = $$.config,
7827 xs = _$$$config.data_xs,
7828 removeNull = _$$$config.bar_indices_removeNull,
7829 id = d.id,
7830 index = d.index;
7831 if ($$.isBarType(id) && removeNull) {
7832 var ind = {};
7833
7834 // redefine bar indices order
7835 $$.getAllValuesOnIndex(index, !0).forEach(function (v, i) {
7836 _newArrowCheck(this, _this3);
7837 ind[v.id] = i;
7838 ind.__max__ = i;
7839 }.bind(this));
7840 return ind;
7841 }
7842 return notEmpty(xs) ? indices[xs[id]] : indices;
7843 },
7844 /**
7845 * Get indices max number
7846 * @param {object} indices Indices object
7847 * @returns {number} Max number
7848 * @private
7849 */
7850 getIndicesMax: function getIndicesMax(indices) {
7851 var _this4 = this;
7852 return notEmpty(this.config.data_xs) ?
7853 // if is multiple xs, return total sum of xs' __max__ value
7854 Object.keys(indices).map(function (v) {
7855 _newArrowCheck(this, _this4);
7856 return indices[v].__max__ || 0;
7857 }.bind(this)).reduce(function (acc, curr) {
7858 _newArrowCheck(this, _this4);
7859 return acc + curr;
7860 }.bind(this)) : indices.__max__;
7861 },
7862 getShapeX: function getShapeX(offset, indices, isSub) {
7863 var _this5 = this,
7864 $$ = this,
7865 config = $$.config,
7866 scale = $$.scale,
7867 currScale = isSub ? scale.subX : scale.zoom || scale.x,
7868 barOverlap = config.bar_overlap,
7869 barPadding = config.bar_padding,
7870 sum = function (p, c) {
7871 _newArrowCheck(this, _this5);
7872 return p + c;
7873 }.bind(this),
7874 halfWidth = isObjectType(offset) && (offset._$total.length ? offset._$total.reduce(sum) / 2 : 0);
7875 return function (d) {
7876 _newArrowCheck(this, _this5);
7877 var ind = $$.getIndices(indices, d, "getShapeX"),
7878 index = d.id in ind ? ind[d.id] : 0,
7879 targetsNum = (ind.__max__ || 0) + 1,
7880 x = 0;
7881 if (notEmpty(d.x)) {
7882 var xPos = currScale(d.x, !0);
7883 if (halfWidth) {
7884 var offsetWidth = offset[d.id] || offset._$width;
7885 x = barOverlap ? xPos - offsetWidth / 2 : xPos - offsetWidth + offset._$total.slice(0, index + 1).reduce(sum) - halfWidth;
7886 } else {
7887 x = xPos - (isNumber(offset) ? offset : offset._$width) * (targetsNum / 2 - (barOverlap ? 1 : index));
7888 }
7889 }
7890
7891 // adjust x position for bar.padding option
7892 if (offset && x && targetsNum > 1 && barPadding) {
7893 if (index) {
7894 x += barPadding * index;
7895 }
7896 if (targetsNum > 2) {
7897 x -= (targetsNum - 1) * barPadding / 2;
7898 } else if (targetsNum === 2) {
7899 x -= barPadding / 2;
7900 }
7901 }
7902 return x;
7903 }.bind(this);
7904 },
7905 getShapeY: function getShapeY(isSub) {
7906 var _this6 = this,
7907 $$ = this,
7908 isStackNormalized = $$.isStackNormalized();
7909 return function (d) {
7910 _newArrowCheck(this, _this6);
7911 var value = d.value;
7912 if (isNumber(d)) {
7913 value = d;
7914 } else if (isStackNormalized) {
7915 value = $$.getRatio("index", d, !0);
7916 } else if ($$.isBubbleZType(d)) {
7917 value = $$.getBubbleZData(d.value, "y");
7918 } else if ($$.isBarRangeType(d)) {
7919 // TODO use range.getEnd() like method
7920 value = value[1];
7921 }
7922 return $$.getYScaleById(d.id, isSub)(value);
7923 }.bind(this);
7924 },
7925 /**
7926 * Get shape based y Axis min value
7927 * @param {string} id Data id
7928 * @returns {number}
7929 * @private
7930 */
7931 getShapeYMin: function getShapeYMin(id) {
7932 var $$ = this,
7933 axisId = $$.axis.getId(id),
7934 scale = $$.scale[axisId],
7935 _scale$domain = scale.domain(),
7936 yMin = _scale$domain[0],
7937 inverted = $$.config["axis_" + axisId + "_inverted"];
7938 return !$$.isGrouped(id) && !inverted && yMin > 0 ? yMin : 0;
7939 },
7940 /**
7941 * Get Shape's offset data
7942 * @param {Function} typeFilter Type filter function
7943 * @returns {object}
7944 * @private
7945 */
7946 getShapeOffsetData: function getShapeOffsetData(typeFilter) {
7947 var _this7 = this,
7948 $$ = this,
7949 targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))),
7950 isStackNormalized = $$.isStackNormalized(),
7951 shapeOffsetTargets = targets.map(function (target) {
7952 var _this8 = this;
7953 _newArrowCheck(this, _this7);
7954 var rowValues = target.values,
7955 values = {};
7956 if ($$.isStepType(target)) {
7957 rowValues = $$.convertValuesToStep(rowValues);
7958 }
7959 var rowValueMapByXValue = rowValues.reduce(function (out, d) {
7960 _newArrowCheck(this, _this8);
7961 var key = +d.x;
7962 out[key] = d;
7963 values[key] = isStackNormalized ? $$.getRatio("index", d, !0) : d.value;
7964 return out;
7965 }.bind(this), {});
7966 return {
7967 id: target.id,
7968 rowValues: rowValues,
7969 rowValueMapByXValue: rowValueMapByXValue,
7970 values: values
7971 };
7972 }.bind(this)),
7973 indexMapByTargetId = targets.reduce(function (out, _ref, index) {
7974 var id = _ref.id;
7975 _newArrowCheck(this, _this7);
7976 out[id] = index;
7977 return out;
7978 }.bind(this), {});
7979 return {
7980 indexMapByTargetId: indexMapByTargetId,
7981 shapeOffsetTargets: shapeOffsetTargets
7982 };
7983 },
7984 getShapeOffset: function getShapeOffset(typeFilter, indices, isSub) {
7985 var _this9 = this,
7986 $$ = this,
7987 _$$$getShapeOffsetDat = $$.getShapeOffsetData(typeFilter),
7988 shapeOffsetTargets = _$$$getShapeOffsetDat.shapeOffsetTargets,
7989 indexMapByTargetId = _$$$getShapeOffsetDat.indexMapByTargetId,
7990 groupsZeroAs = $$.config.data_groupsZeroAs;
7991 return function (d, idx) {
7992 var _this10 = this;
7993 _newArrowCheck(this, _this9);
7994 var id = d.id,
7995 value = d.value,
7996 x = d.x,
7997 ind = $$.getIndices(indices, d),
7998 scale = $$.getYScaleById(id, isSub);
7999 if ($$.isBarRangeType(d)) {
8000 // TODO use range.getStart()
8001 return scale(value[0]);
8002 }
8003 var dataXAsNumber = +x,
8004 y0 = scale(groupsZeroAs === "zero" ? 0 : $$.getShapeYMin(id)),
8005 offset = y0;
8006 shapeOffsetTargets.filter(function (t) {
8007 _newArrowCheck(this, _this10);
8008 return t.id !== id && ind[t.id] === ind[id];
8009 }.bind(this)).forEach(function (t) {
8010 _newArrowCheck(this, _this10);
8011 var tid = t.id,
8012 rowValueMapByXValue = t.rowValueMapByXValue,
8013 rowValues = t.rowValues,
8014 tvalues = t.values;
8015
8016 // for same stacked group (ind[tid] === ind[id])
8017 if (indexMapByTargetId[tid] < indexMapByTargetId[id]) {
8018 var _row,
8019 rValue = tvalues[dataXAsNumber],
8020 row = rowValues[idx];
8021 // check if the x values line up
8022 if (!row || +row.x !== dataXAsNumber) {
8023 row = rowValueMapByXValue[dataXAsNumber];
8024 }
8025 if (((_row = row) == null ? void 0 : _row.value) * value >= 0 && isNumber(rValue)) {
8026 var addOffset = value === 0 ? groupsZeroAs === "positive" && rValue > 0 || groupsZeroAs === "negative" && rValue < 0 : !0;
8027 if (addOffset) {
8028 offset += scale(rValue) - y0;
8029 }
8030 }
8031 }
8032 }.bind(this));
8033 return offset;
8034 }.bind(this);
8035 },
8036 getBarW: function getBarW(type, axis, targetsNum) {
8037 var _this11 = this,
8038 $$ = this,
8039 config = $$.config,
8040 org = $$.org,
8041 scale = $$.scale,
8042 maxDataCount = $$.getMaxDataCount(),
8043 isGrouped = type === "bar" && config.data_groups.length,
8044 configName = type + "_width",
8045 tickInterval = scale.zoom && !$$.axis.isCategorized() ? org.xDomain.map(function (v) {
8046 _newArrowCheck(this, _this11);
8047 return scale.zoom(v);
8048 }.bind(this)).reduce(function (a, c) {
8049 _newArrowCheck(this, _this11);
8050 return Math.abs(a) + c;
8051 }.bind(this)) / maxDataCount : axis.tickInterval(maxDataCount),
8052 getWidth = function (id) {
8053 _newArrowCheck(this, _this11);
8054 var width = id ? config[configName][id] : config[configName],
8055 ratio = id ? width.ratio : config[configName + "_ratio"],
8056 max = id ? width.max : config[configName + "_max"],
8057 w = isNumber(width) ? width : targetsNum ? tickInterval * ratio / targetsNum : 0;
8058 return max && w > max ? max : w;
8059 }.bind(this),
8060 result = getWidth();
8061 if (!isGrouped && isObjectType(config[configName])) {
8062 result = {
8063 _$width: result,
8064 _$total: []
8065 };
8066 $$.filterTargetsToShow($$.data.targets).forEach(function (v) {
8067 _newArrowCheck(this, _this11);
8068 if (config[configName][v.id]) {
8069 result[v.id] = getWidth(v.id);
8070 result._$total.push(result[v.id] || result._$width);
8071 }
8072 }.bind(this));
8073 }
8074 return result;
8075 },
8076 /**
8077 * Get shape element
8078 * @param {string} shapeName Shape string
8079 * @param {number} i Index number
8080 * @param {string} id Data series id
8081 * @returns {d3Selection}
8082 * @private
8083 */
8084 getShapeByIndex: function getShapeByIndex(shapeName, i, id) {
8085 var _this12 = this,
8086 $$ = this,
8087 $el = $$.$el,
8088 suffix = isValue(i) ? "-" + i : "",
8089 shape = $el[shapeName];
8090 // filter from shape reference if has
8091 if (shape && !shape.empty()) {
8092 shape = shape.filter(function (d) {
8093 _newArrowCheck(this, _this12);
8094 return id ? d.id === id : !0;
8095 }.bind(this)).filter(function (d) {
8096 _newArrowCheck(this, _this12);
8097 return isValue(i) ? d.index === i : !0;
8098 }.bind(this));
8099 } else {
8100 shape = (id ? $el.main.selectAll("." + classes[shapeName + "s"] + $$.getTargetSelectorSuffix(id)) : $el.main).selectAll("." + classes[shapeName] + suffix);
8101 }
8102 return shape;
8103 },
8104 isWithinShape: function isWithinShape(that, d) {
8105 var $$ = this,
8106 shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that),
8107 isWithin;
8108 if (!$$.isTargetToShow(d.id)) {
8109 isWithin = !1;
8110 } else if ($$.hasValidPointType != null && $$.hasValidPointType(that.nodeName)) {
8111 isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) : $$.isWithinCircle(that, $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0);
8112 } else if (that.nodeName === "path") {
8113 isWithin = shape.classed(classes.bar) ? $$.isWithinBar(that) : !0;
8114 }
8115 return isWithin;
8116 },
8117 getInterpolate: function getInterpolate(d) {
8118 var $$ = this,
8119 interpolation = $$.getInterpolateType(d);
8120 return {
8121 "basis": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasis,
8122 "basis-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisClosed,
8123 "basis-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisOpen,
8124 "bundle": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBundle,
8125 "cardinal": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinal,
8126 "cardinal-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalClosed,
8127 "cardinal-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalOpen,
8128 "catmull-rom": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRom,
8129 "catmull-rom-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomClosed,
8130 "catmull-rom-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomOpen,
8131 "monotone-x": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneX,
8132 "monotone-y": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneY,
8133 "natural": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveNatural,
8134 "linear-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinearClosed,
8135 "linear": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinear,
8136 "step": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStep,
8137 "step-after": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepAfter,
8138 "step-before": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepBefore
8139 }[interpolation];
8140 },
8141 getInterpolateType: function getInterpolateType(d) {
8142 var $$ = this,
8143 config = $$.config,
8144 type = config.spline_interpolation_type,
8145 interpolation = $$.isInterpolationType(type) ? type : "cardinal";
8146 return $$.isSplineType(d) ? interpolation : $$.isStepType(d) ? config.line_step_type : "linear";
8147 },
8148 isWithinBar: function isWithinBar(that) {
8149 var mouse = getPointer(this.state.event, that),
8150 list = getRectSegList(that),
8151 _list = list,
8152 seg0 = _list[0],
8153 seg1 = _list[1],
8154 x = Math.min(seg0.x, seg1.x),
8155 y = Math.min(seg0.y, seg1.y),
8156 offset = this.config.bar_sensitivity,
8157 _that$getBBox = that.getBBox(),
8158 width = _that$getBBox.width,
8159 height = _that$getBBox.height,
8160 isWithin = x - offset < mouse[0] && mouse[0] < x + width + offset && y - offset < mouse[1] && mouse[1] < y + height + offset;
8161 return isWithin;
8162 }
8163});
8164;// CONCATENATED MODULE: ./src/ChartInternal/internals/size.ts
8165
8166/**
8167 * Copyright (c) 2017 ~ present NAVER Corp.
8168 * billboard.js project is licensed under the MIT license
8169 */
8170
8171
8172
8173/* harmony default export */ var size = ({
8174 /**
8175 * Update container size
8176 * @private
8177 */
8178 setContainerSize: function setContainerSize() {
8179 var $$ = this,
8180 state = $$.state;
8181 state.current.width = $$.getCurrentWidth();
8182 state.current.height = $$.getCurrentHeight();
8183 },
8184 getCurrentWidth: function getCurrentWidth() {
8185 var $$ = this;
8186 return $$.config.size_width || $$.getParentWidth();
8187 },
8188 getCurrentHeight: function getCurrentHeight() {
8189 var $$ = this,
8190 config = $$.config,
8191 h = config.size_height || $$.getParentHeight();
8192 return h > 0 ? h : 320 / ($$.hasType("gauge") && !config.gauge_fullCircle ? 2 : 1);
8193 },
8194 getCurrentPaddingTop: function getCurrentPaddingTop() {
8195 var $$ = this,
8196 config = $$.config,
8197 hasAxis = $$.state.hasAxis,
8198 $el = $$.$el,
8199 axesLen = hasAxis ? config.axis_y2_axes.length : 0,
8200 padding = isValue(config.padding_top) ? config.padding_top : 0;
8201 if ($el.title && $el.title.node()) {
8202 padding += $$.getTitlePadding();
8203 }
8204 if (axesLen && config.axis_rotated) {
8205 padding += $$.getHorizontalAxisHeight("y2") * axesLen;
8206 }
8207 return padding;
8208 },
8209 getCurrentPaddingBottom: function getCurrentPaddingBottom() {
8210 var $$ = this,
8211 config = $$.config,
8212 hasAxis = $$.state.hasAxis,
8213 axisId = config.axis_rotated ? "y" : "x",
8214 axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
8215 padding = isValue(config.padding_bottom) ? config.padding_bottom : 0;
8216 return padding + (axesLen ? $$.getHorizontalAxisHeight(axisId) * axesLen : 0);
8217 },
8218 getCurrentPaddingLeft: function getCurrentPaddingLeft(withoutRecompute) {
8219 var $$ = this,
8220 config = $$.config,
8221 hasAxis = $$.state.hasAxis,
8222 isRotated = config.axis_rotated,
8223 axisId = isRotated ? "x" : "y",
8224 axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
8225 axisWidth = hasAxis ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : 0,
8226 padding;
8227 if (isValue(config.padding_left)) {
8228 padding = config.padding_left;
8229 } else if (hasAxis && isRotated) {
8230 padding = !config.axis_x_show ? 1 : Math.max(ceil10(axisWidth), 40);
8231 } else if (hasAxis && (!config.axis_y_show || config.axis_y_inner)) {
8232 // && !config.axis_rotated
8233 padding = $$.axis.getAxisLabelPosition("y").isOuter ? 30 : 1;
8234 } else {
8235 padding = ceil10(axisWidth);
8236 }
8237 return padding + axisWidth * axesLen;
8238 },
8239 getCurrentPaddingRight: function getCurrentPaddingRight(withXAxisTickTextOverflow) {
8240 if (withXAxisTickTextOverflow === void 0) {
8241 withXAxisTickTextOverflow = !1;
8242 }
8243 var $$ = this,
8244 config = $$.config,
8245 hasAxis = $$.state.hasAxis,
8246 legendWidthOnRight = $$.state.isLegendRight ? $$.getLegendWidth() + 20 : 0,
8247 axesLen = hasAxis ? config.axis_y2_axes.length : 0,
8248 axisWidth = hasAxis ? $$.getAxisWidthByAxisId("y2") : 0,
8249 xAxisTickTextOverflow = withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(10) : 0,
8250 padding;
8251 if (isValue(config.padding_right)) {
8252 padding = config.padding_right + 1; // 1 is needed not to hide tick line
8253 } else if ($$.axis && config.axis_rotated) {
8254 padding = 10 + legendWidthOnRight;
8255 } else if ($$.axis && (!config.axis_y2_show || config.axis_y2_inner)) {
8256 // && !config.axis_rotated
8257 padding = Math.max(2 + legendWidthOnRight + ($$.axis.getAxisLabelPosition("y2").isOuter ? 20 : 0), xAxisTickTextOverflow);
8258 } else {
8259 padding = Math.max(ceil10(axisWidth) + legendWidthOnRight, xAxisTickTextOverflow);
8260 }
8261 return padding + axisWidth * axesLen;
8262 },
8263 /**
8264 * Get the parent rect element's size
8265 * @param {string} key property/attribute name
8266 * @returns {number}
8267 * @private
8268 */
8269 getParentRectValue: function getParentRectValue(key) {
8270 var offsetName = "offset" + capitalize(key),
8271 parent = this.$el.chart.node(),
8272 v = 0;
8273 while (v < 30 && parent && parent.tagName !== "BODY") {
8274 try {
8275 v = parent.getBoundingClientRect()[key];
8276 } catch (e) {
8277 if (offsetName in parent) {
8278 // In IE in certain cases getBoundingClientRect
8279 // will cause an "unspecified error"
8280 v = parent[offsetName];
8281 }
8282 }
8283 parent = parent.parentNode;
8284 }
8285
8286 // Sometimes element's dimension value is incorrect(ex. flex container)
8287 // In this case, use body's offset instead.
8288 var bodySize = browser_doc.body[offsetName];
8289 v > bodySize && (v = bodySize);
8290 return v;
8291 },
8292 getParentWidth: function getParentWidth() {
8293 return this.getParentRectValue("width");
8294 },
8295 getParentHeight: function getParentHeight() {
8296 var h = this.$el.chart.style("height"),
8297 height = 0;
8298 if (h) {
8299 height = /px$/.test(h) ? parseInt(h, 10) : this.getParentRectValue("height");
8300 }
8301 return height;
8302 },
8303 getSvgLeft: function getSvgLeft(withoutRecompute) {
8304 var $$ = this,
8305 config = $$.config,
8306 $el = $$.$el,
8307 hasLeftAxisRect = config.axis_rotated || !config.axis_rotated && !config.axis_y_inner,
8308 leftAxisClass = config.axis_rotated ? $AXIS.axisX : $AXIS.axisY,
8309 leftAxis = $el.main.select("." + leftAxisClass).node(),
8310 svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : {
8311 right: 0
8312 },
8313 chartRect = $el.chart.node().getBoundingClientRect(),
8314 hasArc = $$.hasArcType(),
8315 svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute));
8316 return svgLeft > 0 ? svgLeft : 0;
8317 },
8318 updateDimension: function updateDimension(withoutAxis) {
8319 var $$ = this,
8320 config = $$.config,
8321 hasAxis = $$.state.hasAxis,
8322 $el = $$.$el;
8323 if (hasAxis && !withoutAxis && $$.axis.x && config.axis_rotated) {
8324 var _$$$axis$subX;
8325 (_$$$axis$subX = $$.axis.subX) == null ? void 0 : _$$$axis$subX.create($el.axis.subX);
8326 }
8327
8328 // pass 'withoutAxis' param to not animate at the init rendering
8329 $$.updateScales(withoutAxis);
8330 $$.updateSvgSize();
8331 $$.transformAll(!1);
8332 },
8333 updateSvgSize: function updateSvgSize() {
8334 var $$ = this,
8335 _$$$state = $$.state,
8336 clip = _$$$state.clip,
8337 current = _$$$state.current,
8338 hasAxis = _$$$state.hasAxis,
8339 width = _$$$state.width,
8340 height = _$$$state.height,
8341 svg = $$.$el.svg;
8342 svg.attr("width", current.width).attr("height", current.height);
8343 if (hasAxis) {
8344 var brush = svg.select("." + $SUBCHART.brush + " .overlay"),
8345 brushSize = {
8346 width: 0,
8347 height: 0
8348 };
8349 if (brush.size()) {
8350 brushSize.width = +brush.attr("width");
8351 brushSize.height = +brush.attr("height");
8352 }
8353 svg.selectAll(["#" + clip.id, "#" + clip.idGrid]).select("rect").attr("width", width).attr("height", height);
8354 svg.select("#" + clip.idXAxis).select("rect").call($$.setXAxisClipPath.bind($$));
8355 svg.select("#" + clip.idYAxis).select("rect").call($$.setYAxisClipPath.bind($$));
8356 clip.idSubchart && svg.select("#" + clip.idSubchart).select("rect").attr("width", width).attr("height", brushSize.height);
8357 }
8358 },
8359 /**
8360 * Get resetted padding values when 'padding=false' option is set
8361 * https://github.com/naver/billboard.js/issues/2367
8362 * @param {number|object} v Padding values to be resetted
8363 * @returns {number|object} Padding value
8364 * @private
8365 */
8366 getResettedPadding: function getResettedPadding(v) {
8367 var _this = this,
8368 $$ = this,
8369 config = $$.config,
8370 isNum = isNumber(v),
8371 p = isNum ? 0 : {};
8372 if (config.padding === !1) {
8373 isNum || Object.keys(v).forEach(function (key) {
8374 _newArrowCheck(this, _this);
8375 // when data.lables=true, do not reset top padding
8376 p[key] = !isEmpty(config.data_labels) && config.data_labels !== !1 && key === "top" ? v[key] : 0;
8377 }.bind(this));
8378 } else {
8379 p = v;
8380 }
8381 return p;
8382 },
8383 /**
8384 * Update size values
8385 * @param {boolean} isInit If is called at initialization
8386 * @private
8387 */
8388 updateSizes: function updateSizes(isInit) {
8389 var $$ = this,
8390 config = $$.config,
8391 state = $$.state,
8392 legend = $$.$el.legend,
8393 isRotated = config.axis_rotated,
8394 hasArc = $$.hasArcType();
8395 isInit || $$.setContainerSize();
8396 var currLegend = {
8397 width: legend ? $$.getLegendWidth() : 0,
8398 height: legend ? $$.getLegendHeight() : 0
8399 };
8400 if (!hasArc && config.axis_x_show && config.axis_x_tick_autorotate) {
8401 $$.updateXAxisTickClip();
8402 }
8403 var legendHeightForBottom = state.isLegendRight || state.isLegendInset ? 0 : currLegend.height,
8404 xAxisHeight = isRotated || hasArc ? 0 : $$.getHorizontalAxisHeight("x"),
8405 subchartXAxisHeight = config.subchart_axis_x_show && config.subchart_axis_x_tick_text_show ? xAxisHeight : 30,
8406 subchartHeight = config.subchart_show && !hasArc ? config.subchart_size_height + subchartXAxisHeight : 0;
8407 // for main
8408 state.margin = !hasArc && isRotated ? {
8409 top: $$.getHorizontalAxisHeight("y2") + $$.getCurrentPaddingTop(),
8410 right: hasArc ? 0 : $$.getCurrentPaddingRight(!0),
8411 bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom + $$.getCurrentPaddingBottom(),
8412 left: subchartHeight + (hasArc ? 0 : $$.getCurrentPaddingLeft())
8413 } : {
8414 top: 4 + $$.getCurrentPaddingTop(),
8415 // for top tick text
8416 right: hasArc ? 0 : $$.getCurrentPaddingRight(!0),
8417 bottom: xAxisHeight + subchartHeight + legendHeightForBottom + $$.getCurrentPaddingBottom(),
8418 left: hasArc ? 0 : $$.getCurrentPaddingLeft()
8419 };
8420 state.margin = $$.getResettedPadding(state.margin);
8421
8422 // for subchart
8423 state.margin2 = isRotated ? {
8424 top: state.margin.top,
8425 right: NaN,
8426 bottom: 20 + legendHeightForBottom,
8427 left: $$.state.rotatedPadding.left
8428 } : {
8429 top: state.current.height - subchartHeight - legendHeightForBottom,
8430 right: NaN,
8431 bottom: subchartXAxisHeight + legendHeightForBottom,
8432 left: state.margin.left
8433 };
8434
8435 // for legend
8436 state.margin3 = {
8437 top: 0,
8438 right: NaN,
8439 bottom: 0,
8440 left: 0
8441 };
8442 $$.updateSizeForLegend == null ? void 0 : $$.updateSizeForLegend(currLegend);
8443 state.width = state.current.width - state.margin.left - state.margin.right;
8444 state.height = state.current.height - state.margin.top - state.margin.bottom;
8445 if (state.width < 0) {
8446 state.width = 0;
8447 }
8448 if (state.height < 0) {
8449 state.height = 0;
8450 }
8451 state.width2 = isRotated ? state.margin.left - state.rotatedPadding.left - state.rotatedPadding.right : state.width;
8452 state.height2 = isRotated ? state.height : state.current.height - state.margin2.top - state.margin2.bottom;
8453 if (state.width2 < 0) {
8454 state.width2 = 0;
8455 }
8456 if (state.height2 < 0) {
8457 state.height2 = 0;
8458 }
8459
8460 // for arc
8461 var hasGauge = $$.hasType("gauge"),
8462 isLegendRight = config.legend_show && state.isLegendRight;
8463 state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0);
8464 state.arcHeight = state.height - (isLegendRight && !hasGauge ? 0 : 10);
8465 if (hasGauge && !config.gauge_fullCircle) {
8466 state.arcHeight += state.height - $$.getPaddingBottomForGauge();
8467 }
8468 $$.updateRadius == null ? void 0 : $$.updateRadius();
8469 if (state.isLegendRight && hasArc) {
8470 state.margin3.left = state.arcWidth / 2 + state.radiusExpanded * 1.1;
8471 }
8472 }
8473});
8474;// CONCATENATED MODULE: ./src/ChartInternal/internals/style.ts
8475
8476/**
8477 * Copyright (c) 2017 ~ present NAVER Corp.
8478 * billboard.js project is licensed under the MIT license
8479 */
8480
8481
8482/* harmony default export */ var style = ({
8483 /**
8484 * Add props color css rule to given selector
8485 * @param {boolean} withShape Set shpes' prefix class
8486 * @param {string} selector CSS selector
8487 * @param {Array} props CSS props list
8488 * @param {Function} propsFn Function to retrieve value or determine for props
8489 * @returns {Function}
8490 * @private
8491 */
8492 setCssRule: function setCssRule(withShape, selector, props, propsFn) {
8493 var _this = this,
8494 $$ = this,
8495 config = $$.config,
8496 _$$$state = $$.state,
8497 cssRule = _$$$state.cssRule,
8498 style = _$$$state.style;
8499 return config.boost_useCssRule ? function (selection) {
8500 var _this2 = this;
8501 _newArrowCheck(this, _this);
8502 selection.each(function (d) {
8503 var _this3 = this;
8504 _newArrowCheck(this, _this2);
8505 var res = propsFn && (propsFn == null ? void 0 : propsFn.call($$, d)),
8506 shapeSelector = "" + (withShape ? "." + ($SHAPE.shapes + $$.getTargetSelectorSuffix(d.id)) : "") + selector;
8507 selector in cssRule && style.sheet.deleteRule(cssRule[shapeSelector]);
8508 $$.state.cssRule[shapeSelector] = addCssRules(style, shapeSelector, props.filter(Boolean).map(function (v) {
8509 _newArrowCheck(this, _this3);
8510 return isString(res) && v.indexOf(":") === -1 ? v + ": " + res : v || "";
8511 }.bind(this)));
8512 }.bind(this));
8513 }.bind(this) : function () {
8514 _newArrowCheck(this, _this);
8515 }.bind(this);
8516 },
8517 /**
8518 * Get style prop value
8519 * @param {Function|string} v Value
8520 * @returns {string|null}
8521 * @private
8522 */
8523 getStylePropValue: function getStylePropValue(v) {
8524 var useCssRule = this.config.boost_useCssRule;
8525 return useCssRule ? null : isFunction(v) ? v.bind(this) : v;
8526 }
8527});
8528;// CONCATENATED MODULE: ./src/ChartInternal/internals/text.ts
8529
8530/**
8531 * Copyright (c) 2017 ~ present NAVER Corp.
8532 * billboard.js project is licensed under the MIT license
8533 */
8534
8535
8536
8537
8538/**
8539 * Get text-anchor according text.labels.rotate angle
8540 * @param {number} angle Angle value
8541 * @returns {string} Anchor string value
8542 * @private
8543 */
8544function getRotateAnchor(angle) {
8545 var anchor = "middle";
8546 if (angle > 0 && angle <= 170) {
8547 anchor = "end";
8548 } else if (angle > 190 && angle <= 360) {
8549 anchor = "start";
8550 }
8551 return anchor;
8552}
8553
8554/**
8555 * Set rotated position coordinate according text.labels.rotate angle
8556 * @param {object} d Data object
8557 * @param {object} pos Position object
8558 * @param {object} pos.x x coordinate
8559 * @param {object} pos.y y coordinate
8560 * @param {string} anchor string value
8561 * @param {boolean} isRotated If axis is rotated
8562 * @param {boolean} isInverted If axis is inverted
8563 * @returns {object} x, y coordinate
8564 * @private
8565 */
8566function setRotatePos(d, pos, anchor, isRotated, isInverted) {
8567 var _$$$getCandlestickDat,
8568 $$ = this,
8569 value = d.value,
8570 isCandlestickType = $$.isCandlestickType(d),
8571 isNegative = isNumber(value) && value < 0 || isCandlestickType && !((_$$$getCandlestickDat = $$.getCandlestickData(d)) != null && _$$$getCandlestickDat._isUp),
8572 x = pos.x,
8573 y = pos.y,
8574 gap = 4,
8575 doubleGap = 8;
8576 if (isRotated) {
8577 if (anchor === "start") {
8578 x += isNegative ? 0 : doubleGap;
8579 y += gap;
8580 } else if (anchor === "middle") {
8581 x += doubleGap;
8582 y -= doubleGap;
8583 } else if (anchor === "end") {
8584 isNegative && (x -= doubleGap);
8585 y += gap;
8586 }
8587 } else {
8588 if (anchor === "start") {
8589 x += gap;
8590 isNegative && (y += doubleGap * 2);
8591 } else if (anchor === "middle") {
8592 y -= doubleGap;
8593 } else if (anchor === "end") {
8594 x -= gap;
8595 isNegative && (y += doubleGap * 2);
8596 }
8597 if (isInverted) {
8598 y += isNegative ? -17 : isCandlestickType ? 13 : 7;
8599 }
8600 }
8601 return {
8602 x: x,
8603 y: y
8604 };
8605}
8606/* harmony default export */ var internals_text = ({
8607 opacityForText: function opacityForText(d) {
8608 var $$ = this;
8609 return $$.isBarType(d) && !$$.meetsLabelThreshold(Math.abs($$.getRatio("bar", d)), "bar") ? "0" : $$.hasDataLabel ? null : "0";
8610 },
8611 /**
8612 * Initializes the text
8613 * @private
8614 */
8615 initText: function initText() {
8616 var $el = this.$el;
8617 $el.main.select("." + $COMMON.chart).append("g").attr("class", $TEXT.chartTexts);
8618 },
8619 /**
8620 * Update chartText
8621 * @param {object} targets $$.data.targets
8622 * @private
8623 */
8624 updateTargetsForText: function updateTargetsForText(targets) {
8625 var _this = this,
8626 $$ = this,
8627 classChartText = $$.getChartClass("Text"),
8628 classTexts = $$.getClass("texts", "id"),
8629 classFocus = $$.classFocus.bind($$),
8630 mainTextUpdate = $$.$el.main.select("." + $TEXT.chartTexts).selectAll("." + $TEXT.chartText).data(targets).attr("class", function (d) {
8631 _newArrowCheck(this, _this);
8632 return classChartText(d) + classFocus(d);
8633 }.bind(this)),
8634 mainTextEnter = mainTextUpdate.enter().append("g").style("opacity", "0").attr("class", classChartText).call($$.setCssRule(!0, " ." + $TEXT.text, ["fill", "pointer-events:none"], $$.updateTextColor));
8635 mainTextEnter.append("g").attr("class", classTexts);
8636 },
8637 /**
8638 * Update text
8639 * @private
8640 */
8641 updateText: function updateText() {
8642 var _this2 = this,
8643 $$ = this,
8644 $el = $$.$el,
8645 $T = $$.$T,
8646 config = $$.config,
8647 classText = $$.getClass("text", "index"),
8648 text = $el.main.selectAll("." + $TEXT.texts).selectAll("." + $TEXT.text).data($$.labelishData.bind($$));
8649 $T(text.exit()).style("fill-opacity", "0").remove();
8650 $el.text = text.enter().append("text").merge(text).attr("class", classText).attr("text-anchor", function (d) {
8651 _newArrowCheck(this, _this2);
8652 // when value is negative or
8653 var isEndAnchor = d.value < 0;
8654 if ($$.isCandlestickType(d)) {
8655 var data = $$.getCandlestickData(d);
8656 isEndAnchor = !(data != null && data._isUp);
8657 }
8658 return config.axis_rotated ? isEndAnchor ? "end" : "start" : "middle";
8659 }.bind(this)).style("fill", $$.getStylePropValue($$.updateTextColor)).style("fill-opacity", "0").each(function (d, i, texts) {
8660 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
8661 value = d.value;
8662 if ($$.isBubbleZType(d)) {
8663 value = $$.getBubbleZData(value, "z");
8664 } else if ($$.isCandlestickType(d)) {
8665 var data = $$.getCandlestickData(d);
8666 if (data) {
8667 value = data.close;
8668 }
8669 }
8670 value = $$.dataLabelFormat(d.id)(value, d.id, i, texts);
8671 if (isNumber(value)) {
8672 this.textContent = value;
8673 } else {
8674 setTextValue(node, value);
8675 }
8676 });
8677 },
8678 updateTextColor: function updateTextColor(d) {
8679 var $$ = this,
8680 config = $$.config,
8681 labelColors = config.data_labels_colors,
8682 defaultColor = $$.isArcType(d) && !$$.isRadarType(d) ? null : $$.color(d),
8683 color;
8684 if (isString(labelColors)) {
8685 color = labelColors;
8686 } else if (isObject(labelColors)) {
8687 var _ref = d.data || d,
8688 id = _ref.id;
8689 color = labelColors[id];
8690 } else if (isFunction(labelColors)) {
8691 color = labelColors.bind($$.api)(defaultColor, d);
8692 }
8693 if ($$.isCandlestickType(d) && !isFunction(labelColors)) {
8694 var value = $$.getCandlestickData(d);
8695 if (!(value != null && value._isUp)) {
8696 var downColor = config.candlestick_color_down;
8697 color = isObject(downColor) ? downColor[d.id] : downColor;
8698 }
8699 }
8700 return color || defaultColor;
8701 },
8702 /**
8703 * Update data label text background color
8704 * @param {object} d Data object
8705 * @returns {string|null}
8706 * @private
8707 */
8708 updateTextBacgroundColor: function updateTextBacgroundColor(d) {
8709 var $$ = this,
8710 $el = $$.$el,
8711 config = $$.config,
8712 backgroundColor = config.data_labels_backgroundColors,
8713 color = "";
8714 if (isString(backgroundColor) || isObject(backgroundColor)) {
8715 var id = isString(backgroundColor) ? "" : $$.getTargetSelectorSuffix("id" in d ? d.id : d.data.id),
8716 filter = $el.defs.select(["filter[id*='labels-bg", "']"].join(id));
8717 if (filter.size()) {
8718 color = "url(#" + filter.attr("id") + ")";
8719 }
8720 }
8721 return color || null;
8722 },
8723 /**
8724 * Redraw chartText
8725 * @param {Function} getX Positioning function for x
8726 * @param {Function} getY Positioning function for y
8727 * @param {boolean} forFlow Weather is flow
8728 * @param {boolean} withTransition transition is enabled
8729 * @returns {Array}
8730 * @private
8731 */
8732 redrawText: function redrawText(getX, getY, forFlow, withTransition) {
8733 var $$ = this,
8734 $T = $$.$T,
8735 axis = $$.axis,
8736 config = $$.config,
8737 t = getRandom(!0),
8738 isRotated = config.axis_rotated,
8739 angle = config.data_labels.rotate,
8740 anchorString = getRotateAnchor(angle),
8741 rotateString = angle ? "rotate(" + angle + ")" : "";
8742 $$.$el.text.style("fill", $$.getStylePropValue($$.updateTextColor)).attr("filter", $$.updateTextBacgroundColor.bind($$)).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function (d, i) {
8743 // do not apply transition for newly added text elements
8744 var node = $T(this, !!(withTransition && this.getAttribute("x")), t),
8745 isInverted = config["axis_" + (axis == null ? void 0 : axis.getId(d.id)) + "_inverted"],
8746 pos = {
8747 x: getX.bind(this)(d, i),
8748 y: getY.bind(this)(d, i)
8749 };
8750 if (angle) {
8751 pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
8752 node.attr("text-anchor", anchorString);
8753 }
8754
8755 // when is multiline
8756 if (this.childElementCount || angle) {
8757 node.attr("transform", "translate(" + pos.x + " " + pos.y + ") " + rotateString);
8758 } else {
8759 node.attr("x", pos.x).attr("y", pos.y);
8760 }
8761 });
8762
8763 // need to return 'true' as of being pushed to the redraw list
8764 // ref: getRedrawList()
8765 return !0;
8766 },
8767 /**
8768 * Gets the getBoundingClientRect value of the element
8769 * @param {HTMLElement|d3.selection} element Target element
8770 * @param {string} className Class name
8771 * @returns {object} value of element.getBoundingClientRect()
8772 * @private
8773 */
8774 getTextRect: function getTextRect(element, className) {
8775 var _this3 = this,
8776 $$ = this,
8777 base = element.node ? element.node() : element;
8778 if (!/text/i.test(base.tagName)) {
8779 base = base.querySelector("text");
8780 }
8781 var text = base.textContent,
8782 cacheKey = KEY.textRect + "-" + text.replace(/\W/g, "_"),
8783 rect = $$.cache.get(cacheKey);
8784 if (!rect) {
8785 $$.$el.svg.append("text").style("visibility", "hidden").style("font", (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(base).style("font")).classed(className, !0).text(text).call(function (v) {
8786 _newArrowCheck(this, _this3);
8787 rect = getBoundingRect(v.node());
8788 }.bind(this)).remove();
8789 $$.cache.add(cacheKey, rect);
8790 }
8791 return rect;
8792 },
8793 /**
8794 * Gets the x or y coordinate of the text
8795 * @param {object} indices Indices values
8796 * @param {boolean} forX whether or not to x
8797 * @returns {number} coordinates
8798 * @private
8799 */
8800 generateXYForText: function generateXYForText(indices, forX) {
8801 var _this4 = this,
8802 $$ = this,
8803 types = Object.keys(indices),
8804 points = {},
8805 getter = forX ? $$.getXForText : $$.getYForText;
8806 $$.hasType("radar") && types.push("radar");
8807 types.forEach(function (v) {
8808 _newArrowCheck(this, _this4);
8809 points[v] = $$["generateGet" + capitalize(v) + "Points"](indices[v], !1);
8810 }.bind(this));
8811 return function (d, i) {
8812 var type = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar" || $$.isCandlestickType(d) && "candlestick" || $$.isRadarType(d) && "radar" || "line";
8813 return getter.call($$, points[type](d, i), d, this);
8814 };
8815 },
8816 /**
8817 * Get centerized text position for bar type data.label.text
8818 * @param {object} d Data object
8819 * @param {Array} points Data points position
8820 * @param {HTMLElement} textElement Data label text element
8821 * @returns {number} Position value
8822 * @private
8823 */
8824 getCenteredTextPos: function getCenteredTextPos(d, points, textElement) {
8825 var $$ = this,
8826 config = $$.config,
8827 isRotated = config.axis_rotated;
8828 if (config.data_labels.centered && $$.isBarType(d)) {
8829 var _rect = getBoundingRect(textElement),
8830 isPositive = d.value >= 0;
8831 if (isRotated) {
8832 var w = (isPositive ? points[1][1] - points[0][1] : points[0][1] - points[1][1]) / 2 + _rect.width / 2;
8833 return isPositive ? -w - 3 : w + 2;
8834 } else {
8835 var h = (isPositive ? points[0][1] - points[1][1] : points[1][1] - points[0][1]) / 2 + _rect.height / 2;
8836 return isPositive ? h : -h - 2;
8837 }
8838 }
8839 return 0;
8840 },
8841 /**
8842 * Get data.labels.position value
8843 * @param {string} id Data id value
8844 * @param {string} type x | y
8845 * @returns {number} Position value
8846 * @private
8847 */
8848 getTextPos: function getTextPos(id, type) {
8849 var pos = this.config.data_labels_position;
8850 return (id in pos ? pos[id] : pos)[type] || 0;
8851 },
8852 /**
8853 * Gets the x coordinate of the text
8854 * @param {object} points Data points position
8855 * @param {object} d Data object
8856 * @param {HTMLElement} textElement Data label text element
8857 * @returns {number} x coordinate
8858 * @private
8859 */
8860 getXForText: function getXForText(points, d, textElement) {
8861 var $$ = this,
8862 config = $$.config,
8863 state = $$.state,
8864 isRotated = config.axis_rotated,
8865 xPos = points[0][0];
8866 if ($$.isCandlestickType(d)) {
8867 if (isRotated) {
8868 var _$$$getCandlestickDat2;
8869 xPos = (_$$$getCandlestickDat2 = $$.getCandlestickData(d)) != null && _$$$getCandlestickDat2._isUp ? points[2][2] + 4 : points[2][1] - 4;
8870 } else {
8871 xPos += (points[1][0] - xPos) / 2;
8872 }
8873 } else {
8874 if (isRotated) {
8875 var padding = $$.isBarType(d) ? 4 : 6;
8876 xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1);
8877 } else {
8878 xPos = $$.hasType("bar") ? (points[2][0] + points[0][0]) / 2 : xPos;
8879 }
8880 }
8881
8882 // show labels regardless of the domain if value is null
8883 if (d.value === null) {
8884 if (xPos > state.width) {
8885 var _getBoundingRect = getBoundingRect(textElement),
8886 width = _getBoundingRect.width;
8887 xPos = state.width - width;
8888 } else if (xPos < 0) {
8889 xPos = 4;
8890 }
8891 }
8892 if (isRotated) {
8893 xPos += $$.getCenteredTextPos(d, points, textElement);
8894 }
8895 return xPos + $$.getTextPos(d.id, "x");
8896 },
8897 /**
8898 * Gets the y coordinate of the text
8899 * @param {object} points Data points position
8900 * @param {object} d Data object
8901 * @param {HTMLElement} textElement Data label text element
8902 * @returns {number} y coordinate
8903 * @private
8904 */
8905 getYForText: function getYForText(points, d, textElement) {
8906 var $$ = this,
8907 axis = $$.axis,
8908 config = $$.config,
8909 state = $$.state,
8910 isRotated = config.axis_rotated,
8911 isInverted = config["axis_" + (axis == null ? void 0 : axis.getId(d.id)) + "_inverted"],
8912 isBarType = $$.isBarType(d),
8913 r = config.point_r,
8914 rect = getBoundingRect(textElement),
8915 value = d.value,
8916 baseY = 3,
8917 yPos;
8918 if ($$.isCandlestickType(d)) {
8919 value = $$.getCandlestickData(d);
8920 if (isRotated) {
8921 yPos = points[0][0];
8922 yPos += (points[1][0] - yPos) / 2 + baseY;
8923 } else {
8924 yPos = value && value._isUp ? points[2][2] - baseY : points[2][1] + baseY * 4;
8925 if (isInverted) {
8926 yPos += 15 * (value._isUp ? 1 : -1);
8927 }
8928 }
8929 } else {
8930 if (isRotated) {
8931 yPos = (points[0][0] + points[2][0] + rect.height * .6) / 2;
8932 } else {
8933 yPos = points[2][1];
8934 if (isNumber(r) && r > 5 && ($$.isLineType(d) || $$.isScatterType(d))) {
8935 baseY += config.point_r / 2.3;
8936 }
8937 if (value < 0 || value === 0 && !state.hasPositiveValue && state.hasNegativeValue) {
8938 yPos += isInverted ? isBarType ? -3 : -5 : rect.height + (isBarType ? -baseY : baseY);
8939 } else {
8940 var diff = -baseY * 2;
8941 if (isBarType) {
8942 diff = -baseY;
8943 } else if ($$.isBubbleType(d)) {
8944 diff = baseY;
8945 }
8946 if (isInverted) {
8947 diff = isBarType ? 10 : 15;
8948 }
8949 yPos += diff;
8950 }
8951 }
8952 }
8953
8954 // show labels regardless of the domain if value is null
8955 if (d.value === null && !isRotated) {
8956 var boxHeight = rect.height;
8957 if (yPos < boxHeight) {
8958 yPos = boxHeight;
8959 } else if (yPos > state.height) {
8960 yPos = state.height - 4;
8961 }
8962 }
8963 if (!isRotated) {
8964 yPos += $$.getCenteredTextPos(d, points, textElement);
8965 }
8966 return yPos + $$.getTextPos(d.id, "y");
8967 },
8968 /**
8969 * Calculate if two or more text nodes are overlapping
8970 * Mark overlapping text nodes with "text-overlapping" class
8971 * @param {string} id Axis id
8972 * @param {ChartInternal} $$ ChartInternal context
8973 * @param {string} selector Selector string
8974 * @private
8975 */
8976 markOverlapped: function markOverlapped(id, $$, selector) {
8977 var _this5 = this,
8978 textNodes = $$.$el.arcs.selectAll(selector),
8979 filteredTextNodes = textNodes.filter(function (node) {
8980 _newArrowCheck(this, _this5);
8981 return node.data.id !== id;
8982 }.bind(this)),
8983 textNode = textNodes.filter(function (node) {
8984 _newArrowCheck(this, _this5);
8985 return node.data.id === id;
8986 }.bind(this)),
8987 translate = getTranslation(textNode.node()),
8988 calcHypo = function (x, y) {
8989 _newArrowCheck(this, _this5);
8990 return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
8991 }.bind(this);
8992 textNode.node() && filteredTextNodes.each(function () {
8993 var coordinate = getTranslation(this),
8994 filteredTextNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
8995 nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : filteredTextNode,
8996 overlapsX = Math.ceil(Math.abs(translate.e - coordinate.e)) < Math.ceil(nodeForWidth.node().getComputedTextLength()),
8997 overlapsY = Math.ceil(Math.abs(translate.f - coordinate.f)) < parseInt(textNode.style("font-size"), 10);
8998 filteredTextNode.classed($TEXT.TextOverlapping, overlapsX && overlapsY);
8999 });
9000 },
9001 /**
9002 * Calculate if two or more text nodes are overlapping
9003 * Remove "text-overlapping" class on selected text nodes
9004 * @param {ChartInternal} $$ ChartInternal context
9005 * @param {string} selector Selector string
9006 * @private
9007 */
9008 undoMarkOverlapped: function undoMarkOverlapped($$, selector) {
9009 $$.$el.arcs.selectAll(selector).each(function () {
9010 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([this, this.previousSibling]).classed($TEXT.TextOverlapping, !1);
9011 });
9012 },
9013 /**
9014 * Check if meets the ratio to show data label text
9015 * @param {number} ratio ratio to meet
9016 * @param {string} type chart type
9017 * @returns {boolean}
9018 * @private
9019 */
9020 meetsLabelThreshold: function meetsLabelThreshold(ratio, type) {
9021 if (ratio === void 0) {
9022 ratio = 0;
9023 }
9024 var $$ = this,
9025 config = $$.config,
9026 threshold = config[type + "_label_threshold"] || 0;
9027 return ratio >= threshold;
9028 }
9029});
9030;// CONCATENATED MODULE: ./src/ChartInternal/internals/title.ts
9031/**
9032 * Copyright (c) 2017 ~ present NAVER Corp.
9033 * billboard.js project is licensed under the MIT license
9034 */
9035
9036
9037
9038/**
9039 * Get the text position
9040 * @param {string} pos right, left or center
9041 * @param {number} width chart width
9042 * @returns {string|number} text-anchor value or position in pixel
9043 * @private
9044 */
9045function getTextPos(pos, width) {
9046 if (pos === void 0) {
9047 pos = "left";
9048 }
9049 var isNum = isNumber(width),
9050 position;
9051 if (pos.indexOf("center") > -1) {
9052 position = isNum ? width / 2 : "middle";
9053 } else if (pos.indexOf("right") > -1) {
9054 position = isNum ? width : "end";
9055 } else {
9056 position = isNum ? 0 : "start";
9057 }
9058 return position;
9059}
9060/* harmony default export */ var internals_title = ({
9061 /**
9062 * Initializes the title
9063 * @private
9064 */
9065 initTitle: function initTitle() {
9066 var $$ = this,
9067 config = $$.config,
9068 $el = $$.$el;
9069 if (config.title_text) {
9070 $el.title = $el.svg.append("g");
9071 var text = $el.title.append("text").style("text-anchor", getTextPos(config.title_position)).attr("class", $TEXT.title);
9072 setTextValue(text, config.title_text, [.3, 1.5]);
9073 }
9074 },
9075 /**
9076 * Redraw title
9077 * @private
9078 */
9079 redrawTitle: function redrawTitle() {
9080 var $$ = this,
9081 config = $$.config,
9082 current = $$.state.current,
9083 title = $$.$el.title;
9084 if (title) {
9085 var y = $$.yForTitle.call($$);
9086 if (/g/i.test(title.node().tagName)) {
9087 title.attr("transform", "translate(" + getTextPos(config.title_position, current.width) + ", " + y + ")");
9088 } else {
9089 title.attr("x", $$.xForTitle.call($$)).attr("y", y);
9090 }
9091 }
9092 },
9093 /**
9094 * Returns the x attribute value of the title
9095 * @returns {number} x attribute value
9096 * @private
9097 */
9098 xForTitle: function xForTitle() {
9099 var $$ = this,
9100 config = $$.config,
9101 current = $$.state.current,
9102 position = config.title_position || "left",
9103 textRectWidth = $$.getTextRect($$.$el.title, $TEXT.title).width,
9104 x;
9105 if (/(right|center)/.test(position)) {
9106 x = current.width - textRectWidth;
9107 if (position.indexOf("right") >= 0) {
9108 x = current.width - textRectWidth - config.title_padding.right;
9109 } else if (position.indexOf("center") >= 0) {
9110 x = (current.width - textRectWidth) / 2;
9111 }
9112 } else {
9113 // left
9114 x = config.title_padding.left || 0;
9115 }
9116 return x;
9117 },
9118 /**
9119 * Returns the y attribute value of the title
9120 * @returns {number} y attribute value
9121 * @private
9122 */
9123 yForTitle: function yForTitle() {
9124 var $$ = this;
9125 return ($$.config.title_padding.top || 0) + $$.getTextRect($$.$el.title, $TEXT.title).height;
9126 },
9127 /**
9128 * Get title padding
9129 * @returns {number} padding value
9130 * @private
9131 */
9132 getTitlePadding: function getTitlePadding() {
9133 var $$ = this;
9134 return $$.yForTitle() + ($$.config.title_padding.bottom || 0);
9135 }
9136});
9137;// CONCATENATED MODULE: ./src/ChartInternal/internals/tooltip.ts
9138
9139/**
9140 * Copyright (c) 2017 ~ present NAVER Corp.
9141 * billboard.js project is licensed under the MIT license
9142 */
9143
9144
9145
9146
9147/* harmony default export */ var internals_tooltip = ({
9148 /**
9149 * Initializes the tooltip
9150 * @private
9151 */
9152 initTooltip: function initTooltip() {
9153 var $$ = this,
9154 config = $$.config,
9155 $el = $$.$el;
9156 $el.tooltip = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.tooltip_contents.bindto);
9157 if ($el.tooltip.empty()) {
9158 $el.tooltip = $el.chart.append("div").attr("class", $TOOLTIP.tooltipContainer).style("position", "absolute").style("pointer-events", "none").style("display", "none");
9159 }
9160 $$.bindTooltipResizePos();
9161 },
9162 initShowTooltip: function initShowTooltip() {
9163 var _this = this,
9164 $$ = this,
9165 config = $$.config,
9166 $el = $$.$el,
9167 _$$$state = $$.state,
9168 hasAxis = _$$$state.hasAxis,
9169 hasRadar = _$$$state.hasRadar;
9170 // Show tooltip if needed
9171 if (config.tooltip_init_show) {
9172 var _$$$axis,
9173 _$$$axis2,
9174 isArc = !(hasAxis && hasRadar);
9175 if ((_$$$axis = $$.axis) != null && _$$$axis.isTimeSeries() && isString(config.tooltip_init_x)) {
9176 var targets = $$.data.targets[0],
9177 i,
9178 val;
9179 config.tooltip_init_x = parseDate.call($$, config.tooltip_init_x);
9180 for (i = 0; val = targets.values[i]; i++) {
9181 if (val.x - config.tooltip_init_x === 0) {
9182 break;
9183 }
9184 }
9185 config.tooltip_init_x = i;
9186 }
9187 var data = $$.data.targets.map(function (d) {
9188 _newArrowCheck(this, _this);
9189 var x = isArc ? 0 : config.tooltip_init_x;
9190 return $$.addName(d.values[x]);
9191 }.bind(this));
9192 if (isArc) {
9193 data = [data[config.tooltip_init_x]];
9194 }
9195 $el.tooltip.html($$.getTooltipHTML(data, (_$$$axis2 = $$.axis) == null ? void 0 : _$$$axis2.getXAxisTickFormat(), $$.getDefaultValueFormat(), $$.color));
9196 if (!config.tooltip_contents.bindto) {
9197 $el.tooltip.style("top", config.tooltip_init_position.top).style("left", config.tooltip_init_position.left).style("display", null);
9198 }
9199 }
9200 },
9201 /**
9202 * Get the tooltip HTML string
9203 * @param {Array} args Arguments
9204 * @returns {string} Formatted HTML string
9205 * @private
9206 */
9207 getTooltipHTML: function getTooltipHTML() {
9208 var $$ = this,
9209 api = $$.api,
9210 config = $$.config;
9211 return isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api).apply(void 0, arguments) : $$.getTooltipContent.apply($$, arguments);
9212 },
9213 /**
9214 * Returns the tooltip content(HTML string)
9215 * @param {object} d data
9216 * @param {Function} defaultTitleFormat Default title format
9217 * @param {Function} defaultValueFormat Default format for each data value in the tooltip.
9218 * @param {Function} color Color function
9219 * @returns {string} html
9220 * @private
9221 */
9222 getTooltipContent: function getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) {
9223 var _this2 = this,
9224 $$ = this,
9225 api = $$.api,
9226 config = $$.config,
9227 state = $$.state,
9228 _map = ["title", "name", "value"].map(function (v) {
9229 _newArrowCheck(this, _this2);
9230 var fn = config["tooltip_format_" + v];
9231 return isFunction(fn) ? fn.bind(api) : fn;
9232 }.bind(this)),
9233 titleFormat = _map[0],
9234 nameFormat = _map[1],
9235 valueFormat = _map[2];
9236 titleFormat = titleFormat || defaultTitleFormat;
9237 nameFormat = nameFormat || function (name) {
9238 _newArrowCheck(this, _this2);
9239 return name;
9240 }.bind(this);
9241 valueFormat = valueFormat || ($$.isStackNormalized() ? function (v, ratio) {
9242 _newArrowCheck(this, _this2);
9243 return (ratio * 100).toFixed(2) + "%";
9244 }.bind(this) : defaultValueFormat);
9245 var order = config.tooltip_order,
9246 getRowValue = function (row) {
9247 _newArrowCheck(this, _this2);
9248 return $$.axis && $$.isBubbleZType(row) ? $$.getBubbleZData(row.value, "z") : $$.getBaseValue(row);
9249 }.bind(this),
9250 getBgColor = $$.levelColor ? function (row) {
9251 _newArrowCheck(this, _this2);
9252 return $$.levelColor(row.value);
9253 }.bind(this) : function (row) {
9254 _newArrowCheck(this, _this2);
9255 return color(row);
9256 }.bind(this),
9257 contents = config.tooltip_contents,
9258 tplStr = contents.template,
9259 targetIds = $$.mapToTargetIds();
9260 if (order === null && config.data_groups.length) {
9261 // for stacked data, order should aligned with the visually displayed data
9262 var ids = $$.orderTargets($$.data.targets).map(function (i2) {
9263 _newArrowCheck(this, _this2);
9264 return i2.id;
9265 }.bind(this)).reverse();
9266 d.sort(function (a, b) {
9267 _newArrowCheck(this, _this2);
9268 var v1 = a ? a.value : null,
9269 v2 = b ? b.value : null;
9270 if (v1 > 0 && v2 > 0) {
9271 v1 = a.id ? ids.indexOf(a.id) : null;
9272 v2 = b.id ? ids.indexOf(b.id) : null;
9273 }
9274 return v1 - v2;
9275 }.bind(this));
9276 } else if (/^(asc|desc)$/.test(order)) {
9277 d.sort(function (a, b) {
9278 _newArrowCheck(this, _this2);
9279 var v1 = a ? getRowValue(a) : null,
9280 v2 = b ? getRowValue(b) : null;
9281 return order === "asc" ? v1 - v2 : v2 - v1;
9282 }.bind(this));
9283 } else if (isFunction(order)) {
9284 d.sort(order.bind(api));
9285 }
9286 var tpl = $$.getTooltipContentTemplate(tplStr),
9287 len = d.length,
9288 text,
9289 row,
9290 param,
9291 value,
9292 i;
9293 for (i = 0; i < len; i++) {
9294 row = d[i];
9295 if (!row || !(getRowValue(row) || getRowValue(row) === 0)) {
9296 continue;
9297 }
9298 if (isUndefined(text)) {
9299 var title = (state.hasAxis || state.hasRadar) && sanitise(titleFormat ? titleFormat(row.x) : row.x);
9300 text = tplProcess(tpl[0], {
9301 CLASS_TOOLTIP: $TOOLTIP.tooltip,
9302 TITLE: isValue(title) ? tplStr ? title : "<tr><th colspan=\"2\">" + title + "</th></tr>" : ""
9303 });
9304 }
9305 if (!row.ratio && $$.$el.arcs) {
9306 row.ratio = $$.getRatio("arc", $$.$el.arcs.select("path." + $ARC.arc + "-" + row.id).data()[0]);
9307 }
9308 param = [row.ratio, row.id, row.index, d];
9309 value = sanitise(valueFormat.apply(void 0, [getRowValue(row)].concat(param)));
9310 if ($$.isAreaRangeType(row)) {
9311 var _map2 = ["high", "low"].map(function (v) {
9312 _newArrowCheck(this, _this2);
9313 return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v)].concat(param)));
9314 }.bind(this)),
9315 high = _map2[0],
9316 low = _map2[1];
9317 value = "<b>Mid:</b> " + value + " <b>High:</b> " + high + " <b>Low:</b> " + low;
9318 } else if ($$.isCandlestickType(row)) {
9319 var _map3 = ["open", "high", "low", "close", "volume"].map(function (v) {
9320 _newArrowCheck(this, _this2);
9321 return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v, "candlestick")].concat(param)));
9322 }.bind(this)),
9323 open = _map3[0],
9324 _high = _map3[1],
9325 _low = _map3[2],
9326 close = _map3[3],
9327 volume = _map3[4];
9328 value = "<b>Open:</b> " + open + " <b>High:</b> " + _high + " <b>Low:</b> " + _low + " <b>Close:</b> " + close + (volume ? " <b>Volume:</b> " + volume : "");
9329 } else if ($$.isBarRangeType(row)) {
9330 var _row$value = row.value,
9331 start = _row$value[0],
9332 end = _row$value[1];
9333 value = valueFormat(start) + " ~ " + valueFormat(end);
9334 }
9335 if (value !== undefined) {
9336 var _ret = function () {
9337 var _this3 = this;
9338 // Skip elements when their name is set to null
9339 if (row.name === null) {
9340 return "continue";
9341 }
9342 var name = sanitise(nameFormat.apply(void 0, [row.name].concat(param))),
9343 color = getBgColor(row),
9344 contentValue = {
9345 CLASS_TOOLTIP_NAME: $TOOLTIP.tooltipName + $$.getTargetSelectorSuffix(row.id),
9346 COLOR: tplStr || !$$.patterns ? color : "<svg><rect style=\"fill:" + color + "\" width=\"10\" height=\"10\"></rect></svg>",
9347 NAME: name,
9348 VALUE: value
9349 };
9350 if (tplStr && isObject(contents.text)) {
9351 var index = targetIds.indexOf(row.id);
9352 Object.keys(contents.text).forEach(function (key) {
9353 _newArrowCheck(this, _this3);
9354 contentValue[key] = contents.text[key][index];
9355 }.bind(this));
9356 }
9357 text += tplProcess(tpl[1], contentValue);
9358 }();
9359 if (_ret === "continue") continue;
9360 }
9361 }
9362 return text + "</table>";
9363 },
9364 /**
9365 * Get the content template string
9366 * @param {string} tplStr Tempalte string
9367 * @returns {Array} Template string
9368 * @private
9369 */
9370 getTooltipContentTemplate: function getTooltipContentTemplate(tplStr) {
9371 return (tplStr || "<table class=\"{=CLASS_TOOLTIP}\"><tbody>\n\t\t\t\t{=TITLE}\n\t\t\t\t{{<tr class=\"{=CLASS_TOOLTIP_NAME}\">\n\t\t\t\t\t<td class=\"name\">" + (this.patterns ? "{=COLOR}" : "<span style=\"background-color:{=COLOR}\"></span>") + "{=NAME}</td>\n\t\t\t\t\t<td class=\"value\">{=VALUE}</td>\n\t\t\t\t</tr>}}\n\t\t\t</tbody></table>").replace(/(\r?\n|\t)/g, "").split(/{{(.*)}}/);
9372 },
9373 /**
9374 * Returns the position of the tooltip
9375 * @param {object} dataToShow data
9376 * @param {string} tWidth Width value of tooltip element
9377 * @param {string} tHeight Height value of tooltip element
9378 * @param {HTMLElement} element Tooltip element
9379 * @returns {object} top, left value
9380 * @private
9381 */
9382 tooltipPosition: function tooltipPosition(dataToShow, tWidth, tHeight, element) {
9383 var _this4 = this,
9384 $$ = this,
9385 config = $$.config,
9386 scale = $$.scale,
9387 state = $$.state,
9388 _state = state,
9389 width = _state.width,
9390 height = _state.height,
9391 current = _state.current,
9392 isLegendRight = _state.isLegendRight,
9393 inputType = _state.inputType,
9394 event = _state.event,
9395 hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle,
9396 svgLeft = $$.getSvgLeft(!0),
9397 chartRight = svgLeft + current.width - $$.getCurrentPaddingRight(),
9398 chartLeft = $$.getCurrentPaddingLeft(!0),
9399 _getPointer = getPointer(event, element),
9400 x = _getPointer[0],
9401 y = _getPointer[1];
9402 // Determine tooltip position
9403 if ($$.hasArcType()) {
9404 var raw = inputType === "touch" || $$.hasType("radar");
9405 if (!raw) {
9406 y += hasGauge ? height : height / 2;
9407 x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
9408 }
9409 } else {
9410 var dataScale = scale.x(dataToShow[0].x);
9411 if (config.axis_rotated) {
9412 y = dataScale + 20;
9413 x += svgLeft + 100;
9414 chartRight -= svgLeft;
9415 } else {
9416 y -= 5;
9417 x = svgLeft + chartLeft + 20 + ($$.scale.zoom ? x : dataScale);
9418 }
9419 }
9420
9421 // when tooltip left + tWidth > chart's width
9422 if (x + tWidth + 15 > chartRight) {
9423 x -= tWidth + chartLeft;
9424 }
9425 if (y + tHeight > current.height) {
9426 y -= hasGauge ? tHeight * 3 : tHeight + 30;
9427 }
9428 var pos = {
9429 top: y,
9430 left: x
9431 };
9432
9433 // make sure to not be positioned out of viewport
9434 Object.keys(pos).forEach(function (v) {
9435 _newArrowCheck(this, _this4);
9436 if (pos[v] < 0) {
9437 pos[v] = 0;
9438 }
9439 }.bind(this));
9440 return pos;
9441 },
9442 /**
9443 * Show the tooltip
9444 * @param {object} selectedData Data object
9445 * @param {SVGElement} eventRect Event <rect> element
9446 * @private
9447 */
9448 showTooltip: function showTooltip(selectedData, eventRect) {
9449 var _this5 = this,
9450 $$ = this,
9451 config = $$.config,
9452 scale = $$.scale,
9453 state = $$.state,
9454 tooltip = $$.$el.tooltip,
9455 bindto = config.tooltip_contents.bindto,
9456 dataToShow = selectedData.filter(function (d) {
9457 _newArrowCheck(this, _this5);
9458 return d && isValue($$.getBaseValue(d));
9459 }.bind(this));
9460 if (!tooltip || dataToShow.length === 0 || !config.tooltip_show) {
9461 return;
9462 }
9463 var datum = tooltip.datum(),
9464 _ref = datum || {},
9465 _ref$width = _ref.width,
9466 width = _ref$width === void 0 ? 0 : _ref$width,
9467 _ref$height = _ref.height,
9468 height = _ref$height === void 0 ? 0 : _ref$height,
9469 dataStr = JSON.stringify(selectedData);
9470 if (!datum || datum.current !== dataStr) {
9471 var index = selectedData.concat().sort()[0].index;
9472 callFn(config.tooltip_onshow, $$.api, selectedData);
9473
9474 // set tooltip content
9475 tooltip.html($$.getTooltipHTML(selectedData,
9476 // data
9477 $$.axis ? $$.axis.getXAxisTickFormat() : $$.categoryName.bind($$),
9478 // defaultTitleFormat
9479 $$.getDefaultValueFormat(),
9480 // defaultValueFormat
9481 $$.color // color
9482 )).style("display", null).style("visibility", null) // for IE9
9483 .datum(datum = {
9484 index: index,
9485 current: dataStr,
9486 width: width = tooltip.property("offsetWidth"),
9487 height: height = tooltip.property("offsetHeight")
9488 });
9489 callFn(config.tooltip_onshown, $$.api, selectedData);
9490 $$._handleLinkedCharts(!0, index);
9491 }
9492 if (!bindto) {
9493 var _config$tooltip_posit,
9494 _selectedData$filter,
9495 fnPos = ((_config$tooltip_posit = config.tooltip_position) == null ? void 0 : _config$tooltip_posit.bind($$.api)) || $$.tooltipPosition.bind($$),
9496 _getPointer2 = getPointer(state.event, eventRect),
9497 x = _getPointer2[0],
9498 y = _getPointer2[1],
9499 currPos = {
9500 x: x,
9501 y: y
9502 },
9503 data = (_selectedData$filter = selectedData.filter(Boolean)) == null ? void 0 : _selectedData$filter.shift();
9504 if (scale.x && data && "x" in data) {
9505 currPos.xAxis = scale.x(data.x);
9506 }
9507
9508 // Get tooltip dimensions
9509 var pos = fnPos(dataToShow, width, height, eventRect, currPos);
9510 ["top", "left"].forEach(function (v) {
9511 _newArrowCheck(this, _this5);
9512 var value = pos[v];
9513 tooltip.style(v, value + "px");
9514
9515 // Remember left pos in percentage to be used on resize call
9516 if (v === "left" && !datum.xPosInPercent) {
9517 datum.xPosInPercent = value / state.current.width * 100;
9518 }
9519 }.bind(this));
9520 }
9521 },
9522 /**
9523 * Adjust tooltip position on resize event
9524 * @private
9525 */
9526 bindTooltipResizePos: function bindTooltipResizePos() {
9527 var _this6 = this,
9528 $$ = this,
9529 resizeFunction = $$.resizeFunction,
9530 state = $$.state,
9531 tooltip = $$.$el.tooltip;
9532 resizeFunction.add(function () {
9533 _newArrowCheck(this, _this6);
9534 if (tooltip.style("display") === "block") {
9535 var current = state.current,
9536 _tooltip$datum = tooltip.datum(),
9537 width = _tooltip$datum.width,
9538 xPosInPercent = _tooltip$datum.xPosInPercent,
9539 _value = current.width / 100 * xPosInPercent,
9540 diff = current.width - (_value + width);
9541 // if tooltip size overs current viewport size
9542 if (diff < 0) {
9543 _value += diff;
9544 }
9545 tooltip.style("left", _value + "px");
9546 }
9547 }.bind(this));
9548 },
9549 /**
9550 * Hide the tooltip
9551 * @param {boolean} force Force to hide
9552 * @private
9553 */
9554 hideTooltip: function hideTooltip(force) {
9555 var $$ = this,
9556 api = $$.api,
9557 config = $$.config,
9558 tooltip = $$.$el.tooltip;
9559 if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
9560 var selectedData = JSON.parse(tooltip.datum().current);
9561 callFn(config.tooltip_onhide, api, selectedData);
9562
9563 // hide tooltip
9564 tooltip.style("display", "none").style("visibility", "hidden") // for IE9
9565 .datum(null);
9566 callFn(config.tooltip_onhidden, api, selectedData);
9567 }
9568 },
9569 /**
9570 * Toggle display for linked chart instances
9571 * @param {boolean} show true: show, false: hide
9572 * @param {number} index x Axis index
9573 * @private
9574 */
9575 _handleLinkedCharts: function _handleLinkedCharts(show, index) {
9576 var _this7 = this,
9577 $$ = this,
9578 charts = $$.charts,
9579 config = $$.config,
9580 event = $$.state.event;
9581 // Prevent propagation among instances if isn't instantiated from the user's event
9582 // https://github.com/naver/billboard.js/issues/1979
9583 if (event != null && event.isTrusted && config.tooltip_linked && charts.length > 1) {
9584 var linkedName = config.tooltip_linked_name;
9585 charts.filter(function (c) {
9586 _newArrowCheck(this, _this7);
9587 return c !== $$.api;
9588 }.bind(this)).forEach(function (c) {
9589 _newArrowCheck(this, _this7);
9590 var _c$internal = c.internal,
9591 config = _c$internal.config,
9592 $el = _c$internal.$el,
9593 isLinked = config.tooltip_linked,
9594 name = config.tooltip_linked_name,
9595 isInDom = browser_doc.body.contains($el.chart.node());
9596 if (isLinked && linkedName === name && isInDom) {
9597 var data = $el.tooltip.data()[0],
9598 isNotSameIndex = index !== (data == null ? void 0 : data.index);
9599 try {
9600 c.tooltip[show && isNotSameIndex ? "show" : "hide"]({
9601 index: index
9602 });
9603 } catch (e) {}
9604 }
9605 }.bind(this));
9606 }
9607 }
9608});
9609;// CONCATENATED MODULE: ./src/ChartInternal/internals/transform.ts
9610/**
9611 * Copyright (c) 2017 ~ present NAVER Corp.
9612 * billboard.js project is licensed under the MIT license
9613 */
9614
9615
9616/* harmony default export */ var transform = ({
9617 getTranslate: function getTranslate(target, index) {
9618 if (index === void 0) {
9619 index = 0;
9620 }
9621 var $$ = this,
9622 config = $$.config,
9623 state = $$.state,
9624 isRotated = config.axis_rotated,
9625 padding = 0,
9626 x,
9627 y;
9628 if (index && /^(x|y2?)$/.test(target)) {
9629 padding = $$.getAxisSize(target) * index;
9630 }
9631 if (target === "main") {
9632 x = asHalfPixel(state.margin.left);
9633 y = asHalfPixel(state.margin.top);
9634 } else if (target === "context") {
9635 x = asHalfPixel(state.margin2.left);
9636 y = asHalfPixel(state.margin2.top);
9637 } else if (target === "legend") {
9638 x = state.margin3.left;
9639 y = state.margin3.top;
9640 } else if (target === "x") {
9641 x = isRotated ? -padding : 0;
9642 y = isRotated ? 0 : state.height + padding;
9643 } else if (target === "y") {
9644 x = isRotated ? 0 : -padding;
9645 y = isRotated ? state.height + padding : 0;
9646 } else if (target === "y2") {
9647 x = isRotated ? 0 : state.width + padding;
9648 y = isRotated ? 1 - padding : 0;
9649 } else if (target === "subX") {
9650 x = 0;
9651 y = isRotated ? 0 : state.height2;
9652 } else if (target === "arc") {
9653 x = state.arcWidth / 2;
9654 y = state.arcHeight / 2;
9655 } else if (target === "polar") {
9656 x = state.arcWidth / 2;
9657 y = state.arcHeight / 2;
9658 } else if (target === "radar") {
9659 var _$$$getRadarSize = $$.getRadarSize(),
9660 width = _$$$getRadarSize[0];
9661 x = state.width / 2 - width;
9662 y = asHalfPixel(state.margin.top);
9663 }
9664 return "translate(" + x + ", " + y + ")";
9665 },
9666 transformMain: function transformMain(withTransition, transitions) {
9667 var $$ = this,
9668 main = $$.$el.main,
9669 $T = $$.$T,
9670 xAxis = transitions != null && transitions.axisX ? transitions.axisX : $T(main.select("." + $AXIS.axisX), withTransition),
9671 yAxis = transitions != null && transitions.axisY ? transitions.axisY : $T(main.select("." + $AXIS.axisY), withTransition),
9672 y2Axis = transitions != null && transitions.axisY2 ? transitions.axisY2 : $T(main.select("." + $AXIS.axisY2), withTransition);
9673 $T(main, withTransition).attr("transform", $$.getTranslate("main"));
9674 xAxis.attr("transform", $$.getTranslate("x"));
9675 yAxis.attr("transform", $$.getTranslate("y"));
9676 y2Axis.attr("transform", $$.getTranslate("y2"));
9677 main.select("." + $ARC.chartArcs).attr("transform", $$.getTranslate("arc"));
9678 },
9679 transformAll: function transformAll(withTransition, transitions) {
9680 var $$ = this,
9681 config = $$.config,
9682 hasAxis = $$.state.hasAxis,
9683 $el = $$.$el;
9684 $$.transformMain(withTransition, transitions);
9685 hasAxis && config.subchart_show && $$.transformContext(withTransition, transitions);
9686 $el.legend && $$.transformLegend(withTransition);
9687 }
9688});
9689;// CONCATENATED MODULE: ./src/ChartInternal/internals/type.ts
9690
9691/**
9692 * Copyright (c) 2017 ~ present NAVER Corp.
9693 * billboard.js project is licensed under the MIT license
9694 */
9695
9696
9697/* harmony default export */ var type = ({
9698 setTargetType: function setTargetType(targetIds, type) {
9699 var _this = this,
9700 $$ = this,
9701 config = $$.config,
9702 withoutFadeIn = $$.state.withoutFadeIn;
9703 $$.mapToTargetIds(targetIds).forEach(function (id) {
9704 _newArrowCheck(this, _this);
9705 withoutFadeIn[id] = type === config.data_types[id];
9706 config.data_types[id] = type;
9707 }.bind(this));
9708 if (!targetIds) {
9709 config.data_type = type;
9710 }
9711 },
9712 /**
9713 * Updte current used chart types
9714 * @private
9715 */
9716 updateTypesElements: function updateTypesElements() {
9717 var _this2 = this,
9718 $$ = this,
9719 current = $$.state.current;
9720 Object.keys(TYPE).forEach(function (v) {
9721 _newArrowCheck(this, _this2);
9722 var t = TYPE[v],
9723 has = $$.hasType(t, null, !0),
9724 idx = current.types.indexOf(t);
9725 if (idx === -1 && has) {
9726 current.types.push(t);
9727 } else if (idx > -1 && !has) {
9728 current.types.splice(idx, 1);
9729 }
9730 }.bind(this));
9731
9732 // Update current chart elements reference
9733 $$.setChartElements();
9734 },
9735 /**
9736 * Check if given chart types exists
9737 * @param {string} type Chart type
9738 * @param {Array} targetsValue Data array
9739 * @param {boolean} checkFromData Force to check type cotains from data targets
9740 * @returns {boolean}
9741 * @private
9742 */
9743 hasType: function hasType(type, targetsValue, checkFromData) {
9744 var _current$types,
9745 _this3 = this;
9746 if (checkFromData === void 0) {
9747 checkFromData = !1;
9748 }
9749 var $$ = this,
9750 config = $$.config,
9751 current = $$.state.current,
9752 types = config.data_types,
9753 targets = targetsValue || $$.data.targets,
9754 has = !1;
9755 if (!checkFromData && ((_current$types = current.types) == null ? void 0 : _current$types.indexOf(type)) > -1) {
9756 has = !0;
9757 } else if (targets != null && targets.length) {
9758 targets.forEach(function (target) {
9759 _newArrowCheck(this, _this3);
9760 var t = types[target.id];
9761 if (t === type || !t && type === "line") {
9762 has = !0;
9763 }
9764 }.bind(this));
9765 } else if (Object.keys(types).length) {
9766 Object.keys(types).forEach(function (id) {
9767 _newArrowCheck(this, _this3);
9768 if (types[id] === type) {
9769 has = !0;
9770 }
9771 }.bind(this));
9772 } else {
9773 has = config.data_type === type;
9774 }
9775 return has;
9776 },
9777 /**
9778 * Check if contains given chart types
9779 * @param {string} type Type key
9780 * @param {object} targets Target data
9781 * @param {Array} exclude Excluded types
9782 * @returns {boolean}
9783 * @private
9784 */
9785 hasTypeOf: function hasTypeOf(type, targets, exclude) {
9786 var _this4 = this;
9787 if (exclude === void 0) {
9788 exclude = [];
9789 }
9790 if (type in TYPE_BY_CATEGORY) {
9791 return !TYPE_BY_CATEGORY[type].filter(function (v) {
9792 _newArrowCheck(this, _this4);
9793 return exclude.indexOf(v) === -1;
9794 }.bind(this)).every(function (v) {
9795 _newArrowCheck(this, _this4);
9796 return !this.hasType(v, targets);
9797 }.bind(this));
9798 }
9799 return !1;
9800 },
9801 /**
9802 * Check if given data is certain chart type
9803 * @param {object} d Data object
9804 * @param {string|Array} type chart type
9805 * @returns {boolean}
9806 * @private
9807 */
9808 isTypeOf: function isTypeOf(d, type) {
9809 var id = isString(d) ? d : d.id,
9810 dataType = this.config.data_types[id] || this.config.data_type;
9811 return isArray(type) ? type.indexOf(dataType) >= 0 : dataType === type;
9812 },
9813 hasPointType: function hasPointType() {
9814 var $$ = this;
9815 return $$.hasTypeOf("Line") || $$.hasType("bubble") || $$.hasType("scatter");
9816 },
9817 /**
9818 * Check if contains arc types chart
9819 * @param {object} targets Target data
9820 * @param {Array} exclude Excluded types
9821 * @returns {boolean}
9822 * @private
9823 */
9824 hasArcType: function hasArcType(targets, exclude) {
9825 return this.hasTypeOf("Arc", targets, exclude);
9826 },
9827 hasMultiArcGauge: function hasMultiArcGauge() {
9828 return this.hasType("gauge") && this.config.gauge_type === "multi";
9829 },
9830 isLineType: function isLineType(d) {
9831 var id = isString(d) ? d : d.id;
9832 return !this.config.data_types[id] || this.isTypeOf(id, TYPE_BY_CATEGORY.Line);
9833 },
9834 isStepType: function isStepType(d) {
9835 return this.isTypeOf(d, TYPE_BY_CATEGORY.Step);
9836 },
9837 isSplineType: function isSplineType(d) {
9838 return this.isTypeOf(d, TYPE_BY_CATEGORY.Spline);
9839 },
9840 isAreaType: function isAreaType(d) {
9841 return this.isTypeOf(d, TYPE_BY_CATEGORY.Area);
9842 },
9843 isAreaRangeType: function isAreaRangeType(d) {
9844 return this.isTypeOf(d, TYPE_BY_CATEGORY.AreaRange);
9845 },
9846 isBarType: function isBarType(d) {
9847 return this.isTypeOf(d, "bar");
9848 },
9849 isBubbleType: function isBubbleType(d) {
9850 return this.isTypeOf(d, "bubble");
9851 },
9852 isCandlestickType: function isCandlestickType(d) {
9853 return this.isTypeOf(d, "candlestick");
9854 },
9855 isScatterType: function isScatterType(d) {
9856 return this.isTypeOf(d, "scatter");
9857 },
9858 isPieType: function isPieType(d) {
9859 return this.isTypeOf(d, "pie");
9860 },
9861 isGaugeType: function isGaugeType(d) {
9862 return this.isTypeOf(d, "gauge");
9863 },
9864 isDonutType: function isDonutType(d) {
9865 return this.isTypeOf(d, "donut");
9866 },
9867 isPolarType: function isPolarType(d) {
9868 return this.isTypeOf(d, "polar");
9869 },
9870 isRadarType: function isRadarType(d) {
9871 return this.isTypeOf(d, "radar");
9872 },
9873 isArcType: function isArcType(d) {
9874 return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d) || this.isPolarType(d) || this.isRadarType(d);
9875 },
9876 // determine if is 'circle' data point
9877 isCirclePoint: function isCirclePoint(node) {
9878 var config = this.config,
9879 pattern = config.point_pattern,
9880 isCircle = !1;
9881 if ((node == null ? void 0 : node.tagName) === "circle") {
9882 isCircle = !0;
9883 } else {
9884 isCircle = config.point_type === "circle" && (!pattern || isArray(pattern) && pattern.length === 0);
9885 }
9886 return isCircle;
9887 },
9888 lineData: function lineData(d) {
9889 return this.isLineType(d) ? [d] : [];
9890 },
9891 arcData: function arcData(d) {
9892 return this.isArcType(d.data) ? [d] : [];
9893 },
9894 /**
9895 * Get data adapt for data label showing
9896 * @param {object} d Data object
9897 * @returns {Array}
9898 * @private
9899 */
9900 labelishData: function labelishData(d) {
9901 var _this5 = this;
9902 return this.isBarType(d) || this.isLineType(d) || this.isScatterType(d) || this.isBubbleType(d) || this.isCandlestickType(d) || this.isRadarType(d) ? d.values.filter(function (v) {
9903 _newArrowCheck(this, _this5);
9904 return isNumber(v.value) || !!v.value;
9905 }.bind(this)) : [];
9906 },
9907 barLineBubbleData: function barLineBubbleData(d) {
9908 return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ? d.values : [];
9909 },
9910 // https://github.com/d3/d3-shape#curves
9911 isInterpolationType: function isInterpolationType(type) {
9912 return ["basis", "basis-closed", "basis-open", "bundle", "cardinal", "cardinal-closed", "cardinal-open", "catmull-rom", "catmull-rom-closed", "catmull-rom-open", "linear", "linear-closed", "monotone-x", "monotone-y", "natural"].indexOf(type) >= 0;
9913 }
9914});
9915;// CONCATENATED MODULE: ./src/ChartInternal/ChartInternal.ts
9916
9917/**
9918 * Copyright (c) 2017 ~ present NAVER Corp.
9919 * billboard.js project is licensed under the MIT license
9920 * @ignore
9921 */
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933// data
9934
9935
9936
9937
9938// interactions
9939
9940
9941// internals
9942
9943 // used to retrieve radar Axis name
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959/**
9960 * Internal chart class.
9961 * - Note: Instantiated internally, not exposed for public.
9962 * @class ChartInternal
9963 * @ignore
9964 * @private
9965 */
9966var ChartInternal = /*#__PURE__*/function () {
9967 // API interface
9968 // config object
9969 // cache instance
9970 // elements
9971 // state variables
9972 // all Chart instances array within page (equivalent of 'bb.instances')
9973
9974 // data object
9975
9976 // Axis
9977 // Axis
9978
9979 // scales
9980
9981 // original values
9982
9983 // formatter function
9984
9985 // format function
9986
9987 function ChartInternal(api) {
9988 this.api = void 0;
9989 this.config = void 0;
9990 this.cache = void 0;
9991 this.$el = void 0;
9992 this.state = void 0;
9993 this.charts = void 0;
9994 this.data = {
9995 xs: {},
9996 targets: []
9997 };
9998 this.axis = void 0;
9999 this.scale = {
10000 x: null,
10001 y: null,
10002 y2: null,
10003 subX: null,
10004 subY: null,
10005 subY2: null,
10006 zoom: null
10007 };
10008 this.org = {
10009 xScale: null,
10010 xDomain: null
10011 };
10012 this.color = void 0;
10013 this.patterns = void 0;
10014 this.levelColor = void 0;
10015 this.point = void 0;
10016 this.brush = void 0;
10017 this.format = {
10018 extraLineClasses: null,
10019 xAxisTick: null,
10020 dataTime: null,
10021 // dataTimeFormat
10022 defaultAxisTime: null,
10023 // defaultAxisTimeFormat
10024 axisTime: null // axisTimeFormat
10025 };
10026
10027 var $$ = this;
10028 $$.api = api; // Chart class instance alias
10029 $$.config = new Options();
10030 $$.cache = new Cache();
10031 var store = new Store();
10032 $$.$el = store.getStore("element");
10033 $$.state = store.getStore("state");
10034 $$.$T = $$.$T.bind($$);
10035 }
10036
10037 /**
10038 * Get the selection based on transition config
10039 * @param {SVGElement|d3Selection} selection Target selection
10040 * @param {boolean} force Force transition
10041 * @param {string} name Transition name
10042 * @returns {d3Selection}
10043 * @private
10044 */
10045 var _proto = ChartInternal.prototype;
10046 _proto.$T = function $T(selection, force, name) {
10047 var config = this.config,
10048 state = this.state,
10049 duration = config.transition_duration,
10050 subchart = config.subchart_show,
10051 t = selection;
10052 if (t) {
10053 // in case of non d3 selection, wrap with d3 selection
10054 if ("tagName" in t) {
10055 t = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(t);
10056 }
10057
10058 // do not transit on:
10059 // - wheel zoom (state.zooming = true)
10060 // - when has no subchart
10061 // - initialization
10062 // - resizing
10063 var transit = (force !== !1 && duration || force) && (!state.zooming || state.dragging) && !state.resizing && state.rendered && !subchart;
10064 t = transit ? t.transition(name).duration(duration) : t;
10065 }
10066 return t;
10067 };
10068 _proto.beforeInit = function beforeInit() {
10069 var $$ = this;
10070 $$.callPluginHook("$beforeInit");
10071
10072 // can do something
10073 callFn($$.config.onbeforeinit, $$.api);
10074 };
10075 _proto.afterInit = function afterInit() {
10076 var $$ = this;
10077 $$.callPluginHook("$afterInit");
10078
10079 // can do something
10080 callFn($$.config.onafterinit, $$.api);
10081 };
10082 _proto.init = function init() {
10083 var $$ = this,
10084 config = $$.config,
10085 state = $$.state,
10086 $el = $$.$el,
10087 useCssRule = config.boost_useCssRule;
10088 checkModuleImport($$);
10089 state.hasAxis = !$$.hasArcType();
10090 state.hasRadar = !state.hasAxis && $$.hasType("radar");
10091
10092 // datetime to be used for uniqueness
10093 state.datetimeId = "bb-" + +new Date() * getRandom();
10094 if (useCssRule) {
10095 // append style element
10096 var styleEl = browser_doc.createElement("style");
10097
10098 // styleEl.id = styleId;
10099 styleEl.type = "text/css";
10100 browser_doc.head.appendChild(styleEl);
10101 state.style = {
10102 rootSelctor: "." + state.datetimeId,
10103 sheet: styleEl.sheet
10104 };
10105
10106 // used on .destroy()
10107 $el.style = styleEl;
10108 }
10109 var bindto = {
10110 element: config.bindto,
10111 classname: "bb"
10112 };
10113 if (isObject(config.bindto)) {
10114 bindto.element = config.bindto.element || "#chart";
10115 bindto.classname = config.bindto.classname || bindto.classname;
10116 }
10117
10118 // select bind element
10119 $el.chart = isFunction(bindto.element.node) ? config.bindto.element : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(bindto.element || []);
10120 if ($el.chart.empty()) {
10121 $el.chart = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.body.appendChild(browser_doc.createElement("div")));
10122 }
10123 $el.chart.html("").classed(bindto.classname, !0).classed(state.datetimeId, useCssRule).style("position", "relative");
10124 $$.initParams();
10125 $$.initToRender();
10126 }
10127
10128 /**
10129 * Initialize the rendering process
10130 * @param {boolean} forced Force to render process
10131 * @private
10132 */;
10133 _proto.initToRender = function initToRender(forced) {
10134 var _this = this,
10135 $$ = this,
10136 config = $$.config,
10137 state = $$.state,
10138 chart = $$.$el.chart,
10139 isHidden = function () {
10140 _newArrowCheck(this, _this);
10141 return chart.style("display") === "none" || chart.style("visibility") === "hidden";
10142 }.bind(this),
10143 isLazy = config.render.lazy || isHidden(),
10144 MutationObserver = win.MutationObserver;
10145 if (isLazy && MutationObserver && config.render.observe !== !1 && !forced) {
10146 new MutationObserver(function (mutation, observer) {
10147 _newArrowCheck(this, _this);
10148 if (!isHidden()) {
10149 observer.disconnect();
10150 state.rendered || $$.initToRender(!0);
10151 }
10152 }.bind(this)).observe(chart.node(), {
10153 attributes: !0,
10154 attributeFilter: ["class", "style"]
10155 });
10156 }
10157 if (!isLazy || forced) {
10158 $$.convertData(config, function (res) {
10159 _newArrowCheck(this, _this);
10160 $$.initWithData(res);
10161 $$.afterInit();
10162 }.bind(this));
10163 }
10164 };
10165 _proto.initParams = function initParams() {
10166 var _this2 = this,
10167 $$ = this,
10168 config = $$.config,
10169 format = $$.format,
10170 state = $$.state,
10171 isRotated = config.axis_rotated;
10172 // color settings
10173 $$.color = $$.generateColor();
10174 $$.levelColor = $$.generateLevelColor();
10175
10176 // when 'padding=false' is set, disable axes and subchart. Because they are useless.
10177 if (config.padding === !1) {
10178 config.axis_x_show = !1;
10179 config.axis_y_show = !1;
10180 config.axis_y2_show = !1;
10181 config.subchart_show = !1;
10182 }
10183 if ($$.hasPointType()) {
10184 $$.point = $$.generatePoint();
10185 }
10186 if (state.hasAxis) {
10187 $$.initClip();
10188 format.extraLineClasses = $$.generateExtraLineClass();
10189 format.dataTime = config.data_xLocaltime ? external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.timeParse : external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.utcParse;
10190 format.axisTime = config.axis_x_localtime ? external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.timeFormat : external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.utcFormat;
10191 var isDragZoom = $$.config.zoom_enabled && $$.config.zoom_type === "drag";
10192 format.defaultAxisTime = function (d) {
10193 _newArrowCheck(this, _this2);
10194 var _$$$scale = $$.scale,
10195 x = _$$$scale.x,
10196 zoom = _$$$scale.zoom,
10197 isZoomed = isDragZoom ? zoom : zoom && x.orgDomain().toString() !== zoom.domain().toString(),
10198 specifier = d.getMilliseconds() && ".%L" || d.getSeconds() && ".:%S" || d.getMinutes() && "%I:%M" || d.getHours() && "%I %p" || d.getDate() !== 1 && "%b %d" || isZoomed && d.getDate() === 1 && "%b\'%y" || d.getMonth() && "%-m/%-d" || "%Y";
10199 return format.axisTime(specifier)(d);
10200 }.bind(this);
10201 }
10202 state.isLegendRight = config.legend_position === "right";
10203 state.isLegendInset = config.legend_position === "inset";
10204 state.isLegendTop = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "top-right";
10205 state.isLegendLeft = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "bottom-left";
10206 state.rotatedPadding.top = $$.getResettedPadding(state.rotatedPadding.top);
10207 state.rotatedPadding.right = isRotated && !config.axis_x_show ? 0 : 30;
10208 state.inputType = convertInputType(config.interaction_inputType_mouse, config.interaction_inputType_touch);
10209 };
10210 _proto.initWithData = function initWithData(data) {
10211 var _this3 = this,
10212 $$ = this,
10213 config = $$.config,
10214 scale = $$.scale,
10215 state = $$.state,
10216 $el = $$.$el,
10217 org = $$.org,
10218 hasAxis = state.hasAxis,
10219 hasInteraction = config.interaction_enabled,
10220 hasPolar = $$.hasType("polar");
10221 // for arc type, set axes to not be shown
10222 // $$.hasArcType() && ["x", "y", "y2"].forEach(id => (config[`axis_${id}_show`] = false));
10223
10224 if (hasAxis) {
10225 $$.axis = $$.getAxisInstance();
10226 config.zoom_enabled && $$.initZoom();
10227 }
10228
10229 // Init data as targets
10230 $$.data.xs = {};
10231 $$.data.targets = $$.convertDataToTargets(data);
10232 if (config.data_filter) {
10233 $$.data.targets = $$.data.targets.filter(config.data_filter.bind($$.api));
10234 }
10235
10236 // Set targets to hide if needed
10237 if (config.data_hide) {
10238 $$.addHiddenTargetIds(config.data_hide === !0 ? $$.mapToIds($$.data.targets) : config.data_hide);
10239 }
10240 if (config.legend_hide) {
10241 $$.addHiddenLegendIds(config.legend_hide === !0 ? $$.mapToIds($$.data.targets) : config.legend_hide);
10242 }
10243
10244 // Init sizes and scales
10245 $$.updateSizes();
10246 $$.updateScales(!0);
10247
10248 // retrieve scale after the 'updateScales()' is called
10249 var x = scale.x,
10250 y = scale.y,
10251 y2 = scale.y2,
10252 subX = scale.subX,
10253 subY = scale.subY,
10254 subY2 = scale.subY2;
10255
10256 // Set domains for each scale
10257 if (x) {
10258 x.domain(sortValue($$.getXDomain($$.data.targets)));
10259 subX.domain(x.domain());
10260
10261 // Save original x domain for zoom update
10262 org.xDomain = x.domain();
10263 }
10264 if (y) {
10265 y.domain($$.getYDomain($$.data.targets, "y"));
10266 subY.domain(y.domain());
10267 }
10268 if (y2) {
10269 y2.domain($$.getYDomain($$.data.targets, "y2"));
10270 subY2 && subY2.domain(y2.domain());
10271 }
10272
10273 // -- Basic Elements --
10274 $el.svg = $el.chart.append("svg").style("overflow", "hidden").style("display", "block");
10275 if (hasInteraction && state.inputType) {
10276 var isTouch = state.inputType === "touch",
10277 onclick = config.onclick,
10278 onover = config.onover,
10279 onout = config.onout;
10280 $el.svg.on("click", (onclick == null ? void 0 : onclick.bind($$.api)) || null).on(isTouch ? "touchstart" : "mouseenter", (onover == null ? void 0 : onover.bind($$.api)) || null).on(isTouch ? "touchend" : "mouseleave", (onout == null ? void 0 : onout.bind($$.api)) || null);
10281 }
10282 config.svg_classname && $el.svg.attr("class", config.svg_classname);
10283
10284 // Define defs
10285 var hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
10286 if (hasAxis || hasColorPatterns || config.data_labels_backgroundColors || hasPolar) {
10287 $el.defs = $el.svg.append("defs");
10288 if (hasAxis) {
10289 ["id", "idXAxis", "idYAxis", "idGrid"].forEach(function (v) {
10290 _newArrowCheck(this, _this3);
10291 $$.appendClip($el.defs, state.clip[v]);
10292 }.bind(this));
10293 }
10294
10295 // Append data background color filter definition
10296 $$.generateDataLabelBackgroundColorFilter();
10297
10298 // set color patterns
10299 if (hasColorPatterns) {
10300 $$.patterns.forEach(function (p) {
10301 var _this4 = this;
10302 _newArrowCheck(this, _this3);
10303 return $el.defs.append(function () {
10304 _newArrowCheck(this, _this4);
10305 return p.node;
10306 }.bind(this));
10307 }.bind(this));
10308 }
10309 }
10310 $$.updateSvgSize();
10311
10312 // Bind resize event
10313 $$.bindResize();
10314
10315 // Define regions
10316 var main = $el.svg.append("g").classed($COMMON.main, !0).attr("transform", $$.getTranslate("main"));
10317 $el.main = main;
10318
10319 // initialize subchart when subchart show option is set
10320 config.subchart_show && $$.initSubchart();
10321 config.tooltip_show && $$.initTooltip();
10322 config.title_text && $$.initTitle();
10323 config.legend_show && $$.initLegend();
10324
10325 // -- Main Region --
10326
10327 // text when empty
10328 if (config.data_empty_label_text) {
10329 main.append("text").attr("class", $TEXT.text + " " + $COMMON.empty).attr("text-anchor", "middle") // horizontal centering of text at x position in all browsers.
10330 .attr("dominant-baseline", "middle"); // vertical centering of text at y position in all browsers, except IE.
10331 }
10332
10333 if (hasAxis) {
10334 // Regions
10335 config.regions.length && $$.initRegion();
10336
10337 // Add Axis here, when clipPath is 'false'
10338 config.clipPath || $$.axis.init();
10339 }
10340
10341 // Define g for chart area
10342 main.append("g").classed($COMMON.chart, !0).attr("clip-path", hasAxis ? state.clip.path : null);
10343 $$.callPluginHook("$init");
10344 if (hasAxis) {
10345 var _$$$axis;
10346 // Cover whole with rects for events
10347 hasInteraction && ($$.initEventRect == null ? void 0 : $$.initEventRect());
10348
10349 // Grids
10350 $$.initGrid();
10351
10352 // Add Axis here, when clipPath is 'true'
10353 config.clipPath && ((_$$$axis = $$.axis) == null ? void 0 : _$$$axis.init());
10354 }
10355 $$.initChartElements();
10356
10357 // Set targets
10358 $$.updateTargets($$.data.targets);
10359
10360 // Draw with targets
10361 $$.updateDimension();
10362
10363 // oninit callback
10364 callFn(config.oninit, $$.api);
10365
10366 // Set background
10367 $$.setBackground();
10368 $$.redraw({
10369 withTransition: !1,
10370 withTransform: !0,
10371 withUpdateXDomain: !0,
10372 withUpdateOrgXDomain: !0,
10373 withTransitionForAxis: !1,
10374 initializing: !0
10375 });
10376
10377 // data.onmin/max callback
10378 if (config.data_onmin || config.data_onmax) {
10379 var minMax = $$.getMinMaxData();
10380 callFn(config.data_onmin, $$.api, minMax.min);
10381 callFn(config.data_onmax, $$.api, minMax.max);
10382 }
10383 config.tooltip_show && $$.initShowTooltip();
10384 state.rendered = !0;
10385 }
10386
10387 /**
10388 * Initialize chart elements
10389 * @private
10390 */;
10391 _proto.initChartElements = function initChartElements() {
10392 var _this5 = this,
10393 $$ = this,
10394 _$$$state = $$.state,
10395 hasAxis = _$$$state.hasAxis,
10396 hasRadar = _$$$state.hasRadar,
10397 types = [];
10398 if (hasAxis) {
10399 ["bar", "bubble", "candlestick", "line"].forEach(function (v) {
10400 _newArrowCheck(this, _this5);
10401 var name = capitalize(v);
10402 if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
10403 types.push(name);
10404 }
10405 }.bind(this));
10406 } else {
10407 var hasPolar = $$.hasType("polar");
10408 if (!hasRadar) {
10409 types.push("Arc", "Pie");
10410 }
10411 if ($$.hasType("gauge")) {
10412 types.push("Gauge");
10413 } else if (hasRadar) {
10414 types.push("Radar");
10415 } else if (hasPolar) {
10416 types.push("Polar");
10417 }
10418 }
10419 types.forEach(function (v) {
10420 _newArrowCheck(this, _this5);
10421 $$["init" + v]();
10422 }.bind(this));
10423 notEmpty($$.config.data_labels) && !$$.hasArcType(null, ["radar"]) && $$.initText();
10424 }
10425
10426 /**
10427 * Set chart elements
10428 * @private
10429 */;
10430 _proto.setChartElements = function setChartElements() {
10431 var $$ = this,
10432 _$$$$el = $$.$el,
10433 chart = _$$$$el.chart,
10434 svg = _$$$$el.svg,
10435 defs = _$$$$el.defs,
10436 main = _$$$$el.main,
10437 tooltip = _$$$$el.tooltip,
10438 legend = _$$$$el.legend,
10439 title = _$$$$el.title,
10440 grid = _$$$$el.grid,
10441 arc = _$$$$el.arcs,
10442 circles = _$$$$el.circle,
10443 bars = _$$$$el.bar,
10444 candlestick = _$$$$el.candlestick,
10445 lines = _$$$$el.line,
10446 areas = _$$$$el.area,
10447 texts = _$$$$el.text;
10448 $$.api.$ = {
10449 chart: chart,
10450 svg: svg,
10451 defs: defs,
10452 main: main,
10453 tooltip: tooltip,
10454 legend: legend,
10455 title: title,
10456 grid: grid,
10457 arc: arc,
10458 circles: circles,
10459 bar: {
10460 bars: bars
10461 },
10462 candlestick: candlestick,
10463 line: {
10464 lines: lines,
10465 areas: areas
10466 },
10467 text: {
10468 texts: texts
10469 }
10470 };
10471 }
10472
10473 /**
10474 * Set background element/image
10475 * @private
10476 */;
10477 _proto.setBackground = function setBackground() {
10478 var $$ = this,
10479 bg = $$.config.background,
10480 state = $$.state,
10481 svg = $$.$el.svg;
10482 if (notEmpty(bg)) {
10483 var element = svg.select("g").insert(bg.imgUrl ? "image" : "rect", ":first-child");
10484 if (bg.imgUrl) {
10485 element.attr("href", bg.imgUrl);
10486 } else if (bg.color) {
10487 element.style("fill", bg.color).attr("clip-path", state.clip.path);
10488 }
10489 element.attr("class", bg.class || null).attr("width", "100%").attr("height", "100%");
10490 }
10491 }
10492
10493 /**
10494 * Update targeted element with given data
10495 * @param {object} targets Data object formatted as 'target'
10496 * @private
10497 */;
10498 _proto.updateTargets = function updateTargets(targets) {
10499 var _this6 = this,
10500 $$ = this,
10501 _$$$state2 = $$.state,
10502 hasAxis = _$$$state2.hasAxis,
10503 hasRadar = _$$$state2.hasRadar,
10504 helper = function (type) {
10505 _newArrowCheck(this, _this6);
10506 return $$["updateTargetsFor" + type](targets.filter($$["is" + type + "Type"].bind($$)));
10507 }.bind(this);
10508 // Text
10509 $$.updateTargetsForText(targets);
10510 if (hasAxis) {
10511 ["bar", "candlestick", "line"].forEach(function (v) {
10512 _newArrowCheck(this, _this6);
10513 var name = capitalize(v);
10514 if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
10515 helper(name);
10516 }
10517 }.bind(this));
10518
10519 // Sub Chart
10520 $$.updateTargetsForSubchart && $$.updateTargetsForSubchart(targets);
10521
10522 // Arc, Polar, Radar
10523 } else if ($$.hasArcType(targets)) {
10524 var type = "Arc";
10525 if (hasRadar) {
10526 type = "Radar";
10527 } else if ($$.hasType("polar")) {
10528 type = "Polar";
10529 }
10530 helper(type);
10531 }
10532
10533 // Point types
10534 var hasPointType = $$.hasType("bubble") || $$.hasType("scatter");
10535 if (hasPointType) {
10536 $$.updateTargetForCircle == null ? void 0 : $$.updateTargetForCircle();
10537 }
10538
10539 // Fade-in each chart
10540 $$.filterTargetsToShowAtInit(hasPointType);
10541 }
10542
10543 /**
10544 * Display targeted elements at initialization
10545 * @param {boolean} hasPointType whether has point type(bubble, scatter) or not
10546 * @private
10547 */;
10548 _proto.filterTargetsToShowAtInit = function filterTargetsToShowAtInit(hasPointType) {
10549 var _this7 = this;
10550 if (hasPointType === void 0) {
10551 hasPointType = !1;
10552 }
10553 var $$ = this,
10554 svg = $$.$el.svg,
10555 $T = $$.$T,
10556 selector = "." + $COMMON.target;
10557 if (hasPointType) {
10558 selector += ", ." + $CIRCLE.chartCircles + " > ." + $CIRCLE.circles;
10559 }
10560 $T(svg.selectAll(selector).filter(function (d) {
10561 _newArrowCheck(this, _this7);
10562 return $$.isTargetToShow(d.id);
10563 }.bind(this))).style("opacity", null);
10564 };
10565 _proto.getWithOption = function getWithOption(options) {
10566 var _this8 = this,
10567 withOptions = {
10568 Dimension: !0,
10569 EventRect: !0,
10570 Legend: !1,
10571 Subchart: !0,
10572 Transform: !1,
10573 Transition: !0,
10574 TrimXDomain: !0,
10575 UpdateXAxis: "UpdateXDomain",
10576 UpdateXDomain: !1,
10577 UpdateOrgXDomain: !1,
10578 TransitionForExit: "Transition",
10579 TransitionForAxis: "Transition",
10580 Y: !0
10581 };
10582 Object.keys(withOptions).forEach(function (key) {
10583 _newArrowCheck(this, _this8);
10584 var defVal = withOptions[key];
10585 if (isString(defVal)) {
10586 defVal = withOptions[defVal];
10587 }
10588 withOptions[key] = getOption(options, "with" + key, defVal);
10589 }.bind(this));
10590 return withOptions;
10591 };
10592 _proto.initialOpacity = function initialOpacity(d) {
10593 var $$ = this,
10594 withoutFadeIn = $$.state.withoutFadeIn,
10595 r = $$.getBaseValue(d) !== null && withoutFadeIn[d.id] ? null : "0";
10596 return r;
10597 };
10598 _proto.bindResize = function bindResize() {
10599 var _this9 = this,
10600 $$ = this,
10601 config = $$.config,
10602 state = $$.state,
10603 resizeFunction = generateResize(config.resize_timer),
10604 list = [];
10605 list.push(function () {
10606 _newArrowCheck(this, _this9);
10607 return callFn(config.onresize, $$.api);
10608 }.bind(this));
10609 if (config.resize_auto) {
10610 list.push(function () {
10611 _newArrowCheck(this, _this9);
10612 state.resizing = !0;
10613
10614 // https://github.com/naver/billboard.js/issues/2650
10615 if (config.legend_show) {
10616 $$.updateSizes();
10617 $$.updateLegend();
10618 }
10619 $$.api.flush(!1);
10620 }.bind(this));
10621 }
10622 list.push(function () {
10623 _newArrowCheck(this, _this9);
10624 callFn(config.onresized, $$.api);
10625 state.resizing = !1;
10626 }.bind(this));
10627
10628 // add resize functions
10629 list.forEach(function (v) {
10630 _newArrowCheck(this, _this9);
10631 return resizeFunction.add(v);
10632 }.bind(this));
10633 $$.resizeFunction = resizeFunction;
10634
10635 // attach resize event
10636 win.addEventListener("resize", $$.resizeFunction = resizeFunction);
10637 }
10638
10639 /**
10640 * Call plugin hook
10641 * @param {string} phase The lifecycle phase
10642 * @param {Array} args Arguments
10643 * @private
10644 */;
10645 _proto.callPluginHook = function callPluginHook(phase) {
10646 for (var _this10 = this, _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
10647 args[_key - 1] = arguments[_key];
10648 }
10649 this.config.plugins.forEach(function (v) {
10650 _newArrowCheck(this, _this10);
10651 if (phase === "$beforeInit") {
10652 v.$$ = this;
10653 this.api.plugins.push(v);
10654 }
10655 v[phase].apply(v, args);
10656 }.bind(this));
10657 };
10658 return ChartInternal;
10659}();
10660
10661extend(ChartInternal.prototype, [
10662// common
10663convert, data_data, load, category, internals_class, internals_color, domain, interactions_interaction, format, internals_legend, redraw, scale, shape, size, style, internals_text, internals_title, internals_tooltip, transform, type]);
10664;// CONCATENATED MODULE: ./src/config/config.ts
10665
10666/**
10667 * Copyright (c) 2017 ~ present NAVER Corp.
10668 * billboard.js project is licensed under the MIT license
10669 */
10670
10671/**
10672 * Load configuration option
10673 * @param {object} config User's generation config value
10674 * @private
10675 */
10676function loadConfig(config) {
10677 var _this = this,
10678 thisConfig = this.config,
10679 target,
10680 keys,
10681 read,
10682 find = function () {
10683 _newArrowCheck(this, _this);
10684 var key = keys.shift();
10685 if (key && target && isObjectType(target) && key in target) {
10686 target = target[key];
10687 return find();
10688 } else if (!key) {
10689 return target;
10690 }
10691 return undefined;
10692 }.bind(this);
10693 Object.keys(thisConfig).forEach(function (key) {
10694 _newArrowCheck(this, _this);
10695 target = config;
10696 keys = key.split("_");
10697 read = find();
10698 if (isDefined(read)) {
10699 thisConfig[key] = read;
10700 }
10701 }.bind(this));
10702
10703 // only should run in the ChartInternal context
10704 if (this.api) {
10705 this.state.orgConfig = config;
10706 }
10707}
10708;// CONCATENATED MODULE: ./src/Chart/api/chart.ts
10709
10710/**
10711 * Copyright (c) 2017 ~ present NAVER Corp.
10712 * billboard.js project is licensed under the MIT license
10713 */
10714
10715
10716/* harmony default export */ var chart = ({
10717 /**
10718 * Resize the chart.
10719 * @function resize
10720 * @instance
10721 * @memberof Chart
10722 * @param {object} size This argument should include width and height in pixels.
10723 * @param {number} [size.width] width value
10724 * @param {number} [size.height] height value
10725 * @example
10726 * // Resize to 640x480
10727 * chart.resize({
10728 * width: 640,
10729 * height: 480
10730 * });
10731 */
10732 resize: function resize(size) {
10733 var $$ = this.internal,
10734 config = $$.config,
10735 state = $$.state;
10736 if (state.rendered) {
10737 config.size_width = size ? size.width : null;
10738 config.size_height = size ? size.height : null;
10739 state.resizing = !0;
10740 this.flush(!1);
10741 $$.resizeFunction();
10742 }
10743 },
10744 /**
10745 * Force to redraw.
10746 * - **NOTE:** When zoom/subchart is used, the zoomed state will be resetted.
10747 * @function flush
10748 * @instance
10749 * @memberof Chart
10750 * @param {boolean} [soft] For soft redraw.
10751 * @example
10752 * chart.flush();
10753 *
10754 * // for soft redraw
10755 * chart.flush(true);
10756 */
10757 flush: function flush(soft) {
10758 var $$ = this.internal,
10759 state = $$.state,
10760 zoomResetBtn = $$.$el.zoomResetBtn;
10761 if (state.rendered) {
10762 // reset possible zoom scale when is called from resize event
10763 // eslint-disable-next-line prefer-rest-params
10764 if (state.resizing) {
10765 var _$$$brush;
10766 // arguments[1] is given when is called from resize
10767 (_$$$brush = $$.brush) == null ? void 0 : _$$$brush.updateResize();
10768 } else {
10769 var _$$$axis;
10770 // re-update config info
10771 (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.setOrient();
10772 }
10773
10774 // hide possible reset zoom button
10775 // https://github.com/naver/billboard.js/issues/2201
10776 zoomResetBtn == null ? void 0 : zoomResetBtn.style("display", "none");
10777 $$.scale.zoom = null;
10778 soft ? $$.redraw({
10779 withTransform: !0,
10780 withUpdateXDomain: !0,
10781 withUpdateOrgXDomain: !0,
10782 withLegend: !0
10783 }) : $$.updateAndRedraw({
10784 withLegend: !0,
10785 withTransition: !1,
10786 withTransitionForTransform: !1
10787 });
10788
10789 // reset subchart selection & selection state
10790 if (!state.resizing && $$.brush) {
10791 $$.brush.getSelection().call($$.brush.move);
10792 $$.unselectRect();
10793 }
10794 } else {
10795 $$.initToRender(!0);
10796 }
10797 },
10798 /**
10799 * Reset the chart object and remove element and events completely.
10800 * @function destroy
10801 * @instance
10802 * @memberof Chart
10803 * @returns {null}
10804 * @example
10805 * chart.destroy();
10806 */
10807 destroy: function destroy() {
10808 var _this = this,
10809 $$ = this.internal,
10810 _$$$$el = $$.$el,
10811 chart = _$$$$el.chart,
10812 style = _$$$$el.style,
10813 svg = _$$$$el.svg;
10814 if (notEmpty($$)) {
10815 $$.callPluginHook("$willDestroy");
10816 $$.charts.splice($$.charts.indexOf(this), 1);
10817
10818 // detach events
10819 $$.unbindAllEvents();
10820
10821 // clear timers && pending transition
10822 svg.select("*").interrupt();
10823 $$.resizeFunction.clear();
10824 win.removeEventListener("resize", $$.resizeFunction);
10825 chart.classed("bb", !1).style("position", null).selectChildren().remove();
10826
10827 // remove <style> element added by boost.useCssRule option
10828 style && style.parentNode.removeChild(style);
10829
10830 // releasing own references
10831 Object.keys(this).forEach(function (key) {
10832 var _this2 = this;
10833 _newArrowCheck(this, _this);
10834 key === "internal" && Object.keys($$).forEach(function (k) {
10835 _newArrowCheck(this, _this2);
10836 $$[k] = null;
10837 }.bind(this));
10838 this[key] = null;
10839 delete this[key];
10840 }.bind(this));
10841
10842 // release prototype chains
10843 for (var key in this) {
10844 this[key] = function () {
10845 _newArrowCheck(this, _this);
10846 }.bind(this);
10847 }
10848 }
10849 return null;
10850 },
10851 /**
10852 * Get or set config option value.
10853 * - **NOTE:** for without parameter occasion
10854 * - will return all specified generation options object only. (will exclude any other options not specified at the initialization)
10855 * @function config
10856 * @instance
10857 * @memberof Chart
10858 * @param {string} name The option key name.
10859 * @param {*} [value] The value accepted for indicated option.
10860 * @param {boolean} [redraw] Set to redraw with the new option changes.
10861 * - **NOTE:** Doesn't guarantee work in all circumstances. It can be applied for limited options only.
10862 * @returns {*}
10863 * @example
10864 *
10865 * // Getter
10866 * chart.config("gauge.max");
10867 *
10868 * // without any arguments, it returns generation config object
10869 * chart.config(); // {data: { ... }, axis: { ... }, ...}
10870 *
10871 * // Setter
10872 * chart.config("gauge.max", 100);
10873 *
10874 * // Setter & redraw with the new option
10875 * chart.config("gauge.max", 100, true);
10876 */
10877 config: function (name, value, redraw) {
10878 var $$ = this.internal,
10879 config = $$.config,
10880 state = $$.state,
10881 key = name == null ? void 0 : name.replace(/\./g, "_"),
10882 res;
10883 if (name && key in config) {
10884 if (isDefined(value)) {
10885 config[key] = value;
10886 res = value;
10887 redraw && this.flush();
10888 } else {
10889 res = config[key];
10890 }
10891 } else {
10892 res = state.orgConfig;
10893 }
10894 return res;
10895 }
10896});
10897;// CONCATENATED MODULE: ./src/Chart/api/color.ts
10898/**
10899 * Copyright (c) 2017 ~ present NAVER Corp.
10900 * billboard.js project is licensed under the MIT license
10901 */
10902/* harmony default export */ var api_color = ({
10903 /**
10904 * Get the color
10905 * @function color
10906 * @instance
10907 * @memberof Chart
10908 * @param {string} id id to get the color
10909 * @returns {string}
10910 * @example
10911 * chart.color("data1");
10912 */
10913 color: function color(id) {
10914 return this.internal.color(id); // more patterns
10915 }
10916});
10917;// CONCATENATED MODULE: ./src/Chart/api/data.ts
10918
10919/**
10920 * Copyright (c) 2017 ~ present NAVER Corp.
10921 * billboard.js project is licensed under the MIT license
10922 */
10923
10924
10925/**
10926 * Get data loaded in the chart.
10927 * @function data
10928 * @instance
10929 * @memberof Chart
10930 * @param {string|Array} targetIds If this argument is given, this API returns the specified target data. If this argument is not given, all of data will be returned.
10931 * @returns {Array} Data objects
10932 * @example
10933 * // Get only data1 data
10934 * chart.data("data1");
10935 * // --> [{id: "data1", id_org: "data1", values: Array(6)}, ...]
10936 *
10937 * // Get data1 and data2 data
10938 * chart.data(["data1", "data2"]);
10939 *
10940 * // Get all data
10941 * chart.data();
10942 */
10943function api_data_data(targetIds) {
10944 var _this = this,
10945 targets = this.internal.data.targets;
10946 if (!isUndefined(targetIds)) {
10947 var ids = isArray(targetIds) ? targetIds : [targetIds];
10948 return targets.filter(function (t) {
10949 var _this2 = this;
10950 _newArrowCheck(this, _this);
10951 return ids.some(function (v) {
10952 _newArrowCheck(this, _this2);
10953 return v === t.id;
10954 }.bind(this));
10955 }.bind(this));
10956 }
10957 return targets;
10958}
10959extend(api_data_data, {
10960 /**
10961 * Get data shown in the chart.
10962 * @function data․shown
10963 * @instance
10964 * @memberof Chart
10965 * @param {string|Array} targetIds If this argument is given, this API filters the data with specified target ids. If this argument is not given, all shown data will be returned.
10966 * @returns {Array} Data objects
10967 * @example
10968 * // Get shown data by filtering to include only data1 data
10969 * chart.data.shown("data1");
10970 * // --> [{id: "data1", id_org: "data1", values: Array(6)}, ...]
10971 *
10972 * // Get shown data by filtering to include data1 and data2 data
10973 * chart.data.shown(["data1", "data2"]);
10974 *
10975 * // Get all shown data
10976 * chart.data.shown();
10977 */
10978 shown: function shown(targetIds) {
10979 return this.internal.filterTargetsToShow(this.data(targetIds));
10980 },
10981 /**
10982 * Get values of the data loaded in the chart.
10983 * @function data․values
10984 * @instance
10985 * @memberof Chart
10986 * @param {string|Array|null} targetIds This API returns the values of specified target. If this argument is not given, null will be retruned
10987 * @param {boolean} [flat=true] Get flatten values
10988 * @returns {Array} Data values
10989 * @example
10990 * // Get data1 values
10991 * chart.data.values("data1");
10992 * // --> [10, 20, 30, 40]
10993 */
10994 values: function (targetIds, flat) {
10995 var _this3 = this;
10996 if (flat === void 0) {
10997 flat = !0;
10998 }
10999 var values = null;
11000 if (targetIds) {
11001 var targets = this.data(targetIds);
11002 if (isArray(targets)) {
11003 values = [];
11004 targets.forEach(function (v) {
11005 var _this4 = this;
11006 _newArrowCheck(this, _this3);
11007 var dataValue = v.values.map(function (d) {
11008 _newArrowCheck(this, _this4);
11009 return d.value;
11010 }.bind(this));
11011 flat ? values = values.concat(dataValue) : values.push(dataValue);
11012 }.bind(this));
11013 }
11014 }
11015 return values;
11016 },
11017 /**
11018 * Get and set names of the data loaded in the chart.
11019 * @function data․names
11020 * @instance
11021 * @memberof Chart
11022 * @param {object} names If this argument is given, the names of data will be updated. If not given, the current names will be returned. The format of this argument is the same as [data.names](./Options.html#.data%25E2%2580%25A4names).
11023 * @returns {object} Corresponding names according its key value, if specified names values.
11024 * @example
11025 * // Get current names
11026 * chart.data.names();
11027 * // --> {data1: "test1", data2: "test2"}
11028 *
11029 * // Update names
11030 * chart.data.names({
11031 * data1: "New Name 1",
11032 * data2: "New Name 2"
11033 *});
11034 */
11035 names: function names(_names) {
11036 var $$ = this.internal;
11037 return $$.updateDataAttributes("names", _names);
11038 },
11039 /**
11040 * Get and set colors of the data loaded in the chart.
11041 * @function data․colors
11042 * @instance
11043 * @memberof Chart
11044 * @param {object} colors If this argument is given, the colors of data will be updated. If not given, the current colors will be returned. The format of this argument is the same as [data.colors](./Options.html#.data%25E2%2580%25A4colors).
11045 * @returns {object} Corresponding data color value according its key value.
11046 * @example
11047 * // Get current colors
11048 * chart.data.colors();
11049 * // --> {data1: "#00c73c", data2: "#fa7171"}
11050 *
11051 * // Update colors
11052 * chart.data.colors({
11053 * data1: "#FFFFFF",
11054 * data2: "#000000"
11055 * });
11056 */
11057 colors: function colors(_colors) {
11058 return this.internal.updateDataAttributes("colors", _colors);
11059 },
11060 /**
11061 * Get and set axes of the data loaded in the chart.
11062 * - **NOTE:** If all data is related to one of the axes, the domain of axis without related data will be replaced by the domain from the axis with related data
11063 * @function data․axes
11064 * @instance
11065 * @memberof Chart
11066 * @param {object} axes If this argument is given, the axes of data will be updated. If not given, the current axes will be returned. The format of this argument is the same as
11067 * @returns {object} Corresponding axes value for data, if specified axes value.
11068 * @example
11069 * // Get current axes
11070 * chart.data.axes();
11071 * // --> {data1: "y"}
11072 *
11073 * // Update axes
11074 * chart.data.axes({
11075 * data1: "y",
11076 * data2: "y2"
11077 * });
11078 */
11079 axes: function axes(_axes) {
11080 return this.internal.updateDataAttributes("axes", _axes);
11081 },
11082 /**
11083 * Get the minimum data value bound to the chart
11084 * @function data․min
11085 * @instance
11086 * @memberof Chart
11087 * @returns {Array} Data objects
11088 * @example
11089 * // Get current axes
11090 * chart.data.min();
11091 * // --> [{x: 0, value: 30, id: "data1", index: 0}, ...]
11092 */
11093 min: function min() {
11094 return this.internal.getMinMaxData().min;
11095 },
11096 /**
11097 * Get the maximum data value bound to the chart
11098 * @function data․max
11099 * @instance
11100 * @memberof Chart
11101 * @returns {Array} Data objects
11102 * @example
11103 * // Get current axes
11104 * chart.data.max();
11105 * // --> [{x: 3, value: 400, id: "data1", index: 3}, ...]
11106 */
11107 max: function max() {
11108 return this.internal.getMinMaxData().max;
11109 }
11110});
11111/* harmony default export */ var api_data = ({
11112 data: api_data_data
11113});
11114;// CONCATENATED MODULE: ./src/Chart/api/export.ts
11115
11116var export_this = undefined;
11117/**
11118 * Copyright (c) 2017 ~ present NAVER Corp.
11119 * billboard.js project is licensed under the MIT license
11120 */
11121
11122
11123
11124/**
11125 * Encode to base64
11126 * @param {string} str string to be encoded
11127 * @returns {string}
11128 * @private
11129 * @see https://developer.mozilla.org/ko/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
11130 */
11131var b64EncodeUnicode = function (str) {
11132 var _this2 = this;
11133 _newArrowCheck(this, export_this);
11134 return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p) {
11135 _newArrowCheck(this, _this2);
11136 return String.fromCharCode(+("0x" + p));
11137 }.bind(this)));
11138}.bind(undefined);
11139
11140/**
11141 * Convert svg node to data url
11142 * @param {HTMLElement} node target node
11143 * @param {object} option object containing {width, height, preserveAspectRatio}
11144 * @param {object} orgSize object containing {width, height}
11145 * @returns {string}
11146 * @private
11147 */
11148function nodeToSvgDataUrl(node, option, orgSize) {
11149 var _this3 = this,
11150 _ref = option || orgSize,
11151 width = _ref.width,
11152 height = _ref.height,
11153 serializer = new XMLSerializer(),
11154 clone = node.cloneNode(!0),
11155 cssText = getCssRules(toArray(browser_doc.styleSheets)).filter(function (r) {
11156 _newArrowCheck(this, _this3);
11157 return r.cssText;
11158 }.bind(this)).map(function (r) {
11159 _newArrowCheck(this, _this3);
11160 return r.cssText;
11161 }.bind(this));
11162 clone.setAttribute("xmlns", external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.xhtml);
11163 var nodeXml = serializer.serializeToString(clone),
11164 style = browser_doc.createElement("style"); // escape css for XML
11165 style.appendChild(browser_doc.createTextNode(cssText.join("\n")));
11166 var styleXml = serializer.serializeToString(style),
11167 dataStr = ("<svg xmlns=\"" + external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg + "\" width=\"" + width + "\" height=\"" + height + "\" \n\t\tviewBox=\"0 0 " + orgSize.width + " " + orgSize.height + "\" \n\t\tpreserveAspectRatio=\"" + ((option == null ? void 0 : option.preserveAspectRatio) === !1 ? "none" : "xMinYMid meet") + "\">\n\t\t\t<foreignObject width=\"100%\" height=\"100%\">\n\t\t\t\t" + styleXml + "\n\t\t\t\t" + nodeXml.replace(/(url\()[^#]+/g, "$1") + "\n\t\t\t</foreignObject></svg>").replace("/\n/g", "%0A"); // foreignObject not supported in IE11 and below
11168 // https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx
11169 return "data:image/svg+xml;base64," + b64EncodeUnicode(dataStr);
11170}
11171/* harmony default export */ var api_export = ({
11172 /**
11173 * Export chart as an image.
11174 * - **NOTE:**
11175 * - IE11 and below not work properly due to the lack of the feature(<a href="https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx">foreignObject</a>) support
11176 * - The basic CSS file(ex. billboard.css) should be at same domain as API call context to get correct styled export image.
11177 * @function export
11178 * @instance
11179 * @memberof Chart
11180 * @param {object} option Export option
11181 * @param {string} [option.mimeType="image/png"] The desired output image format. (ex. 'image/png' for png, 'image/jpeg' for jpeg format)
11182 * @param {number} [option.width={currentWidth}] width
11183 * @param {number} [option.height={currentHeigth}] height
11184 * @param {boolean} [option.preserveAspectRatio=true] Preserve aspect ratio on given size
11185 * @param {Function} [callback] The callback to be invoked when export is ready.
11186 * @returns {string} dataURI
11187 * @example
11188 * chart.export();
11189 * // --> "data:image/svg+xml;base64,PHN..."
11190 *
11191 * // Initialize the download automatically
11192 * chart.export({mimeType: "image/png"}, dataUrl => {
11193 * const link = document.createElement("a");
11194 *
11195 * link.download = `${Date.now()}.png`;
11196 * link.href = dataUrl;
11197 * link.innerHTML = "Download chart as image";
11198 *
11199 * document.body.appendChild(link);
11200 * });
11201 *
11202 * // Resize the exported image
11203 * chart.export(
11204 * {
11205 * width: 800,
11206 * height: 600,
11207 * preserveAspectRatio: false,
11208 * mimeType: "image/png"
11209 * },
11210 * dataUrl => { ... }
11211 * );
11212 */
11213 export: function _export(option, callback) {
11214 var _this4 = this,
11215 $$ = this.internal,
11216 state = $$.state,
11217 chart = $$.$el.chart,
11218 _state$current = state.current,
11219 width = _state$current.width,
11220 height = _state$current.height,
11221 opt = mergeObj({
11222 width: width,
11223 height: height,
11224 preserveAspectRatio: !0,
11225 mimeType: "image/png"
11226 }, option),
11227 svgDataUrl = nodeToSvgDataUrl(chart.node(), opt, {
11228 width: width,
11229 height: height
11230 });
11231 if (callback && isFunction(callback)) {
11232 var img = new Image();
11233 img.crossOrigin = "Anonymous";
11234 img.onload = function () {
11235 _newArrowCheck(this, _this4);
11236 var canvas = browser_doc.createElement("canvas"),
11237 ctx = canvas.getContext("2d");
11238 canvas.width = opt.width || width;
11239 canvas.height = opt.height || height;
11240 ctx.drawImage(img, 0, 0);
11241 callback.bind(this)(canvas.toDataURL(opt.mimeType));
11242 }.bind(this);
11243 img.src = svgDataUrl;
11244 }
11245 return svgDataUrl;
11246 }
11247});
11248;// CONCATENATED MODULE: ./src/Chart/api/focus.ts
11249
11250/**
11251 * Copyright (c) 2017 ~ present NAVER Corp.
11252 * billboard.js project is licensed under the MIT license
11253 */
11254
11255
11256/* harmony default export */ var api_focus = ({
11257 /**
11258 * This API highlights specified targets and fade out the others.<br><br>
11259 * You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be highlighted.
11260 * @function focus
11261 * @instance
11262 * @memberof Chart
11263 * @param {string|Array} targetIdsValue Target ids to be highlighted.
11264 * @example
11265 * // data1 will be highlighted and the others will be faded out
11266 * chart.focus("data1");
11267 *
11268 * // data1 and data2 will be highlighted and the others will be faded out
11269 * chart.focus(["data1", "data2"]);
11270 *
11271 * // all targets will be highlighted
11272 * chart.focus();
11273 */
11274 focus: function focus(targetIdsValue) {
11275 var _this = this,
11276 $$ = this.internal,
11277 state = $$.state,
11278 targetIds = $$.mapToTargetIds(targetIdsValue),
11279 candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
11280 this.revert();
11281 this.defocus();
11282 candidates.classed($FOCUS.focused, !0).classed($FOCUS.defocused, !1);
11283 if ($$.hasArcType() && !state.hasRadar) {
11284 $$.expandArc(targetIds);
11285 $$.hasType("gauge") && $$.markOverlapped(targetIdsValue, $$, "." + $GAUGE.gaugeValue);
11286 }
11287 $$.toggleFocusLegend(targetIds, !0);
11288 state.focusedTargetIds = targetIds;
11289 state.defocusedTargetIds = state.defocusedTargetIds.filter(function (id) {
11290 _newArrowCheck(this, _this);
11291 return targetIds.indexOf(id) < 0;
11292 }.bind(this));
11293 },
11294 /**
11295 * This API fades out specified targets and reverts the others.<br><br>
11296 * You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be faded out.
11297 * @function defocus
11298 * @instance
11299 * @memberof Chart
11300 * @param {string|Array} targetIdsValue Target ids to be faded out.
11301 * @example
11302 * // data1 will be faded out and the others will be reverted.
11303 * chart.defocus("data1");
11304 *
11305 * // data1 and data2 will be faded out and the others will be reverted.
11306 * chart.defocus(["data1", "data2"]);
11307 *
11308 * // all targets will be faded out.
11309 * chart.defocus();
11310 */
11311 defocus: function defocus(targetIdsValue) {
11312 var _this2 = this,
11313 $$ = this.internal,
11314 state = $$.state,
11315 targetIds = $$.mapToTargetIds(targetIdsValue),
11316 candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
11317 candidates.classed($FOCUS.focused, !1).classed($FOCUS.defocused, !0);
11318 if ($$.hasArcType(null, ["polar"])) {
11319 $$.unexpandArc(targetIds);
11320 $$.hasType("gauge") && $$.undoMarkOverlapped($$, "." + $GAUGE.gaugeValue);
11321 }
11322 $$.toggleFocusLegend(targetIds, !1);
11323 state.focusedTargetIds = state.focusedTargetIds.filter(function (id) {
11324 _newArrowCheck(this, _this2);
11325 return targetIds.indexOf(id) < 0;
11326 }.bind(this));
11327 state.defocusedTargetIds = targetIds;
11328 },
11329 /**
11330 * This API reverts specified targets.<br><br>
11331 * You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be reverted.
11332 * @function revert
11333 * @instance
11334 * @memberof Chart
11335 * @param {string|Array} targetIdsValue Target ids to be reverted
11336 * @example
11337 * // data1 will be reverted.
11338 * chart.revert("data1");
11339 *
11340 * // data1 and data2 will be reverted.
11341 * chart.revert(["data1", "data2"]);
11342 *
11343 * // all targets will be reverted.
11344 * chart.revert();
11345 */
11346 revert: function revert(targetIdsValue) {
11347 var $$ = this.internal,
11348 config = $$.config,
11349 state = $$.state,
11350 $el = $$.$el,
11351 targetIds = $$.mapToTargetIds(targetIdsValue),
11352 candidates = $el.svg.selectAll($$.selectorTargets(targetIds));
11353 // should be for all targets
11354
11355 candidates.classed($FOCUS.focused, !1).classed($FOCUS.defocused, !1);
11356 $$.hasArcType(null, ["polar"]) && $$.unexpandArc(targetIds);
11357 if (config.legend_show) {
11358 $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
11359 $el.legend.selectAll($$.selectorLegends(targetIds)).filter(function () {
11360 return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused);
11361 }).classed($FOCUS.legendItemFocused, !1);
11362 }
11363 state.focusedTargetIds = [];
11364 state.defocusedTargetIds = [];
11365 }
11366});
11367;// CONCATENATED MODULE: ./src/Chart/api/legend.ts
11368/**
11369 * Copyright (c) 2017 ~ present NAVER Corp.
11370 * billboard.js project is licensed under the MIT license
11371 */
11372/**
11373 * Define legend
11374 * @ignore
11375 */
11376var legend_legend = {
11377 /**
11378 * Show legend for each target.
11379 * @function legend․show
11380 * @instance
11381 * @memberof Chart
11382 * @param {string|Array} targetIds
11383 * - If targetIds is given, specified target's legend will be shown.
11384 * - If only one target is the candidate, String can be passed.
11385 * - If no argument is given, all of target's legend will be shown.
11386 * @example
11387 * // Show legend for data1.
11388 * chart.legend.show("data1");
11389 *
11390 * // Show legend for data1 and data2.
11391 * chart.legend.show(["data1", "data2"]);
11392 *
11393 * // Show all legend.
11394 * chart.legend.show();
11395 */
11396 show: function show(targetIds) {
11397 var $$ = this.internal;
11398 $$.showLegend($$.mapToTargetIds(targetIds));
11399 $$.updateAndRedraw({
11400 withLegend: !0
11401 });
11402 },
11403 /**
11404 * Hide legend for each target.
11405 * @function legend․hide
11406 * @instance
11407 * @memberof Chart
11408 * @param {string|Array} targetIds
11409 * - If targetIds is given, specified target's legend will be hidden.
11410 * - If only one target is the candidate, String can be passed.
11411 * - If no argument is given, all of target's legend will be hidden.
11412 * @example
11413 * // Hide legend for data1.
11414 * chart.legend.hide("data1");
11415 *
11416 * // Hide legend for data1 and data2.
11417 * chart.legend.hide(["data1", "data2"]);
11418 *
11419 * // Hide all legend.
11420 * chart.legend.hide();
11421 */
11422 hide: function hide(targetIds) {
11423 var $$ = this.internal;
11424 $$.hideLegend($$.mapToTargetIds(targetIds));
11425 $$.updateAndRedraw({
11426 withLegend: !0
11427 });
11428 }
11429};
11430/* harmony default export */ var api_legend = ({
11431 legend: legend_legend
11432});
11433;// CONCATENATED MODULE: ./src/Chart/api/load.ts
11434
11435/**
11436 * Copyright (c) 2017 ~ present NAVER Corp.
11437 * billboard.js project is licensed under the MIT license
11438 */
11439
11440
11441/* harmony default export */ var api_load = ({
11442 /**
11443 * Load data to the chart.<br><br>
11444 * You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be toggles.
11445 * - <b>Note:</b>
11446 * - unload should be used if some data needs to be unloaded simultaneously.
11447 * If you call unload API soon after/before load instead of unload param, chart will not be rendered properly because of cancel of animation.<br>
11448 * - done will be called after data loaded, but it's not after rendering.
11449 * It's because rendering will finish after some transition and there is some time lag between loading and rendering
11450 * @function load
11451 * @instance
11452 * @memberof Chart
11453 * @param {object} args The object can consist with following members:<br>
11454 *
11455 * | Key | Description |
11456 * | --- | --- |
11457 * | - url<br>- json<br>- rows<br>- columns | The data will be loaded. If data that has the same target id is given, the chart will be updated. Otherwise, new target will be added |
11458 * | data | Data objects to be loaded. Checkout the example. |
11459 * | append | Load data appending it to the current dataseries.<br>If the existing chart has`x` value, should provide with corresponding `x` value for newly loaded data. |
11460 * | names | Same as data.names() |
11461 * | xs | Same as data.xs option |
11462 * | classes | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
11463 * | categories | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
11464 * | axes | The axes specified by data.axes will be updated. axes must be Object that has target id as keys. |
11465 * | colors | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
11466 * | headers | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
11467 * | keys | Choose which JSON objects keys correspond to desired data.<br>**NOTE:** Only for JSON object given as array.<br>@see [data․keys](Options.html#.data%25E2%2580%25A4keys) |
11468 * | mimeType | Set 'json' if loading JSON via url.<br>@see [data․mimeType](Options.html#.data%25E2%2580%25A4mimeType) |
11469 * | - type<br>- types | The type of targets will be updated. type must be String and types must be Object. |
11470 * | unload | Specify the data will be unloaded before loading new data. If true given, all of data will be unloaded. If target ids given as String or Array, specified targets will be unloaded. If absent or false given, unload will not occur. |
11471 * | done | The specified function will be called after data loaded.|
11472 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataFromURL)
11473 * @example
11474 * // Load data1 and unload data2 and data3
11475 * chart.load({
11476 * columns: [
11477 * ["data1", 100, 200, 150, ...],
11478 * ...
11479 * ],
11480 * unload: ["data2", "data3"],
11481 * url: "...",
11482 * done: function() { ... }
11483 * });
11484 * @example
11485 * const chart = bb.generate({
11486 * data: {
11487 * columns: [
11488 * ["data1", 20, 30, 40]
11489 * ]
11490 * }
11491 * });
11492 *
11493 * chart.load({
11494 * columns: [
11495 * // with 'append' option, the 'data1' will have `[20,30,40,50,60]`.
11496 * ["data1", 50, 60]
11497 * ],
11498 * append: true
11499 * });
11500 * @example
11501 * const chart = bb.generate({
11502 * data: {
11503 * x: "x",
11504 * xFormat: "%Y-%m-%dT%H:%M:%S",
11505 * columns: [
11506 * ["x", "2021-01-03T03:00:00", "2021-01-04T12:00:00", "2021-01-05T21:00:00"],
11507 * ["data1", 36, 30, 24]
11508 * ]
11509 * },
11510 * axis: {
11511 * x: {
11512 * type: "timeseries"
11513 * }
11514 * }
11515 * };
11516 *
11517 * chart.load({
11518 * columns: [
11519 * // when existing chart has `x` value, should provide correponding 'x' value.
11520 * // with 'append' option, the 'data1' will have `[36,30,24,37]`.
11521 * ["x", "2021-02-01T08:00:00"],
11522 * ["data1", 37]
11523 * ],
11524 * append: true
11525 * });
11526 * @example
11527 * // myAPI.json
11528 * // {
11529 * // "data1": [220, 240, 270, 250, 280],
11530 * // "data2": [180, 150, 300, 70, 120]
11531 * // }
11532 *
11533 * chart.load({
11534 * url: './data/myAPI.json',
11535 * mimeType: "json",
11536 *
11537 * // set request header if is needed
11538 * headers: {
11539 * "Content-Type": "text/json"
11540 * }
11541 * });
11542 * @example
11543 * chart.load({
11544 * data: [
11545 * // equivalent as: columns: [["data1", 30, 200, 100]]
11546 * {"data1": 30}, {"data1": 200}, {"data1": 100}
11547 *
11548 * // or
11549 * // equivalent as: columns: [["data1", 10, 20], ["data2", 13, 30]]
11550 * // {"data1": 10, "data2": 13}, {"data1": 20, "data2": 30}}
11551 * ]
11552 * });
11553 * @example
11554 * chart.load({
11555 * json: [
11556 * {name: "www.site1.com", upload: 800, download: 500, total: 400},
11557 * ],
11558 * keys: {
11559 * x: "name",
11560 * value: ["upload", "download"]
11561 * }
11562 * });
11563 * @example
11564 * chart.load({
11565 * json: {
11566 * data1:[30, 20, 50, 40, 60, 50],
11567 * data2:[200, 130, 90, 240, 130, 220],
11568 * }
11569 * });
11570 */
11571 load: function load(args) {
11572 var _this = this,
11573 $$ = this.internal,
11574 config = $$.config;
11575 // update xs if specified
11576 args.xs && $$.addXs(args.xs);
11577
11578 // update names if exists
11579 "names" in args && this.data.names(args.names);
11580
11581 // update classes if exists
11582 "classes" in args && Object.keys(args.classes).forEach(function (id) {
11583 _newArrowCheck(this, _this);
11584 config.data_classes[id] = args.classes[id];
11585 }.bind(this));
11586
11587 // update categories if exists
11588 if ("categories" in args && $$.axis.isCategorized()) {
11589 config.axis_x_categories = args.categories;
11590 }
11591
11592 // update axes if exists
11593 "axes" in args && Object.keys(args.axes).forEach(function (id) {
11594 _newArrowCheck(this, _this);
11595 config.data_axes[id] = args.axes[id];
11596 }.bind(this));
11597
11598 // update colors if exists
11599 "colors" in args && Object.keys(args.colors).forEach(function (id) {
11600 _newArrowCheck(this, _this);
11601 config.data_colors[id] = args.colors[id];
11602 }.bind(this));
11603
11604 // unload if needed
11605 if ("unload" in args && args.unload !== !1) {
11606 // TODO: do not unload if target will load (included in url/rows/columns)
11607 $$.unload($$.mapToTargetIds(args.unload === !0 ? null : args.unload), function () {
11608 var _this2 = this;
11609 _newArrowCheck(this, _this);
11610 // to mitigate improper rendering for multiple consecutive calls
11611 // https://github.com/naver/billboard.js/issues/2121
11612 win.requestIdleCallback(function () {
11613 _newArrowCheck(this, _this2);
11614 return $$.loadFromArgs(args);
11615 }.bind(this));
11616 }.bind(this));
11617 } else {
11618 $$.loadFromArgs(args);
11619 }
11620 },
11621 /**
11622 * Unload data to the chart.<br><br>
11623 * You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be toggles.
11624 * - <b>Note:</b>
11625 * If you call load API soon after/before unload, unload param of load should be used. Otherwise chart will not be rendered properly because of cancel of animation.<br>
11626 * `done` will be called after data loaded, but it's not after rendering. It's because rendering will finish after some transition and there is some time lag between loading and rendering.
11627 * @function unload
11628 * @instance
11629 * @memberof Chart
11630 * @param {object} argsValue
11631 * | key | Type | Description |
11632 * | --- | --- | --- |
11633 * | ids | String &vert; Array | Target id data to be unloaded. If not given, all data will be unloaded. |
11634 * | done | Fuction | Callback after data is unloaded. |
11635 * @example
11636 * // Unload data2 and data3
11637 * chart.unload({
11638 * ids: ["data2", "data3"],
11639 * done: function() {
11640 * // called after the unloaded
11641 * }
11642 * });
11643 */
11644 unload: function unload(argsValue) {
11645 var _this3 = this,
11646 $$ = this.internal,
11647 args = argsValue || {};
11648 if (isArray(args)) {
11649 args = {
11650 ids: args
11651 };
11652 } else if (isString(args)) {
11653 args = {
11654 ids: [args]
11655 };
11656 }
11657 var ids = $$.mapToTargetIds(args.ids);
11658 $$.unload(ids, function () {
11659 _newArrowCheck(this, _this3);
11660 $$.redraw({
11661 withUpdateOrgXDomain: !0,
11662 withUpdateXDomain: !0,
11663 withLegend: !0
11664 });
11665 $$.cache.remove(ids);
11666 args.done && args.done.call(this);
11667 }.bind(this));
11668 }
11669});
11670;// CONCATENATED MODULE: ./src/Chart/api/show.ts
11671
11672/**
11673 * Copyright (c) 2017 ~ present NAVER Corp.
11674 * billboard.js project is licensed under the MIT license
11675 */
11676
11677
11678/**
11679 * Show/Hide data series
11680 * @param {boolean} show Show or hide
11681 * @param {Array} targetIdsValue Target id values
11682 * @param {object} options Options
11683 * @private
11684 */
11685function showHide(show, targetIdsValue, options) {
11686 var _this = this,
11687 $$ = this.internal,
11688 targetIds = $$.mapToTargetIds(targetIdsValue),
11689 hiddenIds = $$.state.hiddenTargetIds.map(function (v) {
11690 _newArrowCheck(this, _this);
11691 return targetIds.indexOf(v) > -1 && v;
11692 }.bind(this)).filter(Boolean);
11693 $$.state.toggling = !0;
11694 $$[(show ? "remove" : "add") + "HiddenTargetIds"](targetIds);
11695 var targets = $$.$el.svg.selectAll($$.selectorTargets(targetIds)),
11696 opacity = show ? null : "0";
11697 if (show && hiddenIds.length) {
11698 targets.style("display", null);
11699 callFn($$.config.data_onshown, this, hiddenIds);
11700 }
11701 $$.$T(targets).style("opacity", opacity, "important").call(endall, function () {
11702 _newArrowCheck(this, _this);
11703 // https://github.com/naver/billboard.js/issues/1758
11704 if (!show && hiddenIds.length === 0) {
11705 targets.style("display", "none");
11706 callFn($$.config.data_onhidden, this, targetIds);
11707 }
11708 targets.style("opacity", opacity);
11709 }.bind(this));
11710 options.withLegend && $$[(show ? "show" : "hide") + "Legend"](targetIds);
11711 $$.redraw({
11712 withUpdateOrgXDomain: !0,
11713 withUpdateXDomain: !0,
11714 withLegend: !0
11715 });
11716 $$.state.toggling = !1;
11717}
11718/* harmony default export */ var show = ({
11719 /**
11720 * Show data series on chart
11721 * @function show
11722 * @instance
11723 * @memberof Chart
11724 * @param {string|Array} [targetIdsValue] The target id value.
11725 * @param {object} [options] The object can consist with following members:<br>
11726 *
11727 * | Key | Type | default | Description |
11728 * | --- | --- | --- | --- |
11729 * | withLegend | boolean | false | whether or not display legend |
11730 *
11731 * @example
11732 * // show 'data1'
11733 * chart.show("data1");
11734 *
11735 * // show 'data1' and 'data3'
11736 * chart.show(["data1", "data3"]);
11737 */
11738 show: function show(targetIdsValue, options) {
11739 if (options === void 0) {
11740 options = {};
11741 }
11742 showHide.call(this, !0, targetIdsValue, options);
11743 },
11744 /**
11745 * Hide data series from chart
11746 * @function hide
11747 * @instance
11748 * @memberof Chart
11749 * @param {string|Array} [targetIdsValue] The target id value.
11750 * @param {object} [options] The object can consist with following members:<br>
11751 *
11752 * | Key | Type | default | Description |
11753 * | --- | --- | --- | --- |
11754 * | withLegend | boolean | false | whether or not display legend |
11755 *
11756 * @example
11757 * // hide 'data1'
11758 * chart.hide("data1");
11759 *
11760 * // hide 'data1' and 'data3'
11761 * chart.hide(["data1", "data3"]);
11762 */
11763 hide: function hide(targetIdsValue, options) {
11764 if (options === void 0) {
11765 options = {};
11766 }
11767 showHide.call(this, !1, targetIdsValue, options);
11768 },
11769 /**
11770 * Toggle data series on chart. When target data is hidden, it will show. If is shown, it will hide in vice versa.
11771 * @function toggle
11772 * @instance
11773 * @memberof Chart
11774 * @param {string|Array} [targetIds] The target id value.
11775 * @param {object} [options] The object can consist with following members:<br>
11776 *
11777 * | Key | Type | default | Description |
11778 * | --- | --- | --- | --- |
11779 * | withLegend | boolean | false | whether or not display legend |
11780 *
11781 * @example
11782 * // toggle 'data1'
11783 * chart.toggle("data1");
11784 *
11785 * // toggle 'data1' and 'data3'
11786 * chart.toggle(["data1", "data3"]);
11787 */
11788 toggle: function toggle(targetIds, options) {
11789 var _this2 = this;
11790 if (options === void 0) {
11791 options = {};
11792 }
11793 var $$ = this.internal,
11794 targets = {
11795 show: [],
11796 hide: []
11797 };
11798 // sort show & hide target ids
11799 $$.mapToTargetIds(targetIds).forEach(function (id) {
11800 _newArrowCheck(this, _this2);
11801 return targets[$$.isTargetToShow(id) ? "hide" : "show"].push(id);
11802 }.bind(this));
11803
11804 // perform show & hide task separately
11805 // https://github.com/naver/billboard.js/issues/454
11806 targets.show.length && this.show(targets.show, options);
11807 targets.hide.length && setTimeout(function () {
11808 _newArrowCheck(this, _this2);
11809 return this.hide(targets.hide, options);
11810 }.bind(this), 0);
11811 }
11812});
11813;// CONCATENATED MODULE: ./src/Chart/api/tooltip.ts
11814
11815/**
11816 * Copyright (c) 2017 ~ present NAVER Corp.
11817 * billboard.js project is licensed under the MIT license
11818 */
11819
11820
11821/**
11822 * Define tooltip
11823 * @ignore
11824 */
11825var tooltip_tooltip = {
11826 /**
11827 * Show tooltip
11828 * @function tooltip․show
11829 * @instance
11830 * @memberof Chart
11831 * @param {object} args The object can consist with following members:<br>
11832 *
11833 * | Key | Type | Description |
11834 * | --- | --- | --- |
11835 * | index | Number | Determine focus by index |
11836 * | x | Number &vert; Date | Determine focus by x Axis index |
11837 * | mouse | Array | Determine x and y coordinate value relative the targeted '.bb-event-rect' x Axis.<br>It should be used along with `data`, `index` or `x` value. The default value is set as `[0,0]` |
11838 * | data | Object | When [data.xs](Options.html#.data%25E2%2580%25A4xs) option is used or [tooltip.grouped](Options.html#.tooltip) set to 'false', `should be used giving this param`.<br><br>**Key:**<br>- x {number &verbar; Date}: x Axis value<br>- index {number}: x Axis index (useless for data.xs)<br>- id {string}: data id<br>- value {number}: The corresponding value for tooltip. |
11839 *
11840 * @example
11841 * // show the 2nd x Axis coordinate tooltip
11842 * // for Arc(gauge, donut & pie) and radar type, approch showing tooltip by using "index" number.
11843 * chart.tooltip.show({
11844 * index: 1
11845 * });
11846 *
11847 * // show tooltip for the 3rd x Axis in x:50 and y:100 coordinate of '.bb-event-rect' of the x Axis.
11848 * chart.tooltip.show({
11849 * x: 2,
11850 * mouse: [50, 100]
11851 * });
11852 *
11853 * // show tooltip for timeseries x axis
11854 * chart.tooltip.show({
11855 * x: new Date("2018-01-02 00:00")
11856 * });
11857 *
11858 * // when data.xs is used
11859 * chart.tooltip.show({
11860 * data: {
11861 * x: 3, // x Axis value
11862 * id: "data1", // data id
11863 * value: 500 // data value
11864 * }
11865 * });
11866 *
11867 * // when data.xs isn't used, but tooltip.grouped=false is set
11868 * chart.tooltip.show({
11869 * data: {
11870 * index: 3, // or 'x' key value
11871 * id: "data1", // data id
11872 * value: 500 // data value
11873 * }
11874 * });
11875 */
11876 show: function show(args) {
11877 var _this = this,
11878 $$ = this.internal,
11879 config = $$.config,
11880 inputType = $$.state.inputType,
11881 index,
11882 mouse;
11883 // determine mouse position on the chart
11884 if (args.mouse) {
11885 mouse = args.mouse;
11886 }
11887
11888 // determine focus data
11889 if (args.data) {
11890 var data = args.data,
11891 y = $$.getYScaleById(data.id)(data.value);
11892 if ($$.isMultipleX()) {
11893 // if multiple xs, target point will be determined by mouse
11894 mouse = [$$.scale.x(data.x), y];
11895 } else {
11896 if (!config.tooltip_grouped) {
11897 mouse = [0, y];
11898 }
11899 index = isValue(data.index) ? data.index : $$.getIndexByX(data.x);
11900 }
11901 } else if (isDefined(args.x)) {
11902 index = $$.getIndexByX(args.x);
11903 } else if (isDefined(args.index)) {
11904 index = args.index;
11905 }
11906 (inputType === "mouse" ? ["mouseover", "mousemove"] : ["touchstart"]).forEach(function (eventName) {
11907 _newArrowCheck(this, _this);
11908 $$.dispatchEvent(eventName, index, mouse);
11909 }.bind(this));
11910 },
11911 /**
11912 * Hide tooltip
11913 * @function tooltip․hide
11914 * @instance
11915 * @memberof Chart
11916 */
11917 hide: function hide() {
11918 var _this2 = this,
11919 $$ = this.internal,
11920 inputType = $$.state.inputType,
11921 tooltip = $$.$el.tooltip,
11922 data = tooltip == null ? void 0 : tooltip.datum();
11923 if (data) {
11924 var index = JSON.parse(data.current)[0].index;
11925
11926 // make to finalize, possible pending event flow set from '.tooltip.show()' call
11927 (inputType === "mouse" ? ["mouseout"] : ["touchend"]).forEach(function (eventName) {
11928 _newArrowCheck(this, _this2);
11929 $$.dispatchEvent(eventName, index);
11930 }.bind(this));
11931 }
11932
11933 // reset last touch point index
11934 inputType === "touch" && $$.callOverOutForTouch();
11935 $$.hideTooltip(!0);
11936 $$.hideGridFocus();
11937 $$.unexpandCircles == null ? void 0 : $$.unexpandCircles();
11938 $$.expandBarTypeShapes(!1);
11939 }
11940};
11941/* harmony default export */ var api_tooltip = ({
11942 tooltip: tooltip_tooltip
11943});
11944;// CONCATENATED MODULE: ./src/Chart/Chart.ts
11945
11946/**
11947 * Copyright (c) 2017 ~ present NAVER Corp.
11948 * billboard.js project is licensed under the MIT license
11949 */
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963/**
11964 * Main chart class.
11965 * - Note: Instantiated via `bb.generate()`.
11966 * @class Chart
11967 * @example
11968 * var chart = bb.generate({
11969 * data: {
11970 * columns: [
11971 * ["x", "2015-11-02", "2015-12-01", "2016-01-01", "2016-02-01", "2016-03-01"],
11972 * ["count1", 11, 8, 7, 6, 5 ],
11973 * ["count2", 9, 3, 6, 2, 8 ]
11974 * ]}
11975 * }
11976 * @see {@link bb.generate} for the initialization.
11977 */
11978/**
11979 * Access instance's primary node elements
11980 * @member {object} $
11981 * @property {object} $ Access instance's primary node elements
11982 * @property {d3.selection} $.chart Wrapper element
11983 * @property {d3.selection} $.svg Main svg element
11984 * @property {d3.selection} $.defs Definition element
11985 * @property {d3.selection} $.main Main grouping element
11986 * @property {d3.selection} $.tooltip Tooltip element
11987 * @property {d3.selection} $.legend Legend element
11988 * @property {d3.selection} $.title Title element
11989 * @property {d3.selection} $.grid Grid element
11990 * @property {d3.selection} $.arc Arc element
11991 * @property {d3.selection} $.circles Data point circle elements
11992 * @property {object} $.bar Bar element object
11993 * @property {d3.selection} $.bar.bars Bar elements
11994 * @property {d3.selection} $.candlestick Candlestick elements
11995 * @property {object} $.line Line element object
11996 * @property {d3.selection} $.line.lines Line elements
11997 * @property {d3.selection} $.line.areas Areas elements
11998 * @property {object} $.text Text element object
11999 * @property {d3.selection} $.text.texts Data label text elements
12000 * @memberof Chart
12001 * @example
12002 * var chart = bb.generate({ ... });
12003 *
12004 * chart.$.chart; // wrapper element
12005 * chart.$.line.circles; // all data point circle elements
12006 */
12007/**
12008 * Plugin instance array
12009 * @member {Array} plugins
12010 * @memberof Chart
12011 * @example
12012 * var chart = bb.generate({
12013 * ...
12014 * plugins: [
12015 * new bb.plugin.stanford({ ... }),
12016 * new PluginA()
12017 * ]
12018 * });
12019 *
12020 * chart.plugins; // [Stanford, PluginA] - instance array
12021 */
12022var Chart = function Chart(options) {
12023 this.plugins = [];
12024 this.internal = void 0;
12025 var $$ = new ChartInternal(this);
12026 this.internal = $$;
12027
12028 // bind to namespaced APIs
12029 (function bindThis(fn, target, argThis) {
12030 var _this = this;
12031 Object.keys(fn).forEach(function (key) {
12032 _newArrowCheck(this, _this);
12033 var isFunc = isFunction(fn[key]),
12034 isChild = target !== argThis,
12035 isNotNil = notEmpty(fn[key]),
12036 hasChild = isNotNil && Object.keys(fn[key]).length > 0;
12037 if (isFunc && (!isChild && hasChild || isChild)) {
12038 target[key] = fn[key].bind(argThis);
12039 } else if (isNotNil && !isFunc) {
12040 target[key] = {};
12041 } else {
12042 target[key] = fn[key];
12043 }
12044 hasChild && bindThis(fn[key], target[key], argThis);
12045 }.bind(this));
12046 })(Chart.prototype, this, this);
12047 loadConfig.call($$, options);
12048 $$.beforeInit();
12049 $$.init();
12050}; // extend common APIs as part of Chart class
12051
12052extend(Chart.prototype, [chart, api_color, api_data, api_export, api_focus, api_legend, api_load, show, api_tooltip]);
12053;// CONCATENATED MODULE: ./src/Chart/api/axis.ts
12054
12055/**
12056 * Copyright (c) 2017 ~ present NAVER Corp.
12057 * billboard.js project is licensed under the MIT license
12058 */
12059
12060/**
12061 * Set the min/max value
12062 * @param {Chart} $$ Chart instance
12063 * @param {string} type Set type 'min' or 'max'
12064 * @param {object} value Value to be set
12065 * @private
12066 */
12067function setMinMax($$, type, value) {
12068 var _this = this,
12069 config = $$.config,
12070 helper = function (key, value) {
12071 _newArrowCheck(this, _this);
12072 var v = isNumber(value) ? value : value === !1 ? undefined : null;
12073 if (v !== null) {
12074 config["axis_" + key + "_" + type] = v;
12075 }
12076 }.bind(this);
12077 if (isDefined(value)) {
12078 if (isObjectType(value)) {
12079 Object.keys(value).forEach(function (key) {
12080 _newArrowCheck(this, _this);
12081 helper(key, value[key]);
12082 }.bind(this));
12083 } else if (isNumber(value) || value === !1) {
12084 // shorthand values affects only y and y2.
12085 ["y", "y2"].forEach(function (key) {
12086 _newArrowCheck(this, _this);
12087 helper(key, value);
12088 }.bind(this));
12089 }
12090 $$.redraw({
12091 withUpdateOrgXDomain: !0,
12092 withUpdateXDomain: !0
12093 });
12094 }
12095}
12096
12097/**
12098 * Get the min/max value
12099 * @param {Chart} $$ Chart instance
12100 * @param {string} type Set type 'min' or 'max'
12101 * @returns {{x, y, y2}}
12102 * @private
12103 */
12104function axis_getMinMax($$, type) {
12105 var config = $$.config;
12106 return {
12107 x: config["axis_x_" + type],
12108 y: config["axis_y_" + type],
12109 y2: config["axis_y2_" + type]
12110 };
12111}
12112
12113/**
12114 * Define axis
12115 * @ignore
12116 */
12117var axis = {
12118 /**
12119 * Get and set axis labels.
12120 * @function axis․labels
12121 * @instance
12122 * @memberof Chart
12123 * @param {object} labels specified axis' label to be updated.
12124 * @param {string} [labels.x] x Axis string
12125 * @param {string} [labels.y] y Axis string
12126 * @param {string} [labels.y2] y2 Axis string
12127 * @returns {object|undefined} axis labels text object
12128 * @example
12129 * // Update axis' label
12130 * chart.axis.labels({
12131 * x: "New X Axis Label",
12132 * y: "New Y Axis Label",
12133 * y2: "New Y2 Axis Label"
12134 * });
12135 *
12136 * chart.axis.labels();
12137 * // --> {
12138 * // x: "New X Axis Label",
12139 * // y: "New Y Axis Label",
12140 * // y2: "New Y2 Axis Label"
12141 * // }
12142 */
12143 labels: function labels(_labels) {
12144 var _this2 = this,
12145 $$ = this.internal,
12146 labelText;
12147 if (_labels) {
12148 Object.keys(_labels).forEach(function (axisId) {
12149 _newArrowCheck(this, _this2);
12150 $$.axis.setLabelText(axisId, _labels[axisId]);
12151 }.bind(this));
12152 $$.axis.updateLabels();
12153 }
12154 ["x", "y", "y2"].forEach(function (v) {
12155 _newArrowCheck(this, _this2);
12156 var text = $$.axis.getLabelText(v);
12157 if (text) {
12158 labelText || (labelText = {});
12159 labelText[v] = text;
12160 }
12161 }.bind(this));
12162 return labelText;
12163 },
12164 /**
12165 * Get and set axis min value.
12166 * @function axis․min
12167 * @instance
12168 * @memberof Chart
12169 * @param {object} min If min is given, specified axis' min value will be updated.<br>
12170 * If no argument is given, the min values set on generating option for each axis will be returned.
12171 * If not set any min values on generation, it will return `undefined`.<br>
12172 * To unset specific axis max, set `false` to each of them.
12173 * @returns {object|undefined}
12174 * @example
12175 * // Update axis' min
12176 * chart.axis.min({
12177 * x: -10,
12178 * y: 1000,
12179 * y2: 100
12180 * });
12181 *
12182 * // To unset specific axis min, set false to each of them.
12183 * chart.axis.min({
12184 * x: false,
12185 * y: false,
12186 * y2: false
12187 * });
12188 *
12189 * // shorthand (only affects y and y2 axis)
12190 * chart.axis.min(-50);
12191 * chart.axis.min(false);
12192 */
12193 min: function min(_min) {
12194 var $$ = this.internal;
12195 return isValue(_min) || _min === !1 ? setMinMax($$, "min", _min) : axis_getMinMax($$, "min");
12196 },
12197 /**
12198 * Get and set axis max value.
12199 * @function axis․max
12200 * @instance
12201 * @memberof Chart
12202 * @param {object} max If max is given, specified axis' max value will be updated.<br>
12203 * If no argument is given, the max values set on generating option for each axis will be returned.
12204 * If not set any max values on generation, it will return `undefined`.<br>
12205 * To unset specific axis max, set `false` to each of them.
12206 * @returns {object|undefined}
12207 * @example
12208 * // Update axis' label
12209 * chart.axis.max({
12210 * x: 100,
12211 * y: 1000,
12212 * y2: 10000
12213 * });
12214 *
12215 * // To unset specific axis max, set false to each of them.
12216 * chart.axis.max({
12217 * x: false,
12218 * y: false,
12219 * y2: false
12220 * });
12221 *
12222 * // shorthand (only affects y and y2 axis)
12223 * chart.axis.max(10);
12224 * chart.axis.max(false);
12225 */
12226 max: function max(_max) {
12227 var $$ = this.internal;
12228 return isValue(_max) || _max === !1 ? setMinMax($$, "max", _max) : axis_getMinMax($$, "max");
12229 },
12230 /**
12231 * Get and set axis min and max value.
12232 * @function axis․range
12233 * @instance
12234 * @memberof Chart
12235 * @param {object} range If range is given, specified axis' min and max value will be updated.
12236 * If no argument is given, the current min and max values for each axis will be returned.<br>
12237 * To unset specific axis max, set `false` to each of them.
12238 * @returns {object|undefined}
12239 * @example
12240 * // Update axis' label
12241 * chart.axis.range({
12242 * min: {
12243 * x: -10,
12244 * y: -1000,
12245 * y2: -10000
12246 * },
12247 * max: {
12248 * x: 100,
12249 * y: 1000,
12250 * y2: 10000
12251 * },
12252 * });
12253 *
12254 * // To unset specific axis max, set false to each of them.
12255 * chart.axis.range({
12256 * min: {
12257 * x: false,
12258 * y: false,
12259 * y2: false
12260 * },
12261 * max: {
12262 * x: false,
12263 * y: false,
12264 * y2: false
12265 * },
12266 * });
12267 *
12268 * // shorthand (only affects y and y2 axis)
12269 * chart.axis.range({ min: -50, max: 1000 });
12270 * chart.axis.range({ min: false, max: false });
12271 */
12272 range: function range(_range) {
12273 var axis = this.axis;
12274 if (arguments.length) {
12275 var min = _range.min,
12276 max = _range.max;
12277 isDefined(max) && axis.max(max);
12278 isDefined(min) && axis.min(min);
12279 } else {
12280 return {
12281 max: axis.max(),
12282 min: axis.min()
12283 };
12284 }
12285 return undefined;
12286 }
12287};
12288/* harmony default export */ var api_axis = ({
12289 axis: axis
12290});
12291;// CONCATENATED MODULE: ./src/Chart/api/category.ts
12292/**
12293 * Copyright (c) 2017 ~ present NAVER Corp.
12294 * billboard.js project is licensed under the MIT license
12295 */
12296/* harmony default export */ var api_category = ({
12297 /**
12298 * Set specified category name on category axis.
12299 * @function category
12300 * @instance
12301 * @memberof Chart
12302 * @param {number} i index of category to be changed
12303 * @param {string} category category value to be changed
12304 * @returns {string}
12305 * @example
12306 * chart.category(2, "Category 3");
12307 */
12308 category: function category(i, _category) {
12309 var $$ = this.internal,
12310 config = $$.config;
12311 if (arguments.length > 1) {
12312 config.axis_x_categories[i] = _category;
12313 $$.redraw();
12314 }
12315 return config.axis_x_categories[i];
12316 },
12317 /**
12318 * Set category names on category axis.
12319 * @function categories
12320 * @instance
12321 * @memberof Chart
12322 * @param {Array} categories This must be an array that includes category names in string. If category names are included in the date by data.x option, this is not required.
12323 * @returns {Array}
12324 * @example
12325 * chart.categories([
12326 * "Category 1", "Category 2", ...
12327 * ]);
12328 */
12329 categories: function categories(_categories) {
12330 var $$ = this.internal,
12331 config = $$.config;
12332 if (!arguments.length) {
12333 return config.axis_x_categories;
12334 }
12335 config.axis_x_categories = _categories;
12336 $$.redraw();
12337 return config.axis_x_categories;
12338 }
12339});
12340;// CONCATENATED MODULE: ./src/Chart/api/grid.x.ts
12341/**
12342 * Copyright (c) 2017 ~ present NAVER Corp.
12343 * billboard.js project is licensed under the MIT license
12344 */
12345
12346/**
12347 * Update x grid lines.
12348 * @function xgrids
12349 * @instance
12350 * @memberof Chart
12351 * @param {Array} grids X grid lines will be replaced with this argument. The format of this argument is the same as grid.x.lines.
12352 * @returns {object}
12353 * @example
12354 * // Show 2 x grid lines
12355 * chart.xgrids([
12356 * {value: 1, text: "Label 1"},
12357 * {value: 4, text: "Label 4"}
12358 * ]);
12359 * // --> Returns: [{value: 1, text: "Label 1"}, {value: 4, text: "Label 4"}]
12360 */
12361function xgrids(grids) {
12362 var $$ = this.internal,
12363 config = $$.config;
12364 if (!grids) {
12365 return config.grid_x_lines;
12366 }
12367 config.grid_x_lines = grids;
12368 $$.redrawWithoutRescale();
12369 return config.grid_x_lines;
12370}
12371extend(xgrids, {
12372 /**
12373 * Add x grid lines.<br>
12374 * This API adds new x grid lines instead of replacing like xgrids.
12375 * @function xgrids․add
12376 * @instance
12377 * @memberof Chart
12378 * @param {Array|object} grids New x grid lines will be added. The format of this argument is the same as grid.x.lines and it's possible to give an Object if only one line will be added.
12379 * @returns {object}
12380 * @example
12381 * // Add a new x grid line
12382 * chart.xgrids.add(
12383 * {value: 4, text: "Label 4"}
12384 * );
12385 *
12386 * // Add new x grid lines
12387 * chart.xgrids.add([
12388 * {value: 2, text: "Label 2"},
12389 * {value: 4, text: "Label 4"}
12390 * ]);
12391 */
12392 add: function add(grids) {
12393 return this.xgrids(this.internal.config.grid_x_lines.concat(grids || []));
12394 },
12395 /**
12396 * Remove x grid lines.<br>
12397 * This API removes x grid lines.
12398 * @function xgrids․remove
12399 * @instance
12400 * @memberof Chart
12401 * @param {object} params This argument should include value or class. If value is given, the x grid lines that have specified x value will be removed. If class is given, the x grid lines that have specified class will be removed. If args is not given, all of x grid lines will be removed.
12402 * @example
12403 * // x grid line on x = 2 will be removed
12404 * chart.xgrids.remove({value: 2});
12405 *
12406 * // x grid lines that have 'grid-A' will be removed
12407 * chart.xgrids.remove({
12408 * class: "grid-A"
12409 * });
12410 *
12411 * // all of x grid lines will be removed
12412 * chart.xgrids.remove();
12413 */
12414 remove: function remove(params) {
12415 // TODO: multiple
12416 this.internal.removeGridLines(params, !0);
12417 }
12418});
12419/* harmony default export */ var grid_x = ({
12420 xgrids: xgrids
12421});
12422;// CONCATENATED MODULE: ./src/Chart/api/grid.y.ts
12423/**
12424 * Copyright (c) 2017 ~ present NAVER Corp.
12425 * billboard.js project is licensed under the MIT license
12426 */
12427
12428
12429/**
12430 * Update y grid lines.
12431 * @function ygrids
12432 * @instance
12433 * @memberof Chart
12434 * @param {Array} grids Y grid lines will be replaced with this argument. The format of this argument is the same as grid.y.lines.
12435 * @returns {object}
12436 * @example
12437 * // Show 2 y grid lines
12438 * chart.ygrids([
12439 * {value: 100, text: "Label 1"},
12440 * {value: 400, text: "Label 4"}
12441 * ]);
12442 * // --> Returns: [{value: 100, text: "Label 1"}, {value: 400, text: "Label 4"}]
12443 */
12444function ygrids(grids) {
12445 var $$ = this.internal,
12446 config = $$.config;
12447 if (!grids) {
12448 return config.grid_y_lines;
12449 }
12450 config.grid_y_lines = grids;
12451 $$.redrawWithoutRescale();
12452 return config.grid_y_lines;
12453}
12454extend(ygrids, {
12455 /**
12456 * Add y grid lines.<br>
12457 * This API adds new y grid lines instead of replacing like ygrids.
12458 * @function ygrids․add
12459 * @instance
12460 * @memberof Chart
12461 * @param {Array|object} grids New y grid lines will be added. The format of this argument is the same as grid.y.lines and it's possible to give an Object if only one line will be added.
12462 * @returns {object}
12463 * @example
12464 * // Add a new x grid line
12465 * chart.ygrids.add(
12466 * {value: 400, text: "Label 4"}
12467 * );
12468 *
12469 * // Add new x grid lines
12470 * chart.ygrids.add([
12471 * {value: 200, text: "Label 2"},
12472 * {value: 400, text: "Label 4"}
12473 * ]);
12474 */
12475 add: function add(grids) {
12476 return this.ygrids(this.internal.config.grid_y_lines.concat(grids || []));
12477 },
12478 /**
12479 * Remove y grid lines.<br>
12480 * This API removes x grid lines.
12481 * @function ygrids․remove
12482 * @instance
12483 * @memberof Chart
12484 * @param {object} params This argument should include value or class. If value is given, the y grid lines that have specified y value will be removed. If class is given, the y grid lines that have specified class will be removed. If args is not given, all of y grid lines will be removed.
12485 * @param {number} [params.value] target value
12486 * @param {string} [params.class] target class
12487 * @example
12488 * // y grid line on y = 200 will be removed
12489 * chart.ygrids.remove({value: 200});
12490 *
12491 * // y grid lines that have 'grid-A' will be removed
12492 * chart.ygrids.remove({
12493 * class: "grid-A"
12494 * });
12495 *
12496 * // all of y grid lines will be removed
12497 * chart.ygrids.remove();
12498 */
12499 remove: function remove(params) {
12500 // TODO: multiple
12501 this.internal.removeGridLines(params, !1);
12502 }
12503});
12504/* harmony default export */ var grid_y = ({
12505 ygrids: ygrids
12506});
12507;// CONCATENATED MODULE: ./src/Chart/api/group.ts
12508/**
12509 * Copyright (c) 2017 ~ present NAVER Corp.
12510 * billboard.js project is licensed under the MIT license
12511 */
12512
12513/* harmony default export */ var group = ({
12514 /**
12515 * Update groups for the targets.
12516 * @function groups
12517 * @instance
12518 * @memberof Chart
12519 * @param {Array} groups This argument needs to be an Array that includes one or more Array that includes target ids to be grouped.
12520 * @returns {Array} Grouped data names array
12521 * @example
12522 * // data1 and data2 will be a new group.
12523 * chart.groups([
12524 * ["data1", "data2"]
12525 * ]);
12526 */
12527 groups: function groups(_groups) {
12528 var $$ = this.internal,
12529 config = $$.config;
12530 if (isUndefined(_groups)) {
12531 return config.data_groups;
12532 }
12533 config.data_groups = _groups;
12534 $$.redraw();
12535 return config.data_groups;
12536 }
12537});
12538;// CONCATENATED MODULE: ./src/Chart/api/regions.ts
12539
12540/**
12541 * Copyright (c) 2017 ~ present NAVER Corp.
12542 * billboard.js project is licensed under the MIT license
12543 */
12544
12545
12546/**
12547 * Update regions.
12548 * @function regions
12549 * @instance
12550 * @memberof Chart
12551 * @param {Array} regions Regions will be replaced with this argument. The format of this argument is the same as regions.
12552 * @returns {Array} regions
12553 * @example
12554 * // Show 2 regions
12555 * chart.regions([
12556 * {axis: "x", start: 5, class: "regionX"},
12557 * {axis: "y", end: 50, class: "regionY"}
12558 * ]);
12559 */
12560function regions(regions) {
12561 var $$ = this.internal,
12562 config = $$.config;
12563 if (!regions) {
12564 return config.regions;
12565 }
12566 config.regions = regions;
12567 $$.redrawWithoutRescale();
12568 return regions;
12569}
12570extend(regions, {
12571 /**
12572 * Add new region.<br><br>
12573 * This API adds new region instead of replacing like regions.
12574 * @function regions․add
12575 * @instance
12576 * @memberof Chart
12577 * @param {Array|object} regions New region will be added. The format of this argument is the same as regions and it's possible to give an Object if only one region will be added.
12578 * @returns {Array} regions
12579 * @example
12580 * // Add a new region
12581 * chart.regions.add(
12582 * {axis: "x", start: 5, class: "regionX"}
12583 * );
12584 *
12585 * // Add new regions
12586 * chart.regions.add([
12587 * {axis: "x", start: 5, class: "regionX"},
12588 * {axis: "y", end: 50, class: "regionY"}
12589 *]);
12590 */
12591 add: function add(regions) {
12592 var $$ = this.internal,
12593 config = $$.config;
12594 if (!regions) {
12595 return config.regions;
12596 }
12597 config.regions = config.regions.concat(regions);
12598 $$.redrawWithoutRescale();
12599 return config.regions;
12600 },
12601 /**
12602 * Remove regions.<br><br>
12603 * This API removes regions.
12604 * @function regions․remove
12605 * @instance
12606 * @memberof Chart
12607 * @param {object} optionsValue This argument should include classes. If classes is given, the regions that have one of the specified classes will be removed. If args is not given, all of regions will be removed.
12608 * @returns {Array} regions Removed regions
12609 * @example
12610 * // regions that have 'region-A' or 'region-B' will be removed.
12611 * chart.regions.remove({
12612 * classes: [
12613 * "region-A", "region-B"
12614 * ]
12615 * });
12616 *
12617 * // all of regions will be removed.
12618 * chart.regions.remove();
12619 */
12620 remove: function remove(optionsValue) {
12621 var _this = this,
12622 $$ = this.internal,
12623 config = $$.config,
12624 $T = $$.$T,
12625 options = optionsValue || {},
12626 classes = getOption(options, "classes", [$REGION.region]),
12627 regions = $$.$el.main.select("." + $REGION.regions).selectAll(classes.map(function (c) {
12628 _newArrowCheck(this, _this);
12629 return "." + c;
12630 }.bind(this)));
12631 $T(regions).style("opacity", "0").remove();
12632 regions = config.regions;
12633 if (Object.keys(options).length) {
12634 regions = regions.filter(function (region) {
12635 var _this2 = this;
12636 _newArrowCheck(this, _this);
12637 var found = !1;
12638 if (!region.class) {
12639 return !0;
12640 }
12641 region.class.split(" ").forEach(function (c) {
12642 _newArrowCheck(this, _this2);
12643 if (classes.indexOf(c) >= 0) {
12644 found = !0;
12645 }
12646 }.bind(this));
12647 return !found;
12648 }.bind(this));
12649 config.regions = regions;
12650 } else {
12651 config.regions = [];
12652 }
12653 return regions;
12654 }
12655});
12656/* harmony default export */ var api_regions = ({
12657 regions: regions
12658});
12659;// CONCATENATED MODULE: ./src/Chart/api/x.ts
12660/**
12661 * Copyright (c) 2017 ~ present NAVER Corp.
12662 * billboard.js project is licensed under the MIT license
12663 */
12664
12665/* harmony default export */ var x = ({
12666 /**
12667 * Get and set x values for the chart.
12668 * @function x
12669 * @instance
12670 * @memberof Chart
12671 * @param {Array} x If x is given, x values of every target will be updated. If no argument is given, current x values will be returned as an Object whose keys are the target ids.
12672 * @returns {object} xs
12673 * @example
12674 * // Get current x values
12675 * chart.x();
12676 *
12677 * // Update x values for all targets
12678 * chart.x([100, 200, 300, 400, ...]);
12679 */
12680 x: function x(_x) {
12681 var $$ = this.internal,
12682 axis = $$.axis,
12683 data = $$.data,
12684 isCategorized = axis.isCustomX() && axis.isCategorized();
12685 if (isArray(_x)) {
12686 if (isCategorized) {
12687 this.categories(_x);
12688 } else {
12689 $$.updateTargetX(data.targets, _x);
12690 $$.redraw({
12691 withUpdateOrgXDomain: !0,
12692 withUpdateXDomain: !0
12693 });
12694 }
12695 }
12696 return isCategorized ? this.categories() : data.xs;
12697 },
12698 /**
12699 * Get and set x values for the chart.
12700 * @function xs
12701 * @instance
12702 * @memberof Chart
12703 * @param {Array} xs If xs is given, specified target's x values will be updated. If no argument is given, current x values will be returned as an Object whose keys are the target ids.
12704 * @returns {object} xs
12705 * @example
12706 * // Get current x values
12707 * chart.xs();
12708 *
12709 * // Update x values for all targets
12710 * chart.xs({
12711 * data1: [10, 20, 30, 40, ...],
12712 * data2: [100, 200, 300, 400, ...]
12713 * });
12714 */
12715 xs: function xs(_xs) {
12716 var $$ = this.internal;
12717 if (isObject(_xs)) {
12718 $$.updateTargetXs($$.data.targets, _xs);
12719 $$.redraw({
12720 withUpdateOrgXDomain: !0,
12721 withUpdateXDomain: !0
12722 });
12723 }
12724 return $$.data.xs;
12725 }
12726});
12727;// CONCATENATED MODULE: ./src/Chart/api/flow.ts
12728
12729/**
12730 * Copyright (c) 2017 ~ present NAVER Corp.
12731 * billboard.js project is licensed under the MIT license
12732 */
12733
12734/* harmony default export */ var flow = ({
12735 /**
12736 * Flow data to the chart.<br><br>
12737 * By this API, you can append new data points to the chart.
12738 * @function flow
12739 * @instance
12740 * @memberof Chart
12741 * @param {object} args The object can consist with following members:<br>
12742 *
12743 * | Key | Type | Description |
12744 * | --- | --- | --- |
12745 * | json | Object | Data as JSON format (@see [data․json](Options.html#.data%25E2%2580%25A4json)) |
12746 * | rows | Array | Data in array as row format (@see [data․rows](Options.html#.data%25E2%2580%25A4json)) |
12747 * | columns | Array | Data in array as column format (@see [data․columns](Options.html#.data%25E2%2580%25A4columns)) |
12748 * | to | String | The lower x edge will move to that point. If not given, the lower x edge will move by the number of given data points |
12749 * | length | Number | The lower x edge will move by the number of this argument |
12750 * | duration | Number | The duration of the transition will be specified value. If not given, transition.duration will be used as default |
12751 * | done | Function | The specified function will be called when flow ends |
12752 *
12753 * - **NOTE:**
12754 * - If json, rows and columns given, the data will be loaded.
12755 * - If data that has the same target id is given, the chart will be appended.
12756 * - Otherwise, new target will be added. One of these is required when calling.
12757 * - If json specified, keys is required as well as data.json.
12758 * - If tab isn't visible(by evaluating `document.hidden`), will not be executed to prevent unnecessary work.
12759 * @example
12760 * // 2 data points will be apprended to the tail and popped from the head.
12761 * // After that, 4 data points will be appended and no data points will be poppoed.
12762 * chart.flow({
12763 * columns: [
12764 * ["x", "2018-01-11", "2018-01-21"],
12765 * ["data1", 500, 200],
12766 * ["data2", 100, 300],
12767 * ["data3", 200, 120]
12768 * ],
12769 * to: "2013-01-11",
12770 * done: function () {
12771 * chart.flow({
12772 * columns: [
12773 * ["x", "2018-02-11", "2018-02-12", "2018-02-13", "2018-02-14"],
12774 * ["data1", 200, 300, 100, 250],
12775 * ["data2", 100, 90, 40, 120],
12776 * ["data3", 100, 100, 300, 500]
12777 * ],
12778 * length: 2,
12779 * duration: 1500
12780 * });
12781 * }
12782 * });
12783 */
12784 flow: function flow(args) {
12785 var _this = this,
12786 $$ = this.internal,
12787 data;
12788 if (args.json || args.rows || args.columns) {
12789 $$.convertData(args, function (res) {
12790 _newArrowCheck(this, _this);
12791 data = res;
12792 _();
12793 }.bind(this));
12794 }
12795
12796 /**
12797 * Process flows
12798 * @private
12799 */
12800 function _() {
12801 var _this2 = this,
12802 domain,
12803 length = 0,
12804 tail = 0,
12805 diff,
12806 to;
12807 if ($$.state.redrawing || !data || !isTabVisible()) {
12808 return;
12809 }
12810 var notfoundIds = [],
12811 orgDataCount = $$.getMaxDataCount(),
12812 targets = $$.convertDataToTargets(data, !0),
12813 isTimeSeries = $$.axis.isTimeSeries();
12814 // Update/Add data
12815 $$.data.targets.forEach(function (t) {
12816 _newArrowCheck(this, _this2);
12817 var found = !1;
12818 for (var i = 0; i < targets.length; i++) {
12819 if (t.id === targets[i].id) {
12820 found = !0;
12821 if (t.values[t.values.length - 1]) {
12822 tail = t.values[t.values.length - 1].index + 1;
12823 }
12824 length = targets[i].values.length;
12825 for (var j = 0; j < length; j++) {
12826 targets[i].values[j].index = tail + j;
12827 if (!isTimeSeries) {
12828 targets[i].values[j].x = tail + j;
12829 }
12830 }
12831 t.values = t.values.concat(targets[i].values);
12832 targets.splice(i, 1);
12833 break;
12834 }
12835 }
12836 found || notfoundIds.push(t.id);
12837 }.bind(this));
12838
12839 // Append null for not found targets
12840 $$.data.targets.forEach(function (t) {
12841 _newArrowCheck(this, _this2);
12842 for (var i = 0; i < notfoundIds.length; i++) {
12843 if (t.id === notfoundIds[i]) {
12844 tail = t.values[t.values.length - 1].index + 1;
12845 for (var j = 0; j < length; j++) {
12846 t.values.push({
12847 id: t.id,
12848 index: tail + j,
12849 x: isTimeSeries ? $$.getOtherTargetX(tail + j) : tail + j,
12850 value: null
12851 });
12852 }
12853 }
12854 }
12855 }.bind(this));
12856
12857 // Generate null values for new target
12858 if ($$.data.targets.length) {
12859 targets.forEach(function (t) {
12860 var _this3 = this;
12861 _newArrowCheck(this, _this2);
12862 var missing = [];
12863 for (var i = $$.data.targets[0].values[0].index; i < tail; i++) {
12864 missing.push({
12865 id: t.id,
12866 index: i,
12867 x: isTimeSeries ? $$.getOtherTargetX(i) : i,
12868 value: null
12869 });
12870 }
12871 t.values.forEach(function (v) {
12872 _newArrowCheck(this, _this3);
12873 v.index += tail;
12874 if (!isTimeSeries) {
12875 v.x += tail;
12876 }
12877 }.bind(this));
12878 t.values = missing.concat(t.values);
12879 }.bind(this));
12880 }
12881 $$.data.targets = $$.data.targets.concat(targets); // add remained
12882
12883 // check data count because behavior needs to change when it"s only one
12884 // const dataCount = $$.getMaxDataCount();
12885 var baseTarget = $$.data.targets[0],
12886 baseValue = baseTarget.values[0];
12887 // Update length to flow if needed
12888 if (isDefined(args.to)) {
12889 length = 0;
12890 to = isTimeSeries ? parseDate.call($$, args.to) : args.to;
12891 baseTarget.values.forEach(function (v) {
12892 _newArrowCheck(this, _this2);
12893 v.x < to && length++;
12894 }.bind(this));
12895 } else if (isDefined(args.length)) {
12896 length = args.length;
12897 }
12898
12899 // If only one data, update the domain to flow from left edge of the chart
12900 if (!orgDataCount) {
12901 if (isTimeSeries) {
12902 diff = baseTarget.values.length > 1 ? baseTarget.values[baseTarget.values.length - 1].x - baseValue.x : baseValue.x - $$.getXDomain($$.data.targets)[0];
12903 } else {
12904 diff = 1;
12905 }
12906 domain = [baseValue.x - diff, baseValue.x];
12907 } else if (orgDataCount === 1 && isTimeSeries) {
12908 diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2;
12909 domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)];
12910 }
12911 domain && $$.updateXDomain(null, !0, !0, !1, domain);
12912
12913 // Set targets
12914 $$.updateTargets($$.data.targets);
12915
12916 // Redraw with new targets
12917 $$.redraw({
12918 flow: {
12919 index: baseValue.index,
12920 length: length,
12921 duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
12922 done: args.done,
12923 orgDataCount: orgDataCount
12924 },
12925 withLegend: !0,
12926 withTransition: orgDataCount > 1,
12927 withTrimXDomain: !1,
12928 withUpdateXAxis: !0
12929 });
12930 }
12931 }
12932});
12933// EXTERNAL MODULE: external {"commonjs":"d3-axis","commonjs2":"d3-axis","amd":"d3-axis","root":"d3"}
12934var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack_require__(10);
12935;// CONCATENATED MODULE: ./src/ChartInternal/Axis/AxisRendererHelper.ts
12936
12937/**
12938 * Copyright (c) 2017 ~ present NAVER Corp.
12939 * billboard.js project is licensed under the MIT license
12940 * @ignore
12941 */
12942
12943
12944var AxisRendererHelper = /*#__PURE__*/function () {
12945 function AxisRendererHelper(owner) {
12946 this.owner = void 0;
12947 this.config = void 0;
12948 this.scale = void 0;
12949 var scale = getScale(),
12950 config = owner.config,
12951 params = owner.params;
12952 this.owner = owner;
12953 this.config = config;
12954 this.scale = scale;
12955 if (config.noTransition || !params.config.transition_duration) {
12956 config.withoutTransition = !0;
12957 }
12958
12959 // set range
12960 config.range = this.scaleExtent((params.orgXScale || scale).range());
12961 }
12962
12963 /**
12964 * Compute a character dimension
12965 * @param {d3.selection} node <g class=tick> node
12966 * @returns {{w: number, h: number}}
12967 * @private
12968 */
12969 AxisRendererHelper.getSizeFor1Char = function getSizeFor1Char(node) {
12970 var _this = this,
12971 size = {
12972 w: 5.5,
12973 h: 11.5
12974 };
12975 node.empty() || node.select("text").text("0").call(function (el) {
12976 _newArrowCheck(this, _this);
12977 try {
12978 var _el$node$getBBox = el.node().getBBox(),
12979 width = _el$node$getBBox.width,
12980 height = _el$node$getBBox.height;
12981 if (width && height) {
12982 size.w = width;
12983 size.h = height;
12984 }
12985 } catch (e) {} finally {
12986 el.text("");
12987 }
12988 }.bind(this));
12989 this.getSizeFor1Char = function () {
12990 _newArrowCheck(this, _this);
12991 return size;
12992 }.bind(this);
12993 return size;
12994 }
12995
12996 /**
12997 * Get tick transform setter function
12998 * @param {string} id Axis id
12999 * @returns {Function} transfrom setter function
13000 * @private
13001 */;
13002 var _proto = AxisRendererHelper.prototype;
13003 _proto.getTickTransformSetter = function getTickTransformSetter(id) {
13004 var _this2 = this,
13005 config = this.config,
13006 fn = id === "x" ? function (value) {
13007 _newArrowCheck(this, _this2);
13008 return "translate(" + (value + config.tickOffset) + ",0)";
13009 }.bind(this) : function (value) {
13010 _newArrowCheck(this, _this2);
13011 return "translate(0," + value + ")";
13012 }.bind(this);
13013 return function (selection, scale) {
13014 var _this3 = this;
13015 _newArrowCheck(this, _this2);
13016 selection.attr("transform", function (d) {
13017 _newArrowCheck(this, _this3);
13018 return isValue(d) ? fn(Math.ceil(scale(d))) : null;
13019 }.bind(this));
13020 }.bind(this);
13021 };
13022 _proto.scaleExtent = function scaleExtent(domain) {
13023 var start = domain[0],
13024 stop = domain[domain.length - 1];
13025 return start < stop ? [start, stop] : [stop, start];
13026 };
13027 _proto.generateTicks = function generateTicks(scale, isYAxes) {
13028 var _this4 = this,
13029 tickStepSize = this.owner.params.tickStepSize,
13030 _scale$domain = scale.domain(),
13031 start = _scale$domain[0],
13032 end = _scale$domain[1],
13033 ticks = [];
13034 // When 'axis[y|y2].tick.stepSize' option is set
13035 if (isYAxes && tickStepSize) {
13036 var interval = Math.round(start);
13037 while (interval <= end) {
13038 ticks.push(interval);
13039 interval += tickStepSize;
13040 }
13041 } else if (scale.ticks) {
13042 var tickArguments = this.config.tickArguments;
13043
13044 // adjust excessive tick count show
13045 if (scale.type === "log" && !tickArguments) {
13046 // nicer symlog ticks didn't implemented yet: https://github.com/d3/d3-scale/issues/162
13047 // get ticks values from logScale
13048 var s = getScale("_log").domain([start > 0 ? start : 1, end]).range(scale.range());
13049 ticks = s.ticks();
13050 for (var cnt = end.toFixed().length; ticks.length > 15; cnt--) {
13051 ticks = s.ticks(cnt);
13052 }
13053 ticks.splice(0, 1, start);
13054 ticks.splice(ticks.length - 1, 1, end);
13055 } else {
13056 ticks = scale.ticks.apply(scale, this.config.tickArguments || []);
13057 }
13058 ticks = ticks.map(function (v) {
13059 _newArrowCheck(this, _this4);
13060 // round the tick value if is number
13061 var r = isString(v) && isNumber(v) && !isNaN(v) && Math.round(v * 10) / 10 || v;
13062 return r;
13063 }.bind(this));
13064 } else {
13065 for (var i = Math.ceil(start); i < end; i++) {
13066 ticks.push(i);
13067 }
13068 if (ticks.length > 0 && ticks[0] > 0) {
13069 ticks.unshift(ticks[0] - (ticks[1] - ticks[0]));
13070 }
13071 }
13072 return ticks;
13073 };
13074 _proto.copyScale = function copyScale() {
13075 var newScale = this.scale.copy();
13076 if (!newScale.domain().length) {
13077 newScale.domain(this.scale.domain());
13078 }
13079 newScale.type = this.scale.type;
13080 return newScale;
13081 };
13082 _proto.textFormatted = function textFormatted(v) {
13083 var tickFormat = this.config.tickFormat,
13084 value = /\d+\.\d+0{5,}\d$/.test(v) ? +(v + "").replace(/0+\d$/, "") : v,
13085 formatted = tickFormat ? tickFormat(value) : value; // to round float numbers from 'binary floating point'
13086 // https://en.wikipedia.org/wiki/Double-precision_floating-point_format
13087 // https://stackoverflow.com/questions/17849101/laymans-explanation-for-why-javascript-has-weird-floating-math-ieee-754-stand
13088 return isDefined(formatted) ? formatted : "";
13089 };
13090 _proto.transitionise = function transitionise(selection) {
13091 var config = this.config,
13092 transitionSelection = selection;
13093 if (config.withoutTransition) {
13094 transitionSelection = selection.interrupt();
13095 } else if (config.transition || !this.owner.params.noTransition) {
13096 // prevent for 'transition not found' case
13097 // https://github.com/naver/billboard.js/issues/2140
13098 try {
13099 transitionSelection = selection.transition(config.transition);
13100 } catch (e) {}
13101 }
13102 return transitionSelection;
13103 };
13104 return AxisRendererHelper;
13105}();
13106
13107;// CONCATENATED MODULE: ./src/ChartInternal/Axis/AxisRenderer.ts
13108
13109/**
13110 * Copyright (c) 2017 ~ present NAVER Corp.
13111 * billboard.js project is licensed under the MIT license
13112 * @ignore
13113 */
13114
13115
13116
13117var AxisRenderer = /*#__PURE__*/function () {
13118 function AxisRenderer(params) {
13119 if (params === void 0) {
13120 params = {};
13121 }
13122 this.helper = void 0;
13123 this.config = void 0;
13124 this.params = void 0;
13125 this.g = void 0;
13126 this.generatedTicks = void 0;
13127 var config = {
13128 innerTickSize: 6,
13129 outerTickSize: params.outerTick ? 6 : 0,
13130 orient: "bottom",
13131 range: [],
13132 tickArguments: null,
13133 tickCentered: null,
13134 tickCulling: !0,
13135 tickFormat: null,
13136 tickLength: 9,
13137 tickOffset: 0,
13138 tickPadding: 3,
13139 tickValues: null,
13140 transition: null,
13141 noTransition: params.noTransition
13142 };
13143 config.tickLength = Math.max(config.innerTickSize, 0) + config.tickPadding;
13144 this.config = config;
13145 this.params = params;
13146 this.helper = new AxisRendererHelper(this);
13147 }
13148
13149 /**
13150 * Create axis element
13151 * @param {d3.selection} g Axis selection
13152 * @private
13153 */
13154 var _proto = AxisRenderer.prototype;
13155 _proto.create = function create(g) {
13156 var ctx = this,
13157 config = ctx.config,
13158 helper = ctx.helper,
13159 params = ctx.params,
13160 scale = helper.scale,
13161 orient = config.orient,
13162 splitTickText = this.splitTickText.bind(ctx),
13163 isLeftRight = /^(left|right)$/.test(orient),
13164 isTopBottom = /^(top|bottom)$/.test(orient),
13165 tickTransform = helper.getTickTransformSetter(isTopBottom ? "x" : "y"),
13166 axisPx = tickTransform === helper.axisX ? "y" : "x",
13167 sign = /^(top|left)$/.test(orient) ? -1 : 1,
13168 rotate = params.tickTextRotate;
13169 this.config.range = scale.rangeExtent ? scale.rangeExtent() : helper.scaleExtent((params.orgXScale || scale).range());
13170 var innerTickSize = config.innerTickSize,
13171 tickLength = config.tickLength,
13172 range = config.range,
13173 id = params.id,
13174 tickTextPos = id && /^(x|y|y2)$/.test(id) ? params.config["axis_" + id + "_tick_text_position"] : {
13175 x: 0,
13176 y: 0
13177 },
13178 prefix = id === "subX" ? "subchart_axis_x" : "axis_" + id,
13179 axisShow = params.config[prefix + "_show"],
13180 tickShow = {
13181 tick: axisShow ? params.config[prefix + "_tick_show"] : !1,
13182 text: axisShow ? params.config[prefix + "_tick_text_show"] : !1
13183 },
13184 $g; // // get the axis' tick position configuration
13185 g.each(function () {
13186 var _this = this,
13187 g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
13188 scale0 = this.__chart__ || scale,
13189 scale1 = helper.copyScale();
13190 $g = g;
13191 this.__chart__ = scale1;
13192 config.tickOffset = params.isCategory ? Math.ceil((scale1(1) - scale1(0)) / 2) : 0;
13193
13194 // update selection - data join
13195 var path = g.selectAll(".domain").data([0]);
13196
13197 // enter + update selection
13198 path.enter().append("path").attr("class", "domain")
13199 // https://observablehq.com/@d3/d3-selection-2-0
13200 .merge(path).attr("d", function () {
13201 _newArrowCheck(this, _this);
13202 var outerTickSized = config.outerTickSize * sign;
13203 return isTopBottom ? "M" + range[0] + "," + outerTickSized + "V0H" + range[1] + "V" + outerTickSized : "M" + outerTickSized + "," + range[0] + "H0V" + range[1] + "H" + outerTickSized;
13204 }.bind(this));
13205 if (tickShow.tick || tickShow.text) {
13206 // count of tick data in array
13207 var ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight);
13208
13209 // set generated ticks
13210 ctx.generatedTicks = ticks;
13211
13212 // update selection
13213 var tick = g.selectAll(".tick").data(ticks, scale1),
13214 tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick"),
13215 tickExit = tick.exit().remove(); // enter selection
13216 // enter + update selection
13217 tick = tickEnter.merge(tick);
13218 tickShow.tick && tickEnter.append("line");
13219 tickShow.text && tickEnter.append("text");
13220 var sizeFor1Char = AxisRendererHelper.getSizeFor1Char(tick),
13221 counts = [],
13222 tspan = tick.select("text").selectAll("tspan").data(function (d, index) {
13223 var _this2 = this;
13224 _newArrowCheck(this, _this);
13225 var split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
13226 counts[index] = split.length;
13227 return split.map(function (splitted) {
13228 _newArrowCheck(this, _this2);
13229 return {
13230 index: index,
13231 splitted: splitted
13232 };
13233 }.bind(this));
13234 }.bind(this));
13235 tspan.exit().remove();
13236 tspan = tspan.enter().append("tspan").merge(tspan).text(function (d) {
13237 _newArrowCheck(this, _this);
13238 return d.splitted;
13239 }.bind(this));
13240
13241 // set <tspan>'s position
13242 tspan.attr("x", isTopBottom ? 0 : tickLength * sign).attr("dx", function () {
13243 _newArrowCheck(this, _this);
13244 var dx = 0;
13245 if (/(top|bottom)/.test(orient) && rotate) {
13246 dx = 8 * Math.sin(Math.PI * (rotate / 180)) * (orient === "top" ? -1 : 1);
13247 }
13248 return dx + (tickTextPos.x || 0);
13249 }.bind(this)()).attr("dy", function (d, i) {
13250 _newArrowCheck(this, _this);
13251 var dy = 0;
13252 if (orient !== "top") {
13253 dy = sizeFor1Char.h;
13254 if (i === 0) {
13255 dy = isLeftRight ? -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3) : tickTextPos.y === 0 ? ".71em" : 0;
13256 }
13257 }
13258 return isNumber(dy) && tickTextPos.y ? dy + tickTextPos.y : dy || ".71em";
13259 }.bind(this));
13260 var lineUpdate = tick.select("line"),
13261 textUpdate = tick.select("text");
13262 tickEnter.select("line").attr(axisPx + "2", innerTickSize * sign);
13263 tickEnter.select("text").attr(axisPx, tickLength * sign);
13264 ctx.setTickLineTextPosition(lineUpdate, textUpdate);
13265
13266 // Append <title> for tooltip display
13267 if (params.tickTitle) {
13268 var title = textUpdate.select("title");
13269 (title.empty() ? textUpdate.append("title") : title).text(function (index) {
13270 _newArrowCheck(this, _this);
13271 return params.tickTitle[index];
13272 }.bind(this));
13273 }
13274 if (scale1.bandwidth) {
13275 var x = scale1,
13276 dx = x.bandwidth() / 2;
13277 scale0 = function (d) {
13278 _newArrowCheck(this, _this);
13279 return x(d) + dx;
13280 }.bind(this);
13281 scale1 = scale0;
13282 } else if (scale0.bandwidth) {
13283 scale0 = scale1;
13284 } else {
13285 tickTransform(tickExit, scale1);
13286 }
13287
13288 // when .flow(), it should follow flow's transition config
13289 // otherwise make to use ChartInternals.$T()
13290 tick = params.owner.state.flowing ? helper.transitionise(tick) : params.owner.$T(tick);
13291 tickTransform(tickEnter, scale0);
13292 tickTransform(tick.style("opacity", null), scale1);
13293 }
13294 });
13295 this.g = $g;
13296 }
13297
13298 /**
13299 * Get generated ticks
13300 * @param {number} count Count of ticks
13301 * @returns {Array} Generated ticks
13302 * @private
13303 */;
13304 _proto.getGeneratedTicks = function getGeneratedTicks(count) {
13305 var _this$generatedTicks,
13306 len = ((_this$generatedTicks = this.generatedTicks) == null ? void 0 : _this$generatedTicks.length) - 1,
13307 res = this.generatedTicks,
13308 _this3 = this;
13309 if (len > count) {
13310 var interval = Math.round(len / count + .1);
13311 res = this.generatedTicks.map(function (v, i) {
13312 _newArrowCheck(this, _this3);
13313 return i % interval === 0 ? v : null;
13314 }.bind(this)).filter(function (v) {
13315 _newArrowCheck(this, _this3);
13316 return v !== null;
13317 }.bind(this)).splice(0, count);
13318 }
13319 return res;
13320 }
13321
13322 /**
13323 * Get tick x/y coordinate
13324 * @returns {{x: number, y: number}}
13325 * @private
13326 */;
13327 _proto.getTickXY = function getTickXY() {
13328 var config = this.config,
13329 pos = {
13330 x: 0,
13331 y: 0
13332 };
13333 if (this.params.isCategory) {
13334 pos.x = config.tickCentered ? 0 : config.tickOffset;
13335 pos.y = config.tickCentered ? config.tickOffset : 0;
13336 }
13337 return pos;
13338 }
13339
13340 /**
13341 * Get tick size
13342 * @param {object} d data object
13343 * @returns {number}
13344 * @private
13345 */;
13346 _proto.getTickSize = function getTickSize(d) {
13347 var scale = this.helper.scale,
13348 config = this.config,
13349 _config2 = config,
13350 innerTickSize = _config2.innerTickSize,
13351 range = _config2.range,
13352 tickPosition = scale(d) + (config.tickCentered ? 0 : config.tickOffset);
13353 return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0;
13354 }
13355
13356 /**
13357 * Set tick's line & text position
13358 * @param {d3.selection} lineUpdate Line selection
13359 * @param {d3.selection} textUpdate Text selection
13360 * @private
13361 */;
13362 _proto.setTickLineTextPosition = function setTickLineTextPosition(lineUpdate, textUpdate) {
13363 var _this4 = this,
13364 tickPos = this.getTickXY(),
13365 _this$config = this.config,
13366 innerTickSize = _this$config.innerTickSize,
13367 orient = _this$config.orient,
13368 tickLength = _this$config.tickLength,
13369 tickOffset = _this$config.tickOffset,
13370 rotate = this.params.tickTextRotate,
13371 textAnchorForText = function (r) {
13372 _newArrowCheck(this, _this4);
13373 var value = ["start", "end"];
13374 orient === "top" && value.reverse();
13375 return !r ? "middle" : value[r > 0 ? 0 : 1];
13376 }.bind(this),
13377 textTransform = function (r) {
13378 _newArrowCheck(this, _this4);
13379 return r ? "rotate(" + r + ")" : null;
13380 }.bind(this),
13381 yForText = function (r) {
13382 _newArrowCheck(this, _this4);
13383 var r2 = r / (orient === "bottom" ? 15 : 23);
13384 return r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
13385 }.bind(this);
13386 switch (orient) {
13387 case "bottom":
13388 lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", this.getTickSize.bind(this));
13389 textUpdate.attr("x", 0).attr("y", yForText(rotate)).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
13390 break;
13391 case "top":
13392 lineUpdate.attr("x2", 0).attr("y2", -innerTickSize);
13393 textUpdate.attr("x", 0).attr("y", -yForText(rotate) * 2).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
13394 break;
13395 case "left":
13396 lineUpdate.attr("x2", -innerTickSize).attr("y1", tickPos.y).attr("y2", tickPos.y);
13397 textUpdate.attr("x", -tickLength).attr("y", tickOffset).style("text-anchor", "end");
13398 break;
13399 case "right":
13400 lineUpdate.attr("x2", innerTickSize).attr("y2", 0);
13401 textUpdate.attr("x", tickLength).attr("y", 0).style("text-anchor", "start");
13402 }
13403 }
13404
13405 // this should be called only when category axis
13406 ;
13407 _proto.splitTickText = function splitTickText(d, scale, ticks, isLeftRight, charWidth) {
13408 var params = this.params,
13409 tickText = this.helper.textFormatted(d),
13410 splitted = isString(tickText) && tickText.indexOf("\n") > -1 ? tickText.split("\n") : [];
13411 if (splitted.length) {
13412 return splitted;
13413 }
13414 if (isArray(tickText)) {
13415 return tickText;
13416 }
13417 var tickWidth = params.tickWidth;
13418 if (!tickWidth || tickWidth <= 0) {
13419 tickWidth = isLeftRight ? 95 : params.isCategory ? Math.ceil(scale(ticks[1]) - scale(ticks[0])) - 12 : 110;
13420 }
13421
13422 // split given text by tick width size
13423 // eslint-disable-next-line
13424 function split(splitted, text) {
13425 var subtext, spaceIndex, textWidth;
13426 for (var i = 1; i < text.length; i++) {
13427 if (text.charAt(i) === " ") {
13428 spaceIndex = i;
13429 }
13430 subtext = text.substr(0, i + 1);
13431 textWidth = charWidth * subtext.length;
13432
13433 // if text width gets over tick width, split by space index or current index
13434 if (tickWidth < textWidth) {
13435 return split(splitted.concat(text.substr(0, spaceIndex || i)), text.slice(spaceIndex ? spaceIndex + 1 : i));
13436 }
13437 }
13438 return splitted.concat(text);
13439 }
13440 return split(splitted, tickText + "");
13441 };
13442 _proto.scale = function scale(x) {
13443 if (!arguments.length) {
13444 return this.helper.scale;
13445 }
13446 this.helper.scale = x;
13447 return this;
13448 };
13449 _proto.orient = function orient(x) {
13450 if (!arguments.length) {
13451 return this.config.orient;
13452 }
13453 this.config.orient = x in {
13454 top: 1,
13455 right: 1,
13456 bottom: 1,
13457 left: 1
13458 } ? x + "" : "bottom";
13459 return this;
13460 };
13461 _proto.tickFormat = function tickFormat(format) {
13462 var config = this.config;
13463 if (!arguments.length) {
13464 return config.tickFormat;
13465 }
13466 config.tickFormat = format;
13467 return this;
13468 };
13469 _proto.tickCentered = function tickCentered(isCentered) {
13470 var config = this.config;
13471 if (!arguments.length) {
13472 return config.tickCentered;
13473 }
13474 config.tickCentered = isCentered;
13475 return this;
13476 }
13477
13478 /**
13479 * Return tick's offset value.
13480 * The value will be set for 'category' axis type.
13481 * @returns {number}
13482 * @private
13483 */;
13484 _proto.tickOffset = function tickOffset() {
13485 return this.config.tickOffset;
13486 }
13487
13488 /**
13489 * Get tick interval count
13490 * @private
13491 * @param {number} size Total data size
13492 * @returns {number}
13493 */;
13494 _proto.tickInterval = function tickInterval(size) {
13495 var _this5 = this,
13496 _this$config2 = this.config,
13497 outerTickSize = _this$config2.outerTickSize,
13498 tickOffset = _this$config2.tickOffset,
13499 tickValues = _this$config2.tickValues,
13500 interval;
13501 if (this.params.isCategory) {
13502 interval = tickOffset * 2;
13503 } else {
13504 var length = this.g.select("path.domain").node().getTotalLength() - outerTickSize * 2;
13505 interval = length / (size || this.g.selectAll("line").size());
13506
13507 // get the interval by its values
13508 var intervalByValue = tickValues ? tickValues.map(function (v, i, arr) {
13509 _newArrowCheck(this, _this5);
13510 var next = i + 1;
13511 return next < arr.length ? this.helper.scale(arr[next]) - this.helper.scale(v) : null;
13512 }.bind(this)).filter(Boolean) : [];
13513 interval = Math.min.apply(Math, intervalByValue.concat([interval]));
13514 }
13515 return interval === Infinity ? 0 : interval;
13516 };
13517 _proto.ticks = function ticks() {
13518 for (var config = this.config, _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
13519 args[_key] = arguments[_key];
13520 }
13521 if (!args.length) {
13522 return config.tickArguments;
13523 }
13524 config.tickArguments = toArray(args);
13525 return this;
13526 };
13527 _proto.tickCulling = function tickCulling(culling) {
13528 var config = this.config;
13529 if (!arguments.length) {
13530 return config.tickCulling;
13531 }
13532 config.tickCulling = culling;
13533 return this;
13534 };
13535 _proto.tickValues = function tickValues(x) {
13536 var _this6 = this,
13537 config = this.config;
13538 if (isFunction(x)) {
13539 config.tickValues = function () {
13540 _newArrowCheck(this, _this6);
13541 return x(this.helper.scale.domain());
13542 }.bind(this);
13543 } else {
13544 if (!arguments.length) {
13545 return config.tickValues;
13546 }
13547 config.tickValues = x;
13548 }
13549 return this;
13550 };
13551 _proto.setTransition = function setTransition(t) {
13552 this.config.transition = t;
13553 return this;
13554 };
13555 return AxisRenderer;
13556}();
13557
13558;// CONCATENATED MODULE: ./src/ChartInternal/Axis/Axis.ts
13559
13560/**
13561 * Copyright (c) 2017 ~ present NAVER Corp.
13562 * billboard.js project is licensed under the MIT license
13563 */
13564
13565
13566
13567
13568
13569/* harmony default export */ var Axis = ({
13570 getAxisInstance: function getAxisInstance() {
13571 return this.axis || new Axis_Axis(this);
13572 }
13573});
13574var Axis_Axis = /*#__PURE__*/function () {
13575 function Axis(owner) {
13576 this.owner = void 0;
13577 this.x = void 0;
13578 this.subX = void 0;
13579 this.y = void 0;
13580 this.y2 = void 0;
13581 this.axesList = {};
13582 this.tick = {
13583 x: null,
13584 y: null,
13585 y2: null
13586 };
13587 this.xs = [];
13588 this.orient = {
13589 x: "bottom",
13590 y: "left",
13591 y2: "right",
13592 subX: "bottom"
13593 };
13594 this.owner = owner;
13595 this.setOrient();
13596 }
13597 var _proto = Axis.prototype;
13598 _proto.getAxisClassName = function getAxisClassName(id) {
13599 return $AXIS.axis + " " + $AXIS["axis" + capitalize(id)];
13600 };
13601 _proto.isHorizontal = function isHorizontal($$, forHorizontal) {
13602 var isRotated = $$.config.axis_rotated;
13603 return forHorizontal ? isRotated : !isRotated;
13604 };
13605 _proto.isCategorized = function isCategorized() {
13606 var _this$owner = this.owner,
13607 config = _this$owner.config,
13608 state = _this$owner.state;
13609 return config.axis_x_type.indexOf("category") >= 0 || state.hasRadar;
13610 };
13611 _proto.isCustomX = function isCustomX() {
13612 var config = this.owner.config;
13613 return !this.isTimeSeries() && (config.data_x || notEmpty(config.data_xs));
13614 };
13615 _proto.isTimeSeries = function isTimeSeries(id) {
13616 if (id === void 0) {
13617 id = "x";
13618 }
13619 return this.owner.config["axis_" + id + "_type"] === "timeseries";
13620 };
13621 _proto.isLog = function isLog(id) {
13622 if (id === void 0) {
13623 id = "x";
13624 }
13625 return this.owner.config["axis_" + id + "_type"] === "log";
13626 };
13627 _proto.isTimeSeriesY = function isTimeSeriesY() {
13628 return this.isTimeSeries("y");
13629 };
13630 _proto.getAxisType = function getAxisType(id) {
13631 if (id === void 0) {
13632 id = "x";
13633 }
13634 var type = "linear";
13635 if (this.isTimeSeries(id)) {
13636 type = this.owner.config.axis_x_localtime ? "time" : "utc";
13637 } else if (this.isLog(id)) {
13638 type = "log";
13639 }
13640 return type;
13641 };
13642 _proto.init = function init() {
13643 var _this = this,
13644 $$ = this.owner,
13645 config = $$.config,
13646 _$$$$el = $$.$el,
13647 main = _$$$$el.main,
13648 axis = _$$$$el.axis,
13649 clip = $$.state.clip,
13650 isRotated = config.axis_rotated,
13651 target = ["x", "y"];
13652 config.axis_y2_show && target.push("y2");
13653 target.forEach(function (v) {
13654 var _this2 = this;
13655 _newArrowCheck(this, _this);
13656 var classAxis = this.getAxisClassName(v),
13657 classLabel = $AXIS["axis" + v.toUpperCase() + "Label"];
13658 axis[v] = main.append("g").attr("class", classAxis).attr("clip-path", function () {
13659 _newArrowCheck(this, _this2);
13660 var res = null;
13661 if (v === "x") {
13662 res = clip.pathXAxis;
13663 } else if (v === "y") {
13664 // && config.axis_y_inner) {
13665 res = clip.pathYAxis;
13666 }
13667 return res;
13668 }.bind(this)).attr("transform", $$.getTranslate(v)).style("visibility", config["axis_" + v + "_show"] ? null : "hidden");
13669 axis[v].append("text").attr("class", classLabel).attr("transform", ["rotate(-90)", null][v === "x" ? +!isRotated : +isRotated]).style("text-anchor", function () {
13670 _newArrowCheck(this, _this2);
13671 return this.textAnchorForAxisLabel(v);
13672 }.bind(this));
13673 this.generateAxes(v);
13674 }.bind(this));
13675 }
13676
13677 /**
13678 * Set axis orient according option value
13679 * @private
13680 */;
13681 _proto.setOrient = function setOrient() {
13682 var $$ = this.owner,
13683 _$$$config = $$.config,
13684 isRotated = _$$$config.axis_rotated,
13685 yInner = _$$$config.axis_y_inner,
13686 y2Inner = _$$$config.axis_y2_inner;
13687 this.orient = {
13688 x: isRotated ? "left" : "bottom",
13689 y: isRotated ? yInner ? "top" : "bottom" : yInner ? "right" : "left",
13690 y2: isRotated ? y2Inner ? "bottom" : "top" : y2Inner ? "left" : "right",
13691 subX: isRotated ? "left" : "bottom"
13692 };
13693 }
13694
13695 /**
13696 * Generate axes
13697 * It's used when axis' axes option is set
13698 * @param {string} id Axis id
13699 * @private
13700 */;
13701 _proto.generateAxes = function generateAxes(id) {
13702 var _this3 = this,
13703 $$ = this.owner,
13704 config = $$.config,
13705 axes = [],
13706 axesConfig = config["axis_" + id + "_axes"],
13707 isRotated = config.axis_rotated,
13708 d3Axis;
13709 if (id === "x") {
13710 d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisLeft : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisBottom;
13711 } else if (id === "y") {
13712 d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisBottom : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisLeft;
13713 } else if (id === "y2") {
13714 d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisTop : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisRight;
13715 }
13716 if (axesConfig.length) {
13717 axesConfig.forEach(function (v) {
13718 var _this4 = this;
13719 _newArrowCheck(this, _this3);
13720 var tick = v.tick || {},
13721 scale = $$.scale[id].copy();
13722 v.domain && scale.domain(v.domain);
13723 axes.push(d3Axis(scale).ticks(tick.count).tickFormat(isFunction(tick.format) ? tick.format.bind($$.api) : function (x) {
13724 _newArrowCheck(this, _this4);
13725 return x;
13726 }.bind(this)).tickValues(tick.values).tickSizeOuter(tick.outer === !1 ? 0 : 6));
13727 }.bind(this));
13728 }
13729 this.axesList[id] = axes;
13730 }
13731
13732 /**
13733 * Update axes nodes
13734 * @private
13735 */;
13736 _proto.updateAxes = function updateAxes() {
13737 var _this5 = this,
13738 $$ = this.owner,
13739 config = $$.config,
13740 main = $$.$el.main,
13741 $T = $$.$T;
13742 Object.keys(this.axesList).forEach(function (id) {
13743 var _this6 = this;
13744 _newArrowCheck(this, _this5);
13745 var axesConfig = config["axis_" + id + "_axes"],
13746 scale = $$.scale[id].copy(),
13747 range = scale.range();
13748 this.axesList[id].forEach(function (v, i) {
13749 var _this7 = this;
13750 _newArrowCheck(this, _this6);
13751 var axisRange = v.scale().range();
13752
13753 // adjust range value with the current
13754 // https://github.com/naver/billboard.js/issues/859
13755 if (!range.every(function (v, i) {
13756 _newArrowCheck(this, _this7);
13757 return v === axisRange[i];
13758 }.bind(this))) {
13759 v.scale().range(range);
13760 }
13761 var className = this.getAxisClassName(id) + "-" + (i + 1),
13762 g = main.select("." + className.replace(/\s/, "."));
13763 if (g.empty()) {
13764 g = main.append("g").attr("class", className).style("visibility", config["axis_" + id + "_show"] ? null : "hidden").call(v);
13765 } else {
13766 axesConfig[i].domain && scale.domain(axesConfig[i].domain);
13767 $T(g).call(v.scale(scale));
13768 }
13769 g.attr("transform", $$.getTranslate(id, i + 1));
13770 }.bind(this));
13771 }.bind(this));
13772 }
13773
13774 /**
13775 * Set Axis & tick values
13776 * called from: updateScales()
13777 * @param {string} id Axis id string
13778 * @param {d3Scale} scale Scale
13779 * @param {boolean} outerTick If show outer tick
13780 * @param {boolean} noTransition If with no transition
13781 * @private
13782 */;
13783 _proto.setAxis = function setAxis(id, scale, outerTick, noTransition) {
13784 var $$ = this.owner;
13785 if (id !== "subX") {
13786 this.tick[id] = this.getTickValues(id);
13787 }
13788
13789 // @ts-ignore
13790 this[id] = this.getAxis(id, scale, outerTick,
13791 // do not transit x Axis on zoom and resizing
13792 // https://github.com/naver/billboard.js/issues/1949
13793 id === "x" && ($$.scale.zoom || $$.config.subchart_show || $$.state.resizing) ? !0 : noTransition);
13794 }
13795
13796 // called from : getMaxTickWidth()
13797 ;
13798 _proto.getAxis = function getAxis(id, scale, outerTick, noTransition, noTickTextRotate) {
13799 var _this8 = this,
13800 $$ = this.owner,
13801 config = $$.config,
13802 isX = /^(x|subX)$/.test(id),
13803 type = isX ? "x" : id,
13804 isCategory = isX && this.isCategorized(),
13805 orient = this.orient[id],
13806 tickTextRotate = noTickTextRotate ? 0 : $$.getAxisTickRotate(type),
13807 tickFormat;
13808 if (isX) {
13809 tickFormat = id === "subX" ? $$.format.subXAxisTick : $$.format.xAxisTick;
13810 } else {
13811 var fn = config["axis_" + id + "_tick_format"];
13812 if (isFunction(fn)) {
13813 tickFormat = fn.bind($$.api);
13814 }
13815 }
13816 var tickValues = this.tick[type],
13817 axisParams = mergeObj({
13818 outerTick: outerTick,
13819 noTransition: noTransition,
13820 config: config,
13821 id: id,
13822 tickTextRotate: tickTextRotate,
13823 owner: $$
13824 }, isX && {
13825 isCategory: isCategory,
13826 tickMultiline: config.axis_x_tick_multiline,
13827 tickWidth: config.axis_x_tick_width,
13828 tickTitle: isCategory && config.axis_x_tick_tooltip && $$.api.categories(),
13829 orgXScale: $$.scale.x
13830 });
13831 if (!isX) {
13832 axisParams.tickStepSize = config["axis_" + type + "_tick_stepSize"];
13833 }
13834 var axis = new AxisRenderer(axisParams).scale(isX && $$.scale.zoom || scale).orient(orient);
13835 if (isX && this.isTimeSeries() && tickValues && !isFunction(tickValues)) {
13836 var _fn = parseDate.bind($$);
13837 tickValues = tickValues.map(function (v) {
13838 _newArrowCheck(this, _this8);
13839 return _fn(v);
13840 }.bind(this));
13841 } else if (!isX && this.isTimeSeriesY()) {
13842 // https://github.com/d3/d3/blob/master/CHANGES.md#time-intervals-d3-time
13843 axis.ticks(config.axis_y_tick_time_value);
13844 tickValues = null;
13845 }
13846 tickValues && axis.tickValues(tickValues);
13847
13848 // Set tick
13849 axis.tickFormat(tickFormat || !isX && $$.isStackNormalized() && function (x) {
13850 _newArrowCheck(this, _this8);
13851 return x + "%";
13852 }.bind(this));
13853 if (isCategory) {
13854 axis.tickCentered(config.axis_x_tick_centered);
13855 if (isEmpty(config.axis_x_tick_culling)) {
13856 config.axis_x_tick_culling = !1;
13857 }
13858 }
13859 var tickCount = config["axis_" + type + "_tick_count"];
13860 tickCount && axis.ticks(tickCount);
13861 return axis;
13862 };
13863 _proto.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) {
13864 var $$ = this.owner,
13865 config = $$.config,
13866 fit = config.axis_x_tick_fit,
13867 count = config.axis_x_tick_count,
13868 values;
13869 if (fit || count && fit) {
13870 values = $$.mapTargetsToUniqueXs(targets);
13871
13872 // if given count is greater than the value length, then limit the count.
13873 if (this.isCategorized() && count > values.length) {
13874 count = values.length;
13875 }
13876 values = this.generateTickValues(values, count, this.isTimeSeries());
13877 }
13878 if (axis) {
13879 axis.tickValues(values);
13880 } else if (this.x) {
13881 var _this$subX;
13882 this.x.tickValues(values);
13883 (_this$subX = this.subX) == null ? void 0 : _this$subX.tickValues(values);
13884 }
13885 return values;
13886 };
13887 _proto.getId = function getId(id) {
13888 var _this$owner2 = this.owner,
13889 config = _this$owner2.config,
13890 scale = _this$owner2.scale,
13891 axis = config.data_axes[id];
13892 // when data.axes option has 'y2', but 'axis.y2.show=true' isn't set will return 'y'
13893 if (!axis || !scale[axis]) {
13894 axis = "y";
13895 }
13896 return axis;
13897 };
13898 _proto.getXAxisTickFormat = function getXAxisTickFormat(forSubchart) {
13899 var _this9 = this,
13900 $$ = this.owner,
13901 config = $$.config,
13902 format = $$.format,
13903 tickFormat = forSubchart ? config.subchart_axis_x_tick_format || config.axis_x_tick_format : config.axis_x_tick_format,
13904 isTimeSeries = this.isTimeSeries(),
13905 isCategorized = this.isCategorized(),
13906 currFormat;
13907 if (tickFormat) {
13908 if (isFunction(tickFormat)) {
13909 currFormat = tickFormat.bind($$.api);
13910 } else if (isTimeSeries) {
13911 currFormat = function (date) {
13912 _newArrowCheck(this, _this9);
13913 return date ? format.axisTime(tickFormat)(date) : "";
13914 }.bind(this);
13915 }
13916 } else {
13917 currFormat = isTimeSeries ? format.defaultAxisTime : isCategorized ? $$.categoryName : function (v) {
13918 _newArrowCheck(this, _this9);
13919 return v < 0 ? v.toFixed(0) : v;
13920 }.bind(this);
13921 }
13922 return isFunction(currFormat) ? function (v) {
13923 _newArrowCheck(this, _this9);
13924 return currFormat.apply($$, isCategorized ? [v, $$.categoryName(v)] : [v]);
13925 }.bind(this) : currFormat;
13926 };
13927 _proto.getTickValues = function getTickValues(id) {
13928 var $$ = this.owner,
13929 tickValues = $$.config["axis_" + id + "_tick_values"],
13930 axis = $$[id + "Axis"];
13931 return (isFunction(tickValues) ? tickValues.call($$.api) : tickValues) || (axis ? axis.tickValues() : undefined);
13932 };
13933 _proto.getLabelOptionByAxisId = function getLabelOptionByAxisId(id) {
13934 return this.owner.config["axis_" + id + "_label"];
13935 };
13936 _proto.getLabelText = function getLabelText(id) {
13937 var option = this.getLabelOptionByAxisId(id);
13938 return isString(option) ? option : option ? option.text : null;
13939 };
13940 _proto.setLabelText = function setLabelText(id, text) {
13941 var $$ = this.owner,
13942 config = $$.config,
13943 option = this.getLabelOptionByAxisId(id);
13944 if (isString(option)) {
13945 config["axis_" + id + "_label"] = text;
13946 } else if (option) {
13947 option.text = text;
13948 }
13949 };
13950 _proto.getLabelPosition = function getLabelPosition(id, defaultPosition) {
13951 var _this10 = this,
13952 isRotated = this.owner.config.axis_rotated,
13953 option = this.getLabelOptionByAxisId(id),
13954 position = isObjectType(option) && option.position ? option.position : defaultPosition[+!isRotated],
13955 has = function (v) {
13956 _newArrowCheck(this, _this10);
13957 return !!~position.indexOf(v);
13958 }.bind(this);
13959 return {
13960 isInner: has("inner"),
13961 isOuter: has("outer"),
13962 isLeft: has("left"),
13963 isCenter: has("center"),
13964 isRight: has("right"),
13965 isTop: has("top"),
13966 isMiddle: has("middle"),
13967 isBottom: has("bottom")
13968 };
13969 };
13970 _proto.getAxisLabelPosition = function getAxisLabelPosition(id) {
13971 return this.getLabelPosition(id, id === "x" ? ["inner-top", "inner-right"] : ["inner-right", "inner-top"]);
13972 };
13973 _proto.getLabelPositionById = function getLabelPositionById(id) {
13974 return this.getAxisLabelPosition(id);
13975 };
13976 _proto.xForAxisLabel = function xForAxisLabel(id) {
13977 var $$ = this.owner,
13978 _$$$state = $$.state,
13979 width = _$$$state.width,
13980 height = _$$$state.height,
13981 position = this.getAxisLabelPosition(id),
13982 x = position.isMiddle ? -height / 2 : 0;
13983 if (this.isHorizontal($$, id !== "x")) {
13984 x = position.isLeft ? 0 : position.isCenter ? width / 2 : width;
13985 } else if (position.isBottom) {
13986 x = -height;
13987 }
13988 return x;
13989 };
13990 _proto.dxForAxisLabel = function dxForAxisLabel(id) {
13991 var $$ = this.owner,
13992 position = this.getAxisLabelPosition(id),
13993 dx = position.isBottom ? "0.5em" : "0";
13994 if (this.isHorizontal($$, id !== "x")) {
13995 dx = position.isLeft ? "0.5em" : position.isRight ? "-0.5em" : "0";
13996 } else if (position.isTop) {
13997 dx = "-0.5em";
13998 }
13999 return dx;
14000 };
14001 _proto.textAnchorForAxisLabel = function textAnchorForAxisLabel(id) {
14002 var $$ = this.owner,
14003 position = this.getAxisLabelPosition(id),
14004 anchor = position.isMiddle ? "middle" : "end";
14005 if (this.isHorizontal($$, id !== "x")) {
14006 anchor = position.isLeft ? "start" : position.isCenter ? "middle" : "end";
14007 } else if (position.isBottom) {
14008 anchor = "start";
14009 }
14010 return anchor;
14011 };
14012 _proto.dyForAxisLabel = function dyForAxisLabel(id) {
14013 var $$ = this.owner,
14014 config = $$.config,
14015 isRotated = config.axis_rotated,
14016 isInner = this.getAxisLabelPosition(id).isInner,
14017 tickRotate = config["axis_" + id + "_tick_rotate"] ? $$.getHorizontalAxisHeight(id) : 0,
14018 maxTickWidth = this.getMaxTickWidth(id),
14019 dy;
14020 if (id === "x") {
14021 var xHeight = config.axis_x_height;
14022 if (isRotated) {
14023 dy = isInner ? "1.2em" : -25 - maxTickWidth;
14024 } else if (isInner) {
14025 dy = "-0.5em";
14026 } else if (xHeight) {
14027 dy = xHeight - 10;
14028 } else if (tickRotate) {
14029 dy = tickRotate - 10;
14030 } else {
14031 dy = "3em";
14032 }
14033 } else {
14034 dy = {
14035 y: ["-0.5em", 10, "3em", "1.2em", 10],
14036 y2: ["1.2em", -20, "-2.2em", "-0.5em", 15]
14037 }[id];
14038 if (isRotated) {
14039 if (isInner) {
14040 dy = dy[0];
14041 } else if (tickRotate) {
14042 dy = tickRotate * (id === "y2" ? -1 : 1) - dy[1];
14043 } else {
14044 dy = dy[2];
14045 }
14046 } else {
14047 dy = isInner ? dy[3] : (dy[4] + (config["axis_" + id + "_inner"] ? 0 : maxTickWidth + dy[4])) * (id === "y" ? -1 : 1);
14048 }
14049 }
14050 return dy;
14051 };
14052 _proto.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) {
14053 var _this11 = this,
14054 $$ = this.owner,
14055 config = $$.config,
14056 current = $$.state.current,
14057 _$$$$el2 = $$.$el,
14058 svg = _$$$$el2.svg,
14059 chart = _$$$$el2.chart,
14060 currentTickMax = current.maxTickWidths[id],
14061 maxWidth = 0;
14062 if (withoutRecompute || !config["axis_" + id + "_show"] || $$.filterTargetsToShow().length === 0) {
14063 return currentTickMax.size;
14064 }
14065 if (svg) {
14066 var isYAxis = /^y2?$/.test(id),
14067 targetsToShow = $$.filterTargetsToShow($$.data.targets),
14068 _scale = $$.scale[id].copy().domain($$["get" + (isYAxis ? "Y" : "X") + "Domain"](targetsToShow, id)),
14069 domain = _scale.domain(),
14070 isDomainSame = domain[0] === domain[1] && domain.every(function (v) {
14071 _newArrowCheck(this, _this11);
14072 return v > 0;
14073 }.bind(this)),
14074 isCurrentMaxTickDomainSame = isArray(currentTickMax.domain) && currentTickMax.domain[0] === currentTickMax.domain[1] && currentTickMax.domain.every(function (v) {
14075 _newArrowCheck(this, _this11);
14076 return v > 0;
14077 }.bind(this));
14078 // do not compute if domain or currentMaxTickDomain is same
14079 if (isDomainSame || isCurrentMaxTickDomainSame) {
14080 return currentTickMax.size;
14081 } else {
14082 currentTickMax.domain = domain;
14083 }
14084
14085 // reset old max state value to prevent from new data loading
14086 if (!isYAxis) {
14087 currentTickMax.ticks.splice(0);
14088 }
14089 var axis = this.getAxis(id, _scale, !1, !1, !0),
14090 tickCount = config["axis_" + id + "_tick_count"],
14091 tickValues = config["axis_" + id + "_tick_values"];
14092 // Make to generate the final tick text to be rendered
14093 // https://github.com/naver/billboard.js/issues/920
14094 // Do not generate if 'tick values' option is given
14095 // https://github.com/naver/billboard.js/issues/1251
14096 if (!tickValues && tickCount) {
14097 axis.tickValues(this.generateTickValues(domain, tickCount, isYAxis ? this.isTimeSeriesY() : this.isTimeSeries()));
14098 }
14099 isYAxis || this.updateXAxisTickValues(targetsToShow, axis);
14100 var dummy = chart.append("svg").style("visibility", "hidden").style("position", "fixed").style("top", "0").style("left", "0");
14101 axis.create(dummy);
14102 dummy.selectAll("text").each(function (d, i) {
14103 var currentTextWidth = this.getBoundingClientRect().width;
14104 maxWidth = Math.max(maxWidth, currentTextWidth);
14105 // cache tick text width for getXAxisTickTextY2Overflow()
14106 if (!isYAxis) {
14107 currentTickMax.ticks[i] = currentTextWidth;
14108 }
14109 });
14110 dummy.remove();
14111 }
14112 if (maxWidth > 0) {
14113 currentTickMax.size = maxWidth;
14114 }
14115 return currentTickMax.size;
14116 };
14117 _proto.getXAxisTickTextY2Overflow = function getXAxisTickTextY2Overflow(defaultPadding) {
14118 var $$ = this.owner,
14119 axis = $$.axis,
14120 config = $$.config,
14121 state = $$.state,
14122 xAxisTickRotate = $$.getAxisTickRotate("x");
14123 if ((axis.isCategorized() || axis.isTimeSeries()) && config.axis_x_tick_fit && !config.axis_x_tick_culling && !config.axis_x_tick_multiline && xAxisTickRotate > 0 && xAxisTickRotate < 90) {
14124 var widthWithoutCurrentPaddingLeft = state.current.width - $$.getCurrentPaddingLeft(),
14125 maxOverflow = this.getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft - defaultPadding),
14126 xAxisTickTextY2Overflow = Math.max(0, maxOverflow) + defaultPadding;
14127 // for display inconsistencies between browsers
14128
14129 return Math.min(xAxisTickTextY2Overflow, widthWithoutCurrentPaddingLeft / 2);
14130 }
14131 return 0;
14132 };
14133 _proto.getXAxisTickMaxOverflow = function getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft) {
14134 var $$ = this.owner,
14135 axis = $$.axis,
14136 config = $$.config,
14137 state = $$.state,
14138 isTimeSeries = axis.isTimeSeries(),
14139 tickTextWidths = state.current.maxTickWidths.x.ticks,
14140 tickCount = tickTextWidths.length,
14141 _state$axis$x$padding = state.axis.x.padding,
14142 left = _state$axis$x$padding.left,
14143 right = _state$axis$x$padding.right,
14144 maxOverflow = 0,
14145 remaining = tickCount - (isTimeSeries && config.axis_x_tick_fit ? .5 : 0);
14146 for (var i = 0; i < tickCount; i++) {
14147 var tickIndex = i + 1,
14148 rotatedTickTextWidth = Math.cos(Math.PI * xAxisTickRotate / 180) * tickTextWidths[i],
14149 ticksBeforeTickText = tickIndex - (isTimeSeries ? 1 : .5) + left;
14150 // Skip ticks if there are no ticks before them
14151 if (ticksBeforeTickText <= 0) {
14152 continue;
14153 }
14154 var xAxisLengthWithoutTickTextWidth = widthWithoutCurrentPaddingLeft - rotatedTickTextWidth,
14155 tickLength = xAxisLengthWithoutTickTextWidth / ticksBeforeTickText,
14156 remainingTicks = remaining - tickIndex,
14157 paddingRightLength = right * tickLength,
14158 remainingTickWidth = remainingTicks * tickLength + paddingRightLength,
14159 overflow = rotatedTickTextWidth - tickLength / 2 - remainingTickWidth;
14160 maxOverflow = Math.max(maxOverflow, overflow);
14161 }
14162 var filteredTargets = $$.filterTargetsToShow($$.data.targets),
14163 tickOffset = 0;
14164 if (!isTimeSeries && config.axis_x_tick_count <= filteredTargets.length && filteredTargets[0].values.length) {
14165 var _scale2 = getScale($$.axis.getAxisType("x"), 0, widthWithoutCurrentPaddingLeft - maxOverflow).domain([left * -1, $$.getXDomainMax($$.data.targets) + 1 + right]);
14166 tickOffset = Math.ceil((_scale2(1) - _scale2(0)) / 2);
14167 }
14168 return maxOverflow + tickOffset;
14169 };
14170 _proto.updateLabels = function updateLabels(withTransition) {
14171 var _this12 = this,
14172 $$ = this.owner,
14173 main = $$.$el.main,
14174 $T = $$.$T,
14175 labels = {
14176 x: main.select("." + $AXIS.axisX + " ." + $AXIS.axisXLabel),
14177 y: main.select("." + $AXIS.axisY + " ." + $AXIS.axisYLabel),
14178 y2: main.select("." + $AXIS.axisY2 + " ." + $AXIS.axisY2Label)
14179 };
14180 Object.keys(labels).filter(function (id) {
14181 _newArrowCheck(this, _this12);
14182 return !labels[id].empty();
14183 }.bind(this)).forEach(function (v) {
14184 var _this13 = this;
14185 _newArrowCheck(this, _this12);
14186 var node = labels[v];
14187
14188 // @check $$.$T(node, withTransition)
14189 $T(node, withTransition).attr("x", function () {
14190 _newArrowCheck(this, _this13);
14191 return this.xForAxisLabel(v);
14192 }.bind(this)).attr("dx", function () {
14193 _newArrowCheck(this, _this13);
14194 return this.dxForAxisLabel(v);
14195 }.bind(this)).attr("dy", function () {
14196 _newArrowCheck(this, _this13);
14197 return this.dyForAxisLabel(v);
14198 }.bind(this)).text(function () {
14199 _newArrowCheck(this, _this13);
14200 return this.getLabelText(v);
14201 }.bind(this));
14202 }.bind(this));
14203 }
14204
14205 /**
14206 * Get axis padding value
14207 * @param {number|object} padding Padding object
14208 * @param {string} key Key string of padding
14209 * @param {Date|number} defaultValue Default value
14210 * @param {number} domainLength Domain length
14211 * @returns {number} Padding value in scale
14212 * @private
14213 */;
14214 _proto.getPadding = function getPadding(padding, key, defaultValue, domainLength) {
14215 var p = isNumber(padding) ? padding : padding[key];
14216 if (!isValue(p)) {
14217 return defaultValue;
14218 }
14219 return this.owner.convertPixelToScale(/(bottom|top)/.test(key) ? "y" : "x", p, domainLength);
14220 };
14221 _proto.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) {
14222 var _this14 = this,
14223 tickValues = values;
14224 if (tickCount) {
14225 var targetCount = isFunction(tickCount) ? tickCount() : tickCount;
14226
14227 // compute ticks according to tickCount
14228 if (targetCount === 1) {
14229 tickValues = [values[0]];
14230 } else if (targetCount === 2) {
14231 tickValues = [values[0], values[values.length - 1]];
14232 } else if (targetCount > 2) {
14233 var isCategorized = this.isCategorized(),
14234 count = targetCount - 2,
14235 start = values[0],
14236 end = values[values.length - 1],
14237 tickValue;
14238 // re-construct unique values
14239 tickValues = [start];
14240 for (var i = 0; i < count; i++) {
14241 tickValue = +start + (end - start) / (count + 1) * (i + 1);
14242 tickValues.push(forTimeSeries ? new Date(tickValue) : isCategorized ? Math.round(tickValue) : tickValue);
14243 }
14244 tickValues.push(end);
14245 }
14246 }
14247 if (!forTimeSeries) {
14248 tickValues = tickValues.sort(function (a, b) {
14249 _newArrowCheck(this, _this14);
14250 return a - b;
14251 }.bind(this));
14252 }
14253 return tickValues;
14254 };
14255 _proto.generateTransitions = function generateTransitions(withTransition) {
14256 var _this15 = this,
14257 $$ = this.owner,
14258 axis = $$.$el.axis,
14259 $T = $$.$T,
14260 _map = ["x", "y", "y2", "subX"].map(function (v) {
14261 _newArrowCheck(this, _this15);
14262 return $T(axis[v], withTransition);
14263 }.bind(this)),
14264 axisX = _map[0],
14265 axisY = _map[1],
14266 axisY2 = _map[2],
14267 axisSubX = _map[3];
14268 return {
14269 axisX: axisX,
14270 axisY: axisY,
14271 axisY2: axisY2,
14272 axisSubX: axisSubX
14273 };
14274 };
14275 _proto.redraw = function redraw(transitions, isHidden, isInit) {
14276 var _this16 = this,
14277 $$ = this.owner,
14278 config = $$.config,
14279 $el = $$.$el,
14280 opacity = isHidden ? "0" : null;
14281 ["x", "y", "y2", "subX"].forEach(function (id) {
14282 _newArrowCheck(this, _this16);
14283 var axis = this[id],
14284 $axis = $el.axis[id];
14285 if (axis && $axis) {
14286 if (!isInit && !config.transition_duration) {
14287 axis.config.withoutTransition = !0;
14288 }
14289 $axis.style("opacity", opacity);
14290 axis.create(transitions["axis" + capitalize(id)]);
14291 }
14292 }.bind(this));
14293 this.updateAxes();
14294 }
14295
14296 /**
14297 * Redraw axis
14298 * @param {Array} targetsToShow targets data to be shown
14299 * @param {object} wth option object
14300 * @param {d3.Transition} transitions Transition object
14301 * @param {object} flow flow object
14302 * @param {boolean} isInit called from initialization
14303 * @private
14304 */;
14305 _proto.redrawAxis = function redrawAxis(targetsToShow, wth, transitions, flow, isInit) {
14306 var _this17 = this,
14307 $$ = this.owner,
14308 config = $$.config,
14309 scale = $$.scale,
14310 $el = $$.$el,
14311 hasZoom = !!scale.zoom,
14312 xDomainForZoom;
14313 if (!hasZoom && this.isCategorized() && targetsToShow.length === 0) {
14314 scale.x.domain([0, $el.axis.x.selectAll(".tick").size()]);
14315 }
14316 if (scale.x && targetsToShow.length) {
14317 hasZoom || $$.updateXDomain(targetsToShow, wth.UpdateXDomain, wth.UpdateOrgXDomain, wth.TrimXDomain);
14318 if (!config.axis_x_tick_values) {
14319 this.updateXAxisTickValues(targetsToShow);
14320 }
14321 } else if (this.x) {
14322 var _this$subX2;
14323 this.x.tickValues([]);
14324 (_this$subX2 = this.subX) == null ? void 0 : _this$subX2.tickValues([]);
14325 }
14326 if (config.zoom_rescale && !flow) {
14327 xDomainForZoom = scale.x.orgDomain();
14328 }
14329 ["y", "y2"].forEach(function (key) {
14330 var _this18 = this;
14331 _newArrowCheck(this, _this17);
14332 var prefix = "axis_" + key + "_",
14333 axisScale = scale[key];
14334 if (axisScale) {
14335 var tickValues = config[prefix + "tick_values"],
14336 tickCount = config[prefix + "tick_count"];
14337 axisScale.domain($$.getYDomain(targetsToShow, key, xDomainForZoom));
14338 if (!tickValues && tickCount) {
14339 var axis = $$.axis[key],
14340 domain = axisScale.domain();
14341 axis.tickValues(this.generateTickValues(domain, domain.every(function (v) {
14342 _newArrowCheck(this, _this18);
14343 return v === 0;
14344 }.bind(this)) ? 1 : tickCount, this.isTimeSeriesY()));
14345 }
14346 }
14347 }.bind(this));
14348
14349 // axes
14350 this.redraw(transitions, $$.hasArcType(), isInit);
14351
14352 // Update axis label
14353 this.updateLabels(wth.Transition);
14354
14355 // show/hide if manual culling needed
14356 if ((wth.UpdateXDomain || wth.UpdateXAxis || wth.Y) && targetsToShow.length) {
14357 this.setCulling();
14358 }
14359
14360 // Update sub domain
14361 if (wth.Y) {
14362 var _scale$subY, _scale$subY2;
14363 (_scale$subY = scale.subY) == null ? void 0 : _scale$subY.domain($$.getYDomain(targetsToShow, "y"));
14364 (_scale$subY2 = scale.subY2) == null ? void 0 : _scale$subY2.domain($$.getYDomain(targetsToShow, "y2"));
14365 }
14366 }
14367
14368 /**
14369 * Set manual culling
14370 * @private
14371 */;
14372 _proto.setCulling = function setCulling() {
14373 var _this19 = this,
14374 $$ = this.owner,
14375 config = $$.config,
14376 _$$$state2 = $$.state,
14377 clip = _$$$state2.clip,
14378 current = _$$$state2.current,
14379 $el = $$.$el;
14380 ["subX", "x", "y", "y2"].forEach(function (type) {
14381 _newArrowCheck(this, _this19);
14382 var axis = $el.axis[type],
14383 id = type === "subX" ? "x" : type,
14384 cullingOptionPrefix = "axis_" + id + "_tick_culling",
14385 toCull = config[cullingOptionPrefix]; // subchart x axis should be aligned with x axis culling
14386 if (axis && toCull) {
14387 var tickNodes = axis.selectAll(".tick"),
14388 tickValues = sortValue(tickNodes.data()),
14389 tickSize = tickValues.length,
14390 cullingMax = config[cullingOptionPrefix + "_max"],
14391 lines = config[cullingOptionPrefix + "_lines"],
14392 intervalForCulling;
14393 if (tickSize) {
14394 for (var i = 1; i < tickSize; i++) {
14395 if (tickSize / i < cullingMax) {
14396 intervalForCulling = i;
14397 break;
14398 }
14399 }
14400 tickNodes.each(function (d) {
14401 var node = lines ? this.querySelector("text") : this;
14402 if (node) {
14403 node.style.display = tickValues.indexOf(d) % intervalForCulling ? "none" : null;
14404 }
14405 });
14406 } else {
14407 tickNodes.style("display", null);
14408 }
14409
14410 // set/unset x_axis_tick_clippath
14411 if (type === "x") {
14412 var clipPath = current.maxTickWidths.x.clipPath ? clip.pathXAxisTickTexts : null;
14413 $el.svg.selectAll("." + $AXIS.axisX + " .tick text").attr("clip-path", clipPath);
14414 }
14415 }
14416 }.bind(this));
14417 };
14418 return Axis;
14419}();
14420;// CONCATENATED MODULE: ./src/ChartInternal/interactions/eventrect.ts
14421
14422/**
14423 * Copyright (c) 2017 ~ present NAVER Corp.
14424 * billboard.js project is licensed under the MIT license
14425 */
14426
14427
14428/* harmony default export */ var eventrect = ({
14429 /**
14430 * Initialize the area that detects the event.
14431 * Add a container for the zone that detects the event.
14432 * @private
14433 */
14434 initEventRect: function initEventRect() {
14435 var $$ = this;
14436 $$.$el.main.select("." + $COMMON.chart).append("g").attr("class", $EVENT.eventRects).style("fill-opacity", "0");
14437 },
14438 /**
14439 * Redraws the area that detects the event.
14440 * @private
14441 */
14442 redrawEventRect: function redrawEventRect() {
14443 var $$ = this,
14444 config = $$.config,
14445 state = $$.state,
14446 $el = $$.$el,
14447 isMultipleX = $$.isMultipleX();
14448 if ($el.eventRect) {
14449 $$.updateEventRect($el.eventRect, !0);
14450 } else {
14451 var eventRects = $$.$el.main.select("." + $EVENT.eventRects).style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ? config.axis_rotated ? "ns-resize" : "ew-resize" : null).classed($EVENT.eventRectsMultiple, isMultipleX).classed($EVENT.eventRectsSingle, !isMultipleX),
14452 eventRectUpdate = eventRects.selectAll("." + $EVENT.eventRect).data([0]).enter().append("rect"); // append event <rect>
14453 $$.updateEventRect(eventRectUpdate);
14454
14455 // bind event to <rect> element
14456 isMultipleX ? $$.generateEventRectsForMultipleXs(eventRectUpdate) : $$.generateEventRectsForSingleX(eventRectUpdate);
14457
14458 // bind draggable selection
14459 eventRectUpdate.call($$.getDraggableSelection());
14460 $el.eventRect = eventRectUpdate;
14461 if ($$.state.inputType === "touch" && !$el.svg.on("touchstart.eventRect") && !$$.hasArcType()) {
14462 $$.bindTouchOnEventRect(isMultipleX);
14463 }
14464 }
14465 if (!isMultipleX) {
14466 // Set data and update eventReceiver.data
14467 var xAxisTickValues = $$.getMaxDataCountTarget();
14468
14469 // update data's index value to be alinged with the x Axis
14470 $$.updateDataIndexByX(xAxisTickValues);
14471 $$.updateXs(xAxisTickValues);
14472 $$.updatePointClass == null ? void 0 : $$.updatePointClass(!0);
14473 state.eventReceiver.data = xAxisTickValues;
14474 }
14475 $$.updateEventRectData();
14476 },
14477 bindTouchOnEventRect: function bindTouchOnEventRect(isMultipleX) {
14478 var _this = this,
14479 $$ = this,
14480 config = $$.config,
14481 state = $$.state,
14482 _$$$$el = $$.$el,
14483 eventRect = _$$$$el.eventRect,
14484 svg = _$$$$el.svg,
14485 selectRect = function (context) {
14486 _newArrowCheck(this, _this);
14487 if (isMultipleX) {
14488 $$.selectRectForMultipleXs(context);
14489 } else {
14490 var index = $$.getDataIndexFromEvent(state.event);
14491 $$.callOverOutForTouch(index);
14492 index === -1 ? $$.unselectRect() : $$.selectRectForSingle(context, eventRect, index);
14493 }
14494 }.bind(this),
14495 unselectRect = function () {
14496 _newArrowCheck(this, _this);
14497 $$.unselectRect();
14498 $$.callOverOutForTouch();
14499 }.bind(this),
14500 preventDefault = config.interaction_inputType_touch.preventDefault,
14501 isPrevented = isboolean(preventDefault) && preventDefault || !1,
14502 preventThreshold = !isNaN(preventDefault) && preventDefault || null,
14503 startPx,
14504 preventEvent = function (event) {
14505 _newArrowCheck(this, _this);
14506 var eventType = event.type,
14507 touch = event.changedTouches[0],
14508 currentXY = touch["client" + (config.axis_rotated ? "Y" : "X")];
14509 // prevent document scrolling
14510 if (eventType === "touchstart") {
14511 if (isPrevented) {
14512 event.preventDefault();
14513 } else if (preventThreshold !== null) {
14514 startPx = currentXY;
14515 }
14516 } else if (eventType === "touchmove") {
14517 if (isPrevented || startPx === !0 || preventThreshold !== null && Math.abs(startPx - currentXY) >= preventThreshold) {
14518 // once prevented, keep prevented during whole 'touchmove' context
14519 startPx = !0;
14520 event.preventDefault();
14521 }
14522 }
14523 }.bind(this);
14524 // bind touch events
14525 eventRect.on("touchstart", function (event) {
14526 _newArrowCheck(this, _this);
14527 state.event = event;
14528 $$.updateEventRect();
14529 }.bind(this)).on("touchstart.eventRect touchmove.eventRect", function (event) {
14530 _newArrowCheck(this, _this);
14531 state.event = event;
14532 if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
14533 // if touch points are > 1, means doing zooming interaction. In this case do not execute tooltip codes.
14534 if (state.dragging || state.flowing || $$.hasArcType() || event.touches.length > 1) {
14535 return;
14536 }
14537 preventEvent(event);
14538 selectRect(eventRect.node());
14539 } else {
14540 unselectRect();
14541 }
14542 }.bind(this), !0).on("touchend.eventRect", function (event) {
14543 _newArrowCheck(this, _this);
14544 state.event = event;
14545 if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
14546 if ($$.hasArcType() || !$$.toggleShape || state.cancelClick) {
14547 state.cancelClick && (state.cancelClick = !1);
14548 }
14549 }
14550 }.bind(this), !0);
14551 svg.on("touchstart", function (event) {
14552 _newArrowCheck(this, _this);
14553 state.event = event;
14554 var target = event.target;
14555 if (target && target !== eventRect.node()) {
14556 unselectRect();
14557 }
14558 }.bind(this));
14559 },
14560 /**
14561 * Update event rect size
14562 * @param {d3Selection} eventRect Event <rect> element
14563 * @param {boolean} force Force to update
14564 * @private
14565 */
14566 updateEventRect: function updateEventRect(eventRect, force) {
14567 var _this2 = this;
14568 if (force === void 0) {
14569 force = !1;
14570 }
14571 var $$ = this,
14572 state = $$.state,
14573 $el = $$.$el,
14574 _state = state,
14575 eventReceiver = _state.eventReceiver,
14576 width = _state.width,
14577 height = _state.height,
14578 rendered = _state.rendered,
14579 resizing = _state.resizing,
14580 rectElement = eventRect || $el.eventRect,
14581 updateClientRect = function () {
14582 _newArrowCheck(this, _this2);
14583 eventReceiver && (eventReceiver.rect = rectElement.node().getBoundingClientRect());
14584 }.bind(this);
14585 if (!rendered || resizing || force) {
14586 rectElement.attr("x", 0).attr("y", 0).attr("width", width).attr("height", height);
14587
14588 // only for init
14589 if (!rendered) {
14590 rectElement.attr("class", $EVENT.eventRect);
14591 }
14592 }
14593 updateClientRect();
14594 },
14595 /**
14596 * Updates the location and size of the eventRect.
14597 * @private
14598 */
14599 updateEventRectData: function updateEventRectData() {
14600 var _this3 = this,
14601 $$ = this,
14602 config = $$.config,
14603 scale = $$.scale,
14604 state = $$.state,
14605 xScale = scale.zoom || scale.x,
14606 isRotated = config.axis_rotated,
14607 x,
14608 y,
14609 w,
14610 h;
14611 if ($$.isMultipleX()) {
14612 // TODO: rotated not supported yet
14613 x = 0;
14614 y = 0;
14615 w = state.width;
14616 h = state.height;
14617 } else {
14618 var rectW, rectX;
14619 if ($$.axis.isCategorized()) {
14620 rectW = $$.getEventRectWidth();
14621 rectX = function (d) {
14622 _newArrowCheck(this, _this3);
14623 return xScale(d.x) - rectW / 2;
14624 }.bind(this);
14625 } else {
14626 var getPrevNextX = function (_ref) {
14627 var index = _ref.index;
14628 _newArrowCheck(this, _this3);
14629 return {
14630 prev: $$.getPrevX(index),
14631 next: $$.getNextX(index)
14632 };
14633 }.bind(this);
14634 rectW = function (d) {
14635 var _this4 = this;
14636 _newArrowCheck(this, _this3);
14637 var x = getPrevNextX(d),
14638 xDomain = xScale.domain(),
14639 val;
14640 // if there this is a single data point make the eventRect full width (or height)
14641 if (x.prev === null && x.next === null) {
14642 val = isRotated ? state.height : state.width;
14643 } else if (x.prev === null) {
14644 val = (xScale(x.next) + xScale(d.x)) / 2;
14645 } else if (x.next === null) {
14646 val = xScale(xDomain[1]) - (xScale(x.prev) + xScale(d.x)) / 2;
14647 } else {
14648 Object.keys(x).forEach(function (key, i) {
14649 var _x$key;
14650 _newArrowCheck(this, _this4);
14651 x[key] = (_x$key = x[key]) != null ? _x$key : xDomain[i];
14652 }.bind(this));
14653 val = Math.max(0, (xScale(x.next) - xScale(x.prev)) / 2);
14654 }
14655 return val;
14656 }.bind(this);
14657 rectX = function (d) {
14658 _newArrowCheck(this, _this3);
14659 var x = getPrevNextX(d),
14660 val;
14661 // if there this is a single data point position the eventRect at 0
14662 if (x.prev === null && x.next === null) {
14663 val = 0;
14664 } else if (x.prev === null) {
14665 val = xScale(xScale.domain()[0]);
14666 } else {
14667 val = (xScale(d.x) + xScale(x.prev)) / 2;
14668 }
14669 return val;
14670 }.bind(this);
14671 }
14672 x = isRotated ? 0 : rectX;
14673 y = isRotated ? rectX : 0;
14674 w = isRotated ? state.width : rectW;
14675 h = isRotated ? rectW : state.height;
14676 }
14677 var eventReceiver = state.eventReceiver,
14678 call = function (fn, v) {
14679 _newArrowCheck(this, _this3);
14680 return isFunction(fn) ? fn(v) : fn;
14681 }.bind(this);
14682 // reset for possible remains coords data before the data loading
14683 eventReceiver.coords.splice(eventReceiver.data.length);
14684 eventReceiver.data.forEach(function (d, i) {
14685 _newArrowCheck(this, _this3);
14686 eventReceiver.coords[i] = {
14687 x: call(x, d),
14688 y: call(y, d),
14689 w: call(w, d),
14690 h: call(h, d)
14691 };
14692 }.bind(this));
14693 },
14694 selectRectForMultipleXs: function selectRectForMultipleXs(context) {
14695 var _this5 = this,
14696 $$ = this,
14697 config = $$.config,
14698 state = $$.state,
14699 targetsToShow = $$.filterTargetsToShow($$.data.targets);
14700 // do nothing when dragging
14701 if (state.dragging || $$.hasArcType(targetsToShow)) {
14702 return;
14703 }
14704 var mouse = getPointer(state.event, context),
14705 closest = $$.findClosestFromTargets(targetsToShow, mouse);
14706 if (state.mouseover && (!closest || closest.id !== state.mouseover.id)) {
14707 config.data_onout.call($$.api, state.mouseover);
14708 state.mouseover = undefined;
14709 }
14710 if (!closest) {
14711 $$.unselectRect();
14712 return;
14713 }
14714 var sameXData = $$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped ? [closest] : $$.filterByX(targetsToShow, closest.x),
14715 selectedData = sameXData.map(function (d) {
14716 _newArrowCheck(this, _this5);
14717 return $$.addName(d);
14718 }.bind(this)); // show tooltip when cursor is close to some point
14719 $$.showTooltip(selectedData, context);
14720
14721 // expand points
14722 $$.setExpand(closest.index, closest.id, !0);
14723
14724 // Show xgrid focus line
14725 $$.showGridFocus(selectedData);
14726
14727 // Show cursor as pointer if point is close to mouse position
14728 if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
14729 $$.$el.svg.select("." + $EVENT.eventRect).style("cursor", "pointer");
14730 if (!state.mouseover) {
14731 config.data_onover.call($$.api, closest);
14732 state.mouseover = closest;
14733 }
14734 }
14735 },
14736 /**
14737 * Unselect EventRect.
14738 * @private
14739 */
14740 unselectRect: function unselectRect() {
14741 var $$ = this,
14742 config = $$.config,
14743 _$$$$el2 = $$.$el,
14744 circle = _$$$$el2.circle,
14745 tooltip = _$$$$el2.tooltip;
14746 $$.$el.svg.select("." + $EVENT.eventRect).style("cursor", null);
14747 $$.hideGridFocus();
14748 if (tooltip) {
14749 $$.hideTooltip();
14750 $$._handleLinkedCharts(!1);
14751 }
14752 circle && !config.point_focus_only && $$.unexpandCircles();
14753 $$.expandBarTypeShapes(!1);
14754 },
14755 /**
14756 * Create eventRect for each data on the x-axis.
14757 * Register touch and drag events.
14758 * @param {object} eventRectEnter d3.select($EVENT.eventRects) object.
14759 * @returns {object} d3.select($EVENT.eventRects) object.
14760 * @private
14761 */
14762 generateEventRectsForSingleX: function generateEventRectsForSingleX(eventRectEnter) {
14763 var _this6 = this,
14764 $$ = this,
14765 config = $$.config,
14766 state = $$.state,
14767 eventReceiver = state.eventReceiver,
14768 rect = eventRectEnter.style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null).on("click", function (event) {
14769 state.event = event;
14770 var currentIdx = eventReceiver.currentIdx,
14771 data = eventReceiver.data,
14772 d = data[currentIdx === -1 ? $$.getDataIndexFromEvent(event) : currentIdx];
14773 $$.clickHandlerForSingleX.bind(this)(d, $$);
14774 });
14775 if (state.inputType === "mouse") {
14776 var getData = function (event) {
14777 _newArrowCheck(this, _this6);
14778 var index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
14779 return index > -1 ? eventReceiver.data[index] : null;
14780 }.bind(this);
14781 rect.on("mouseover", function (event) {
14782 _newArrowCheck(this, _this6);
14783 state.event = event;
14784 $$.updateEventRect();
14785 }.bind(this)).on("mousemove", function (event) {
14786 var d = getData(event);
14787 state.event = event;
14788 if (!d) {
14789 return;
14790 }
14791 var index = d.index,
14792 stepType = config.line_step_type;
14793 // tooltip position match for step-before & step-after
14794 if (config.line_step_tooltipMatch && $$.hasType("step") && /^step\-(before|after)$/.test(stepType)) {
14795 var scale = $$.scale.zoom || $$.scale.x,
14796 xs = $$.axis.xs[index],
14797 inverted = scale.invert(getPointer(event, this)[0]);
14798 if (stepType === "step-after" && inverted < xs) {
14799 index -= 1;
14800 } else if (stepType === "step-before" && inverted > xs) {
14801 index += 1;
14802 }
14803 }
14804
14805 // do nothing while dragging/flowing
14806 if (state.dragging || state.flowing || $$.hasArcType() || config.tooltip_grouped && index === eventReceiver.currentIdx) {
14807 return;
14808 }
14809 if (index !== eventReceiver.currentIdx) {
14810 $$.setOverOut(!1, eventReceiver.currentIdx);
14811 eventReceiver.currentIdx = index;
14812 }
14813 index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, rect, index);
14814
14815 // As of individual data point(or <path>) element can't bind mouseover/out event
14816 // to determine current interacting element, so use 'mousemove' event instead.
14817 $$.setOverOut(index !== -1, index);
14818 }).on("mouseout", function (event) {
14819 _newArrowCheck(this, _this6);
14820 state.event = event;
14821
14822 // chart is destroyed
14823 if (!config || $$.hasArcType() || eventReceiver.currentIdx === -1) {
14824 return;
14825 }
14826 $$.unselectRect();
14827 $$.setOverOut(!1, eventReceiver.currentIdx);
14828
14829 // reset the event current index
14830 eventReceiver.currentIdx = -1;
14831 }.bind(this));
14832 }
14833 return rect;
14834 },
14835 clickHandlerForSingleX: function clickHandlerForSingleX(d, ctx) {
14836 var $$ = ctx,
14837 config = $$.config,
14838 state = $$.state,
14839 main = $$.$el.main;
14840 if (!d || $$.hasArcType() || state.cancelClick) {
14841 state.cancelClick && (state.cancelClick = !1);
14842 return;
14843 }
14844 var index = d.index;
14845 main.selectAll("." + $SHAPE.shape + "-" + index).each(function (d2) {
14846 if (config.data_selection_grouped || $$.isWithinShape(this, d2)) {
14847 $$.toggleShape == null ? void 0 : $$.toggleShape(this, d2, index);
14848 config.data_onclick.bind($$.api)(d2, this);
14849 }
14850 });
14851 },
14852 /**
14853 * Create an eventRect,
14854 * Register touch and drag events.
14855 * @param {object} eventRectEnter d3.select($EVENT.eventRects) object.
14856 * @private
14857 */
14858 generateEventRectsForMultipleXs: function generateEventRectsForMultipleXs(eventRectEnter) {
14859 var _this7 = this,
14860 $$ = this,
14861 state = $$.state;
14862 eventRectEnter.on("click", function (event) {
14863 state.event = event;
14864 $$.clickHandlerForMultipleXS.bind(this)($$);
14865 });
14866 if (state.inputType === "mouse") {
14867 eventRectEnter.on("mouseover mousemove", function (event) {
14868 state.event = event;
14869 $$.selectRectForMultipleXs(this);
14870 }).on("mouseout", function (event) {
14871 _newArrowCheck(this, _this7);
14872 state.event = event;
14873
14874 // chart is destroyed
14875 if (!$$.config || $$.hasArcType()) {
14876 return;
14877 }
14878 $$.unselectRect();
14879 }.bind(this));
14880 }
14881 },
14882 clickHandlerForMultipleXS: function clickHandlerForMultipleXS(ctx) {
14883 var $$ = ctx,
14884 config = $$.config,
14885 state = $$.state,
14886 targetsToShow = $$.filterTargetsToShow($$.data.targets);
14887 if ($$.hasArcType(targetsToShow)) {
14888 return;
14889 }
14890 var mouse = getPointer(state.event, this),
14891 closest = $$.findClosestFromTargets(targetsToShow, mouse);
14892 if (!closest) {
14893 return;
14894 }
14895
14896 // select if selection enabled
14897 if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
14898 $$.$el.main.selectAll("." + $SHAPE.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll("." + $SHAPE.shape + "-" + closest.index).each(function () {
14899 if (config.data_selection_grouped || $$.isWithinShape(this, closest)) {
14900 $$.toggleShape == null ? void 0 : $$.toggleShape(this, closest, closest.index);
14901 config.data_onclick.bind($$.api)(closest, this);
14902 }
14903 });
14904 }
14905 }
14906});
14907// EXTERNAL MODULE: external {"commonjs":"d3-ease","commonjs2":"d3-ease","amd":"d3-ease","root":"d3"}
14908var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack_require__(11);
14909;// CONCATENATED MODULE: ./src/ChartInternal/interactions/flow.ts
14910
14911/**
14912 * Copyright (c) 2017 ~ present NAVER Corp.
14913 * billboard.js project is licensed under the MIT license
14914 */
14915
14916
14917
14918
14919/* harmony default export */ var interactions_flow = ({
14920 /**
14921 * Generate flow
14922 * @param {object} args option object
14923 * @returns {Function}
14924 * @private
14925 */
14926 generateFlow: function generateFlow(args) {
14927 var $$ = this,
14928 data = $$.data,
14929 state = $$.state,
14930 $el = $$.$el;
14931 return function () {
14932 var _this = this,
14933 flowLength = args.flow.length;
14934 // set flag
14935 state.flowing = !0;
14936
14937 // remove head data after rendered
14938 data.targets.forEach(function (d) {
14939 _newArrowCheck(this, _this);
14940 d.values.splice(0, flowLength);
14941 }.bind(this));
14942
14943 // update elements related to x scale
14944 if ($$.updateXGrid) {
14945 $$.updateXGrid(!0);
14946 }
14947
14948 // target elements
14949 var elements = {};
14950 ["axis.x", "grid.x", "gridLines.x", "region.list", "text", "bar", "line", "area", "circle"].forEach(function (v) {
14951 var _node;
14952 _newArrowCheck(this, _this);
14953 var name = v.split("."),
14954 node = $el[name[0]];
14955 if (node && name.length > 1) {
14956 node = node[name[1]];
14957 }
14958 if ((_node = node) != null && _node.size()) {
14959 elements[v] = node;
14960 }
14961 }.bind(this));
14962 $$.hideGridFocus();
14963 $$.setFlowList(elements, args);
14964 };
14965 },
14966 /**
14967 * Set flow list
14968 * @param {object} elements Target elements
14969 * @param {object} args option object
14970 * @private
14971 */
14972 setFlowList: function setFlowList(elements, args) {
14973 var _this2 = this,
14974 $$ = this,
14975 flow = args.flow,
14976 targets = args.targets,
14977 _flow = flow,
14978 _flow$duration = _flow.duration,
14979 duration = _flow$duration === void 0 ? args.duration : _flow$duration,
14980 flowIndex = _flow.index,
14981 flowLength = _flow.length,
14982 orgDataCount = _flow.orgDataCount,
14983 transform = $$.getFlowTransform(targets, orgDataCount, flowIndex, flowLength),
14984 wait = generateWait(),
14985 n;
14986 wait.add(Object.keys(elements).map(function (v) {
14987 var _this3 = this;
14988 _newArrowCheck(this, _this2);
14989 n = elements[v].transition().ease(external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_.easeLinear).duration(duration);
14990 if (v === "axis.x") {
14991 n = n.call(function (g) {
14992 _newArrowCheck(this, _this3);
14993 $$.axis.x.setTransition(g).create(g);
14994 }.bind(this));
14995 } else if (v === "region.list") {
14996 n = n.filter($$.isRegionOnX).attr("transform", transform);
14997 } else {
14998 n = n.attr("transform", transform);
14999 }
15000 return n;
15001 }.bind(this)));
15002 n.call(wait, function () {
15003 _newArrowCheck(this, _this2);
15004 $$.cleanUpFlow(elements, args);
15005 }.bind(this));
15006 },
15007 /**
15008 * Clean up flow
15009 * @param {object} elements Target elements
15010 * @param {object} args option object
15011 * @private
15012 */
15013 cleanUpFlow: function cleanUpFlow(elements, args) {
15014 var _this4 = this,
15015 $$ = this,
15016 config = $$.config,
15017 state = $$.state,
15018 svg = $$.$el.svg,
15019 isRotated = config.axis_rotated,
15020 flow = args.flow,
15021 shape = args.shape,
15022 xv = args.xv,
15023 _shape$pos = shape.pos,
15024 cx = _shape$pos.cx,
15025 cy = _shape$pos.cy,
15026 xForText = _shape$pos.xForText,
15027 yForText = _shape$pos.yForText,
15028 _flow2 = flow,
15029 _flow2$done = _flow2.done,
15030 done = _flow2$done === void 0 ? function () {
15031 _newArrowCheck(this, _this4);
15032 }.bind(this) : _flow2$done,
15033 flowLength = _flow2.length;
15034 // Remove flowed elements
15035 if (flowLength) {
15036 ["circle", "text", "shape", "eventRect"].forEach(function (v) {
15037 _newArrowCheck(this, _this4);
15038 var target = [];
15039 for (var i = 0; i < flowLength; i++) {
15040 target.push("." + classes[v] + "-" + i);
15041 }
15042 svg.selectAll("." + classes[v + "s"]) // circles, shapes, texts, eventRects
15043 .selectAll(target).remove();
15044 }.bind(this));
15045 svg.select("." + classes.xgrid).remove();
15046 }
15047
15048 // draw again for removing flowed elements and reverting attr
15049 Object.keys(elements).forEach(function (v) {
15050 var _this5 = this;
15051 _newArrowCheck(this, _this4);
15052 var n = elements[v];
15053 if (v !== "axis.x") {
15054 n.attr("transform", null);
15055 }
15056 if (v === "grid.x") {
15057 n.attr(state.xgridAttr);
15058 } else if (v === "gridLines.x") {
15059 n.attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);
15060 } else if (v === "gridLines.x") {
15061 n.select("line").attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);
15062 n.select("text").attr("x", isRotated ? state.width : 0).attr("y", xv);
15063 } else if (/^(area|bar|line)$/.test(v)) {
15064 n.attr("d", shape.type[v]);
15065 } else if (v === "text") {
15066 n.attr("x", xForText).attr("y", yForText).style("fill-opacity", $$.opacityForText.bind($$));
15067 } else if (v === "circle") {
15068 if ($$.isCirclePoint()) {
15069 n.attr("cx", cx).attr("cy", cy);
15070 } else {
15071 var xFunc = function (d) {
15072 _newArrowCheck(this, _this5);
15073 return cx(d) - config.point_r;
15074 }.bind(this),
15075 yFunc = function (d) {
15076 _newArrowCheck(this, _this5);
15077 return cy(d) - config.point_r;
15078 }.bind(this);
15079 n.attr("x", xFunc).attr("y", yFunc).attr("cx", cx) // when pattern is used, it possibly contain 'circle' also.
15080 .attr("cy", cy);
15081 }
15082 } else if (v === "region.list") {
15083 n.select("rect").filter($$.isRegionOnX).attr("x", $$.regionX.bind($$)).attr("width", $$.regionWidth.bind($$));
15084 }
15085 }.bind(this));
15086 config.interaction_enabled && $$.redrawEventRect();
15087
15088 // callback for end of flow
15089 done.call($$.api);
15090 state.flowing = !1;
15091 },
15092 /**
15093 * Get flow transform value
15094 * @param {object} targets target
15095 * @param {number} orgDataCount original data count
15096 * @param {number} flowIndex flow index
15097 * @param {number} flowLength flow length
15098 * @returns {string}
15099 * @private
15100 */
15101 getFlowTransform: function getFlowTransform(targets, orgDataCount, flowIndex, flowLength) {
15102 var _flowStart,
15103 _flowEnd,
15104 $$ = this,
15105 data = $$.data,
15106 x = $$.scale.x,
15107 dataValues = data.targets[0].values,
15108 flowStart = $$.getValueOnIndex(dataValues, flowIndex),
15109 flowEnd = $$.getValueOnIndex(dataValues, flowIndex + flowLength),
15110 translateX,
15111 orgDomain = x.domain(),
15112 domain = $$.updateXDomain(targets, !0, !0);
15113 // generate transform to flow
15114 if (!orgDataCount) {
15115 // if empty
15116 if (dataValues.length !== 1) {
15117 translateX = x(orgDomain[0]) - x(domain[0]);
15118 } else {
15119 if ($$.axis.isTimeSeries()) {
15120 flowStart = $$.getValueOnIndex(dataValues, 0);
15121 flowEnd = $$.getValueOnIndex(dataValues, dataValues.length - 1);
15122 translateX = x(flowStart.x) - x(flowEnd.x);
15123 } else {
15124 translateX = diffDomain(domain) / 2;
15125 }
15126 }
15127 } else if (orgDataCount === 1 || ((_flowStart = flowStart) == null ? void 0 : _flowStart.x) === ((_flowEnd = flowEnd) == null ? void 0 : _flowEnd.x)) {
15128 translateX = x(orgDomain[0]) - x(domain[0]);
15129 } else {
15130 var _flowStart2;
15131 translateX = $$.axis.isTimeSeries() ? x(orgDomain[0]) - x(domain[0]) : x(((_flowStart2 = flowStart) == null ? void 0 : _flowStart2.x) || 0) - x(flowEnd.x);
15132 }
15133 var scaleX = diffDomain(orgDomain) / diffDomain(domain);
15134 return "translate(" + translateX + ",0) scale(" + scaleX + ",1)";
15135 }
15136});
15137;// CONCATENATED MODULE: ./src/ChartInternal/internals/clip.ts
15138/**
15139 * Copyright (c) 2017 ~ present NAVER Corp.
15140 * billboard.js project is licensed under the MIT license
15141 */
15142
15143/* harmony default export */ var clip = ({
15144 initClip: function initClip() {
15145 var $$ = this,
15146 clip = $$.state.clip;
15147 // MEMO: clipId needs to be unique because it conflicts when multiple charts exist
15148 clip.id = $$.state.datetimeId + "-clip";
15149 clip.idXAxis = clip.id + "-xaxis";
15150 clip.idYAxis = clip.id + "-yaxis";
15151 clip.idGrid = clip.id + "-grid";
15152
15153 // Define 'clip-path' attribute values
15154 clip.path = $$.getClipPath(clip.id);
15155 clip.pathXAxis = $$.getClipPath(clip.idXAxis);
15156 clip.pathYAxis = $$.getClipPath(clip.idYAxis);
15157 clip.pathGrid = $$.getClipPath(clip.idGrid);
15158 },
15159 getClipPath: function getClipPath(id) {
15160 var $$ = this,
15161 config = $$.config;
15162 if (!config.clipPath && /-clip$/.test(id) || !config.axis_x_clipPath && /-clip-xaxis$/.test(id) || !config.axis_y_clipPath && /-clip-yaxis$/.test(id)) {
15163 return null;
15164 }
15165 var isIE9 = win.navigator ? win.navigator.appVersion.toLowerCase().indexOf("msie 9.") >= 0 : !1;
15166 return "url(" + (isIE9 ? "" : browser_doc.URL.split("#")[0]) + "#" + id + ")";
15167 },
15168 appendClip: function appendClip(parent, id) {
15169 id && parent.append("clipPath").attr("id", id).append("rect");
15170 },
15171 /**
15172 * Set x Axis clipPath dimension
15173 * @param {d3Selecton} node clipPath <rect> selection
15174 * @private
15175 */
15176 setXAxisClipPath: function setXAxisClipPath(node) {
15177 var $$ = this,
15178 config = $$.config,
15179 _$$$state = $$.state,
15180 margin = _$$$state.margin,
15181 width = _$$$state.width,
15182 height = _$$$state.height,
15183 isRotated = config.axis_rotated,
15184 left = Math.max(30, margin.left) - (isRotated ? 0 : 20),
15185 x = isRotated ? -(1 + left) : -(left - 1),
15186 y = -Math.max(15, margin.top),
15187 w = isRotated ? margin.left + 20 : width + 10 + left,
15188 h = (isRotated ? margin.top + height + 10 : margin.bottom) + 20;
15189 node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
15190 },
15191 /**
15192 * Set y Axis clipPath dimension
15193 * @param {d3Selecton} node clipPath <rect> selection
15194 * @private
15195 */
15196 setYAxisClipPath: function setYAxisClipPath(node) {
15197 var $$ = this,
15198 config = $$.config,
15199 _$$$state2 = $$.state,
15200 margin = _$$$state2.margin,
15201 width = _$$$state2.width,
15202 height = _$$$state2.height,
15203 isRotated = config.axis_rotated,
15204 left = Math.max(30, margin.left) - (isRotated ? 20 : 0),
15205 isInner = config.axis_y_inner,
15206 x = isInner ? -1 : isRotated ? -(1 + left) : -(left - 1),
15207 y = -(isRotated ? 20 : margin.top),
15208 w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0),
15209 h = (isRotated ? margin.bottom : margin.top + height) + 10;
15210 node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
15211 },
15212 updateXAxisTickClip: function updateXAxisTickClip() {
15213 var $$ = this,
15214 config = $$.config,
15215 _$$$state3 = $$.state,
15216 clip = _$$$state3.clip,
15217 xAxisHeight = _$$$state3.xAxisHeight,
15218 defs = $$.$el.defs,
15219 newXAxisHeight = $$.getHorizontalAxisHeight("x");
15220 if (defs && !clip.idXAxisTickTexts) {
15221 var clipId = clip.id + "-xaxisticktexts";
15222 $$.appendClip(defs, clipId);
15223 clip.pathXAxisTickTexts = $$.getClipPath(clip.idXAxisTickTexts);
15224 clip.idXAxisTickTexts = clipId;
15225 }
15226 if (!config.axis_x_tick_multiline && $$.getAxisTickRotate("x") && newXAxisHeight !== xAxisHeight) {
15227 $$.setXAxisTickClipWidth();
15228 $$.setXAxisTickTextClipPathWidth();
15229 }
15230 $$.state.xAxisHeight = newXAxisHeight;
15231 },
15232 setXAxisTickClipWidth: function setXAxisTickClipWidth() {
15233 var $$ = this,
15234 config = $$.config,
15235 maxTickWidths = $$.state.current.maxTickWidths,
15236 xAxisTickRotate = $$.getAxisTickRotate("x");
15237 if (!config.axis_x_tick_multiline && xAxisTickRotate) {
15238 var sinRotation = Math.sin(Math.PI / 180 * Math.abs(xAxisTickRotate));
15239 maxTickWidths.x.clipPath = ($$.getHorizontalAxisHeight("x") - 20) / sinRotation;
15240 } else {
15241 maxTickWidths.x.clipPath = null;
15242 }
15243 },
15244 setXAxisTickTextClipPathWidth: function setXAxisTickTextClipPathWidth() {
15245 var $$ = this,
15246 _$$$state4 = $$.state,
15247 clip = _$$$state4.clip,
15248 current = _$$$state4.current,
15249 svg = $$.$el.svg;
15250 if (svg) {
15251 svg.select("#" + clip.idXAxisTickTexts + " rect").attr("width", current.maxTickWidths.x.clipPath).attr("height", 30);
15252 }
15253 }
15254});
15255;// CONCATENATED MODULE: ./src/ChartInternal/internals/grid.ts
15256
15257var grid_this = undefined;
15258/**
15259 * Copyright (c) 2017 ~ present NAVER Corp.
15260 * billboard.js project is licensed under the MIT license
15261 */
15262
15263
15264
15265
15266// Grid position and text anchor helpers
15267var getGridTextAnchor = function (d) {
15268 _newArrowCheck(this, grid_this);
15269 return isValue(d.position) || "end";
15270 }.bind(undefined),
15271 getGridTextDx = function (d) {
15272 _newArrowCheck(this, grid_this);
15273 return d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
15274 }.bind(undefined);
15275/**
15276 * Get grid text x value getter function
15277 * @param {boolean} isX Is x Axis
15278 * @param {number} width Width value
15279 * @param {number} height Height value
15280 * @returns {Function}
15281 * @private
15282 */
15283function getGridTextX(isX, width, height) {
15284 var _this2 = this;
15285 return function (d) {
15286 _newArrowCheck(this, _this2);
15287 var x = isX ? 0 : width;
15288 if (d.position === "start") {
15289 x = isX ? -height : 0;
15290 } else if (d.position === "middle") {
15291 x = (isX ? -height : width) / 2;
15292 }
15293 return x;
15294 }.bind(this);
15295}
15296
15297/**
15298 * Update coordinate attributes value
15299 * @param {d3.selection} el Target node
15300 * @param {string} type Type
15301 * @private
15302 */
15303function smoothLines(el, type) {
15304 if (type === "grid") {
15305 el.each(function () {
15306 var _this3 = this,
15307 g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
15308 ["x1", "x2", "y1", "y2"].forEach(function (v) {
15309 _newArrowCheck(this, _this3);
15310 return g.attr(v, Math.ceil(+g.attr(v)));
15311 }.bind(this));
15312 });
15313 }
15314}
15315/* harmony default export */ var grid = ({
15316 hasGrid: function hasGrid() {
15317 var _this4 = this,
15318 config = this.config;
15319 return ["x", "y"].some(function (v) {
15320 _newArrowCheck(this, _this4);
15321 return config["grid_" + v + "_show"] || config["grid_" + v + "_lines"].length;
15322 }.bind(this));
15323 },
15324 initGrid: function initGrid() {
15325 var $$ = this;
15326 $$.hasGrid() && $$.initGridLines();
15327 $$.initFocusGrid();
15328 },
15329 initGridLines: function initGridLines() {
15330 var $$ = this,
15331 config = $$.config,
15332 clip = $$.state.clip,
15333 $el = $$.$el;
15334 if (config.grid_x_lines.length || config.grid_y_lines.length) {
15335 $el.gridLines.main = $el.main.insert("g", "." + $COMMON.chart + (config.grid_lines_front ? " + *" : "")).attr("clip-path", clip.pathGrid).attr("class", $GRID.grid + " " + $GRID.gridLines);
15336 $el.gridLines.main.append("g").attr("class", $GRID.xgridLines);
15337 $el.gridLines.main.append("g").attr("class", $GRID.ygridLines);
15338 $el.gridLines.x = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([]);
15339 }
15340 },
15341 updateXGrid: function updateXGrid(withoutUpdate) {
15342 var _this5 = this,
15343 $$ = this,
15344 config = $$.config,
15345 scale = $$.scale,
15346 state = $$.state,
15347 _$$$$el = $$.$el,
15348 main = _$$$$el.main,
15349 grid = _$$$$el.grid,
15350 isRotated = config.axis_rotated,
15351 xgridData = $$.generateGridData(config.grid_x_type, scale.x),
15352 tickOffset = $$.axis.isCategorized() ? $$.axis.x.tickOffset() : 0,
15353 pos = function (d) {
15354 _newArrowCheck(this, _this5);
15355 return (scale.zoom || scale.x)(d) + tickOffset * (isRotated ? -1 : 1);
15356 }.bind(this);
15357 state.xgridAttr = isRotated ? {
15358 "x1": 0,
15359 "x2": state.width,
15360 "y1": pos,
15361 "y2": pos
15362 } : {
15363 "x1": pos,
15364 "x2": pos,
15365 "y1": 0,
15366 "y2": state.height
15367 };
15368 grid.x = main.select("." + $GRID.xgrids).selectAll("." + $GRID.xgrid).data(xgridData);
15369 grid.x.exit().remove();
15370 grid.x = grid.x.enter().append("line").attr("class", $GRID.xgrid).merge(grid.x);
15371 if (!withoutUpdate) {
15372 grid.x.each(function () {
15373 var _this6 = this,
15374 grid = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
15375 Object.keys(state.xgridAttr).forEach(function (id) {
15376 var _this7 = this;
15377 _newArrowCheck(this, _this6);
15378 grid.attr(id, state.xgridAttr[id]).style("opacity", function () {
15379 _newArrowCheck(this, _this7);
15380 return grid.attr(isRotated ? "y1" : "x1") === (isRotated ? state.height : 0) ? "0" : null;
15381 }.bind(this));
15382 }.bind(this));
15383 });
15384 }
15385 },
15386 updateYGrid: function updateYGrid() {
15387 var _this8 = this,
15388 $$ = this,
15389 axis = $$.axis,
15390 config = $$.config,
15391 scale = $$.scale,
15392 state = $$.state,
15393 _$$$$el2 = $$.$el,
15394 grid = _$$$$el2.grid,
15395 main = _$$$$el2.main,
15396 isRotated = config.axis_rotated,
15397 pos = function (d) {
15398 _newArrowCheck(this, _this8);
15399 return Math.ceil(scale.y(d));
15400 }.bind(this),
15401 gridValues = axis.y.getGeneratedTicks(config.grid_y_ticks) || $$.scale.y.ticks(config.grid_y_ticks);
15402 grid.y = main.select("." + $GRID.ygrids).selectAll("." + $GRID.ygrid).data(gridValues);
15403 grid.y.exit().remove();
15404 grid.y = grid.y.enter().append("line").attr("class", $GRID.ygrid).merge(grid.y);
15405 grid.y.attr("x1", isRotated ? pos : 0).attr("x2", isRotated ? pos : state.width).attr("y1", isRotated ? 0 : pos).attr("y2", isRotated ? state.height : pos);
15406 smoothLines(grid.y, "grid");
15407 },
15408 updateGrid: function updateGrid() {
15409 var $$ = this,
15410 _$$$$el3 = $$.$el,
15411 grid = _$$$$el3.grid,
15412 gridLines = _$$$$el3.gridLines;
15413 gridLines.main || $$.initGridLines();
15414
15415 // hide if arc type
15416 grid.main.style("visibility", $$.hasArcType() ? "hidden" : null);
15417 $$.hideGridFocus();
15418 $$.updateXGridLines();
15419 $$.updateYGridLines();
15420 },
15421 /**
15422 * Update X Grid lines
15423 * @private
15424 */
15425 updateXGridLines: function updateXGridLines() {
15426 var _this9 = this,
15427 $$ = this,
15428 config = $$.config,
15429 _$$$$el4 = $$.$el,
15430 gridLines = _$$$$el4.gridLines,
15431 main = _$$$$el4.main,
15432 $T = $$.$T,
15433 isRotated = config.axis_rotated;
15434 config.grid_x_show && $$.updateXGrid();
15435 var xLines = main.select("." + $GRID.xgridLines).selectAll("." + $GRID.xgridLine).data(config.grid_x_lines);
15436
15437 // exit
15438 $T(xLines.exit()).style("opacity", "0").remove();
15439
15440 // enter
15441 var xgridLine = xLines.enter().append("g");
15442 xgridLine.append("line").style("opacity", "0");
15443 xgridLine.append("text").attr("transform", isRotated ? "" : "rotate(-90)").attr("dy", -5).style("opacity", "0");
15444 xLines = xgridLine.merge(xLines);
15445 $T(xLines.attr("class", function (d) {
15446 _newArrowCheck(this, _this9);
15447 return ($GRID.xgridLine + " " + (d.class || "")).trim();
15448 }.bind(this)).select("text").attr("text-anchor", getGridTextAnchor).attr("dx", getGridTextDx)).text(function (d) {
15449 _newArrowCheck(this, _this9);
15450 return d.text;
15451 }.bind(this)).style("opacity", null);
15452 gridLines.x = xLines;
15453 },
15454 /**
15455 * Update Y Grid lines
15456 * @private
15457 */
15458 updateYGridLines: function updateYGridLines() {
15459 var _this10 = this,
15460 $$ = this,
15461 config = $$.config,
15462 _$$$state = $$.state,
15463 width = _$$$state.width,
15464 height = _$$$state.height,
15465 $el = $$.$el,
15466 $T = $$.$T,
15467 isRotated = config.axis_rotated;
15468 config.grid_y_show && $$.updateYGrid();
15469 var ygridLines = $el.main.select("." + $GRID.ygridLines).selectAll("." + $GRID.ygridLine).data(config.grid_y_lines);
15470
15471 // exit
15472 $T(ygridLines.exit()).style("opacity", "0").remove();
15473
15474 // enter
15475 var ygridLine = ygridLines.enter().append("g");
15476 ygridLine.append("line").style("opacity", "0");
15477 ygridLine.append("text").attr("transform", isRotated ? "rotate(-90)" : "").style("opacity", "0");
15478 ygridLines = ygridLine.merge(ygridLines);
15479
15480 // update
15481 var yv = $$.yv.bind($$);
15482 $T(ygridLines.attr("class", function (d) {
15483 _newArrowCheck(this, _this10);
15484 return ($GRID.ygridLine + " " + (d.class || "")).trim();
15485 }.bind(this)).select("line")).attr("x1", isRotated ? yv : 0).attr("x2", isRotated ? yv : width).attr("y1", isRotated ? 0 : yv).attr("y2", isRotated ? height : yv).style("opacity", null);
15486 $T(ygridLines.select("text").attr("text-anchor", getGridTextAnchor).attr("dx", getGridTextDx)).attr("dy", -5).attr("x", getGridTextX(isRotated, width, height)).attr("y", yv).text(function (d) {
15487 _newArrowCheck(this, _this10);
15488 return d.text;
15489 }.bind(this)).style("opacity", null);
15490 $el.gridLines.y = ygridLines;
15491 },
15492 redrawGrid: function redrawGrid(withTransition) {
15493 var _this11 = this,
15494 $$ = this,
15495 isRotated = $$.config.axis_rotated,
15496 _$$$state2 = $$.state,
15497 width = _$$$state2.width,
15498 height = _$$$state2.height,
15499 gridLines = $$.$el.gridLines,
15500 $T = $$.$T,
15501 xv = $$.xv.bind($$),
15502 lines = gridLines.x.select("line"),
15503 texts = gridLines.x.select("text");
15504 lines = $T(lines, withTransition).attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? width : xv).attr("y1", isRotated ? xv : 0).attr("y2", isRotated ? xv : height);
15505 texts = $T(texts, withTransition).attr("x", getGridTextX(!isRotated, width, height)).attr("y", xv).text(function (d) {
15506 _newArrowCheck(this, _this11);
15507 return d.text;
15508 }.bind(this));
15509 return [lines.style("opacity", null), texts.style("opacity", null)];
15510 },
15511 initFocusGrid: function initFocusGrid() {
15512 var $$ = this,
15513 config = $$.config,
15514 clip = $$.state.clip,
15515 $el = $$.$el,
15516 isFront = config.grid_front,
15517 className = "." + (isFront && $el.gridLines.main ? $GRID.gridLines : $COMMON.chart) + (isFront ? " + *" : ""),
15518 grid = $el.main.insert("g", className).attr("clip-path", clip.pathGrid).attr("class", $GRID.grid);
15519 $el.grid.main = grid;
15520 config.grid_x_show && grid.append("g").attr("class", $GRID.xgrids);
15521 config.grid_y_show && grid.append("g").attr("class", $GRID.ygrids);
15522 if (config.interaction_enabled && config.grid_focus_show) {
15523 grid.append("g").attr("class", $FOCUS.xgridFocus).append("line").attr("class", $FOCUS.xgridFocus);
15524
15525 // to show xy focus grid line, should be 'tooltip.grouped=false'
15526 if (config.grid_focus_y && !config.tooltip_grouped) {
15527 grid.append("g").attr("class", $FOCUS.ygridFocus).append("line").attr("class", $FOCUS.ygridFocus);
15528 }
15529 }
15530 },
15531 /**
15532 * Show grid focus line
15533 * @param {Array} data Selected data
15534 * @private
15535 */
15536 showGridFocus: function showGridFocus(data) {
15537 var _this12 = this,
15538 $$ = this,
15539 config = $$.config,
15540 _$$$state3 = $$.state,
15541 width = _$$$state3.width,
15542 height = _$$$state3.height,
15543 isRotated = config.axis_rotated,
15544 focusEl = $$.$el.main.selectAll("line." + $FOCUS.xgridFocus + ", line." + $FOCUS.ygridFocus),
15545 dataToShow = (data || [focusEl.datum()]).filter(function (d) {
15546 _newArrowCheck(this, _this12);
15547 return d && isValue($$.getBaseValue(d));
15548 }.bind(this));
15549 // Hide when bubble/scatter/stanford plot exists
15550 if (!config.tooltip_show || dataToShow.length === 0 || $$.hasType("bubble") || $$.hasArcType()) {
15551 return;
15552 }
15553 var isEdge = config.grid_focus_edge && !config.tooltip_grouped,
15554 xx = $$.xx.bind($$);
15555 focusEl.style("visibility", null).data(dataToShow.concat(dataToShow)).each(function (d) {
15556 var _this13 = this,
15557 el = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
15558 pos = {
15559 x: xx(d),
15560 y: $$.getYScaleById(d.id)(d.value)
15561 },
15562 xy;
15563 if (el.classed($FOCUS.xgridFocus)) {
15564 // will contain 'x1, y1, x2, y2' order
15565 xy = isRotated ? [null,
15566 // x1
15567 pos.x,
15568 // y1
15569 isEdge ? pos.y : width,
15570 // x2
15571 pos.x // y2
15572 ] : [pos.x, isEdge ? pos.y : null, pos.x, height];
15573 } else {
15574 var isY2 = $$.axis.getId(d.id) === "y2";
15575 xy = isRotated ? [pos.y,
15576 // x1
15577 isEdge && !isY2 ? pos.x : null,
15578 // y1
15579 pos.y,
15580 // x2
15581 isEdge && isY2 ? pos.x : height // y2
15582 ] : [isEdge && isY2 ? pos.x : null, pos.y, isEdge && !isY2 ? pos.x : width, pos.y];
15583 }
15584 ["x1", "y1", "x2", "y2"].forEach(function (v, i) {
15585 _newArrowCheck(this, _this13);
15586 return el.attr(v, xy[i]);
15587 }.bind(this));
15588 });
15589 smoothLines(focusEl, "grid");
15590 $$.showCircleFocus == null ? void 0 : $$.showCircleFocus(data);
15591 },
15592 hideGridFocus: function hideGridFocus() {
15593 var $$ = this,
15594 _$$$state4 = $$.state,
15595 inputType = _$$$state4.inputType,
15596 resizing = _$$$state4.resizing,
15597 main = $$.$el.main;
15598 if (inputType === "mouse" || !resizing) {
15599 main.selectAll("line." + $FOCUS.xgridFocus + ", line." + $FOCUS.ygridFocus).style("visibility", "hidden");
15600 $$.hideCircleFocus == null ? void 0 : $$.hideCircleFocus();
15601 }
15602 },
15603 updateGridFocus: function updateGridFocus() {
15604 var $$ = this,
15605 _$$$state5 = $$.state,
15606 inputType = _$$$state5.inputType,
15607 width = _$$$state5.width,
15608 height = _$$$state5.height,
15609 resizing = _$$$state5.resizing,
15610 grid = $$.$el.grid,
15611 xgridFocus = grid.main.select("line." + $FOCUS.xgridFocus);
15612 if (inputType === "touch") {
15613 if (xgridFocus.empty()) {
15614 resizing && ($$.showCircleFocus == null ? void 0 : $$.showCircleFocus());
15615 } else {
15616 $$.showGridFocus();
15617 }
15618 } else {
15619 var _isRotated = $$.config.axis_rotated;
15620 xgridFocus.attr("x1", _isRotated ? 0 : -10).attr("x2", _isRotated ? width : -10).attr("y1", _isRotated ? -10 : 0).attr("y2", _isRotated ? -10 : height);
15621 }
15622
15623 // need to return 'true' as of being pushed to the redraw list
15624 // ref: getRedrawList()
15625 return !0;
15626 },
15627 generateGridData: function generateGridData(type, scale) {
15628 var _this14 = this,
15629 $$ = this,
15630 tickNum = $$.$el.main.select("." + $AXIS.axisX).selectAll(".tick").size(),
15631 gridData = [];
15632 if (type === "year") {
15633 var xDomain = $$.getXDomain(),
15634 _xDomain$map = xDomain.map(function (v) {
15635 _newArrowCheck(this, _this14);
15636 return v.getFullYear();
15637 }.bind(this)),
15638 firstYear = _xDomain$map[0],
15639 lastYear = _xDomain$map[1];
15640 for (var i = firstYear; i <= lastYear; i++) {
15641 gridData.push(new Date(i + "-01-01 00:00:00"));
15642 }
15643 } else {
15644 gridData = scale.ticks(10);
15645 if (gridData.length > tickNum) {
15646 // use only int
15647 gridData = gridData.filter(function (d) {
15648 _newArrowCheck(this, _this14);
15649 return (d + "").indexOf(".") < 0;
15650 }.bind(this));
15651 }
15652 }
15653 return gridData;
15654 },
15655 getGridFilterToRemove: function getGridFilterToRemove(params) {
15656 var _this15 = this;
15657 return params ? function (line) {
15658 var _this16 = this;
15659 _newArrowCheck(this, _this15);
15660 var found = !1;
15661 (isArray(params) ? params.concat() : [params]).forEach(function (param) {
15662 _newArrowCheck(this, _this16);
15663 if ("value" in param && line.value === param.value || "class" in param && line.class === param.class) {
15664 found = !0;
15665 }
15666 }.bind(this));
15667 return found;
15668 }.bind(this) : function () {
15669 _newArrowCheck(this, _this15);
15670 return !0;
15671 }.bind(this);
15672 },
15673 removeGridLines: function removeGridLines(params, forX) {
15674 var _this17 = this,
15675 $$ = this,
15676 config = $$.config,
15677 $T = $$.$T,
15678 toRemove = $$.getGridFilterToRemove(params),
15679 toShow = function (line) {
15680 _newArrowCheck(this, _this17);
15681 return !toRemove(line);
15682 }.bind(this),
15683 classLines = forX ? $GRID.xgridLines : $GRID.ygridLines,
15684 classLine = forX ? $GRID.xgridLine : $GRID.ygridLine;
15685 $T($$.$el.main.select("." + classLines).selectAll("." + classLine).filter(toRemove)).style("opacity", "0").remove();
15686 var gridLines = "grid_" + (forX ? "x" : "y") + "_lines";
15687 config[gridLines] = config[gridLines].filter(toShow);
15688 }
15689});
15690;// CONCATENATED MODULE: ./src/ChartInternal/internals/region.ts
15691
15692/**
15693 * Copyright (c) 2017 ~ present NAVER Corp.
15694 * billboard.js project is licensed under the MIT license
15695 */
15696 // selection
15697
15698
15699/* harmony default export */ var region = ({
15700 initRegion: function initRegion() {
15701 var $$ = this,
15702 $el = $$.$el;
15703 $el.region.main = $el.main.insert("g", ":first-child").attr("clip-path", $$.state.clip.path).attr("class", $REGION.regions);
15704 },
15705 updateRegion: function updateRegion() {
15706 var $$ = this,
15707 config = $$.config,
15708 region = $$.$el.region,
15709 $T = $$.$T;
15710 if (!region.main) {
15711 $$.initRegion();
15712 }
15713
15714 // hide if arc type
15715 region.main.style("visibility", $$.hasArcType() ? "hidden" : null);
15716 // select <g> element
15717
15718 var list = region.main.selectAll("." + $REGION.region).data(config.regions);
15719 $T(list.exit()).style("opacity", "0").remove();
15720 list = list.enter().append("g").merge(list).attr("class", $$.classRegion.bind($$));
15721 list.append("rect").style("fill-opacity", "0");
15722 region.list = list;
15723 },
15724 redrawRegion: function redrawRegion(withTransition) {
15725 var _this = this,
15726 $$ = this,
15727 region = $$.$el.region,
15728 $T = $$.$T,
15729 regions = region.list.select("rect");
15730 regions = $T(regions, withTransition).attr("x", $$.regionX.bind($$)).attr("y", $$.regionY.bind($$)).attr("width", $$.regionWidth.bind($$)).attr("height", $$.regionHeight.bind($$));
15731 return [regions.style("fill-opacity", function (d) {
15732 _newArrowCheck(this, _this);
15733 return isValue(d.opacity) ? d.opacity : null;
15734 }.bind(this)).on("end", function () {
15735 // remove unnecessary rect after transition
15736 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode).selectAll("rect:not([x])").remove();
15737 })];
15738 },
15739 getRegionXY: function getRegionXY(type, d) {
15740 var $$ = this,
15741 config = $$.config,
15742 scale = $$.scale,
15743 isRotated = config.axis_rotated,
15744 isX = type === "x",
15745 key = "start",
15746 currScale,
15747 pos = 0;
15748 if (d.axis === "y" || d.axis === "y2") {
15749 if (!isX) {
15750 key = "end";
15751 }
15752 if ((isX ? isRotated : !isRotated) && key in d) {
15753 currScale = scale[d.axis];
15754 pos = currScale(d[key]);
15755 }
15756 } else if ((isX ? !isRotated : isRotated) && key in d) {
15757 currScale = scale.zoom || scale.x;
15758 pos = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key]);
15759 }
15760 return pos;
15761 },
15762 regionX: function regionX(d) {
15763 return this.getRegionXY("x", d);
15764 },
15765 regionY: function regionY(d) {
15766 return this.getRegionXY("y", d);
15767 },
15768 getRegionSize: function getRegionSize(type, d) {
15769 var $$ = this,
15770 config = $$.config,
15771 scale = $$.scale,
15772 state = $$.state,
15773 isRotated = config.axis_rotated,
15774 isWidth = type === "width",
15775 start = $$[isWidth ? "regionX" : "regionY"](d),
15776 currScale,
15777 key = "end",
15778 end = state[type];
15779 if (d.axis === "y" || d.axis === "y2") {
15780 if (!isWidth) {
15781 key = "start";
15782 }
15783 if ((isWidth ? isRotated : !isRotated) && key in d) {
15784 currScale = scale[d.axis];
15785 end = currScale(d[key]);
15786 }
15787 } else if ((isWidth ? !isRotated : isRotated) && key in d) {
15788 currScale = scale.zoom || scale.x;
15789 end = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key]);
15790 }
15791 return end < start ? 0 : end - start;
15792 },
15793 regionWidth: function regionWidth(d) {
15794 return this.getRegionSize("width", d);
15795 },
15796 regionHeight: function regionHeight(d) {
15797 return this.getRegionSize("height", d);
15798 },
15799 isRegionOnX: function isRegionOnX(d) {
15800 return !d.axis || d.axis === "x";
15801 }
15802});
15803;// CONCATENATED MODULE: ./src/ChartInternal/internals/size.axis.ts
15804/**
15805 * Copyright (c) 2017 ~ present NAVER Corp.
15806 * billboard.js project is licensed under the MIT license
15807 */
15808
15809/* harmony default export */ var size_axis = ({
15810 /**
15811 * Get Axis size according its position
15812 * @param {string} id Axis id value - x, y or y2
15813 * @returns {number} size Axis size value
15814 * @private
15815 */
15816 getAxisSize: function getAxisSize(id) {
15817 var $$ = this,
15818 isRotated = $$.config.axis_rotated;
15819 return isRotated && id === "x" || !isRotated && /y2?/.test(id) ? $$.getAxisWidthByAxisId(id, !0) : $$.getHorizontalAxisHeight(id);
15820 },
15821 getAxisWidthByAxisId: function getAxisWidthByAxisId(id, withoutRecompute) {
15822 var $$ = this;
15823 if ($$.axis) {
15824 var _$$$axis,
15825 position = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.getLabelPositionById(id),
15826 width = $$.axis.getMaxTickWidth(id, withoutRecompute),
15827 gap = width === 0 ? .5 : 0;
15828 return width + (position.isInner ? 20 + gap : 40);
15829 } else {
15830 return 40;
15831 }
15832 },
15833 getHorizontalAxisHeight: function getHorizontalAxisHeight(id) {
15834 var $$ = this,
15835 config = $$.config,
15836 state = $$.state,
15837 _state = state,
15838 current = _state.current,
15839 rotatedPadding = _state.rotatedPadding,
15840 isLegendRight = _state.isLegendRight,
15841 isLegendInset = _state.isLegendInset,
15842 isRotated = config.axis_rotated,
15843 h = 30;
15844 if (id === "x" && !config.axis_x_show) {
15845 return 8;
15846 }
15847 if (id === "x" && config.axis_x_height) {
15848 return config.axis_x_height;
15849 }
15850 if (id === "y" && !config.axis_y_show) {
15851 return config.legend_show && !isLegendRight && !isLegendInset ? 10 : 1;
15852 }
15853 if (id === "y2" && !config.axis_y2_show) {
15854 return rotatedPadding.top;
15855 }
15856 var rotate = $$.getAxisTickRotate(id);
15857
15858 // Calculate x/y axis height when tick rotated
15859 if ((id === "x" && !isRotated || /y2?/.test(id) && isRotated) && rotate) {
15860 h = 30 + $$.axis.getMaxTickWidth(id) * Math.cos(Math.PI * (90 - Math.abs(rotate)) / 180);
15861 if (!config.axis_x_tick_multiline && current.height) {
15862 if (h > current.height / 2) {
15863 h = current.height / 2;
15864 }
15865 }
15866 }
15867 return h + ($$.axis.getLabelPositionById(id).isInner ? 0 : 10) + (id === "y2" && !isRotated ? -10 : 0);
15868 },
15869 getEventRectWidth: function getEventRectWidth() {
15870 return Math.max(0, this.axis.x.tickInterval());
15871 },
15872 /**
15873 * Get axis tick test rotate value
15874 * @param {string} id Axis id
15875 * @returns {number} rotate value
15876 * @private
15877 */
15878 getAxisTickRotate: function getAxisTickRotate(id) {
15879 var $$ = this,
15880 axis = $$.axis,
15881 config = $$.config,
15882 state = $$.state,
15883 $el = $$.$el,
15884 rotate = config["axis_" + id + "_tick_rotate"];
15885 if (id === "x") {
15886 var allowedXAxisTypes = axis.isCategorized() || axis.isTimeSeries();
15887 if (config.axis_x_tick_fit && allowedXAxisTypes) {
15888 var xTickCount = config.axis_x_tick_count,
15889 currentXTicksLength = state.current.maxTickWidths.x.ticks.length,
15890 tickCount = 0;
15891 if (xTickCount) {
15892 tickCount = xTickCount > currentXTicksLength ? currentXTicksLength : xTickCount;
15893 } else if (currentXTicksLength) {
15894 tickCount = currentXTicksLength;
15895 }
15896 if (tickCount !== state.axis.x.tickCount) {
15897 var targets = $$.data.targets;
15898 state.axis.x.padding = $$.getXDomainPadding([$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")], tickCount);
15899 }
15900 state.axis.x.tickCount = tickCount;
15901 }
15902 if ($el.svg && config.axis_x_tick_fit && !config.axis_x_tick_multiline && !config.axis_x_tick_culling && config.axis_x_tick_autorotate && allowedXAxisTypes) {
15903 rotate = $$.needToRotateXAxisTickTexts() ? config.axis_x_tick_rotate : 0;
15904 }
15905 }
15906 return rotate;
15907 },
15908 /**
15909 * Check weather axis tick text needs to be rotated
15910 * @returns {boolean}
15911 * @private
15912 */
15913 needToRotateXAxisTickTexts: function needToRotateXAxisTickTexts() {
15914 var $$ = this,
15915 _$$$state = $$.state,
15916 axis = _$$$state.axis,
15917 current = _$$$state.current,
15918 xAxisLength = current.width - $$.getCurrentPaddingLeft(!1) - $$.getCurrentPaddingRight(),
15919 tickCountWithPadding = axis.x.tickCount + axis.x.padding.left + axis.x.padding.right,
15920 maxTickWidth = $$.axis.getMaxTickWidth("x"),
15921 tickLength = tickCountWithPadding ? xAxisLength / tickCountWithPadding : 0;
15922 return maxTickWidth > tickLength;
15923 }
15924});
15925;// CONCATENATED MODULE: ./src/config/Options/data/axis.ts
15926/**
15927 * Copyright (c) 2017 ~ present NAVER Corp.
15928 * billboard.js project is licensed under the MIT license
15929 */
15930/**
15931 * Axis based chart data config options
15932 */
15933/* harmony default export */ var data_axis = ({
15934 /**
15935 * Specify the keys of the x values for each data.<br><br>
15936 * This option can be used if we want to show the data that has different x values.
15937 * @name data․xs
15938 * @memberof Options
15939 * @type {object}
15940 * @default {}
15941 * @example
15942 * data: {
15943 * xs: {
15944 * data1: "x1",
15945 * data2: "x2"
15946 * }
15947 * }
15948 */
15949 data_xs: {},
15950 /**
15951 * Set a format specifier to parse string specifed as x.
15952 * @name data․xFormat
15953 * @memberof Options
15954 * @type {string}
15955 * @default %Y-%m-%d
15956 * @example
15957 * data: {
15958 * x: "x",
15959 * columns: [
15960 * ["x", "01012019", "02012019", "03012019"],
15961 * ["data1", 30, 200, 100]
15962 * ],
15963 * // Format specifier to parse as datetime for given 'x' string value
15964 * xFormat: "%m%d%Y"
15965 * },
15966 * axis: {
15967 * x: {
15968 * type: "timeseries"
15969 * }
15970 * }
15971 * @see [D3's time specifier](https://github.com/d3/d3-time-format#locale_format)
15972 */
15973 data_xFormat: "%Y-%m-%d",
15974 /**
15975 * Set localtime format to parse x axis.
15976 * @name data․xLocaltime
15977 * @memberof Options
15978 * @type {boolean}
15979 * @default true
15980 * @example
15981 * data: {
15982 * xLocaltime: false
15983 * }
15984 */
15985 data_xLocaltime: !0,
15986 /**
15987 * Sort on x axis.
15988 * @name data․xSort
15989 * @memberof Options
15990 * @type {boolean}
15991 * @default true
15992 * @example
15993 * data: {
15994 * xSort: false
15995 * }
15996 */
15997 data_xSort: !0,
15998 /**
15999 * Set y axis the data related to. y and y2 can be used.
16000 * - **NOTE:** If all data is related to one of the axes, the domain of axis without related data will be replaced by the domain from the axis with related data
16001 * @name data․axes
16002 * @memberof Options
16003 * @type {object}
16004 * @default {}
16005 * @example
16006 * data: {
16007 * axes: {
16008 * data1: "y",
16009 * data2: "y2"
16010 * }
16011 * }
16012 */
16013 data_axes: {},
16014 /**
16015 * Define regions for each data.<br>
16016 * The values must be an array for each data and it should include an object that has `start`, `end` and `style`.
16017 * - The object type should be as:
16018 * - start {number}: Start data point number. If not set, the start will be the first data point.
16019 * - [end] {number}: End data point number. If not set, the end will be the last data point.
16020 * - [style.dasharray="2 2"] {object}: The first number specifies a distance for the filled area, and the second a distance for the unfilled area.
16021 * - **NOTE:** Currently this option supports only line chart and dashed style. If this option specified, the line will be dashed only in the regions.
16022 * @name data․regions
16023 * @memberof Options
16024 * @type {object}
16025 * @default {}
16026 * @example
16027 * data: {
16028 * regions: {
16029 * data1: [{
16030 * start: 1,
16031 * end: 2,
16032 * style: {
16033 * dasharray: "5 2"
16034 * }
16035 * }, {
16036 * start: 3
16037 * }],
16038 * ...
16039 * }
16040 * }
16041 */
16042 data_regions: {},
16043 /**
16044 * Set the stacking to be normalized
16045 * - **NOTE:**
16046 * - For stacking, '[data.groups](#.data%25E2%2580%25A4groups)' option should be set
16047 * - y Axis will be set in percentage value (0 ~ 100%)
16048 * - Must have postive values
16049 * @name data․stack․normalize
16050 * @memberof Options
16051 * @type {boolean}
16052 * @default false
16053 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
16054 * @example
16055 * data: {
16056 * stack: {
16057 * normalize: true
16058 * }
16059 * }
16060 */
16061 data_stack_normalize: !1
16062});
16063;// CONCATENATED MODULE: ./src/config/Options/axis/x.ts
16064/**
16065 * Copyright (c) 2017 ~ present NAVER Corp.
16066 * billboard.js project is licensed under the MIT license
16067 */
16068/**
16069 * x Axis config options
16070 */
16071/* harmony default export */ var axis_x = ({
16072 /**
16073 * Set clip-path attribute for x axis element
16074 * @name axis․x․clipPath
16075 * @memberof Options
16076 * @type {boolean}
16077 * @default true
16078 * @see [Demo]()
16079 * @example
16080 * // don't set 'clip-path' attribute
16081 * clipPath: false
16082 */
16083 axis_x_clipPath: !0,
16084 /**
16085 * Show or hide x axis.
16086 * @name axis․x․show
16087 * @memberof Options
16088 * @type {boolean}
16089 * @default true
16090 * @example
16091 * axis: {
16092 * x: {
16093 * show: false
16094 * }
16095 * }
16096 */
16097 axis_x_show: !0,
16098 /**
16099 * Set type of x axis.<br><br>
16100 * **Available Values:**
16101 * - category
16102 * - indexed
16103 * - log
16104 * - timeseries
16105 *
16106 * **NOTE:**<br>
16107 * - **log** type:
16108 * - the x values specified by [`data.x`](#.data%25E2%2580%25A4x)(or by any equivalent option), must be exclusively-positive.
16109 * - x axis min value should be >= 0.
16110 *
16111 * @name axis․x․type
16112 * @memberof Options
16113 * @type {string}
16114 * @default indexed
16115 * @see [Demo: indexed](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
16116 * @see [Demo: timeseries](https://naver.github.io/billboard.js/demo/#Chart.TimeseriesChart)
16117 * @see [Demo: category](https://naver.github.io/billboard.js/demo/#Data.CategoryData)
16118 * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
16119 * @example
16120 * axis: {
16121 * x: {
16122 * type: "timeseries"
16123 * }
16124 * }
16125 */
16126 axis_x_type: "indexed",
16127 /**
16128 * Set how to treat the timezone of x values.<br>
16129 * If true, treat x value as localtime. If false, convert to UTC internally.
16130 * @name axis․x․localtime
16131 * @memberof Options
16132 * @type {boolean}
16133 * @default true
16134 * @example
16135 * axis: {
16136 * x: {
16137 * localtime: false
16138 * }
16139 * }
16140 */
16141 axis_x_localtime: !0,
16142 /**
16143 * Set category names on category axis.
16144 * This must be an array that includes category names in string. If category names are included in the date by data.x option, this is not required.
16145 * @name axis․x․categories
16146 * @memberof Options
16147 * @type {Array}
16148 * @default []
16149 * @example
16150 * axis: {
16151 * x: {
16152 * categories: ["Category 1", "Category 2", ...]
16153 * }
16154 * }
16155 */
16156 axis_x_categories: [],
16157 /**
16158 * centerize ticks on category axis.
16159 * @name axis․x․tick․centered
16160 * @memberof Options
16161 * @type {boolean}
16162 * @default false
16163 * @example
16164 * axis: {
16165 * x: {
16166 * tick: {
16167 * centered: true
16168 * }
16169 * }
16170 * }
16171 */
16172 axis_x_tick_centered: !1,
16173 /**
16174 * A function to format tick value. Format string is also available for timeseries data.
16175 * @name axis․x․tick․format
16176 * @memberof Options
16177 * @type {Function|string}
16178 * @default undefined
16179 * @see [D3's time specifier](https://github.com/d3/d3-time-format#locale_format)
16180 * @example
16181 * axis: {
16182 * x: {
16183 * tick: {
16184 * // for timeseries, a 'datetime' object is given as parameter
16185 * format: function(x) {
16186 * return x.getFullYear();
16187 * }
16188 *
16189 * // for category, index(Number) and categoryName(String) are given as parameter
16190 * format: function(index, categoryName) {
16191 * return categoryName.substr(0, 10);
16192 * },
16193 *
16194 * // for timeseries format specifier
16195 * format: "%Y-%m-%d %H:%M:%S"
16196 * }
16197 * }
16198 * }
16199 */
16200 axis_x_tick_format: undefined,
16201 /**
16202 * Setting for culling ticks.
16203 * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
16204 * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.x.tick.culling.lines=false`.
16205 * - `false`: all of ticks will be shown.<br><br>
16206 * The number of ticks to be shown can be chaned by `axis.x.tick.culling.max`.
16207 * @name axis․x․tick․culling
16208 * @memberof Options
16209 * @type {boolean}
16210 * @default
16211 * `true` for indexed axis and timeseries axis, `false` for category axis
16212 * @example
16213 * axis: {
16214 * x: {
16215 * tick: {
16216 * culling: false
16217 * }
16218 * }
16219 * }
16220 */
16221 axis_x_tick_culling: {},
16222 /**
16223 * The number of tick texts will be adjusted to less than this value.
16224 * @name axis․x․tick․culling․max
16225 * @memberof Options
16226 * @type {number}
16227 * @default 10
16228 * @example
16229 * axis: {
16230 * x: {
16231 * tick: {
16232 * culling: {
16233 * max: 5
16234 * }
16235 * }
16236 * }
16237 * }
16238 */
16239 axis_x_tick_culling_max: 10,
16240 /**
16241 * Control visibility of tick lines within culling option, along with tick text.
16242 * @name axis․x․tick․culling․lines
16243 * @memberof Options
16244 * @type {boolean}
16245 * @default true
16246 * @example
16247 * axis: {
16248 * x: {
16249 * tick: {
16250 * culling: {
16251 * lines: false,
16252 * }
16253 * }
16254 * }
16255 * }
16256 */
16257 axis_x_tick_culling_lines: !0,
16258 /**
16259 * The number of x axis ticks to show.<br><br>
16260 * This option hides tick lines together with tick text. If this option is used on timeseries axis, the ticks position will be determined precisely and not nicely positioned (e.g. it will have rough second value).
16261 * @name axis․x․tick․count
16262 * @memberof Options
16263 * @type {number}
16264 * @default undefined
16265 * @example
16266 * axis: {
16267 * x: {
16268 * tick: {
16269 * count: 5
16270 * }
16271 * }
16272 * }
16273 */
16274 axis_x_tick_count: undefined,
16275 /**
16276 * Show or hide x axis tick line.
16277 * @name axis․x․tick․show
16278 * @memberof Options
16279 * @type {boolean}
16280 * @default true
16281 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
16282 * @example
16283 * axis: {
16284 * x: {
16285 * tick: {
16286 * show: false
16287 * }
16288 * }
16289 * }
16290 */
16291 axis_x_tick_show: !0,
16292 /**
16293 * Show or hide x axis tick text.
16294 * @name axis․x․tick․text․show
16295 * @memberof Options
16296 * @type {boolean}
16297 * @default true
16298 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
16299 * @example
16300 * axis: {
16301 * x: {
16302 * tick: {
16303 * text: {
16304 * show: false
16305 * }
16306 * }
16307 * }
16308 * }
16309 */
16310 axis_x_tick_text_show: !0,
16311 /**
16312 * Set the x Axis tick text's position relatively its original position
16313 * @name axis․x․tick․text․position
16314 * @memberof Options
16315 * @type {object}
16316 * @default {x: 0, y:0}
16317 * @example
16318 * axis: {
16319 * x: {
16320 * tick: {
16321 * text: {
16322 * position: {
16323 * x: 10,
16324 * y: 10
16325 * }
16326 * }
16327 * }
16328 * }
16329 * }
16330 */
16331 axis_x_tick_text_position: {
16332 x: 0,
16333 y: 0
16334 },
16335 /**
16336 * Fit x axis ticks.
16337 * - **true**: ticks will be shown according to x value of the data points.
16338 * - **false**: ticks will be shown as to have same intervals.
16339 * @name axis․x․tick․fit
16340 * @memberof Options
16341 * @type {boolean}
16342 * @default true
16343 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickFitting)
16344 * @see [Demo: for timeseries zoom](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickTimeseries)
16345 * @example
16346 * axis: {
16347 * x: {
16348 * tick: {
16349 * fit: false
16350 * }
16351 * }
16352 * }
16353 */
16354 axis_x_tick_fit: !0,
16355 /**
16356 * Set the x values of ticks manually.<br><br>
16357 * If this option is provided, the position of the ticks will be determined based on those values.<br>
16358 * This option works with `timeseries` data and the x values will be parsed accoding to the type of the value and data.xFormat option.
16359 * @name axis․x․tick․values
16360 * @memberof Options
16361 * @type {Array|Function}
16362 * @default null
16363 * @example
16364 * axis: {
16365 * x: {
16366 * tick: {
16367 * values: [1, 2, 4, 8, 16, 32, ...],
16368 *
16369 * // an Array value should be returned
16370 * values: function() {
16371 * return [ ... ];
16372 * }
16373 * }
16374 * }
16375 * }
16376 */
16377 axis_x_tick_values: null,
16378 /**
16379 * Rotate x axis tick text if there is not enough space for 'category' and 'timeseries' type axis.
16380 * - **NOTE:** The conditions where `autorotate` is enabled are:
16381 * - axis.x.type='category' or 'timeseries
16382 * - axis.x.tick.multiline=false
16383 * - axis.x.tick.culling=false
16384 * - axis.x.tick.fit=true
16385 * - **NOTE:** axis.x.tick.clippath=false is necessary for calculating the overflow padding between the end of x axis and the width of the SVG
16386 * @name axis․x․tick․autorotate
16387 * @memberof Options
16388 * @type {boolean}
16389 * @default false
16390 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickAutorotate)
16391 * @example
16392 * axis: {
16393 * x: {
16394 * tick: {
16395 * rotate: 15,
16396 * autorotate: true,
16397 * multiline: false,
16398 * culling: false,
16399 * fit: true
16400 * },
16401 * clipPath: false
16402 * }
16403 * }
16404 */
16405 axis_x_tick_autorotate: !1,
16406 /**
16407 * Rotate x axis tick text.
16408 * - If you set negative value, it will rotate to opposite direction.
16409 * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `false`.
16410 * - As long as `axis_x_tick_fit` is set to `true` it will calculate an overflow for the y2 axis and add this value to the right padding.
16411 * @name axis․x․tick․rotate
16412 * @memberof Options
16413 * @type {number}
16414 * @default 0
16415 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.RotateXAxisTickText)
16416 * @example
16417 * axis: {
16418 * x: {
16419 * tick: {
16420 * rotate: 60
16421 * }
16422 * }
16423 * }
16424 */
16425 axis_x_tick_rotate: 0,
16426 /**
16427 * Show x axis outer tick.
16428 * @name axis․x․tick․outer
16429 * @memberof Options
16430 * @type {boolean}
16431 * @default true
16432 * @example
16433 * axis: {
16434 * x: {
16435 * tick: {
16436 * outer: false
16437 * }
16438 * }
16439 * }
16440 */
16441 axis_x_tick_outer: !0,
16442 /**
16443 * Set tick text to be multiline
16444 * - **NOTE:**
16445 * > When x tick text contains `\n`, it's used as line break and 'axis.x.tick.width' option is ignored.
16446 * @name axis․x․tick․multiline
16447 * @memberof Options
16448 * @type {boolean}
16449 * @default true
16450 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickMultiline)
16451 * @example
16452 * axis: {
16453 * x: {
16454 * tick: {
16455 * multiline: false
16456 * }
16457 * }
16458 * }
16459 * @example
16460 * // example of line break with '\n'
16461 * // In this case, 'axis.x.tick.width' is ignored
16462 * data: {
16463 * x: "x",
16464 * columns: [
16465 * ["x", "long\ntext", "Another\nLong\nText"],
16466 * ...
16467 * ],
16468 * }
16469 */
16470 axis_x_tick_multiline: !0,
16471 /**
16472 * Set tick width
16473 * - **NOTE:**
16474 * > When x tick text contains `\n`, this option is ignored.
16475 * @name axis․x․tick․width
16476 * @memberof Options
16477 * @type {number}
16478 * @default null
16479 * @example
16480 * axis: {
16481 * x: {
16482 * tick: {
16483 * width: 50
16484 * }
16485 * }
16486 * }
16487 */
16488 axis_x_tick_width: null,
16489 /**
16490 * Set to display system tooltip(via 'title' attribute) for tick text
16491 * - **NOTE:** Only available for category axis type (`axis.x.type='category'`)
16492 * @name axis․x․tick․tooltip
16493 * @memberof Options
16494 * @type {boolean}
16495 * @default false
16496 * @example
16497 * axis: {
16498 * x: {
16499 * tick: {
16500 * tooltip: true
16501 * }
16502 * }
16503 * }
16504 */
16505 axis_x_tick_tooltip: !1,
16506 /**
16507 * Set max value of x axis range.
16508 * @name axis․x․max
16509 * @memberof Options
16510 * @property {number} max Set the max value
16511 * @property {boolean} [max.fit=false] When specified `max.value` is greater than the bound data value, setting `true` will make x axis max to be fitted to the bound data max value.
16512 * - **NOTE:** If the bound data max value is greater than the `max.value`, the x axis max will be limited as the given `max.value`.
16513 * @property {number} [max.value] Set the max value
16514 * @example
16515 * axis: {
16516 * x: {
16517 * max: 100,
16518 *
16519 * max: {
16520 * // 'fit=true' will make x axis max to be limited as the bound data value max when 'max.value' is greater.
16521 * // - when bound data max is '10' and max.value: '100' ==> x axis max will be '10'
16522 * // - when bound data max is '1000' and max.value: '100' ==> x axis max will be '100'
16523 * fit: true,
16524 * value: 100
16525 * }
16526 * }
16527 * }
16528 */
16529 axis_x_max: undefined,
16530 /**
16531 * Set min value of x axis range.
16532 * @name axis․x․min
16533 * @memberof Options
16534 * @property {number} min Set the min value
16535 * @property {boolean} [min.fit=false] When specified `min.value` is lower than the bound data value, setting `true` will make x axis min to be fitted to the bound data min value.
16536 * - **NOTE:** If the bound data min value is lower than the `min.value`, the x axis min will be limited as the given `min.value`.
16537 * @property {number} [min.value] Set the min value
16538 * @example
16539 * axis: {
16540 * x: {
16541 * min: -100,
16542 *
16543 * min: {
16544 * // 'fit=true' will make x axis min to be limited as the bound data value min when 'min.value' is lower.
16545 * // - when bound data min is '-10' and min.value: '-100' ==> x axis min will be '-10'
16546 * // - when bound data min is '-1000' and min.value: '-100' ==> x axis min will be '-100'
16547 * fit: true,
16548 * value: -100
16549 * }
16550 * }
16551 * }
16552 */
16553 axis_x_min: undefined,
16554 /**
16555 * Set padding for x axis.<br><br>
16556 * If this option is set, the range of x axis will increase/decrease according to the values.
16557 * If no padding is needed in the rage of x axis, 0 should be set.
16558 * By default, left/right padding are set depending on x axis type or chart types.
16559 * - **NOTE:**
16560 * - The meaning of padding values, differs according axis types:<br>
16561 * - **category/indexed:** The unit of tick value
16562 * ex. the given value `1`, is same as the width of 1 tick width
16563 * - **timeseries:** Numeric time value
16564 * ex. the given value `1000*60*60*24`, which is numeric time equivalent of a day, is same as the width of 1 tick width
16565 * - If want values to be treated as pixels, specify `unit:"px"`.
16566 * - The pixel value will be convered based on the scale values. Hence can not reflect accurate padding result.
16567 * @name axis․x․padding
16568 * @memberof Options
16569 * @type {object|number}
16570 * @default {}
16571 * @example
16572 * axis: {
16573 * x: {
16574 * padding: {
16575 * // when axis type is 'category'
16576 * left: 1, // set left padding width of equivalent value of a tick's width
16577 * right: 0.5 // set right padding width as half of equivalent value of tick's width
16578 *
16579 * // when axis type is 'timeseries'
16580 * left: 1000*60*60*24, // set left padding width of equivalent value of a day tick's width
16581 * right: 1000*60*60*12 // set right padding width as half of equivalent value of a day tick's width
16582 * },
16583 *
16584 * // or set both values at once.
16585 * padding: 10,
16586 *
16587 * // or set padding values as pixel unit.
16588 * padding: {
16589 * left: 100,
16590 * right: 50,
16591 * unit: "px"
16592 * },
16593 * }
16594 * }
16595 */
16596 axis_x_padding: {},
16597 /**
16598 * Set height of x axis.<br><br>
16599 * The height of x axis can be set manually by this option. If you need more space for x axis, please use this option for that. The unit is pixel.
16600 * @name axis․x․height
16601 * @memberof Options
16602 * @type {number}
16603 * @default undefined
16604 * @example
16605 * axis: {
16606 * x: {
16607 * height: 20
16608 * }
16609 * }
16610 */
16611 axis_x_height: undefined,
16612 /**
16613 * Set default extent for subchart and zoom. This can be an array or function that returns an array.
16614 * @name axis․x․extent
16615 * @memberof Options
16616 * @type {Array|Function}
16617 * @default undefined
16618 * @example
16619 * axis: {
16620 * x: {
16621 * // extent range as a pixel value
16622 * extent: [0, 200],
16623 *
16624 * // when axis is 'timeseries', parsable datetime string
16625 * extent: ["2019-03-01", "2019-03-05"],
16626 *
16627 * // return extent value
16628 * extent: function(domain, scale) {
16629 * var extent = domain.map(function(v) {
16630 * return scale(v);
16631 * });
16632 *
16633 * // it should return a format of array
16634 * // ex) [0, 584]
16635 * return extent;
16636 * }
16637 * }
16638 * }
16639 */
16640 axis_x_extent: undefined,
16641 /**
16642 * Set label on x axis.<br><br>
16643 * You can set x axis label and change its position by this option.
16644 * `string` and `object` can be passed and we can change the poisiton by passing object that has position key.<br>
16645 * Available position differs according to the axis direction (vertical or horizontal).
16646 * If string set, the position will be the default.
16647 *
16648 * - **If it's horizontal axis:**
16649 * - inner-right [default]
16650 * - inner-center
16651 * - inner-left
16652 * - outer-right
16653 * - outer-center
16654 * - outer-left
16655 * - **If it's vertical axis:**
16656 * - inner-top [default]
16657 * - inner-middle
16658 * - inner-bottom
16659 * - outer-top
16660 * - outer-middle
16661 * - outer-bottom
16662 * @name axis․x․label
16663 * @memberof Options
16664 * @type {string|object}
16665 * @default undefined
16666 * @example
16667 * axis: {
16668 * x: {
16669 * label: "Your X Axis"
16670 * }
16671 * }
16672 *
16673 * axis: {
16674 * x: {
16675 * label: {
16676 * text: "Your X Axis",
16677 * position: "outer-center"
16678 * }
16679 * }
16680 * }
16681 */
16682 axis_x_label: {},
16683 /**
16684 * Set additional axes for x Axis.
16685 * - **NOTE:** Axis' scale is based on x Axis value if domain option isn't set.
16686 *
16687 * Each axis object should consist with following options:
16688 *
16689 * | Name | Type | Default | Description |
16690 * | --- | --- | --- | --- |
16691 * | domain | Array | - | Set the domain value |
16692 * | tick.outer | boolean | true | Show outer tick |
16693 * | tick.format | Function | - | Set formatter for tick text |
16694 * | tick.count | Number | - | Set the number of y axis ticks |
16695 * | tick.values | Array | - | Set tick values manually |
16696 * @name axis․x․axes
16697 * @memberof Options
16698 * @type {Array}
16699 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
16700 * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
16701 * @example
16702 * x: {
16703 * axes: [
16704 * {
16705 * // if set, will not be correlated with the main x Axis domain value
16706 * domain: [0, 1000],
16707 * tick: {
16708 * outer: false,
16709 * format: function(x) {
16710 * return x + "%";
16711 * },
16712 * count: 2,
16713 * values: [10, 20, 30]
16714 * }
16715 * },
16716 * ...
16717 * ]
16718 * }
16719 */
16720 axis_x_axes: []
16721});
16722;// CONCATENATED MODULE: ./src/config/Options/axis/y.ts
16723/**
16724 * Copyright (c) 2017 ~ present NAVER Corp.
16725 * billboard.js project is licensed under the MIT license
16726 */
16727/**
16728 * y Axis config options
16729 */
16730/* harmony default export */ var y = ({
16731 /**
16732 * Set clip-path attribute for y axis element
16733 * - **NOTE**: `clip-path` attribute for y Axis is set only when `axis.y.inner` option is true.
16734 * @name axis․y․clipPath
16735 * @memberof Options
16736 * @type {boolean}
16737 * @default true
16738 * @example
16739 * // don't set 'clip-path' attribute
16740 * clipPath: false
16741 */
16742 axis_y_clipPath: !0,
16743 /**
16744 * Show or hide y axis.
16745 * @name axis․y․show
16746 * @memberof Options
16747 * @type {boolean}
16748 * @default true
16749 * @example
16750 * axis: {
16751 * y: {
16752 * show: false
16753 * }
16754 * }
16755 */
16756 axis_y_show: !0,
16757 /**
16758 * Set type of y axis.<br><br>
16759 * **Available Values:**
16760 * - indexed
16761 * - log
16762 * - timeseries
16763 *
16764 * **NOTE:**<br>
16765 * - **log** type:
16766 * - the bound data values must be exclusively-positive.
16767 * - y axis min value should be >= 0.
16768 * - [`data.groups`](#.data%25E2%2580%25A4groups)(stacked data) option aren't supported.
16769 *
16770 * @name axis․y․type
16771 * @memberof Options
16772 * @type {string}
16773 * @default "indexed"
16774 * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
16775 * @example
16776 * axis: {
16777 * y: {
16778 * type: "log"
16779 * }
16780 * }
16781 */
16782 axis_y_type: "indexed",
16783 /**
16784 * Set max value of y axis.
16785 * - **NOTE:** Padding will be added based on this value, so if you don't need the padding, please set axis.y.padding to disable it (e.g. axis.y.padding = 0).
16786 * @name axis․y․max
16787 * @memberof Options
16788 * @type {number}
16789 * @default undefined
16790 * @example
16791 * axis: {
16792 * y: {
16793 * max: 1000
16794 * }
16795 * }
16796 */
16797 axis_y_max: undefined,
16798 /**
16799 * Set min value of y axis.
16800 * - **NOTE:**
16801 * Padding will be added based on this value, so if you don't need the padding, please set axis.y.padding to disable it (e.g. axis.y.padding = 0).
16802 * @name axis․y․min
16803 * @memberof Options
16804 * @type {number}
16805 * @default undefined
16806 * @example
16807 * axis: {
16808 * y: {
16809 * min: 1000
16810 * }
16811 * }
16812 */
16813 axis_y_min: undefined,
16814 /**
16815 * Change the direction of y axis.<br><br>
16816 * If true set, the direction will be from the top to the bottom.
16817 * @name axis․y․inverted
16818 * @memberof Options
16819 * @type {boolean}
16820 * @default false
16821 * @example
16822 * axis: {
16823 * y: {
16824 * inverted: true
16825 * }
16826 * }
16827 */
16828 axis_y_inverted: !1,
16829 /**
16830 * Set center value of y axis.
16831 * @name axis․y․center
16832 * @memberof Options
16833 * @type {number}
16834 * @default undefined
16835 * @example
16836 * axis: {
16837 * y: {
16838 * center: 0
16839 * }
16840 * }
16841 */
16842 axis_y_center: undefined,
16843 /**
16844 * Show y axis inside of the chart.
16845 * @name axis․y․inner
16846 * @memberof Options
16847 * @type {boolean}
16848 * @default false
16849 * @example
16850 * axis: {
16851 * y: {
16852 * inner: true
16853 * }
16854 * }
16855 */
16856 axis_y_inner: !1,
16857 /**
16858 * Set label on y axis.<br><br>
16859 * You can set y axis label and change its position by this option. This option works in the same way as [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label).
16860 * @name axis․y․label
16861 * @memberof Options
16862 * @type {string|object}
16863 * @default {}
16864 * @see [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label) for position string value.
16865 * @example
16866 * axis: {
16867 * y: {
16868 * label: "Your Y Axis"
16869 * }
16870 * }
16871 *
16872 * axis: {
16873 * y: {
16874 * label: {
16875 * text: "Your Y Axis",
16876 * position: "outer-middle"
16877 * }
16878 * }
16879 * }
16880 */
16881 axis_y_label: {},
16882 /**
16883 * Set formatter for y axis tick text.<br><br>
16884 * This option accepts d3.format object as well as a function you define.
16885 * @name axis․y․tick․format
16886 * @memberof Options
16887 * @type {Function}
16888 * @default undefined
16889 * @example
16890 * axis: {
16891 * y: {
16892 * tick: {
16893 * format: function(x) {
16894 * return x.getFullYear();
16895 * }
16896 * }
16897 * }
16898 * }
16899 */
16900 axis_y_tick_format: undefined,
16901 /**
16902 * Setting for culling ticks.
16903 * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
16904 * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.y.tick.culling.lines=false`.
16905 * - `false`: all of ticks will be shown.<br><br>
16906 * The number of ticks to be shown can be chaned by `axis.y.tick.culling.max`.
16907 * @name axis․y․tick․culling
16908 * @memberof Options
16909 * @type {boolean}
16910 * @default false
16911 * @example
16912 * axis: {
16913 * y: {
16914 * tick: {
16915 * culling: false
16916 * }
16917 * }
16918 * }
16919 */
16920 axis_y_tick_culling: !1,
16921 /**
16922 * The number of tick texts will be adjusted to less than this value.
16923 * @name axis․y․tick․culling․max
16924 * @memberof Options
16925 * @type {number}
16926 * @default 5
16927 * @example
16928 * axis: {
16929 * y: {
16930 * tick: {
16931 * culling: {
16932 * max: 5
16933 * }
16934 * }
16935 * }
16936 * }
16937 */
16938 axis_y_tick_culling_max: 5,
16939 /**
16940 * Control visibility of tick lines within culling option, along with tick text.
16941 * @name axis․y․tick․culling․lines
16942 * @memberof Options
16943 * @type {boolean}
16944 * @default true
16945 * @example
16946 * axis: {
16947 * y: {
16948 * tick: {
16949 * culling: {
16950 * lines: false,
16951 * }
16952 * }
16953 * }
16954 * }
16955 */
16956 axis_y_tick_culling_lines: !0,
16957 /**
16958 * Show y axis outer tick.
16959 * @name axis․y․tick․outer
16960 * @memberof Options
16961 * @type {boolean}
16962 * @default true
16963 * @example
16964 * axis: {
16965 * y: {
16966 * tick: {
16967 * outer: false
16968 * }
16969 * }
16970 * }
16971 */
16972 axis_y_tick_outer: !0,
16973 /**
16974 * Set y axis tick values manually.
16975 * @name axis․y․tick․values
16976 * @memberof Options
16977 * @type {Array|Function}
16978 * @default null
16979 * @example
16980 * axis: {
16981 * y: {
16982 * tick: {
16983 * values: [100, 1000, 10000],
16984 *
16985 * // an Array value should be returned
16986 * values: function() {
16987 * return [ ... ];
16988 * }
16989 * }
16990 * }
16991 * }
16992 */
16993 axis_y_tick_values: null,
16994 /**
16995 * Rotate y axis tick text.
16996 * - If you set negative value, it will rotate to opposite direction.
16997 * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `true`.
16998 * @name axis․y․tick․rotate
16999 * @memberof Options
17000 * @type {number}
17001 * @default 0
17002 * @example
17003 * axis: {
17004 * y: {
17005 * tick: {
17006 * rotate: 60
17007 * }
17008 * }
17009 * }
17010 */
17011 axis_y_tick_rotate: 0,
17012 /**
17013 * Set the number of y axis ticks.<br><br>
17014 * - **NOTE:** The position of the ticks will be calculated precisely, so the values on the ticks will not be rounded nicely. In the case, axis.y.tick.format or axis.y.tick.values will be helpful.
17015 * @name axis․y․tick․count
17016 * @memberof Options
17017 * @type {number}
17018 * @default undefined
17019 * @example
17020 * axis: {
17021 * y: {
17022 * tick: {
17023 * count: 5
17024 * }
17025 * }
17026 * }
17027 */
17028 axis_y_tick_count: undefined,
17029 /**
17030 * Show or hide y axis tick line.
17031 * @name axis․y․tick․show
17032 * @memberof Options
17033 * @type {boolean}
17034 * @default true
17035 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
17036 * @example
17037 * axis: {
17038 * y: {
17039 * tick: {
17040 * show: false
17041 * }
17042 * }
17043 * }
17044 */
17045 axis_y_tick_show: !0,
17046 /**
17047 * Set axis tick step(interval) size.
17048 * - **NOTE:** Will be ignored if `axis.y.tick.count` or `axis.y.tick.values` options are set.
17049 * @name axis․y․tick․stepSize
17050 * @memberof Options
17051 * @type {number}
17052 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.StepSizeForYAxis)
17053 * @example
17054 * axis: {
17055 * y: {
17056 * tick: {
17057 * // tick value will step as indicated interval value.
17058 * // ex) 'stepSize=15' ==> [0, 15, 30, 45, 60]
17059 * stepSize: 15
17060 * }
17061 * }
17062 * }
17063 */
17064 axis_y_tick_stepSize: null,
17065 /**
17066 * Show or hide y axis tick text.
17067 * @name axis․y․tick․text․show
17068 * @memberof Options
17069 * @type {boolean}
17070 * @default true
17071 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
17072 * @example
17073 * axis: {
17074 * y: {
17075 * tick: {
17076 * text: {
17077 * show: false
17078 * }
17079 * }
17080 * }
17081 * }
17082 */
17083 axis_y_tick_text_show: !0,
17084 /**
17085 * Set the y Axis tick text's position relatively its original position
17086 * @name axis․y․tick․text․position
17087 * @memberof Options
17088 * @type {object}
17089 * @default {x: 0, y:0}
17090 * @example
17091 * axis: {
17092 * y: {
17093 * tick: {
17094 * text: {
17095 * position: {
17096 * x: 10,
17097 * y: 10
17098 * }
17099 * }
17100 * }
17101 * }
17102 * }
17103 */
17104 axis_y_tick_text_position: {
17105 x: 0,
17106 y: 0
17107 },
17108 /**
17109 * Set the number of y axis ticks.<br><br>
17110 * - **NOTE:** The position of the ticks will be calculated precisely, so the values on the ticks will not be rounded nicely. In the case, axis.y.tick.format or axis.y.tick.values will be helpful.
17111 * @name axis․y․tick․time
17112 * @memberof Options
17113 * @private
17114 * @type {object}
17115 * @property {object} time time object
17116 * @property {Function} [time.value] D3's time interval function (https://github.com/d3/d3-time#intervals)
17117 * @example
17118 * axis: {
17119 * y: {
17120 * tick: {
17121 * time: {
17122 * // ticks at 15-minute intervals
17123 * // https://github.com/d3/d3-scale/blob/master/README.md#time_ticks
17124 * value: d3.timeMinute.every(15)
17125 * }
17126 * }
17127 * }
17128 * }
17129 */
17130 // @TODO: not fully implemented yet
17131 axis_y_tick_time_value: undefined,
17132 /**
17133 * Set padding for y axis.<br><br>
17134 * You can set padding for y axis to create more space on the edge of the axis.
17135 * This option accepts object and it can include top and bottom. top, bottom will be treated as pixels.
17136 *
17137 * - **NOTE:**
17138 * - Given values are translated relative to the y Axis domain value for padding
17139 * - For area and bar type charts, [area.zerobased](#.area) or [bar.zerobased](#.bar) options should be set to 'false` to get padded bottom.
17140 * @name axis․y․padding
17141 * @memberof Options
17142 * @type {object|number}
17143 * @default {}
17144 * @example
17145 * axis: {
17146 * y: {
17147 * padding: {
17148 * top: 0,
17149 * bottom: 0
17150 * },
17151 *
17152 * // or set both values at once.
17153 * padding: 10
17154 * }
17155 * }
17156 */
17157 axis_y_padding: {},
17158 /**
17159 * Set default range of y axis.<br><br>
17160 * This option set the default value for y axis when there is no data on init.
17161 * @name axis․y․default
17162 * @memberof Options
17163 * @type {Array}
17164 * @default undefined
17165 * @example
17166 * axis: {
17167 * y: {
17168 * default: [0, 1000]
17169 * }
17170 * }
17171 */
17172 axis_y_default: undefined,
17173 /**
17174 * Set additional axes for y Axis.
17175 * - **NOTE:** Axis' scale is based on y Axis value if domain option isn't set.
17176 *
17177 * Each axis object should consist with following options:
17178 *
17179 * | Name | Type | Default | Description |
17180 * | --- | --- | --- | --- |
17181 * | domain | Array | - | Set the domain value |
17182 * | tick.outer | boolean | true | Show outer tick |
17183 * | tick.format | Function | - | Set formatter for tick text |
17184 * | tick.count | Number | - | Set the number of y axis ticks |
17185 * | tick.values | Array | - | Set tick values manually |
17186 * @name axis․y․axes
17187 * @memberof Options
17188 * @type {Array}
17189 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
17190 * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
17191 * @example
17192 * y: {
17193 * axes: [
17194 * {
17195 * // if set, will not be correlated with the main y Axis domain value
17196 * domain: [0, 1000],
17197 * tick: {
17198 * outer: false,
17199 * format: function(x) {
17200 * return x + "%";
17201 * },
17202 * count: 2,
17203 * values: [10, 20, 30]
17204 * }
17205 * },
17206 * ...
17207 * ]
17208 * }
17209 */
17210 axis_y_axes: []
17211});
17212;// CONCATENATED MODULE: ./src/config/Options/axis/y2.ts
17213/**
17214 * Copyright (c) 2017 ~ present NAVER Corp.
17215 * billboard.js project is licensed under the MIT license
17216 */
17217/**
17218 * y2 Axis config options
17219 */
17220/* harmony default export */ var y2 = ({
17221 /**
17222 * Show or hide y2 axis.
17223 * - **NOTE**:
17224 * - When set to `false` will not generate y2 axis node. In this case, all 'y2' axis related functionality won't work properly.
17225 * - If need to use 'y2' related options while y2 isn't visible, set the value `true` and control visibility by css display property.
17226 * @name axis․y2․show
17227 * @memberof Options
17228 * @type {boolean}
17229 * @default false
17230 * @example
17231 * axis: {
17232 * y2: {
17233 * show: true
17234 * }
17235 * }
17236 */
17237 axis_y2_show: !1,
17238 /**
17239 * Set type of y2 axis.<br><br>
17240 * **Available Values:**
17241 * - indexed
17242 * - log
17243 * - timeseries
17244 *
17245 * **NOTE:**<br>
17246 * - **log** type:
17247 * - the bound data values must be exclusively-positive.
17248 * - y2 axis min value should be >= 0.
17249 * - [`data.groups`](#.data%25E2%2580%25A4groups)(stacked data) option aren't supported.
17250 *
17251 * @name axis․y2․type
17252 * @memberof Options
17253 * @type {string}
17254 * @default "indexed"
17255 * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
17256 * @example
17257 * axis: {
17258 * y2: {
17259 * type: "indexed"
17260 * }
17261 * }
17262 */
17263 axis_y2_type: "indexed",
17264 /**
17265 * Set max value of y2 axis.
17266 * @name axis․y2․max
17267 * @memberof Options
17268 * @type {number}
17269 * @default undefined
17270 * @example
17271 * axis: {
17272 * y2: {
17273 * max: 1000
17274 * }
17275 * }
17276 */
17277 axis_y2_max: undefined,
17278 /**
17279 * Set min value of y2 axis.
17280 * @name axis․y2․min
17281 * @memberof Options
17282 * @type {number}
17283 * @default undefined
17284 * @example
17285 * axis: {
17286 * y2: {
17287 * min: -1000
17288 * }
17289 * }
17290 */
17291 axis_y2_min: undefined,
17292 /**
17293 * Change the direction of y2 axis.<br><br>
17294 * If true set, the direction will be from the top to the bottom.
17295 * @name axis․y2․inverted
17296 * @memberof Options
17297 * @type {boolean}
17298 * @default false
17299 * @example
17300 * axis: {
17301 * y2: {
17302 * inverted: true
17303 * }
17304 * }
17305 */
17306 axis_y2_inverted: !1,
17307 /**
17308 * Set center value of y2 axis.
17309 * @name axis․y2․center
17310 * @memberof Options
17311 * @type {number}
17312 * @default undefined
17313 * @example
17314 * axis: {
17315 * y2: {
17316 * center: 0
17317 * }
17318 * }
17319 */
17320 axis_y2_center: undefined,
17321 /**
17322 * Show y2 axis inside of the chart.
17323 * @name axis․y2․inner
17324 * @memberof Options
17325 * @type {boolean}
17326 * @default false
17327 * @example
17328 * axis: {
17329 * y2: {
17330 * inner: true
17331 * }
17332 * }
17333 */
17334 axis_y2_inner: !1,
17335 /**
17336 * Set label on y2 axis.<br><br>
17337 * You can set y2 axis label and change its position by this option. This option works in the same way as [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label).
17338 * @name axis․y2․label
17339 * @memberof Options
17340 * @type {string|object}
17341 * @default {}
17342 * @see [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label) for position string value.
17343 * @example
17344 * axis: {
17345 * y2: {
17346 * label: "Your Y2 Axis"
17347 * }
17348 * }
17349 *
17350 * axis: {
17351 * y2: {
17352 * label: {
17353 * text: "Your Y2 Axis",
17354 * position: "outer-middle"
17355 * }
17356 * }
17357 * }
17358 */
17359 axis_y2_label: {},
17360 /**
17361 * Set formatter for y2 axis tick text.<br><br>
17362 * This option works in the same way as axis.y.format.
17363 * @name axis․y2․tick․format
17364 * @memberof Options
17365 * @type {Function}
17366 * @default undefined
17367 * @example
17368 * axis: {
17369 * y2: {
17370 * tick: {
17371 * format: d3.format("$,")
17372 * //or format: function(d) { return "$" + d; }
17373 * }
17374 * }
17375 * }
17376 */
17377 axis_y2_tick_format: undefined,
17378 /**
17379 * Setting for culling ticks.
17380 * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
17381 * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.y2.tick.culling.lines=false`.
17382 * - `false`: all of ticks will be shown.<br><br>
17383 * The number of ticks to be shown can be chaned by `axis.y2.tick.culling.max`.
17384 * @name axis․y2․tick․culling
17385 * @memberof Options
17386 * @type {boolean}
17387 * @default false
17388 * @example
17389 * axis: {
17390 * y2: {
17391 * tick: {
17392 * culling: false
17393 * }
17394 * }
17395 * }
17396 */
17397 axis_y2_tick_culling: !1,
17398 /**
17399 * The number of tick texts will be adjusted to less than this value.
17400 * @name axis․y2․tick․culling․max
17401 * @memberof Options
17402 * @type {number}
17403 * @default 5
17404 * @example
17405 * axis: {
17406 * y2: {
17407 * tick: {
17408 * culling: {
17409 * max: 5
17410 * }
17411 * }
17412 * }
17413 * }
17414 */
17415 axis_y2_tick_culling_max: 5,
17416 /**
17417 * Control visibility of tick lines within culling option, along with tick text.
17418 * @name axis․y2․tick․culling․lines
17419 * @memberof Options
17420 * @type {boolean}
17421 * @default true
17422 * @example
17423 * axis: {
17424 * y2: {
17425 * tick: {
17426 * culling: {
17427 * lines: false,
17428 * }
17429 * }
17430 * }
17431 * }
17432 */
17433 axis_y2_tick_culling_lines: !0,
17434 /**
17435 * Show or hide y2 axis outer tick.
17436 * @name axis․y2․tick․outer
17437 * @memberof Options
17438 * @type {boolean}
17439 * @default true
17440 * @example
17441 * axis: {
17442 * y2: {
17443 * tick: {
17444 * outer: false
17445 * }
17446 * }
17447 * }
17448 */
17449 axis_y2_tick_outer: !0,
17450 /**
17451 * Set y2 axis tick values manually.
17452 * @name axis․y2․tick․values
17453 * @memberof Options
17454 * @type {Array|Function}
17455 * @default null
17456 * @example
17457 * axis: {
17458 * y2: {
17459 * tick: {
17460 * values: [100, 1000, 10000],
17461 *
17462 * // an Array value should be returned
17463 * values: function() {
17464 * return [ ... ];
17465 * }
17466 * }
17467 * }
17468 * }
17469 */
17470 axis_y2_tick_values: null,
17471 /**
17472 * Rotate y2 axis tick text.
17473 * - If you set negative value, it will rotate to opposite direction.
17474 * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `true`.
17475 * @name axis․y2․tick․rotate
17476 * @memberof Options
17477 * @type {number}
17478 * @default 0
17479 * @example
17480 * axis: {
17481 * y2: {
17482 * tick: {
17483 * rotate: 60
17484 * }
17485 * }
17486 * }
17487 */
17488 axis_y2_tick_rotate: 0,
17489 /**
17490 * Set the number of y2 axis ticks.
17491 * - **NOTE:** This works in the same way as axis.y.tick.count.
17492 * @name axis․y2․tick․count
17493 * @memberof Options
17494 * @type {number}
17495 * @default undefined
17496 * @example
17497 * axis: {
17498 * y2: {
17499 * tick: {
17500 * count: 5
17501 * }
17502 * }
17503 * }
17504 */
17505 axis_y2_tick_count: undefined,
17506 /**
17507 * Show or hide y2 axis tick line.
17508 * @name axis․y2․tick․show
17509 * @memberof Options
17510 * @type {boolean}
17511 * @default true
17512 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
17513 * @example
17514 * axis: {
17515 * y2: {
17516 * tick: {
17517 * show: false
17518 * }
17519 * }
17520 * }
17521 */
17522 axis_y2_tick_show: !0,
17523 /**
17524 * Set axis tick step(interval) size.
17525 * - **NOTE:** Will be ignored if `axis.y2.tick.count` or `axis.y2.tick.values` options are set.
17526 * @name axis․y2․tick․stepSize
17527 * @memberof Options
17528 * @type {number}
17529 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.StepSizeForYAxis)
17530 * @example
17531 * axis: {
17532 * y2: {
17533 * tick: {
17534 * // tick value will step as indicated interval value.
17535 * // ex) 'stepSize=15' ==> [0, 15, 30, 45, 60]
17536 * stepSize: 15
17537 * }
17538 * }
17539 * }
17540 */
17541 axis_y2_tick_stepSize: null,
17542 /**
17543 * Show or hide y2 axis tick text.
17544 * @name axis․y2․tick․text․show
17545 * @memberof Options
17546 * @type {boolean}
17547 * @default true
17548 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
17549 * @example
17550 * axis: {
17551 * y2: {
17552 * tick: {
17553 * text: {
17554 * show: false
17555 * }
17556 * }
17557 * }
17558 * }
17559 */
17560 axis_y2_tick_text_show: !0,
17561 /**
17562 * Set the y2 Axis tick text's position relatively its original position
17563 * @name axis․y2․tick․text․position
17564 * @memberof Options
17565 * @type {object}
17566 * @default {x: 0, y:0}
17567 * @example
17568 * axis: {
17569 * y2: {
17570 * tick: {
17571 * text: {
17572 * position: {
17573 * x: 10,
17574 * y: 10
17575 * }
17576 * }
17577 * }
17578 * }
17579 * }
17580 */
17581 axis_y2_tick_text_position: {
17582 x: 0,
17583 y: 0
17584 },
17585 /**
17586 * Set padding for y2 axis.<br><br>
17587 * You can set padding for y2 axis to create more space on the edge of the axis.
17588 * This option accepts object and it can include top and bottom. top, bottom will be treated as pixels.
17589 *
17590 * - **NOTE:**
17591 * - Given values are translated relative to the y2 Axis domain value for padding
17592 * - For area and bar type charts, [area.zerobased](#.area) or [bar.zerobased](#.bar) options should be set to 'false` to get padded bottom.
17593 * @name axis․y2․padding
17594 * @memberof Options
17595 * @type {object|number}
17596 * @default {}
17597 * @example
17598 * axis: {
17599 * y2: {
17600 * padding: {
17601 * top: 100,
17602 * bottom: 100
17603 * }
17604 *
17605 * // or set both values at once.
17606 * padding: 10
17607 * }
17608 */
17609 axis_y2_padding: {},
17610 /**
17611 * Set default range of y2 axis.<br><br>
17612 * This option set the default value for y2 axis when there is no data on init.
17613 * @name axis․y2․default
17614 * @memberof Options
17615 * @type {Array}
17616 * @default undefined
17617 * @example
17618 * axis: {
17619 * y2: {
17620 * default: [0, 1000]
17621 * }
17622 * }
17623 */
17624 axis_y2_default: undefined,
17625 /**
17626 * Set additional axes for y2 Axis.
17627 * - **NOTE:** Axis' scale is based on y2 Axis value if domain option isn't set.
17628 *
17629 * Each axis object should consist with following options:
17630 *
17631 * | Name | Type | Default | Description |
17632 * | --- | --- | --- | --- |
17633 * | domain | Array | - | Set the domain value |
17634 * | tick.outer | boolean | true | Show outer tick |
17635 * | tick.format | Function | - | Set formatter for tick text |
17636 * | tick.count | Number | - | Set the number of y axis ticks |
17637 * | tick.values | Array | - | Set tick values manually |
17638 * @name axis․y2․axes
17639 * @memberof Options
17640 * @type {Array}
17641 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
17642 * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
17643 * @example
17644 * y2: {
17645 * axes: [
17646 * {
17647 * // if set, will not be correlated with the main y2 Axis domain value
17648 * domain: [0, 1000],
17649 * tick: {
17650 * outer: false,
17651 * format: function(x) {
17652 * return x + "%";
17653 * },
17654 * count: 2,
17655 * values: [10, 20, 30]
17656 * }
17657 * },
17658 * ...
17659 * ]
17660 * }
17661 */
17662 axis_y2_axes: []
17663});
17664;// CONCATENATED MODULE: ./src/config/Options/axis/axis.ts
17665
17666function axis_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17667function axis_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? axis_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : axis_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17668/**
17669 * Copyright (c) 2017 ~ present NAVER Corp.
17670 * billboard.js project is licensed under the MIT license
17671 */
17672
17673
17674
17675
17676/**
17677 * y Axis config options
17678 */
17679/* harmony default export */ var axis_axis = (axis_objectSpread(axis_objectSpread(axis_objectSpread({
17680 /**
17681 * Switch x and y axis position.
17682 * @name axis․rotated
17683 * @memberof Options
17684 * @type {boolean}
17685 * @default false
17686 * @example
17687 * axis: {
17688 * rotated: true
17689 * }
17690 */
17691 axis_rotated: !1
17692}, axis_x), y), y2));
17693;// CONCATENATED MODULE: ./src/config/Options/common/grid.ts
17694/**
17695 * Copyright (c) 2017 ~ present NAVER Corp.
17696 * billboard.js project is licensed under the MIT license
17697 */
17698/**
17699 * grid config options
17700 */
17701
17702/* harmony default export */ var common_grid = ({
17703 /**
17704 * Set related options
17705 * @name grid
17706 * @memberof Options
17707 * @type {object}
17708 * @property {boolean} [front=false] Set 'grid & focus lines' to be positioned over grid lines and chart elements.
17709 * @property {object} x Grid x object
17710 * @property {boolean} [x.show=false] Show grids along x axis.
17711 * @property {Array} [x.lines=[]] Show additional grid lines along x axis.<br>
17712 * This option accepts array including object that has value, text, position and class. text, position and class are optional. For position, start, middle and end (default) are available.
17713 * If x axis is category axis, value can be category name. If x axis is timeseries axis, value can be date string, Date object and unixtime integer.
17714 * @property {object} y Grid y object
17715 * @property {boolean} [y.show=false] Show grids along x axis.
17716 * @property {Array} [y.lines=[]] Show additional grid lines along y axis.<br>
17717 * This option accepts array including object that has value, text, position and class.
17718 * @property {number} [y.ticks=undefined] Number of y grids to be shown.
17719 * @property {object} focus Grid focus object
17720 * @property {boolean} [focus.edge=false] Show edged focus grid line.<br>**NOTE:** Available when [`tooltip.grouped=false`](#.tooltip) option is set.
17721 * @property {boolean} [focus.show=true] Show grid line when focus.
17722 * @property {boolean} [focus.y=false] Show y coordinate focus grid line.<br>**NOTE:** Available when [`tooltip.grouped=false`](#.tooltip) option is set.
17723 * @property {object} lines Grid lines object
17724 * @property {boolean} [lines.front=true] Set grid lines to be positioned over chart elements.
17725 * @default undefined
17726 * @see [Demo](https://naver.github.io/billboard.js/demo/#Grid.GridLines)
17727 * @see [Demo: X Grid Lines](https://naver.github.io/billboard.js/demo/#Grid.OptionalXGridLines)
17728 * @see [Demo: Y Grid Lines](https://naver.github.io/billboard.js/demo/#Grid.OptionalYGridLines)
17729 * @example
17730 * grid: {
17731 * x: {
17732 * show: true,
17733 * lines: [
17734 * {value: 2, text: "Label on 2"},
17735 * {value: 5, text: "Label on 5", class: "label-5"},
17736 * {value: 6, text: "Label on 6", position: "start"}
17737 * ]
17738 * },
17739 * y: {
17740 * show: true,
17741 * lines: [
17742 * {value: 100, text: "Label on 100"},
17743 * {value: 200, text: "Label on 200", class: "label-200"},
17744 * {value: 300, text: "Label on 300", position: 'middle'}
17745 * ],
17746 * ticks: 5
17747 * },
17748 * front: true,
17749 * focus: {
17750 * show: false,
17751 *
17752 * // Below options are available when 'tooltip.grouped=false' option is set
17753 * edge: true,
17754 * y: true
17755 * },
17756 * lines: {
17757 * front: false
17758 * }
17759 * }
17760 */
17761 grid_x_show: !1,
17762 grid_x_type: "tick",
17763 grid_x_lines: [],
17764 grid_y_show: !1,
17765 grid_y_lines: [],
17766 grid_y_ticks: undefined,
17767 grid_focus_edge: !1,
17768 grid_focus_show: !0,
17769 grid_focus_y: !1,
17770 grid_front: !1,
17771 grid_lines_front: !0
17772});
17773;// CONCATENATED MODULE: ./src/config/resolver/axis.ts
17774/**
17775 * Copyright (c) 2017 ~ present NAVER Corp.
17776 * billboard.js project is licensed under the MIT license
17777 */
17778/**
17779 * Modules exports for Axis based chart
17780 */
17781// Chart
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791// ChartInternal
17792
17793
17794
17795
17796
17797
17798
17799
17800// Axis based options
17801
17802
17803
17804var api = [api_axis, api_category, grid_x, grid_y, flow, group, api_regions, x];
17805var internal = [Axis, clip, eventrect, interactions_flow, grid, region, size_axis];
17806var options = [data_axis, axis_axis, common_grid];
17807// EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
17808var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(12);
17809;// CONCATENATED MODULE: ./src/ChartInternal/shape/arc.ts
17810
17811/**
17812 * Copyright (c) 2017 ~ present NAVER Corp.
17813 * billboard.js project is licensed under the MIT license
17814 */
17815
17816
17817
17818
17819
17820
17821/* harmony default export */ var arc = ({
17822 initPie: function initPie() {
17823 var _this2 = this,
17824 $$ = this,
17825 config = $$.config,
17826 dataType = config.data_type,
17827 padding = config[dataType + "_padding"],
17828 startingAngle = config[dataType + "_startingAngle"] || 0,
17829 padAngle = (padding ? padding * .01 : config[dataType + "_padAngle"]) || 0;
17830 $$.pie = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.pie)().startAngle(startingAngle).endAngle(startingAngle + 2 * Math.PI).padAngle(padAngle).value(function (d) {
17831 var _this3 = this;
17832 _newArrowCheck(this, _this2);
17833 return d.values.reduce(function (a, b) {
17834 _newArrowCheck(this, _this3);
17835 return a + b.value;
17836 }.bind(this), 0);
17837 }.bind(this)).sort($$.getSortCompareFn.bind($$)(!0));
17838 },
17839 updateRadius: function updateRadius() {
17840 var $$ = this,
17841 config = $$.config,
17842 state = $$.state,
17843 dataType = config.data_type,
17844 padding = config[dataType + "_padding"],
17845 w = config.gauge_width || config.donut_width,
17846 gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length * config.gauge_arcs_minWidth;
17847 // determine radius
17848 state.radiusExpanded = Math.min(state.arcWidth, state.arcHeight) / 2 * ($$.hasMultiArcGauge() && config.gauge_label_show ? .85 : 1);
17849 state.radius = state.radiusExpanded * .95;
17850 state.innerRadiusRatio = w ? (state.radius - w) / state.radius : .6;
17851 state.gaugeArcWidth = w || (gaugeArcWidth <= state.radius - state.innerRadius ? state.radius - state.innerRadius : gaugeArcWidth <= state.radius ? gaugeArcWidth : state.radius);
17852 var innerRadius = config.pie_innerRadius || (padding ? padding * (state.innerRadiusRatio + .1) : 0);
17853
17854 // NOTE: inner/outerRadius can be an object by user setting, only for 'pie' type
17855 state.outerRadius = config.pie_outerRadius;
17856 state.innerRadius = $$.hasType("donut") || $$.hasType("gauge") ? state.radius * state.innerRadiusRatio : innerRadius;
17857 },
17858 /**
17859 * Get pie's inner & outer radius value
17860 * @param {object|undefined} d Data object
17861 * @returns {object}
17862 * @private
17863 */
17864 getRadius: function getRadius(d) {
17865 var $$ = this,
17866 data = d == null ? void 0 : d.data,
17867 _$$$state = $$.state,
17868 innerRadius = _$$$state.innerRadius,
17869 outerRadius = _$$$state.outerRadius;
17870 if (!isNumber(innerRadius) && data) {
17871 innerRadius = innerRadius[data.id] || 0;
17872 }
17873 if (isObject(outerRadius) && data && data.id in outerRadius) {
17874 outerRadius = outerRadius[data.id];
17875 } else if (!isNumber(outerRadius)) {
17876 outerRadius = $$.state.radius;
17877 }
17878 return {
17879 innerRadius: innerRadius,
17880 outerRadius: outerRadius
17881 };
17882 },
17883 updateArc: function updateArc() {
17884 var $$ = this;
17885 $$.updateRadius();
17886 $$.svgArc = $$.getSvgArc();
17887 $$.svgArcExpanded = $$.getSvgArcExpanded();
17888 },
17889 getArcLength: function getArcLength() {
17890 var $$ = this,
17891 config = $$.config,
17892 arcLengthInPercent = config.gauge_arcLength * 3.6,
17893 len = 2 * (arcLengthInPercent / 360);
17894 if (arcLengthInPercent < -360) {
17895 len = -2;
17896 } else if (arcLengthInPercent > 360) {
17897 len = 2;
17898 }
17899 return len * Math.PI;
17900 },
17901 getStartAngle: function getStartAngle() {
17902 var $$ = this,
17903 config = $$.config,
17904 isFullCircle = config.gauge_fullCircle,
17905 defaultStartAngle = -1 * Math.PI / 2,
17906 defaultEndAngle = Math.PI / 2,
17907 startAngle = config.gauge_startingAngle;
17908 if (!isFullCircle && startAngle <= defaultStartAngle) {
17909 startAngle = defaultStartAngle;
17910 } else if (!isFullCircle && startAngle >= defaultEndAngle) {
17911 startAngle = defaultEndAngle;
17912 } else if (startAngle > Math.PI || startAngle < -1 * Math.PI) {
17913 startAngle = Math.PI;
17914 }
17915 return startAngle;
17916 },
17917 updateAngle: function updateAngle(dValue) {
17918 var _this4 = this,
17919 $$ = this,
17920 config = $$.config,
17921 state = $$.state,
17922 pie = $$.pie,
17923 d = dValue,
17924 found = !1;
17925 if (!config) {
17926 return null;
17927 }
17928 var gStart = $$.getStartAngle(),
17929 radius = config.gauge_fullCircle ? $$.getArcLength() : gStart * -2;
17930 if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
17931 var min = config.gauge_min,
17932 max = config.gauge_max,
17933 totalSum = $$.getTotalDataSum(state.rendered); // to prevent excluding total data sum during the init(when data.hide option is used), use $$.rendered state value
17934 pie = pie.startAngle(gStart).endAngle(radius * ((totalSum - min) / (max - min)) + gStart);
17935 }
17936 pie($$.filterTargetsToShow()).forEach(function (t, i) {
17937 _newArrowCheck(this, _this4);
17938 if (!found && t.data.id === d.data.id) {
17939 found = !0;
17940 d = t;
17941 d.index = i;
17942 }
17943 }.bind(this));
17944 if (isNaN(d.startAngle)) {
17945 d.startAngle = 0;
17946 }
17947 if (isNaN(d.endAngle)) {
17948 d.endAngle = d.startAngle;
17949 }
17950 if (d.data && $$.hasMultiArcGauge()) {
17951 var gMin = config.gauge_min,
17952 gMax = config.gauge_max,
17953 gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : gMax - gMin;
17954 d.startAngle = gStart;
17955 d.endAngle = gStart + radius / (gMax - gMin) * gValue;
17956 }
17957 return found ? d : null;
17958 },
17959 getSvgArc: function getSvgArc() {
17960 var _this5 = this,
17961 $$ = this,
17962 state = $$.state,
17963 singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
17964 hasMultiArcGauge = $$.hasMultiArcGauge(),
17965 hasPolar = $$.hasType("polar"),
17966 arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
17967 _newArrowCheck(this, _this5);
17968 var _$$$getRadius = $$.getRadius(d),
17969 innerRadius = _$$$getRadius.innerRadius;
17970 return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : isNumber(innerRadius) ? innerRadius : 0;
17971 }.bind(this)).outerRadius(function (d) {
17972 _newArrowCheck(this, _this5);
17973 var _$$$getRadius2 = $$.getRadius(d),
17974 outerRadius = _$$$getRadius2.outerRadius,
17975 radius = outerRadius;
17976 if (hasMultiArcGauge) {
17977 radius = state.radius - singleArcWidth * d.index;
17978 } else if (hasPolar) {
17979 radius = $$.getPolarOuterRadius(d, outerRadius);
17980 }
17981 return radius;
17982 }.bind(this)),
17983 newArc = function (d, withoutUpdate) {
17984 var path = "M 0 0";
17985 if (d.value || d.data) {
17986 var updated = !withoutUpdate && $$.updateAngle(d);
17987 if (withoutUpdate) {
17988 path = arc(d);
17989 } else if (updated) {
17990 path = arc(updated);
17991 }
17992 }
17993 return path;
17994 };
17995 // TODO: extends all function
17996 newArc.centroid = arc.centroid;
17997 return newArc;
17998 },
17999 getSvgArcExpanded: function getSvgArcExpanded(rate) {
18000 var _this6 = this,
18001 $$ = this,
18002 state = $$.state,
18003 newRate = rate || 1,
18004 singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
18005 hasMultiArcGauge = $$.hasMultiArcGauge(),
18006 expandWidth = Math.min(state.radiusExpanded * newRate - state.radius, singleArcWidth * .8 - (1 - newRate) * 100),
18007 arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
18008 _newArrowCheck(this, _this6);
18009 return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : $$.getRadius(d).innerRadius;
18010 }.bind(this)).outerRadius(function (d) {
18011 _newArrowCheck(this, _this6);
18012 var radius;
18013 if (hasMultiArcGauge) {
18014 radius = state.radius - singleArcWidth * d.index + expandWidth;
18015 } else {
18016 var _$$$getRadius3 = $$.getRadius(d),
18017 outerRadius = _$$$getRadius3.outerRadius,
18018 radiusExpanded = state.radiusExpanded;
18019 if (state.radius !== outerRadius) {
18020 radiusExpanded -= Math.abs(state.radius - outerRadius);
18021 }
18022 radius = radiusExpanded * newRate;
18023 }
18024 return radius;
18025 }.bind(this));
18026 return function (d) {
18027 var updated = $$.updateAngle(d);
18028 return updated ? arc(updated) : "M 0 0";
18029 };
18030 },
18031 getArc: function getArc(d, withoutUpdate, force) {
18032 return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0";
18033 },
18034 /**
18035 * Set transform attributes to arc label text
18036 * @param {object} d Data object
18037 * @returns {string} Translate attribute string
18038 * @private
18039 */
18040 transformForArcLabel: function transformForArcLabel(d) {
18041 var _this7 = this,
18042 $$ = this,
18043 config = $$.config,
18044 radiusExpanded = $$.state.radiusExpanded,
18045 updated = $$.updateAngle(d),
18046 translate = "";
18047 if (updated) {
18048 if ($$.hasMultiArcGauge()) {
18049 var y1 = Math.sin(updated.endAngle - Math.PI / 2),
18050 x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + 25),
18051 y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
18052 translate = "translate(" + x + "," + y + ")";
18053 } else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
18054 var _filter$map,
18055 _$$$getRadius4 = $$.getRadius(d),
18056 outerRadius = _$$$getRadius4.outerRadius;
18057 if ($$.hasType("polar")) {
18058 outerRadius = $$.getPolarOuterRadius(d, outerRadius);
18059 }
18060 var c = this.svgArc.centroid(updated),
18061 _c$map = c.map(function (v) {
18062 _newArrowCheck(this, _this7);
18063 return isNaN(v) ? 0 : v;
18064 }.bind(this)),
18065 x = _c$map[0],
18066 y = _c$map[1],
18067 h = Math.sqrt(x * x + y * y),
18068 ratio = (_filter$map = ["donut", "pie", "polar"].filter($$.hasType.bind($$)).map(function (v) {
18069 _newArrowCheck(this, _this7);
18070 return config[v + "_label_ratio"];
18071 }.bind(this))) == null ? void 0 : _filter$map[0];
18072 if (ratio) {
18073 ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
18074 } else {
18075 ratio = outerRadius && (h ? (36 / outerRadius > .375 ? 1.175 - 36 / outerRadius : .8) * outerRadius / h : 0);
18076 }
18077 translate = "translate(" + x * ratio + "," + y * ratio + ")";
18078 }
18079 }
18080 return translate;
18081 },
18082 convertToArcData: function convertToArcData(d) {
18083 return this.addName({
18084 id: d.data ? d.data.id : d.id,
18085 value: d.value,
18086 ratio: this.getRatio("arc", d),
18087 index: d.index
18088 });
18089 },
18090 textForArcLabel: function textForArcLabel(selection) {
18091 var $$ = this,
18092 hasGauge = $$.hasType("gauge");
18093 if ($$.shouldShowArcLabel()) {
18094 selection.style("fill", $$.updateTextColor.bind($$)).attr("filter", $$.updateTextBacgroundColor.bind($$)).each(function (d) {
18095 var _filter,
18096 node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
18097 updated = $$.updateAngle(d),
18098 ratio = $$.getRatio("arc", updated),
18099 isUnderThreshold = $$.meetsLabelThreshold(ratio, (_filter = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) == null ? void 0 : _filter[0]);
18100 if (isUnderThreshold) {
18101 var value = (updated || d).value,
18102 text = ($$.getArcLabelFormat() || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
18103 setTextValue(node, text, [-1, 1], hasGauge);
18104 } else {
18105 node.text("");
18106 }
18107 });
18108 }
18109 },
18110 expandArc: function expandArc(targetIds) {
18111 var _this8 = this,
18112 $$ = this,
18113 transiting = $$.state.transiting,
18114 $el = $$.$el;
18115 // MEMO: avoid to cancel transition
18116 if (transiting) {
18117 var interval = setInterval(function () {
18118 _newArrowCheck(this, _this8);
18119 if (!transiting) {
18120 clearInterval(interval);
18121 $el.legend.selectAll("." + $FOCUS.legendItemFocused).size() > 0 && $$.expandArc(targetIds);
18122 }
18123 }.bind(this), 10);
18124 return;
18125 }
18126 var newTargetIds = $$.mapToTargetIds(targetIds);
18127 $el.svg.selectAll($$.selectorTargets(newTargetIds, "." + $ARC.chartArc)).each(function (d) {
18128 if (!$$.shouldExpand(d.data.id)) {
18129 return;
18130 }
18131 var expandDuration = $$.getExpandConfig(d.data.id, "duration"),
18132 svgArcExpandedSub = $$.getSvgArcExpanded($$.getExpandConfig(d.data.id, "rate"));
18133 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attr("d", $$.svgArcExpanded).transition().duration(expandDuration * 2).attr("d", svgArcExpandedSub);
18134 });
18135 },
18136 unexpandArc: function unexpandArc(targetIds) {
18137 var _this9 = this,
18138 $$ = this,
18139 transiting = $$.state.transiting,
18140 svg = $$.$el.svg;
18141 if (transiting) {
18142 return;
18143 }
18144 var newTargetIds = $$.mapToTargetIds(targetIds);
18145 svg.selectAll($$.selectorTargets(newTargetIds, "." + $ARC.chartArc)).selectAll("path").transition().duration(function (d) {
18146 _newArrowCheck(this, _this9);
18147 return $$.getExpandConfig(d.data.id, "duration");
18148 }.bind(this)).attr("d", $$.svgArc);
18149 svg.selectAll("" + $ARC.arc).style("opacity", null);
18150 },
18151 /**
18152 * Get expand config value
18153 * @param {string} id data ID
18154 * @param {string} key config key: 'duration | rate'
18155 * @returns {number}
18156 * @private
18157 */
18158 getExpandConfig: function getExpandConfig(id, key) {
18159 var $$ = this,
18160 config = $$.config,
18161 type;
18162 if ($$.isDonutType(id)) {
18163 type = "donut";
18164 } else if ($$.isGaugeType(id)) {
18165 type = "gauge";
18166 } else if ($$.isPieType(id)) {
18167 type = "pie";
18168 }
18169 return type ? config[type + "_expand_" + key] : {
18170 duration: 50,
18171 rate: .98
18172 }[key];
18173 },
18174 shouldExpand: function shouldExpand(id) {
18175 var $$ = this,
18176 config = $$.config;
18177 return $$.isDonutType(id) && config.donut_expand || $$.isGaugeType(id) && config.gauge_expand || $$.isPieType(id) && config.pie_expand;
18178 },
18179 shouldShowArcLabel: function shouldShowArcLabel() {
18180 var _this10 = this,
18181 $$ = this,
18182 config = $$.config;
18183 return ["donut", "gauge", "pie", "polar"].some(function (v) {
18184 _newArrowCheck(this, _this10);
18185 return $$.hasType(v) && config[v + "_label_show"];
18186 }.bind(this));
18187 },
18188 getArcLabelFormat: function getArcLabelFormat() {
18189 var _this11 = this,
18190 $$ = this,
18191 config = $$.config,
18192 format = function (v) {
18193 _newArrowCheck(this, _this11);
18194 return v;
18195 }.bind(this);
18196 ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).forEach(function (v) {
18197 _newArrowCheck(this, _this11);
18198 format = config[v + "_label_format"];
18199 }.bind(this));
18200 return isFunction(format) ? format.bind($$.api) : format;
18201 },
18202 getArcTitle: function getArcTitle() {
18203 var $$ = this,
18204 type = $$.hasType("donut") && "donut" || $$.hasType("gauge") && "gauge";
18205 return type ? $$.config[type + "_title"] : "";
18206 },
18207 updateTargetsForArc: function updateTargetsForArc(targets) {
18208 var _this12 = this,
18209 $$ = this,
18210 $el = $$.$el,
18211 hasGauge = $$.hasType("gauge"),
18212 classChartArc = $$.getChartClass("Arc"),
18213 classArcs = $$.getClass("arcs", !0),
18214 classFocus = $$.classFocus.bind($$),
18215 chartArcs = $el.main.select("." + $ARC.chartArcs),
18216 mainPieUpdate = chartArcs.selectAll("." + $ARC.chartArc).data($$.pie(targets)).attr("class", function (d) {
18217 _newArrowCheck(this, _this12);
18218 return classChartArc(d) + classFocus(d.data);
18219 }.bind(this)),
18220 mainPieEnter = mainPieUpdate.enter().append("g").attr("class", classChartArc).call(this.setCssRule(!1, "." + $ARC.chartArcs + " text", ["pointer-events:none", "text-anchor:middle"]));
18221 mainPieEnter.append("g").attr("class", classArcs).merge(mainPieUpdate);
18222 mainPieEnter.append("text").attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" : ".35em").style("opacity", "0").style("text-anchor", $$.getStylePropValue("middle")).style("pointer-events", $$.getStylePropValue("none"));
18223 $el.text = chartArcs.selectAll("." + $COMMON.target + " text");
18224 // MEMO: can not keep same color..., but not bad to update color in redraw
18225 // mainPieUpdate.exit().remove();
18226 },
18227 initArc: function initArc() {
18228 var $$ = this,
18229 $el = $$.$el;
18230 $el.arcs = $el.main.select("." + $COMMON.chart).append("g").attr("class", $ARC.chartArcs).attr("transform", $$.getTranslate("arc"));
18231 $$.setArcTitle();
18232 },
18233 /**
18234 * Set arc title text
18235 * @private
18236 */
18237 setArcTitle: function setArcTitle() {
18238 var $$ = this,
18239 title = $$.getArcTitle(),
18240 hasGauge = $$.hasType("gauge");
18241 if (title) {
18242 var text = $$.$el.arcs.append("text").attr("class", hasGauge ? $GAUGE.chartArcsGaugeTitle : $ARC.chartArcsTitle).style("text-anchor", "middle");
18243 hasGauge && text.attr("dy", "-0.3em");
18244 setTextValue(text, title, hasGauge ? undefined : [-.6, 1.35], !0);
18245 }
18246 },
18247 redrawArc: function redrawArc(duration, durationForExit, withTransform) {
18248 var _this13 = this,
18249 $$ = this,
18250 config = $$.config,
18251 state = $$.state,
18252 main = $$.$el.main,
18253 hasInteraction = config.interaction_enabled,
18254 isSelectable = hasInteraction && config.data_selection_isselectable,
18255 mainArc = main.selectAll("." + $ARC.arcs).selectAll("." + $ARC.arc).data($$.arcData.bind($$));
18256 mainArc.exit().transition().duration(durationForExit).style("opacity", "0").remove();
18257 mainArc = mainArc.enter().append("path").attr("class", $$.getClass("arc", !0)).style("fill", function (d) {
18258 _newArrowCheck(this, _this13);
18259 return $$.color(d.data);
18260 }.bind(this)).style("cursor", function (d) {
18261 _newArrowCheck(this, _this13);
18262 return isSelectable != null && isSelectable.bind != null && isSelectable.bind($$.api)(d) ? "pointer" : null;
18263 }.bind(this)).style("opacity", "0").each(function (d) {
18264 if ($$.isGaugeType(d.data)) {
18265 d.startAngle = config.gauge_startingAngle;
18266 d.endAngle = config.gauge_startingAngle;
18267 }
18268 this._current = d;
18269 }).merge(mainArc);
18270 if ($$.hasType("gauge")) {
18271 $$.updateGaugeMax();
18272 $$.hasMultiArcGauge() && $$.redrawMultiArcGauge();
18273 }
18274 mainArc.attr("transform", function (d) {
18275 _newArrowCheck(this, _this13);
18276 return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : "";
18277 }.bind(this)).style("opacity", function (d) {
18278 return d === this._current ? "0" : null;
18279 }).each(function () {
18280 _newArrowCheck(this, _this13);
18281 state.transiting = !0;
18282 }.bind(this)).transition().duration(duration).attrTween("d", function (d) {
18283 var _this14 = this,
18284 updated = $$.updateAngle(d);
18285 if (!updated) {
18286 return function () {
18287 _newArrowCheck(this, _this14);
18288 return "M 0 0";
18289 }.bind(this);
18290 }
18291 if (isNaN(this._current.startAngle)) {
18292 this._current.startAngle = 0;
18293 }
18294 if (isNaN(this._current.endAngle)) {
18295 this._current.endAngle = this._current.startAngle;
18296 }
18297 var interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(this._current, updated);
18298 this._current = interpolate(0);
18299 return function (t) {
18300 var interpolated = interpolate(t);
18301 interpolated.data = d.data; // data.id will be updated by interporator
18302
18303 return $$.getArc(interpolated, !0);
18304 };
18305 }).attr("transform", withTransform ? "scale(1)" : "").style("fill", function (d) {
18306 _newArrowCheck(this, _this13);
18307 var color;
18308 if ($$.levelColor) {
18309 color = $$.levelColor(d.data.values[0].value);
18310
18311 // update data's color
18312 config.data_colors[d.data.id] = color;
18313 } else {
18314 color = $$.color(d.data);
18315 }
18316 return color;
18317 }.bind(this))
18318 // Where gauge reading color would receive customization.
18319 .style("opacity", null).call(endall, function () {
18320 if ($$.levelColor) {
18321 var path = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
18322 d = path.datum();
18323 $$.updateLegendItemColor(d.data.id, path.style("fill"));
18324 }
18325 state.transiting = !1;
18326 callFn(config.onrendered, $$.api);
18327 });
18328
18329 // bind arc events
18330 hasInteraction && $$.bindArcEvent(mainArc);
18331 $$.hasType("polar") && $$.redrawPolar();
18332 $$.hasType("gauge") && $$.redrawBackgroundArcs();
18333 $$.redrawArcText(duration);
18334 },
18335 redrawBackgroundArcs: function redrawBackgroundArcs() {
18336 var _this15 = this,
18337 $$ = this,
18338 config = $$.config,
18339 state = $$.state,
18340 hasMultiArcGauge = $$.hasMultiArcGauge(),
18341 isFullCircle = config.gauge_fullCircle,
18342 startAngle = $$.getStartAngle(),
18343 endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1,
18344 backgroundArc = $$.$el.arcs.select((hasMultiArcGauge ? "g" : "") + "." + $ARC.chartArcsBackground);
18345 if (hasMultiArcGauge) {
18346 var index = 0;
18347 backgroundArc = backgroundArc.selectAll("path." + $ARC.chartArcsBackground).data($$.data.targets);
18348 backgroundArc.enter().append("path").attr("class", function (d, i) {
18349 _newArrowCheck(this, _this15);
18350 return $ARC.chartArcsBackground + " " + $ARC.chartArcsBackground + "-" + i;
18351 }.bind(this)).merge(backgroundArc).style("fill", config.gauge_background || null).attr("d", function (_ref2) {
18352 var id = _ref2.id;
18353 _newArrowCheck(this, _this15);
18354 if (state.hiddenTargetIds.indexOf(id) >= 0) {
18355 return "M 0 0";
18356 }
18357 var d = {
18358 data: [{
18359 value: config.gauge_max
18360 }],
18361 startAngle: startAngle,
18362 endAngle: endAngle,
18363 index: index++
18364 };
18365 return $$.getArc(d, !0, !0);
18366 }.bind(this));
18367 backgroundArc.exit().remove();
18368 } else {
18369 backgroundArc.attr("d", function () {
18370 _newArrowCheck(this, _this15);
18371 var d = {
18372 data: [{
18373 value: config.gauge_max
18374 }],
18375 startAngle: startAngle,
18376 endAngle: endAngle
18377 };
18378 return $$.getArc(d, !0, !0);
18379 }.bind(this));
18380 }
18381 },
18382 bindArcEvent: function bindArcEvent(arc) {
18383 var _this16 = this,
18384 $$ = this,
18385 config = $$.config,
18386 state = $$.state,
18387 isTouch = state.inputType === "touch",
18388 isMouse = state.inputType === "mouse";
18389 // eslint-disable-next-line
18390 function selectArc(_this, arcData, id) {
18391 // transitions
18392 $$.expandArc(id);
18393 $$.api.focus(id);
18394 $$.toggleFocusLegend(id, !0);
18395 $$.showTooltip([arcData], _this);
18396 }
18397
18398 // eslint-disable-next-line
18399 function unselectArc(arcData) {
18400 var id = (arcData == null ? void 0 : arcData.id) || undefined;
18401 $$.unexpandArc(id);
18402 $$.api.revert();
18403 $$.revertLegend();
18404 $$.hideTooltip();
18405 }
18406 arc.on("click", function (event, d, i) {
18407 var updated = $$.updateAngle(d),
18408 arcData;
18409 if (updated) {
18410 arcData = $$.convertToArcData(updated);
18411 $$.toggleShape == null ? void 0 : $$.toggleShape(this, arcData, i);
18412 config.data_onclick.bind($$.api)(arcData, this);
18413 }
18414 });
18415
18416 // mouse events
18417 if (isMouse) {
18418 arc.on("mouseover", function (event, d) {
18419 var _arcData;
18420 if (state.transiting) {
18421 // skip while transiting
18422 return;
18423 }
18424 state.event = event;
18425 var updated = $$.updateAngle(d),
18426 arcData = updated ? $$.convertToArcData(updated) : null,
18427 id = ((_arcData = arcData) == null ? void 0 : _arcData.id) || undefined;
18428 selectArc(this, arcData, id);
18429 $$.setOverOut(!0, arcData);
18430 }).on("mouseout", function (event, d) {
18431 _newArrowCheck(this, _this16);
18432 if (state.transiting) {
18433 // skip while transiting
18434 return;
18435 }
18436 state.event = event;
18437 var updated = $$.updateAngle(d),
18438 arcData = updated ? $$.convertToArcData(updated) : null;
18439 unselectArc();
18440 $$.setOverOut(!1, arcData);
18441 }.bind(this)).on("mousemove", function (event, d) {
18442 var updated = $$.updateAngle(d),
18443 arcData = updated ? $$.convertToArcData(updated) : null;
18444 state.event = event;
18445 $$.showTooltip([arcData], this);
18446 });
18447 }
18448
18449 // touch events
18450 if (isTouch && $$.hasArcType() && !$$.radars) {
18451 var getEventArc = function (event) {
18452 _newArrowCheck(this, _this16);
18453 var touch = event.changedTouches[0],
18454 eventArc = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.elementFromPoint(touch.clientX, touch.clientY));
18455 return eventArc;
18456 }.bind(this);
18457 $$.$el.svg.on("touchstart touchmove", function (event) {
18458 var _datum, _arcData2;
18459 if (state.transiting) {
18460 // skip while transiting
18461 return;
18462 }
18463 state.event = event;
18464 var eventArc = getEventArc(event),
18465 datum = eventArc.datum(),
18466 updated = (_datum = datum) != null && _datum.data && datum.data.id ? $$.updateAngle(datum) : null,
18467 arcData = updated ? $$.convertToArcData(updated) : null,
18468 id = ((_arcData2 = arcData) == null ? void 0 : _arcData2.id) || undefined;
18469 $$.callOverOutForTouch(arcData);
18470 isUndefined(id) ? unselectArc() : selectArc(this, arcData, id);
18471 });
18472 }
18473 },
18474 redrawArcText: function redrawArcText(duration) {
18475 var _this17 = this,
18476 $$ = this,
18477 config = $$.config,
18478 state = $$.state,
18479 _$$$$el = $$.$el,
18480 main = _$$$$el.main,
18481 arcs = _$$$$el.arcs,
18482 hasGauge = $$.hasType("gauge"),
18483 hasMultiArcGauge = $$.hasMultiArcGauge(),
18484 text;
18485 // for gauge type, update text when has no title & multi data
18486 if (!(hasGauge && $$.data.targets.length === 1 && config.gauge_title)) {
18487 text = main.selectAll("." + $ARC.chartArc).select("text").style("opacity", "0").attr("class", function (d) {
18488 _newArrowCheck(this, _this17);
18489 return $$.isGaugeType(d.data) ? $GAUGE.gaugeValue : null;
18490 }.bind(this)).call($$.textForArcLabel.bind($$)).attr("transform", $$.transformForArcLabel.bind($$)).style("font-size", function (d) {
18491 _newArrowCheck(this, _this17);
18492 return $$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ? Math.round(state.radius / 5) + "px" : null;
18493 }.bind(this)).transition().duration(duration).style("opacity", function (d) {
18494 _newArrowCheck(this, _this17);
18495 return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0";
18496 }.bind(this));
18497 hasMultiArcGauge && text.attr("dy", "-.1em");
18498 }
18499 main.select("." + $ARC.chartArcsTitle).style("opacity", $$.hasType("donut") || hasGauge ? null : "0");
18500 if (hasGauge) {
18501 var _text,
18502 isFullCircle = config.gauge_fullCircle;
18503 isFullCircle && ((_text = text) == null ? void 0 : _text.attr("dy", "" + (hasMultiArcGauge ? 0 : Math.round(state.radius / 14))));
18504 if (config.gauge_label_show) {
18505 arcs.select("." + $GAUGE.chartArcsGaugeUnit).attr("dy", (isFullCircle ? 1.5 : .75) + "em").text(config.gauge_units);
18506 arcs.select("." + $GAUGE.chartArcsGaugeMin).attr("dx", -1 * (state.innerRadius + (state.radius - state.innerRadius) / (isFullCircle ? 1 : 2)) + "px").attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_min, !1));
18507
18508 // show max text when isn't fullCircle
18509 isFullCircle || arcs.select("." + $GAUGE.chartArcsGaugeMax).attr("dx", state.innerRadius + (state.radius - state.innerRadius) / 2 + "px").attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_max, !0));
18510 }
18511 }
18512 }
18513});
18514;// CONCATENATED MODULE: ./src/ChartInternal/shape/area.ts
18515
18516/**
18517 * Copyright (c) 2017 ~ present NAVER Corp.
18518 * billboard.js project is licensed under the MIT license
18519 */
18520
18521
18522
18523
18524/* harmony default export */ var shape_area = ({
18525 initArea: function initArea(mainLine) {
18526 var $$ = this,
18527 config = $$.config;
18528 mainLine.insert("g", "." + (config.area_front ? $CIRCLE.circles : $LINE.lines)).attr("class", $$.getClass("areas", !0));
18529 },
18530 /**
18531 * Update area color
18532 * @param {object} d Data object
18533 * @returns {string} Color string
18534 * @private
18535 */
18536 updateAreaColor: function updateAreaColor(d) {
18537 var $$ = this;
18538 return $$.config.area_linearGradient ? $$.getGradienColortUrl(d.id) : $$.color(d);
18539 },
18540 /**
18541 * Generate/Update elements
18542 * @param {boolean} withTransition Transition for exit elements
18543 * @param {boolean} isSub Subchart draw
18544 * @private
18545 */
18546 updateArea: function updateArea(withTransition, isSub) {
18547 if (isSub === void 0) {
18548 isSub = !1;
18549 }
18550 var $$ = this,
18551 config = $$.config,
18552 state = $$.state,
18553 $el = $$.$el,
18554 $T = $$.$T,
18555 $root = isSub ? $el.subchart : $el;
18556 config.area_linearGradient && $$.updateLinearGradient();
18557 var area = $root.main.selectAll("." + $AREA.areas).selectAll("." + $AREA.area).data($$.lineData.bind($$));
18558 $T(area.exit(), withTransition).style("opacity", "0").remove();
18559 $root.area = area.enter().append("path").attr("class", $$.getClass("area", !0)).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function () {
18560 state.orgAreaOpacity = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).style("opacity");
18561 return "0";
18562 }).merge(area);
18563 area.style("opacity", state.orgAreaOpacity);
18564 },
18565 /**
18566 * Redraw function
18567 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
18568 * @param {boolean} withTransition With or without transition
18569 * @param {boolean} isSub Subchart draw
18570 * @returns {Array}
18571 */
18572 redrawArea: function redrawArea(drawFn, withTransition, isSub) {
18573 var _this = this;
18574 if (isSub === void 0) {
18575 isSub = !1;
18576 }
18577 var $$ = this,
18578 _ref = isSub ? this.$el.subchart : this.$el,
18579 area = _ref.area,
18580 orgAreaOpacity = $$.state.orgAreaOpacity;
18581 return [$$.$T(area, withTransition, getRandom()).attr("d", drawFn).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function (d) {
18582 _newArrowCheck(this, _this);
18583 return ($$.isAreaRangeType(d) ? orgAreaOpacity / 1.75 : orgAreaOpacity) + "";
18584 }.bind(this))];
18585 },
18586 /**
18587 * Generate area path data
18588 * @param {object} areaIndices Indices
18589 * @param {boolean} isSub Weather is sub axis
18590 * @returns {Function}
18591 * @private
18592 */
18593 generateDrawArea: function generateDrawArea(areaIndices, isSub) {
18594 var _this2 = this,
18595 $$ = this,
18596 config = $$.config,
18597 lineConnectNull = config.line_connectNull,
18598 isRotated = config.axis_rotated,
18599 getPoints = $$.generateGetAreaPoints(areaIndices, isSub),
18600 yScale = $$.getYScaleById.bind($$),
18601 xValue = function (d) {
18602 _newArrowCheck(this, _this2);
18603 return (isSub ? $$.subxx : $$.xx).call($$, d);
18604 }.bind(this),
18605 value0 = function (d, i) {
18606 _newArrowCheck(this, _this2);
18607 return $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : $$.getShapeYMin(d.id));
18608 }.bind(this),
18609 value1 = function (d, i) {
18610 _newArrowCheck(this, _this2);
18611 return $$.isGrouped(d.id) ? getPoints(d, i)[1][1] : yScale(d.id, isSub)($$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : d.value);
18612 }.bind(this);
18613 return function (d) {
18614 var _this3 = this;
18615 _newArrowCheck(this, _this2);
18616 var values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
18617 x0 = 0,
18618 y0 = 0,
18619 path;
18620 if ($$.isAreaType(d)) {
18621 var area = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.area)();
18622 area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue).y0(config.area_above ? 0 : config.area_below ? $$.state.height : value0).y1(value1);
18623 if (!lineConnectNull) {
18624 area = area.defined(function (d) {
18625 _newArrowCheck(this, _this3);
18626 return $$.getBaseValue(d) !== null;
18627 }.bind(this));
18628 }
18629 if ($$.isStepType(d)) {
18630 values = $$.convertValuesToStep(values);
18631 }
18632 path = area.curve($$.getCurve(d))(values);
18633 } else {
18634 if (values[0]) {
18635 x0 = $$.scale.x(values[0].x);
18636 y0 = $$.getYScaleById(d.id)(values[0].value);
18637 }
18638 path = isRotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
18639 }
18640 return path || "M 0 0";
18641 }.bind(this);
18642 },
18643 generateGetAreaPoints: function generateGetAreaPoints(areaIndices, isSub) {
18644 // partial duplication of generateGetBarPoints
18645 var $$ = this,
18646 config = $$.config,
18647 x = $$.getShapeX(0, areaIndices, isSub),
18648 y = $$.getShapeY(!!isSub),
18649 areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, isSub),
18650 yScale = $$.getYScaleById.bind($$);
18651 return function (d, i) {
18652 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
18653 offset = areaOffset(d, i) || y0,
18654 posX = x(d),
18655 value = d.value,
18656 posY = y(d);
18657 // fix posY not to overflow opposite quadrant
18658 if (config.axis_rotated && (value > 0 && posY < y0 || value < 0 && y0 < posY)) {
18659 posY = y0;
18660 }
18661
18662 // 1 point that marks the area position
18663 return [[posX, offset], [posX, posY - (y0 - offset)], [posX, posY - (y0 - offset)],
18664 // needed for compatibility
18665 [posX, offset] // needed for compatibility
18666 ];
18667 };
18668 }
18669});
18670;// CONCATENATED MODULE: ./src/ChartInternal/shape/bar.ts
18671
18672/**
18673 * Copyright (c) 2017 ~ present NAVER Corp.
18674 * billboard.js project is licensed under the MIT license
18675 */
18676
18677
18678
18679/* harmony default export */ var bar = ({
18680 initBar: function initBar() {
18681 var $el = this.$el,
18682 config = this.config,
18683 clip = this.state.clip;
18684 $el.bar = $el.main.select("." + $COMMON.chart)
18685 // should positioned at the beginning of the shape node to not overlap others
18686 .insert("g", ":first-child").attr("class", $BAR.chartBars).call(this.setCssRule(!1, "." + $BAR.chartBars, ["pointer-events:none"]));
18687
18688 // set clip-path attribute when condition meet
18689 // https://github.com/naver/billboard.js/issues/2421
18690 if (config.clipPath === !1 && (config.bar_radius || config.bar_radius_ratio)) {
18691 $el.bar.attr("clip-path", clip.pathXAxis.replace(/#[^)]*/, "#" + clip.id));
18692 }
18693 },
18694 updateTargetsForBar: function updateTargetsForBar(targets) {
18695 var _this = this,
18696 $$ = this,
18697 config = $$.config,
18698 $el = $$.$el,
18699 classChartBar = $$.getChartClass("Bar"),
18700 classBars = $$.getClass("bars", !0),
18701 classFocus = $$.classFocus.bind($$),
18702 isSelectable = config.interaction_enabled && config.data_selection_isselectable;
18703 if (!$el.bar) {
18704 $$.initBar();
18705 }
18706 var mainBarUpdate = $$.$el.main.select("." + $BAR.chartBars).selectAll("." + $BAR.chartBar).data(
18707 // remove
18708 targets.filter(function (v) {
18709 var _this2 = this;
18710 _newArrowCheck(this, _this);
18711 return v.values.some(function (d) {
18712 _newArrowCheck(this, _this2);
18713 return isNumber(d.value) || $$.isBarRangeType(d);
18714 }.bind(this));
18715 }.bind(this))).attr("class", function (d) {
18716 _newArrowCheck(this, _this);
18717 return classChartBar(d) + classFocus(d);
18718 }.bind(this)),
18719 mainBarEnter = mainBarUpdate.enter().append("g").attr("class", classChartBar).style("opacity", "0").style("pointer-events", $$.getStylePropValue("none"));
18720 // Bars for each data
18721 mainBarEnter.append("g").attr("class", classBars).style("cursor", function (d) {
18722 _newArrowCheck(this, _this);
18723 return isSelectable != null && isSelectable.bind != null && isSelectable.bind($$.api)(d) ? "pointer" : null;
18724 }.bind(this)).call($$.setCssRule(!0, " ." + $BAR.bar, ["fill"], $$.color));
18725 },
18726 /**
18727 * Generate/Update elements
18728 * @param {boolean} withTransition Transition for exit elements
18729 * @param {boolean} isSub Subchart draw
18730 * @private
18731 */
18732 updateBar: function updateBar(withTransition, isSub) {
18733 if (isSub === void 0) {
18734 isSub = !1;
18735 }
18736 var $$ = this,
18737 config = $$.config,
18738 $el = $$.$el,
18739 $T = $$.$T,
18740 $root = isSub ? $el.subchart : $el,
18741 classBar = $$.getClass("bar", !0),
18742 initialOpacity = $$.initialOpacity.bind($$);
18743 config.bar_linearGradient && $$.updateLinearGradient();
18744 var bar = $root.main.selectAll("." + $BAR.bars).selectAll("." + $BAR.bar).data($$.labelishData.bind($$));
18745 $T(bar.exit(), withTransition).style("opacity", "0").remove();
18746 $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.updateBarColor.bind($$)).merge(bar).style("opacity", initialOpacity);
18747 },
18748 /**
18749 * Update bar color
18750 * @param {object} d Data object
18751 * @returns {string} Color string
18752 * @private
18753 */
18754 updateBarColor: function updateBarColor(d) {
18755 var $$ = this,
18756 fn = $$.getStylePropValue($$.color);
18757 return $$.config.bar_linearGradient ? $$.getGradienColortUrl(d.id) : fn ? fn(d) : null;
18758 },
18759 /**
18760 * Redraw function
18761 * @param {Function} drawFn Retuned function from .getDrawShape() => .generateDrawBar()
18762 * @param {boolean} withTransition With or without transition
18763 * @param {boolean} isSub Subchart draw
18764 * @returns {Array}
18765 * @private
18766 */
18767 redrawBar: function redrawBar(drawFn, withTransition, isSub) {
18768 var _this3 = this;
18769 if (isSub === void 0) {
18770 isSub = !1;
18771 }
18772 var $$ = this,
18773 _ref = isSub ? $$.$el.subchart : $$.$el,
18774 bar = _ref.bar;
18775 return [$$.$T(bar, withTransition, getRandom()).attr("d", function (d) {
18776 _newArrowCheck(this, _this3);
18777 return (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d);
18778 }.bind(this)).style("fill", $$.updateBarColor.bind($$)).style("opacity", null)];
18779 },
18780 /**
18781 * Generate draw function
18782 * @param {object} barIndices data order within x axis.
18783 * barIndices ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
18784 *
18785 * When gropus given as:
18786 * groups: [
18787 * ["data1", "data2"],
18788 * ["data3", "data4"]
18789 * ],
18790 *
18791 * Will be rendered as:
18792 * data1 data3 data1 data3
18793 * data2 data4 data2 data4
18794 * -------------------------
18795 * 0 1
18796 * @param {boolean} isSub If is for subchart
18797 * @returns {Function}
18798 * @private
18799 */
18800 generateDrawBar: function generateDrawBar(barIndices, isSub) {
18801 var _this4 = this,
18802 $$ = this,
18803 config = $$.config,
18804 getPoints = $$.generateGetBarPoints(barIndices, isSub),
18805 isRotated = config.axis_rotated,
18806 barRadius = config.bar_radius,
18807 barRadiusRatio = config.bar_radius_ratio,
18808 getRadius = isNumber(barRadius) && barRadius > 0 ? function () {
18809 _newArrowCheck(this, _this4);
18810 return barRadius;
18811 }.bind(this) : isNumber(barRadiusRatio) ? function (w) {
18812 _newArrowCheck(this, _this4);
18813 return w * barRadiusRatio;
18814 }.bind(this) : null;
18815 return function (d, i) {
18816 _newArrowCheck(this, _this4);
18817 // 4 points that make a bar
18818 var points = getPoints(d, i),
18819 indexX = +isRotated,
18820 indexY = +!indexX,
18821 isNegative = d.value < 0,
18822 pathRadius = ["", ""],
18823 radius = 0,
18824 isGrouped = $$.isGrouped(d.id),
18825 isRadiusData = getRadius && isGrouped ? $$.isStackingRadiusData(d) : !1; // switch points if axis is rotated, not applicable for sub chart
18826 if (getRadius && (!isGrouped || isRadiusData)) {
18827 var index = isRotated ? indexY : indexX,
18828 barW = points[2][index] - points[0][index];
18829 radius = getRadius(barW);
18830 var arc = "a" + radius + "," + radius + " " + (isNegative ? "1 0 0" : "0 0 1") + " ";
18831 pathRadius[+!isRotated] = "" + arc + radius + "," + radius;
18832 pathRadius[+isRotated] = "" + arc + [-radius, radius][isRotated ? "sort" : "reverse"]();
18833 isNegative && pathRadius.reverse();
18834 }
18835
18836 // path string data shouldn't be containing new line chars
18837 // https://github.com/naver/billboard.js/issues/530
18838 var path = isRotated ? "H" + (points[1][indexX] - radius) + " " + pathRadius[0] + "V" + (points[2][indexY] - radius) + " " + pathRadius[1] + "H" + points[3][indexX] : "V" + (points[1][indexY] + (isNegative ? -radius : radius)) + " " + pathRadius[0] + "H" + (points[2][indexX] - radius) + " " + pathRadius[1] + "V" + points[3][indexY];
18839 return "M" + points[0][indexX] + "," + points[0][indexY] + path + "z";
18840 }.bind(this);
18841 },
18842 /**
18843 * Determine if given stacking bar data is radius type
18844 * @param {object} d Data row
18845 * @returns {boolean}
18846 */
18847 isStackingRadiusData: function isStackingRadiusData(d) {
18848 var _this5 = this,
18849 $$ = this,
18850 $el = $$.$el,
18851 config = $$.config,
18852 data = $$.data,
18853 state = $$.state,
18854 id = d.id,
18855 index = d.index,
18856 value = d.value;
18857 // when the data is hidden, check if has rounded edges
18858 if (state.hiddenTargetIds.indexOf(id) > -1) {
18859 var target = $el.bar.filter(function (d) {
18860 _newArrowCheck(this, _this5);
18861 return d.id === id && d.value === value;
18862 }.bind(this));
18863 return !target.empty() && /a\d+/i.test(target.attr("d"));
18864 }
18865
18866 // Find same grouped ids
18867 var keys = config.data_groups.find(function (v) {
18868 _newArrowCheck(this, _this5);
18869 return v.indexOf(id) > -1;
18870 }.bind(this)),
18871 sortedList = $$.orderTargets($$.filterTargetsToShow(data.targets.filter($$.isBarType, $$))).filter(function (v) {
18872 _newArrowCheck(this, _this5);
18873 return keys.indexOf(v.id) > -1;
18874 }.bind(this)),
18875 sortedIds = sortedList.map(function (v) {
18876 var _this6 = this;
18877 _newArrowCheck(this, _this5);
18878 return v.values.filter(function (v2) {
18879 _newArrowCheck(this, _this6);
18880 return v2.index === index && (isNumber(value) && value > 0 ? v2.value > 0 : v2.value < 0);
18881 }.bind(this))[0];
18882 }.bind(this)).filter(Boolean).map(function (v) {
18883 _newArrowCheck(this, _this5);
18884 return v.id;
18885 }.bind(this)); // Get sorted list
18886 // If the given id stays in the last position, then radius should be applied.
18887 return value !== 0 && sortedIds.indexOf(id) === sortedIds.length - 1;
18888 },
18889 /**
18890 * Generate bar coordinate points data
18891 * @param {object} barIndices Data order within x axis.
18892 * @param {boolean} isSub If is for subchart
18893 * @returns {Array} Array of coordinate points
18894 * @private
18895 */
18896 generateGetBarPoints: function generateGetBarPoints(barIndices, isSub) {
18897 var _this7 = this,
18898 $$ = this,
18899 config = $$.config,
18900 axis = isSub ? $$.axis.subX : $$.axis.x,
18901 barTargetsNum = $$.getIndicesMax(barIndices) + 1,
18902 barW = $$.getBarW("bar", axis, barTargetsNum),
18903 barX = $$.getShapeX(barW, barIndices, !!isSub),
18904 barY = $$.getShapeY(!!isSub),
18905 barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub),
18906 yScale = $$.getYScaleById.bind($$);
18907 return function (d, i) {
18908 _newArrowCheck(this, _this7);
18909 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
18910 offset = barOffset(d, i) || y0,
18911 width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
18912 value = d.value,
18913 posX = barX(d),
18914 posY = barY(d);
18915 // fix posY not to overflow opposite quadrant
18916 if (config.axis_rotated && (value > 0 && posY < y0 || value < 0 && y0 < posY)) {
18917 posY = y0;
18918 }
18919 if (!$$.isBarRangeType(d)) {
18920 posY -= y0 - offset;
18921 }
18922 var startPosX = posX + width;
18923
18924 // 4 points that make a bar
18925 return [[posX, offset], [posX, posY], [startPosX, posY], [startPosX, offset]];
18926 }.bind(this);
18927 }
18928});
18929;// CONCATENATED MODULE: ./src/ChartInternal/shape/candlestick.ts
18930
18931
18932function candlestick_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18933function candlestick_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? candlestick_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : candlestick_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18934/**
18935 * Copyright (c) 2017 ~ present NAVER Corp.
18936 * billboard.js project is licensed under the MIT license
18937 */
18938
18939
18940
18941/* harmony default export */ var candlestick = ({
18942 initCandlestick: function initCandlestick() {
18943 var $el = this.$el;
18944 $el.candlestick = $el.main.select("." + $COMMON.chart)
18945 // should positioned at the beginning of the shape node to not overlap others
18946 .append("g").attr("class", $CANDLESTICK.chartCandlesticks);
18947 },
18948 /**
18949 * Update targets by its data
18950 * called from: ChartInternal.updateTargets()
18951 * @param {Array} targets Filtered target by type
18952 * @private
18953 */
18954 updateTargetsForCandlestick: function updateTargetsForCandlestick(targets) {
18955 var _this = this,
18956 $$ = this,
18957 $el = $$.$el,
18958 classChart = $$.getChartClass("Candlestick"),
18959 classFocus = $$.classFocus.bind($$);
18960 if (!$el.candlestick) {
18961 $$.initCandlestick();
18962 }
18963 var mainUpdate = $$.$el.main.select("." + $CANDLESTICK.chartCandlesticks).selectAll("." + $CANDLESTICK.chartCandlestick).data(targets).attr("class", function (d) {
18964 _newArrowCheck(this, _this);
18965 return classChart(d) + classFocus(d);
18966 }.bind(this));
18967 mainUpdate.enter().append("g").attr("class", classChart).style("pointer-events", "none");
18968 },
18969 /**
18970 * Generate/Update elements
18971 * @param {boolean} withTransition Transition for exit elements
18972 * @param {boolean} isSub Subchart draw
18973 * @private
18974 */
18975 updateCandlestick: function updateCandlestick(withTransition, isSub) {
18976 var _this2 = this;
18977 if (isSub === void 0) {
18978 isSub = !1;
18979 }
18980 var $$ = this,
18981 $el = $$.$el,
18982 $T = $$.$T,
18983 $root = isSub ? $el.subchart : $el,
18984 classSetter = $$.getClass("candlestick", !0),
18985 initialOpacity = $$.initialOpacity.bind($$),
18986 candlestick = $root.main.selectAll("." + $CANDLESTICK.chartCandlestick).selectAll("." + $CANDLESTICK.candlestick).data($$.labelishData.bind($$));
18987 $T(candlestick.exit(), withTransition).style("opacity", "0").remove();
18988 var candlestickEnter = candlestick.enter().filter(function (d) {
18989 _newArrowCheck(this, _this2);
18990 return d.value;
18991 }.bind(this)).append("g").attr("class", classSetter);
18992 candlestickEnter.append("line");
18993 candlestickEnter.append("path");
18994 if (!$root.candlestick) {
18995 $root.candlestick = {};
18996 }
18997 $root.candlestick = candlestick.merge(candlestickEnter).style("opacity", initialOpacity);
18998 },
18999 /**
19000 * Get draw function
19001 * @param {object} indices Indice data
19002 * @param {boolean} isSub Subchart draw
19003 * @returns {Function}
19004 * @private
19005 */
19006 generateDrawCandlestick: function generateDrawCandlestick(indices, isSub) {
19007 var _this3 = this,
19008 $$ = this,
19009 config = $$.config,
19010 getPoints = $$.generateGetCandlestickPoints(indices, isSub),
19011 isRotated = config.axis_rotated,
19012 downColor = config.candlestick_color_down;
19013 return function (d, i, g) {
19014 var _value,
19015 _this4 = this;
19016 _newArrowCheck(this, _this3);
19017 var points = getPoints(d, i),
19018 value = $$.getCandlestickData(d),
19019 isUp = (_value = value) == null ? void 0 : _value._isUp,
19020 indexX = +isRotated;
19021 if (g.classed) {
19022 g.classed($CANDLESTICK[isUp ? "valueUp" : "valueDown"], !0);
19023 }
19024 var path = isRotated ? "H" + points[1][1] + " V" + points[1][0] + " H" + points[0][1] : "V" + points[1][1] + " H" + points[1][0] + " V" + points[0][1];
19025 g.select("path").attr("d", "M" + points[0][indexX] + "," + points[0][+!indexX] + path + "z").style("fill", function (d) {
19026 _newArrowCheck(this, _this4);
19027 var color = isUp ? $$.color(d) : isObject(downColor) ? downColor[d.id] : downColor;
19028 return color || $$.color(d);
19029 }.bind(this));
19030
19031 // set line position
19032 var line = g.select("line"),
19033 pos = isRotated ? {
19034 x1: points[2][1],
19035 x2: points[2][2],
19036 y1: points[2][0],
19037 y2: points[2][0]
19038 } : {
19039 x1: points[2][0],
19040 x2: points[2][0],
19041 y1: points[2][1],
19042 y2: points[2][2]
19043 };
19044 for (var x in pos) {
19045 line.attr(x, pos[x]);
19046 }
19047 }.bind(this);
19048 },
19049 /**
19050 * Generate shape drawing points
19051 * @param {object} indices Indice data
19052 * @param {boolean} isSub Subchart draw
19053 * @returns {Function}
19054 */
19055 generateGetCandlestickPoints: function generateGetCandlestickPoints(indices, isSub) {
19056 var _this5 = this;
19057 if (isSub === void 0) {
19058 isSub = !1;
19059 }
19060 var $$ = this,
19061 config = $$.config,
19062 axis = isSub ? $$.axis.subX : $$.axis.x,
19063 targetsNum = $$.getIndicesMax(indices) + 1,
19064 barW = $$.getBarW("candlestick", axis, targetsNum),
19065 x = $$.getShapeX(barW, indices, !!isSub),
19066 y = $$.getShapeY(!!isSub),
19067 shapeOffset = $$.getShapeOffset($$.isBarType, indices, !!isSub),
19068 yScale = $$.getYScaleById.bind($$);
19069 return function (d, i) {
19070 _newArrowCheck(this, _this5);
19071 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
19072 offset = shapeOffset(d, i) || y0,
19073 width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
19074 value = $$.getCandlestickData(d),
19075 points;
19076 if (value) {
19077 var posX = {
19078 start: x(d),
19079 end: 0
19080 };
19081 posX.end = posX.start + width;
19082 var posY = {
19083 start: y(value.open),
19084 end: y(value.close)
19085 },
19086 posLine = {
19087 x: posX.start + width / 2,
19088 high: y(value.high),
19089 low: y(value.low)
19090 };
19091 // fix posY not to overflow opposite quadrant
19092 if (config.axis_rotated && (d.value > 0 && posY.start < y0 || d.value < 0 && y0 < posY.start)) {
19093 posY.start = y0;
19094 }
19095 posY.start -= y0 - offset;
19096 points = [[posX.start, posY.start], [posX.end, posY.end], [posLine.x, posLine.low, posLine.high]];
19097 } else {
19098 points = [[0, 0], [0, 0], [0, 0, 0]];
19099 }
19100 return points;
19101 }.bind(this);
19102 },
19103 /**
19104 * Redraw function
19105 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
19106 * @param {boolean} withTransition With or without transition
19107 * @param {boolean} isSub Subchart draw
19108 * @returns {Array}
19109 */
19110 redrawCandlestick: function redrawCandlestick(drawFn, withTransition, isSub) {
19111 if (isSub === void 0) {
19112 isSub = !1;
19113 }
19114 var $$ = this,
19115 $el = $$.$el,
19116 $T = $$.$T,
19117 _ref = isSub ? $el.subchart : $el,
19118 candlestick = _ref.candlestick,
19119 rand = getRandom(!0);
19120 return [candlestick.each(function (d, i) {
19121 var g = $T((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), withTransition, rand);
19122 drawFn(d, i, g);
19123 }).style("opacity", null)];
19124 },
19125 /**
19126 * Get candlestick data as object
19127 * @param {object} param Data object
19128 * @param {Array|object} param.value Data value
19129 * @returns {object|null} Converted data object
19130 * @private
19131 */
19132 getCandlestickData: function getCandlestickData(_ref2) {
19133 var value = _ref2.value,
19134 d;
19135 if (isArray(value)) {
19136 var open = value[0],
19137 high = value[1],
19138 low = value[2],
19139 close = value[3],
19140 _value$ = value[4],
19141 volume = _value$ === void 0 ? !1 : _value$;
19142 d = {
19143 open: open,
19144 high: high,
19145 low: low,
19146 close: close
19147 };
19148 if (volume !== !1) {
19149 d.volume = volume;
19150 }
19151 } else if (isObject(value)) {
19152 d = candlestick_objectSpread({}, value);
19153 }
19154 if (d) {
19155 d._isUp = d.close >= d.open;
19156 }
19157 return d || null;
19158 }
19159});
19160;// CONCATENATED MODULE: ./src/ChartInternal/shape/gauge.ts
19161
19162/**
19163 * Copyright (c) 2017 ~ present NAVER Corp.
19164 * billboard.js project is licensed under the MIT license
19165 */
19166
19167
19168
19169/* harmony default export */ var gauge = ({
19170 initGauge: function initGauge() {
19171 var _this = this,
19172 $$ = this,
19173 config = $$.config,
19174 arcs = $$.$el.arcs,
19175 appendText = function (className) {
19176 _newArrowCheck(this, _this);
19177 arcs.append("text").attr("class", className).style("text-anchor", "middle").style("pointer-events", "none");
19178 }.bind(this);
19179 if ($$.hasType("gauge")) {
19180 var hasMulti = $$.hasMultiArcGauge();
19181 arcs.append(hasMulti ? "g" : "path").attr("class", $ARC.chartArcsBackground).style("fill", !hasMulti && config.gauge_background || null);
19182 config.gauge_units && appendText($GAUGE.chartArcsGaugeUnit);
19183 if (config.gauge_label_show) {
19184 appendText($GAUGE.chartArcsGaugeMin);
19185 config.gauge_fullCircle || appendText($GAUGE.chartArcsGaugeMax);
19186 }
19187 }
19188 },
19189 updateGaugeMax: function updateGaugeMax() {
19190 var $$ = this,
19191 config = $$.config,
19192 state = $$.state,
19193 hasMultiGauge = $$.hasMultiArcGauge(),
19194 max = hasMultiGauge ? $$.getMinMaxData().max[0].value : $$.getTotalDataSum(state.rendered);
19195 // if gauge_max less than max, make max to max value
19196 if (max + config.gauge_min * (config.gauge_min > 0 ? -1 : 1) > config.gauge_max) {
19197 config.gauge_max = max - config.gauge_min;
19198 }
19199 },
19200 redrawMultiArcGauge: function redrawMultiArcGauge() {
19201 var _this2 = this,
19202 $$ = this,
19203 config = $$.config,
19204 state = $$.state,
19205 $el = $$.$el,
19206 hiddenTargetIds = $$.state.hiddenTargetIds,
19207 arcLabelLines = $el.main.selectAll("." + $ARC.arcs).selectAll("." + $ARC.arcLabelLine).data($$.arcData.bind($$)),
19208 mainArcLabelLine = arcLabelLines.enter().append("rect").attr("class", function (d) {
19209 _newArrowCheck(this, _this2);
19210 return $ARC.arcLabelLine + " " + $COMMON.target + " " + $COMMON.target + "-" + d.data.id;
19211 }.bind(this)).merge(arcLabelLines);
19212 mainArcLabelLine.style("fill", function (d) {
19213 _newArrowCheck(this, _this2);
19214 return $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data);
19215 }.bind(this)).style("display", config.gauge_label_show ? null : "none").each(function (d) {
19216 var lineLength = 0,
19217 lineThickness = 2,
19218 x = 0,
19219 y = 0,
19220 transform = "";
19221 if (hiddenTargetIds.indexOf(d.data.id) < 0) {
19222 var updated = $$.updateAngle(d),
19223 innerLineLength = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length * (updated.index + 1),
19224 lineAngle = updated.endAngle - Math.PI / 2,
19225 arcInnerRadius = state.radius - innerLineLength,
19226 linePositioningAngle = lineAngle - (arcInnerRadius === 0 ? 0 : 1 / arcInnerRadius);
19227 lineLength = state.radiusExpanded - state.radius + innerLineLength;
19228 x = Math.cos(linePositioningAngle) * arcInnerRadius;
19229 y = Math.sin(linePositioningAngle) * arcInnerRadius;
19230 transform = "rotate(" + lineAngle * 180 / Math.PI + ", " + x + ", " + y + ")";
19231 }
19232 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).attr("x", x).attr("y", y).attr("width", lineLength).attr("height", lineThickness).attr("transform", transform).style("stroke-dasharray", "0, " + (lineLength + lineThickness) + ", 0");
19233 });
19234 },
19235 textForGaugeMinMax: function textForGaugeMinMax(value, isMax) {
19236 var $$ = this,
19237 config = $$.config,
19238 format = config.gauge_label_extents;
19239 return isFunction(format) ? format.bind($$.api)(value, isMax) : value;
19240 },
19241 getGaugeLabelHeight: function getGaugeLabelHeight() {
19242 var config = this.config;
19243 return this.config.gauge_label_show && !config.gauge_fullCircle ? 20 : 0;
19244 },
19245 getPaddingBottomForGauge: function getPaddingBottomForGauge() {
19246 var $$ = this;
19247 return $$.getGaugeLabelHeight() * ($$.config.gauge_label_show ? 2 : 2.5);
19248 }
19249});
19250;// CONCATENATED MODULE: ./src/ChartInternal/shape/bubble.ts
19251
19252/**
19253 * Copyright (c) 2017 ~ present NAVER Corp.
19254 * billboard.js project is licensed under the MIT license
19255 */
19256
19257
19258/* harmony default export */ var bubble = ({
19259 /**
19260 * Initializer
19261 * @private
19262 */
19263 initBubble: function initBubble() {
19264 var $$ = this,
19265 config = $$.config;
19266 if ($$.hasType("bubble")) {
19267 config.point_show = !0;
19268 config.point_type = "circle";
19269 config.point_sensitivity = 25;
19270 }
19271 },
19272 /**
19273 * Get user agent's computed value
19274 * @returns {number}
19275 * @private
19276 */
19277 getBaseLength: function getBaseLength() {
19278 var $$ = this,
19279 _$$$state = $$.state,
19280 width = _$$$state.width,
19281 height = _$$$state.height,
19282 cacheKey = KEY.bubbleBaseLength,
19283 baseLength = $$.cache.get(cacheKey);
19284 if (!baseLength) {
19285 $$.cache.add(cacheKey, baseLength = getMinMax("min", [width, height]));
19286 }
19287 return baseLength;
19288 },
19289 /**
19290 * Get the radius value for bubble circle
19291 * @param {object} d Data object
19292 * @returns {number}
19293 * @private
19294 */
19295 getBubbleR: function getBubbleR(d) {
19296 var _this = this,
19297 $$ = this,
19298 maxR = $$.config.bubble_maxR;
19299 if (isFunction(maxR)) {
19300 maxR = maxR.bind($$.api)(d);
19301 } else if (!isNumber(maxR)) {
19302 maxR = $$.getBaseLength() / ($$.getMaxDataCount() * 2) + 12;
19303 }
19304 var max = getMinMax("max", $$.getMinMaxData().max.map(function (d) {
19305 _newArrowCheck(this, _this);
19306 return $$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "y") : isObject(d.value) ? d.value.mid : d.value;
19307 }.bind(this))),
19308 maxArea = maxR * maxR * Math.PI,
19309 area = ($$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "z") : d.value) * (maxArea / max);
19310 return Math.sqrt(area / Math.PI);
19311 },
19312 /**
19313 * Get bubble dimension data
19314 * @param {object|Array} d data value
19315 * @param {string} type - y or z
19316 * @returns {number}
19317 * @private
19318 */
19319 getBubbleZData: function getBubbleZData(d, type) {
19320 return isObject(d) ? d[type] : d[type === "y" ? 0 : 1];
19321 }
19322});
19323;// CONCATENATED MODULE: ./src/ChartInternal/shape/line.ts
19324
19325/**
19326 * Copyright (c) 2017 ~ present NAVER Corp.
19327 * billboard.js project is licensed under the MIT license
19328 */
19329
19330
19331
19332
19333/* harmony default export */ var line = ({
19334 initLine: function initLine() {
19335 var $el = this.$el;
19336 $el.line = $el.main.select("." + $COMMON.chart).append("g").attr("class", $LINE.chartLines).call(this.setCssRule(!1, "." + $LINE.chartLines, ["pointer-events:none"]));
19337 },
19338 updateTargetsForLine: function updateTargetsForLine(t) {
19339 var _this = this,
19340 $$ = this,
19341 _$$$$el = $$.$el,
19342 area = _$$$$el.area,
19343 line = _$$$$el.line,
19344 main = _$$$$el.main,
19345 classChartLine = $$.getChartClass("Line"),
19346 classLines = $$.getClass("lines", !0),
19347 classFocus = $$.classFocus.bind($$);
19348 if (!line) {
19349 $$.initLine();
19350 }
19351 var targets = t.filter(function (d) {
19352 _newArrowCheck(this, _this);
19353 return !($$.isScatterType(d) || $$.isBubbleType(d));
19354 }.bind(this)),
19355 mainLineUpdate = main.select("." + $LINE.chartLines).selectAll("." + $LINE.chartLine).data(targets).attr("class", function (d) {
19356 _newArrowCheck(this, _this);
19357 return classChartLine(d) + classFocus(d);
19358 }.bind(this)),
19359 mainLineEnter = mainLineUpdate.enter().append("g").attr("class", classChartLine).style("opacity", "0").style("pointer-events", $$.getStylePropValue("none"));
19360 // Lines for each data
19361 mainLineEnter.append("g").attr("class", classLines);
19362
19363 // Areas
19364 if ($$.hasTypeOf("Area")) {
19365 var mainLine = (!area && mainLineEnter.empty() ? mainLineUpdate : mainLineEnter).filter($$.isAreaType.bind($$));
19366 $$.initArea(mainLine);
19367 }
19368 $$.updateTargetForCircle(targets, mainLineEnter);
19369 },
19370 /**
19371 * Generate/Update elements
19372 * @param {boolean} withTransition Transition for exit elements
19373 * @param {boolean} isSub Subchart draw
19374 * @private
19375 */
19376 updateLine: function updateLine(withTransition, isSub) {
19377 var _this2 = this;
19378 if (isSub === void 0) {
19379 isSub = !1;
19380 }
19381 var $$ = this,
19382 extraLineClasses = $$.format.extraLineClasses,
19383 $el = $$.$el,
19384 $T = $$.$T,
19385 $root = isSub ? $el.subchart : $el,
19386 line = $root.main.selectAll("." + $LINE.lines).selectAll("." + $LINE.line).data($$.lineData.bind($$));
19387 $T(line.exit(), withTransition).style("opacity", "0").remove();
19388 $root.line = line.enter().append("path").attr("class", function (d) {
19389 _newArrowCheck(this, _this2);
19390 return $$.getClass("line", !0)(d) + " " + (extraLineClasses(d) || "");
19391 }.bind(this)).style("stroke", $$.color).merge(line).style("opacity", $$.initialOpacity.bind($$)).style("shape-rendering", function (d) {
19392 _newArrowCheck(this, _this2);
19393 return $$.isStepType(d) ? "crispEdges" : "";
19394 }.bind(this)).attr("transform", null);
19395 },
19396 /**
19397 * Redraw function
19398 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
19399 * @param {boolean} withTransition With or without transition
19400 * @param {boolean} isSub Subchart draw
19401 * @returns {Array}
19402 */
19403 redrawLine: function redrawLine(drawFn, withTransition, isSub) {
19404 if (isSub === void 0) {
19405 isSub = !1;
19406 }
19407 var $$ = this,
19408 $el = $$.$el,
19409 $T = $$.$T,
19410 _ref = isSub ? $el.subchart : $el,
19411 line = _ref.line;
19412 return [$T(line, withTransition, getRandom()).attr("d", drawFn).style("stroke", this.color).style("opacity", null)];
19413 },
19414 /**
19415 * Get the curve interpolate
19416 * @param {Array} d Data object
19417 * @returns {Function}
19418 * @private
19419 */
19420 getCurve: function getCurve(d) {
19421 var _this3 = this,
19422 $$ = this,
19423 isRotatedStepType = $$.config.axis_rotated && $$.isStepType(d);
19424 // when is step & rotated, should be computed in different way
19425 // https://github.com/naver/billboard.js/issues/471
19426 return isRotatedStepType ? function (context) {
19427 _newArrowCheck(this, _this3);
19428 var step = $$.getInterpolate(d)(context);
19429
19430 // keep the original method
19431 step.orgPoint = step.point;
19432
19433 // to get rotated path data
19434 step.pointRotated = function (x, y) {
19435 this._point === 1 && (this._point = 2);
19436 var y1 = this._y * (1 - this._t) + y * this._t;
19437 this._context.lineTo(this._x, y1);
19438 this._context.lineTo(x, y1);
19439 this._x = x;
19440 this._y = y;
19441 };
19442 step.point = function (x, y) {
19443 this._point === 0 ? this.orgPoint(x, y) : this.pointRotated(x, y);
19444 };
19445 return step;
19446 }.bind(this) : $$.getInterpolate(d);
19447 },
19448 generateDrawLine: function generateDrawLine(lineIndices, isSub) {
19449 var _this4 = this,
19450 $$ = this,
19451 config = $$.config,
19452 scale = $$.scale,
19453 lineConnectNull = config.line_connectNull,
19454 isRotated = config.axis_rotated,
19455 getPoints = $$.generateGetLinePoints(lineIndices, isSub),
19456 yScale = $$.getYScaleById.bind($$),
19457 xValue = function (d) {
19458 _newArrowCheck(this, _this4);
19459 return (isSub ? $$.subxx : $$.xx).call($$, d);
19460 }.bind(this),
19461 yValue = function (d, i) {
19462 _newArrowCheck(this, _this4);
19463 return $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.getBaseValue(d));
19464 }.bind(this),
19465 line = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.line)();
19466 line = isRotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
19467 if (!lineConnectNull) {
19468 line = line.defined(function (d) {
19469 _newArrowCheck(this, _this4);
19470 return $$.getBaseValue(d) !== null;
19471 }.bind(this));
19472 }
19473 var x = isSub ? scale.subX : scale.x;
19474 return function (d) {
19475 _newArrowCheck(this, _this4);
19476 var y = yScale(d.id, isSub),
19477 values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
19478 x0 = 0,
19479 y0 = 0,
19480 path;
19481 if ($$.isLineType(d)) {
19482 var regions = config.data_regions[d.id];
19483 if (regions) {
19484 path = $$.lineWithRegions(values, scale.zoom || x, y, regions);
19485 } else {
19486 if ($$.isStepType(d)) {
19487 values = $$.convertValuesToStep(values);
19488 }
19489 path = line.curve($$.getCurve(d))(values);
19490 }
19491 } else {
19492 if (values[0]) {
19493 x0 = x(values[0].x);
19494 y0 = y(values[0].value);
19495 }
19496 path = isRotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
19497 }
19498 return path || "M 0 0";
19499 }.bind(this);
19500 },
19501 lineWithRegions: function lineWithRegions(d, x, y, _regions) {
19502 var _this5 = this,
19503 $$ = this,
19504 config = $$.config,
19505 isRotated = config.axis_rotated,
19506 isTimeSeries = $$.axis.isTimeSeries(),
19507 xOffset = $$.axis.isCategorized() ? .5 : 0,
19508 regions = [],
19509 dasharray = "2 2",
19510 xp,
19511 yp,
19512 diff,
19513 diffx2,
19514 isWithinRegions = function (withinX, withinRegions) {
19515 _newArrowCheck(this, _this5);
19516 for (var i = 0, reg; reg = withinRegions[i]; i++) {
19517 if (reg.start < withinX && withinX <= reg.end) {
19518 return reg.style;
19519 }
19520 }
19521 return !1;
19522 }.bind(this);
19523 // Check start/end of regions
19524 if (isDefined(_regions)) {
19525 var getValue = function (v, def) {
19526 _newArrowCheck(this, _this5);
19527 return isUndefined(v) ? def : isTimeSeries ? parseDate.call($$, v) : v;
19528 }.bind(this);
19529 for (var i = 0, reg; reg = _regions[i]; i++) {
19530 var start = getValue(reg.start, d[0].x),
19531 end = getValue(reg.end, d[d.length - 1].x),
19532 style = reg.style || {
19533 dasharray: dasharray
19534 };
19535 regions[i] = {
19536 start: start,
19537 end: end,
19538 style: style
19539 };
19540 }
19541 }
19542
19543 // Set scales
19544 var xValue = isRotated ? function (dt) {
19545 _newArrowCheck(this, _this5);
19546 return y(dt.value);
19547 }.bind(this) : function (dt) {
19548 _newArrowCheck(this, _this5);
19549 return x(dt.x);
19550 }.bind(this),
19551 yValue = isRotated ? function (dt) {
19552 _newArrowCheck(this, _this5);
19553 return x(dt.x);
19554 }.bind(this) : function (dt) {
19555 _newArrowCheck(this, _this5);
19556 return y(dt.value);
19557 }.bind(this),
19558 generateM = function (points) {
19559 _newArrowCheck(this, _this5);
19560 return "M" + points[0][0] + "," + points[0][1] + "L" + points[1][0] + "," + points[1][1];
19561 }.bind(this),
19562 sWithRegion = isTimeSeries ? function (d0, d1, k, timeseriesDiff) {
19563 _newArrowCheck(this, _this5);
19564 var x0 = d0.x.getTime(),
19565 xDiff = d1.x - d0.x,
19566 xv0 = new Date(x0 + xDiff * k),
19567 xv1 = new Date(x0 + xDiff * (k + timeseriesDiff)),
19568 points = isRotated ? [[y(yp(k)), x(xv0)], [y(yp(k + diff)), x(xv1)]] : [[x(xv0), y(yp(k))], [x(xv1), y(yp(k + diff))]];
19569 return generateM(points);
19570 }.bind(this) : function (d0, d1, k, otherDiff) {
19571 _newArrowCheck(this, _this5);
19572 var points = isRotated ? [[y(yp(k), !0), x(xp(k))], [y(yp(k + otherDiff), !0), x(xp(k + otherDiff))]] : [[x(xp(k), !0), y(yp(k))], [x(xp(k + otherDiff), !0), y(yp(k + otherDiff))]];
19573 return generateM(points);
19574 }.bind(this),
19575 axisType = {
19576 x: $$.axis.getAxisType("x"),
19577 y: $$.axis.getAxisType("y")
19578 },
19579 path = "";
19580 for (var _i = 0, data; data = d[_i]; _i++) {
19581 var prevData = d[_i - 1],
19582 hasPrevData = prevData && isValue(prevData.value),
19583 style = isWithinRegions(data.x, regions);
19584 // https://github.com/naver/billboard.js/issues/1172
19585 if (!isValue(data.value)) {
19586 continue;
19587 }
19588
19589 // Draw as normal
19590 if (isUndefined(regions) || !style || !hasPrevData) {
19591 path += "" + (_i && hasPrevData ? "L" : "M") + xValue(data) + "," + yValue(data);
19592 } else if (hasPrevData) {
19593 try {
19594 style = style.dasharray.split(" ");
19595 } catch (e) {
19596 style = dasharray.split(" ");
19597 }
19598
19599 // Draw with region // TODO: Fix for horizotal charts
19600 xp = getScale(axisType.x, prevData.x + xOffset, data.x + xOffset);
19601 yp = getScale(axisType.y, prevData.value, data.value);
19602 var dx = x(data.x) - x(prevData.x),
19603 dy = y(data.value) - y(prevData.value),
19604 dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
19605 diff = style[0] / dd;
19606 diffx2 = diff * style[1];
19607 for (var j = diff; j <= 1; j += diffx2) {
19608 path += sWithRegion(prevData, data, j, diff);
19609
19610 // to make sure correct line drawing
19611 if (j + diffx2 >= 1) {
19612 path += sWithRegion(prevData, data, 1, 0);
19613 }
19614 }
19615 }
19616 }
19617 return path;
19618 },
19619 isWithinStep: function isWithinStep(that, y) {
19620 return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
19621 },
19622 shouldDrawPointsForLine: function shouldDrawPointsForLine(d) {
19623 var linePoint = this.config.line_point;
19624 return linePoint === !0 || isArray(linePoint) && linePoint.indexOf(d.id) !== -1;
19625 }
19626});
19627;// CONCATENATED MODULE: ./src/ChartInternal/shape/point.ts
19628
19629var point_this = undefined;
19630/**
19631 * Copyright (c) 2017 ~ present NAVER Corp.
19632 * billboard.js project is licensed under the MIT license
19633 */
19634
19635
19636
19637
19638var getTransitionName = function () {
19639 _newArrowCheck(this, point_this);
19640 return getRandom();
19641}.bind(undefined);
19642/* harmony default export */ var point = ({
19643 hasValidPointType: function hasValidPointType(type) {
19644 return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
19645 },
19646 hasValidPointDrawMethods: function hasValidPointDrawMethods(type) {
19647 var pointType = type || this.config.point_type;
19648 return isObjectType(pointType) && isFunction(pointType.create) && isFunction(pointType.update);
19649 },
19650 initialOpacityForCircle: function initialOpacityForCircle(d) {
19651 var config = this.config,
19652 withoutFadeIn = this.state.withoutFadeIn,
19653 opacity = config.point_opacity;
19654 if (isUndefined(opacity)) {
19655 opacity = this.getBaseValue(d) !== null && withoutFadeIn[d.id] ? this.opacityForCircle(d) : "0";
19656 }
19657 return opacity;
19658 },
19659 opacityForCircle: function opacityForCircle(d) {
19660 var config = this.config,
19661 opacity = config.point_opacity;
19662 if (isUndefined(opacity)) {
19663 opacity = config.point_show && !config.point_focus_only ? null : "0";
19664 opacity = isValue(this.getBaseValue(d)) ? this.isBubbleType(d) || this.isScatterType(d) ? "0.5" : opacity : "0";
19665 }
19666 return opacity;
19667 },
19668 initCircle: function initCircle() {
19669 var $$ = this,
19670 main = $$.$el.main;
19671 $$.point = $$.generatePoint();
19672 if (($$.hasType("bubble") || $$.hasType("scatter")) && main.select("." + $CIRCLE.chartCircles).empty()) {
19673 main.select("." + $COMMON.chart).append("g").attr("class", $CIRCLE.chartCircles);
19674 }
19675 },
19676 updateTargetForCircle: function updateTargetForCircle(targetsValue, enterNodeValue) {
19677 var _this2 = this,
19678 $$ = this,
19679 config = $$.config,
19680 data = $$.data,
19681 $el = $$.$el,
19682 selectionEnabled = config.interaction_enabled && config.data_selection_enabled,
19683 isSelectable = selectionEnabled && config.data_selection_isselectable,
19684 classCircles = $$.getClass("circles", !0);
19685 if (!config.point_show) {
19686 return;
19687 }
19688 $el.circle || $$.initCircle();
19689 var targets = targetsValue,
19690 enterNode = enterNodeValue;
19691 // only for scatter & bubble type should generate seprate <g> node
19692 if (!targets) {
19693 targets = data.targets.filter(function (d) {
19694 _newArrowCheck(this, _this2);
19695 return this.isScatterType(d) || this.isBubbleType(d);
19696 }.bind(this));
19697 var mainCircle = $el.main.select("." + $CIRCLE.chartCircles).style("pointer-events", "none").selectAll("." + $CIRCLE.circles).data(targets);
19698 mainCircle.exit().remove();
19699 enterNode = mainCircle.enter();
19700 }
19701
19702 // Circles for each data point on lines
19703 selectionEnabled && enterNode.append("g").attr("class", function (d) {
19704 _newArrowCheck(this, _this2);
19705 return $$.generateClass($SELECT.selectedCircles, d.id);
19706 }.bind(this));
19707 enterNode.append("g").attr("class", classCircles).call(function (selection) {
19708 _newArrowCheck(this, _this2);
19709 $$.setCssRule(!0, "." + $CIRCLE.circles, ["cursor:pointer"], isSelectable)(selection);
19710 $$.setCssRule(!0, " ." + $CIRCLE.circle, ["fill", "stroke"], $$.color)(selection);
19711 }.bind(this)).style("opacity", function () {
19712 var parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode);
19713
19714 // if the parent node is .bb-chart-circles (bubble, scatter), initialize <g bb-circles> with opacity "0"
19715 return parent.attr("class").indexOf($CIRCLE.chartCircles) > -1 ? "0" : null;
19716 });
19717
19718 // Update date for selected circles
19719 selectionEnabled && targets.forEach(function (t) {
19720 var _this3 = this;
19721 _newArrowCheck(this, _this2);
19722 $el.main.selectAll("." + $SELECT.selectedCircles + $$.getTargetSelectorSuffix(t.id)).selectAll("" + $SELECT.selectedCircle).each(function (d) {
19723 _newArrowCheck(this, _this3);
19724 d.value = t.values[d.index].value;
19725 }.bind(this));
19726 }.bind(this));
19727 },
19728 updateCircle: function updateCircle(isSub) {
19729 var _this4 = this;
19730 if (isSub === void 0) {
19731 isSub = !1;
19732 }
19733 var $$ = this,
19734 config = $$.config,
19735 state = $$.state,
19736 $el = $$.$el,
19737 focusOnly = config.point_focus_only,
19738 $root = isSub ? $el.subchart : $el;
19739 if (config.point_show && !state.toggling) {
19740 var circles = $root.main.selectAll("." + $CIRCLE.circles).selectAll("." + $CIRCLE.circle).data(function (d) {
19741 _newArrowCheck(this, _this4);
19742 return $$.isLineType(d) && $$.shouldDrawPointsForLine(d) || $$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ? focusOnly ? [d.values[0]] : d.values : [];
19743 }.bind(this));
19744 circles.exit().remove();
19745 circles.enter().filter(Boolean).append($$.point("create", this, $$.pointR.bind($$), $$.getStylePropValue($$.color)));
19746 $root.circle = $root.main.selectAll("." + $CIRCLE.circles + " ." + $CIRCLE.circle).style("stroke", $$.getStylePropValue($$.color)).style("opacity", $$.initialOpacityForCircle.bind($$));
19747 }
19748 },
19749 redrawCircle: function redrawCircle(cx, cy, withTransition, flow, isSub) {
19750 if (isSub === void 0) {
19751 isSub = !1;
19752 }
19753 var $$ = this,
19754 rendered = $$.state.rendered,
19755 $el = $$.$el,
19756 $T = $$.$T,
19757 $root = isSub ? $el.subchart : $el,
19758 selectedCircles = $root.main.selectAll("." + $SELECT.selectedCircle);
19759 if (!$$.config.point_show) {
19760 return [];
19761 }
19762 var fn = $$.point("update", $$, cx, cy, $$.getStylePropValue($$.color), withTransition, flow, selectedCircles),
19763 posAttr = $$.isCirclePoint() ? "c" : "",
19764 t = getRandom(),
19765 opacityStyleFn = $$.opacityForCircle.bind($$),
19766 mainCircles = [];
19767 $root.circle.each(function (d) {
19768 var result = fn.bind(this)(d);
19769 result = $T(result, withTransition || !rendered, t).style("opacity", opacityStyleFn);
19770 mainCircles.push(result);
19771 });
19772 return [mainCircles, $T(selectedCircles, withTransition).attr(posAttr + "x", cx).attr(posAttr + "y", cy)];
19773 },
19774 /**
19775 * Show focused data point circle
19776 * @param {object} d Selected data
19777 * @private
19778 */
19779 showCircleFocus: function showCircleFocus(d) {
19780 var $$ = this,
19781 config = $$.config,
19782 _$$$state = $$.state,
19783 hasRadar = _$$$state.hasRadar,
19784 resizing = _$$$state.resizing,
19785 toggling = _$$$state.toggling,
19786 transiting = _$$$state.transiting,
19787 $el = $$.$el,
19788 circle = $el.circle;
19789 if (transiting === !1 && config.point_focus_only && circle) {
19790 var cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$),
19791 cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$),
19792 withTransition = toggling || isUndefined(d),
19793 fn = $$.point("update", $$, cx, cy, $$.getStylePropValue($$.color), resizing ? !1 : withTransition);
19794 if (d) {
19795 circle = circle.filter(function (t) {
19796 var _this5 = this,
19797 data = d.filter(function (v) {
19798 _newArrowCheck(this, _this5);
19799 return v.id === t.id;
19800 }.bind(this));
19801 return data.length ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).datum(data[0]) : !1;
19802 });
19803 }
19804 circle.attr("class", this.updatePointClass.bind(this)).style("opacity", null).each(function (d) {
19805 var id = d.id,
19806 index = d.index,
19807 value = d.value,
19808 visibility = "hidden";
19809 if (isValue(value)) {
19810 fn.bind(this)(d);
19811 $$.expandCircles(index, id);
19812 visibility = "";
19813 }
19814 this.style.visibility = visibility;
19815 });
19816 }
19817 },
19818 /**
19819 * Hide focused data point circle
19820 * @private
19821 */
19822 hideCircleFocus: function hideCircleFocus() {
19823 var $$ = this,
19824 config = $$.config,
19825 circle = $$.$el.circle;
19826 if (config.point_focus_only && circle) {
19827 $$.unexpandCircles();
19828 circle.style("visibility", "hidden");
19829 }
19830 },
19831 circleX: function circleX(d) {
19832 return this.xx(d);
19833 },
19834 updateCircleY: function updateCircleY(isSub) {
19835 var _this6 = this;
19836 if (isSub === void 0) {
19837 isSub = !1;
19838 }
19839 var $$ = this,
19840 getPoints = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType), isSub);
19841 return function (d, i) {
19842 _newArrowCheck(this, _this6);
19843 var id = d.id;
19844 return $$.isGrouped(id) ? getPoints(d, i)[0][1] : $$.getYScaleById(id, isSub)($$.getBaseValue(d));
19845 }.bind(this);
19846 },
19847 expandCircles: function expandCircles(i, id, reset) {
19848 var $$ = this,
19849 r = $$.pointExpandedR.bind($$);
19850 reset && $$.unexpandCircles();
19851 var circles = $$.getShapeByIndex("circle", i, id).classed($COMMON.EXPANDED, !0),
19852 scale = r(circles) / $$.config.point_r,
19853 ratio = 1 - scale;
19854 if ($$.isCirclePoint()) {
19855 circles.attr("r", r);
19856 } else {
19857 // transform must be applied to each node individually
19858 circles.each(function () {
19859 var point = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
19860 if (this.tagName === "circle") {
19861 point.attr("r", r);
19862 } else {
19863 var _this$getBBox = this.getBBox(),
19864 width = _this$getBBox.width,
19865 height = _this$getBBox.height,
19866 x = ratio * (+point.attr("x") + width / 2),
19867 y = ratio * (+point.attr("y") + height / 2);
19868 point.attr("transform", "translate(" + x + " " + y + ") scale(" + scale + ")");
19869 }
19870 });
19871 }
19872 },
19873 unexpandCircles: function unexpandCircles(i) {
19874 var $$ = this,
19875 r = $$.pointR.bind($$),
19876 circles = $$.getShapeByIndex("circle", i).filter(function () {
19877 return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($COMMON.EXPANDED);
19878 }).classed($COMMON.EXPANDED, !1);
19879 circles.attr("r", r);
19880 if (!$$.isCirclePoint()) {
19881 var _scale = r(circles) / $$.config.point_r;
19882 circles.attr("transform", _scale !== 1 ? "scale(" + _scale + ")" : null);
19883 }
19884 },
19885 pointR: function (d) {
19886 var $$ = this,
19887 config = $$.config,
19888 pointR = config.point_r,
19889 r = pointR;
19890 if ($$.isBubbleType(d)) {
19891 r = $$.getBubbleR(d);
19892 } else if (isFunction(pointR)) {
19893 r = pointR.bind($$.api)(d);
19894 }
19895 return r;
19896 },
19897 pointExpandedR: function pointExpandedR(d) {
19898 var $$ = this,
19899 config = $$.config,
19900 scale = $$.isBubbleType(d) ? 1.15 : 1.75;
19901 return config.point_focus_expand_enabled ? config.point_focus_expand_r || $$.pointR(d) * scale : $$.pointR(d);
19902 },
19903 pointSelectR: function pointSelectR(d) {
19904 var $$ = this,
19905 selectR = $$.config.point_select_r;
19906 return isFunction(selectR) ? selectR(d) : selectR || $$.pointR(d) * 4;
19907 },
19908 isWithinCircle: function isWithinCircle(node, r) {
19909 var mouse = getPointer(this.state.event, node),
19910 element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(node),
19911 prefix = this.isCirclePoint(node) ? "c" : "",
19912 cx = +element.attr(prefix + "x"),
19913 cy = +element.attr(prefix + "y");
19914 // if node don't have cx/y or x/y attribute value
19915 if (!(cx || cy) && node.nodeType === 1) {
19916 var _getBoundingRect = getBoundingRect(node),
19917 x = _getBoundingRect.x,
19918 y = _getBoundingRect.y;
19919 cx = x;
19920 cy = y;
19921 }
19922 return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < (r || this.config.point_sensitivity);
19923 },
19924 insertPointInfoDefs: function insertPointInfoDefs(point, id) {
19925 var _this7 = this,
19926 $$ = this,
19927 copyAttr = function (from, target) {
19928 _newArrowCheck(this, _this7);
19929 for (var attribs = from.attributes, i = 0, name; name = attribs[i]; i++) {
19930 name = name.name;
19931 target.setAttribute(name, from.getAttribute(name));
19932 }
19933 }.bind(this),
19934 doc = new DOMParser().parseFromString(point, "image/svg+xml"),
19935 node = doc.documentElement,
19936 clone = browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, node.nodeName.toLowerCase()),
19937 _node$childNodes;
19938 clone.id = id;
19939 clone.style.fill = "inherit";
19940 clone.style.stroke = "inherit";
19941 copyAttr(node, clone);
19942 if ((_node$childNodes = node.childNodes) != null && _node$childNodes.length) {
19943 var parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(clone);
19944 if ("innerHTML" in clone) {
19945 parent.html(node.innerHTML);
19946 } else {
19947 toArray(node.childNodes).forEach(function (v) {
19948 _newArrowCheck(this, _this7);
19949 copyAttr(v, parent.append(v.tagName).node());
19950 }.bind(this));
19951 }
19952 }
19953 $$.$el.defs.node().appendChild(clone);
19954 },
19955 pointFromDefs: function pointFromDefs(id) {
19956 return this.$el.defs.select("#" + id);
19957 },
19958 updatePointClass: function updatePointClass(d) {
19959 var $$ = this,
19960 circle = $$.$el.circle,
19961 pointClass = !1;
19962 if (isObject(d) || circle) {
19963 pointClass = d === !0 ? circle.each(function (d) {
19964 var className = $$.getClass("circle", !0)(d);
19965 if (this.getAttribute("class").indexOf($COMMON.EXPANDED) > -1) {
19966 className += " " + $COMMON.EXPANDED;
19967 }
19968 this.setAttribute("class", className);
19969 }) : $$.getClass("circle", !0)(d);
19970 }
19971 return pointClass;
19972 },
19973 generateGetLinePoints: function generateGetLinePoints(lineIndices, isSub) {
19974 var _this8 = this,
19975 $$ = this,
19976 config = $$.config,
19977 x = $$.getShapeX(0, lineIndices, isSub),
19978 y = $$.getShapeY(isSub),
19979 lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, isSub),
19980 yScale = $$.getYScaleById.bind($$);
19981 return function (d, i) {
19982 _newArrowCheck(this, _this8);
19983 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
19984 offset = lineOffset(d, i) || y0,
19985 posX = x(d),
19986 posY = y(d);
19987 // fix posY not to overflow opposite quadrant
19988 if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
19989 posY = y0;
19990 }
19991
19992 // 1 point that marks the line position
19993 var point = [posX, posY - (y0 - offset)];
19994 return [point, point,
19995 // from here and below, needed for compatibility
19996 point, point];
19997 }.bind(this);
19998 },
19999 generatePoint: function generatePoint() {
20000 var $$ = this,
20001 config = $$.config,
20002 datetimeId = $$.state.datetimeId,
20003 ids = [],
20004 pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
20005 return function (method, context) {
20006 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
20007 args[_key - 2] = arguments[_key];
20008 }
20009 return function (d) {
20010 var _d$data,
20011 id = $$.getTargetSelectorSuffix(d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d),
20012 element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
20013 ids.indexOf(id) < 0 && ids.push(id);
20014 var point = pattern[ids.indexOf(id) % pattern.length];
20015 if ($$.hasValidPointType(point)) {
20016 point = $$[point];
20017 } else if (!$$.hasValidPointDrawMethods(point)) {
20018 var pointId = datetimeId + "-point" + id,
20019 pointFromDefs = $$.pointFromDefs(pointId);
20020 if (pointFromDefs.size() < 1) {
20021 $$.insertPointInfoDefs(point, pointId);
20022 }
20023 if (method === "create") {
20024 return $$.custom.create.bind(context).apply(void 0, [element, pointId].concat(args));
20025 } else if (method === "update") {
20026 return $$.custom.update.bind(context).apply(void 0, [element].concat(args));
20027 }
20028 }
20029 return point[method].bind(context).apply(void 0, [element].concat(args));
20030 };
20031 };
20032 },
20033 custom: {
20034 create: function create(element, id, fillStyleFn) {
20035 return element.append("use").attr("xlink:href", "#" + id).attr("class", this.updatePointClass.bind(this)).style("fill", fillStyleFn).node();
20036 },
20037 update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
20038 var _this9 = this,
20039 $$ = this,
20040 _element$node$getBBox = element.node().getBBox(),
20041 width = _element$node$getBBox.width,
20042 height = _element$node$getBBox.height,
20043 xPosFn2 = function (d) {
20044 _newArrowCheck(this, _this9);
20045 return isValue(d.value) ? xPosFn(d) - width / 2 : 0;
20046 }.bind(this),
20047 yPosFn2 = function (d) {
20048 _newArrowCheck(this, _this9);
20049 return isValue(d.value) ? yPosFn(d) - height / 2 : 0;
20050 }.bind(this),
20051 mainCircles = element;
20052 if (withTransition) {
20053 flow && mainCircles.attr("x", xPosFn2);
20054 mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
20055 selectedCircles && $$.$T(selectedCircles, withTransition, getTransitionName());
20056 }
20057 return mainCircles.attr("x", xPosFn2).attr("y", yPosFn2).style("fill", fillStyleFn);
20058 }
20059 },
20060 // 'circle' data point
20061 circle: {
20062 create: function create(element, sizeFn, fillStyleFn) {
20063 return element.append("circle").attr("class", this.updatePointClass.bind(this)).attr("r", sizeFn).style("fill", fillStyleFn).node();
20064 },
20065 update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
20066 var $$ = this,
20067 mainCircles = element;
20068 // when '.load()' called, bubble size should be updated
20069 if ($$.hasType("bubble")) {
20070 mainCircles.attr("r", $$.pointR.bind($$));
20071 }
20072 if (withTransition) {
20073 flow && mainCircles.attr("cx", xPosFn);
20074 if (mainCircles.attr("cx")) {
20075 mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
20076 }
20077 selectedCircles && $$.$T(mainCircles, withTransition, getTransitionName());
20078 }
20079 return mainCircles.attr("cx", xPosFn).attr("cy", yPosFn).style("fill", fillStyleFn);
20080 }
20081 },
20082 // 'rectangle' data point
20083 rectangle: {
20084 create: function create(element, sizeFn, fillStyleFn) {
20085 var _this10 = this,
20086 rectSizeFn = function (d) {
20087 _newArrowCheck(this, _this10);
20088 return sizeFn(d) * 2;
20089 }.bind(this);
20090 return element.append("rect").attr("class", this.updatePointClass.bind(this)).attr("width", rectSizeFn).attr("height", rectSizeFn).style("fill", fillStyleFn).node();
20091 },
20092 update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
20093 var _this11 = this,
20094 $$ = this,
20095 r = $$.config.point_r,
20096 rectXPosFn = function (d) {
20097 _newArrowCheck(this, _this11);
20098 return xPosFn(d) - r;
20099 }.bind(this),
20100 rectYPosFn = function (d) {
20101 _newArrowCheck(this, _this11);
20102 return yPosFn(d) - r;
20103 }.bind(this),
20104 mainCircles = element;
20105 if (withTransition) {
20106 flow && mainCircles.attr("x", rectXPosFn);
20107 mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
20108 selectedCircles && $$.$T(selectedCircles, withTransition, getTransitionName());
20109 }
20110 return mainCircles.attr("x", rectXPosFn).attr("y", rectYPosFn).style("fill", fillStyleFn);
20111 }
20112 }
20113});
20114;// CONCATENATED MODULE: ./src/ChartInternal/shape/polar.ts
20115
20116/**
20117 * Copyright (c) 2017 ~ present NAVER Corp.
20118 * billboard.js project is licensed under the MIT license
20119 */
20120
20121
20122/**
20123 * Get data max value
20124 * @param {object} $$ ChartInternal instance
20125 * @returns {number} max value
20126 * @private
20127 */
20128function getDataMax($$) {
20129 var levelMax = $$.config.polar_level_max,
20130 dataMax = $$.getMinMaxData().max[0].value;
20131 // Apply level max only when is greater than the data max value
20132 if (levelMax && levelMax > dataMax) {
20133 dataMax = levelMax;
20134 }
20135 return dataMax;
20136}
20137/* harmony default export */ var polar = ({
20138 /**
20139 * Initialize polar
20140 * @private
20141 */
20142 initPolar: function initPolar() {
20143 var $$ = this,
20144 arcs = $$.$el.arcs,
20145 config = $$.config,
20146 levelTextShow = config.polar_level_text_show,
20147 levelTextBgColor = config.polar_level_text_backgroundColor;
20148 // append <g> for level
20149 arcs.levels = arcs.append("g").attr("class", $LEVEL.levels);
20150
20151 // set level text background color
20152 if (levelTextShow && levelTextBgColor) {
20153 $$.generateDataLabelBackgroundColorFilter(levelTextBgColor);
20154 }
20155 },
20156 /**
20157 * Get polar outer radius according to the data value
20158 * @param {object} d Data object
20159 * @param {numbet} outerRadius Outer radius
20160 * @returns {number} outer radius
20161 * @private
20162 */
20163 getPolarOuterRadius: function getPolarOuterRadius(d, outerRadius) {
20164 var _d$data$values$0$valu,
20165 dataMax = getDataMax(this);
20166 return ((_d$data$values$0$valu = d == null ? void 0 : d.data.values[0].value) != null ? _d$data$values$0$valu : 0) / dataMax * outerRadius;
20167 },
20168 /**
20169 * Update polar based on given data array
20170 * @param {object} targets Data object
20171 * @private
20172 */
20173 updateTargetsForPolar: function updateTargetsForPolar(targets) {
20174 // borrow from Arc
20175 this.updateTargetsForArc(targets);
20176 },
20177 /**
20178 * Called whenever redraw happens
20179 * @private
20180 */
20181 redrawPolar: function redrawPolar() {
20182 var $$ = this,
20183 config = $$.config;
20184 config.polar_level_show && $$.updatePolarLevel();
20185 },
20186 /**
20187 * Update polar level circle
20188 * @private
20189 */
20190 updatePolarLevel: function updatePolarLevel() {
20191 var _this = this,
20192 $$ = this,
20193 config = $$.config,
20194 state = $$.state,
20195 levels = $$.$el.arcs.levels,
20196 depth = config.polar_level_depth,
20197 dataMax = getDataMax($$),
20198 levelData = getRange(0, depth),
20199 outerRadius = state.radius,
20200 levelRatio = levelData.map(function (l) {
20201 _newArrowCheck(this, _this);
20202 return outerRadius * ((l + 1) / depth);
20203 }.bind(this)),
20204 levelTextFormat = (config.polar_level_text_format || function () {}).bind($$.api),
20205 level = levels.selectAll("." + $LEVEL.level).data(levelData);
20206 level.exit().remove();
20207 var levelEnter = level.enter().append("g").attr("class", function (d, i) {
20208 _newArrowCheck(this, _this);
20209 return $LEVEL.level + " " + $LEVEL.level + "-" + i;
20210 }.bind(this));
20211
20212 // cx, cy, translate: Set center as origin (0,0) so that it can share same center with arcs
20213 levelEnter.append("circle");
20214 levelEnter.merge(level).selectAll("circle").style("visibility", config.polar_level_show ? null : "hidden").attr("cx", 0).attr("cy", 0).attr("r", function (d) {
20215 _newArrowCheck(this, _this);
20216 return levelRatio[d];
20217 }.bind(this));
20218 if (config.polar_level_text_show) {
20219 var levelTextBackgroundColor = config.polar_level_text_backgroundColor,
20220 defsId = "#" + state.datetimeId + "-labels-bg" + $$.getTargetSelectorSuffix(levelTextBackgroundColor);
20221 levelEnter.append("text").style("text-anchor", "middle");
20222 levelEnter.merge(level).selectAll("text").attr("dy", function (d) {
20223 _newArrowCheck(this, _this);
20224 return -levelRatio[d] + 5;
20225 }.bind(this)).attr("filter", levelTextBackgroundColor ? "url(" + defsId + ")" : null).text(function (d) {
20226 _newArrowCheck(this, _this);
20227 return levelTextFormat(dataMax / levelData.length * (d + 1));
20228 }.bind(this));
20229 }
20230 }
20231});
20232;// CONCATENATED MODULE: ./src/ChartInternal/shape/radar.ts
20233
20234/**
20235 * Copyright (c) 2017 ~ present NAVER Corp.
20236 * billboard.js project is licensed under the MIT license
20237 */
20238
20239
20240
20241
20242
20243/**
20244 * Get the position value
20245 * @param {boolean} isClockwise If the direction is clockwise
20246 * @param {string} type Coordinate type 'x' or 'y'
20247 * @param {number} edge Number of edge
20248 * @param {number} pos The indexed position
20249 * @param {number} range Range value
20250 * @param {number} ratio Ratio value
20251 * @returns {number}
20252 * @private
20253 */
20254function getPosition(isClockwise, type, edge, pos, range, ratio) {
20255 var index = isClockwise && pos > 0 ? edge - pos : pos,
20256 r = 2 * Math.PI,
20257 func = type === "x" ? Math.sin : Math.cos;
20258 return range * (1 - ratio * func(index * r / edge));
20259}
20260
20261// cache key
20262var cacheKey = KEY.radarPoints;
20263/* harmony default export */ var radar = ({
20264 initRadar: function initRadar() {
20265 var $$ = this,
20266 config = $$.config,
20267 current = $$.state.current,
20268 $el = $$.$el;
20269 if ($$.hasType("radar")) {
20270 $el.radar = $el.main.select("." + $COMMON.chart).append("g").attr("class", $RADAR.chartRadars);
20271
20272 // level
20273 $el.radar.levels = $el.radar.append("g").attr("class", $LEVEL.levels);
20274
20275 // axis
20276 $el.radar.axes = $el.radar.append("g").attr("class", $AXIS.axis);
20277
20278 // shapes
20279 $el.radar.shapes = $el.radar.append("g").attr("class", $SHAPE.shapes);
20280 current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value;
20281 }
20282 },
20283 getRadarSize: function getRadarSize() {
20284 var $$ = this,
20285 config = $$.config,
20286 _$$$state = $$.state,
20287 arcWidth = _$$$state.arcWidth,
20288 arcHeight = _$$$state.arcHeight,
20289 padding = config.axis_x_categories.length < 4 ? -20 : 10,
20290 size = (Math.min(arcWidth, arcHeight) - padding) / 2;
20291 return [size, size];
20292 },
20293 updateTargetsForRadar: function updateTargetsForRadar(targets) {
20294 var _this = this,
20295 $$ = this,
20296 config = $$.config;
20297 if (isEmpty(config.axis_x_categories)) {
20298 config.axis_x_categories = getRange(0, getMinMax("max", targets.map(function (v) {
20299 _newArrowCheck(this, _this);
20300 return v.values.length;
20301 }.bind(this))));
20302 }
20303 $$.generateRadarPoints();
20304 },
20305 getRadarPosition: function getRadarPosition(type, index, range, ratio) {
20306 var _this2 = this,
20307 $$ = this,
20308 config = $$.config,
20309 _$$$getRadarSize = $$.getRadarSize(),
20310 width = _$$$getRadarSize[0],
20311 height = _$$$getRadarSize[1],
20312 edge = config.axis_x_categories.length,
20313 isClockwise = config.radar_direction_clockwise,
20314 pos = toArray(type).map(function (v) {
20315 _newArrowCheck(this, _this2);
20316 return getPosition(isClockwise, v, edge, index, isDefined(range) ? range : type === "x" ? width : height, isNumber(ratio) ? ratio : config.radar_size_ratio);
20317 }.bind(this));
20318 return pos.length === 1 ? pos[0] : pos;
20319 },
20320 /**
20321 * Generate data points
20322 * @private
20323 */
20324 generateRadarPoints: function generateRadarPoints() {
20325 var _this3 = this,
20326 $$ = this,
20327 targets = $$.data.targets,
20328 _$$$getRadarSize2 = $$.getRadarSize(),
20329 width = _$$$getRadarSize2[0],
20330 height = _$$$getRadarSize2[1],
20331 points = $$.cache.get(cacheKey) || {},
20332 size = points._size;
20333 // recalculate position only when the previous dimension has been changed
20334 if (!size || size.width !== width && size.height !== height) {
20335 targets.forEach(function (d) {
20336 var _this4 = this;
20337 _newArrowCheck(this, _this3);
20338 points[d.id] = d.values.map(function (v, i) {
20339 _newArrowCheck(this, _this4);
20340 return $$.getRadarPosition(["x", "y"], i, undefined, $$.getRatio("radar", v));
20341 }.bind(this));
20342 }.bind(this));
20343 points._size = {
20344 width: width,
20345 height: height
20346 };
20347 $$.cache.add(cacheKey, points);
20348 }
20349 },
20350 redrawRadar: function redrawRadar() {
20351 var $$ = this,
20352 _$$$$el = $$.$el,
20353 radar = _$$$$el.radar,
20354 main = _$$$$el.main,
20355 translate = $$.getTranslate("radar");
20356 // Adjust radar, circles and texts' position
20357 if (translate) {
20358 radar.attr("transform", translate);
20359 main.select("." + $TEXT.chartTexts).attr("transform", translate);
20360 $$.generateRadarPoints();
20361 $$.updateRadarLevel();
20362 $$.updateRadarAxes();
20363 $$.updateRadarShape();
20364 }
20365 },
20366 generateGetRadarPoints: function generateGetRadarPoints() {
20367 var _this5 = this,
20368 points = this.cache.get(cacheKey);
20369 return function (d, i) {
20370 _newArrowCheck(this, _this5);
20371 var point = points[d.id][i];
20372 return [point, point, point, point];
20373 }.bind(this);
20374 },
20375 updateRadarLevel: function updateRadarLevel() {
20376 var _this6 = this,
20377 $$ = this,
20378 config = $$.config,
20379 state = $$.state,
20380 radar = $$.$el.radar,
20381 _$$$getRadarSize3 = $$.getRadarSize(),
20382 width = _$$$getRadarSize3[0],
20383 height = _$$$getRadarSize3[1],
20384 depth = config.radar_level_depth,
20385 edge = config.axis_x_categories.length,
20386 showText = config.radar_level_text_show,
20387 radarLevels = radar.levels,
20388 levelData = getRange(0, depth),
20389 radius = config.radar_size_ratio * Math.min(width, height),
20390 levelRatio = levelData.map(function (l) {
20391 _newArrowCheck(this, _this6);
20392 return radius * ((l + 1) / depth);
20393 }.bind(this)),
20394 levelTextFormat = (config.radar_level_text_format || function () {}).bind($$.api),
20395 points = levelData.map(function (v) {
20396 var _this7 = this;
20397 _newArrowCheck(this, _this6);
20398 var range = levelRatio[v],
20399 pos = getRange(0, edge).map(function (i) {
20400 _newArrowCheck(this, _this7);
20401 return $$.getRadarPosition(["x", "y"], i, range, 1).join(",");
20402 }.bind(this));
20403 return pos.join(" ");
20404 }.bind(this)),
20405 level = radarLevels.selectAll("." + $LEVEL.level).data(levelData);
20406 level.exit().remove();
20407 var levelEnter = level.enter().append("g").attr("class", function (d, i) {
20408 _newArrowCheck(this, _this6);
20409 return $LEVEL.level + " " + $LEVEL.level + "-" + i;
20410 }.bind(this));
20411 levelEnter.append("polygon").style("visibility", config.radar_level_show ? null : "hidden");
20412 if (showText) {
20413 if (radarLevels.select("text").empty()) {
20414 radarLevels.append("text").attr("dx", "-.5em").attr("dy", "-.7em").style("text-anchor", "end").text(function () {
20415 _newArrowCheck(this, _this6);
20416 return levelTextFormat(0);
20417 }.bind(this));
20418 }
20419 levelEnter.append("text").attr("dx", "-.5em").style("text-anchor", "end").text(function (d) {
20420 _newArrowCheck(this, _this6);
20421 return levelTextFormat(state.current.dataMax / levelData.length * (d + 1));
20422 }.bind(this));
20423 }
20424 levelEnter.merge(level).attr("transform", function (d) {
20425 _newArrowCheck(this, _this6);
20426 return "translate(" + (width - levelRatio[d]) + ", " + (height - levelRatio[d]) + ")";
20427 }.bind(this)).selectAll("polygon").attr("points", function (d) {
20428 _newArrowCheck(this, _this6);
20429 return points[d];
20430 }.bind(this));
20431
20432 // update level text position
20433 if (showText) {
20434 radarLevels.selectAll("text").attr("x", function (d) {
20435 _newArrowCheck(this, _this6);
20436 return isUndefined(d) ? width : points[d].split(",")[0];
20437 }.bind(this)).attr("y", function (d) {
20438 _newArrowCheck(this, _this6);
20439 return isUndefined(d) ? height : 0;
20440 }.bind(this));
20441 }
20442 },
20443 updateRadarAxes: function updateRadarAxes() {
20444 var _this8 = this,
20445 $$ = this,
20446 config = $$.config,
20447 radar = $$.$el.radar,
20448 _$$$getRadarSize4 = $$.getRadarSize(),
20449 width = _$$$getRadarSize4[0],
20450 height = _$$$getRadarSize4[1],
20451 categories = config.axis_x_categories,
20452 axis = radar.axes.selectAll("g").data(categories);
20453 axis.exit().remove();
20454 var axisEnter = axis.enter().append("g").attr("class", function (d, i) {
20455 _newArrowCheck(this, _this8);
20456 return $AXIS.axis + "-" + i;
20457 }.bind(this));
20458 config.radar_axis_line_show && axisEnter.append("line");
20459 config.radar_axis_text_show && axisEnter.append("text");
20460 axis = axisEnter.merge(axis);
20461
20462 // axis line
20463 if (config.radar_axis_line_show) {
20464 axis.select("line").attr("x1", width).attr("y1", height).attr("x2", function (d, i) {
20465 _newArrowCheck(this, _this8);
20466 return $$.getRadarPosition("x", i);
20467 }.bind(this)).attr("y2", function (d, i) {
20468 _newArrowCheck(this, _this8);
20469 return $$.getRadarPosition("y", i);
20470 }.bind(this));
20471 }
20472
20473 // axis text
20474 if (config.radar_axis_text_show) {
20475 var _config$radar_axis_te = config.radar_axis_text_position,
20476 _config$radar_axis_te2 = _config$radar_axis_te.x,
20477 x = _config$radar_axis_te2 === void 0 ? 0 : _config$radar_axis_te2,
20478 _config$radar_axis_te3 = _config$radar_axis_te.y,
20479 y = _config$radar_axis_te3 === void 0 ? 0 : _config$radar_axis_te3;
20480 axis.select("text").style("text-anchor", "middle").attr("dy", ".5em").call(function (selection) {
20481 _newArrowCheck(this, _this8);
20482 selection.each(function (d) {
20483 setTextValue((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), d + "", [-.6, 1.2]);
20484 });
20485 }.bind(this)).datum(function (d, i) {
20486 _newArrowCheck(this, _this8);
20487 return {
20488 index: i
20489 };
20490 }.bind(this)).attr("transform", function (d) {
20491 if (isUndefined(this.width)) {
20492 // cache evaluated axis text width
20493 this.width = this.getBoundingClientRect().width / 2;
20494 }
20495 var posX = $$.getRadarPosition("x", d.index, undefined, 1),
20496 posY = Math.round($$.getRadarPosition("y", d.index, undefined, 1));
20497 if (posX > width) {
20498 posX += this.width + x;
20499 } else if (Math.round(posX) < width) {
20500 posX -= this.width + x;
20501 }
20502 if (posY > height) {
20503 // update vertical centered edge axis text dy position
20504 if (posY / 2 === height && this.firstChild.tagName === "tspan") {
20505 this.firstChild.setAttribute("dy", "0em");
20506 }
20507 posY += y;
20508 } else if (posY < height) {
20509 posY -= y;
20510 }
20511 return "translate(" + posX + " " + posY + ")";
20512 });
20513 }
20514 $$.bindEvent();
20515 },
20516 bindEvent: function bindEvent() {
20517 var _this9 = this,
20518 $$ = this,
20519 config = $$.config,
20520 state = $$.state,
20521 _$$$$el2 = $$.$el,
20522 radar = _$$$$el2.radar,
20523 svg = _$$$$el2.svg,
20524 focusOnly = config.point_focus_only,
20525 _state = state,
20526 inputType = _state.inputType,
20527 transiting = _state.transiting;
20528 if (config.interaction_enabled) {
20529 var isMouse = inputType === "mouse",
20530 getIndex = function (event) {
20531 _newArrowCheck(this, _this9);
20532 var target = event.target;
20533
20534 // in case of multilined axis text
20535 if (/tspan/i.test(target.tagName)) {
20536 target = target.parentNode;
20537 }
20538 var d = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
20539 return d && Object.keys(d).length === 1 ? d.index : undefined;
20540 }.bind(this),
20541 hide = function (event) {
20542 _newArrowCheck(this, _this9);
20543 state.event = event;
20544 var index = getIndex(event),
20545 noIndex = isUndefined(index);
20546 if (isMouse || noIndex) {
20547 $$.hideTooltip();
20548 focusOnly ? $$.hideCircleFocus() : $$.unexpandCircles();
20549 if (isMouse) {
20550 $$.setOverOut(!1, index);
20551 } else if (noIndex) {
20552 $$.callOverOutForTouch();
20553 }
20554 }
20555 }.bind(this);
20556 radar.axes.selectAll("text").on(isMouse ? "mouseover " : "touchstart", function (event) {
20557 _newArrowCheck(this, _this9);
20558 if (transiting) {
20559 // skip while transiting
20560 return;
20561 }
20562 state.event = event;
20563 var index = getIndex(event);
20564 $$.selectRectForSingle(svg.node(), null, index);
20565 isMouse ? $$.setOverOut(!0, index) : $$.callOverOutForTouch(index);
20566 }.bind(this)).on("mouseout", isMouse ? hide : null);
20567 if (!isMouse) {
20568 svg.on("touchstart", hide);
20569 }
20570 }
20571 },
20572 updateRadarShape: function updateRadarShape() {
20573 var _this10 = this,
20574 $$ = this,
20575 targets = $$.data.targets.filter(function (d) {
20576 _newArrowCheck(this, _this10);
20577 return $$.isRadarType(d);
20578 }.bind(this)),
20579 points = $$.cache.get(cacheKey),
20580 areas = $$.$el.radar.shapes.selectAll("polygon").data(targets),
20581 areasEnter = areas.enter().append("g").attr("class", $$.getChartClass("Radar"));
20582 $$.$T(areas.exit()).remove();
20583 areasEnter.append("polygon").merge(areas).style("fill", $$.color).style("stroke", $$.color).attr("points", function (d) {
20584 _newArrowCheck(this, _this10);
20585 return points[d.id].join(" ");
20586 }.bind(this));
20587 $$.updateTargetForCircle(targets, areasEnter);
20588 },
20589 /**
20590 * Get data point x coordinate
20591 * @param {object} d Data object
20592 * @returns {number}
20593 * @private
20594 */
20595 radarCircleX: function radarCircleX(d) {
20596 return this.cache.get(cacheKey)[d.id][d.index][0];
20597 },
20598 /**
20599 * Get data point y coordinate
20600 * @param {object} d Data object
20601 * @returns {number}
20602 * @private
20603 */
20604 radarCircleY: function radarCircleY(d) {
20605 return this.cache.get(cacheKey)[d.id][d.index][1];
20606 }
20607});
20608;// CONCATENATED MODULE: ./src/config/Options/common/point.ts
20609/**
20610 * Copyright (c) 2017 ~ present NAVER Corp.
20611 * billboard.js project is licensed under the MIT license
20612 */
20613/**
20614 * point config options
20615 */
20616/* harmony default export */ var common_point = ({
20617 /**
20618 * Set point options
20619 * @name point
20620 * @memberof Options
20621 * @type {object}
20622 * @property {object} point Point object
20623 * @property {boolean} [point.show=true] Whether to show each point in line.
20624 * @property {number|Function} [point.r=2.5] The radius size of each point.
20625 * - **NOTE:** Disabled for 'bubble' type
20626 * @property {boolean} [point.focus.expand.enabled=true] Whether to expand each point on focus.
20627 * @property {number} [point.focus.expand.r=point.r*1.75] The radius size of each point on focus.
20628 * - **NOTE:** For 'bubble' type, the default is `bubbleSize*1.15`
20629 * @property {boolean} [point.focus.only=false] Show point only when is focused.
20630 * @property {number|null} [point.opacity=undefined] Set point opacity value.
20631 * - **NOTE:**
20632 * - `null` will make to not set inline 'opacity' css prop.
20633 * - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
20634 * @property {number} [point.sensitivity=10] The senstivity value for interaction boundary.
20635 * @property {number} [point.select.r=point.r*4] The radius size of each point on selected.
20636 * @property {string} [point.type="circle"] The type of point to be drawn
20637 * - **NOTE:**
20638 * - If chart has 'bubble' type, only circle can be used.
20639 * - For IE, non circle point expansions are not supported due to lack of transform support.
20640 * - **Available Values:**
20641 * - circle
20642 * - rectangle
20643 * @property {Array} [point.pattern=[]] The type of point or svg shape as string, to be drawn for each line
20644 * - **NOTE:**
20645 * - This is an `experimental` feature and can have some unexpected behaviors.
20646 * - If chart has 'bubble' type, only circle can be used.
20647 * - For IE, non circle point expansions are not supported due to lack of transform support.
20648 * - **Available Values:**
20649 * - circle
20650 * - rectangle
20651 * - svg shape tag interpreted as string<br>
20652 * (ex. `<polygon points='2.5 0 0 5 5 5'></polygon>`)
20653 * @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
20654 * @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
20655 * @example
20656 * point: {
20657 * show: false,
20658 * r: 5,
20659 *
20660 * // or customize the radius
20661 * r: function(d) {
20662 * ...
20663 * return r;
20664 * },
20665 *
20666 * focus: {
20667 * expand: {
20668 * enabled: true,
20669 * r: 1
20670 * },
20671 * only: true
20672 * },
20673 *
20674 * // do not set inline 'opacity' css prop setting
20675 * opacity: null,
20676 *
20677 * // set every data point's opacity value
20678 * opacity: 0.7,
20679 *
20680 * select: {
20681 * r: 3
20682 * },
20683 *
20684 * // having lower value, means how closer to be for interaction
20685 * sensitivity: 3,
20686 *
20687 * // valid values are "circle" or "rectangle"
20688 * type: "rectangle",
20689 *
20690 * // or indicate as pattern
20691 * pattern: [
20692 * "circle",
20693 * "rectangle",
20694 * "<polygon points='0 6 4 0 -4 0'></polygon>"
20695 * ],
20696 * }
20697 */
20698 point_show: !0,
20699 point_r: 2.5,
20700 point_sensitivity: 10,
20701 point_focus_expand_enabled: !0,
20702 point_focus_expand_r: undefined,
20703 point_focus_only: !1,
20704 point_opacity: undefined,
20705 point_pattern: [],
20706 point_select_r: undefined,
20707 point_type: "circle"
20708});
20709;// CONCATENATED MODULE: ./src/config/Options/shape/area.ts
20710/**
20711 * Copyright (c) 2017 ~ present NAVER Corp.
20712 * billboard.js project is licensed under the MIT license
20713 */
20714/**
20715 * area config options
20716 */
20717/* harmony default export */ var Options_shape_area = ({
20718 /**
20719 * Set area options
20720 * @name area
20721 * @memberof Options
20722 * @type {object}
20723 * @property {object} area Area object
20724 * @property {boolean} [area.above=false] Set background area `above` the data chart line.
20725 * @property {boolean} [area.below=false] Set background area `below` the data chart line.
20726 * - **NOTE**: Can't be used along with `above` option. When above & below options are set to true, `above` will be prioritized.
20727 * @property {boolean} [area.front=true] Set area node to be positioned over line node.
20728 * @property {boolean|object} [area.linearGradient=false] Set the linear gradient on area.<br><br>
20729 * Or customize by giving below object value:
20730 * - x {Array}: `x1`, `x2` value
20731 * - y {Array}: `y1`, `y2` value
20732 * - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
20733 * @property {boolean} [area.zerobased=true] Set if min or max value will be 0 on area chart.
20734 * @see [MDN's &lt;linearGradient>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient), [&lt;stop>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/stop)
20735 * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
20736 * @see [Demo: above](https://naver.github.io/billboard.js/demo/#AreaChartOptions.Above)
20737 * @see [Demo: below](https://naver.github.io/billboard.js/demo/#AreaChartOptions.Below)
20738 * @see [Demo: linearGradient](https://naver.github.io/billboard.js/demo/#AreaChartOptions.LinearGradient)
20739 * @example
20740 * area: {
20741 * above: true,
20742 * below: false,
20743 * zerobased: false,
20744 *
20745 * // <g class='bb-areas'> will be positioned behind the line <g class='bb-lines'> in stacking order
20746 * front: false,
20747 *
20748 * // will generate follwing linearGradient:
20749 * // <linearGradient x1="0" x2="0" y1="0" y2="1">
20750 * // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
20751 * // <stop offset="1" stop-color="$DATA_COLOR" stop-opacity="0"></stop>
20752 * // </linearGradient>
20753 * linearGradient: true,
20754 *
20755 * // Or customized gradient
20756 * linearGradient: {
20757 * x: [0, 0], // x1, x2 attributes
20758 * y: [0, 0], // y1, y2 attributes
20759 * stops: [
20760 * // offset, stop-color, stop-opacity
20761 * [0, "#7cb5ec", 1],
20762 *
20763 * // setting 'null' for stop-color, will set its original data color
20764 * [0.5, null, 0],
20765 *
20766 * // setting 'function' for stop-color, will pass data id as argument.
20767 * // It should return color string or null value
20768 * [1, function(id) { return id === "data1" ? "red" : "blue"; }, 0],
20769 * ]
20770 * }
20771 * }
20772 */
20773 area_above: !1,
20774 area_below: !1,
20775 area_front: !0,
20776 area_linearGradient: !1,
20777 area_zerobased: !0
20778});
20779;// CONCATENATED MODULE: ./src/config/Options/shape/bar.ts
20780/**
20781 * Copyright (c) 2017 ~ present NAVER Corp.
20782 * billboard.js project is licensed under the MIT license
20783 */
20784/**
20785 * bar config options
20786 */
20787/* harmony default export */ var shape_bar = ({
20788 /**
20789 * Set bar options
20790 * @name bar
20791 * @memberof Options
20792 * @type {object}
20793 * @property {object} bar Bar object
20794 * @property {number} [bar.indices.removeNull=false] Remove nullish data on bar indices positions.
20795 * @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
20796 * @property {boolean|object} [bar.linearGradient=false] Set the linear gradient on bar.<br><br>
20797 * Or customize by giving below object value:
20798 * - x {Array}: `x1`, `x2` value
20799 * - y {Array}: `y1`, `y2` value
20800 * - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
20801 * @property {boolean} [bar.overlap=false] Bars will be rendered at same position, which will be overlapped each other. (for non-grouped bars only)
20802 * @property {number} [bar.padding=0] The padding pixel value between each bar.
20803 * @property {number} [bar.radius] Set the radius of bar edge in pixel.
20804 * @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
20805 * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
20806 * @property {number} [bar.width] Change the width of bar chart.
20807 * @property {number} [bar.width.ratio=0.6] Change the width of bar chart by ratio.
20808 * @property {number} [bar.width.max] The maximum width value for ratio.
20809 * @property {number} [bar.width.dataname] Change the width of bar for indicated dataset only.
20810 * - **NOTE:**
20811 * - Works only for non-stacked bar
20812 * - Bars are centered accoding its total width value
20813 * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
20814 * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
20815 * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
20816 * @see [Demo: bar indices](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarIndices)
20817 * @see [Demo: bar overlap](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarOverlap)
20818 * @see [Demo: bar padding](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarPadding)
20819 * @see [Demo: bar radius](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarRadius)
20820 * @see [Demo: bar width](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidth)
20821 * @see [Demo: bar width variant](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidthVariant)
20822 * @example
20823 * bar: {
20824 * // remove nullish data on bar indices postions
20825 * indices: {
20826 * removeNull: true
20827 * },
20828 *
20829 * // will generate follwing linearGradient:
20830 * // <linearGradient x1="0" x2="0" y1="0" y2="1">
20831 * // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
20832 * // <stop offset="1" stop-color="$DATA_COLOR" stop-opacity="0"></stop>
20833 * // </linearGradient>
20834 * linearGradient: true,
20835 *
20836 * // Or customized gradient
20837 * linearGradient: {
20838 * x: [0, 0], // x1, x2 attributes
20839 * y: [0, 0], // y1, y2 attributes
20840 * stops: [
20841 * // offset, stop-color, stop-opacity
20842 * [0, "#7cb5ec", 1],
20843 *
20844 * // setting 'null' for stop-color, will set its original data color
20845 * [0.5, null, 0],
20846 *
20847 * // setting 'function' for stop-color, will pass data id as argument.
20848 * // It should return color string or null value
20849 * [1, function(id) { return id === "data1" ? "red" : "blue"; }, 0],
20850 * ]
20851 * },
20852 *
20853 * // remove nullish da
20854 * overlap: true,
20855 *
20856 * padding: 1,
20857 *
20858 * // bar radius
20859 * radius: 10,
20860 * // or
20861 * radius: {
20862 * ratio: 0.5
20863 * }
20864 *
20865 * label: {
20866 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the y Axis domain range value.
20867 * // if data value is below than 0.1, text label will be hidden.
20868 * threshold: 0.1,
20869 * },
20870 *
20871 * // will not have offset between each bar elements for interaction
20872 * sensitivity: 0,
20873 *
20874 * width: 10,
20875 *
20876 * // or
20877 * width: {
20878 * ratio: 0.2,
20879 * max: 20
20880 * },
20881 *
20882 * // or specify width per dataset
20883 * width: {
20884 * data1: 20,
20885 * data2: {
20886 * ratio: 0.2,
20887 * max: 20
20888 * }
20889 * },
20890 *
20891 * zerobased: false
20892 * }
20893 */
20894 bar_label_threshold: 0,
20895 bar_linearGradient: !1,
20896 bar_indices_removeNull: !1,
20897 bar_overlap: !1,
20898 bar_padding: 0,
20899 bar_radius: undefined,
20900 bar_radius_ratio: undefined,
20901 bar_sensitivity: 2,
20902 bar_width: undefined,
20903 bar_width_ratio: .6,
20904 bar_width_max: undefined,
20905 bar_zerobased: !0
20906});
20907;// CONCATENATED MODULE: ./src/config/Options/shape/bubble.ts
20908/**
20909 * Copyright (c) 2017 ~ present NAVER Corp.
20910 * billboard.js project is licensed under the MIT license
20911 */
20912/**
20913 * bubble config options
20914 */
20915/* harmony default export */ var shape_bubble = ({
20916 /**
20917 * Set bubble options
20918 * @name bubble
20919 * @memberof Options
20920 * @type {object}
20921 * @property {object} bubble bubble object
20922 * @property {number|Function} [bubble.maxR=35] Set the max bubble radius value
20923 * @property {boolean} [bubble.zerobased=false] Set if min or max value will be 0 on bubble chart.
20924 * @example
20925 * bubble: {
20926 * // ex) If 100 is the highest value among data bound, the representation bubble of 100 will have radius of 50.
20927 * // And the lesser will have radius relatively from tha max value.
20928 * maxR: 50,
20929 *
20930 * // or set radius callback
20931 * maxR: function(d) {
20932 * // ex. of d param - {x: Fri Oct 06 2017 00:00:00 GMT+0900, value: 80, id: "data2", index: 5}
20933 * ...
20934 * return Math.sqrt(d.value * 2);
20935 * },
20936 * zerobased: false
20937 * }
20938 */
20939 bubble_maxR: 35,
20940 bubble_zerobased: !1
20941});
20942;// CONCATENATED MODULE: ./src/config/Options/shape/candlestick.ts
20943/**
20944 * Copyright (c) 2017 ~ present NAVER Corp.
20945 * billboard.js project is licensed under the MIT license
20946 */
20947/**
20948 * candlestick config options
20949 */
20950/* harmony default export */ var shape_candlestick = ({
20951 /**
20952 * Set candlestick options
20953 * @name candlestick
20954 * @memberof Options
20955 * @type {object}
20956 * @property {object} candlestick Candlestick object
20957 * @property {number} [candlestick.width] Change the width.
20958 * @property {number} [candlestick.width.ratio=0.6] Change the width by ratio.
20959 * @property {number} [candlestick.width.max] The maximum width value for ratio.
20960 * @property {number} [candlestick.width.dataname] Change the width for indicated dataset only.
20961 * @property {number} [candlestick.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
20962 * @property {number} [candlestick.width.dataname.max] The maximum width value for ratio.
20963 * @property {object} [candlestick.color] Color setting.
20964 * @property {string|object} [candlestick.color.down] Change down(bearish) value color.
20965 * @property {string} [candlestick.color.down.dataname] Change down value color for indicated dataset only.
20966 *
20967 * @see [Demo](https://naver.github.io/billboard.js/demo/##Chart.CandlestickChart)
20968 * @example
20969 * candlestick: {
20970 * width: 10,
20971 *
20972 * // or
20973 * width: {
20974 * ratio: 0.2,
20975 * max: 20
20976 * },
20977 *
20978 * // or specify width per dataset
20979 * width: {
20980 * data1: 20,
20981 * data2: {
20982 * ratio: 0.2,
20983 * max: 20
20984 * }
20985 * },
20986 * color: {
20987 * // spcify bearish color
20988 * down: "red",
20989 *
20990 * // or specify color per dataset
20991 * down: {
20992 * data1: "red",
20993 * data2: "blue",
20994 * }
20995 * }
20996 * }
20997 */
20998 candlestick_width: undefined,
20999 candlestick_width_ratio: .6,
21000 candlestick_width_max: undefined,
21001 candlestick_color_down: "red"
21002});
21003;// CONCATENATED MODULE: ./src/config/Options/shape/line.ts
21004/**
21005 * Copyright (c) 2017 ~ present NAVER Corp.
21006 * billboard.js project is licensed under the MIT license
21007 */
21008/**
21009 * line config options
21010 */
21011/* harmony default export */ var shape_line = ({
21012 /**
21013 * Set line options
21014 * @name line
21015 * @memberof Options
21016 * @type {object}
21017 * @property {object} line Line object
21018 * @property {boolean} [line.connectNull=false] Set if null data point will be connected or not.<br>
21019 * If true set, the region of null data will be connected without any data point. If false set, the region of null data will not be connected and get empty.
21020 * @property {Array} [line.classes=undefined] If set, used to set a css class on each line.
21021 * @property {boolean} [line.step.type=step] Change step type for step chart.<br>
21022 * **Available values:**
21023 * - step
21024 * - step-before
21025 * - step-after
21026 * @property {boolean} [line.step.tooltipMatch=false] Set to `true` for `step-before` and `step-after` types to have cursor/tooltip match to hovered step's point instead of nearest point.
21027 * @property {boolean|Array} [line.point=true] Set to false to not draw points on linecharts. Or pass an array of line ids to draw points for.
21028 * @property {boolean} [line.zerobased=false] Set if min or max value will be 0 on line chart.
21029 * @example
21030 * line: {
21031 * connectNull: true,
21032 * classes: [
21033 * "line-class1",
21034 * "line-class2"
21035 * ],
21036 * step: {
21037 * type: "step-after",
21038 *
21039 * // to have cursor/tooltip match to hovered step's point instead of nearest point.
21040 * tooltipMatch: true
21041 * },
21042 *
21043 * // hide all data points ('point.show=false' also has similar effect)
21044 * point: false,
21045 *
21046 * // show data points for only indicated datas
21047 * point: [
21048 * "data1", "data3"
21049 * ],
21050 *
21051 * zerobased: false
21052 * }
21053 */
21054 line_connectNull: !1,
21055 line_step_type: "step",
21056 line_step_tooltipMatch: !1,
21057 line_zerobased: !1,
21058 line_classes: undefined,
21059 line_point: !0
21060});
21061;// CONCATENATED MODULE: ./src/config/Options/shape/scatter.ts
21062/**
21063 * Copyright (c) 2017 ~ present NAVER Corp.
21064 * billboard.js project is licensed under the MIT license
21065 */
21066/**
21067 * scatter config options
21068 */
21069/* harmony default export */ var scatter = ({
21070 /**
21071 * Set scatter options
21072 * @name scatter
21073 * @memberof Options
21074 * @type {object}
21075 * @property {object} [scatter] scatter object
21076 * @property {boolean} [scatter.zerobased=false] Set if min or max value will be 0 on scatter chart.
21077 * @example
21078 * scatter: {
21079 * connectNull: true,
21080 * step: {
21081 * type: "step-after"
21082 * },
21083 *
21084 * // hide all data points ('point.show=false' also has similar effect)
21085 * point: false,
21086 *
21087 * // show data points for only indicated datas
21088 * point: [
21089 * "data1", "data3"
21090 * ],
21091 *
21092 * zerobased: false
21093 * }
21094 */
21095 scatter_zerobased: !1
21096});
21097;// CONCATENATED MODULE: ./src/config/Options/shape/spline.ts
21098/**
21099 * Copyright (c) 2017 ~ present NAVER Corp.
21100 * billboard.js project is licensed under the MIT license
21101 */
21102/**
21103 * x Axis config options
21104 */
21105/* harmony default export */ var spline = ({
21106 /**
21107 * Set spline options
21108 * - **Available interpolation type values:**
21109 * - basis (d3.curveBasis)
21110 * - basis-closed (d3.curveBasisClosed)
21111 * - basis-open (d3.curveBasisOpen)
21112 * - bundle (d3.curveBundle)
21113 * - cardinal (d3.curveCardinal)
21114 * - cardinal-closed (d3.curveCardinalClosed)
21115 * - cardinal-open (d3.curveCardinalOpen)
21116 * - catmull-rom (d3.curveCatmullRom)
21117 * - catmull-rom-closed (d3.curveCatmullRomClosed)
21118 * - catmull-rom-open (d3.curveCatmullRomOpen)
21119 * - monotone-x (d3.curveMonotoneX)
21120 * - monotone-y (d3.curveMonotoneY)
21121 * - natural (d3.curveNatural)
21122 * - linear-closed (d3.curveLinearClosed)
21123 * - linear (d3.curveLinear)
21124 * - step (d3.curveStep)
21125 * - step-after (d3.curveStepAfter)
21126 * - step-before (d3.curveStepBefore)
21127 * @name spline
21128 * @memberof Options
21129 * @type {object}
21130 * @property {object} spline Spline object
21131 * @property {object} spline.interpolation Spline interpolation object
21132 * @property {string} [spline.interpolation.type="cardinal"] Interpolation type
21133 * @see [Interpolation (d3 v4)](http://bl.ocks.org/emmasaunders/c25a147970def2b02d8c7c2719dc7502)
21134 * @example
21135 * spline: {
21136 * interpolation: {
21137 * type: "cardinal"
21138 * }
21139 * }
21140 */
21141 spline_interpolation_type: "cardinal"
21142});
21143;// CONCATENATED MODULE: ./src/config/Options/shape/donut.ts
21144/**
21145 * Copyright (c) 2017 ~ present NAVER Corp.
21146 * billboard.js project is licensed under the MIT license
21147 */
21148/**
21149 * donut config options
21150 */
21151/* harmony default export */ var donut = ({
21152 /**
21153 * Set donut options
21154 * @name donut
21155 * @memberof Options
21156 * @type {object}
21157 * @property {object} donut Donut object
21158 * @property {boolean} [donut.label.show=true] Show or hide label on each donut piece.
21159 * @property {Function} [donut.label.format] Set formatter for the label on each donut piece.
21160 * @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
21161 * @property {number|Function} [donut.label.ratio=undefined] Set ratio of labels position.
21162 * @property {boolean} [donut.expand=true] Enable or disable expanding donut pieces.
21163 * @property {number} [donut.expand.rate=0.98] Set expand rate.
21164 * @property {number} [donut.expand.duration=50] Set expand transition time in ms.
21165 * @property {number} [donut.width] Set width of donut chart.
21166 * @property {string} [donut.title=""] Set title of donut chart. Use `\n` character for line break.
21167 * @property {number} [donut.padAngle=0] Set padding between data.
21168 * @property {number} [donut.startingAngle=0] Set starting angle where data draws.
21169 * @example
21170 * donut: {
21171 * label: {
21172 * show: false,
21173 * format: function(value, ratio, id) {
21174 * return d3.format("$")(value);
21175 *
21176 * // to multiline, return with '\n' character
21177 * // return value +"%\nLine1\n2Line2";
21178 * },
21179 *
21180 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
21181 * // if data value is below than 0.1, text label will be hidden.
21182 * threshold: 0.1,
21183 *
21184 * // set ratio callback. Should return ratio value
21185 * ratio: function(d, radius, h) {
21186 * ...
21187 * return ratio;
21188 * },
21189 * // or set ratio number
21190 * ratio: 0.5
21191 * },
21192 *
21193 * // disable expand transition for interaction
21194 * expand: false,
21195 *
21196 * expand: {
21197 * // set duration of expand transition to 500ms.
21198 * duration: 500,
21199 *
21200 * // set expand area rate
21201 * rate: 1
21202 * },
21203 *
21204 * width: 10,
21205 * padAngle: 0.2,
21206 * startingAngle: 1,
21207 * title: "Donut Title"
21208 *
21209 * // title with line break
21210 * title: "Title1\nTitle2"
21211 * }
21212 */
21213 donut_label_show: !0,
21214 donut_label_format: undefined,
21215 donut_label_threshold: .05,
21216 donut_label_ratio: undefined,
21217 donut_width: undefined,
21218 donut_title: "",
21219 donut_expand: {},
21220 donut_expand_rate: .98,
21221 donut_expand_duration: 50,
21222 donut_padAngle: 0,
21223 donut_startingAngle: 0
21224});
21225;// CONCATENATED MODULE: ./src/config/Options/shape/gauge.ts
21226/**
21227 * Copyright (c) 2017 ~ present NAVER Corp.
21228 * billboard.js project is licensed under the MIT license
21229 */
21230/**
21231 * gauge config options
21232 */
21233/* harmony default export */ var shape_gauge = ({
21234 /**
21235 * Set gauge options
21236 * @name gauge
21237 * @memberof Options
21238 * @type {object}
21239 * @property {object} gauge Gauge object
21240 * @property {boolean} [gauge.background=""] Set background color. (The `.bb-chart-arcs-background` element)
21241 * @property {boolean} [gauge.fullCircle=false] Show full circle as donut. When set to 'true', the max label will not be showed due to start and end points are same location.
21242 * @property {boolean} [gauge.label.show=true] Show or hide label on gauge.
21243 * @property {Function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.<br>
21244 * Will pass following arguments to the given function:
21245 * - value {number}: absolute value
21246 * - ratio {number}: value's ratio
21247 * - id {string}: data's id value
21248 * @property {Function} [gauge.label.extents] Set customized min/max label text.
21249 * @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
21250 * @property {boolean} [gauge.expand=true] Enable or disable expanding gauge.
21251 * @property {number} [gauge.expand.rate=0.98] Set expand rate.
21252 * @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
21253 * @property {number} [gauge.min=0] Set min value of the gauge.
21254 * @property {number} [gauge.max=100] Set max value of the gauge.
21255 * @property {number} [gauge.startingAngle=-1 * Math.PI / 2] Set starting angle where data draws.
21256 *
21257 * **Limitations:**
21258 * - when `gauge.fullCircle=false`:
21259 * - -1 * Math.PI / 2 <= startingAngle <= Math.PI / 2
21260 * - `startingAngle <= -1 * Math.PI / 2` defaults to `-1 * Math.PI / 2`
21261 * - `startingAngle >= Math.PI / 2` defaults to `Math.PI / 2`
21262 * - when `gauge.fullCircle=true`:
21263 * - -1 * Math.PI < startingAngle < Math.PI
21264 * - `startingAngle < -1 * Math.PI` defaults to `Math.PI`
21265 * - `startingAngle > Math.PI` defaults to `Math.PI`
21266 * @property {number} [gauge.arcLength=100] Set the length of the arc to be drawn in percent from -100 to 100.<br>
21267 * Negative value will draw the arc **counterclockwise**.
21268 *
21269 * **Limitations:**
21270 * - -100 <= arcLength (in percent) <= 100
21271 * - 'arcLength < -100' defaults to -100
21272 * - 'arcLength > 100' defaults to 100
21273 * @property {string} [gauge.title=""] Set title of gauge chart. Use `\n` character for line break.
21274 * @property {string} [gauge.units] Set units of the gauge.
21275 * @property {number} [gauge.width] Set width of gauge chart.
21276 * @property {string} [gauge.type="single"] Set type of gauge to be displayed.<br><br>
21277 * **Available Values:**
21278 * - single
21279 * - multi
21280 * @property {string} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
21281 * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
21282 * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
21283 * @example
21284 * gauge: {
21285 * background: "#eee", // will set 'fill' css prop for '.bb-chart-arcs-background' classed element.
21286 * fullCircle: false,
21287 * label: {
21288 * show: false,
21289 * format: function(value, ratio, id) {
21290 * return value;
21291 *
21292 * // to multiline, return with '\n' character
21293 * // return value +"%\nLine1\n2Line2";
21294 * },
21295 *
21296 * extents: function(value, isMax) {
21297 * return (isMax ? "Max:" : "Min:") + value;
21298 * },
21299 *
21300 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
21301 * // if data value is below than 0.1, text label will be hidden.
21302 * threshold: 0.1,
21303 * },
21304 *
21305 * // disable expand transition for interaction
21306 * expand: false,
21307 *
21308 * expand: {
21309 * // set duration of expand transition to 500ms.
21310 * duration: 500,
21311 *
21312 * // set expand area rate
21313 * rate: 1
21314 * },
21315 *
21316 * min: -100,
21317 * max: 200,
21318 * type: "single" // or 'multi'
21319 * title: "Title Text",
21320 * units: "%",
21321 * width: 10,
21322 * startingAngle: -1 * Math.PI / 2,
21323 * arcLength: 100,
21324 * arcs: {
21325 * minWidth: 5
21326 * }
21327 * }
21328 */
21329 gauge_background: "",
21330 gauge_fullCircle: !1,
21331 gauge_label_show: !0,
21332 gauge_label_format: undefined,
21333 gauge_label_extents: undefined,
21334 gauge_label_threshold: 0,
21335 gauge_min: 0,
21336 gauge_max: 100,
21337 gauge_type: "single",
21338 gauge_startingAngle: -1 * Math.PI / 2,
21339 gauge_arcLength: 100,
21340 gauge_title: "",
21341 gauge_units: undefined,
21342 gauge_width: undefined,
21343 gauge_arcs_minWidth: 5,
21344 gauge_expand: {},
21345 gauge_expand_rate: .98,
21346 gauge_expand_duration: 50
21347});
21348;// CONCATENATED MODULE: ./src/config/Options/shape/pie.ts
21349/**
21350 * Copyright (c) 2017 ~ present NAVER Corp.
21351 * billboard.js project is licensed under the MIT license
21352 */
21353/**
21354 * x Axis config options
21355 */
21356/* harmony default export */ var pie = ({
21357 /**
21358 * Set pie options
21359 * @name pie
21360 * @memberof Options
21361 * @type {object}
21362 * @property {object} pie Pie object
21363 * @property {boolean} [pie.label.show=true] Show or hide label on each pie piece.
21364 * @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
21365 * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
21366 * @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
21367 * @property {boolean|object} [pie.expand=true] Enable or disable expanding pie pieces.
21368 * @property {number} [pie.expand.rate=0.98] Set expand rate.
21369 * @property {number} [pie.expand.duration=50] Set expand transition time in ms.
21370 * @property {number|object} [pie.innerRadius=0] Sets the inner radius of pie arc.
21371 * @property {number|object|undefined} [pie.outerRadius=undefined] Sets the outer radius of pie arc.
21372 * @property {number} [pie.padAngle=0] Set padding between data.
21373 * @property {number} [pie.padding=0] Sets the gap between pie arcs.
21374 * @property {number} [pie.startingAngle=0] Set starting angle where data draws.
21375 * @see [Demo: expand.rate](https://naver.github.io/billboard.js/demo/#PieChartOptions.ExpandRate)
21376 * @see [Demo: innerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.InnerRadius)
21377 * @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
21378 * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
21379 * @example
21380 * pie: {
21381 * label: {
21382 * show: false,
21383 * format: function(value, ratio, id) {
21384 * return d3.format("$")(value);
21385 *
21386 * // to multiline, return with '\n' character
21387 * // return value +"%\nLine1\n2Line2";
21388 * },
21389 *
21390 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
21391 * // if data value is below than 0.1, text label will be hidden.
21392 * threshold: 0.1,
21393 *
21394 * // set ratio callback. Should return ratio value
21395 * ratio: function(d, radius, h) {
21396 * ...
21397 * return ratio;
21398 * },
21399 * // or set ratio number
21400 * ratio: 0.5
21401 * },
21402 *
21403 * // disable expand transition for interaction
21404 * expand: false,
21405 *
21406 * expand: {
21407 * // set duration of expand transition to 500ms.
21408 * duration: 500,
21409 *
21410 * // set expand area rate
21411 * rate: 1
21412 * },
21413 *
21414 * innerRadius: 0,
21415 *
21416 * // set different innerRadius for each data
21417 * innerRadius: {
21418 * data1: 10,
21419 * data2: 0
21420 * },
21421 *
21422 * outerRadius: 100,
21423 *
21424 * // set different outerRadius for each data
21425 * outerRadius: {
21426 * data1: 50,
21427 * data2: 100
21428 * }
21429 *
21430 * padAngle: 0.1,
21431 * padding: 0,
21432 * startingAngle: 1
21433 * }
21434 */
21435 pie_label_show: !0,
21436 pie_label_format: undefined,
21437 pie_label_threshold: .05,
21438 pie_label_ratio: undefined,
21439 pie_expand: {},
21440 pie_expand_rate: .98,
21441 pie_expand_duration: 50,
21442 pie_innerRadius: 0,
21443 pie_outerRadius: undefined,
21444 pie_padAngle: 0,
21445 pie_padding: 0,
21446 pie_startingAngle: 0
21447});
21448;// CONCATENATED MODULE: ./src/config/Options/shape/polar.ts
21449
21450var polar_this = undefined;
21451/**
21452 * Copyright (c) 2017 ~ present NAVER Corp.
21453 * billboard.js project is licensed under the MIT license
21454 */
21455/**
21456 * x Axis config options
21457 */
21458/* harmony default export */ var shape_polar = ({
21459 /**
21460 * Set polar options
21461 * @name polar
21462 * @memberof Options
21463 * @type {object}
21464 * @property {object} polar Polar object
21465 * @property {boolean} [polar.label.show=true] Show or hide label on each polar piece.
21466 * @property {Function} [polar.label.format] Set formatter for the label on each polar piece.
21467 * @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
21468 * @property {number|Function} [polar.label.ratio=undefined] Set ratio of labels position.
21469 * @property {number} [polar.level.depth=3] Set the level depth.
21470 * @property {boolean} [polar.level.show=true] Show or hide level.
21471 * @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
21472 * @property {Function} [polar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
21473 * @property {boolean} [polar.level.text.show=true] Show or hide level text.
21474 * @property {number} [polar.padAngle=0] Set padding between data.
21475 * @property {number} [polar.padding=0] Sets the gap between pie arcs.
21476 * @property {number} [polar.startingAngle=0] Set starting angle where data draws.
21477 * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
21478 * @example
21479 * polar: {
21480 * label: {
21481 * show: false,
21482 * format: function(value, ratio, id) {
21483 * return d3.format("$")(value);
21484 *
21485 * // to multiline, return with '\n' character
21486 * // return value +"%\nLine1\n2Line2";
21487 * },
21488 *
21489 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
21490 * // if data value is below than 0.1, text label will be hidden.
21491 * threshold: 0.1,
21492 *
21493 * // set ratio callback. Should return ratio value
21494 * ratio: function(d, radius, h) {
21495 * ...
21496 * return ratio;
21497 * },
21498 * // or set ratio number
21499 * ratio: 0.5
21500 * },
21501 * level: {
21502 * depth: 3,
21503 * max: 500,
21504 * show: true,
21505 * text: {
21506 * format: function(x) {
21507 * return x + "%";
21508 * },
21509 * show: true,
21510 * backgroundColor: "red"
21511 * }
21512 * },
21513 * padAngle: 0.1,
21514 * padding: 0,
21515 * startingAngle: 1
21516 * }
21517 */
21518 polar_label_show: !0,
21519 polar_label_format: undefined,
21520 polar_label_threshold: .05,
21521 polar_label_ratio: undefined,
21522 polar_level_depth: 3,
21523 polar_level_max: undefined,
21524 polar_level_show: !0,
21525 polar_level_text_backgroundColor: "#fff",
21526 polar_level_text_format: function polar_level_text_format(x) {
21527 _newArrowCheck(this, polar_this);
21528 return x % 1 === 0 ? x : x.toFixed(2);
21529 }.bind(undefined),
21530 polar_level_text_show: !0,
21531 polar_padAngle: 0,
21532 polar_padding: 0,
21533 polar_startingAngle: 0
21534});
21535;// CONCATENATED MODULE: ./src/config/Options/shape/radar.ts
21536
21537var radar_this = undefined;
21538/**
21539 * Copyright (c) 2017 ~ present NAVER Corp.
21540 * billboard.js project is licensed under the MIT license
21541 */
21542/**
21543 * x Axis config options
21544 */
21545/* harmony default export */ var shape_radar = ({
21546 /**
21547 * Set radar options
21548 * - **NOTE:**
21549 * > When x tick text contains `\n`, it's used as line break.
21550 * @name radar
21551 * @memberof Options
21552 * @type {object}
21553 * @property {object} radar Radar object
21554 * @property {number} [radar.axis.max=undefined] The max value of axis. If not given, it'll take the max value from the given data.
21555 * @property {boolean} [radar.axis.line.show=true] Show or hide axis line.
21556 * @property {number} [radar.axis.text.position.x=0] x coordinate position, relative the original.
21557 * @property {number} [radar.axis.text.position.y=0] y coordinate position, relative the original.
21558 * @property {boolean} [radar.axis.text.show=true] Show or hide axis text.
21559 * @property {boolean} [radar.direction.clockwise=false] Set the direction to be drawn.
21560 * @property {number} [radar.level.depth=3] Set the level depth.
21561 * @property {boolean} [radar.level.show=true] Show or hide level.
21562 * @property {Function} [radar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
21563 * @property {boolean} [radar.level.text.show=true] Show or hide level text.
21564 * @property {number} [radar.size.ratio=0.87] Set size ratio.
21565 * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.RadarChart)
21566 * @see [Demo: radar axis](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarAxis)
21567 * @see [Demo: radar level](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarLevel)
21568 * @see [Demo: radar size](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarSize)
21569 * @see [Demo: radar axis multiline](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarAxisMultiline)
21570 * @example
21571 * radar: {
21572 * axis: {
21573 * max: 50,
21574 * line: {
21575 * show: false
21576 * },
21577 * text: {
21578 * position: {
21579 * x: 0,
21580 * y: 0
21581 * },
21582 * show: false
21583 * }
21584 * },
21585 * direction: {
21586 * clockwise: true
21587 * },
21588 * level: {
21589 * show: false,
21590 * text: {
21591 * format: function(x) {
21592 * return x + "%";
21593 * },
21594 * show: true
21595 * }
21596 * },
21597 * size: {
21598 * ratio: 0.7
21599 * }
21600 * }
21601 */
21602 radar_axis_max: undefined,
21603 radar_axis_line_show: !0,
21604 radar_axis_text_show: !0,
21605 radar_axis_text_position: {},
21606 radar_level_depth: 3,
21607 radar_level_show: !0,
21608 radar_level_text_format: function radar_level_text_format(x) {
21609 _newArrowCheck(this, radar_this);
21610 return x % 1 === 0 ? x : x.toFixed(2);
21611 }.bind(undefined),
21612 radar_level_text_show: !0,
21613 radar_size_ratio: .87,
21614 radar_direction_clockwise: !1
21615});
21616;// CONCATENATED MODULE: ./src/config/resolver/shape.ts
21617
21618var shape_this = undefined;
21619/**
21620 * Copyright (c) 2017 ~ present NAVER Corp.
21621 * billboard.js project is licensed under the MIT license
21622 */
21623
21624
21625
21626
21627
21628
21629// Axis
21630
21631
21632// Shape
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644// Options
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654// Non-Axis based
21655
21656
21657
21658
21659
21660
21661
21662/**
21663 * Extend Axis
21664 * @param {Array} module Module to be extended
21665 * @param {Array} option Option object to be extended
21666 * @private
21667 */
21668function extendAxis(module, option) {
21669 extend(ChartInternal.prototype, internal.concat(module));
21670 extend(Chart.prototype, api);
21671 Options.setOptions(options.concat(option || []));
21672}
21673
21674/**
21675 * Extend Line type modules
21676 * @param {object} module Module to be extended
21677 * @param {Array} option Option object to be extended
21678 * @private
21679 */
21680function extendLine(module, option) {
21681 extendAxis([point, line].concat(module || []));
21682 Options.setOptions([common_point, shape_line].concat(option || []));
21683}
21684
21685/**
21686 * Extend Arc type modules
21687 * @param {Array} module Module to be extended
21688 * @param {Array} option Option object to be extended
21689 * @private
21690 */
21691function extendArc(module, option) {
21692 extend(ChartInternal.prototype, [arc].concat(module || []));
21693 Options.setOptions(option);
21694}
21695
21696// Area types
21697var _area = function area() {
21698 var _this2 = this;
21699 _newArrowCheck(this, shape_this);
21700 return extendLine(shape_area, [Options_shape_area]), (_area = function () {
21701 _newArrowCheck(this, _this2);
21702 return TYPE.AREA;
21703 }.bind(this))();
21704 }.bind(undefined),
21705 areaLineRange = function () {
21706 var _this3 = this;
21707 _newArrowCheck(this, shape_this);
21708 return extendLine(shape_area, [Options_shape_area]), (areaLineRange = function () {
21709 _newArrowCheck(this, _this3);
21710 return TYPE.AREA_LINE_RANGE;
21711 }.bind(this))();
21712 }.bind(undefined),
21713 areaSpline = function () {
21714 var _this4 = this;
21715 _newArrowCheck(this, shape_this);
21716 return extendLine(shape_area, [Options_shape_area, spline]), (areaSpline = function () {
21717 _newArrowCheck(this, _this4);
21718 return TYPE.AREA_SPLINE;
21719 }.bind(this))();
21720 }.bind(undefined),
21721 areaSplineRange = function () {
21722 var _this5 = this;
21723 _newArrowCheck(this, shape_this);
21724 return extendLine(shape_area, [Options_shape_area, spline]), (areaSplineRange = function () {
21725 _newArrowCheck(this, _this5);
21726 return TYPE.AREA_SPLINE_RANGE;
21727 }.bind(this))();
21728 }.bind(undefined),
21729 areaStep = function () {
21730 var _this6 = this;
21731 _newArrowCheck(this, shape_this);
21732 return extendLine(shape_area, [Options_shape_area]), (areaStep = function () {
21733 _newArrowCheck(this, _this6);
21734 return TYPE.AREA_STEP;
21735 }.bind(this))();
21736 }.bind(undefined),
21737 resolver_shape_line = function () {
21738 var _this7 = this;
21739 _newArrowCheck(this, shape_this);
21740 return extendLine(), (resolver_shape_line = function () {
21741 _newArrowCheck(this, _this7);
21742 return TYPE.LINE;
21743 }.bind(this))();
21744 }.bind(undefined),
21745 shape_spline = function () {
21746 var _this8 = this;
21747 _newArrowCheck(this, shape_this);
21748 return extendLine(undefined, [spline]), (shape_spline = function () {
21749 _newArrowCheck(this, _this8);
21750 return TYPE.SPLINE;
21751 }.bind(this))();
21752 }.bind(undefined),
21753 step = function () {
21754 var _this9 = this;
21755 _newArrowCheck(this, shape_this);
21756 return extendLine(), (step = function () {
21757 _newArrowCheck(this, _this9);
21758 return TYPE.STEP;
21759 }.bind(this))();
21760 }.bind(undefined),
21761 shape_donut = function () {
21762 var _this10 = this;
21763 _newArrowCheck(this, shape_this);
21764 return extendArc(undefined, [donut]), (shape_donut = function () {
21765 _newArrowCheck(this, _this10);
21766 return TYPE.DONUT;
21767 }.bind(this))();
21768 }.bind(undefined),
21769 resolver_shape_gauge = function () {
21770 var _this11 = this;
21771 _newArrowCheck(this, shape_this);
21772 return extendArc([gauge], [shape_gauge]), (resolver_shape_gauge = function () {
21773 _newArrowCheck(this, _this11);
21774 return TYPE.GAUGE;
21775 }.bind(this))();
21776 }.bind(undefined),
21777 shape_pie = function () {
21778 var _this12 = this;
21779 _newArrowCheck(this, shape_this);
21780 return extendArc(undefined, [pie]), (shape_pie = function () {
21781 _newArrowCheck(this, _this12);
21782 return TYPE.PIE;
21783 }.bind(this))();
21784 }.bind(undefined),
21785 resolver_shape_polar = function () {
21786 var _this13 = this;
21787 _newArrowCheck(this, shape_this);
21788 return extendArc([polar], [shape_polar]), (resolver_shape_polar = function () {
21789 _newArrowCheck(this, _this13);
21790 return TYPE.POLAR;
21791 }.bind(this))();
21792 }.bind(undefined),
21793 resolver_shape_radar = function () {
21794 var _this14 = this;
21795 _newArrowCheck(this, shape_this);
21796 return extendArc([point, radar], [common_point, shape_radar]), (resolver_shape_radar = function () {
21797 _newArrowCheck(this, _this14);
21798 return TYPE.RADAR;
21799 }.bind(this))();
21800 }.bind(undefined),
21801 resolver_shape_bar = function () {
21802 var _this15 = this;
21803 _newArrowCheck(this, shape_this);
21804 return extendAxis([bar], shape_bar), (resolver_shape_bar = function () {
21805 _newArrowCheck(this, _this15);
21806 return TYPE.BAR;
21807 }.bind(this))();
21808 }.bind(undefined),
21809 resolver_shape_bubble = function () {
21810 var _this16 = this;
21811 _newArrowCheck(this, shape_this);
21812 return extendAxis([point, bubble], [shape_bubble, common_point]), (resolver_shape_bubble = function () {
21813 _newArrowCheck(this, _this16);
21814 return TYPE.BUBBLE;
21815 }.bind(this))();
21816 }.bind(undefined),
21817 resolver_shape_candlestick = function () {
21818 var _this17 = this;
21819 _newArrowCheck(this, shape_this);
21820 return extendAxis([candlestick], [shape_candlestick]), (resolver_shape_candlestick = function () {
21821 _newArrowCheck(this, _this17);
21822 return TYPE.CANDLESTICK;
21823 }.bind(this))();
21824 }.bind(undefined),
21825 shape_scatter = function () {
21826 var _this18 = this;
21827 _newArrowCheck(this, shape_this);
21828 return extendAxis([point], [common_point, scatter]), (shape_scatter = function () {
21829 _newArrowCheck(this, _this18);
21830 return TYPE.SCATTER;
21831 }.bind(this))();
21832 }.bind(undefined);
21833;// CONCATENATED MODULE: ./src/Chart/api/selection.ts
21834
21835/**
21836 * Copyright (c) 2017 ~ present NAVER Corp.
21837 * billboard.js project is licensed under the MIT license
21838 */
21839
21840
21841
21842/* harmony default export */ var selection = ({
21843 /**
21844 * Get selected data points.<br><br>
21845 * By this API, you can get selected data points information. To use this API, data.selection.enabled needs to be set true.
21846 * @function selected
21847 * @instance
21848 * @memberof Chart
21849 * @param {string} [targetId] You can filter the result by giving target id that you want to get. If not given, all of data points will be returned.
21850 * @returns {Array} dataPoint Array of the data points.<br>ex.) `[{x: 1, value: 200, id: "data1", index: 1, name: "data1"}, ...]`
21851 * @example
21852 * // all selected data points will be returned.
21853 * chart.selected();
21854 * // --> ex.) [{x: 1, value: 200, id: "data1", index: 1, name: "data1"}, ... ]
21855 *
21856 * // all selected data points of data1 will be returned.
21857 * chart.selected("data1");
21858 */
21859 selected: function selected(targetId) {
21860 var _this = this,
21861 $$ = this.internal,
21862 dataPoint = [];
21863 $$.$el.main.selectAll("." + ($SHAPE.shapes + $$.getTargetSelectorSuffix(targetId))).selectAll("." + $SHAPE.shape).filter(function () {
21864 return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($SELECT.SELECTED);
21865 }).each(function (d) {
21866 _newArrowCheck(this, _this);
21867 return dataPoint.push(d);
21868 }.bind(this));
21869 return dataPoint;
21870 },
21871 /**
21872 * Set data points to be selected. ([`data.selection.enabled`](Options.html#.data%25E2%2580%25A4selection%25E2%2580%25A4enabled) option should be set true to use this method)
21873 * @function select
21874 * @instance
21875 * @memberof Chart
21876 * @param {string|Array} [ids] id value to get selected.
21877 * @param {Array} [indices] The index array of data points. If falsy value given, will select all data points.
21878 * @param {boolean} [resetOther] Unselect already selected.
21879 * @example
21880 * // select all data points
21881 * chart.select();
21882 *
21883 * // select all from 'data2'
21884 * chart.select("data2");
21885 *
21886 * // select all from 'data1' and 'data2'
21887 * chart.select(["data1", "data2"]);
21888 *
21889 * // select from 'data1', indices 2 and unselect others selected
21890 * chart.select("data1", [2], true);
21891 *
21892 * // select from 'data1', indices 0, 3 and 5
21893 * chart.select("data1", [0, 3, 5]);
21894 */
21895 select: function select(ids, indices, resetOther) {
21896 var $$ = this.internal,
21897 config = $$.config,
21898 $el = $$.$el;
21899 if (!config.data_selection_enabled) {
21900 return;
21901 }
21902 $el.main.selectAll("." + $SHAPE.shapes).selectAll("." + $SHAPE.shape).each(function (d, i) {
21903 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
21904 id = d.data ? d.data.id : d.id,
21905 toggle = $$.getToggle(this, d).bind($$),
21906 isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
21907 isTargetIndex = !indices || indices.indexOf(i) >= 0,
21908 isSelected = shape.classed($SELECT.SELECTED);
21909 // line/area selection not supported yet
21910 if (shape.classed($LINE.line) || shape.classed($AREA.area)) {
21911 return;
21912 }
21913 if (isTargetId && isTargetIndex) {
21914 if (config.data_selection_isselectable.bind($$.api)(d) && !isSelected) {
21915 toggle(!0, shape.classed($SELECT.SELECTED, !0), d, i);
21916 }
21917 } else if (isDefined(resetOther) && resetOther && isSelected) {
21918 toggle(!1, shape.classed($SELECT.SELECTED, !1), d, i);
21919 }
21920 });
21921 },
21922 /**
21923 * Set data points to be un-selected.
21924 * @function unselect
21925 * @instance
21926 * @memberof Chart
21927 * @param {string|Array} [ids] id value to be unselected.
21928 * @param {Array} [indices] The index array of data points. If falsy value given, will select all data points.
21929 * @example
21930 * // unselect all data points
21931 * chart.unselect();
21932 *
21933 * // unselect all from 'data1'
21934 * chart.unselect("data1");
21935 *
21936 * // unselect from 'data1', indices 2
21937 * chart.unselect("data1", [2]);
21938 */
21939 unselect: function unselect(ids, indices) {
21940 var $$ = this.internal,
21941 config = $$.config,
21942 $el = $$.$el;
21943 if (!config.data_selection_enabled) {
21944 return;
21945 }
21946 $el.main.selectAll("." + $SHAPE.shapes).selectAll("." + $SHAPE.shape).each(function (d, i) {
21947 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
21948 id = d.data ? d.data.id : d.id,
21949 toggle = $$.getToggle(this, d).bind($$),
21950 isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
21951 isTargetIndex = !indices || indices.indexOf(i) >= 0,
21952 isSelected = shape.classed($SELECT.SELECTED);
21953 // line/area selection not supported yet
21954 if (shape.classed($LINE.line) || shape.classed($AREA.area)) {
21955 return;
21956 }
21957 if (isTargetId && isTargetIndex && config.data_selection_isselectable.bind($$.api)(d) && isSelected) {
21958 toggle(!1, shape.classed($SELECT.SELECTED, !1), d, i);
21959 }
21960 });
21961 }
21962});
21963;// CONCATENATED MODULE: ./src/Chart/api/subchart.ts
21964/**
21965 * Copyright (c) 2017 ~ present NAVER Corp.
21966 * billboard.js project is licensed under the MIT license
21967 */
21968
21969/* harmony default export */ var subchart = ({
21970 subchart: {
21971 /**
21972 * Show subchart
21973 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
21974 * @function subchart․show
21975 * @instance
21976 * @memberof Chart
21977 * @example
21978 * // for ESM imports, needs to import 'subchart' and must be instantiated first to enable subchart's API.
21979 * import {subchart} from "billboard.js";
21980 *
21981 * const chart = bb.generate({
21982 * ...
21983 * subchart: {
21984 * // need to be instantiated by calling 'subchart()'
21985 * enabled: subchart()
21986 *
21987 * // in case don't want subchart to be shown at initialization, instantiate with '!subchart()'
21988 * enabled: !subchart()
21989 * }
21990 * });
21991 *
21992 * chart.subchart.show();
21993 */
21994 show: function () {
21995 var $$ = this.internal,
21996 subchart = $$.$el.subchart,
21997 config = $$.config,
21998 show = config.subchart_show;
21999 if (!show) {
22000 var _$target, _subchart$main2;
22001 // unbind zoom event bound to chart rect area
22002 $$.unbindZoomEvent();
22003 config.subchart_show = !show;
22004 subchart.main || $$.initSubchart();
22005 var $target = subchart.main.selectAll("." + $COMMON.target);
22006
22007 // need to cover when new data has been loaded
22008 if ($$.data.targets.length !== $target.size()) {
22009 var _subchart$main;
22010 $$.updateSizes();
22011 $$.updateTargetsForSubchart($$.data.targets);
22012 $target = (_subchart$main = subchart.main) == null ? void 0 : _subchart$main.selectAll("." + $COMMON.target);
22013 }
22014 (_$target = $target) == null ? void 0 : _$target.style("opacity", null);
22015 (_subchart$main2 = subchart.main) == null ? void 0 : _subchart$main2.style("display", null);
22016 this.resize();
22017 }
22018 },
22019 /**
22020 * Hide generated subchart
22021 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
22022 * @function subchart․hide
22023 * @instance
22024 * @memberof Chart
22025 * @example
22026 * chart.subchart.hide();
22027 */
22028 hide: function hide() {
22029 var $$ = this.internal,
22030 main = $$.$el.subchart.main,
22031 config = $$.config;
22032 if (config.subchart_show && (main == null ? void 0 : main.style("display")) !== "none") {
22033 config.subchart_show = !1;
22034 main.style("display", "none");
22035 this.resize();
22036 }
22037 },
22038 /**
22039 * Toggle the visiblity of subchart
22040 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
22041 * @function subchart․toggle
22042 * @instance
22043 * @memberof Chart
22044 * @example
22045 * // When subchart is hidden, will be shown
22046 * // When subchart is shown, will be hidden
22047 * chart.subchart.toggle();
22048 */
22049 toggle: function toggle() {
22050 var $$ = this.internal,
22051 config = $$.config;
22052 this.subchart[config.subchart_show ? "hide" : "show"]();
22053 }
22054 }
22055});
22056// EXTERNAL MODULE: external {"commonjs":"d3-zoom","commonjs2":"d3-zoom","amd":"d3-zoom","root":"d3"}
22057var external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_ = __webpack_require__(13);
22058;// CONCATENATED MODULE: ./src/Chart/api/zoom.ts
22059
22060/**
22061 * Copyright (c) 2017 ~ present NAVER Corp.
22062 * billboard.js project is licensed under the MIT license
22063 */
22064
22065
22066
22067/**
22068 * Check if the given domain is within zoom range
22069 * @param {Array} domain Target domain value
22070 * @param {Array} current Current zoom domain value
22071 * @param {Array} range Zoom range value
22072 * @returns {boolean}
22073 * @private
22074 */
22075function withinRange(domain, current, range) {
22076 var _this = this,
22077 min = range[0],
22078 max = range[1];
22079 return domain.every(function (v, i) {
22080 var _this2 = this;
22081 _newArrowCheck(this, _this);
22082 return (i === 0 ? v >= min : v <= max) && !domain.every(function (v, i) {
22083 _newArrowCheck(this, _this2);
22084 return v === current[i];
22085 }.bind(this));
22086 }.bind(this));
22087}
22088
22089/**
22090 * Zoom by giving x domain range.
22091 * - **NOTE:**
22092 * - For `wheel` type zoom, the minimum zoom range will be set as the given domain range. To get the initial state, [.unzoom()](#unzoom) should be called.
22093 * - To be used [zoom.enabled](Options.html#.zoom) option should be set as `truthy`.
22094 * @function zoom
22095 * @instance
22096 * @memberof Chart
22097 * @param {Array} domainValue If domain range is given, the chart will be zoomed to the given domain. If no argument is given, the current zoomed domain will be returned.
22098 * @returns {Array} domain value in array
22099 * @example
22100 * // Zoom to specified domain range
22101 * chart.zoom([10, 20]);
22102 *
22103 * // For timeseries, the domain value can be string, but the format should match with the 'data.xFormat' option.
22104 * chart.zoom(["2021-02-03", "2021-02-08"]);
22105 *
22106 * // Get the current zoomed domain range
22107 * chart.zoom();
22108 */
22109var zoom = function (domainValue) {
22110 var _this3 = this,
22111 $$ = this.internal,
22112 $el = $$.$el,
22113 axis = $$.axis,
22114 config = $$.config,
22115 org = $$.org,
22116 scale = $$.scale,
22117 isRotated = config.axis_rotated,
22118 isCategorized = axis.isCategorized(),
22119 domain = domainValue;
22120 if (config.zoom_enabled && domain) {
22121 if (axis.isTimeSeries()) {
22122 domain = domain.map(function (x) {
22123 _newArrowCheck(this, _this3);
22124 return parseDate.bind($$)(x);
22125 }.bind(this));
22126 }
22127 if (withinRange(domain, $$.getZoomDomain(!0), $$.getZoomDomain())) {
22128 if (isCategorized) {
22129 domain = domain.map(function (v, i) {
22130 _newArrowCheck(this, _this3);
22131 return +v + (i === 0 ? 0 : 1);
22132 }.bind(this));
22133 }
22134
22135 // hide any possible tooltip show before the zoom
22136 $$.api.tooltip.hide();
22137 if (config.subchart_show) {
22138 var x = scale.zoom || scale.x;
22139 $$.brush.getSelection().call($$.brush.move, domain.map(x));
22140 // resultDomain = domain;
22141 } else {
22142 var _d3ZoomIdentity$scale,
22143 _x = isCategorized ? scale.x.orgScale() : org.xScale || scale.x,
22144 translate = [-_x(domain[0]), 0],
22145 transform = (_d3ZoomIdentity$scale = external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.scale(_x.range()[1] / (_x(domain[1]) - _x(domain[0])))).translate.apply(_d3ZoomIdentity$scale, isRotated ? translate.reverse() : translate);
22146 $el.eventRect.call($$.zoom.transform, transform);
22147 }
22148 $$.setZoomResetButton();
22149 }
22150 } else {
22151 domain = scale.zoom ? scale.zoom.domain() : scale.x.orgDomain();
22152 }
22153 return domain;
22154};
22155extend(zoom, {
22156 /**
22157 * Enable and disable zooming.
22158 * @function zoom․enable
22159 * @instance
22160 * @memberof Chart
22161 * @param {string|boolean} enabled Possible string values are "wheel" or "drag". If enabled is true, "wheel" will be used. If false is given, zooming will be disabled.<br>When set to false, the current zooming status will be reset.
22162 * @example
22163 * // Enable zooming using the mouse wheel
22164 * chart.zoom.enable(true);
22165 * // Or
22166 * chart.zoom.enable("wheel");
22167 *
22168 * // Enable zooming by dragging
22169 * chart.zoom.enable("drag");
22170 *
22171 * // Disable zooming
22172 * chart.zoom.enable(false);
22173 */
22174 enable: function enable(enabled) {
22175 var $$ = this.internal,
22176 config = $$.config;
22177 if (/^(drag|wheel)$/.test(enabled)) {
22178 config.zoom_type = enabled;
22179 }
22180 config.zoom_enabled = !!enabled;
22181 if (!$$.zoom) {
22182 $$.initZoom();
22183 $$.bindZoomEvent();
22184 } else if (enabled === !1) {
22185 $$.bindZoomEvent(!1);
22186 }
22187 $$.updateAndRedraw();
22188 },
22189 /**
22190 * Set or get x Axis maximum zoom range value
22191 * @function zoom․max
22192 * @instance
22193 * @memberof Chart
22194 * @param {number} [max] maximum value to set for zoom
22195 * @returns {number} zoom max value
22196 * @example
22197 * // Set maximum range value
22198 * chart.zoom.max(20);
22199 */
22200 max: function max(_max) {
22201 var $$ = this.internal,
22202 config = $$.config,
22203 xDomain = $$.org.xDomain;
22204 if (_max === 0 || _max) {
22205 config.zoom_x_max = getMinMax("max", [xDomain[1], _max]);
22206 }
22207 return config.zoom_x_max;
22208 },
22209 /**
22210 * Set or get x Axis minimum zoom range value
22211 * @function zoom․min
22212 * @instance
22213 * @memberof Chart
22214 * @param {number} [min] minimum value to set for zoom
22215 * @returns {number} zoom min value
22216 * @example
22217 * // Set minimum range value
22218 * chart.zoom.min(-1);
22219 */
22220 min: function min(_min) {
22221 var $$ = this.internal,
22222 config = $$.config,
22223 xDomain = $$.org.xDomain;
22224 if (_min === 0 || _min) {
22225 config.zoom_x_min = getMinMax("min", [xDomain[0], _min]);
22226 }
22227 return config.zoom_x_min;
22228 },
22229 /**
22230 * Set zoom range
22231 * @function zoom․range
22232 * @instance
22233 * @memberof Chart
22234 * @param {object} [range] zoom range
22235 * @returns {object} zoom range value
22236 * {
22237 * min: 0,
22238 * max: 100
22239 * }
22240 * @example
22241 * chart.zoom.range({
22242 * min: 10,
22243 * max: 100
22244 * });
22245 */
22246 range: function range(_range) {
22247 var zoom = this.zoom;
22248 if (isObject(_range)) {
22249 var min = _range.min,
22250 max = _range.max;
22251 isDefined(min) && zoom.min(min);
22252 isDefined(max) && zoom.max(max);
22253 }
22254 return {
22255 min: zoom.min(),
22256 max: zoom.max()
22257 };
22258 }
22259});
22260/* harmony default export */ var api_zoom = ({
22261 zoom: zoom,
22262 /**
22263 * Unzoom zoomed area
22264 * - **NOTE:** Calling .unzoom() will not trigger zoom events.
22265 * @function unzoom
22266 * @instance
22267 * @memberof Chart
22268 * @example
22269 * chart.unzoom();
22270 */
22271 unzoom: function unzoom() {
22272 var $$ = this.internal,
22273 config = $$.config,
22274 _$$$$el = $$.$el,
22275 eventRect = _$$$$el.eventRect,
22276 zoomResetBtn = _$$$$el.zoomResetBtn;
22277 if ($$.scale.zoom) {
22278 config.subchart_show ? $$.brush.getSelection().call($$.brush.move, null) : $$.zoom.updateTransformScale(external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
22279 $$.updateZoom(!0);
22280 zoomResetBtn == null ? void 0 : zoomResetBtn.style("display", "none");
22281
22282 // reset transform
22283 if ((0,external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomTransform)(eventRect.node()) !== external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity) {
22284 $$.zoom.transform(eventRect, external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
22285 }
22286 }
22287 }
22288});
22289;// CONCATENATED MODULE: ./src/ChartInternal/interactions/drag.ts
22290
22291/**
22292 * Copyright (c) 2017 ~ present NAVER Corp.
22293 * billboard.js project is licensed under the MIT license
22294 */
22295
22296
22297
22298
22299/**
22300 * Module used for data.selection.draggable option
22301 */
22302/* harmony default export */ var drag = ({
22303 /**
22304 * Called when dragging.
22305 * Data points can be selected.
22306 * @private
22307 * @param {object} mouse Object
22308 */
22309 drag: function drag(mouse) {
22310 var _this = this,
22311 $$ = this,
22312 config = $$.config,
22313 state = $$.state,
22314 main = $$.$el.main,
22315 isSelectionGrouped = config.data_selection_grouped,
22316 isSelectable = config.interaction_enabled && config.data_selection_isselectable;
22317 if ($$.hasArcType() || !config.data_selection_enabled ||
22318 // do nothing if not selectable
22319 config.zoom_enabled && !$$.zoom.altDomain ||
22320 // skip if zoomable because of conflict drag behavior
22321 !config.data_selection_multiple // skip when single selection because drag is used for multiple selection
22322 ) {
22323 return;
22324 }
22325 var _ref = state.dragStart || [0, 0],
22326 sx = _ref[0],
22327 sy = _ref[1],
22328 mx = mouse[0],
22329 my = mouse[1],
22330 minX = Math.min(sx, mx),
22331 maxX = Math.max(sx, mx),
22332 minY = isSelectionGrouped ? state.margin.top : Math.min(sy, my),
22333 maxY = isSelectionGrouped ? state.height : Math.max(sy, my);
22334 main.select("." + $DRAG.dragarea).attr("x", minX).attr("y", minY).attr("width", maxX - minX).attr("height", maxY - minY);
22335
22336 // TODO: binary search when multiple xs
22337 main.selectAll("." + $SHAPE.shapes).selectAll("." + $SHAPE.shape).filter(function (d) {
22338 _newArrowCheck(this, _this);
22339 return isSelectable == null ? void 0 : isSelectable.bind($$.api)(d);
22340 }.bind(this)).each(function (d, i) {
22341 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
22342 isSelected = shape.classed($SELECT.SELECTED),
22343 isIncluded = shape.classed($DRAG.INCLUDED),
22344 isWithin = !1,
22345 toggle;
22346 if (shape.classed($CIRCLE.circle)) {
22347 var x = +shape.attr("cx") * 1,
22348 y = +shape.attr("cy") * 1;
22349 toggle = $$.togglePoint;
22350 isWithin = minX < x && x < maxX && minY < y && y < maxY;
22351 } else if (shape.classed($BAR.bar)) {
22352 var _getPathBox = getPathBox(this),
22353 _x = _getPathBox.x,
22354 y = _getPathBox.y,
22355 width = _getPathBox.width,
22356 height = _getPathBox.height;
22357 toggle = $$.togglePath;
22358 isWithin = !(maxX < _x || _x + width < minX) && !(maxY < y || y + height < minY);
22359 } else {
22360 // line/area selection not supported yet
22361 return;
22362 }
22363
22364 // @ts-ignore
22365 if (isWithin ^ isIncluded) {
22366 shape.classed($DRAG.INCLUDED, !isIncluded);
22367 // TODO: included/unincluded callback here
22368 shape.classed($SELECT.SELECTED, !isSelected);
22369 toggle.call($$, !isSelected, shape, d, i);
22370 }
22371 });
22372 },
22373 /**
22374 * Called when the drag starts.
22375 * Adds and Shows the drag area.
22376 * @private
22377 * @param {object} mouse Object
22378 */
22379 dragstart: function dragstart(mouse) {
22380 var $$ = this,
22381 config = $$.config,
22382 state = $$.state,
22383 main = $$.$el.main;
22384 if ($$.hasArcType() || !config.data_selection_enabled) {
22385 return;
22386 }
22387 state.dragStart = mouse;
22388 main.select("." + $COMMON.chart).append("rect").attr("class", $DRAG.dragarea).style("opacity", "0.1");
22389 $$.setDragStatus(!0);
22390 },
22391 /**
22392 * Called when the drag finishes.
22393 * Removes the drag area.
22394 * @private
22395 */
22396 dragend: function dragend() {
22397 var $$ = this,
22398 config = $$.config,
22399 main = $$.$el.main,
22400 $T = $$.$T;
22401 if ($$.hasArcType() || !config.data_selection_enabled) {
22402 // do nothing if not selectable
22403 return;
22404 }
22405 $T(main.select("." + $DRAG.dragarea)).style("opacity", "0").remove();
22406 main.selectAll("." + $SHAPE.shape).classed($DRAG.INCLUDED, !1);
22407 $$.setDragStatus(!1);
22408 }
22409});
22410;// CONCATENATED MODULE: ./src/ChartInternal/internals/selection.ts
22411
22412
22413function selection_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22414function selection_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? selection_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : selection_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
22415/**
22416 * Copyright (c) 2017 ~ present NAVER Corp.
22417 * billboard.js project is licensed under the MIT license
22418 */
22419
22420
22421
22422
22423/* harmony default export */ var internals_selection = (selection_objectSpread(selection_objectSpread({}, drag), {}, {
22424 /**
22425 * Select a point
22426 * @param {object} target Target point
22427 * @param {object} d Data object
22428 * @param {number} i Index number
22429 * @private
22430 */
22431 selectPoint: function selectPoint(target, d, i) {
22432 var _this = this,
22433 $$ = this,
22434 config = $$.config,
22435 main = $$.$el.main,
22436 $T = $$.$T,
22437 isRotated = config.axis_rotated,
22438 cx = (isRotated ? $$.circleY : $$.circleX).bind($$),
22439 cy = (isRotated ? $$.circleX : $$.circleY).bind($$),
22440 r = $$.pointSelectR.bind($$);
22441 callFn(config.data_onselected, $$.api, d, target.node());
22442
22443 // add selected-circle on low layer g
22444 $T(main.select("." + $SELECT.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll("." + $SELECT.selectedCircle + "-" + i).data([d]).enter().append("circle").attr("class", function () {
22445 _newArrowCheck(this, _this);
22446 return $$.generateClass($SELECT.selectedCircle, i);
22447 }.bind(this)).attr("cx", cx).attr("cy", cy).attr("stroke", $$.color).attr("r", function (d2) {
22448 _newArrowCheck(this, _this);
22449 return $$.pointSelectR(d2) * 1.4;
22450 }.bind(this))).attr("r", r);
22451 },
22452 /**
22453 * Unelect a point
22454 * @param {object} target Target point
22455 * @param {object} d Data object
22456 * @param {number} i Index number
22457 * @private
22458 */
22459 unselectPoint: function unselectPoint(target, d, i) {
22460 var $$ = this,
22461 config = $$.config,
22462 main = $$.$el.main,
22463 $T = $$.$T;
22464 callFn(config.data_onunselected, $$.api, d, target.node());
22465
22466 // remove selected-circle from low layer g
22467 $T(main.select("." + $SELECT.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll("." + $SELECT.selectedCircle + "-" + i)).attr("r", 0).remove();
22468 },
22469 /**
22470 * Toggles the selection of points
22471 * @param {boolean} selected whether or not to select.
22472 * @param {object} target Target object
22473 * @param {object} d Data object
22474 * @param {number} i Index number
22475 * @private
22476 */
22477 togglePoint: function togglePoint(selected, target, d, i) {
22478 var method = (selected ? "" : "un") + "selectPoint";
22479 this[method](target, d, i);
22480 },
22481 /**
22482 * Select a path
22483 * @param {object} target Target path
22484 * @param {object} d Data object
22485 * @private
22486 */
22487 selectPath: function selectPath(target, d) {
22488 var $$ = this,
22489 config = $$.config;
22490 callFn(config.data_onselected, $$.api, d, target.node());
22491 if (config.interaction_brighten) {
22492 target.style("filter", "brightness(1.25)");
22493 }
22494 },
22495 /**
22496 * Unelect a path
22497 * @private
22498 * @param {object} target Target path
22499 * @param {object} d Data object
22500 */
22501 unselectPath: function unselectPath(target, d) {
22502 var $$ = this,
22503 config = $$.config;
22504 callFn(config.data_onunselected, $$.api, d, target.node());
22505 if (config.interaction_brighten) {
22506 target.style("filter", null);
22507 }
22508 },
22509 /**
22510 * Toggles the selection of lines
22511 * @param {boolean} selected whether or not to select.
22512 * @param {object} target Target object
22513 * @param {object} d Data object
22514 * @param {number} i Index number
22515 * @private
22516 */
22517 togglePath: function togglePath(selected, target, d, i) {
22518 this[(selected ? "" : "un") + "selectPath"](target, d, i);
22519 },
22520 /**
22521 * Returns the toggle method of the target
22522 * @param {object} that shape
22523 * @param {object} d Data object
22524 * @returns {Function} toggle method
22525 * @private
22526 */
22527 getToggle: function getToggle(that, d) {
22528 var _this2 = this,
22529 $$ = this;
22530 return that.nodeName === "path" ? $$.togglePath : $$.isStepType(d) ? function () {
22531 _newArrowCheck(this, _this2);
22532 }.bind(this) :
22533 // circle is hidden in step chart, so treat as within the click area
22534 $$.togglePoint;
22535 },
22536 /**
22537 * Toggles the selection of shapes
22538 * @param {object} that shape
22539 * @param {object} d Data object
22540 * @param {number} i Index number
22541 * @private
22542 */
22543 toggleShape: function toggleShape(that, d, i) {
22544 var $$ = this,
22545 config = $$.config,
22546 main = $$.$el.main;
22547 if (config.data_selection_enabled && config.data_selection_isselectable.bind($$.api)(d)) {
22548 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that),
22549 isSelected = shape.classed($SELECT.SELECTED),
22550 toggle = $$.getToggle(that, d).bind($$),
22551 toggledShape;
22552 if (!config.data_selection_multiple) {
22553 var selector = "." + $SHAPE.shapes;
22554 if (config.data_selection_grouped) {
22555 selector += $$.getTargetSelectorSuffix(d.id);
22556 }
22557 main.selectAll(selector).selectAll("." + $SHAPE.shape).each(function (d, i) {
22558 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
22559 if (shape.classed($SELECT.SELECTED)) {
22560 toggledShape = shape;
22561 toggle(!1, shape.classed($SELECT.SELECTED, !1), d, i);
22562 }
22563 });
22564 }
22565 if (!toggledShape || toggledShape.node() !== shape.node()) {
22566 shape.classed($SELECT.SELECTED, !isSelected);
22567 toggle(!isSelected, shape, d, i);
22568 }
22569 }
22570 }
22571}));
22572;// CONCATENATED MODULE: ./src/ChartInternal/interactions/subchart.ts
22573
22574/**
22575 * Copyright (c) 2017 ~ present NAVER Corp.
22576 * billboard.js project is licensed under the MIT license
22577 */
22578
22579
22580
22581
22582/* harmony default export */ var interactions_subchart = ({
22583 /**
22584 * Initialize the brush.
22585 * @private
22586 */
22587 initBrush: function initBrush() {
22588 var _this = this,
22589 $$ = this,
22590 config = $$.config,
22591 scale = $$.scale,
22592 subchart = $$.$el.subchart,
22593 isRotated = config.axis_rotated,
22594 lastDomain,
22595 timeout;
22596 // set the brush
22597 $$.brush = (isRotated ? (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushY)() : (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushX)()).handleSize(5);
22598 var getBrushSize = function () {
22599 _newArrowCheck(this, _this);
22600 var brush = $$.$el.svg.select("." + classes.brush + " .overlay"),
22601 brushSize = {
22602 width: 0,
22603 height: 0
22604 };
22605 if (brush.size()) {
22606 brushSize.width = +brush.attr("width");
22607 brushSize.height = +brush.attr("height");
22608 }
22609 return brushSize[isRotated ? "width" : "height"];
22610 }.bind(this);
22611
22612 // bind brush event
22613 $$.brush.on("start brush end", function (event) {
22614 var _this2 = this;
22615 _newArrowCheck(this, _this);
22616 var selection = event.selection,
22617 target = event.target,
22618 type = event.type;
22619 if (type === "start") {
22620 $$.state.inputType === "touch" && $$.hideTooltip();
22621 }
22622 if (/(start|brush)/.test(type)) {
22623 $$.redrawForBrush();
22624 }
22625 if (type === "end") {
22626 lastDomain = scale.x.orgDomain();
22627 }
22628
22629 // handle brush's handle position & visibility
22630 if (target != null && target.handle) {
22631 if (selection === null) {
22632 $$.brush.handle.attr("display", "none");
22633 } else {
22634 $$.brush.handle.attr("display", null).attr("transform", function (d, i) {
22635 _newArrowCheck(this, _this2);
22636 var pos = isRotated ? [33, selection[i] - (i === 0 ? 30 : 24)] : [selection[i], 3];
22637 return "translate(" + pos + ")";
22638 }.bind(this));
22639 }
22640 }
22641 }.bind(this));
22642 $$.brush.updateResize = function () {
22643 var _this3 = this;
22644 timeout && clearTimeout(timeout);
22645 timeout = setTimeout(function () {
22646 _newArrowCheck(this, _this3);
22647 var selection = this.getSelection();
22648 lastDomain && (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection.node()) && this.move(selection, lastDomain.map(scale.subX.orgScale()));
22649 }.bind(this), 0);
22650 };
22651 $$.brush.update = function () {
22652 var _this4 = this,
22653 extent = this.extent()();
22654 if (extent[1].filter(function (v) {
22655 _newArrowCheck(this, _this4);
22656 return isNaN(v);
22657 }.bind(this)).length === 0) {
22658 var _subchart$main;
22659 (_subchart$main = subchart.main) == null ? void 0 : _subchart$main.select("." + classes.brush).call(this);
22660 }
22661 return this;
22662 };
22663
22664 // set the brush extent
22665 $$.brush.scale = function (scale) {
22666 var _this5 = this,
22667 h = config.subchart_size_height || getBrushSize(),
22668 extent = $$.getExtent();
22669 if (!extent && scale.range) {
22670 extent = [[0, 0], [scale.range()[1], h]];
22671 } else if (isArray(extent)) {
22672 extent = extent.map(function (v, i) {
22673 _newArrowCheck(this, _this5);
22674 return [v, i > 0 ? h : i];
22675 }.bind(this));
22676 }
22677
22678 // [[x0, y0], [x1, y1]], where [x0, y0] is the top-left corner and [x1, y1] is the bottom-right corner
22679 isRotated && extent[1].reverse();
22680 this.extent(extent);
22681
22682 // when extent updates, brush selection also be re-applied
22683 // https://github.com/d3/d3/issues/2918
22684 this.update();
22685 };
22686 $$.brush.getSelection = function () {
22687 _newArrowCheck(this, _this);
22688 return (
22689 // @ts-ignore
22690 subchart.main ? subchart.main.select("." + classes.brush) : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)([])
22691 );
22692 }.bind(this);
22693 },
22694 /**
22695 * Initialize the subchart.
22696 * @private
22697 */
22698 initSubchart: function initSubchart() {
22699 var _this6 = this,
22700 $$ = this,
22701 config = $$.config,
22702 _$$$state = $$.state,
22703 clip = _$$$state.clip,
22704 hasAxis = _$$$state.hasAxis,
22705 _$$$$el = $$.$el,
22706 defs = _$$$$el.defs,
22707 svg = _$$$$el.svg,
22708 subchart = _$$$$el.subchart,
22709 axis = _$$$$el.axis;
22710 if (!hasAxis) {
22711 return;
22712 }
22713 var visibility = config.subchart_show ? null : "hidden",
22714 clipId = clip.id + "-subchart",
22715 clipPath = $$.getClipPath(clipId);
22716 clip.idSubchart = clipId;
22717 $$.appendClip(defs, clipId);
22718 $$.initBrush();
22719 subchart.main = svg.append("g").classed(classes.subchart, !0).attr("transform", $$.getTranslate("context"));
22720 var main = subchart.main;
22721 main.style("visibility", visibility);
22722
22723 // Define g for chart area
22724 main.append("g").attr("clip-path", clipPath).attr("class", classes.chart);
22725
22726 // Define g for chart types area
22727 ["bar", "line", "bubble", "candlestick", "scatter"].forEach(function (v) {
22728 _newArrowCheck(this, _this6);
22729 var type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
22730 if ($$.hasType(v) || $$.hasTypeOf(type)) {
22731 var chart = main.select("." + classes.chart),
22732 chartClassName = classes["chart" + type + "s"];
22733 if (chart.select("." + chartClassName).empty()) {
22734 chart.append("g").attr("class", chartClassName);
22735 }
22736 }
22737 }.bind(this));
22738
22739 // Add extent rect for Brush
22740 var brush = main.append("g").attr("clip-path", clipPath).attr("class", classes.brush).call($$.brush);
22741 config.subchart_showHandle && $$.addBrushHandle(brush);
22742
22743 // ATTENTION: This must be called AFTER chart added
22744 // Add Axis
22745 axis.subX = main.append("g").attr("class", classes.axisX).attr("transform", $$.getTranslate("subX")).attr("clip-path", config.axis_rotated ? "" : clip.pathXAxis).style("visibility", config.subchart_axis_x_show ? visibility : "hidden");
22746 },
22747 /**
22748 * Add brush handle
22749 * Enabled when: subchart.showHandle=true
22750 * @param {d3Selection} brush Brush selection
22751 * @private
22752 */
22753 addBrushHandle: function addBrushHandle(brush) {
22754 var _this7 = this,
22755 $$ = this,
22756 config = $$.config,
22757 isRotated = config.axis_rotated,
22758 initRange = config.subchart_init_range,
22759 path = isRotated ? ["M 5.2491724,29.749209 a 6,6 0 0 0 -5.50000003,-6.5 H -5.7508276 a 6,6 0 0 0 -6.0000004,6.5 z m -5.00000003,-2 H -6.7508276 m 6.99999997,-2 H -6.7508276Z", "M 5.2491724,23.249172 a 6,-6 0 0 1 -5.50000003,6.5 H -5.7508276 a 6,-6 0 0 1 -6.0000004,-6.5 z m -5.00000003,2 H -6.7508276 m 6.99999997,2 H -6.7508276Z"] : ["M 0 18 A 6 6 0 0 0 -6.5 23.5 V 29 A 6 6 0 0 0 0 35 Z M -2 23 V 30 M -4 23 V 30Z", "M 0 18 A 6 6 0 0 1 6.5 23.5 V 29 A 6 6 0 0 1 0 35 Z M 2 23 V 30 M 4 23 V 30Z"];
22760 $$.brush.handle = brush.selectAll(".handle--custom").data(isRotated ? [{
22761 type: "n"
22762 }, {
22763 type: "s"
22764 }] : [{
22765 type: "w"
22766 }, {
22767 type: "e"
22768 }]).enter().append("path").attr("class", "handle--custom").attr("cursor", (isRotated ? "ns" : "ew") + "-resize").attr("d", function (d) {
22769 _newArrowCheck(this, _this7);
22770 return path[+/[se]/.test(d.type)];
22771 }.bind(this)).attr("display", initRange ? null : "none");
22772 },
22773 /**
22774 * Update sub chart
22775 * @param {object} targets $$.data.targets
22776 * @private
22777 */
22778 updateTargetsForSubchart: function updateTargetsForSubchart(targets) {
22779 var _this8 = this,
22780 $$ = this,
22781 config = $$.config,
22782 state = $$.state,
22783 main = $$.$el.subchart.main;
22784 if (config.subchart_show) {
22785 ["bar", "line", "bubble", "candlestick", "scatter"].filter(function (v) {
22786 _newArrowCheck(this, _this8);
22787 return $$.hasType(v) || $$.hasTypeOf(capitalize(v));
22788 }.bind(this)).forEach(function (v) {
22789 _newArrowCheck(this, _this8);
22790 var isPointType = /^(bubble|scatter)$/.test(v),
22791 name = capitalize(isPointType ? "circle" : v),
22792 chartClass = $$.getChartClass(name, !0),
22793 shapeClass = $$.getClass(isPointType ? "circles" : v + "s", !0),
22794 shapeChart = main.select("." + classes["chart" + (name + "s")]);
22795 if (isPointType) {
22796 var circle = shapeChart.selectAll("." + classes.circles).data(targets.filter($$["is" + capitalize(v) + "Type"].bind($$))).attr("class", shapeClass);
22797 circle.exit().remove();
22798 circle.enter().append("g").attr("class", shapeClass);
22799 } else {
22800 var shapeUpdate = shapeChart.selectAll("." + classes["chart" + name]).attr("class", chartClass).data(targets.filter($$["is" + name + "Type"].bind($$))),
22801 shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
22802 shapeUpdate.exit().remove();
22803
22804 // Area
22805 v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", !0));
22806 }
22807 }.bind(this));
22808
22809 // -- Brush --//
22810 main.selectAll("." + classes.brush + " rect").attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? state.width2 : state.height2);
22811 }
22812 },
22813 /**
22814 * Redraw subchart.
22815 * @private
22816 * @param {boolean} withSubchart whether or not to show subchart
22817 * @param {number} duration duration
22818 * @param {object} shape Shape's info
22819 */
22820 redrawSubchart: function redrawSubchart(withSubchart, duration, shape) {
22821 var _this9 = this,
22822 $$ = this,
22823 config = $$.config,
22824 main = $$.$el.subchart.main,
22825 state = $$.state,
22826 withTransition = !!duration;
22827 main.style("visibility", config.subchart_show ? null : "hidden");
22828
22829 // subchart
22830 if (config.subchart_show) {
22831 var _state$event;
22832 // reflect main chart to extent on subchart if zoomed
22833 if (((_state$event = state.event) == null ? void 0 : _state$event.type) === "zoom") {
22834 $$.brush.update();
22835 }
22836
22837 // update subchart elements if needed
22838 if (withSubchart) {
22839 var initRange = config.subchart_init_range;
22840
22841 // extent rect
22842 brushEmpty($$) || $$.brush.update();
22843 Object.keys(shape.type).forEach(function (v) {
22844 _newArrowCheck(this, _this9);
22845 var name = capitalize(v),
22846 drawFn = $$["generateDraw" + name](shape.indices[v], !0);
22847 // call shape's update & redraw method
22848 $$["update" + name](withTransition, !0);
22849 $$["redraw" + name](drawFn, withTransition, !0);
22850 }.bind(this));
22851 if ($$.hasType("bubble") || $$.hasType("scatter")) {
22852 var cx = shape.pos.cx,
22853 cy = $$.updateCircleY(!0);
22854 $$.updateCircle(!0);
22855 $$.redrawCircle(cx, cy, withTransition, undefined, !0);
22856 }
22857 !state.rendered && initRange && $$.brush.move($$.brush.getSelection(), initRange.map($$.scale.x));
22858 }
22859 }
22860 },
22861 /**
22862 * Redraw the brush.
22863 * @private
22864 */
22865 redrawForBrush: function redrawForBrush() {
22866 var $$ = this,
22867 _$$$config = $$.config,
22868 onBrush = _$$$config.subchart_onbrush,
22869 withY = _$$$config.zoom_rescale,
22870 scale = $$.scale;
22871 $$.redraw({
22872 withTransition: !1,
22873 withY: withY,
22874 withSubchart: !1,
22875 withUpdateXDomain: !0,
22876 withDimension: !1
22877 });
22878 onBrush.bind($$.api)(scale.x.orgDomain());
22879 },
22880 /**
22881 * Transform context
22882 * @param {boolean} withTransition indicates transition is enabled
22883 * @param {object} transitions The return value of the generateTransitions method of Axis.
22884 * @private
22885 */
22886 transformContext: function transformContext(withTransition, transitions) {
22887 var $$ = this,
22888 subchart = $$.$el.subchart,
22889 $T = $$.$T,
22890 subXAxis = transitions != null && transitions.axisSubX ? transitions.axisSubX : $T(subchart.main.select("." + classes.axisX), withTransition);
22891 subchart.main.attr("transform", $$.getTranslate("context"));
22892 subXAxis.attr("transform", $$.getTranslate("subX"));
22893 },
22894 /**
22895 * Get extent value
22896 * @returns {Array} default extent
22897 * @private
22898 */
22899 getExtent: function getExtent() {
22900 var _this10 = this,
22901 $$ = this,
22902 config = $$.config,
22903 scale = $$.scale,
22904 extent = config.axis_x_extent;
22905 if (extent) {
22906 if (isFunction(extent)) {
22907 extent = extent.bind($$.api)($$.getXDomain($$.data.targets), scale.subX);
22908 } else if ($$.axis.isTimeSeries() && extent.every(isNaN)) {
22909 var fn = parseDate.bind($$);
22910 extent = extent.map(function (v) {
22911 _newArrowCheck(this, _this10);
22912 return scale.subX(fn(v));
22913 }.bind(this));
22914 }
22915 }
22916 return extent;
22917 }
22918});
22919;// CONCATENATED MODULE: ./src/ChartInternal/interactions/zoom.ts
22920
22921/**
22922 * Copyright (c) 2017 ~ present NAVER Corp.
22923 * billboard.js project is licensed under the MIT license
22924 */
22925
22926
22927
22928
22929/* harmony default export */ var interactions_zoom = ({
22930 /**
22931 * Initialize zoom.
22932 * @private
22933 */
22934 initZoom: function initZoom() {
22935 var $$ = this;
22936 $$.scale.zoom = null;
22937 $$.generateZoom();
22938 $$.initZoomBehaviour();
22939 },
22940 /**
22941 * Bind zoom event
22942 * @param {boolean} bind Weather bind or unbound
22943 * @private
22944 */
22945 bindZoomEvent: function bindZoomEvent(bind) {
22946 if (bind === void 0) {
22947 bind = !0;
22948 }
22949 var $$ = this,
22950 config = $$.config,
22951 zoomEnabled = config.zoom_enabled;
22952 if (zoomEnabled && bind) {
22953 // Do not bind zoom event when subchart is shown
22954 config.subchart_show || $$.bindZoomOnEventRect();
22955 } else if (bind === !1) {
22956 $$.api.unzoom();
22957 $$.unbindZoomEvent();
22958 }
22959 },
22960 /**
22961 * Generate zoom
22962 * @private
22963 */
22964 generateZoom: function generateZoom() {
22965 var _this = this,
22966 $$ = this,
22967 config = $$.config,
22968 org = $$.org,
22969 scale = $$.scale,
22970 zoom = (0,external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoom)().duration(0).on("start", $$.onZoomStart.bind($$)).on("zoom", $$.onZoom.bind($$)).on("end", $$.onZoomEnd.bind($$));
22971 // get zoom extent
22972 // @ts-ignore
22973 zoom.orgScaleExtent = function () {
22974 _newArrowCheck(this, _this);
22975 var extent = config.zoom_extent || [1, 10];
22976 return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])];
22977 }.bind(this);
22978
22979 // @ts-ignore
22980 zoom.updateScaleExtent = function () {
22981 var ratio = diffDomain($$.scale.x.orgDomain()) / diffDomain($$.getZoomDomain()),
22982 extent = this.orgScaleExtent();
22983 this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
22984 return this;
22985 };
22986
22987 /**
22988 * Update scale according zoom transform value
22989 * @param {object} transform transform object
22990 * @param {boolean} correctTransform if the d3 transform should be updated after rescaling
22991 * @private
22992 */
22993 // @ts-ignore
22994 zoom.updateTransformScale = function (transform, correctTransform) {
22995 var _org$xScale;
22996 _newArrowCheck(this, _this);
22997 var isRotated = config.axis_rotated;
22998
22999 // in case of resize, update range of orgXScale
23000 (_org$xScale = org.xScale) == null ? void 0 : _org$xScale.range(scale.x.range());
23001
23002 // rescale from the original scale
23003 var newScale = transform[isRotated ? "rescaleY" : "rescaleX"](org.xScale || scale.x),
23004 domain = $$.trimXDomain(newScale.domain()),
23005 rescale = config.zoom_rescale;
23006 newScale.domain(domain, org.xDomain);
23007
23008 // prevent chart from panning off the edge and feeling "stuck"
23009 // https://github.com/naver/billboard.js/issues/2588
23010 if (correctTransform) {
23011 var t = newScale(scale.x.domain()[0]),
23012 tX = isRotated ? transform.x : t,
23013 tY = isRotated ? t : transform.y;
23014 $$.$el.eventRect.property("__zoom", external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.translate(tX, tY).scale(transform.k));
23015 }
23016 if (!$$.state.xTickOffset) {
23017 $$.state.xTickOffset = $$.axis.x.tickOffset();
23018 }
23019 scale.zoom = $$.getCustomizedScale(newScale);
23020 $$.axis.x.scale(scale.zoom);
23021 if (rescale) {
23022 // copy current initial x scale in case of rescale option is used
23023 org.xScale || (org.xScale = scale.x.copy());
23024 scale.x.domain(domain);
23025 }
23026 }.bind(this);
23027
23028 /**
23029 * Get zoom domain
23030 * @returns {Array} zoom domain
23031 * @private
23032 */
23033 // @ts-ignore
23034 zoom.getDomain = function () {
23035 _newArrowCheck(this, _this);
23036 var domain = scale[scale.zoom ? "zoom" : "subX"].domain(),
23037 isCategorized = $$.axis.isCategorized();
23038 if (isCategorized) {
23039 domain[1] -= 2;
23040 }
23041 return domain;
23042 }.bind(this);
23043 $$.zoom = zoom;
23044 },
23045 /**
23046 * 'start' event listener
23047 * @param {object} event Event object
23048 * @private
23049 */
23050 onZoomStart: function onZoomStart(event) {
23051 var $$ = this,
23052 sourceEvent = event.sourceEvent;
23053 if (sourceEvent) {
23054 $$.zoom.startEvent = sourceEvent;
23055 $$.state.zooming = !0;
23056 callFn($$.config.zoom_onzoomstart, $$.api, event);
23057 }
23058 },
23059 /**
23060 * 'zoom' event listener
23061 * @param {object} event Event object
23062 * @private
23063 */
23064 onZoom: function onZoom(event) {
23065 var _this2 = this,
23066 $$ = this,
23067 config = $$.config,
23068 scale = $$.scale,
23069 state = $$.state,
23070 org = $$.org,
23071 sourceEvent = event.sourceEvent,
23072 isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
23073 if (!config.zoom_enabled || $$.filterTargetsToShow($$.data.targets).length === 0 || !scale.zoom && (sourceEvent == null ? void 0 : sourceEvent.type.indexOf("touch")) > -1 && (sourceEvent == null ? void 0 : sourceEvent.touches.length) === 1) {
23074 return;
23075 }
23076 if (event.sourceEvent) {
23077 state.zooming = !0;
23078 }
23079 var isMousemove = (sourceEvent == null ? void 0 : sourceEvent.type) === "mousemove",
23080 isZoomOut = (sourceEvent == null ? void 0 : sourceEvent.wheelDelta) < 0,
23081 transform = event.transform;
23082 if (!isMousemove && isZoomOut && scale.x.domain().every(function (v, i) {
23083 _newArrowCheck(this, _this2);
23084 return v !== org.xDomain[i];
23085 }.bind(this))) {
23086 scale.x.domain(org.xDomain);
23087 }
23088 $$.zoom.updateTransformScale(transform, config.zoom_type === "wheel" && sourceEvent);
23089
23090 // do zoom transiton when:
23091 // - zoom type 'drag'
23092 // - when .unzoom() is called (event.transform === d3ZoomIdentity)
23093 var doTransition = config.transition_duration > 0 && !config.subchart_show && (state.dragging || isUnZoom || !event.sourceEvent);
23094 $$.redraw({
23095 withTransition: doTransition,
23096 withY: config.zoom_rescale,
23097 withSubchart: !1,
23098 withEventRect: !1,
23099 withDimension: !1
23100 });
23101 $$.state.cancelClick = isMousemove;
23102
23103 // do not call event cb when is .unzoom() is called
23104 isUnZoom || callFn(config.zoom_onzoom, $$.api, $$.zoom.getDomain());
23105 },
23106 /**
23107 * 'end' event listener
23108 * @param {object} event Event object
23109 * @private
23110 */
23111 onZoomEnd: function onZoomEnd(event) {
23112 var _startEvent,
23113 $$ = this,
23114 config = $$.config,
23115 state = $$.state,
23116 startEvent = $$.zoom.startEvent,
23117 e = event == null ? void 0 : event.sourceEvent,
23118 isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
23119 if (((_startEvent = startEvent) == null ? void 0 : _startEvent.type.indexOf("touch")) > -1) {
23120 var _e, _e$changedTouches;
23121 startEvent = startEvent.changedTouches[0];
23122 e = (_e = e) == null ? void 0 : (_e$changedTouches = _e.changedTouches) == null ? void 0 : _e$changedTouches[0];
23123 }
23124
23125 // if click, do nothing. otherwise, click interaction will be canceled.
23126 if (config.zoom_type === "drag" && e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY) {
23127 return;
23128 }
23129 $$.redrawEventRect();
23130 $$.updateZoom();
23131 state.zooming = !1;
23132
23133 // do not call event cb when is .unzoom() is called
23134 !isUnZoom && (e || state.dragging) && callFn(config.zoom_onzoomend, $$.api, $$.zoom.getDomain());
23135 },
23136 /**
23137 * Update zoom
23138 * @param {boolean} force Force unzoom
23139 * @private
23140 */
23141 updateZoom: function updateZoom(force) {
23142 var $$ = this,
23143 _$$$scale = $$.scale,
23144 subX = _$$$scale.subX,
23145 x = _$$$scale.x,
23146 zoom = _$$$scale.zoom;
23147 if (zoom) {
23148 var zoomDomain = zoom.domain(),
23149 xDomain = subX.domain(),
23150 delta = .015,
23151 isfullyShown = (zoomDomain[0] <= xDomain[0] || zoomDomain[0] - delta <= xDomain[0]) && (xDomain[1] <= zoomDomain[1] || xDomain[1] <= zoomDomain[1] - delta);
23152 // check if the zoomed chart is fully shown, then reset scale when zoom is out as initial
23153 if (force || isfullyShown) {
23154 $$.axis.x.scale(subX);
23155 x.domain(subX.orgDomain());
23156 $$.scale.zoom = null;
23157 }
23158 }
23159 },
23160 /**
23161 * Attach zoom event on <rect>
23162 * @private
23163 */
23164 bindZoomOnEventRect: function bindZoomOnEventRect() {
23165 var _this3 = this,
23166 $$ = this,
23167 config = $$.config,
23168 eventRect = $$.$el.eventRect,
23169 behaviour = config.zoom_type === "drag" ? $$.zoomBehaviour : $$.zoom;
23170 // Since Chrome 89, wheel zoom not works properly
23171 // Applying the workaround: https://github.com/d3/d3-zoom/issues/231#issuecomment-802305692
23172 $$.$el.svg.on("wheel", function () {
23173 _newArrowCheck(this, _this3);
23174 }.bind(this));
23175 eventRect.call(behaviour).on("dblclick.zoom", null);
23176 },
23177 /**
23178 * Initialize the drag behaviour used for zooming.
23179 * @private
23180 */
23181 initZoomBehaviour: function initZoomBehaviour() {
23182 var _this4 = this,
23183 $$ = this,
23184 config = $$.config,
23185 state = $$.state,
23186 isRotated = config.axis_rotated,
23187 start = 0,
23188 end = 0,
23189 zoomRect,
23190 prop = {
23191 axis: isRotated ? "y" : "x",
23192 attr: isRotated ? "height" : "width",
23193 index: isRotated ? 1 : 0
23194 };
23195 $$.zoomBehaviour = (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().clickDistance(4).on("start", function (event) {
23196 state.event = event;
23197 $$.setDragStatus(!0);
23198 $$.unselectRect();
23199 if (!zoomRect) {
23200 zoomRect = $$.$el.main.append("rect").attr("clip-path", state.clip.path).attr("class", $ZOOM.zoomBrush).attr("width", isRotated ? state.width : 0).attr("height", isRotated ? 0 : state.height);
23201 }
23202 start = getPointer(event, this)[prop.index];
23203 end = start;
23204 zoomRect.attr(prop.axis, start).attr(prop.attr, 0);
23205 $$.onZoomStart(event);
23206 }).on("drag", function (event) {
23207 end = getPointer(event, this)[prop.index];
23208 zoomRect.attr(prop.axis, Math.min(start, end)).attr(prop.attr, Math.abs(end - start));
23209 }).on("end", function (event) {
23210 var _this5 = this;
23211 _newArrowCheck(this, _this4);
23212 var scale = $$.scale.zoom || $$.scale.x;
23213 state.event = event;
23214 zoomRect.attr(prop.axis, 0).attr(prop.attr, 0);
23215 if (start > end) {
23216 var _ref = [end, start];
23217 start = _ref[0];
23218 end = _ref[1];
23219 }
23220 if (start < 0) {
23221 end += Math.abs(start);
23222 start = 0;
23223 }
23224 if (start !== end) {
23225 $$.api.zoom([start, end].map(function (v) {
23226 _newArrowCheck(this, _this5);
23227 return scale.invert(v);
23228 }.bind(this)));
23229 }
23230 $$.setDragStatus(!1);
23231 }.bind(this));
23232 },
23233 setZoomResetButton: function setZoomResetButton() {
23234 var $$ = this,
23235 config = $$.config,
23236 $el = $$.$el,
23237 resetButton = config.zoom_resetButton;
23238 if (resetButton && config.zoom_type === "drag") {
23239 if (!$el.zoomResetBtn) {
23240 $el.zoomResetBtn = $$.$el.chart.append("div").classed($COMMON.button, !0).append("span").on("click", function () {
23241 isFunction(resetButton.onclick) && resetButton.onclick.bind($$.api)(this);
23242 $$.api.unzoom();
23243 }).classed($ZOOM.buttonZoomReset, !0).text(resetButton.text || "Reset Zoom");
23244 } else {
23245 $el.zoomResetBtn.style("display", null);
23246 }
23247 }
23248 }
23249});
23250;// CONCATENATED MODULE: ./src/config/Options/data/selection.ts
23251
23252var selection_this = undefined;
23253/**
23254 * Copyright (c) 2017 ~ present NAVER Corp.
23255 * billboard.js project is licensed under the MIT license
23256 */
23257/**
23258 * data.selection config options
23259 */
23260/* harmony default export */ var data_selection = ({
23261 /**
23262 * Set data selection enabled<br><br>
23263 * If this option is set true, we can select the data points and get/set its state of selection by API (e.g. select, unselect, selected).
23264 * - **NOTE:** for ESM imports, needs to import 'selection' exports and instantiate it by calling `selection()`.
23265 * - `enabled: selection()`
23266 * @name data․selection․enabled
23267 * @memberof Options
23268 * @type {boolean}
23269 * @default false
23270 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataSelection)
23271 * @example
23272 * data: {
23273 * selection: {
23274 * enabled: true
23275 * }
23276 * }
23277 * @example
23278 * // importing ESM
23279 * import bb, {selection} from "billboard.js";
23280 *
23281 * data: {
23282 * selection: {
23283 * enabled: selection(),
23284 * ...
23285 * }
23286 * }
23287 */
23288 data_selection_enabled: !1,
23289 /**
23290 * Set grouped selection enabled.<br><br>
23291 * If this option set true, multiple data points that have same x value will be selected by one selection.
23292 * @name data․selection․grouped
23293 * @memberof Options
23294 * @type {boolean}
23295 * @default false
23296 * @example
23297 * data: {
23298 * selection: {
23299 * grouped: true
23300 * }
23301 * }
23302 */
23303 data_selection_grouped: !1,
23304 /**
23305 * Set a callback for each data point to determine if it's selectable or not.<br><br>
23306 * The callback will receive d as an argument and it has some parameters like id, value, index. This callback should return boolean.
23307 * @name data․selection․isselectable
23308 * @memberof Options
23309 * @type {Function}
23310 * @default function() { return true; }
23311 * @example
23312 * data: {
23313 * selection: {
23314 * isselectable: function(d) { ... }
23315 * }
23316 * }
23317 */
23318 data_selection_isselectable: function data_selection_isselectable() {
23319 _newArrowCheck(this, selection_this);
23320 return !0;
23321 }.bind(undefined),
23322 /**
23323 * Set multiple data points selection enabled.<br><br>
23324 * If this option set true, multile data points can have the selected state at the same time. If false set, only one data point can have the selected state and the others will be unselected when the new data point is selected.
23325 * @name data․selection․multiple
23326 * @memberof Options
23327 * @type {boolean}
23328 * @default true
23329 * @example
23330 * data: {
23331 * selection: {
23332 * multiple: false
23333 * }
23334 * }
23335 */
23336 data_selection_multiple: !0,
23337 /**
23338 * Enable to select data points by dragging.
23339 * If this option set true, data points can be selected by dragging.
23340 * - **NOTE:** If this option set true, scrolling on the chart will be disabled because dragging event will handle the event.
23341 * @name data․selection․draggable
23342 * @memberof Options
23343 * @type {boolean}
23344 * @default false
23345 * @example
23346 * data: {
23347 * selection: {
23348 * draggable: true
23349 * }
23350 * }
23351 */
23352 data_selection_draggable: !1,
23353 /**
23354 * Set a callback for on data selection.
23355 * @name data․onselected
23356 * @memberof Options
23357 * @type {Function}
23358 * @default function() {}
23359 * @example
23360 * data: {
23361 * onselected: function(d, element) {
23362 * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
23363 * // element - <circle>
23364 * ...
23365 * }
23366 * }
23367 */
23368 data_onselected: function data_onselected() {
23369 _newArrowCheck(this, selection_this);
23370 }.bind(undefined),
23371 /**
23372 * Set a callback for on data un-selection.
23373 * @name data․onunselected
23374 * @memberof Options
23375 * @type {Function}
23376 * @default function() {}
23377 * @example
23378 * data: {
23379 * onunselected: function(d, element) {
23380 * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
23381 * // element - <circle>
23382 * ...
23383 * }
23384 * }
23385 */
23386 data_onunselected: function data_onunselected() {
23387 _newArrowCheck(this, selection_this);
23388 }.bind(undefined)
23389});
23390;// CONCATENATED MODULE: ./src/config/Options/interaction/subchart.ts
23391
23392var subchart_this = undefined;
23393/**
23394 * Copyright (c) 2017 ~ present NAVER Corp.
23395 * billboard.js project is licensed under the MIT license
23396 */
23397/**
23398 * x Axis config options
23399 */
23400/* harmony default export */ var interaction_subchart = ({
23401 /**
23402 * Set subchart options.
23403 * - **NOTE:** Not supported for `bubble`, `scatter` and non-Axis based(pie, donut, gauge, radar) types.
23404 * @name subchart
23405 * @memberof Options
23406 * @type {object}
23407 * @property {object} subchart Subchart object
23408 * @property {boolean} [subchart.show=false] Show sub chart on the bottom of the chart.
23409 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
23410 * - `show: subchart()`
23411 * @property {boolean} [subchart.showHandle=false] Show sub chart's handle.
23412 * @property {boolean} [subchart.axis.x.show=true] Show or hide x axis.
23413 * @property {boolean} [subchart.axis.x.tick.show=true] Show or hide x axis tick line.
23414 * @property {Function|string} [subchart.axis.x.tick.format] Use custom format for x axis ticks - see [axis.x.tick.format](#.axis․x․tick․format) for details.
23415 * @property {boolean} [subchart.axis.x.tick.text.show=true] Show or hide x axis tick text.
23416 * @property {Array} [subchart.init.range] Set initial selection domain range.
23417 * @property {number} [subchart.size.height] Change the height of the subchart.
23418 * @property {Function} [subchart.onbrush] Set callback for brush event.<br>
23419 * Specified function receives the current zoomed x domain.
23420 * @see [Demo](https://naver.github.io/billboard.js/demo/#Interaction.SubChart)
23421 * @example
23422 * subchart: {
23423 * show: true,
23424 * showHandle: true,
23425 * size: {
23426 * height: 20
23427 * },
23428 * init: {
23429 * // specify initial range domain selection
23430 * range: [1, 2]
23431 * },
23432 * axis: {
23433 * x: {
23434 * show: true,
23435 * tick: {
23436 * show: true,
23437 * format: (x) => d3Format(".1f")(x)
23438 * text: {
23439 * show: false
23440 * }
23441 * }
23442 * }
23443 * },
23444 * onbrush: function(domain) { ... }
23445 * }
23446 * @example
23447 * // importing ESM
23448 * import bb, {subchart} from "billboard.js";
23449 *
23450 * subchart: {
23451 * show: subchart(),
23452 * ...
23453 * }
23454 */
23455 subchart_show: !1,
23456 subchart_showHandle: !1,
23457 subchart_size_height: 60,
23458 subchart_axis_x_show: !0,
23459 subchart_axis_x_tick_show: !0,
23460 subchart_axis_x_tick_format: undefined,
23461 subchart_axis_x_tick_text_show: !0,
23462 subchart_init_range: undefined,
23463 subchart_onbrush: function subchart_onbrush() {
23464 _newArrowCheck(this, subchart_this);
23465 }.bind(undefined)
23466});
23467;// CONCATENATED MODULE: ./src/config/Options/interaction/zoom.ts
23468/**
23469 * Copyright (c) 2017 ~ present NAVER Corp.
23470 * billboard.js project is licensed under the MIT license
23471 */
23472/**
23473 * zoom config options
23474 */
23475/* harmony default export */ var interaction_zoom = ({
23476 /**
23477 * Set zoom options
23478 * @name zoom
23479 * @memberof Options
23480 * @type {object}
23481 * @property {object} zoom Zoom object
23482 * @property {boolean} [zoom.enabled=false] Enable zooming.
23483 * - **NOTE:** for ESM imports, needs to import 'zoom' exports and instantiate it by calling `zoom()`.
23484 * - `enabled: zoom()`
23485 * @property {string} [zoom.type='wheel'] Set zoom interaction type.
23486 * - **Available types:**
23487 * - wheel
23488 * - drag
23489 * @property {boolean} [zoom.rescale=false] Enable to rescale after zooming.<br>
23490 * If true set, y domain will be updated according to the zoomed region.
23491 * @property {Array} [zoom.extent=[1, 10]] Change zoom extent.
23492 * @property {number|Date} [zoom.x.min] Set x Axis minimum zoom range
23493 * @property {number|Date} [zoom.x.max] Set x Axis maximum zoom range
23494 * @property {Function} [zoom.onzoomstart=undefined] Set callback that is called when zooming starts.<br>
23495 * Specified function receives the zoom event.
23496 * @property {Function} [zoom.onzoom=undefined] Set callback that is called when the chart is zooming.<br>
23497 * Specified function receives the zoomed domain.
23498 * @property {Function} [zoom.onzoomend=undefined] Set callback that is called when zooming ends.<br>
23499 * Specified function receives the zoomed domain.
23500 * @property {boolean|object} [zoom.resetButton=true] Set to display zoom reset button for 'drag' type zoom
23501 * @property {Function} [zoom.resetButton.onclick] Set callback when clicks the reset button. The callback will receive reset button element reference as argument.
23502 * @property {string} [zoom.resetButton.text='Reset Zoom'] Text value for zoom reset button.
23503 * @see [Demo:zoom](https://naver.github.io/billboard.js/demo/#Interaction.Zoom)
23504 * @see [Demo:drag zoom](https://naver.github.io/billboard.js/demo/#Interaction.DragZoom)
23505 * @example
23506 * zoom: {
23507 * enabled: true,
23508 * type: "drag",
23509 * rescale: true,
23510 * extent: [1, 100] // enable more zooming
23511 * x: {
23512 * min: -1, // set min range
23513 * max: 10 // set max range
23514 * },
23515 * onzoomstart: function(event) { ... },
23516 * onzoom: function(domain) { ... },
23517 * onzoomend: function(domain) { ... },
23518 *
23519 * // show reset button when is zoomed-in
23520 * resetButton: true,
23521 *
23522 * resetButton: {
23523 * // onclick callback when reset button is clicked
23524 * onclick: function(button) {
23525 * button; // Reset button element reference
23526 * ...
23527 * },
23528 *
23529 * // customized text value for reset zoom button
23530 * text: "Unzoom"
23531 * }
23532 * }
23533 * @example
23534 * // importing ESM
23535 * import bb, {zoom} from "billboard.js";
23536 *
23537 * zoom: {
23538 * enabled: zoom(),
23539 * ...
23540 * }
23541 */
23542 zoom_enabled: !1,
23543 zoom_type: "wheel",
23544 zoom_extent: undefined,
23545 zoom_privileged: !1,
23546 zoom_rescale: !1,
23547 zoom_onzoom: undefined,
23548 zoom_onzoomstart: undefined,
23549 zoom_onzoomend: undefined,
23550 zoom_resetButton: !0,
23551 zoom_x_min: undefined,
23552 zoom_x_max: undefined
23553});
23554;// CONCATENATED MODULE: ./src/config/resolver/interaction.ts
23555
23556var interaction_this = undefined;
23557/**
23558 * Copyright (c) 2017 ~ present NAVER Corp.
23559 * billboard.js project is licensed under the MIT license
23560 */
23561
23562
23563
23564
23565
23566// Chart
23567
23568
23569
23570
23571// ChartInternal
23572
23573
23574
23575
23576// Axis based options
23577
23578
23579
23580
23581var _selectionModule = function selectionModule() {
23582 var _this2 = this;
23583 _newArrowCheck(this, interaction_this);
23584 extend(ChartInternal.prototype, internals_selection);
23585 extend(Chart.prototype, selection);
23586 Options.setOptions([data_selection]);
23587 return (_selectionModule = function () {
23588 _newArrowCheck(this, _this2);
23589 return !0;
23590 }.bind(this))();
23591 }.bind(undefined),
23592 subchartModule = function () {
23593 var _this3 = this;
23594 _newArrowCheck(this, interaction_this);
23595 extend(ChartInternal.prototype, interactions_subchart);
23596 extend(Chart.prototype, subchart);
23597 Options.setOptions([interaction_subchart]);
23598 return (subchartModule = function () {
23599 _newArrowCheck(this, _this3);
23600 return !0;
23601 }.bind(this))();
23602 }.bind(undefined),
23603 zoomModule = function () {
23604 var _this4 = this;
23605 _newArrowCheck(this, interaction_this);
23606 extend(ChartInternal.prototype, interactions_zoom);
23607 extend(Chart.prototype, api_zoom);
23608 Options.setOptions([interaction_zoom]);
23609 return (zoomModule = function () {
23610 _newArrowCheck(this, _this4);
23611 return !0;
23612 }.bind(this))();
23613 }.bind(undefined);
23614;// CONCATENATED MODULE: ./src/core.ts
23615/**
23616 * Copyright (c) 2017 ~ present NAVER Corp.
23617 * billboard project is licensed under the MIT license
23618 */
23619
23620
23621
23622// eslint-disable-next-line no-use-before-define
23623
23624var _defaults = {},
23625 bb = {
23626 /**
23627 * Version information
23628 * @property {string} version version
23629 * @example
23630 * bb.version; // "1.0.0"
23631 * @memberof bb
23632 */
23633 version: "3.6.3",
23634 /**
23635 * Generate chart
23636 * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
23637 * - Unused option value is given.
23638 * - ex) For `data.type="pie"` option, setting 'axis' option can cause unexpected generation error.
23639 * - Insufficient value is given for certain option used.
23640 * - ex) `data: { x: "x", columns: [["x"], ["data1", 30, 200, 100]] }`
23641 * @param {Options} config chart options
23642 * @memberof bb
23643 * @returns {Chart}
23644 * @see {@link Options} for different generation options
23645 * @see {@link Chart} for different methods API
23646 * @example
23647 * <!-- chart holder -->
23648 * <div id="LineChart"></div>
23649 * @example
23650 * // Generate chart with options
23651 * var chart = bb.generate({
23652 * "bindto": "#LineChart"
23653 * "data": {
23654 * "columns": [
23655 * ["data1", 30, 200, 100, 400, 150, 250],
23656 * ["data2", 50, 20, 10, 40, 15, 25]
23657 * ],
23658 * "type": "line"
23659 * }
23660 * });
23661 *
23662 * // call some API
23663 * // ex) get the data of 'data1'
23664 * chart.data("data1");
23665 * @example
23666 * // Generate chart by importing ESM
23667 * // Import types to be used only, where this will make smaller bundle size.
23668 * import bb, {
23669 * area,
23670 * areaLineRange,
23671 * areaSpline,
23672 * areaSplineRange,
23673 * areaStep,
23674 * bar,
23675 * bubble,
23676 * donut,
23677 * gauge,
23678 * line,
23679 * pie,
23680 * polar,
23681 * radar,
23682 * scatter,
23683 * spline,
23684 * step
23685 * }
23686 *
23687 * bb.generate({
23688 * "bindto": "#LineChart"
23689 * "data": {
23690 * "columns": [
23691 * ["data1", 30, 200, 100, 400, 150, 250],
23692 * ["data2", 50, 20, 10, 40, 15, 25]
23693 * ]
23694 * },
23695 * type: line(),
23696 *
23697 * // or
23698 * types: {
23699 * data1: bar(),
23700 * data2: step()
23701 * }
23702 * });
23703 */
23704 generate: function generate(config) {
23705 var options = mergeObj({}, _defaults, config),
23706 inst = new Chart(options);
23707 inst.internal.charts = this.instance;
23708 this.instance.push(inst);
23709 return inst;
23710 },
23711 /**
23712 * Set or get global default options.
23713 * - **NOTE:**
23714 * - The options values settings are valid within page context only.
23715 * - If is called multiple times, will override the last value.
23716 * @param {Options} options chart options
23717 * @memberof bb
23718 * @returns {Options}
23719 * @see {@link Options}
23720 * @example
23721 * // Set same option value as for `.generate()`
23722 * bb.defaults({
23723 * data: {
23724 * type: "bar"
23725 * }
23726 * });
23727 *
23728 * bb.defaults(); // {data:{type: "bar"}}
23729 *
23730 * // data.type defaults to 'bar'
23731 * var chart = bb.generate({ ... });
23732 */
23733 defaults: function defaults(options) {
23734 if (isObject(options)) {
23735 _defaults = options;
23736 }
23737 return _defaults;
23738 },
23739 /**
23740 * An array containing instance created
23741 * @property {Array} instance instance array
23742 * @example
23743 * // generate charts
23744 * var chart1 = bb.generate(...);
23745 * var chart2 = bb.generate(...);
23746 *
23747 * bb.instance; // [ chart1, chart2, ... ]
23748 * @memberof bb
23749 */
23750 instance: [],
23751 /**
23752 * Namespace for plugins
23753 * @property {object} plugin plugin namespace
23754 * @example
23755 * // Stanford diagram plugin
23756 * bb.plugin.stanford;
23757 * @memberof bb
23758 */
23759 plugin: {}
23760 };
23761/**
23762 * @namespace bb
23763 * @version 3.6.3
23764 */
23765;// CONCATENATED MODULE: ./src/index.ts
23766
23767var src_this = undefined;
23768/**
23769 * Copyright (c) 2017 ~ present NAVER Corp.
23770 * billboard project is licensed under the MIT license
23771 */
23772
23773
23774
23775// extends shape modules
23776Object.keys(resolver_shape_namespaceObject).forEach(function (v) {
23777 _newArrowCheck(this, src_this);
23778 return resolver_shape_namespaceObject[v]();
23779}.bind(undefined));
23780
23781// extends interaction modules
23782Object.keys(resolver_interaction_namespaceObject).forEach(function (v) {
23783 _newArrowCheck(this, src_this);
23784 return resolver_interaction_namespaceObject[v]();
23785}.bind(undefined));
23786
23787}();
23788/******/ return __webpack_exports__;
23789/******/ })()
23790;
23791});
\No newline at end of file