UNPKG

715 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.2.2
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 "radar": function() { return resolver_shape_radar; },
187 "scatter": function() { return shape_scatter; },
188 "spline": function() { return shape_spline; },
189 "step": function() { return step; }
190});
191
192// NAMESPACE OBJECT: ./src/config/resolver/interaction.ts
193var resolver_interaction_namespaceObject = {};
194__webpack_require__.r(resolver_interaction_namespaceObject);
195__webpack_require__.d(resolver_interaction_namespaceObject, {
196 "selection": function() { return _selectionModule; },
197 "subchart": function() { return subchartModule; },
198 "zoom": function() { return zoomModule; }
199});
200
201// EXTERNAL MODULE: external {"commonjs":"d3-time-format","commonjs2":"d3-time-format","amd":"d3-time-format","root":"d3"}
202var external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_ = __webpack_require__(4);
203// EXTERNAL MODULE: external {"commonjs":"d3-selection","commonjs2":"d3-selection","amd":"d3-selection","root":"d3"}
204var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(2);
205;// CONCATENATED MODULE: ./src/module/browser.ts
206/**
207 * Copyright (c) 2017 ~ present NAVER Corp.
208 * billboard.js project is licensed under the MIT license
209 */
210
211/**
212 * Window object
213 * @private
214 */
215
216/* eslint-disable no-new-func, no-undef */
217
218
219var win = function () {
220 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;
221 return root || Function("return this")();
222}();
223/* eslint-enable no-new-func, no-undef */
224// fallback for non-supported environments
225
226
227win.requestIdleCallback = win.requestIdleCallback || function (cb) {
228 return setTimeout(cb, 1);
229};
230
231win.cancelIdleCallback = win.cancelIdleCallback || function (id) {
232 return clearTimeout(id);
233};
234
235var browser_doc = win == null ? void 0 : win.document;
236;// CONCATENATED MODULE: ./src/config/const.ts
237/**
238 * Copyright (c) 2017 ~ present NAVER Corp.
239 * billboard.js project is licensed under the MIT license
240 */
241
242/**
243 * Chart type constant
244 * @private
245 */
246var TYPE = {
247 AREA: "area",
248 AREA_LINE_RANGE: "area-line-range",
249 AREA_SPLINE: "area-spline",
250 AREA_SPLINE_RANGE: "area-spline-range",
251 AREA_STEP: "area-step",
252 BAR: "bar",
253 BUBBLE: "bubble",
254 CANDLESTICK: "candlestick",
255 DONUT: "donut",
256 GAUGE: "gauge",
257 LINE: "line",
258 PIE: "pie",
259 RADAR: "radar",
260 SCATTER: "scatter",
261 SPLINE: "spline",
262 STEP: "step"
263};
264/**
265 * Chart type module and its method from ChartInternal class, needed to be initialized.
266 * @private
267 */
268
269var TYPE_METHOD_NEEDED = {
270 AREA: "initArea",
271 AREA_LINE_RANGE: "initArea",
272 AREA_SPLINE: "initArea",
273 AREA_SPLINE_RANGE: "initArea",
274 AREA_STEP: "initArea",
275 BAR: "initBar",
276 BUBBLE: "initCircle",
277 CANDLESTICK: "initCandlestick",
278 DONUT: "initArc",
279 GAUGE: "initArc",
280 LINE: "initLine",
281 PIE: "initArc",
282 RADAR: "initCircle",
283 SCATTER: "initCircle",
284 SPLINE: "initLine",
285 STEP: "initLine"
286};
287/**
288 * chart types by category
289 * @private
290 */
291
292var TYPE_BY_CATEGORY = {
293 Area: [TYPE.AREA, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE, TYPE.AREA_STEP],
294 AreaRange: [TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE],
295 Arc: [TYPE.PIE, TYPE.DONUT, TYPE.GAUGE, TYPE.RADAR],
296 Line: [TYPE.LINE, TYPE.SPLINE, TYPE.AREA, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE, TYPE.STEP, TYPE.AREA_STEP],
297 Step: [TYPE.STEP, TYPE.AREA_STEP],
298 Spline: [TYPE.SPLINE, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE]
299};
300;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
301function _defineProperty(obj, key, value) {
302 if (key in obj) {
303 Object.defineProperty(obj, key, {
304 value: value,
305 enumerable: true,
306 configurable: true,
307 writable: true
308 });
309 } else {
310 obj[key] = value;
311 }
312
313 return obj;
314}
315// EXTERNAL MODULE: external {"commonjs":"d3-brush","commonjs2":"d3-brush","amd":"d3-brush","root":"d3"}
316var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(3);
317;// CONCATENATED MODULE: ./src/config/classes.ts
318/**
319 * Copyright (c) 2017 ~ present NAVER Corp.
320 * billboard.js project is licensed under the MIT license
321 */
322
323/**
324 * CSS class names definition
325 * @private
326 */
327/* harmony default export */ var config_classes = ({
328 arc: "bb-arc",
329 arcLabelLine: "bb-arc-label-line",
330 arcs: "bb-arcs",
331 area: "bb-area",
332 areas: "bb-areas",
333 axis: "bb-axis",
334 axisX: "bb-axis-x",
335 axisXLabel: "bb-axis-x-label",
336 axisY: "bb-axis-y",
337 axisY2: "bb-axis-y2",
338 axisY2Label: "bb-axis-y2-label",
339 axisYLabel: "bb-axis-y-label",
340 bar: "bb-bar",
341 bars: "bb-bars",
342 brush: "bb-brush",
343 button: "bb-button",
344 buttonZoomReset: "bb-zoom-reset",
345 candlestick: "bb-candlestick",
346 candlesticks: "bb-candlesticks",
347 chart: "bb-chart",
348 chartArc: "bb-chart-arc",
349 chartArcs: "bb-chart-arcs",
350 chartArcsBackground: "bb-chart-arcs-background",
351 chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
352 chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
353 chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
354 chartArcsTitle: "bb-chart-arcs-title",
355 chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
356 chartBar: "bb-chart-bar",
357 chartBars: "bb-chart-bars",
358 chartCandlestick: "bb-chart-candlestick",
359 chartCandlesticks: "bb-chart-candlesticks",
360 chartCircles: "bb-chart-circles",
361 chartLine: "bb-chart-line",
362 chartLines: "bb-chart-lines",
363 chartRadar: "bb-chart-radar",
364 chartRadars: "bb-chart-radars",
365 chartText: "bb-chart-text",
366 chartTexts: "bb-chart-texts",
367 circle: "bb-circle",
368 circles: "bb-circles",
369 colorPattern: "bb-color-pattern",
370 colorScale: "bb-colorscale",
371 defocused: "bb-defocused",
372 dragarea: "bb-dragarea",
373 empty: "bb-empty",
374 eventRect: "bb-event-rect",
375 eventRects: "bb-event-rects",
376 eventRectsMultiple: "bb-event-rects-multiple",
377 eventRectsSingle: "bb-event-rects-single",
378 focused: "bb-focused",
379 gaugeValue: "bb-gauge-value",
380 grid: "bb-grid",
381 gridLines: "bb-grid-lines",
382 legend: "bb-legend",
383 legendBackground: "bb-legend-background",
384 legendItem: "bb-legend-item",
385 legendItemEvent: "bb-legend-item-event",
386 legendItemFocused: "bb-legend-item-focused",
387 legendItemHidden: "bb-legend-item-hidden",
388 legendItemPoint: "bb-legend-item-point",
389 legendItemTile: "bb-legend-item-tile",
390 level: "bb-level",
391 levels: "bb-levels",
392 line: "bb-line",
393 lines: "bb-lines",
394 main: "bb-main",
395 region: "bb-region",
396 regions: "bb-regions",
397 selectedCircle: "bb-selected-circle",
398 selectedCircles: "bb-selected-circles",
399 shape: "bb-shape",
400 shapes: "bb-shapes",
401 stanfordElements: "bb-stanford-elements",
402 stanfordLine: "bb-stanford-line",
403 stanfordLines: "bb-stanford-lines",
404 stanfordRegion: "bb-stanford-region",
405 stanfordRegions: "bb-stanford-regions",
406 subchart: "bb-subchart",
407 target: "bb-target",
408 text: "bb-text",
409 texts: "bb-texts",
410 title: "bb-title",
411 tooltip: "bb-tooltip",
412 tooltipContainer: "bb-tooltip-container",
413 tooltipName: "bb-tooltip-name",
414 valueDown: "bb-value-down",
415 valueUp: "bb-value-up",
416 xgrid: "bb-xgrid",
417 xgridFocus: "bb-xgrid-focus",
418 xgridLine: "bb-xgrid-line",
419 xgridLines: "bb-xgrid-lines",
420 xgrids: "bb-xgrids",
421 ygrid: "bb-ygrid",
422 ygridFocus: "bb-ygrid-focus",
423 ygridLine: "bb-ygrid-line",
424 ygridLines: "bb-ygrid-lines",
425 ygrids: "bb-ygrids",
426 zoomBrush: "bb-zoom-brush",
427 EXPANDED: "_expanded_",
428 SELECTED: "_selected_",
429 INCLUDED: "_included_",
430 TextOverlapping: "text-overlapping"
431});
432;// CONCATENATED MODULE: ./src/module/util.ts
433
434
435function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
436
437function _objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
438
439/**
440 * Copyright (c) 2017 ~ present NAVER Corp.
441 * billboard.js project is licensed under the MIT license
442 * @ignore
443 */
444
445
446
447
448
449
450var isValue = function (v) {
451 return v || v === 0;
452},
453 isFunction = function (v) {
454 return typeof v === "function";
455},
456 isString = function (v) {
457 return typeof v === "string";
458},
459 isNumber = function (v) {
460 return typeof v === "number";
461},
462 isUndefined = function (v) {
463 return typeof v === "undefined";
464},
465 isDefined = function (v) {
466 return typeof v !== "undefined";
467},
468 isboolean = function (v) {
469 return typeof v === "boolean";
470},
471 ceil10 = function (v) {
472 return Math.ceil(v / 10) * 10;
473},
474 asHalfPixel = function (n) {
475 return Math.ceil(n) + .5;
476},
477 diffDomain = function (d) {
478 return d[1] - d[0];
479},
480 isObjectType = function (v) {
481 return typeof v === "object";
482},
483 isEmpty = function (o) {
484 return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
485},
486 notEmpty = function (o) {
487 return !isEmpty(o);
488},
489 isArray = function (arr) {
490 return Array.isArray(arr);
491},
492 isObject = function (obj) {
493 return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
494};
495
496/**
497 * Get specified key value from object
498 * If default value is given, will return if given key value not found
499 * @param {object} options Source object
500 * @param {string} key Key value
501 * @param {*} defaultValue Default value
502 * @returns {*}
503 * @private
504 */
505function getOption(options, key, defaultValue) {
506 return isDefined(options[key]) ? options[key] : defaultValue;
507}
508/**
509 * Check if value exist in the given object
510 * @param {object} dict Target object to be checked
511 * @param {*} value Value to be checked
512 * @returns {boolean}
513 * @private
514 */
515
516
517function hasValue(dict, value) {
518 var found = !1;
519 Object.keys(dict).forEach(function (key) {
520 return dict[key] === value && (found = !0);
521 });
522 return found;
523}
524/**
525 * Call function with arguments
526 * @param {Function} fn Function to be called
527 * @param {*} args Arguments
528 * @returns {boolean} true: fn is function, false: fn is not function
529 * @private
530 */
531
532
533function callFn(fn) {
534 for (var isFn = isFunction(fn), _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
535 args[_key - 1] = arguments[_key];
536 }
537
538 isFn && fn.call.apply(fn, args);
539 return isFn;
540}
541/**
542 * Call function after all transitions ends
543 * @param {d3.transition} transition Transition
544 * @param {Fucntion} cb Callback function
545 * @private
546 */
547
548
549function endall(transition, cb) {
550 var n = 0,
551 end = function () {
552 for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
553 args[_key2] = arguments[_key2];
554 }
555
556 --n || cb.apply.apply(cb, [this].concat(args));
557 };
558
559 // if is transition selection
560 if ("duration" in transition) {
561 transition.each(function () {
562 return ++n;
563 }).on("end", end);
564 } else {
565 ++n;
566 transition.call(end);
567 }
568}
569/**
570 * Replace tag sign to html entity
571 * @param {string} str Target string value
572 * @returns {string}
573 * @private
574 */
575
576
577function sanitise(str) {
578 return isString(str) ? str.replace(/</g, "&lt;").replace(/>/g, "&gt;") : str;
579}
580/**
581 * Set text value. If there's multiline add nodes.
582 * @param {d3Selection} node Text node
583 * @param {string} text Text value string
584 * @param {Array} dy dy value for multilined text
585 * @param {boolean} toMiddle To be alingned vertically middle
586 * @private
587 */
588
589
590function setTextValue(node, text, dy, toMiddle) {
591 if (dy === void 0) {
592 dy = [-1, 1];
593 }
594
595 if (toMiddle === void 0) {
596 toMiddle = !1;
597 }
598
599 if (!node || !isString(text)) {
600 return;
601 }
602
603 if (text.indexOf("\n") === -1) {
604 node.text(text);
605 } else {
606 var diff = [node.text(), text].map(function (v) {
607 return v.replace(/[\s\n]/g, "");
608 });
609
610 if (diff[0] !== diff[1]) {
611 var multiline = text.split("\n"),
612 len = toMiddle ? multiline.length - 1 : 1;
613 // reset possible text
614 node.html("");
615 multiline.forEach(function (v, i) {
616 node.append("tspan").attr("x", 0).attr("dy", (i === 0 ? dy[0] * len : dy[1]) + "em").text(v);
617 });
618 }
619 }
620}
621/**
622 * Substitution of SVGPathSeg API polyfill
623 * @param {SVGGraphicsElement} path Target svg element
624 * @returns {Array}
625 * @private
626 */
627
628
629function getRectSegList(path) {
630 /*
631 * seg1 ---------- seg2
632 * | |
633 * | |
634 * | |
635 * seg0 ---------- seg3
636 * */
637 var _path$getBBox = path.getBBox(),
638 x = _path$getBBox.x,
639 y = _path$getBBox.y,
640 width = _path$getBBox.width,
641 height = _path$getBBox.height;
642
643 return [{
644 x: x,
645 y: y + height
646 }, // seg0
647 {
648 x: x,
649 y: y
650 }, // seg1
651 {
652 x: x + width,
653 y: y
654 }, // seg2
655 {
656 x: x + width,
657 y: y + height
658 } // seg3
659 ];
660}
661/**
662 * Get svg bounding path box dimension
663 * @param {SVGGraphicsElement} path Target svg element
664 * @returns {object}
665 * @private
666 */
667
668
669function getPathBox(path) {
670 var _path$getBoundingClie = path.getBoundingClientRect(),
671 width = _path$getBoundingClie.width,
672 height = _path$getBoundingClie.height,
673 items = getRectSegList(path),
674 x = items[0].x,
675 y = Math.min(items[0].y, items[1].y);
676
677 return {
678 x: x,
679 y: y,
680 width: width,
681 height: height
682 };
683}
684/**
685 * Get event's current position coordinates
686 * @param {object} event Event object
687 * @param {SVGElement|HTMLElement} element Target element
688 * @returns {Array} [x, y] Coordinates x, y array
689 * @private
690 */
691
692
693function getPointer(event, element) {
694 var _ref,
695 touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]),
696 pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element);
697
698 return pointer.map(function (v) {
699 return isNaN(v) ? 0 : v;
700 });
701}
702/**
703 * Return brush selection array
704 * @param {object} ctx Current instance
705 * @returns {d3.brushSelection}
706 * @private
707 */
708
709
710function getBrushSelection(ctx) {
711 var event = ctx.event,
712 $el = ctx.$el,
713 main = $el.subchart.main || $el.main,
714 selection;
715
716 // check from event
717 if (event && event.type === "brush") {
718 selection = event.selection; // check from brush area selection
719 } else if (main && (selection = main.select("." + config_classes.brush).node())) {
720 selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection);
721 }
722
723 return selection;
724}
725/**
726 * Get boundingClientRect.
727 * Cache the evaluated value once it was called.
728 * @param {HTMLElement} node Target element
729 * @returns {object}
730 * @private
731 */
732
733
734function getBoundingRect(node) {
735 var needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
736 return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
737}
738/**
739 * Retrun random number
740 * @param {boolean} asStr Convert returned value as string
741 * @returns {number|string}
742 * @private
743 */
744
745
746function getRandom(asStr) {
747 if (asStr === void 0) {
748 asStr = !0;
749 }
750
751 var rand = Math.random();
752 return asStr ? rand + "" : rand;
753}
754/**
755 * Find index based on binary search
756 * @param {Array} arr Data array
757 * @param {number} v Target number to find
758 * @param {number} start Start index of data array
759 * @param {number} end End index of data arr
760 * @param {boolean} isRotated Weather is roted axis
761 * @returns {number} Index number
762 * @private
763 */
764
765
766function findIndex(arr, v, start, end, isRotated) {
767 if (start > end) {
768 return -1;
769 }
770
771 var mid = Math.floor((start + end) / 2),
772 _arr$mid = arr[mid],
773 x = _arr$mid.x,
774 _arr$mid$w = _arr$mid.w,
775 w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
776
777 if (isRotated) {
778 x = arr[mid].y;
779 w = arr[mid].h;
780 }
781
782 if (v >= x && v <= x + w) {
783 return mid;
784 }
785
786 return v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
787}
788/**
789 * Check if brush is empty
790 * @param {object} ctx Bursh context
791 * @returns {boolean}
792 * @private
793 */
794
795
796function brushEmpty(ctx) {
797 var selection = getBrushSelection(ctx);
798
799 if (selection) {
800 // brush selected area
801 // two-dimensional: [[x0, y0], [x1, y1]]
802 // one-dimensional: [x0, x1] or [y0, y1]
803 return selection[0] === selection[1];
804 }
805
806 return !0;
807}
808/**
809 * Deep copy object
810 * @param {object} objectN Source object
811 * @returns {object} Cloned object
812 * @private
813 */
814
815
816function deepClone() {
817 for (var clone = function (v) {
818 if (isObject(v) && v.constructor) {
819 var r = new v.constructor();
820
821 for (var k in v) {
822 r[k] = clone(v[k]);
823 }
824
825 return r;
826 }
827
828 return v;
829 }, _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
830 objectN[_key3] = arguments[_key3];
831 }
832
833 return objectN.map(function (v) {
834 return clone(v);
835 }).reduce(function (a, c) {
836 return _objectSpread(_objectSpread({}, a), c);
837 });
838}
839/**
840 * Extend target from source object
841 * @param {object} target Target object
842 * @param {object|Array} source Source object
843 * @returns {object}
844 * @private
845 */
846
847
848function extend(target, source) {
849 if (target === void 0) {
850 target = {};
851 }
852
853 if (isArray(source)) {
854 source.forEach(function (v) {
855 return extend(target, v);
856 });
857 } // exclude name with only numbers
858
859
860 for (var p in source) {
861 if (/^\d+$/.test(p) || p in target) {
862 continue;
863 }
864
865 target[p] = source[p];
866 }
867
868 return target;
869}
870/**
871 * Return first letter capitalized
872 * @param {string} str Target string
873 * @returns {string} capitalized string
874 * @private
875 */
876
877
878var capitalize = function (str) {
879 return str.charAt(0).toUpperCase() + str.slice(1);
880};
881/**
882 * Camelize from kebob style string
883 * @param {string} str Target string
884 * @param {string} separator Separator string
885 * @returns {string} camelized string
886 * @private
887 */
888
889
890function camelize(str, separator) {
891 if (separator === void 0) {
892 separator = "-";
893 }
894
895 return str.split(separator).map(function (v, i) {
896 return i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase();
897 }).join("");
898}
899/**
900 * Convert to array
901 * @param {object} v Target to be converted
902 * @returns {Array}
903 * @private
904 */
905
906
907var toArray = function (v) {
908 return [].slice.call(v);
909};
910/**
911 * Get css rules for specified stylesheets
912 * @param {Array} styleSheets The stylesheets to get the rules from
913 * @returns {Array}
914 * @private
915 */
916
917
918function getCssRules(styleSheets) {
919 var rules = [];
920 styleSheets.forEach(function (sheet) {
921 try {
922 if (sheet.cssRules && sheet.cssRules.length) {
923 rules = rules.concat(toArray(sheet.cssRules));
924 }
925 } catch (e) {
926 console.error("Error while reading rules from " + sheet.href + ": " + e.toString());
927 }
928 });
929 return rules;
930}
931/**
932 * Gets the SVGMatrix of an SVGGElement
933 * @param {SVGElement} node Node element
934 * @returns {SVGMatrix} matrix
935 * @private
936 */
937
938
939function getTranslation(node) {
940 var transform = node ? node.transform : null,
941 baseVal = transform && transform.baseVal;
942 return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
943 a: 0,
944 b: 0,
945 c: 0,
946 d: 0,
947 e: 0,
948 f: 0
949 };
950}
951/**
952 * Get unique value from array
953 * @param {Array} data Source data
954 * @returns {Array} Unique array value
955 * @private
956 */
957
958
959function getUnique(data) {
960 var isDate = data[0] instanceof Date,
961 d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
962 return self.indexOf(v) === i;
963 });
964 return isDate ? d.map(function (v) {
965 return new Date(v);
966 }) : d;
967}
968/**
969 * Merge array
970 * @param {Array} arr Source array
971 * @returns {Array}
972 * @private
973 */
974
975
976function mergeArray(arr) {
977 return arr && arr.length ? arr.reduce(function (p, c) {
978 return p.concat(c);
979 }) : [];
980}
981/**
982 * Merge object returning new object
983 * @param {object} target Target object
984 * @param {object} objectN Source object
985 * @returns {object} merged target object
986 * @private
987 */
988
989
990function mergeObj(target) {
991 for (var _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
992 objectN[_key4 - 1] = arguments[_key4];
993 }
994
995 if (!objectN.length || objectN.length === 1 && !objectN[0]) {
996 return target;
997 }
998
999 var source = objectN.shift();
1000
1001 if (isObject(target) && isObject(source)) {
1002 Object.keys(source).forEach(function (key) {
1003 var value = source[key];
1004
1005 if (isObject(value)) {
1006 target[key] || (target[key] = {});
1007 target[key] = mergeObj(target[key], value);
1008 } else {
1009 target[key] = isArray(value) ? value.concat() : value;
1010 }
1011 });
1012 }
1013
1014 return mergeObj.apply(void 0, [target].concat(objectN));
1015}
1016/**
1017 * Sort value
1018 * @param {Array} data value to be sorted
1019 * @param {boolean} isAsc true: asc, false: desc
1020 * @returns {number|string|Date} sorted date
1021 * @private
1022 */
1023
1024
1025function sortValue(data, isAsc) {
1026 if (isAsc === void 0) {
1027 isAsc = !0;
1028 }
1029
1030 var fn;
1031
1032 if (data[0] instanceof Date) {
1033 fn = isAsc ? function (a, b) {
1034 return a - b;
1035 } : function (a, b) {
1036 return b - a;
1037 };
1038 } else {
1039 if (isAsc && !data.every(isNaN)) {
1040 fn = function (a, b) {
1041 return a - b;
1042 };
1043 } else if (!isAsc) {
1044 fn = function (a, b) {
1045 return a > b && -1 || a < b && 1 || a === b && 0;
1046 };
1047 }
1048 }
1049
1050 return data.concat().sort(fn);
1051}
1052/**
1053 * Get min/max value
1054 * @param {string} type 'min' or 'max'
1055 * @param {Array} data Array data value
1056 * @returns {number|Date|undefined}
1057 * @private
1058 */
1059
1060
1061function getMinMax(type, data) {
1062 var res = data.filter(function (v) {
1063 return notEmpty(v);
1064 });
1065
1066 if (res.length) {
1067 if (isNumber(res[0])) {
1068 res = Math[type].apply(Math, res);
1069 } else if (res[0] instanceof Date) {
1070 res = sortValue(res, type === "min")[0];
1071 }
1072 } else {
1073 res = undefined;
1074 }
1075
1076 return res;
1077}
1078/**
1079 * Get range
1080 * @param {number} start Start number
1081 * @param {number} end End number
1082 * @param {number} step Step number
1083 * @returns {Array}
1084 * @private
1085 */
1086
1087
1088var getRange = function (start, end, step) {
1089 if (step === void 0) {
1090 step = 1;
1091 }
1092
1093 var res = [],
1094 n = Math.max(0, Math.ceil((end - start) / step)) | 0;
1095
1096 for (var i = start; i < n; i++) {
1097 res.push(start + i * step);
1098 }
1099
1100 return res;
1101},
1102 emulateEvent = {
1103 mouse: function () {
1104 var getParams = function () {
1105 return {
1106 bubbles: !1,
1107 cancelable: !1,
1108 screenX: 0,
1109 screenY: 0,
1110 clientX: 0,
1111 clientY: 0
1112 };
1113 };
1114
1115 try {
1116 // eslint-disable-next-line no-new
1117 new MouseEvent("t");
1118 return function (el, eventType, params) {
1119 if (params === void 0) {
1120 params = getParams();
1121 }
1122
1123 el.dispatchEvent(new MouseEvent(eventType, params));
1124 };
1125 } catch (e) {
1126 // Polyfills DOM4 MouseEvent
1127 return function (el, eventType, params) {
1128 if (params === void 0) {
1129 params = getParams();
1130 }
1131
1132 var mouseEvent = browser_doc.createEvent("MouseEvent"); // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
1133
1134 mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0, // the event's mouse click count
1135 params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null);
1136 el.dispatchEvent(mouseEvent);
1137 };
1138 }
1139 }(),
1140 touch: function touch(el, eventType, params) {
1141 var touchObj = new Touch(mergeObj({
1142 identifier: Date.now(),
1143 target: el,
1144 radiusX: 2.5,
1145 radiusY: 2.5,
1146 rotationAngle: 10,
1147 force: .5
1148 }, params));
1149 el.dispatchEvent(new TouchEvent(eventType, {
1150 cancelable: !0,
1151 bubbles: !0,
1152 shiftKey: !0,
1153 touches: [touchObj],
1154 targetTouches: [],
1155 changedTouches: [touchObj]
1156 }));
1157 }
1158}; // emulate event
1159
1160
1161/**
1162 * Process the template & return bound string
1163 * @param {string} tpl Template string
1164 * @param {object} data Data value to be replaced
1165 * @returns {string}
1166 * @private
1167 */
1168function tplProcess(tpl, data) {
1169 var res = tpl;
1170
1171 for (var x in data) {
1172 res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
1173 }
1174
1175 return res;
1176}
1177/**
1178 * Get parsed date value
1179 * (It must be called in 'ChartInternal' context)
1180 * @param {Date|string|number} date Value of date to be parsed
1181 * @returns {Date}
1182 * @private
1183 */
1184
1185
1186function parseDate(date) {
1187 var parsedDate;
1188
1189 if (date instanceof Date) {
1190 parsedDate = date;
1191 } else if (isString(date)) {
1192 var config = this.config,
1193 format = this.format;
1194 parsedDate = format.dataTime(config.data_xFormat)(date);
1195 } else if (isNumber(date) && !isNaN(date)) {
1196 parsedDate = new Date(+date);
1197 }
1198
1199 if (!parsedDate || isNaN(+parsedDate)) {
1200 console && console.error && console.error("Failed to parse x '" + date + "' to Date object");
1201 }
1202
1203 return parsedDate;
1204}
1205/**
1206 * Return if the current doc is visible or not
1207 * @returns {boolean}
1208 * @private
1209 */
1210
1211
1212function isTabVisible() {
1213 return !browser_doc.hidden;
1214}
1215/**
1216 * Get the current input type
1217 * @param {boolean} mouse Config value: interaction.inputType.mouse
1218 * @param {boolean} touch Config value: interaction.inputType.touch
1219 * @returns {string} "mouse" | "touch" | null
1220 * @private
1221 */
1222
1223
1224function convertInputType(mouse, touch) {
1225 var isMobile = !1; // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#Mobile_Tablet_or_Desktop
1226
1227 if (/Mobi/.test(win.navigator.userAgent) && touch) {
1228 // Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
1229 var hasTouchPoints = win.navigator && "maxTouchPoints" in win.navigator && win.navigator.maxTouchPoints > 0,
1230 hasTouch = "ontouchmove" in win || win.DocumentTouch && browser_doc instanceof win.DocumentTouch; // Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
1231 // On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
1232
1233 isMobile = hasTouchPoints || hasTouch;
1234 }
1235
1236 var hasMouse = mouse && !isMobile ? "onmouseover" in win : !1;
1237 return hasMouse && "mouse" || isMobile && "touch" || null;
1238}
1239;// CONCATENATED MODULE: ./src/module/error.ts
1240
1241
1242
1243/**
1244 * Copyright (c) 2021 ~ present NAVER Corp.
1245 * billboard.js project is licensed under the MIT license
1246 */
1247
1248/* eslint no-console: "off" */
1249
1250
1251/**
1252 * Check chart type module imports.
1253 * @param {ChartInternal} ctx Context
1254 * @private
1255 */
1256
1257function checkModuleImport(ctx) {
1258 var $$ = ctx,
1259 config = $$.config,
1260 type = "";
1261
1262 if (isEmpty(config.data_type || config.data_types) && !$$[TYPE_METHOD_NEEDED.LINE]) {
1263 type = "line";
1264 } else {
1265 for (var x in TYPE_METHOD_NEEDED) {
1266 var t = TYPE[x];
1267
1268 if ($$.hasType(t) && !$$[TYPE_METHOD_NEEDED[x]]) {
1269 type = t;
1270 break;
1271 }
1272 }
1273 }
1274
1275 type && logError("Please, make sure if %c" + camelize(type), "module has been imported and specified correctly.");
1276}
1277/**
1278 * Log error and throw error
1279 * @param {string} head Message header
1280 * @param {string} tail Message tail
1281 * @private
1282 */
1283
1284
1285function logError(head, tail) {
1286 var _window$console,
1287 prefix = "[billboard.js]",
1288 hasConsole = (_window$console = win.console) == null ? void 0 : _window$console.error;
1289
1290 if (hasConsole) {
1291 console.error("\u274C " + prefix + " " + head, "background:red;color:white;display:block;font-size:15px", tail);
1292 console.info("%cℹ️", "font-size:15px", "https://github.com/naver/billboard.js/wiki/CHANGELOG-v2#modularization-by-its-functionality");
1293 }
1294
1295 throw Error(prefix + " " + head.replace(/\%c([a-z-]+)/i, "'$1' ") + " " + tail);
1296}
1297;// CONCATENATED MODULE: ./src/config/Store/Element.ts
1298/**
1299 * Copyright (c) 2017 ~ present NAVER Corp.
1300 * billboard.js project is licensed under the MIT license
1301 */
1302
1303/**
1304 * Elements class.
1305 * @class Elements
1306 * @ignore
1307 * @private
1308 */
1309var Element = function () {
1310 return {
1311 chart: null,
1312 main: null,
1313 svg: null,
1314 axis: {
1315 // axes
1316 x: null,
1317 y: null,
1318 y2: null,
1319 subX: null
1320 },
1321 defs: null,
1322 tooltip: null,
1323 legend: null,
1324 title: null,
1325 subchart: {
1326 main: null,
1327 // $$.context
1328 bar: null,
1329 // $$.contextBar
1330 line: null,
1331 // $$.contextLine
1332 area: null // $$.contextArea
1333
1334 },
1335 arcs: null,
1336 bar: null,
1337 // mainBar,
1338 candlestick: null,
1339 line: null,
1340 // mainLine,
1341 area: null,
1342 // mainArea,
1343 circle: null,
1344 // mainCircle,
1345 radar: null,
1346 text: null,
1347 // mainText,
1348 grid: {
1349 main: null,
1350 // grid (also focus)
1351 x: null,
1352 // xgrid,
1353 y: null // ygrid,
1354
1355 },
1356 gridLines: {
1357 main: null,
1358 // gridLines
1359 x: null,
1360 // xgridLines,
1361 y: null // ygridLines
1362
1363 },
1364 region: {
1365 main: null,
1366 // region
1367 list: null // mainRegion
1368
1369 },
1370 eventRect: null,
1371 zoomResetBtn: null // drag zoom reset button
1372
1373 };
1374};
1375
1376
1377;// CONCATENATED MODULE: ./src/config/Store/State.ts
1378/**
1379 * Copyright (c) 2017 ~ present NAVER Corp.
1380 * billboard.js project is licensed under the MIT license
1381 */
1382
1383/**
1384 * State class.
1385 * @class State
1386 * @ignore
1387 * @private
1388 */
1389var State = function () {
1390 return {
1391 // chart drawn area dimension, excluding axes
1392 width: 0,
1393 width2: 0,
1394 height: 0,
1395 height2: 0,
1396 margin: {
1397 top: 0,
1398 bottom: 0,
1399 left: 0,
1400 right: 0
1401 },
1402 margin2: {
1403 top: 0,
1404 bottom: 0,
1405 left: 0,
1406 right: 0
1407 },
1408 margin3: {
1409 top: 0,
1410 bottom: 0,
1411 left: 0,
1412 right: 0
1413 },
1414 arcWidth: 0,
1415 arcHeight: 0,
1416 xAxisHeight: 0,
1417 hasAxis: !1,
1418 hasRadar: !1,
1419 current: {
1420 // chart whole dimension
1421 width: 0,
1422 height: 0,
1423 dataMax: 0,
1424 maxTickWidths: {
1425 x: {
1426 size: 0,
1427 ticks: [],
1428 clipPath: 0,
1429 domain: ""
1430 },
1431 y: {
1432 size: 0,
1433 domain: ""
1434 },
1435 y2: {
1436 size: 0,
1437 domain: ""
1438 }
1439 },
1440 // current used chart type list
1441 types: []
1442 },
1443 // legend
1444 isLegendRight: !1,
1445 isLegendInset: !1,
1446 isLegendTop: !1,
1447 isLegendLeft: !1,
1448 legendStep: 0,
1449 legendItemWidth: 0,
1450 legendItemHeight: 0,
1451 legendHasRendered: !1,
1452 eventReceiver: {
1453 currentIdx: -1,
1454 // current event interaction index
1455 rect: {},
1456 // event rect's clientBoundingRect
1457 data: [],
1458 // event data bound of previoous eventRect
1459 coords: [] // coordination value of previous eventRect
1460
1461 },
1462 axis: {
1463 x: {
1464 padding: {
1465 left: 0,
1466 right: 0
1467 },
1468 tickCount: 0
1469 }
1470 },
1471 rotatedPadding: {
1472 left: 30,
1473 right: 0,
1474 top: 5
1475 },
1476 withoutFadeIn: {},
1477 inputType: "",
1478 datetimeId: "",
1479 // clip id string
1480 clip: {
1481 id: "",
1482 idXAxis: "",
1483 idYAxis: "",
1484 idXAxisTickTexts: "",
1485 idGrid: "",
1486 idSubchart: "",
1487 // clipIdForSubchart
1488 path: "",
1489 pathXAxis: "",
1490 pathYAxis: "",
1491 pathXAxisTickTexts: "",
1492 pathGrid: ""
1493 },
1494 // status
1495 event: null,
1496 // event object
1497 dragStart: null,
1498 dragging: !1,
1499 flowing: !1,
1500 cancelClick: !1,
1501 mouseover: !1,
1502 rendered: !1,
1503 transiting: !1,
1504 redrawing: !1,
1505 // if redraw() is on process
1506 resizing: !1,
1507 // resize event called
1508 toggling: !1,
1509 // legend toggle
1510 zooming: !1,
1511 hasNegativeValue: !1,
1512 hasPositiveValue: !0,
1513 orgAreaOpacity: "0.2",
1514 // ID strings
1515 hiddenTargetIds: [],
1516 hiddenLegendIds: [],
1517 focusedTargetIds: [],
1518 defocusedTargetIds: [],
1519 // value for Arc
1520 radius: 0,
1521 innerRadius: 0,
1522 outerRadius: undefined,
1523 innerRadiusRatio: 0,
1524 gaugeArcWidth: 0,
1525 radiusExpanded: 0,
1526 // xgrid attribute
1527 xgridAttr: {
1528 x1: null,
1529 x2: null,
1530 y1: null,
1531 y2: null
1532 }
1533 };
1534};
1535
1536
1537;// CONCATENATED MODULE: ./src/config/Store/Store.ts
1538/**
1539 * Copyright (c) 2017 ~ present NAVER Corp.
1540 * billboard.js project is licensed under the MIT license
1541 */
1542
1543 // mapping
1544
1545var classes = {
1546 element: Element,
1547 state: State
1548};
1549/**
1550 * Internal store class.
1551 * @class Store
1552 * @ignore
1553 * @private
1554 */
1555
1556var Store = /*#__PURE__*/function () {
1557 function Store() {
1558 var _this = this;
1559
1560 Object.keys(classes).forEach(function (v) {
1561 _this[v] = new classes[v]();
1562 });
1563 }
1564
1565 var _proto = Store.prototype;
1566
1567 _proto.getStore = function getStore(name) {
1568 return this[name];
1569 };
1570
1571 return Store;
1572}();
1573
1574
1575;// CONCATENATED MODULE: ./src/config/Options/common/main.ts
1576/**
1577 * Copyright (c) 2017 ~ present NAVER Corp.
1578 * billboard.js project is licensed under the MIT license
1579 */
1580
1581/**
1582 * main config options
1583 */
1584/* harmony default export */ var main = ({
1585 /**
1586 * Specify the CSS selector or the element which the chart will be set to. D3 selection object can be specified also.<br>
1587 * If other chart is set already, it will be replaced with the new one (only one chart can be set in one element).
1588 * - **NOTE:** In case of element doesn't exist or not specified, will add a `<div>` element to the body.
1589 * @name bindto
1590 * @memberof Options
1591 * @property {string|HTMLElement|d3.selection|object} [bindto="#chart"] Specify the element where chart will be drawn.
1592 * @property {string|HTMLElement|d3.selection} bindto.element="#chart" Specify the element where chart will be drawn.
1593 * @property {string} [bindto.classname=bb] Specify the class name of bind element.<br>
1594 * **NOTE:** When class name isn't `bb`, then you also need to update the default CSS to be rendered correctly.
1595 * @default #chart
1596 * @example
1597 * bindto: "#myContainer"
1598 *
1599 * // or HTMLElement
1600 * bindto: document.getElementById("myContainer")
1601 *
1602 * // or D3 selection object
1603 * bindto: d3.select("#myContainer")
1604 *
1605 * // or to change default classname
1606 * bindto: {
1607 * element: "#chart",
1608 * classname: "bill-board" // ex) <div id='chart' class='bill-board'>
1609 * }
1610 */
1611 bindto: "#chart",
1612
1613 /**
1614 * Set chart background.
1615 * @name background
1616 * @memberof Options
1617 * @property {object} background background object
1618 * @property {string} background.class Specify the class name for background element.
1619 * @property {string} background.color Specify the fill color for background element.<br>**NOTE:** Will be ignored if `imgUrl` option is set.
1620 * @property {string} background.imgUrl Specify the image url string for background.
1621 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.Background)
1622 * @example
1623 * background: {
1624 * class: "myClass",
1625 * color: "red",
1626 *
1627 * // Set image url for background.
1628 * // If specified, 'color' option will be ignored.
1629 * imgUrl: "https://naver.github.io/billboard.js/img/logo/billboard.js.svg",
1630 * }
1631 */
1632 background: {},
1633
1634 /**
1635 * Set 'clip-path' attribute for chart element
1636 * - **NOTE:**
1637 * > When is false, chart node element is positioned after the axis node in DOM tree hierarchy.
1638 * > Is to make chart element positioned over axis element.
1639 * @name clipPath
1640 * @memberof Options
1641 * @type {boolean}
1642 * @default true
1643 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.clipPath)
1644 * @example
1645 * // don't set 'clip-path' attribute
1646 * clipPath: false
1647 */
1648 clipPath: !0,
1649
1650 /**
1651 * Set svg element's class name
1652 * @name svg
1653 * @memberof Options
1654 * @type {object}
1655 * @property {object} [svg] svg object
1656 * @property {string} [svg.classname] class name for svg element
1657 * @example
1658 * svg: {
1659 * classname: "test_class"
1660 * }
1661 */
1662 svg_classname: undefined,
1663
1664 /**
1665 * The desired size of the chart element.
1666 * If value is not specified, the width of the chart will be calculated by the size of the parent element it's appended to.
1667 * @name size
1668 * @memberof Options
1669 * @type {object}
1670 * @property {object} [size] size object
1671 * @property {number} [size.width] width of the chart element
1672 * @property {number} [size.height] height of the chart element
1673 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.ChartSize)
1674 * @example
1675 * size: {
1676 * width: 640,
1677 * height: 480
1678 * }
1679 */
1680 size_width: undefined,
1681 size_height: undefined,
1682
1683 /**
1684 * The padding of the chart element.
1685 * @name padding
1686 * @memberof Options
1687 * @type {object}
1688 * @property {object} [padding] padding object
1689 * @property {number} [padding.top] padding on the top of chart
1690 * @property {number} [padding.right] padding on the right of chart
1691 * @property {number} [padding.bottom] padding on the bottom of chart
1692 * @property {number} [padding.left] padding on the left of chart
1693 * @example
1694 * padding: {
1695 * top: 20,
1696 * right: 20,
1697 * bottom: 20,
1698 * left: 20
1699 * }
1700 */
1701 padding_left: undefined,
1702 padding_right: undefined,
1703 padding_top: undefined,
1704 padding_bottom: undefined,
1705
1706 /**
1707 * Set chart resize options
1708 * @name resize
1709 * @memberof Options
1710 * @type {object}
1711 * @property {object} [resize] resize object
1712 * @property {boolean} [resize.auto=true] Set chart resize automatically on viewport changes.
1713 * @example
1714 * resize: {
1715 * auto: false
1716 * }
1717 */
1718 resize_auto: !0,
1719
1720 /**
1721 * Set a callback to execute when mouse/touch enters the chart.
1722 * @name onover
1723 * @memberof Options
1724 * @type {Function}
1725 * @default undefined
1726 * @example
1727 * onover: function() {
1728 * this; // chart instance itself
1729 * ...
1730 * }
1731 */
1732 onover: undefined,
1733
1734 /**
1735 * Set a callback to execute when mouse/touch leaves the chart.
1736 * @name onout
1737 * @memberof Options
1738 * @type {Function}
1739 * @default undefined
1740 * @example
1741 * onout: function() {
1742 * this; // chart instance itself
1743 * ...
1744 * }
1745 */
1746 onout: undefined,
1747
1748 /**
1749 * Set a callback to execute when user resizes the screen.
1750 * @name onresize
1751 * @memberof Options
1752 * @type {Function}
1753 * @default undefined
1754 * @example
1755 * onresize: function() {
1756 * this; // chart instance itself
1757 * ...
1758 * }
1759 */
1760 onresize: undefined,
1761
1762 /**
1763 * Set a callback to execute when screen resize finished.
1764 * @name onresized
1765 * @memberof Options
1766 * @type {Function}
1767 * @default undefined
1768 * @example
1769 * onresized: function() {
1770 * this; // chart instance itself
1771 * ...
1772 * }
1773 */
1774 onresized: undefined,
1775
1776 /**
1777 * Set a callback to execute before the chart is initialized
1778 * @name onbeforeinit
1779 * @memberof Options
1780 * @type {Function}
1781 * @default undefined
1782 * @example
1783 * onbeforeinit: function() {
1784 * this; // chart instance itself
1785 * ...
1786 * }
1787 */
1788 onbeforeinit: undefined,
1789
1790 /**
1791 * Set a callback to execute when the chart is initialized.
1792 * @name oninit
1793 * @memberof Options
1794 * @type {Function}
1795 * @default undefined
1796 * @example
1797 * oninit: function() {
1798 * this; // chart instance itself
1799 * ...
1800 * }
1801 */
1802 oninit: undefined,
1803
1804 /**
1805 * Set a callback to execute after the chart is initialized
1806 * @name onafterinit
1807 * @memberof Options
1808 * @type {Function}
1809 * @default undefined
1810 * @example
1811 * onafterinit: function() {
1812 * this; // chart instance itself
1813 * ...
1814 * }
1815 */
1816 onafterinit: undefined,
1817
1818 /**
1819 * 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.
1820 * @name onrendered
1821 * @memberof Options
1822 * @type {Function}
1823 * @default undefined
1824 * @example
1825 * onrendered: function() {
1826 * this; // chart instance itself
1827 * ...
1828 * }
1829 */
1830 onrendered: undefined,
1831
1832 /**
1833 * Set duration of transition (in milliseconds) for chart animation.<br><br>
1834 * - **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.
1835 * @name transition
1836 * @memberof Options
1837 * @type {object}
1838 * @property {object} [transition] transition object
1839 * @property {number} [transition.duration=350] duration in milliseconds
1840 * @example
1841 * transition: {
1842 * duration: 500
1843 * }
1844 */
1845 transition_duration: 250,
1846
1847 /**
1848 * Set plugins
1849 * @name plugins
1850 * @memberof Options
1851 * @type {Array}
1852 * @example
1853 * plugins: [
1854 * new bb.plugin.stanford({ ... }),
1855 * new PluginA(),
1856 * ...
1857 * ]
1858 */
1859 plugins: [],
1860
1861 /**
1862 * Control the render timing
1863 * @name render
1864 * @memberof Options
1865 * @type {object}
1866 * @property {object} [render] render object
1867 * @property {boolean} [render.lazy=true] Make to not render at initialization (enabled by default when bind element's visibility is hidden).
1868 * @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.
1869 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.LazyRender)
1870 * @example
1871 * render: {
1872 * lazy: true,
1873 * observe: true
1874 * }
1875 *
1876 * @example
1877 * // <!-- render.lazy will detect visibility defined -->
1878 * // (a) <div id='chart' class='hide'></div>
1879 * // (b) <div id='chart' style='display:none'></div>
1880 *
1881 * // render.lazy enabled by default when element is hidden
1882 * var chart = bb.generate({ ... });
1883 *
1884 * // chart will be rendered automatically when element's visibility changes
1885 * // Note: works only for inlined css property or class attribute changes
1886 * document.getElementById('chart').classList.remove('hide') // (a)
1887 * document.getElementById('chart').style.display = 'block'; // (b)
1888 *
1889 * @example
1890 * // chart won't be rendered and not observing bind element's visiblity changes
1891 * var chart = bb.generate({
1892 * render: {
1893 * lazy: true,
1894 * observe: false
1895 * }
1896 * });
1897 *
1898 * // call at any point when you want to render
1899 * chart.flush();
1900 */
1901 render: {},
1902
1903 /**
1904 * Show rectangles inside the chart.<br><br>
1905 * This option accepts array including object that has axis, start, end and class.
1906 * The keys start, end and class are optional.
1907 * axis must be x, y or y2. start and end should be the value where regions start and end.
1908 * If not specified, the edge values will be used.
1909 * If timeseries x axis, date string, Date object and unixtime integer can be used.
1910 * If class is set, the region element will have it as class.
1911 * @name regions
1912 * @memberof Options
1913 * @type {Array}
1914 * @default []
1915 * @example
1916 * regions: [
1917 * {
1918 * axis: "x",
1919 * start: 1,
1920 * end: 4,
1921 * class: "region-1-4"
1922 * }
1923 * ]
1924 */
1925 regions: []
1926});
1927;// CONCATENATED MODULE: ./src/config/Options/data/data.ts
1928/**
1929 * Copyright (c) 2017 ~ present NAVER Corp.
1930 * billboard.js project is licensed under the MIT license
1931 */
1932
1933/**
1934 * data config options
1935 */
1936/* harmony default export */ var data = ({
1937 /**
1938 * Specify the key of x values in the data.<br><br>
1939 * 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.
1940 * @name data․x
1941 * @memberof Options
1942 * @type {string}
1943 * @default undefined
1944 * @example
1945 * data: {
1946 * x: "date"
1947 * }
1948 */
1949 data_x: undefined,
1950
1951 /**
1952 * Converts data id value
1953 * @name data․idConverter
1954 * @memberof Options
1955 * @type {Function}
1956 * @default function(id) { return id; }
1957 * @example
1958 * data: {
1959 * idConverter: function(id) {
1960 * // when id is 'data1', converts to be 'data2'
1961 * // 'data2' should be given as the initial data value
1962 * if (id === "data1") {
1963 * return "data2";
1964 * } else {
1965 * return id;
1966 * }
1967 * }
1968 * }
1969 */
1970 data_idConverter: function data_idConverter(id) {
1971 return id;
1972 },
1973
1974 /**
1975 * Set custom data name.
1976 * @name data․names
1977 * @memberof Options
1978 * @type {object}
1979 * @default {}
1980 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataName)
1981 * @example
1982 * data: {
1983 * names: {
1984 * data1: "Data Name 1",
1985 * data2: "Data Name 2"
1986 * }
1987 * }
1988 */
1989 data_names: {},
1990
1991 /**
1992 * Set custom data class.<br><br>
1993 * 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).
1994 * @name data․classes
1995 * @memberof Options
1996 * @type {object}
1997 * @default {}
1998 * @example
1999 * data: {
2000 * classes: {
2001 * data1: "additional-data1-class",
2002 * data2: "additional-data2-class"
2003 * }
2004 * }
2005 */
2006 data_classes: {},
2007
2008 /**
2009 * Set chart type at once.<br><br>
2010 * If this option is specified, the type will be applied to every data. This setting can be overwritten by data.types.<br><br>
2011 * **Available Values:**
2012 * - area
2013 * - area-line-range
2014 * - area-spline
2015 * - area-spline-range
2016 * - area-step
2017 * - bar
2018 * - bubble
2019 * - candlestick
2020 * - donut
2021 * - gauge
2022 * - line
2023 * - pie
2024 * - radar
2025 * - scatter
2026 * - spline
2027 * - step
2028 * @name data․type
2029 * @memberof Options
2030 * @type {string}
2031 * @default "line"<br>NOTE: When importing shapes by ESM, `line()` should be specified for type.
2032 * @example
2033 * data: {
2034 * type: "bar"
2035 * }
2036 * @example
2037 * // Generate chart by importing ESM
2038 * // Import types to be used only, where this will make smaller bundle size.
2039 * import bb, {
2040 * area,
2041 * areaLineRange,
2042 * areaSpline,
2043 * areaSplineRange,
2044 * areaStep,
2045 * bar,
2046 * bubble,
2047 * candlestick,
2048 * donut,
2049 * gauge,
2050 * line,
2051 * pie,
2052 * radar,
2053 * scatter,
2054 * spline,
2055 * step
2056 * }
2057 *
2058 * bb.generate({
2059 * ...,
2060 * data: {
2061 * type: bar()
2062 * }
2063 * });
2064 */
2065 data_type: undefined,
2066
2067 /**
2068 * Set chart type for each data.<br>
2069 * This setting overwrites data.type setting.
2070 * - **NOTE:** `radar` type can't be combined with other types.
2071 * @name data․types
2072 * @memberof Options
2073 * @type {object}
2074 * @default {}
2075 * @example
2076 * data: {
2077 * types: {
2078 * data1: "bar",
2079 * data2: "spline"
2080 * }
2081 * }
2082 * @example
2083 * // Generate chart by importing ESM
2084 * // Import types to be used only, where this will make smaller bundle size.
2085 * import bb, {
2086 * area,
2087 * areaLineRange,
2088 * areaSpline,
2089 * areaSplineRange,
2090 * areaStep,
2091 * bar,
2092 * bubble,
2093 * candlestick,
2094 * donut,
2095 * gauge,
2096 * line,
2097 * pie,
2098 * radar,
2099 * scatter,
2100 * spline,
2101 * step
2102 * }
2103 *
2104 * bb.generate({
2105 * ...,
2106 * data: {
2107 * types: {
2108 * data1: bar(),
2109 * data1: spline()
2110 * }
2111 * }
2112 * });
2113 */
2114 data_types: {},
2115
2116 /**
2117 * This option changes the order of stacking data and pieces of pie/donut.
2118 * - If `null` specified, it will be the order the data loaded.
2119 * - 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>
2120 *
2121 * **Available Values:**
2122 * - `desc`: In descending order
2123 * - `asc`: In ascending order
2124 * - `null`: It keeps the data load order
2125 * - `function(data1, data2) { ... }`: Array.sort compareFunction
2126 *
2127 * **NOTE**: order function, only works for Axis based types & Arc types, except `Radar` type.
2128 * @name data․order
2129 * @memberof Options
2130 * @type {string|Function|null}
2131 * @default desc
2132 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataOrder)
2133 * @example
2134 * data: {
2135 * // in descending order (default)
2136 * order: "desc"
2137 *
2138 * // in ascending order
2139 * order: "asc"
2140 *
2141 * // keeps data input order
2142 * order: null
2143 *
2144 * // specifying sort function
2145 * order: function(a, b) {
2146 * // param data passed format
2147 * // {
2148 * // id: "data1", id_org: "data1", values: [
2149 * // {x: 5, value: 250, id: "data1", index: 5, name: "data1"},
2150 * // ...
2151 * // ]
2152 * // }
2153 *
2154 * const reducer = (p, c) => p + Math.abs(c.value);
2155 * const aSum = a.values.reduce(reducer, 0);
2156 * const bSum = b.values.reduce(reducer, 0);
2157 *
2158 * // ascending order
2159 * return aSum - bSum;
2160 *
2161 * // descending order
2162 * // return bSum - aSum;
2163 * }
2164 * }
2165 */
2166 data_order: "desc",
2167
2168 /**
2169 * Set groups for the data for stacking.
2170 * @name data․groups
2171 * @memberof Options
2172 * @type {Array}
2173 * @default []
2174 * @example
2175 * data: {
2176 * groups: [
2177 * ["data1", "data2"],
2178 * ["data3"]
2179 * ]
2180 * }
2181 */
2182 data_groups: [],
2183
2184 /**
2185 * Set color converter function.<br><br>
2186 * 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').
2187 * @name data․color
2188 * @memberof Options
2189 * @type {Function}
2190 * @default undefined
2191 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataColor)
2192 * @example
2193 * data: {
2194 * color: function(color, d) { ... }
2195 * }
2196 */
2197 data_color: undefined,
2198
2199 /**
2200 * Set color for each data.
2201 * @name data․colors
2202 * @memberof Options
2203 * @type {object}
2204 * @default {}
2205 * @example
2206 * data: {
2207 * colors: {
2208 * data1: "#ff0000",
2209 * data2: function(d) {
2210 * return "#000";
2211 * }
2212 * ...
2213 * }
2214 * }
2215 */
2216 data_colors: {},
2217
2218 /**
2219 * Set labels options
2220 * @name data․labels
2221 * @memberof Options
2222 * @type {object}
2223 * @property {object} data Data object
2224 * @property {boolean} [data.labels=false] Show or hide labels on each data points
2225 * @property {boolean} [data.labels.centered=false] Centerize labels on `bar` shape. (**NOTE:** works only for 'bar' type)
2226 * @property {Function} [data.labels.format] Set formatter function for data labels.<br>
2227 * 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>
2228 * The arguments are:<br>
2229 * - `v` is the value of the data point where the label is shown.
2230 * - `id` is the id of the data where the label is shown.
2231 * - `i` is the index of the data series point where the label is shown.
2232 * - `texts` is the array of whole corresponding data series' text labels.<br><br>
2233 * Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
2234 * @property {string|object} [data.labels.backgroundColors] Set label text background colors.
2235 * @property {string|object|Function} [data.labels.colors] Set label text colors.
2236 * @property {object} [data.labels.position] Set each dataset position, relative the original.
2237 * @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
2238 * @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
2239 * @memberof Options
2240 * @type {object}
2241 * @default {}
2242 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataLabel)
2243 * @see [Demo: label colors](https://naver.github.io/billboard.js/demo/#Data.DataLabelColors)
2244 * @see [Demo: label format](https://naver.github.io/billboard.js/demo/#Data.DataLabelFormat)
2245 * @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
2246 * @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
2247 * @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
2248 * @example
2249 * data: {
2250 * labels: true,
2251 *
2252 * // or set specific options
2253 * labels: {
2254 * format: function(v, id, i, j) {
2255 * ...
2256 * // to multiline, return with '\n' character
2257 * return "Line1\nLine2";
2258 * },
2259 *
2260 * // it's possible to set for each data
2261 * format: {
2262 * data1: function(v, id, i, texts) { ... },
2263 * ...
2264 * },
2265 *
2266 * // align text to center of the 'bar' shape (works only for 'bar' type)
2267 * centered: true,
2268 *
2269 * // apply backgound color for label texts
2270 * backgroundColors: "red",
2271 *
2272 * // set differenct backround colors per dataset
2273 * backgroundColors: {
2274 * data1: "green",
2275 * data2: "yellow"
2276 * }
2277 *
2278 * // apply for all label texts
2279 * colors: "red",
2280 *
2281 * // set different colors per dataset
2282 * // for not specified dataset, will have the default color value
2283 * colors: {
2284 * data1: "yellow",
2285 * data3: "green"
2286 * },
2287 *
2288 * // call back for label text color
2289 * colors: function(color, d) {
2290 * // color: the default data label color string
2291 * // data: ex) {x: 0, value: 200, id: "data3", index: 0}
2292 * ....
2293 * return d.value > 200 ? "cyan" : color;
2294 * },
2295 *
2296 * // set x, y coordinate position
2297 * position: {
2298 * x: -10,
2299 * y: 10
2300 * },
2301 *
2302 * // or set x, y coordinate position by each dataset
2303 * position: {
2304 * data1: {x: 5, y: 5},
2305 * data2: {x: 10, y: -20}
2306 * }
2307 * }
2308 * }
2309 */
2310 data_labels: {},
2311 data_labels_backgroundColors: undefined,
2312 data_labels_colors: undefined,
2313 data_labels_position: {},
2314
2315 /**
2316 * Hide each data when the chart appears.<br><br>
2317 * If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
2318 * @name data․hide
2319 * @memberof Options
2320 * @type {boolean|Array}
2321 * @default false
2322 * @example
2323 * data: {
2324 * // all of data will be hidden
2325 * hide: true
2326 *
2327 * // specified data will be hidden
2328 * hide: ["data1", ...]
2329 * }
2330 */
2331 data_hide: !1,
2332
2333 /**
2334 * Filter values to be shown
2335 * The data value is the same as the returned by `.data()`.
2336 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
2337 * @name data․filter
2338 * @memberof Options
2339 * @type {Function}
2340 * @default undefined
2341 * @example
2342 * data: {
2343 * // filter for id value
2344 * filter: function(v) {
2345 * // v: [{id: "data1", id_org: "data1", values: [
2346 * // {x: 0, value: 130, id: "data2", index: 0}, ...]
2347 * // }, ...]
2348 * return v.id !== "data1";
2349 * }
2350 */
2351 data_filter: undefined,
2352
2353 /**
2354 * Set a callback for click event on each data point.<br><br>
2355 * This callback will be called when each data point clicked and will receive `d` and element as the arguments.
2356 * - `d` is the data clicked and element is the element clicked.
2357 * - `element` is the current interacting svg element.
2358 * - In this callback, `this` will be the Chart object.
2359 * @name data․onclick
2360 * @memberof Options
2361 * @type {Function}
2362 * @default function() {}
2363 * @example
2364 * data: {
2365 * onclick: function(d, element) {
2366 * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
2367 * // element - <circle>
2368 * ...
2369 * }
2370 * }
2371 */
2372 data_onclick: function data_onclick() {},
2373
2374 /**
2375 * Set a callback for mouse/touch over event on each data point.<br><br>
2376 * 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.
2377 * - `d` is the data where mouse cursor moves onto.
2378 * - `element` is the current interacting svg element.
2379 * - In this callback, `this` will be the Chart object.
2380 * @name data․onover
2381 * @memberof Options
2382 * @type {Function}
2383 * @default function() {}
2384 * @example
2385 * data: {
2386 * onover: function(d, element) {
2387 * // d - ex) {x: 4, value: 150, id: "data1", index: 4}
2388 * // element - <circle>
2389 * ...
2390 * }
2391 * }
2392 */
2393 data_onover: function data_onover() {},
2394
2395 /**
2396 * Set a callback for mouse/touch out event on each data point.<br><br>
2397 * This callback will be called when mouse cursor or via touch moves out each data point and will receive `d` as the argument.
2398 * - `d` is the data where mouse cursor moves out.
2399 * - `element` is the current interacting svg element.
2400 * - In this callback, `this` will be the Chart object.
2401 * @name data․onout
2402 * @memberof Options
2403 * @type {Function}
2404 * @default function() {}
2405 * @example
2406 * data: {
2407 * onout: function(d, element) {
2408 * // d - ex) {x: 4, value: 150, id: "data1", index: 4}
2409 * // element - <circle>
2410 * ...
2411 * }
2412 * }
2413 */
2414 data_onout: function data_onout() {},
2415
2416 /**
2417 * Set a callback for when data is shown.<br>
2418 * The callback will receive shown data ids in array.
2419 * @name data․onshown
2420 * @memberof Options
2421 * @type {Function}
2422 * @default undefined
2423 * @example
2424 * data: {
2425 * onshown: function(ids) {
2426 * // ids - ["data1", "data2", ...]
2427 * ...
2428 * }
2429 * }
2430 */
2431 data_onshown: undefined,
2432
2433 /**
2434 * Set a callback for when data is hidden.<br>
2435 * The callback will receive hidden data ids in array.
2436 * @name data․onhidden
2437 * @memberof Options
2438 * @type {Function}
2439 * @default undefined
2440 * @example
2441 * data: {
2442 * onhidden: function(ids) {
2443 * // ids - ["data1", "data2", ...]
2444 * ...
2445 * }
2446 * }
2447 */
2448 data_onhidden: undefined,
2449
2450 /**
2451 * Set a callback for minimum data
2452 * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
2453 * @name data․onmin
2454 * @memberof Options
2455 * @type {Function}
2456 * @default undefined
2457 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
2458 * @example
2459 * onmin: function(data) {
2460 * // data - ex) [{x: 3, value: 400, id: "data1", index: 3}, ... ]
2461 * ...
2462 * }
2463 */
2464 data_onmin: undefined,
2465
2466 /**
2467 * Set a callback for maximum data
2468 * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
2469 * @name data․onmax
2470 * @memberof Options
2471 * @type {Function}
2472 * @default undefined
2473 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
2474 * @example
2475 * onmax: function(data) {
2476 * // data - ex) [{x: 3, value: 400, id: "data1", index: 3}, ... ]
2477 * ...
2478 * }
2479 */
2480 data_onmax: undefined,
2481
2482 /**
2483 * 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.
2484 * @name data․url
2485 * @memberof Options
2486 * @type {string}
2487 * @default undefined
2488 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.LoadData)
2489 * @example
2490 * data: {
2491 * url: "/data/test.csv"
2492 * }
2493 */
2494 data_url: undefined,
2495
2496 /**
2497 * XHR header value
2498 * - **NOTE:** Should be used with `data.url` option
2499 * @name data․headers
2500 * @memberof Options
2501 * @type {string}
2502 * @default undefined
2503 * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
2504 * @example
2505 * data: {
2506 * url: "/data/test.csv",
2507 * headers: {
2508 * "Content-Type": "text/xml",
2509 * ...
2510 * }
2511 * }
2512 */
2513 data_headers: undefined,
2514
2515 /**
2516 * Parse a JSON object for data. See also data.keys.
2517 * @name data․json
2518 * @memberof Options
2519 * @type {Array}
2520 * @default undefined
2521 * @see [data․keys](#.data%25E2%2580%25A4keys)
2522 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.JSONData)
2523 * @example
2524 * data: {
2525 * json: [
2526 * {name: "www.site1.com", upload: 200, download: 200, total: 400},
2527 * {name: "www.site2.com", upload: 100, download: 300, total: 400},
2528 * {name: "www.site3.com", upload: 300, download: 200, total: 500},
2529 * {name: "www.site4.com", upload: 400, download: 100, total: 500}
2530 * ],
2531 * keys: {
2532 * // x: "name", // it's possible to specify 'x' when category axis
2533 * value: ["upload", "download"]
2534 * }
2535 * }
2536 */
2537 data_json: undefined,
2538
2539 /**
2540 * Load data from a multidimensional array, with the first element containing the data names, the following containing related data in that order.
2541 * @name data․rows
2542 * @memberof Options
2543 * @type {Array}
2544 * @default undefined
2545 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.RowOrientedData)
2546 * @example
2547 * data: {
2548 * rows: [
2549 * ["A", "B", "C"],
2550 * [90, 120, 300],
2551 * [40, 160, 240],
2552 * [50, 200, 290],
2553 * [120, 160, 230],
2554 * [80, 130, 300],
2555 * [90, 220, 320]
2556 * ]
2557 * }
2558 *
2559 * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
2560 * // - an array of [high, mid, low] data following the order
2561 * // - or an object with 'high', 'mid' and 'low' key value
2562 * data: {
2563 * rows: [
2564 * ["data1", "data2"],
2565 * [
2566 * // or {high:150, mid: 140, low: 110}, 120
2567 * [150, 140, 110], 120
2568 * ],
2569 * [[155, 130, 115], 55],
2570 * [[160, 135, 120], 60]
2571 * ],
2572 * types: {
2573 * data1: "area-line-range",
2574 * data2: "line"
2575 * }
2576 * }
2577 *
2578 * // for 'bubble' type, data can contain dimension value:
2579 * // - an array of [y, z] data following the order
2580 * // - or an object with 'y' and 'z' key value
2581 * // 'y' is for y axis coordination and 'z' is the bubble radius value
2582 * data: {
2583 * rows: [
2584 * ["data1", "data2"],
2585 * [
2586 * // or {y:10, z: 140}, 120
2587 * [10, 140], 120
2588 * ],
2589 * [[100, 30], 55],
2590 * [[50, 100], 60]
2591 * ],
2592 * types: {
2593 * data1: "bubble",
2594 * data2: "line"
2595 * }
2596 * }
2597 *
2598 * // for 'canlestick' type, data should contain:
2599 * // - an array of [open, high, low, close, volume(optional)] data following the order
2600 * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
2601 * data: {
2602 * rows: [
2603 * ["data1", "data2"],
2604 * [
2605 * // open, high, low, close, volume (optional)
2606 * {open: 1300, high: 1369, low: 1200, close: 1339, volume: 100},
2607 * [1000, 1100, 850, 870]
2608 * ],
2609 * [
2610 * {open: 1348, high: 1371, low: 1271, close: 1320},
2611 * [870, 1250, 830, 1200, 50]
2612 * ]
2613 * ],
2614 * type: "candlestick"
2615 * }
2616 */
2617 data_rows: undefined,
2618
2619 /**
2620 * Load data from a multidimensional array, with each element containing an array consisting of a datum name and associated data values.
2621 * @name data․columns
2622 * @memberof Options
2623 * @type {Array}
2624 * @default undefined
2625 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.ColumnOrientedData)
2626 * @example
2627 * data: {
2628 * columns: [
2629 * ["data1", 30, 20, 50, 40, 60, 50],
2630 * ["data2", 200, 130, 90, 240, 130, 220],
2631 * ["data3", 300, 200, 160, 400, 250, 250]
2632 * ]
2633 * }
2634 *
2635 * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
2636 * // - an array of [high, mid, low] data following the order
2637 * // - or an object with 'high', 'mid' and 'low' key value
2638 * data: {
2639 * columns: [
2640 * ["data1",
2641 * [150, 140, 110], // or {high:150, mid: 140, low: 110}
2642 * [150, 140, 110],
2643 * [150, 140, 110]
2644 * ]
2645 * ],
2646 * type: "area-line-range"
2647 * }
2648 *
2649 * // for 'bubble' type, data can contain dimension value:
2650 * // - an array of [y, z] data following the order
2651 * // - or an object with 'y' and 'z' key value
2652 * // 'y' is for y axis coordination and 'z' is the bubble radius value
2653 * data: {
2654 * columns: [
2655 * ["data1",
2656 * [10, 140], // or {y:10, z: 140}
2657 * [100, 30],
2658 * [50, 100]
2659 * ]
2660 * ],
2661 * type: "bubble"
2662 * }
2663 *
2664 * // for 'canlestick' type, data should contain:
2665 * // - an array of [open, high, low, close, volume(optional)] data following the order
2666 * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
2667 * data: {
2668 * columns: [
2669 * ["data1",
2670 * [1000, 1100, 850, 870, 100], // or {open:1000, high: 1100, low: 870, volume: 100}
2671 * [870, 1250, 830, 1200] // 'volume' can be omitted
2672 * ]
2673 * ],
2674 * type: "candlestick"
2675 * }
2676 */
2677 data_columns: undefined,
2678
2679 /**
2680 * Used if loading JSON via data.url.
2681 * - **Available Values:**
2682 * - json
2683 * - csv
2684 * - tsv
2685 * @name data․mimeType
2686 * @memberof Options
2687 * @type {string}
2688 * @default csv
2689 * @example
2690 * data: {
2691 * mimeType: "json"
2692 * }
2693 */
2694 data_mimeType: "csv",
2695
2696 /**
2697 * Choose which JSON object keys correspond to desired data.
2698 * - **NOTE:** Only for JSON object given as array.
2699 * @name data․keys
2700 * @memberof Options
2701 * @type {string}
2702 * @default undefined
2703 * @example
2704 * data: {
2705 * json: [
2706 * {name: "www.site1.com", upload: 200, download: 200, total: 400},
2707 * {name: "www.site2.com", upload: 100, download: 300, total: 400},
2708 * {name: "www.site3.com", upload: 300, download: 200, total: 500},
2709 * {name: "www.site4.com", upload: 400, download: 100, total: 500}
2710 * ],
2711 * keys: {
2712 * // x: "name", // it's possible to specify 'x' when category axis
2713 * value: ["upload", "download"]
2714 * }
2715 * }
2716 */
2717 data_keys: undefined,
2718
2719 /**
2720 * Set text label to be displayed when there's no data to show.
2721 * - ex. Toggling all visible data to not be shown, unloading all current data, etc.
2722 * @name data․empty․label․text
2723 * @memberof Options
2724 * @type {string}
2725 * @default ""
2726 * @example
2727 * data: {
2728 * empty: {
2729 * label: {
2730 * text: "No Data"
2731 * }
2732 * }
2733 * }
2734 */
2735 data_empty_label_text: ""
2736});
2737;// CONCATENATED MODULE: ./src/config/Options/common/color.ts
2738/**
2739 * Copyright (c) 2017 ~ present NAVER Corp.
2740 * billboard.js project is licensed under the MIT license
2741 */
2742
2743/**
2744 * color config options
2745 */
2746/* harmony default export */ var color = ({
2747 /**
2748 * Set color of the data values
2749 * @name color
2750 * @memberof Options
2751 * @type {object}
2752 * @property {object} color color object
2753 * @property {string|object|Function} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
2754 * @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.
2755 * @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).
2756 * - **NOTE:** The pattern element's id will be defined as `bb-colorize-pattern-$COLOR-VALUE`.<br>
2757 * ex. When color pattern value is `['red', '#fff']` and defined 2 patterns,then ids for pattern elements are:<br>
2758 * - `bb-colorize-pattern-red`
2759 * - `bb-colorize-pattern-fff`
2760 * @property {object} [color.threshold] color threshold for gauge and tooltip color
2761 * @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.
2762 * @property {Array} [color.threshold.values] Threshold values for each steps
2763 * @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`.
2764 * @example
2765 * color: {
2766 * pattern: ["#1f77b4", "#aec7e8", ...],
2767 *
2768 * // Set colors' patterns
2769 * // it should return an array of SVGPatternElement
2770 * tiles: function() {
2771 * var pattern = document.createElementNS("http://www.w3.org/2000/svg", "pattern");
2772 * var g = document.createElementNS("http://www.w3.org/2000/svg", "g");
2773 * var circle1 = document.createElementNS("http://www.w3.org/2000/svg", "circle");
2774 *
2775 * pattern.setAttribute("patternUnits", "userSpaceOnUse");
2776 * pattern.setAttribute("width", "32");
2777 * pattern.setAttribute("height", "32");
2778 *
2779 * g.style.fill = "#000";
2780 * g.style.opacity = "0.2";
2781 *
2782 * circle1.setAttribute("cx", "3");
2783 * circle1.setAttribute("cy", "3");
2784 * circle1.setAttribute("r", "3");
2785 *
2786 * g.appendChild(circle1);
2787 * pattern.appendChild(g);
2788 *
2789 * return [pattern];
2790 * },
2791 *
2792 * // for threshold usage, pattern values should be set for each steps
2793 * pattern: ["grey", "green", "yellow", "orange", "red"],
2794 * threshold: {
2795 * unit: "value",
2796 *
2797 * // when value is 20 => 'green', value is 40 => 'orange' will be set.
2798 * values: [10, 20, 30, 40, 50],
2799 *
2800 * // the equation for max:
2801 * // - unit == 'value': max => 30
2802 * // - unit != 'value': max => value*100/30
2803 * max: 30
2804 * },
2805 *
2806 * // set all data to 'red'
2807 * onover: "red",
2808 *
2809 * // set different color for data
2810 * onover: {
2811 * data1: "red",
2812 * data2: "yellow"
2813 * },
2814 *
2815 * // will pass data object to the callback
2816 * onover: function(d) {
2817 * return d.id === "data1" ? "red" : "green";
2818 * }
2819 * }
2820 */
2821 color_pattern: [],
2822 color_tiles: undefined,
2823 color_threshold: {},
2824 color_onover: undefined
2825});
2826;// CONCATENATED MODULE: ./src/config/Options/interaction/interaction.ts
2827/**
2828 * Copyright (c) 2017 ~ present NAVER Corp.
2829 * billboard.js project is licensed under the MIT license
2830 */
2831
2832/**
2833 * interaction config options
2834 */
2835/* harmony default export */ var interaction = ({
2836 /**
2837 * Interaction options
2838 * @name interaction
2839 * @memberof Options
2840 * @type {object}
2841 * @property {object} interaction Intersection object
2842 * @property {boolean} [interaction.enabled=true] Indicate if the chart should have interactions.<br>
2843 * If `false` is set, all of interactions (showing/hiding tooltip, selection, mouse events, etc) will be disabled.
2844 * @property {boolean} [interaction.brighten=true] Make brighter for the selected area (ex. 'pie' type data selected area)
2845 * @property {boolean} [interaction.inputType.mouse=true] enable or disable mouse interaction
2846 * @property {boolean} [interaction.inputType.touch=true] enable or disable touch interaction
2847 * @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.
2848 * @see [Demo: touch.preventDefault](https://naver.github.io/billboard.js/demo/#Interaction.PreventScrollOnTouch)
2849 * @example
2850 * interaction: {
2851 * enabled: false,
2852 * brighten: false,
2853 * inputType: {
2854 * mouse: true,
2855 * touch: false
2856 *
2857 * // or declare preventDefault explicitly.
2858 * // In this case touch inputType is enabled by default
2859 * touch: {
2860 * preventDefault: true
2861 *
2862 * // or threshold pixel value (pixel moved from touchstart to touchmove)
2863 * preventDefault: 5
2864 * }
2865 * }
2866 * }
2867 */
2868 interaction_enabled: !0,
2869 interaction_brighten: !0,
2870 interaction_inputType_mouse: !0,
2871 interaction_inputType_touch: {}
2872});
2873;// CONCATENATED MODULE: ./src/config/Options/common/legend.ts
2874/**
2875 * Copyright (c) 2017 ~ present NAVER Corp.
2876 * billboard.js project is licensed under the MIT license
2877 */
2878
2879/**
2880 * legend config options
2881 */
2882/* harmony default export */ var legend = ({
2883 /**
2884 * Legend options
2885 * @name legend
2886 * @memberof Options
2887 * @type {object}
2888 * @property {object} legend Legend object
2889 * @property {boolean} [legend.show=true] Show or hide legend.
2890 * @property {boolean} [legend.hide=false] Hide legend
2891 * If true given, all legend will be hidden. If string or array given, only the legend that has the id will be hidden.
2892 * @property {string|HTMLElement} [legend.contents.bindto=undefined] Set CSS selector or element reference to bind legend items.
2893 * @property {string|Function} [legend.contents.template=undefined] Set item's template.<br>
2894 * - If set `string` value, within template the 'color' and 'title' can be replaced using template-like syntax string:
2895 * - {=COLOR}: data color value
2896 * - {=TITLE}: data title value
2897 * - If set `function` value, will pass following arguments to the given function:
2898 * - title {string}: data's id value
2899 * - color {string}: color string
2900 * - data {Array}: data array
2901 * @property {string} [legend.position=bottom] Change the position of legend.<br>
2902 * Available values are: `bottom`, `right` and `inset` are supported.
2903 * @property {object} [legend.inset={anchor: 'top-left',x: 10,y: 0,step: undefined}] Change inset legend attributes.<br>
2904 * This option accepts object that has the keys `anchor`, `x`, `y` and `step`.
2905 * - **anchor** decides the position of the legend:
2906 * - top-left
2907 * - top-right
2908 * - bottom-left
2909 * - bottom-right
2910 * - **x** and **y**:
2911 * - set the position of the legend based on the anchor.
2912 * - **step**:
2913 * - defines the max step the legend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).
2914 * @property {boolean} [legend.equally=false] Set to all items have same width size.
2915 * @property {boolean} [legend.padding=0] Set padding value
2916 * @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
2917 * @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
2918 * @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
2919 * @property {number} [legend.item.tile.width=10] Set width of item tile element
2920 * @property {number} [legend.item.tile.height=10] Set height of item tile element
2921 * @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
2922 * @see [Demo: position](https://naver.github.io/billboard.js/demo/#Legend.LegendPosition)
2923 * @see [Demo: contents.template](https://naver.github.io/billboard.js/demo/#Legend.LegendTemplate1)
2924 * @see [Demo: usePoint](https://naver.github.io/billboard.js/demo/#Legend.usePoint)
2925 * @example
2926 * legend: {
2927 * show: true,
2928 * hide: true,
2929 * //or hide: "data1"
2930 * //or hide: ["data1", "data2"]
2931 * contents: {
2932 * bindto: "#legend", // <ul id='legend'></ul>
2933 *
2934 * // will be as: <li style='background-color:#1f77b4'>data1</li>
2935 * template: "<li style='background-color:{=COLOR}'>{=TITLE}</li>"
2936 *
2937 * // or using function
2938 * template: function(id, color, data) {
2939 * // if you want omit some legend, return falsy value
2940 * if (id !== "data1") {
2941 * return "<li style='background-color:"+ color +">"+ id +"</li>";
2942 * }
2943 * }
2944 * },
2945 * position: "bottom", // bottom, right, inset
2946 * inset: {
2947 * anchor: "top-right" // top-left, top-right, bottom-left, bottom-right
2948 * x: 20,
2949 * y: 10,
2950 * step: 2
2951 * },
2952 * equally: false,
2953 * padding: 10,
2954 * item: {
2955 * onclick: function(id) { ... },
2956 * onover: function(id) { ... },
2957 * onout: function(id) { ... },
2958 *
2959 * // set tile's size
2960 * tile: {
2961 * width: 20,
2962 * height: 15
2963 * }
2964 * },
2965 * usePoint: true
2966 * }
2967 */
2968 legend_show: !0,
2969 legend_hide: !1,
2970 legend_contents_bindto: undefined,
2971 legend_contents_template: undefined,
2972 legend_position: "bottom",
2973 legend_inset_anchor: "top-left",
2974 legend_inset_x: 10,
2975 legend_inset_y: 0,
2976 legend_inset_step: undefined,
2977 legend_item_onclick: undefined,
2978 legend_item_onover: undefined,
2979 legend_item_onout: undefined,
2980 legend_equally: !1,
2981 legend_padding: 0,
2982 legend_item_tile_width: 10,
2983 legend_item_tile_height: 10,
2984 legend_usePoint: !1
2985});
2986;// CONCATENATED MODULE: ./src/config/Options/common/title.ts
2987/**
2988 * Copyright (c) 2017 ~ present NAVER Corp.
2989 * billboard.js project is licensed under the MIT license
2990 */
2991
2992/**
2993 * title config options
2994 */
2995/* harmony default export */ var title = ({
2996 /**
2997 * Set title options
2998 * @name title
2999 * @memberof Options
3000 * @type {object}
3001 * @property {object} title Title object
3002 * @property {string} [title.text] Title text. If contains `\n`, it's used as line break allowing multiline title.
3003 * @property {number} [title.padding.top=0] Top padding value.
3004 * @property {number} [title.padding.right=0] Right padding value.
3005 * @property {number} [title.padding.bottom=0] Bottom padding value.
3006 * @property {number} [title.padding.left=0] Left padding value.
3007 * @property {string} [title.position=center] Available values are: 'center', 'right' and 'left'.
3008 * @see [Demo](https://naver.github.io/billboard.js/demo/#Title.MultilinedTitle)
3009 * @example
3010 * title: {
3011 * text: "Title Text",
3012 *
3013 * // or Multiline title text
3014 * text: "Main title text\nSub title text",
3015 *
3016 * padding: {
3017 * top: 10,
3018 * right: 10,
3019 * bottom: 10,
3020 * left: 10
3021 * },
3022 * position: "center"
3023 * }
3024 */
3025 title_text: undefined,
3026 title_padding: {
3027 top: 0,
3028 right: 0,
3029 bottom: 0,
3030 left: 0
3031 },
3032 title_position: "center"
3033});
3034;// CONCATENATED MODULE: ./src/config/Options/common/tooltip.ts
3035/**
3036 * Copyright (c) 2017 ~ present NAVER Corp.
3037 * billboard.js project is licensed under the MIT license
3038 */
3039
3040/**
3041 * tooltip config options
3042 */
3043/* harmony default export */ var tooltip = ({
3044 /**
3045 * Tooltip options
3046 * @name tooltip
3047 * @memberof Options
3048 * @type {object}
3049 * @property {object} tooltip Tooltip object
3050 * @property {boolean} [tooltip.show=true] Show or hide tooltip.
3051 * @property {boolean} [tooltip.doNotHide=false] Make tooltip keep showing not hiding on interaction.
3052 * @property {boolean} [tooltip.grouped=true] Set if tooltip is grouped or not for the data points.
3053 * - **NOTE:** The overlapped data points will be displayed as grouped even if set false.
3054 * @property {boolean} [tooltip.linked=false] Set if tooltips on all visible charts with like x points are shown together when one is shown.
3055 * @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.
3056 * @property {Function} [tooltip.format.title] Set format for the title of tooltip.<br>
3057 * Specified function receives x of the data point to show.
3058 * @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
3059 * 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.
3060 * @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip.<br>
3061 * 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.
3062 * If undefined returned, the row of that value will be skipped.
3063 * @property {Function} [tooltip.position] Set custom position function for the tooltip.<br>
3064 * This option can be used to modify the tooltip position by returning object that has top and left.
3065 * - Will pass following arguments to the given function:
3066 * - `data {Array}`: Current selected data array object.
3067 * - `width {number}`: Width of tooltip.
3068 * - `height {number}`: Height of tooltip.
3069 * - `element {SVGElement}`: Tooltip event bound element
3070 * - `pos {object}`: Current position of the tooltip.
3071 * @property {Function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
3072 * Specified function receives data, defaultTitleFormat, defaultValueFormat and color of the data point to show. If tooltip.grouped is true, data includes multiple data points.
3073 * @property {string|HTMLElement} [tooltip.contents.bindto=undefined] Set CSS selector or element reference to bind tooltip.
3074 * - **NOTE:** When is specified, will not be updating tooltip's position.
3075 * @property {string} [tooltip.contents.template=undefined] Set tooltip's template.<br><br>
3076 * Within template, below syntax will be replaced using template-like syntax string:
3077 * - **{{ ... }}**: the doubly curly brackets indicate loop block for data rows.
3078 * - **{=CLASS_TOOLTIP}**: default tooltip class name `bb-tooltip`.
3079 * - **{=CLASS_TOOLTIP_NAME}**: default tooltip data class name (ex. `bb-tooltip-name-data1`)
3080 * - **{=TITLE}**: title value.
3081 * - **{=COLOR}**: data color.
3082 * - **{=VALUE}**: data value.
3083 * @property {object} [tooltip.contents.text=undefined] Set additional text content within data loop, using template syntax.
3084 * - **NOTE:** It should contain `{ key: Array, ... }` value
3085 * - 'key' name is used as substitution within template as '{=KEY}'
3086 * - The value array length should match with the data length
3087 * @property {boolean} [tooltip.init.show=false] Show tooltip at the initialization.
3088 * @property {number} [tooltip.init.x=0] Set x Axis index(or index for Arc(donut, gauge, pie) types) to be shown at the initialization.
3089 * @property {object} [tooltip.init.position={top: "0px",left: "50px"}] Set the position of tooltip at the initialization.
3090 * @property {Function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
3091 * @property {Function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
3092 * @property {Function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
3093 * @property {Function} [tooltip.onhidden] Set a callback that will be invoked after the tooltip is hidden.
3094 * @property {string|Function|null} [tooltip.order=null] Set tooltip data display order.<br><br>
3095 * **Available Values:**
3096 * - `desc`: In descending data value order
3097 * - `asc`: In ascending data value order
3098 * - `null`: It keeps the data display order<br>
3099 * **NOTE:** When `data.groups` is set, the order will follow as the stacked graph order.<br>
3100 * If want to order as data bound, set any value rather than asc, desc or null. (ex. empty string "")
3101 * - `function(data1, data2) { ... }`: [Array.sort compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters)
3102 * @see [Demo: Hide Tooltip](https://naver.github.io/billboard.js/demo/#Tooltip.HideTooltip)
3103 * @see [Demo: Tooltip Grouping](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipGrouping)
3104 * @see [Demo: Tooltip Format](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipFormat)
3105 * @see [Demo: Linked Tooltip](https://naver.github.io/billboard.js/demo/#Tooltip.LinkedTooltips)
3106 * @see [Demo: Tooltip Template](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipTemplate)
3107 * @example
3108 * tooltip: {
3109 * show: true,
3110 * doNotHide: true,
3111 * grouped: false,
3112 * format: {
3113 * title: function(x) { return "Data " + x; },
3114 * name: function(name, ratio, id, index) { return name; },
3115 * value: function(value, ratio, id, index) { return ratio; }
3116 * },
3117 * position: function(data, width, height, element, pos) {
3118 * // data: [{x, index, id, name, value}, ...]
3119 * // width: Tooltip width
3120 * // height: Tooltip height
3121 * // element: Tooltip event bound element
3122 * // pos: {
3123 * // x: Current mouse event x position,
3124 * // y: Current mouse event y position,
3125 * // xAxis: Current x Axis position (the value is given for axis based chart type only)
3126 * // }
3127 * return {top: 0, left: 0}
3128 * },
3129 *
3130 * contents: function(d, defaultTitleFormat, defaultValueFormat, color) {
3131 * return ... // formatted html as you want
3132 * },
3133 *
3134 * // specify tooltip contents using template
3135 * // - example of HTML returned:
3136 * // <ul class="bb-tooltip">
3137 * // <li class="bb-tooltip-name-data1"><span>250</span><br><span style="color:#00c73c">data1</span></li>
3138 * // <li class="bb-tooltip-name-data2"><span>50</span><br><span style="color:#fa7171">data2</span></li>
3139 * // </ul>
3140 * contents: {
3141 * bindto: "#tooltip",
3142 * template: '<ul class={=CLASS_TOOLTIP}>{{' +
3143 * '<li class="{=CLASS_TOOLTIP_NAME}"><span>{=VALUE}</span><br>' +
3144 * '<span style=color:{=COLOR}>{=NAME}</span></li>' +
3145 * '}}</ul>'
3146 * }
3147 *
3148 * // with additional text value
3149 * // - example of HTML returned:
3150 * // <ul class="bb-tooltip">
3151 * // <li class="bb-tooltip-name-data1"><span>250</span><br>comment1<span style="color:#00c73c">data1</span>text1</li>
3152 * // <li class="bb-tooltip-name-data2"><span>50</span><br>comment2<span style="color:#fa7171">data2</span>text2</li>
3153 * // </ul>
3154 * contents: {
3155 * bindto: "#tooltip",
3156 * text: {
3157 * // a) 'key' name is used as substitution within template as '{=KEY}'
3158 * // b) the length should match with the data length
3159 * VAR1: ["text1", "text2"],
3160 * VAR2: ["comment1", "comment2"],
3161 * },
3162 * template: '<ul class={=CLASS_TOOLTIP}>{{' +
3163 * '<li class="{=CLASS_TOOLTIP_NAME}"><span>{=VALUE}</span>{=VAR2}<br>' +
3164 * '<span style=color:{=COLOR}>{=NAME}</span>{=VAR1}</li>' +
3165 * '}}</ul>'
3166 * }
3167 *
3168 * // sort tooltip data value display in ascending order
3169 * order: "asc",
3170 *
3171 * // specifying sort function
3172 * order: function(a, b) {
3173 * // param data passed format
3174 * {x: 5, value: 250, id: "data1", index: 5, name: "data1"}
3175 * ...
3176 * },
3177 *
3178 * // show at the initialization
3179 * init: {
3180 * show: true,
3181 * x: 2, // x Axis index(or index for Arc(donut, gauge, pie) types)
3182 * position: {
3183 * top: "150px",
3184 * left: "250px"
3185 * }
3186 * },
3187 *
3188 * // fires prior tooltip is shown
3189 * onshow: function(selectedData) {
3190 * // current dataset selected
3191 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
3192 * selectedData;
3193 * },
3194 *
3195 * // fires prior tooltip is hidden
3196 * onhide: function(selectedData) {
3197 * // current dataset selected
3198 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
3199 * selectedData;
3200 * },
3201 *
3202 * // fires after tooltip is shown
3203 * onshown: function(selectedData) {
3204 * // current dataset selected
3205 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
3206 * selectedData;
3207 * },
3208 *
3209 * // fires after tooltip is hidden
3210 * onhidden: function(selectedData) {
3211 * // current dataset selected
3212 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
3213 * selectedData;
3214 * },
3215 *
3216 * // Link any tooltips when multiple charts are on the screen where same x coordinates are available
3217 * // Useful for timeseries correlation
3218 * linked: true,
3219 *
3220 * // Specify name to interact those with the same name only.
3221 * linked: {
3222 * name: "some-group"
3223 * }
3224 * }
3225 */
3226 tooltip_show: !0,
3227 tooltip_doNotHide: !1,
3228 tooltip_grouped: !0,
3229 tooltip_format_title: undefined,
3230 tooltip_format_name: undefined,
3231 tooltip_format_value: undefined,
3232 tooltip_position: undefined,
3233 tooltip_contents: {},
3234 tooltip_init_show: !1,
3235 tooltip_init_x: 0,
3236 tooltip_init_position: {
3237 top: "0px",
3238 left: "50px"
3239 },
3240 tooltip_linked: !1,
3241 tooltip_linked_name: "",
3242 tooltip_onshow: function tooltip_onshow() {},
3243 tooltip_onhide: function tooltip_onhide() {},
3244 tooltip_onshown: function tooltip_onshown() {},
3245 tooltip_onhidden: function tooltip_onhidden() {},
3246 tooltip_order: null
3247});
3248;// CONCATENATED MODULE: ./src/config/Options/Options.ts
3249
3250
3251function Options_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3252
3253function Options_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { Options_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { Options_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
3254
3255/**
3256 * Copyright (c) 2017 ~ present NAVER Corp.
3257 * billboard.js project is licensed under the MIT license
3258 */
3259// common
3260
3261
3262
3263
3264
3265
3266
3267
3268/**
3269 * Class to set options on generating chart.
3270 * - It's instantiated internally, not exposed for public.
3271 * @class Options
3272 * @see {@link bb.generate} to use these options on generating the chart
3273 */
3274
3275var Options = /*#__PURE__*/function () {
3276 Options.setOptions = function setOptions(options) {
3277 this.data = options.reduce(function (a, c) {
3278 return Options_objectSpread(Options_objectSpread({}, a), c);
3279 }, this.data);
3280 };
3281
3282 function Options() {
3283 return deepClone(main, data, color, interaction, legend, title, tooltip, Options.data);
3284 }
3285
3286 return Options;
3287}();
3288
3289Options.data = {};
3290
3291;// CONCATENATED MODULE: ./src/module/Cache.ts
3292/**
3293 * Copyright (c) 2017 ~ present NAVER Corp.
3294 * billboard.js project is licensed under the MIT license
3295 */
3296
3297
3298/**
3299 * Constant for cache key
3300 * - NOTE: Prefixed with '$', will be resetted when .load() is called
3301 * @private
3302 */
3303var KEY = {
3304 bubbleBaseLength: "$baseLength",
3305 colorPattern: "__colorPattern__",
3306 dataMinMax: "$dataMinMax",
3307 dataTotalSum: "$dataTotalSum",
3308 dataTotalPerIndex: "$totalPerIndex",
3309 legendItemTextBox: "legendItemTextBox",
3310 radarPoints: "$radarPoints",
3311 setOverOut: "setOverOut",
3312 callOverOutForTouch: "callOverOutForTouch",
3313 textRect: "textRect"
3314};
3315
3316var Cache = /*#__PURE__*/function () {
3317 function Cache() {
3318 this.cache = {};
3319 }
3320
3321 var _proto = Cache.prototype;
3322
3323 /**
3324 * Add cache
3325 * @param {string} key Cache key
3326 * @param {*} value Value to be stored
3327 * @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
3328 * @returns {*} Added data value
3329 * @private
3330 */
3331 _proto.add = function add(key, value, isDataType) {
3332 if (isDataType === void 0) {
3333 isDataType = !1;
3334 }
3335
3336 this.cache[key] = isDataType ? this.cloneTarget(value) : value;
3337 return this.cache[key];
3338 }
3339 /**
3340 * Remove cache
3341 * @param {string|Array} key Cache key
3342 * @private
3343 */
3344 ;
3345
3346 _proto.remove = function remove(key) {
3347 var _this = this;
3348
3349 toArray(key).forEach(function (v) {
3350 return delete _this.cache[v];
3351 });
3352 }
3353 /**
3354 * Get cahce
3355 * @param {string|Array} key Cache key
3356 * @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
3357 * @returns {*}
3358 * @private
3359 */
3360 ;
3361
3362 _proto.get = function get(key, isDataType) {
3363 if (isDataType === void 0) {
3364 isDataType = !1;
3365 }
3366
3367 if (isDataType) {
3368 var targets = [];
3369
3370 for (var i = 0, id; id = key[i]; i++) {
3371 if (id in this.cache) {
3372 targets.push(this.cloneTarget(this.cache[id]));
3373 }
3374 }
3375
3376 return targets;
3377 } else {
3378 var value = this.cache[key];
3379 return isValue(value) ? value : null;
3380 }
3381 }
3382 /**
3383 * Reset cached data
3384 * @param {boolean} all true: reset all data, false: reset only '$' prefixed key data
3385 * @private
3386 */
3387 ;
3388
3389 _proto.reset = function reset(all) {
3390 var $$ = this;
3391
3392 for (var x in $$.cache) {
3393 // reset the prefixed '$' key(which is internal use data) only.
3394 if (all || /^\$/.test(x)) {
3395 $$.cache[x] = null;
3396 }
3397 }
3398 }
3399 /**
3400 * Clone data target object
3401 * @param {object} target Data object
3402 * @returns {object}
3403 * @private
3404 */
3405 // eslint-disable-next-line camelcase
3406 ;
3407
3408 _proto.cloneTarget = function cloneTarget(target) {
3409 return {
3410 id: target.id,
3411 id_org: target.id_org,
3412 values: target.values.map(function (d) {
3413 return {
3414 x: d.x,
3415 value: d.value,
3416 id: d.id
3417 };
3418 })
3419 };
3420 };
3421
3422 return Cache;
3423}();
3424
3425
3426;// CONCATENATED MODULE: ./src/module/generator.ts
3427/**
3428 * Copyright (c) 2017 ~ present NAVER Corp.
3429 * billboard.js project is licensed under the MIT license
3430 */
3431
3432
3433var generator_setTimeout = win.setTimeout,
3434 generator_clearTimeout = win.clearTimeout;
3435/**
3436 * Generate resize queue function
3437 * @returns {Fucntion}
3438 * @private
3439 */
3440
3441function generateResize() {
3442 var fn = [],
3443 timeout,
3444 callResizeFn = function () {
3445 // Delay all resize functions call, to prevent unintended excessive call from resize event
3446 callResizeFn.clear();
3447 timeout = generator_setTimeout(function () {
3448 fn.forEach(function (f) {
3449 return f();
3450 });
3451 }, 200);
3452 };
3453
3454 callResizeFn.clear = function () {
3455 if (timeout) {
3456 generator_clearTimeout(timeout);
3457 timeout = null;
3458 }
3459 };
3460
3461 callResizeFn.add = function (f) {
3462 return fn.push(f);
3463 };
3464
3465 callResizeFn.remove = function (f) {
3466 return fn.splice(fn.indexOf(f), 1);
3467 };
3468
3469 return callResizeFn;
3470}
3471/**
3472 * Generate transition queue function
3473 * @returns {Function}
3474 * @private
3475 */
3476
3477function generateWait() {
3478 var transitionsToWait = [],
3479 f = function (t, callback) {
3480 var timer; // eslint-disable-next-line
3481
3482 function loop() {
3483 var done = 0;
3484
3485 for (var i = 0, _t; _t = transitionsToWait[i]; i++) {
3486 if (_t === !0 || _t.empty != null && _t.empty()) {
3487 done++;
3488 continue;
3489 }
3490
3491 try {
3492 _t.transition();
3493 } catch (e) {
3494 done++;
3495 }
3496 }
3497
3498 timer && generator_clearTimeout(timer);
3499
3500 if (done === transitionsToWait.length) {
3501 callback == null ? void 0 : callback();
3502 } else {
3503 timer = generator_setTimeout(loop, 50);
3504 }
3505 }
3506
3507 loop();
3508 };
3509
3510 f.add = function (t) {
3511 isArray(t) ? transitionsToWait = transitionsToWait.concat(t) : transitionsToWait.push(t);
3512 };
3513
3514 return f;
3515}
3516// EXTERNAL MODULE: external {"commonjs":"d3-dsv","commonjs2":"d3-dsv","amd":"d3-dsv","root":"d3"}
3517var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_require__(5);
3518;// CONCATENATED MODULE: ./src/ChartInternal/data/convert.ts
3519/**
3520 * Copyright (c) 2017 ~ present NAVER Corp.
3521 * billboard.js project is licensed under the MIT license
3522 */
3523
3524
3525/**
3526 * Data convert
3527 * @memberof ChartInternal
3528 * @private
3529 */
3530
3531/* harmony default export */ var convert = ({
3532 /**
3533 * Convert data according its type
3534 * @param {object} args data object
3535 * @param {Function} [callback] callback for url(XHR) type loading
3536 * @returns {object}
3537 * @private
3538 */
3539 convertData: function convertData(args, callback) {
3540 var data;
3541
3542 if (args.bindto) {
3543 data = {};
3544 ["url", "mimeType", "headers", "keys", "json", "keys", "rows", "columns"].forEach(function (v) {
3545 var key = "data_" + v;
3546
3547 if (key in args) {
3548 data[v] = args[key];
3549 }
3550 });
3551 } else {
3552 data = args;
3553 }
3554
3555 if (data.url && callback) {
3556 this.convertUrlToData(data.url, data.mimeType, data.headers, data.keys, callback);
3557 } else if (data.json) {
3558 data = this.convertJsonToData(data.json, data.keys);
3559 } else if (data.rows) {
3560 data = this.convertRowsToData(data.rows);
3561 } else if (data.columns) {
3562 data = this.convertColumnsToData(data.columns);
3563 } else if (args.bindto) {
3564 throw Error("url or json or rows or columns is required.");
3565 }
3566
3567 return isArray(data) && data;
3568 },
3569
3570 /**
3571 * Convert URL data
3572 * @param {string} url Remote URL
3573 * @param {string} mimeType MIME type string: json | csv | tsv
3574 * @param {object} headers Header object
3575 * @param {object} keys Key object
3576 * @param {Function} done Callback function
3577 * @private
3578 */
3579 convertUrlToData: function convertUrlToData(url, mimeType, headers, keys, done) {
3580 var _this = this;
3581
3582 if (mimeType === void 0) {
3583 mimeType = "csv";
3584 }
3585
3586 var req = new XMLHttpRequest();
3587 req.open("GET", url);
3588
3589 if (headers) {
3590 Object.keys(headers).forEach(function (key) {
3591 req.setRequestHeader(key, headers[key]);
3592 });
3593 }
3594
3595 req.onreadystatechange = function () {
3596 if (req.readyState === 4) {
3597 if (req.status === 200) {
3598 var response = req.responseText;
3599 response && done.call(_this, _this["convert" + capitalize(mimeType) + "ToData"](mimeType === "json" ? JSON.parse(response) : response, keys));
3600 } else {
3601 throw new Error(url + ": Something went wrong loading!");
3602 }
3603 }
3604 };
3605
3606 req.send();
3607 },
3608
3609 /**
3610 * Convert CSV/TSV data
3611 * @param {object} parser Parser object
3612 * @param {object} xsv Data
3613 * @private
3614 * @returns {object}
3615 */
3616 convertCsvTsvToData: function convertCsvTsvToData(parser, xsv) {
3617 var rows = parser.rows(xsv),
3618 d;
3619
3620 if (rows.length === 1) {
3621 d = [{}];
3622 rows[0].forEach(function (id) {
3623 d[0][id] = null;
3624 });
3625 } else {
3626 d = parser.parse(xsv);
3627 }
3628
3629 return d;
3630 },
3631 convertCsvToData: function convertCsvToData(xsv) {
3632 return this.convertCsvTsvToData({
3633 rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParseRows,
3634 parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParse
3635 }, xsv);
3636 },
3637 convertTsvToData: function convertTsvToData(tsv) {
3638 return this.convertCsvTsvToData({
3639 rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParseRows,
3640 parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParse
3641 }, tsv);
3642 },
3643 convertJsonToData: function convertJsonToData(json, keysParam) {
3644 var _this2 = this,
3645 config = this.config,
3646 newRows = [],
3647 targetKeys,
3648 data;
3649
3650 if (isArray(json)) {
3651 var keys = keysParam || config.data_keys;
3652
3653 if (keys.x) {
3654 targetKeys = keys.value.concat(keys.x);
3655 config.data_x = keys.x;
3656 } else {
3657 targetKeys = keys.value;
3658 }
3659
3660 newRows.push(targetKeys);
3661 json.forEach(function (o) {
3662 var newRow = targetKeys.map(function (key) {
3663 // convert undefined to null because undefined data will be removed in convertDataToTargets()
3664 var v = _this2.findValueInJson(o, key);
3665
3666 if (isUndefined(v)) {
3667 v = null;
3668 }
3669
3670 return v;
3671 });
3672 newRows.push(newRow);
3673 });
3674 data = this.convertRowsToData(newRows);
3675 } else {
3676 Object.keys(json).forEach(function (key) {
3677 var tmp = json[key].concat();
3678 tmp.unshift(key);
3679 newRows.push(tmp);
3680 });
3681 data = this.convertColumnsToData(newRows);
3682 }
3683
3684 return data;
3685 },
3686 findValueInJson: function findValueInJson(object, path) {
3687 if (object[path] !== undefined) {
3688 return object[path];
3689 }
3690
3691 var convertedPath = path.replace(/\[(\w+)\]/g, ".$1"),
3692 pathArray = convertedPath.replace(/^\./, "").split("."),
3693 target = object; // convert indexes to properties (replace [] with .)
3694
3695 pathArray.some(function (k) {
3696 return !(target = target && k in target ? target[k] : undefined);
3697 });
3698 return target;
3699 },
3700 convertRowsToData: function convertRowsToData(rows) {
3701 var keys = rows[0],
3702 newRows = [];
3703 rows.forEach(function (row, i) {
3704 if (i > 0) {
3705 var newRow = {};
3706 row.forEach(function (v, j) {
3707 if (isUndefined(v)) {
3708 throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
3709 }
3710
3711 newRow[keys[j]] = v;
3712 });
3713 newRows.push(newRow);
3714 }
3715 });
3716 return newRows;
3717 },
3718 convertColumnsToData: function convertColumnsToData(columns) {
3719 var newRows = [];
3720 columns.forEach(function (col, i) {
3721 var key = col[0];
3722 col.forEach(function (v, j) {
3723 if (j > 0) {
3724 if (isUndefined(newRows[j - 1])) {
3725 newRows[j - 1] = {};
3726 }
3727
3728 if (isUndefined(v)) {
3729 throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
3730 }
3731
3732 newRows[j - 1][key] = v;
3733 }
3734 });
3735 });
3736 return newRows;
3737 },
3738 convertDataToTargets: function convertDataToTargets(data, appendXs) {
3739 var _this3 = this,
3740 $$ = this,
3741 axis = $$.axis,
3742 config = $$.config,
3743 state = $$.state,
3744 isCategorized = !1,
3745 isTimeSeries = !1,
3746 isCustomX = !1;
3747
3748 if (axis) {
3749 isCategorized = axis.isCategorized();
3750 isTimeSeries = axis.isTimeSeries();
3751 isCustomX = axis.isCustomX();
3752 }
3753
3754 var dataKeys = Object.keys(data[0] || {}),
3755 ids = dataKeys.length ? dataKeys.filter($$.isNotX, $$) : [],
3756 xs = dataKeys.length ? dataKeys.filter($$.isX, $$) : [],
3757 xsData;
3758 // save x for update data by load when custom x and bb.x API
3759 ids.forEach(function (id) {
3760 var xKey = _this3.getXKey(id);
3761
3762 if (isCustomX || isTimeSeries) {
3763 // if included in input data
3764 if (xs.indexOf(xKey) >= 0) {
3765 xsData = (appendXs && $$.data.xs[id] || []).concat(data.map(function (d) {
3766 return d[xKey];
3767 }).filter(isValue).map(function (rawX, i) {
3768 return $$.generateTargetX(rawX, id, i);
3769 }));
3770 } else if (config.data_x) {
3771 // if not included in input data, find from preloaded data of other id's x
3772 xsData = _this3.getOtherTargetXs();
3773 } else if (notEmpty(config.data_xs)) {
3774 // if not included in input data, find from preloaded data
3775 xsData = $$.getXValuesOfXKey(xKey, $$.data.targets);
3776 } // MEMO: if no x included, use same x of current will be used
3777
3778 } else {
3779 xsData = data.map(function (d, i) {
3780 return i;
3781 });
3782 }
3783
3784 xsData && (_this3.data.xs[id] = xsData);
3785 }); // check x is defined
3786
3787 ids.forEach(function (id) {
3788 if (!_this3.data.xs[id]) {
3789 throw new Error("x is not defined for id = \"" + id + "\".");
3790 }
3791 }); // convert to target
3792
3793 var targets = ids.map(function (id, index) {
3794 var convertedId = config.data_idConverter.bind($$.api)(id),
3795 xKey = $$.getXKey(id),
3796 isCategory = isCustomX && isCategorized,
3797 hasCategory = isCategory && data.map(function (v) {
3798 return v.x;
3799 }).every(function (v) {
3800 return config.axis_x_categories.indexOf(v) > -1;
3801 }),
3802 isDataAppend = data.__append__,
3803 xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0;
3804 return {
3805 id: convertedId,
3806 id_org: id,
3807 values: data.map(function (d, i) {
3808 var rawX = d[xKey],
3809 value = d[id],
3810 x;
3811 value = value !== null && !isNaN(value) && !isObject(value) ? +value : isArray(value) || isObject(value) ? value : null; // use x as categories if custom x and categorized
3812
3813 if ((isCategory || state.hasRadar) && index === 0 && !isUndefined(rawX)) {
3814 if (!hasCategory && index === 0 && i === 0 && !isDataAppend) {
3815 config.axis_x_categories = [];
3816 }
3817
3818 x = config.axis_x_categories.indexOf(rawX);
3819
3820 if (x === -1) {
3821 x = config.axis_x_categories.length;
3822 config.axis_x_categories.push(rawX);
3823 }
3824 } else {
3825 x = $$.generateTargetX(rawX, id, xIndex + i);
3826 } // mark as x = undefined if value is undefined and filter to remove after mapped
3827
3828
3829 if (isUndefined(value) || $$.data.xs[id].length <= i) {
3830 x = undefined;
3831 }
3832
3833 return {
3834 x: x,
3835 value: value,
3836 id: convertedId
3837 };
3838 }).filter(function (v) {
3839 return isDefined(v.x);
3840 })
3841 };
3842 }); // finish targets
3843
3844 targets.forEach(function (t) {
3845 // sort values by its x
3846 if (config.data_xSort) {
3847 t.values = t.values.sort(function (v1, v2) {
3848 var x1 = v1.x || v1.x === 0 ? v1.x : Infinity,
3849 x2 = v2.x || v2.x === 0 ? v2.x : Infinity;
3850 return x1 - x2;
3851 });
3852 } // indexing each value
3853
3854
3855 t.values.forEach(function (v, i) {
3856 return v.index = i;
3857 }); // this needs to be sorted because its index and value.index is identical
3858
3859 $$.data.xs[t.id].sort(function (v1, v2) {
3860 return v1 - v2;
3861 });
3862 }); // cache information about values
3863
3864 state.hasNegativeValue = $$.hasNegativeValueInTargets(targets);
3865 state.hasPositiveValue = $$.hasPositiveValueInTargets(targets); // set target types
3866
3867 if (config.data_type) {
3868 $$.setTargetType($$.mapToIds(targets).filter(function (id) {
3869 return !(id in config.data_types);
3870 }), config.data_type);
3871 } // cache as original id keyed
3872
3873
3874 targets.forEach(function (d) {
3875 return $$.cache.add(d.id_org, d, !0);
3876 });
3877 return targets;
3878 }
3879});
3880;// CONCATENATED MODULE: ./src/ChartInternal/data/data.ts
3881/**
3882 * Copyright (c) 2017 ~ present NAVER Corp.
3883 * billboard.js project is licensed under the MIT license
3884 */
3885
3886
3887
3888/* harmony default export */ var data_data = ({
3889 isX: function isX(key) {
3890 var $$ = this,
3891 config = $$.config,
3892 dataKey = config.data_x && key === config.data_x,
3893 existValue = notEmpty(config.data_xs) && hasValue(config.data_xs, key);
3894 return dataKey || existValue;
3895 },
3896 isNotX: function isNotX(key) {
3897 return !this.isX(key);
3898 },
3899 isStackNormalized: function isStackNormalized() {
3900 var config = this.config;
3901 return !!(config.data_stack_normalize && config.data_groups.length);
3902 },
3903 isGrouped: function isGrouped(id) {
3904 var groups = this.config.data_groups;
3905 return id ? groups.some(function (v) {
3906 return v.indexOf(id) >= 0 && v.length > 1;
3907 }) : groups.length > 0;
3908 },
3909 getXKey: function getXKey(id) {
3910 var $$ = this,
3911 config = $$.config;
3912 return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null;
3913 },
3914 getXValuesOfXKey: function getXValuesOfXKey(key, targets) {
3915 var $$ = this,
3916 ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : [],
3917 xValues;
3918 ids.forEach(function (id) {
3919 if ($$.getXKey(id) === key) {
3920 xValues = $$.data.xs[id];
3921 }
3922 });
3923 return xValues;
3924 },
3925
3926 /**
3927 * Get index number based on given x Axis value
3928 * @param {Date|number|string} x x Axis to be compared
3929 * @param {Array} basedX x Axis list to be based on
3930 * @returns {number} index number
3931 * @private
3932 */
3933 getIndexByX: function getIndexByX(x, basedX) {
3934 var $$ = this;
3935 return basedX ? basedX.indexOf(isString(x) ? x : +x) : ($$.filterByX($$.data.targets, x)[0] || {
3936 index: null
3937 }).index;
3938 },
3939 getXValue: function getXValue(id, i) {
3940 var $$ = this;
3941 return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i;
3942 },
3943 getOtherTargetXs: function getOtherTargetXs() {
3944 var $$ = this,
3945 idsForX = Object.keys($$.data.xs);
3946 return idsForX.length ? $$.data.xs[idsForX[0]] : null;
3947 },
3948 getOtherTargetX: function getOtherTargetX(index) {
3949 var xs = this.getOtherTargetXs();
3950 return xs && index < xs.length ? xs[index] : null;
3951 },
3952 addXs: function addXs(xs) {
3953 var $$ = this,
3954 config = $$.config;
3955 Object.keys(xs).forEach(function (id) {
3956 config.data_xs[id] = xs[id];
3957 });
3958 },
3959 isMultipleX: function isMultipleX() {
3960 return notEmpty(this.config.data_xs) || !this.config.data_xSort || this.hasType("bubble") || this.hasType("scatter");
3961 },
3962 addName: function addName(data) {
3963 var $$ = this,
3964 config = $$.config,
3965 name;
3966
3967 if (data) {
3968 name = config.data_names[data.id];
3969 data.name = name !== undefined ? name : data.id;
3970 }
3971
3972 return data;
3973 },
3974
3975 /**
3976 * Get all values on given index
3977 * @param {number} index Index
3978 * @param {boolean} filterNull Filter nullish value
3979 * @returns {Array}
3980 * @private
3981 */
3982 getAllValuesOnIndex: function getAllValuesOnIndex(index, filterNull) {
3983 if (filterNull === void 0) {
3984 filterNull = !1;
3985 }
3986
3987 var $$ = this,
3988 value = $$.filterTargetsToShow($$.data.targets).map(function (t) {
3989 return $$.addName($$.getValueOnIndex(t.values, index));
3990 });
3991
3992 if (filterNull) {
3993 value = value.filter(function (v) {
3994 return isValue(v.value);
3995 });
3996 }
3997
3998 return value;
3999 },
4000 getValueOnIndex: function getValueOnIndex(values, index) {
4001 var valueOnIndex = values.filter(function (v) {
4002 return v.index === index;
4003 });
4004 return valueOnIndex.length ? valueOnIndex[0] : null;
4005 },
4006 updateTargetX: function updateTargetX(targets, x) {
4007 var $$ = this;
4008 targets.forEach(function (t) {
4009 t.values.forEach(function (v, i) {
4010 v.x = $$.generateTargetX(x[i], t.id, i);
4011 });
4012 $$.data.xs[t.id] = x;
4013 });
4014 },
4015 updateTargetXs: function updateTargetXs(targets, xs) {
4016 var $$ = this;
4017 targets.forEach(function (t) {
4018 xs[t.id] && $$.updateTargetX([t], xs[t.id]);
4019 });
4020 },
4021 generateTargetX: function generateTargetX(rawX, id, index) {
4022 var _axis,
4023 $$ = this,
4024 axis = $$.axis,
4025 x = (_axis = axis) != null && _axis.isCategorized() ? index : rawX || index,
4026 _axis2,
4027 _axis3,
4028 _axis4;
4029
4030 if ((_axis2 = axis) != null && _axis2.isTimeSeries()) {
4031 var fn = parseDate.bind($$);
4032 x = rawX ? fn(rawX) : fn($$.getXValue(id, index));
4033 } else if ((_axis3 = axis) != null && _axis3.isCustomX() && !((_axis4 = axis) != null && _axis4.isCategorized())) {
4034 x = isValue(rawX) ? +rawX : $$.getXValue(id, index);
4035 }
4036
4037 return x;
4038 },
4039 updateXs: function updateXs(values) {
4040 if (values.length) {
4041 this.axis.xs = values.map(function (v) {
4042 return v.x;
4043 });
4044 }
4045 },
4046 getPrevX: function getPrevX(i) {
4047 var x = this.axis.xs[i - 1];
4048 return isDefined(x) ? x : null;
4049 },
4050 getNextX: function getNextX(i) {
4051 var x = this.axis.xs[i + 1];
4052 return isDefined(x) ? x : null;
4053 },
4054
4055 /**
4056 * Get base value isAreaRangeType
4057 * @param {object} data Data object
4058 * @returns {number}
4059 * @private
4060 */
4061 getBaseValue: function getBaseValue(data) {
4062 var $$ = this,
4063 hasAxis = $$.state.hasAxis,
4064 value = data.value;
4065
4066 // In case of area-range, data is given as: [low, mid, high] or {low, mid, high}
4067 // will take the 'mid' as the base value
4068 if (value && hasAxis) {
4069 if ($$.isAreaRangeType(data)) {
4070 value = $$.getRangedData(data, "mid");
4071 } else if ($$.isBubbleZType(data)) {
4072 value = $$.getBubbleZData(value, "y");
4073 }
4074 }
4075
4076 return value;
4077 },
4078
4079 /**
4080 * Get min/max value from the data
4081 * @private
4082 * @param {Array} data array data to be evaluated
4083 * @returns {{min: {number}, max: {number}}}
4084 */
4085 getMinMaxValue: function getMinMaxValue(data) {
4086 var getBaseValue = this.getBaseValue.bind(this),
4087 min,
4088 max;
4089 (data || this.data.targets.map(function (t) {
4090 return t.values;
4091 })).forEach(function (v, i) {
4092 var value = v.map(getBaseValue).filter(isNumber);
4093 min = Math.min.apply(Math, [i ? min : Infinity].concat(value));
4094 max = Math.max.apply(Math, [i ? max : -Infinity].concat(value));
4095 });
4096 return {
4097 min: min,
4098 max: max
4099 };
4100 },
4101
4102 /**
4103 * Get the min/max data
4104 * @private
4105 * @returns {{min: Array, max: Array}}
4106 */
4107 getMinMaxData: function getMinMaxData() {
4108 var $$ = this,
4109 cacheKey = KEY.dataMinMax,
4110 minMaxData = $$.cache.get(cacheKey);
4111
4112 if (!minMaxData) {
4113 var data = $$.data.targets.map(function (t) {
4114 return t.values;
4115 }),
4116 minMax = $$.getMinMaxValue(data),
4117 min = [],
4118 max = [];
4119 data.forEach(function (v) {
4120 var minData = $$.getFilteredDataByValue(v, minMax.min),
4121 maxData = $$.getFilteredDataByValue(v, minMax.max);
4122
4123 if (minData.length) {
4124 min = min.concat(minData);
4125 }
4126
4127 if (maxData.length) {
4128 max = max.concat(maxData);
4129 }
4130 }); // update the cached data
4131
4132 $$.cache.add(cacheKey, minMaxData = {
4133 min: min,
4134 max: max
4135 });
4136 }
4137
4138 return minMaxData;
4139 },
4140
4141 /**
4142 * Get sum of data per index
4143 * @private
4144 * @returns {Array}
4145 */
4146 getTotalPerIndex: function getTotalPerIndex() {
4147 var $$ = this,
4148 cacheKey = KEY.dataTotalPerIndex,
4149 sum = $$.cache.get(cacheKey);
4150
4151 if ($$.isStackNormalized() && !sum) {
4152 sum = [];
4153 $$.data.targets.forEach(function (row) {
4154 row.values.forEach(function (v, i) {
4155 if (!sum[i]) {
4156 sum[i] = 0;
4157 }
4158
4159 sum[i] += isNumber(v.value) ? v.value : 0;
4160 });
4161 });
4162 }
4163
4164 return sum;
4165 },
4166
4167 /**
4168 * Get total data sum
4169 * @param {boolean} subtractHidden Subtract hidden data from total
4170 * @returns {number}
4171 * @private
4172 */
4173 getTotalDataSum: function getTotalDataSum(subtractHidden) {
4174 var $$ = this,
4175 cacheKey = KEY.dataTotalSum,
4176 total = $$.cache.get(cacheKey);
4177
4178 if (!isNumber(total)) {
4179 var sum = mergeArray($$.data.targets.map(function (t) {
4180 return t.values;
4181 })).map(function (v) {
4182 return v.value;
4183 }).reduce(function (p, c) {
4184 return p + c;
4185 });
4186 $$.cache.add(cacheKey, total = sum);
4187 }
4188
4189 if (subtractHidden) {
4190 total -= $$.getHiddenTotalDataSum();
4191 }
4192
4193 return total;
4194 },
4195
4196 /**
4197 * Get total hidden data sum
4198 * @returns {number}
4199 * @private
4200 */
4201 getHiddenTotalDataSum: function getHiddenTotalDataSum() {
4202 var $$ = this,
4203 api = $$.api,
4204 hiddenTargetIds = $$.state.hiddenTargetIds,
4205 total = 0;
4206
4207 if (hiddenTargetIds.length) {
4208 total = api.data.values.bind(api)(hiddenTargetIds).reduce(function (p, c) {
4209 return p + c;
4210 });
4211 }
4212
4213 return total;
4214 },
4215
4216 /**
4217 * Get filtered data by value
4218 * @param {object} data Data
4219 * @param {number} value Value to be filtered
4220 * @returns {Array} filtered array data
4221 * @private
4222 */
4223 getFilteredDataByValue: function getFilteredDataByValue(data, value) {
4224 var _this = this;
4225
4226 return data.filter(function (t) {
4227 return _this.getBaseValue(t) === value;
4228 });
4229 },
4230
4231 /**
4232 * Return the max length of the data
4233 * @returns {number} max data length
4234 * @private
4235 */
4236 getMaxDataCount: function getMaxDataCount() {
4237 return Math.max.apply(Math, this.data.targets.map(function (t) {
4238 return t.values.length;
4239 }));
4240 },
4241 getMaxDataCountTarget: function getMaxDataCountTarget() {
4242 var target = this.filterTargetsToShow() || [],
4243 length = target.length;
4244
4245 if (length > 1) {
4246 target = target.map(function (t) {
4247 return t.values;
4248 }).reduce(function (a, b) {
4249 return a.concat(b);
4250 }).map(function (v) {
4251 return v.x;
4252 });
4253 target = sortValue(getUnique(target)).map(function (x, index) {
4254 return {
4255 x: x,
4256 index: index
4257 };
4258 });
4259 } else if (length) {
4260 target = target[0].values;
4261 }
4262
4263 return target;
4264 },
4265 mapToIds: function mapToIds(targets) {
4266 return targets.map(function (d) {
4267 return d.id;
4268 });
4269 },
4270 mapToTargetIds: function mapToTargetIds(ids) {
4271 var $$ = this;
4272 return ids ? isArray(ids) ? ids.concat() : [ids] : $$.mapToIds($$.data.targets);
4273 },
4274 hasTarget: function hasTarget(targets, id) {
4275 var ids = this.mapToIds(targets);
4276
4277 for (var i = 0, val; val = ids[i]; i++) {
4278 if (val === id) {
4279 return !0;
4280 }
4281 }
4282
4283 return !1;
4284 },
4285 isTargetToShow: function isTargetToShow(targetId) {
4286 return this.state.hiddenTargetIds.indexOf(targetId) < 0;
4287 },
4288 isLegendToShow: function isLegendToShow(targetId) {
4289 return this.state.hiddenLegendIds.indexOf(targetId) < 0;
4290 },
4291 filterTargetsToShow: function filterTargetsToShow(targets) {
4292 var $$ = this;
4293 return (targets || $$.data.targets).filter(function (t) {
4294 return $$.isTargetToShow(t.id);
4295 });
4296 },
4297 mapTargetsToUniqueXs: function mapTargetsToUniqueXs(targets) {
4298 var $$ = this,
4299 axis = $$.axis,
4300 xs = [];
4301
4302 if (targets != null && targets.length) {
4303 var _axis5;
4304
4305 xs = getUnique(mergeArray(targets.map(function (t) {
4306 return t.values.map(function (v) {
4307 return +v.x;
4308 });
4309 })));
4310 xs = (_axis5 = axis) != null && _axis5.isTimeSeries() ? xs.map(function (x) {
4311 return new Date(+x);
4312 }) : xs.map(Number);
4313 }
4314
4315 return sortValue(xs);
4316 },
4317
4318 /**
4319 * Add to the state target Ids
4320 * @param {string} type State's prop name
4321 * @param {Array|string} targetIds Target ids array
4322 * @private
4323 */
4324 addTargetIds: function addTargetIds(type, targetIds) {
4325 var state = this.state,
4326 ids = isArray(targetIds) ? targetIds : [targetIds];
4327 ids.forEach(function (v) {
4328 state[type].indexOf(v) < 0 && state[type].push(v);
4329 });
4330 },
4331
4332 /**
4333 * Remove from the state target Ids
4334 * @param {string} type State's prop name
4335 * @param {Array|string} targetIds Target ids array
4336 * @private
4337 */
4338 removeTargetIds: function removeTargetIds(type, targetIds) {
4339 var state = this.state,
4340 ids = isArray(targetIds) ? targetIds : [targetIds];
4341 ids.forEach(function (v) {
4342 var index = state[type].indexOf(v);
4343 index >= 0 && state[type].splice(index, 1);
4344 });
4345 },
4346 addHiddenTargetIds: function addHiddenTargetIds(targetIds) {
4347 this.addTargetIds("hiddenTargetIds", targetIds);
4348 },
4349 removeHiddenTargetIds: function removeHiddenTargetIds(targetIds) {
4350 this.removeTargetIds("hiddenTargetIds", targetIds);
4351 },
4352 addHiddenLegendIds: function addHiddenLegendIds(targetIds) {
4353 this.addTargetIds("hiddenLegendIds", targetIds);
4354 },
4355 removeHiddenLegendIds: function removeHiddenLegendIds(targetIds) {
4356 this.removeTargetIds("hiddenLegendIds", targetIds);
4357 },
4358 getValuesAsIdKeyed: function getValuesAsIdKeyed(targets) {
4359 var $$ = this,
4360 hasAxis = $$.state.hasAxis,
4361 ys = {},
4362 isMultipleX = $$.isMultipleX(),
4363 xs = isMultipleX ? $$.mapTargetsToUniqueXs(targets).map(function (v) {
4364 return isString(v) ? v : +v;
4365 }) : null;
4366 targets.forEach(function (t) {
4367 var data = [];
4368 t.values.filter(function (_ref) {
4369 var value = _ref.value;
4370 return isValue(value) || value === null;
4371 }).forEach(function (v) {
4372 var value = v.value; // exclude 'volume' value to correct mis domain calculation
4373
4374 if (value !== null && $$.isCandlestickType(v)) {
4375 value = isArray(value) ? value.slice(0, 4) : [value.open, value.high, value.low, value.close];
4376 }
4377
4378 if (isArray(value)) {
4379 data.push.apply(data, value);
4380 } else if (isObject(value) && "high" in value) {
4381 data.push.apply(data, Object.values(value));
4382 } else if ($$.isBubbleZType(v)) {
4383 data.push(hasAxis && $$.getBubbleZData(value, "y"));
4384 } else {
4385 if (isMultipleX) {
4386 data[$$.getIndexByX(v.x, xs)] = value;
4387 } else {
4388 data.push(value);
4389 }
4390 }
4391 });
4392 ys[t.id] = data;
4393 });
4394 return ys;
4395 },
4396 checkValueInTargets: function checkValueInTargets(targets, checker) {
4397 var ids = Object.keys(targets),
4398 values;
4399
4400 for (var i = 0; i < ids.length; i++) {
4401 values = targets[ids[i]].values;
4402
4403 for (var j = 0; j < values.length; j++) {
4404 if (checker(values[j].value)) {
4405 return !0;
4406 }
4407 }
4408 }
4409
4410 return !1;
4411 },
4412 hasMultiTargets: function hasMultiTargets() {
4413 return this.filterTargetsToShow().length > 1;
4414 },
4415 hasNegativeValueInTargets: function hasNegativeValueInTargets(targets) {
4416 return this.checkValueInTargets(targets, function (v) {
4417 return v < 0;
4418 });
4419 },
4420 hasPositiveValueInTargets: function hasPositiveValueInTargets(targets) {
4421 return this.checkValueInTargets(targets, function (v) {
4422 return v > 0;
4423 });
4424 },
4425
4426 /**
4427 * Sort targets data
4428 * @param {Array} targetsValue Target value
4429 * @returns {Array}
4430 * @private
4431 */
4432 orderTargets: function orderTargets(targetsValue) {
4433 var $$ = this,
4434 targets = [].concat(targetsValue),
4435 fn = $$.getSortCompareFn();
4436 fn && targets.sort(fn);
4437 return targets;
4438 },
4439
4440 /**
4441 * Get data.order compare function
4442 * @param {boolean} isArc Is for Arc type sort or not
4443 * @returns {Function} compare function
4444 * @private
4445 */
4446 getSortCompareFn: function getSortCompareFn(isArc) {
4447 if (isArc === void 0) {
4448 isArc = !1;
4449 }
4450
4451 var $$ = this,
4452 config = $$.config,
4453 order = config.data_order,
4454 orderAsc = /asc/i.test(order),
4455 orderDesc = /desc/i.test(order),
4456 fn;
4457
4458 if (orderAsc || orderDesc) {
4459 var reducer = function (p, c) {
4460 return p + Math.abs(c.value);
4461 };
4462
4463 fn = function (t1, t2) {
4464 var t1Sum = t1.values.reduce(reducer, 0),
4465 t2Sum = t2.values.reduce(reducer, 0);
4466 return isArc ? orderAsc ? t1Sum - t2Sum : t2Sum - t1Sum : orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum;
4467 };
4468 } else if (isFunction(order)) {
4469 fn = order.bind($$.api);
4470 }
4471
4472 return fn || null;
4473 },
4474 filterByX: function filterByX(targets, x) {
4475 return mergeArray(targets.map(function (t) {
4476 return t.values;
4477 })).filter(function (v) {
4478 return v.x - x === 0;
4479 });
4480 },
4481 filterRemoveNull: function filterRemoveNull(data) {
4482 var _this2 = this;
4483
4484 return data.filter(function (d) {
4485 return isValue(_this2.getBaseValue(d));
4486 });
4487 },
4488 filterByXDomain: function filterByXDomain(targets, xDomain) {
4489 return targets.map(function (t) {
4490 return {
4491 id: t.id,
4492 id_org: t.id_org,
4493 values: t.values.filter(function (v) {
4494 return xDomain[0] <= v.x && v.x <= xDomain[1];
4495 })
4496 };
4497 });
4498 },
4499 hasDataLabel: function hasDataLabel() {
4500 var dataLabels = this.config.data_labels;
4501 return isboolean(dataLabels) && dataLabels || isObjectType(dataLabels) && notEmpty(dataLabels);
4502 },
4503
4504 /**
4505 * Get data index from the event coodinates
4506 * @param {Event} event Event object
4507 * @returns {number}
4508 */
4509 getDataIndexFromEvent: function getDataIndexFromEvent(event) {
4510 var $$ = this,
4511 config = $$.config,
4512 _$$$state = $$.state,
4513 inputType = _$$$state.inputType,
4514 _$$$state$eventReceiv = _$$$state.eventReceiver,
4515 coords = _$$$state$eventReceiv.coords,
4516 rect = _$$$state$eventReceiv.rect,
4517 isRotated = config.axis_rotated,
4518 e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event,
4519 index = findIndex(coords, isRotated ? e.clientY - rect.top : e.clientX - rect.left, 0, coords.length - 1, isRotated);
4520 return index;
4521 },
4522 getDataLabelLength: function getDataLabelLength(min, max, key) {
4523 var $$ = this,
4524 lengths = [0, 0];
4525 $$.$el.chart.select("svg").selectAll(".dummy").data([min, max]).enter().append("text").text(function (d) {
4526 return $$.dataLabelFormat(d.id)(d);
4527 }).each(function (d, i) {
4528 lengths[i] = this.getBoundingClientRect()[key] * 1.3;
4529 }).remove();
4530 return lengths;
4531 },
4532 isNoneArc: function isNoneArc(d) {
4533 return this.hasTarget(this.data.targets, d.id);
4534 },
4535 isArc: function isArc(d) {
4536 return "data" in d && this.hasTarget(this.data.targets, d.data.id);
4537 },
4538 findSameXOfValues: function findSameXOfValues(values, index) {
4539 var targetX = values[index].x,
4540 sames = [],
4541 i;
4542
4543 for (i = index - 1; i >= 0; i--) {
4544 if (targetX !== values[i].x) {
4545 break;
4546 }
4547
4548 sames.push(values[i]);
4549 }
4550
4551 for (i = index; i < values.length; i++) {
4552 if (targetX !== values[i].x) {
4553 break;
4554 }
4555
4556 sames.push(values[i]);
4557 }
4558
4559 return sames;
4560 },
4561 findClosestFromTargets: function findClosestFromTargets(targets, pos) {
4562 var $$ = this,
4563 candidates = targets.map(function (target) {
4564 return $$.findClosest(target.values, pos);
4565 });
4566 // map to array of closest points of each target
4567 // decide closest point and return
4568 return $$.findClosest(candidates, pos);
4569 },
4570 findClosest: function findClosest(values, pos) {
4571 var $$ = this,
4572 config = $$.config,
4573 main = $$.$el.main,
4574 data = values.filter(function (v) {
4575 return v && isValue(v.value);
4576 }),
4577 minDist = config.point_sensitivity,
4578 closest;
4579 // find mouseovering bar
4580 data.filter(function (v) {
4581 return $$.isBarType(v.id);
4582 }).forEach(function (v) {
4583 var shape = main.select("." + config_classes.bars + $$.getTargetSelectorSuffix(v.id) + " ." + config_classes.bar + "-" + v.index).node();
4584
4585 if (!closest && $$.isWithinBar(shape)) {
4586 closest = v;
4587 }
4588 }); // find closest point from non-bar
4589
4590 data.filter(function (v) {
4591 return !$$.isBarType(v.id);
4592 }).forEach(function (v) {
4593 var d = $$.dist(v, pos);
4594
4595 if (d < minDist) {
4596 minDist = d;
4597 closest = v;
4598 }
4599 });
4600 return closest;
4601 },
4602 dist: function dist(data, pos) {
4603 var $$ = this,
4604 isRotated = $$.config.axis_rotated,
4605 scale = $$.scale,
4606 xIndex = isRotated ? 1 : 0,
4607 yIndex = isRotated ? 0 : 1,
4608 y = $$.circleY(data, data.index),
4609 x = (scale.zoom || scale.x)(data.x);
4610 return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
4611 },
4612
4613 /**
4614 * Convert data for step type
4615 * @param {Array} values Object data values
4616 * @returns {Array}
4617 * @private
4618 */
4619 convertValuesToStep: function convertValuesToStep(values) {
4620 var $$ = this,
4621 axis = $$.axis,
4622 config = $$.config,
4623 stepType = config.line_step_type,
4624 isCategorized = axis ? axis.isCategorized() : !1,
4625 converted = isArray(values) ? values.concat() : [values];
4626
4627 if (!(isCategorized || /step\-(after|before)/.test(stepType))) {
4628 return values;
4629 } // insert & append cloning first/last value to be fully rendered covering on each gap sides
4630
4631
4632 var head = converted[0],
4633 tail = converted[converted.length - 1],
4634 id = head.id,
4635 x = head.x;
4636 // insert head
4637 converted.unshift({
4638 x: --x,
4639 value: head.value,
4640 id: id
4641 });
4642 isCategorized && stepType === "step-after" && converted.unshift({
4643 x: --x,
4644 value: head.value,
4645 id: id
4646 }); // append tail
4647
4648 x = tail.x;
4649 converted.push({
4650 x: ++x,
4651 value: tail.value,
4652 id: id
4653 });
4654 isCategorized && stepType === "step-before" && converted.push({
4655 x: ++x,
4656 value: tail.value,
4657 id: id
4658 });
4659 return converted;
4660 },
4661 convertValuesToRange: function convertValuesToRange(values) {
4662 var converted = isArray(values) ? values.concat() : [values],
4663 ranges = [];
4664 converted.forEach(function (range) {
4665 var x = range.x,
4666 id = range.id;
4667 ranges.push({
4668 x: x,
4669 id: id,
4670 value: range.value[0]
4671 });
4672 ranges.push({
4673 x: x,
4674 id: id,
4675 value: range.value[2]
4676 });
4677 });
4678 return ranges;
4679 },
4680 updateDataAttributes: function updateDataAttributes(name, attrs) {
4681 var $$ = this,
4682 config = $$.config,
4683 current = config["data_" + name];
4684
4685 if (isUndefined(attrs)) {
4686 return current;
4687 }
4688
4689 Object.keys(attrs).forEach(function (id) {
4690 current[id] = attrs[id];
4691 });
4692 $$.redraw({
4693 withLegend: !0
4694 });
4695 return current;
4696 },
4697 getRangedData: function getRangedData(d, key, type) {
4698 if (key === void 0) {
4699 key = "";
4700 }
4701
4702 if (type === void 0) {
4703 type = "areaRange";
4704 }
4705
4706 var value = d == null ? void 0 : d.value;
4707
4708 if (isArray(value)) {
4709 // @ts-ignore
4710 var index = {
4711 areaRange: ["high", "mid", "low"],
4712 candlestick: ["open", "high", "low", "close", "volume"]
4713 }[type].indexOf(key);
4714 return index >= 0 && value ? value[index] : undefined;
4715 } else if (value) {
4716 return value[key];
4717 }
4718
4719 return value;
4720 },
4721
4722 /**
4723 * Get ratio value
4724 * @param {string} type Ratio for given type
4725 * @param {object} d Data value object
4726 * @param {boolean} asPercent Convert the return as percent or not
4727 * @returns {number} Ratio value
4728 * @private
4729 */
4730 getRatio: function getRatio(type, d, asPercent) {
4731 if (asPercent === void 0) {
4732 asPercent = !1;
4733 }
4734
4735 var $$ = this,
4736 config = $$.config,
4737 state = $$.state,
4738 api = $$.api,
4739 ratio = 0;
4740
4741 if (d && api.data.shown().length) {
4742 ratio = d.ratio || d.value;
4743
4744 if (type === "arc") {
4745 // if has padAngle set, calculate rate based on value
4746 if ($$.pie.padAngle()()) {
4747 ratio = d.value / $$.getTotalDataSum(!0); // otherwise, based on the rendered angle value
4748 } else {
4749 var gaugeArcLength = config.gauge_fullCircle ? $$.getArcLength() : $$.getStartAngle() * -2,
4750 arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
4751 ratio = (d.endAngle - d.startAngle) / arcLength;
4752 }
4753 } else if (type === "index") {
4754 var dataValues = api.data.values.bind(api),
4755 total = this.getTotalPerIndex();
4756
4757 if (state.hiddenTargetIds.length) {
4758 var hiddenSum = dataValues(state.hiddenTargetIds, !1);
4759
4760 if (hiddenSum.length) {
4761 hiddenSum = hiddenSum.reduce(function (acc, curr) {
4762 return acc.map(function (v, i) {
4763 return (isNumber(v) ? v : 0) + curr[i];
4764 });
4765 });
4766 total = total.map(function (v, i) {
4767 return v - hiddenSum[i];
4768 });
4769 }
4770 }
4771
4772 d.ratio = isNumber(d.value) && total && total[d.index] > 0 ? d.value / total[d.index] : 0;
4773 ratio = d.ratio;
4774 } else if (type === "radar") {
4775 ratio = parseFloat(Math.max(d.value, 0) + "") / state.current.dataMax * config.radar_size_ratio;
4776 } else if (type === "bar") {
4777 var yScale = $$.getYScaleById.bind($$)(d.id),
4778 max = yScale.domain().reduce(function (a, c) {
4779 return c - a;
4780 });
4781 // when all data are 0, return 0
4782 ratio = max === 0 ? 0 : Math.abs(d.value) / max;
4783 }
4784 }
4785
4786 return asPercent && ratio ? ratio * 100 : ratio;
4787 },
4788
4789 /**
4790 * Sort data index to be aligned with x axis.
4791 * @param {Array} tickValues Tick array values
4792 * @private
4793 */
4794 updateDataIndexByX: function updateDataIndexByX(tickValues) {
4795 var $$ = this,
4796 tickValueMap = tickValues.reduce(function (out, tick, index) {
4797 out[+tick.x] = index;
4798 return out;
4799 }, {});
4800 $$.data.targets.forEach(function (t) {
4801 t.values.forEach(function (value, valueIndex) {
4802 var index = tickValueMap[+value.x];
4803
4804 if (index === undefined) {
4805 index = valueIndex;
4806 }
4807
4808 value.index = index;
4809 });
4810 });
4811 },
4812
4813 /**
4814 * Determine if bubble has dimension data
4815 * @param {object|Array} d data value
4816 * @returns {boolean}
4817 * @private
4818 */
4819 isBubbleZType: function isBubbleZType(d) {
4820 var $$ = this;
4821 return $$.isBubbleType(d) && (isObject(d.value) && ("z" in d.value || "y" in d.value) || isArray(d.value) && d.value.length === 2);
4822 },
4823
4824 /**
4825 * Get data object by id
4826 * @param {string} id data id
4827 * @returns {object}
4828 * @private
4829 */
4830 getDataById: function getDataById(id) {
4831 var _d$,
4832 d = this.cache.get(id) || this.api.data(id);
4833
4834 return (_d$ = d == null ? void 0 : d[0]) != null ? _d$ : d;
4835 }
4836});
4837;// CONCATENATED MODULE: ./src/ChartInternal/data/load.ts
4838/**
4839 * Copyright (c) 2017 ~ present NAVER Corp.
4840 * billboard.js project is licensed under the MIT license
4841 */
4842
4843
4844/* harmony default export */ var load = ({
4845 load: function load(rawTargets, args) {
4846 var _args$done,
4847 $$ = this,
4848 append = args.append,
4849 targets = rawTargets;
4850
4851 if (targets) {
4852 // filter loading targets if needed
4853 if (args.filter) {
4854 targets = targets.filter(args.filter);
4855 } // set type if args.types || args.type specified
4856
4857
4858 if (args.type || args.types) {
4859 targets.forEach(function (t) {
4860 var _args$types,
4861 type = ((_args$types = args.types) == null ? void 0 : _args$types[t.id]) || args.type;
4862
4863 $$.setTargetType(t.id, type);
4864 });
4865 } // Update/Add data
4866
4867
4868 $$.data.targets.forEach(function (d) {
4869 for (var i = 0; i < targets.length; i++) {
4870 if (d.id === targets[i].id) {
4871 d.values = append ? d.values.concat(targets[i].values) : targets[i].values;
4872 targets.splice(i, 1);
4873 break;
4874 }
4875 }
4876 });
4877 $$.data.targets = $$.data.targets.concat(targets); // add remained
4878 } // Set targets
4879
4880
4881 $$.updateTargets($$.data.targets); // Redraw with new targets
4882
4883 $$.redraw({
4884 withUpdateOrgXDomain: !0,
4885 withUpdateXDomain: !0,
4886 withLegend: !0
4887 }); // Update current state chart type and elements list after redraw
4888
4889 $$.updateTypesElements();
4890 (_args$done = args.done) == null ? void 0 : _args$done.call($$.api);
4891 },
4892 loadFromArgs: function loadFromArgs(args) {
4893 var $$ = this; // prevent load when chart is already destroyed
4894
4895 if (!$$.config) {
4896 return;
4897 } // reset internally cached data
4898
4899
4900 $$.cache.reset();
4901 var data = args.data || $$.convertData(args, function (d) {
4902 return $$.load($$.convertDataToTargets(d), args);
4903 });
4904 args.append && (data.__append__ = !0);
4905 data && $$.load($$.convertDataToTargets(data), args);
4906 },
4907 unload: function unload(rawTargetIds, customDoneCb) {
4908 var $$ = this,
4909 state = $$.state,
4910 $el = $$.$el,
4911 $T = $$.$T,
4912 done = customDoneCb,
4913 targetIds = rawTargetIds;
4914 // reset internally cached data
4915 $$.cache.reset();
4916
4917 if (!done) {
4918 done = function () {};
4919 } // filter existing target
4920
4921
4922 targetIds = targetIds.filter(function (id) {
4923 return $$.hasTarget($$.data.targets, id);
4924 }); // If no target, call done and return
4925
4926 if (!targetIds || targetIds.length === 0) {
4927 done();
4928 return;
4929 }
4930
4931 var targets = $el.svg.selectAll(targetIds.map(function (id) {
4932 return $$.selectorTarget(id);
4933 }));
4934 $T(targets).style("opacity", "0").remove().call(endall, done);
4935 targetIds.forEach(function (id) {
4936 // Reset fadein for future load
4937 state.withoutFadeIn[id] = !1; // Remove target's elements
4938
4939 if ($el.legend) {
4940 $el.legend.selectAll("." + config_classes.legendItem + $$.getTargetSelectorSuffix(id)).remove();
4941 } // Remove target
4942
4943
4944 $$.data.targets = $$.data.targets.filter(function (t) {
4945 return t.id !== id;
4946 });
4947 }); // Update current state chart type and elements list after redraw
4948
4949 $$.updateTypesElements();
4950 }
4951});
4952// EXTERNAL MODULE: external {"commonjs":"d3-drag","commonjs2":"d3-drag","amd":"d3-drag","root":"d3"}
4953var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack_require__(7);
4954;// CONCATENATED MODULE: ./src/ChartInternal/interactions/interaction.ts
4955/**
4956 * Copyright (c) 2017 ~ present NAVER Corp.
4957 * billboard.js project is licensed under the MIT license
4958 */
4959
4960
4961
4962
4963
4964/* harmony default export */ var interactions_interaction = ({
4965 selectRectForSingle: function selectRectForSingle(context, eventRect, index) {
4966 var $$ = this,
4967 config = $$.config,
4968 main = $$.$el.main,
4969 isSelectionEnabled = config.data_selection_enabled,
4970 isSelectionGrouped = config.data_selection_grouped,
4971 isSelectable = config.data_selection_isselectable,
4972 isTooltipGrouped = config.tooltip_grouped,
4973 selectedData = $$.getAllValuesOnIndex(index);
4974
4975 if (isTooltipGrouped) {
4976 $$.showTooltip(selectedData, context);
4977 $$.showGridFocus == null ? void 0 : $$.showGridFocus(selectedData);
4978
4979 if (!isSelectionEnabled || isSelectionGrouped) {
4980 return;
4981 }
4982 }
4983
4984 main.selectAll("." + config_classes.shape + "-" + index).each(function () {
4985 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.EXPANDED, !0);
4986
4987 if (isSelectionEnabled) {
4988 eventRect.style("cursor", isSelectionGrouped ? "pointer" : null);
4989 }
4990
4991 if (!isTooltipGrouped) {
4992 $$.hideGridFocus == null ? void 0 : $$.hideGridFocus();
4993 $$.hideTooltip();
4994 isSelectionGrouped || $$.setExpand(index);
4995 }
4996 }).filter(function (d) {
4997 return $$.isWithinShape(this, d);
4998 }).call(function (selected) {
4999 var _isSelectable,
5000 d = selected.data();
5001
5002 if (isSelectionEnabled && (isSelectionGrouped || (_isSelectable = isSelectable) != null && _isSelectable.bind($$.api)(d))) {
5003 eventRect.style("cursor", "pointer");
5004 }
5005
5006 if (!isTooltipGrouped) {
5007 $$.showTooltip(d, context);
5008 $$.showGridFocus == null ? void 0 : $$.showGridFocus(d);
5009 $$.unexpandCircles == null ? void 0 : $$.unexpandCircles();
5010 selected.each(function (d) {
5011 return $$.setExpand(index, d.id);
5012 });
5013 }
5014 });
5015 },
5016
5017 /**
5018 * Expand data shape/point
5019 * @param {number} index Index number
5020 * @param {string} id Data id
5021 * @param {boolean} reset Reset expand state
5022 * @private
5023 */
5024 setExpand: function setExpand(index, id, reset) {
5025 var $$ = this,
5026 config = $$.config,
5027 circle = $$.$el.circle;
5028 circle && config.point_focus_expand_enabled && $$.expandCircles(index, id, reset); // bar, candlestick
5029
5030 $$.expandBarTypeShapes(!0, index, id, reset);
5031 },
5032
5033 /**
5034 * Expand/Unexpand bar type shapes
5035 * @param {boolean} expand Expand or unexpand
5036 * @param {number} i Shape index
5037 * @param {string} id Data id
5038 * @param {boolean} reset Reset expand style
5039 * @private
5040 */
5041 expandBarTypeShapes: function expandBarTypeShapes(expand, i, id, reset) {
5042 if (expand === void 0) {
5043 expand = !0;
5044 }
5045
5046 var $$ = this;
5047 ["bar", "candlestick"].filter(function (v) {
5048 return $$.$el[v];
5049 }).forEach(function (v) {
5050 reset && $$.$el[v].classed(config_classes.EXPANDED, !1);
5051 $$.getShapeByIndex(v, i, id).classed(config_classes.EXPANDED, expand);
5052 });
5053 },
5054
5055 /**
5056 * Handle data.onover/out callback options
5057 * @param {boolean} isOver Over or not
5058 * @param {number|object} d data object
5059 * @private
5060 */
5061 setOverOut: function setOverOut(isOver, d) {
5062 var $$ = this,
5063 config = $$.config,
5064 hasRadar = $$.state.hasRadar,
5065 main = $$.$el.main,
5066 isArc = isObject(d);
5067
5068 // Call event handler
5069 if (isArc || d !== -1) {
5070 var callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
5071 config.color_onover && $$.setOverColor(isOver, d, isArc);
5072
5073 if (isArc) {
5074 callback(d, main.select("." + config_classes.arc + $$.getTargetSelectorSuffix(d.id)).node());
5075 } else if (!config.tooltip_grouped) {
5076 var last = $$.cache.get(KEY.setOverOut) || [],
5077 shape = main.selectAll("." + config_classes.shape + "-" + d).filter(function (d) {
5078 return $$.isWithinShape(this, d);
5079 });
5080 shape.each(function (d) {
5081 var _this = this;
5082
5083 if (last.length === 0 || last.every(function (v) {
5084 return v !== _this;
5085 })) {
5086 callback(d, this);
5087 last.push(this);
5088 }
5089 });
5090
5091 if (last.length > 0 && shape.empty()) {
5092 callback = config.data_onout.bind($$.api);
5093 last.forEach(function (v) {
5094 return callback((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(v).datum(), v);
5095 });
5096 last = [];
5097 }
5098
5099 $$.cache.add(KEY.setOverOut, last);
5100 } else {
5101 if (isOver) {
5102 config.point_focus_only && hasRadar ? $$.showCircleFocus($$.getAllValuesOnIndex(d, !0)) : $$.setExpand(d, null, !0);
5103 }
5104
5105 $$.isMultipleX() || main.selectAll("." + config_classes.shape + "-" + d).each(function (d) {
5106 callback(d, this);
5107 });
5108 }
5109 }
5110 },
5111
5112 /**
5113 * Call data.onover/out callback for touch event
5114 * @param {number|object} d target index or data object for Arc type
5115 * @private
5116 */
5117 callOverOutForTouch: function callOverOutForTouch(d) {
5118 var $$ = this,
5119 last = $$.cache.get(KEY.callOverOutForTouch);
5120
5121 if (isObject(d) && last ? d.id !== last.id : d !== last) {
5122 (last || isNumber(last)) && $$.setOverOut(!1, last);
5123 (d || isNumber(d)) && $$.setOverOut(!0, d);
5124 $$.cache.add(KEY.callOverOutForTouch, d);
5125 }
5126 },
5127
5128 /**
5129 * Return draggable selection function
5130 * @returns {Function}
5131 * @private
5132 */
5133 getDraggableSelection: function getDraggableSelection() {
5134 var $$ = this,
5135 config = $$.config,
5136 state = $$.state;
5137 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) {
5138 state.event = event;
5139 $$.drag(getPointer(event, this));
5140 }).on("start", function (event) {
5141 state.event = event;
5142 $$.dragstart(getPointer(event, this));
5143 }).on("end", function (event) {
5144 state.event = event;
5145 $$.dragend();
5146 }) : function () {};
5147 },
5148
5149 /**
5150 * Dispatch a mouse event.
5151 * @private
5152 * @param {string} type event type
5153 * @param {number} index Index of eventRect
5154 * @param {Array} mouse x and y coordinate value
5155 */
5156 dispatchEvent: function dispatchEvent(type, index, mouse) {
5157 var $$ = this,
5158 config = $$.config,
5159 _$$$state = $$.state,
5160 eventReceiver = _$$$state.eventReceiver,
5161 hasAxis = _$$$state.hasAxis,
5162 hasRadar = _$$$state.hasRadar,
5163 _$$$$el = $$.$el,
5164 eventRect = _$$$$el.eventRect,
5165 arcs = _$$$$el.arcs,
5166 radar = _$$$$el.radar,
5167 isMultipleX = $$.isMultipleX(),
5168 element = (hasRadar ? radar.axes.select("." + config_classes.axis + "-" + index + " text") : eventRect || arcs.selectAll("." + config_classes.target + " path").filter(function (d, i) {
5169 return i === index;
5170 })).node(),
5171 _element$getBoundingC = element.getBoundingClientRect(),
5172 width = _element$getBoundingC.width,
5173 left = _element$getBoundingC.left,
5174 top = _element$getBoundingC.top;
5175
5176 if (hasAxis && !hasRadar && !isMultipleX) {
5177 var coords = eventReceiver.coords[index];
5178 width = coords.w;
5179 left += coords.x;
5180 top += coords.y;
5181 }
5182
5183 var x = left + (mouse ? mouse[0] : 0) + (isMultipleX || config.axis_rotated ? 0 : width / 2),
5184 y = top + (mouse ? mouse[1] : 0);
5185 emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](element, type, {
5186 screenX: x,
5187 screenY: y,
5188 clientX: x,
5189 clientY: y
5190 });
5191 },
5192 setDragStatus: function setDragStatus(isDragging) {
5193 this.state.dragging = isDragging;
5194 },
5195
5196 /**
5197 * Unbind zoom events
5198 * @private
5199 */
5200 unbindZoomEvent: function unbindZoomEvent() {
5201 var _zoomResetBtn,
5202 $$ = this,
5203 _$$$$el2 = $$.$el,
5204 eventRect = _$$$$el2.eventRect,
5205 zoomResetBtn = _$$$$el2.zoomResetBtn;
5206
5207 eventRect.on(".zoom", null).on(".drag", null);
5208 (_zoomResetBtn = zoomResetBtn) == null ? void 0 : _zoomResetBtn.style("display", "none");
5209 }
5210});
5211;// CONCATENATED MODULE: ./src/ChartInternal/internals/class.ts
5212/**
5213 * Copyright (c) 2017 ~ present NAVER Corp.
5214 * billboard.js project is licensed under the MIT license
5215 */
5216
5217/* harmony default export */ var internals_class = ({
5218 generateClass: function generateClass(prefix, targetId) {
5219 return " " + prefix + " " + (prefix + this.getTargetSelectorSuffix(targetId));
5220 },
5221
5222 /**
5223 * Get class string
5224 * @param {string} type Shape type
5225 * @param {boolean} withShape Get with shape prefix
5226 * @returns {string} Class string
5227 * @private
5228 */
5229 getClass: function getClass(type, withShape) {
5230 var _this = this,
5231 isPlural = /s$/.test(type),
5232 useIdKey = /^(area|arc|line)s?$/.test(type),
5233 key = isPlural ? "id" : "index";
5234
5235 return function (d) {
5236 var data = d.data || d,
5237 result = (withShape ? _this.generateClass(config_classes[isPlural ? "shapes" : "shape"], data[key]) : "") + _this.generateClass(config_classes[type], data[useIdKey ? "id" : key]);
5238
5239 return result.trim();
5240 };
5241 },
5242
5243 /**
5244 * Get chart class string
5245 * @param {string} type Shape type
5246 * @returns {string} Class string
5247 * @private
5248 */
5249 getChartClass: function getChartClass(type) {
5250 var _this2 = this;
5251
5252 return function (d) {
5253 return config_classes["chart" + type] + _this2.classTarget((d.data ? d.data : d).id);
5254 };
5255 },
5256 generateExtraLineClass: function generateExtraLineClass() {
5257 var $$ = this,
5258 classes = $$.config.line_classes || [],
5259 ids = [];
5260 return function (d) {
5261 var _d$data,
5262 id = d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d;
5263
5264 if (ids.indexOf(id) < 0) {
5265 ids.push(id);
5266 }
5267
5268 return classes[ids.indexOf(id) % classes.length];
5269 };
5270 },
5271 classRegion: function classRegion(d, i) {
5272 return this.generateClass(config_classes.region, i) + " " + ("class" in d ? d.class : "");
5273 },
5274 classTarget: function classTarget(id) {
5275 var additionalClassSuffix = this.config.data_classes[id],
5276 additionalClass = "";
5277
5278 if (additionalClassSuffix) {
5279 additionalClass = " " + config_classes.target + "-" + additionalClassSuffix;
5280 }
5281
5282 return this.generateClass(config_classes.target, id) + additionalClass;
5283 },
5284 classFocus: function classFocus(d) {
5285 return this.classFocused(d) + this.classDefocused(d);
5286 },
5287 classFocused: function classFocused(d) {
5288 return " " + (this.state.focusedTargetIds.indexOf(d.id) >= 0 ? config_classes.focused : "");
5289 },
5290 classDefocused: function classDefocused(d) {
5291 return " " + (this.state.defocusedTargetIds.indexOf(d.id) >= 0 ? config_classes.defocused : "");
5292 },
5293 getTargetSelectorSuffix: function getTargetSelectorSuffix(targetId) {
5294 var targetStr = targetId || targetId === 0 ? "-" + targetId : "";
5295 return targetStr.replace(/([\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\])/g, "-");
5296 },
5297 selectorTarget: function selectorTarget(id, prefix) {
5298 var pfx = prefix || "",
5299 target = this.getTargetSelectorSuffix(id);
5300 // select target & circle
5301 return pfx + "." + (config_classes.target + target) + ", " + pfx + "." + (config_classes.circles + target);
5302 },
5303 selectorTargets: function selectorTargets(idsValue, prefix) {
5304 var _this3 = this,
5305 ids = idsValue || [];
5306
5307 return ids.length ? ids.map(function (id) {
5308 return _this3.selectorTarget(id, prefix);
5309 }) : null;
5310 },
5311 selectorLegend: function selectorLegend(id) {
5312 return "." + (config_classes.legendItem + this.getTargetSelectorSuffix(id));
5313 },
5314 selectorLegends: function selectorLegends(ids) {
5315 var _this4 = this;
5316
5317 return ids != null && ids.length ? ids.map(function (id) {
5318 return _this4.selectorLegend(id);
5319 }) : null;
5320 }
5321});
5322;// CONCATENATED MODULE: ./src/ChartInternal/internals/category.ts
5323/**
5324 * Copyright (c) 2017 ~ present NAVER Corp.
5325 * billboard.js project is licensed under the MIT license
5326 */
5327/* harmony default export */ var category = ({
5328 /**
5329 * Category Name
5330 * @param {number} i Index number
5331 * @returns {string} category Name
5332 * @private
5333 */
5334 categoryName: function categoryName(i) {
5335 var categories = this.config.axis_x_categories;
5336 return i < (categories == null ? void 0 : categories.length) ? categories[i] : i;
5337 }
5338});
5339// EXTERNAL MODULE: external {"commonjs":"d3-scale","commonjs2":"d3-scale","amd":"d3-scale","root":"d3"}
5340var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webpack_require__(6);
5341;// CONCATENATED MODULE: ./src/ChartInternal/internals/color.ts
5342/**
5343 * Copyright (c) 2017 ~ present NAVER Corp.
5344 * billboard.js project is licensed under the MIT license
5345 */
5346
5347
5348
5349
5350
5351
5352/**
5353 * Set pattern's background color
5354 * (it adds a <rect> element to simulate bg-color)
5355 * @param {SVGPatternElement} pattern SVG pattern element
5356 * @param {string} color Color string
5357 * @param {string} id ID to be set
5358 * @returns {{id: string, node: SVGPatternElement}}
5359 * @private
5360 */
5361
5362var colorizePattern = function (pattern, color, id) {
5363 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(!0));
5364 node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color);
5365 return {
5366 id: id,
5367 node: node.node()
5368 };
5369},
5370 schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"]; // Replacement of d3.schemeCategory10.
5371// Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
5372
5373
5374/* harmony default export */ var internals_color = ({
5375 /**
5376 * Get color pattern from CSS file
5377 * CSS should be defined as: background-image: url("#00c73c;#fa7171; ...");
5378 * @returns {Array}
5379 * @private
5380 */
5381 getColorFromCss: function getColorFromCss() {
5382 var cacheKey = KEY.colorPattern,
5383 body = browser_doc.body,
5384 pattern = body[cacheKey];
5385
5386 if (!pattern) {
5387 var span = browser_doc.createElement("span");
5388 span.className = config_classes.colorPattern;
5389 span.style.display = "none";
5390 body.appendChild(span);
5391 var content = win.getComputedStyle(span).backgroundImage;
5392 span.parentNode.removeChild(span);
5393
5394 if (content.indexOf(";") > -1) {
5395 pattern = content.replace(/url[^#]*|["'()]|(\s|%20)/g, "").split(";").map(function (v) {
5396 return v.trim().replace(/[\"'\s]/g, "");
5397 }).filter(Boolean);
5398 body[cacheKey] = pattern;
5399 }
5400 }
5401
5402 return pattern;
5403 },
5404 generateColor: function generateColor() {
5405 var $$ = this,
5406 config = $$.config,
5407 colors = config.data_colors,
5408 callback = config.data_color,
5409 ids = [],
5410 pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)($$.getColorFromCss() || schemeCategory10).range(),
5411 originalColorPattern = pattern;
5412
5413 if (isFunction(config.color_tiles)) {
5414 var tiles = config.color_tiles.bind($$.api)(),
5415 colorizedPatterns = pattern.map(function (p, index) {
5416 var color = p.replace(/[#\(\)\s,]/g, ""),
5417 id = $$.state.datetimeId + "-pattern-" + color + "-" + index;
5418 return colorizePattern(tiles[index % tiles.length], p, id);
5419 }); // Add background color to patterns
5420
5421 pattern = colorizedPatterns.map(function (p) {
5422 return "url(#" + p.id + ")";
5423 });
5424 $$.patterns = colorizedPatterns;
5425 }
5426
5427 return function (d) {
5428 var _d$data,
5429 id = d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d,
5430 isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id],
5431 color;
5432
5433 // if callback function is provided
5434 if (isFunction(colors[id])) {
5435 color = colors[id].bind($$.api)(d); // if specified, choose that color
5436 } else if (colors[id]) {
5437 color = colors[id]; // if not specified, choose from pattern
5438 } else {
5439 if (ids.indexOf(id) < 0) {
5440 ids.push(id);
5441 }
5442
5443 color = isLine ? originalColorPattern[ids.indexOf(id) % originalColorPattern.length] : pattern[ids.indexOf(id) % pattern.length];
5444 colors[id] = color;
5445 }
5446
5447 return isFunction(callback) ? callback.bind($$.api)(color, d) : color;
5448 };
5449 },
5450 generateLevelColor: function generateLevelColor() {
5451 var $$ = this,
5452 config = $$.config,
5453 colors = config.color_pattern,
5454 threshold = config.color_threshold,
5455 asValue = threshold.unit === "value",
5456 max = threshold.max || 100,
5457 values = threshold.values && threshold.values.length ? threshold.values : [];
5458 return notEmpty(threshold) ? function (value) {
5459 var v = asValue ? value : value * 100 / max,
5460 color = colors[colors.length - 1];
5461
5462 for (var i = 0, l = values.length; i < l; i++) {
5463 if (v <= values[i]) {
5464 color = colors[i];
5465 break;
5466 }
5467 }
5468
5469 return color;
5470 } : null;
5471 },
5472
5473 /**
5474 * Append data backgound color filter definition
5475 * @private
5476 */
5477 generateDataLabelBackgroundColorFilter: function generateDataLabelBackgroundColorFilter() {
5478 var $$ = this,
5479 $el = $$.$el,
5480 config = $$.config,
5481 state = $$.state,
5482 backgroundColors = config.data_labels_backgroundColors;
5483
5484 if (backgroundColors) {
5485 var ids = [];
5486
5487 if (isString(backgroundColors)) {
5488 ids.push("");
5489 } else if (isObject(backgroundColors)) {
5490 ids = Object.keys(backgroundColors);
5491 }
5492
5493 ids.forEach(function (v) {
5494 var id = state.datetimeId + "-labels-bg" + $$.getTargetSelectorSuffix(v);
5495 $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\"/>");
5496 });
5497 }
5498 },
5499
5500 /**
5501 * Set the data over color.
5502 * When is out, will restate in its previous color value
5503 * @param {boolean} isOver true: set overed color, false: restore
5504 * @param {number|object} d target index or data object for Arc type
5505 * @private
5506 */
5507 setOverColor: function setOverColor(isOver, d) {
5508 var $$ = this,
5509 config = $$.config,
5510 main = $$.$el.main,
5511 onover = config.color_onover,
5512 color = isOver ? onover : $$.color;
5513
5514 if (isObject(color)) {
5515 color = function (_ref) {
5516 var id = _ref.id;
5517 return id in onover ? onover[id] : $$.color(id);
5518 };
5519 } else if (isString(color)) {
5520 color = function () {
5521 return onover;
5522 };
5523 } else if (isFunction(onover)) {
5524 color = color.bind($$.api);
5525 }
5526
5527 main.selectAll(isObject(d) ? // when is Arc type
5528 "." + config_classes.arc + $$.getTargetSelectorSuffix(d.id) : "." + config_classes.shape + "-" + d).style("fill", color);
5529 }
5530});
5531;// CONCATENATED MODULE: ./src/ChartInternal/internals/domain.ts
5532/**
5533 * Copyright (c) 2017 ~ present NAVER Corp.
5534 * billboard.js project is licensed under the MIT license
5535 */
5536
5537
5538/* harmony default export */ var domain = ({
5539 getYDomainMinMax: function getYDomainMinMax(targets, type) {
5540 var $$ = this,
5541 axis = $$.axis,
5542 config = $$.config,
5543 isMin = type === "min",
5544 dataGroups = config.data_groups,
5545 ids = $$.mapToIds(targets),
5546 ys = $$.getValuesAsIdKeyed(targets);
5547
5548 if (dataGroups.length > 0) {
5549 var hasValue = $$["has" + (isMin ? "Negative" : "Positive") + "ValueInTargets"](targets);
5550 dataGroups.forEach(function (groupIds) {
5551 // Determine baseId
5552 var idsInGroup = groupIds.filter(function (v) {
5553 return ids.indexOf(v) >= 0;
5554 });
5555
5556 if (idsInGroup.length) {
5557 var baseId = idsInGroup[0],
5558 baseAxisId = axis.getId(baseId);
5559
5560 // Initialize base value. Set to 0 if not match with the condition
5561 if (hasValue && ys[baseId]) {
5562 ys[baseId] = ys[baseId].map(function (v) {
5563 return (isMin ? v < 0 : v > 0) ? v : 0;
5564 });
5565 }
5566
5567 idsInGroup.filter(function (v, i) {
5568 return i > 0;
5569 }).forEach(function (id) {
5570 if (ys[id]) {
5571 var axisId = axis.getId(id);
5572 ys[id].forEach(function (v, i) {
5573 var val = +v,
5574 meetCondition = isMin ? val > 0 : val < 0;
5575
5576 if (axisId === baseAxisId && !(hasValue && meetCondition)) {
5577 ys[baseId][i] += val;
5578 }
5579 });
5580 }
5581 });
5582 }
5583 });
5584 }
5585
5586 return getMinMax(type, Object.keys(ys).map(function (key) {
5587 return getMinMax(type, ys[key]);
5588 }));
5589 },
5590
5591 /**
5592 * Check if hidden targets bound to the given axis id
5593 * @param {string} id ID to be checked
5594 * @returns {boolean}
5595 * @private
5596 */
5597 isHiddenTargetWithYDomain: function isHiddenTargetWithYDomain(id) {
5598 var $$ = this;
5599 return $$.state.hiddenTargetIds.some(function (v) {
5600 return $$.axis.getId(v) === id;
5601 });
5602 },
5603 getYDomain: function getYDomain(targets, axisId, xDomain) {
5604 var _scale,
5605 $$ = this,
5606 axis = $$.axis,
5607 config = $$.config,
5608 scale = $$.scale,
5609 pfx = "axis_" + axisId;
5610
5611 if ($$.isStackNormalized()) {
5612 return [0, 100];
5613 }
5614
5615 var isLog = ((_scale = scale) == null ? void 0 : _scale[axisId]) && scale[axisId].type === "log",
5616 targetsByAxisId = targets.filter(function (t) {
5617 return axis.getId(t.id) === axisId;
5618 }),
5619 yTargets = xDomain ? $$.filterByXDomain(targetsByAxisId, xDomain) : targetsByAxisId;
5620
5621 if (yTargets.length === 0) {
5622 // use domain of the other axis if target of axisId is none
5623 if ($$.isHiddenTargetWithYDomain(axisId)) {
5624 return scale[axisId].domain();
5625 } else {
5626 return axisId === "y2" ? scale.y.domain() : // When all data bounds to y2, y Axis domain is called prior y2.
5627 // So, it needs to call to get y2 domain here
5628 $$.getYDomain(targets, "y2", xDomain);
5629 }
5630 }
5631
5632 var yMin = config[pfx + "_min"],
5633 yMax = config[pfx + "_max"],
5634 center = config[pfx + "_center"],
5635 isInverted = config[pfx + "_inverted"],
5636 showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated,
5637 showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated,
5638 yDomainMin = $$.getYDomainMinMax(yTargets, "min"),
5639 yDomainMax = $$.getYDomainMinMax(yTargets, "max"),
5640 isZeroBased = [TYPE.BAR, TYPE.BUBBLE, TYPE.SCATTER].concat(TYPE_BY_CATEGORY.Line).some(function (v) {
5641 var type = v.indexOf("area") > -1 ? "area" : v;
5642 return $$.hasType(v, yTargets) && config[type + "_zerobased"];
5643 });
5644 // MEMO: avoid inverting domain unexpectedly
5645 yDomainMin = isValue(yMin) ? yMin : isValue(yMax) ? yDomainMin < yMax ? yDomainMin : yMax - 10 : yDomainMin;
5646 yDomainMax = isValue(yMax) ? yMax : isValue(yMin) ? yMin < yDomainMax ? yDomainMax : yMin + 10 : yDomainMax;
5647
5648 if (isNaN(yDomainMin)) {
5649 // set minimum to zero when not number
5650 yDomainMin = 0;
5651 }
5652
5653 if (isNaN(yDomainMax)) {
5654 // set maximum to have same value as yDomainMin
5655 yDomainMax = yDomainMin;
5656 }
5657
5658 if (yDomainMin === yDomainMax) {
5659 yDomainMin < 0 ? yDomainMax = 0 : yDomainMin = 0;
5660 }
5661
5662 var isAllPositive = yDomainMin >= 0 && yDomainMax >= 0,
5663 isAllNegative = yDomainMin <= 0 && yDomainMax <= 0;
5664
5665 // Cancel zerobased if axis_*_min / axis_*_max specified
5666 if (isValue(yMin) && isAllPositive || isValue(yMax) && isAllNegative) {
5667 isZeroBased = !1;
5668 } // Bar/Area chart should be 0-based if all positive|negative
5669
5670
5671 if (isZeroBased) {
5672 isAllPositive && (yDomainMin = 0);
5673 isAllNegative && (yDomainMax = 0);
5674 }
5675
5676 var domainLength = Math.abs(yDomainMax - yDomainMin),
5677 padding = {
5678 top: domainLength * .1,
5679 bottom: domainLength * .1
5680 };
5681
5682 if (isDefined(center)) {
5683 var yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
5684 yDomainMax = center + yDomainAbs;
5685 yDomainMin = center - yDomainAbs;
5686 } // add padding for data label
5687
5688
5689 if (showHorizontalDataLabel) {
5690 var diff = diffDomain(scale.y.range()),
5691 ratio = $$.getDataLabelLength(yDomainMin, yDomainMax, "width").map(function (v) {
5692 return v / diff;
5693 });
5694 ["bottom", "top"].forEach(function (v, i) {
5695 padding[v] += domainLength * (ratio[i] / (1 - ratio[0] - ratio[1]));
5696 });
5697 } else if (showVerticalDataLabel) {
5698 var lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, "height");
5699 ["bottom", "top"].forEach(function (v, i) {
5700 padding[v] += $$.convertPixelToScale("y", lengths[i], domainLength);
5701 });
5702 } // if padding is set, the domain will be updated relative the current domain value
5703 // ex) $$.height=300, padding.top=150, domainLength=4 --> domain=6
5704
5705
5706 var p = config[pfx + "_padding"];
5707
5708 if (notEmpty(p)) {
5709 ["bottom", "top"].forEach(function (v) {
5710 padding[v] = axis.getPadding(p, v, padding[v], domainLength);
5711 });
5712 } // Bar/Area chart should be 0-based if all positive|negative
5713
5714
5715 if (isZeroBased) {
5716 isAllPositive && (padding.bottom = yDomainMin);
5717 isAllNegative && (padding.top = -yDomainMax);
5718 }
5719
5720 var domain = isLog ? [yDomainMin, yDomainMax].map(function (v) {
5721 return v < 0 ? 0 : v;
5722 }) : [yDomainMin - padding.bottom, yDomainMax + padding.top];
5723 return isInverted ? domain.reverse() : domain;
5724 },
5725 getXDomainMinMax: function getXDomainMinMax(targets, type) {
5726 var _$$$axis,
5727 $$ = this,
5728 configValue = $$.config["axis_x_" + type],
5729 dataValue = getMinMax(type, targets.map(function (t) {
5730 return getMinMax(type, t.values.map(function (v) {
5731 return v.x;
5732 }));
5733 })),
5734 value = isObject(configValue) ? configValue.value : configValue;
5735
5736 value = isDefined(value) && (_$$$axis = $$.axis) != null && _$$$axis.isTimeSeries() ? parseDate.bind(this)(value) : value;
5737
5738 if (isObject(configValue) && configValue.fit && (type === "min" && value < dataValue || type === "max" && value > dataValue)) {
5739 value = undefined;
5740 }
5741
5742 return isDefined(value) ? value : dataValue;
5743 },
5744
5745 /**
5746 * Get x Axis padding
5747 * @param {Array} domain x Axis domain
5748 * @param {number} tickCount Tick count
5749 * @returns {object} Padding object values with 'left' & 'right' key
5750 * @private
5751 */
5752 getXDomainPadding: function getXDomainPadding(domain, tickCount) {
5753 var $$ = this,
5754 axis = $$.axis,
5755 config = $$.config,
5756 padding = config.axis_x_padding,
5757 isTimeSeriesTickCount = axis.isTimeSeries() && tickCount,
5758 diff = diffDomain(domain),
5759 defaultValue;
5760
5761 // determine default padding value
5762 if (axis.isCategorized() || isTimeSeriesTickCount) {
5763 defaultValue = 0;
5764 } else if ($$.hasType("bar")) {
5765 var maxDataCount = $$.getMaxDataCount();
5766 defaultValue = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : .5;
5767 } else {
5768 defaultValue = diff * .01;
5769 }
5770
5771 var _ref = isNumber(padding) ? {
5772 left: padding,
5773 right: padding
5774 } : padding,
5775 _ref$left = _ref.left,
5776 left = _ref$left === void 0 ? defaultValue : _ref$left,
5777 _ref$right = _ref.right,
5778 right = _ref$right === void 0 ? defaultValue : _ref$right; // when the unit is pixel, convert pixels to axis scale value
5779
5780
5781 if (padding.unit === "px") {
5782 var domainLength = Math.abs(diff + diff * .2);
5783 left = axis.getPadding(padding, "left", defaultValue, domainLength);
5784 right = axis.getPadding(padding, "right", defaultValue, domainLength);
5785 } else {
5786 var range = diff + left + right;
5787
5788 if (isTimeSeriesTickCount && range) {
5789 var relativeTickWidth = diff / tickCount / range;
5790 left = left / range / relativeTickWidth;
5791 right = right / range / relativeTickWidth;
5792 }
5793 }
5794
5795 return {
5796 left: left,
5797 right: right
5798 };
5799 },
5800
5801 /**
5802 * Get x Axis domain
5803 * @param {Array} targets targets
5804 * @returns {Array} x Axis domain
5805 * @private
5806 */
5807 getXDomain: function getXDomain(targets) {
5808 var $$ = this,
5809 axis = $$.axis,
5810 x = $$.scale.x,
5811 domain = [$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")],
5812 _domain = domain,
5813 _domain$ = _domain[0],
5814 min = _domain$ === void 0 ? 0 : _domain$,
5815 _domain$2 = _domain[1],
5816 max = _domain$2 === void 0 ? 0 : _domain$2;
5817
5818 if (x.type !== "log") {
5819 var isCategorized = axis.isCategorized(),
5820 isTimeSeries = axis.isTimeSeries(),
5821 padding = $$.getXDomainPadding(domain),
5822 _domain2 = domain,
5823 firstX = _domain2[0],
5824 lastX = _domain2[1];
5825
5826 // show center of x domain if min and max are the same
5827 if (firstX - lastX === 0 && !isCategorized) {
5828 if (isTimeSeries) {
5829 firstX = new Date(firstX.getTime() * .5);
5830 lastX = new Date(lastX.getTime() * 1.5);
5831 } else {
5832 firstX = firstX === 0 ? 1 : firstX * .5;
5833 lastX = lastX === 0 ? -1 : lastX * 1.5;
5834 }
5835 }
5836
5837 if (firstX || firstX === 0) {
5838 min = isTimeSeries ? new Date(firstX.getTime() - padding.left) : firstX - padding.left;
5839 }
5840
5841 if (lastX || lastX === 0) {
5842 max = isTimeSeries ? new Date(lastX.getTime() + padding.right) : lastX + padding.right;
5843 }
5844 }
5845
5846 return [min, max];
5847 },
5848 updateXDomain: function updateXDomain(targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
5849 var $$ = this,
5850 config = $$.config,
5851 org = $$.org,
5852 _$$$scale = $$.scale,
5853 x = _$$$scale.x,
5854 subX = _$$$scale.subX,
5855 zoomEnabled = config.zoom_enabled;
5856
5857 if (withUpdateOrgXDomain) {
5858 var _$$$brush;
5859
5860 x.domain(domain || sortValue($$.getXDomain(targets)));
5861 org.xDomain = x.domain();
5862 zoomEnabled && $$.zoom.updateScaleExtent();
5863 subX.domain(x.domain());
5864 (_$$$brush = $$.brush) == null ? void 0 : _$$$brush.scale(subX);
5865 }
5866
5867 if (withUpdateXDomain) {
5868 var domainValue = domain || !$$.brush || brushEmpty($$) ? org.xDomain : getBrushSelection($$).map(subX.invert);
5869 x.domain(domainValue);
5870 zoomEnabled && $$.zoom.updateScaleExtent();
5871 } // Trim domain when too big by zoom mousemove event
5872
5873
5874 withTrim && x.domain($$.trimXDomain(x.orgDomain()));
5875 return x.domain();
5876 },
5877 trimXDomain: function trimXDomain(domain) {
5878 var zoomDomain = this.getZoomDomain(),
5879 min = zoomDomain[0],
5880 max = zoomDomain[1];
5881
5882 if (domain[0] <= min) {
5883 domain[1] = +domain[1] + (min - domain[0]);
5884 domain[0] = min;
5885 }
5886
5887 if (max <= domain[1]) {
5888 domain[0] = +domain[0] - (domain[1] - max);
5889 domain[1] = max;
5890 }
5891
5892 return domain;
5893 },
5894
5895 /**
5896 * Get zoom domain
5897 * @returns {Array} zoom domain
5898 * @private
5899 */
5900 getZoomDomain: function getZoomDomain() {
5901 var $$ = this,
5902 config = $$.config,
5903 org = $$.org,
5904 _org$xDomain = org.xDomain,
5905 min = _org$xDomain[0],
5906 max = _org$xDomain[1];
5907
5908 if (isDefined(config.zoom_x_min)) {
5909 min = getMinMax("min", [min, config.zoom_x_min]);
5910 }
5911
5912 if (isDefined(config.zoom_x_max)) {
5913 max = getMinMax("max", [max, config.zoom_x_max]);
5914 }
5915
5916 return [min, max];
5917 },
5918
5919 /**
5920 * Converts pixels to axis' scale values
5921 * @param {string} type Axis type
5922 * @param {number} pixels Pixels
5923 * @param {number} domainLength Domain length
5924 * @returns {number}
5925 * @private
5926 */
5927 convertPixelToScale: function convertPixelToScale(type, pixels, domainLength) {
5928 var $$ = this,
5929 config = $$.config,
5930 state = $$.state,
5931 isRotated = config.axis_rotated,
5932 length;
5933
5934 if (type === "x") {
5935 length = isRotated ? "height" : "width";
5936 } else {
5937 length = isRotated ? "width" : "height";
5938 }
5939
5940 return domainLength * (pixels / state[length]);
5941 }
5942});
5943;// CONCATENATED MODULE: ./src/ChartInternal/internals/format.ts
5944/**
5945 * Copyright (c) 2017 ~ present NAVER Corp.
5946 * billboard.js project is licensed under the MIT license
5947 */
5948
5949
5950/**
5951 * Get formatted
5952 * @param {object} $$ Context
5953 * @param {string} typeValue Axis type
5954 * @param {number} v Value to be formatted
5955 * @returns {number | string}
5956 * @private
5957 */
5958function getFormat($$, typeValue, v) {
5959 var config = $$.config,
5960 type = "axis_" + typeValue + "_tick_format",
5961 format = config[type] ? config[type] : $$.defaultValueFormat;
5962 return format(v);
5963}
5964
5965/* harmony default export */ var format = ({
5966 yFormat: function yFormat(v) {
5967 return getFormat(this, "y", v);
5968 },
5969 y2Format: function y2Format(v) {
5970 return getFormat(this, "y2", v);
5971 },
5972
5973 /**
5974 * Get default value format function
5975 * @returns {Function} formatter function
5976 * @private
5977 */
5978 getDefaultValueFormat: function getDefaultValueFormat() {
5979 var $$ = this,
5980 hasArc = $$.hasArcType();
5981 return hasArc && !$$.hasType("gauge") ? $$.defaultArcValueFormat : $$.defaultValueFormat;
5982 },
5983 defaultValueFormat: function defaultValueFormat(v) {
5984 return isValue(v) ? +v : "";
5985 },
5986 defaultArcValueFormat: function defaultArcValueFormat(v, ratio) {
5987 return (ratio * 100).toFixed(1) + "%";
5988 },
5989 dataLabelFormat: function dataLabelFormat(targetId) {
5990 var $$ = this,
5991 dataLabels = $$.config.data_labels,
5992 defaultFormat = function (v) {
5993 return isValue(v) ? +v : "";
5994 },
5995 format = defaultFormat;
5996
5997 // find format according to axis id
5998 if (isFunction(dataLabels.format)) {
5999 format = dataLabels.format;
6000 } else if (isObjectType(dataLabels.format)) {
6001 if (dataLabels.format[targetId]) {
6002 format = dataLabels.format[targetId] === !0 ? defaultFormat : dataLabels.format[targetId];
6003 } else {
6004 format = function () {
6005 return "";
6006 };
6007 }
6008 }
6009
6010 return format.bind($$.api);
6011 }
6012});
6013;// CONCATENATED MODULE: ./src/ChartInternal/internals/legend.ts
6014/**
6015 * Copyright (c) 2017 ~ present NAVER Corp.
6016 * billboard.js project is licensed under the MIT license
6017 */
6018
6019
6020
6021
6022
6023/* harmony default export */ var internals_legend = ({
6024 /**
6025 * Initialize the legend.
6026 * @private
6027 */
6028 initLegend: function initLegend() {
6029 var $$ = this,
6030 config = $$.config,
6031 $el = $$.$el;
6032 $$.legendItemTextBox = {};
6033 $$.state.legendHasRendered = !1;
6034
6035 if (config.legend_show) {
6036 if (!config.legend_contents_bindto) {
6037 $el.legend = $$.$el.svg.append("g").classed(config_classes.legend, !0).attr("transform", $$.getTranslate("legend"));
6038 } // MEMO: call here to update legend box and translate for all
6039 // MEMO: translate will be updated by this, so transform not needed in updateLegend()
6040
6041
6042 $$.updateLegend();
6043 } else {
6044 $$.state.hiddenLegendIds = $$.mapToIds($$.data.targets);
6045 }
6046 },
6047
6048 /**
6049 * Update legend element
6050 * @param {Array} targetIds ID's of target
6051 * @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.
6052 * @param {object} transitions Return value of the generateTransitions
6053 * @private
6054 */
6055 updateLegend: function updateLegend(targetIds, options, transitions) {
6056 var $$ = this,
6057 config = $$.config,
6058 state = $$.state,
6059 scale = $$.scale,
6060 $el = $$.$el,
6061 optionz = options || {
6062 withTransform: !1,
6063 withTransitionForTransform: !1,
6064 withTransition: !1
6065 };
6066 optionz.withTransition = getOption(optionz, "withTransition", !0);
6067 optionz.withTransitionForTransform = getOption(optionz, "withTransitionForTransform", !0);
6068
6069 if (config.legend_contents_bindto && config.legend_contents_template) {
6070 $$.updateLegendTemplate();
6071 } else {
6072 $$.updateLegendElement(targetIds || $$.mapToIds($$.data.targets), optionz, transitions);
6073 } // toggle legend state
6074
6075
6076 $el.legend.selectAll("." + config_classes.legendItem).classed(config_classes.legendItemHidden, function (id) {
6077 var hide = !$$.isTargetToShow(id);
6078
6079 if (hide) {
6080 this.style.opacity = null;
6081 }
6082
6083 return hide;
6084 }); // Update size and scale
6085
6086 $$.updateScales(!1, !scale.zoom);
6087 $$.updateSvgSize(); // Update g positions
6088
6089 $$.transformAll(optionz.withTransitionForTransform, transitions);
6090 state.legendHasRendered = !0;
6091 },
6092
6093 /**
6094 * Update legend using template option
6095 * @private
6096 */
6097 updateLegendTemplate: function updateLegendTemplate() {
6098 var $$ = this,
6099 config = $$.config,
6100 $el = $$.$el,
6101 wrapper = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.legend_contents_bindto),
6102 template = config.legend_contents_template;
6103
6104 if (!wrapper.empty()) {
6105 var targets = $$.mapToIds($$.data.targets),
6106 ids = [],
6107 html = "";
6108 targets.forEach(function (v) {
6109 var content = isFunction(template) ? template.bind($$.api)(v, $$.color(v), $$.api.data(v)[0].values) : tplProcess(template, {
6110 COLOR: $$.color(v),
6111 TITLE: v
6112 });
6113
6114 if (content) {
6115 ids.push(v);
6116 html += content;
6117 }
6118 });
6119 var legendItem = wrapper.html(html).selectAll(function () {
6120 return this.childNodes;
6121 }).data(ids);
6122 $$.setLegendItem(legendItem);
6123 $el.legend = wrapper;
6124 }
6125 },
6126
6127 /**
6128 * Update the size of the legend.
6129 * @param {Obejct} size Size object
6130 * @private
6131 */
6132 updateSizeForLegend: function updateSizeForLegend(size) {
6133 var $$ = this,
6134 config = $$.config,
6135 _$$$state = $$.state,
6136 isLegendTop = _$$$state.isLegendTop,
6137 isLegendLeft = _$$$state.isLegendLeft,
6138 isLegendRight = _$$$state.isLegendRight,
6139 isLegendInset = _$$$state.isLegendInset,
6140 current = _$$$state.current,
6141 width = size.width,
6142 height = size.height,
6143 insetLegendPosition = {
6144 top: isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : current.height - height - $$.getCurrentPaddingBottom() - config.legend_inset_y,
6145 left: isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + .5 : current.width - width - $$.getCurrentPaddingRight() - config.legend_inset_x + .5
6146 };
6147 $$.state.margin3 = {
6148 top: isLegendRight ? 0 : isLegendInset ? insetLegendPosition.top : current.height - height,
6149 right: NaN,
6150 bottom: 0,
6151 left: isLegendRight ? current.width - width : isLegendInset ? insetLegendPosition.left : 0
6152 };
6153 },
6154
6155 /**
6156 * Transform Legend
6157 * @param {boolean} withTransition whether or not to transition.
6158 * @private
6159 */
6160 transformLegend: function transformLegend(withTransition) {
6161 var $$ = this,
6162 legend = $$.$el.legend,
6163 $T = $$.$T;
6164 $T(legend, withTransition).attr("transform", $$.getTranslate("legend"));
6165 },
6166
6167 /**
6168 * Update the legend step
6169 * @param {number} step Step value
6170 * @private
6171 */
6172 updateLegendStep: function updateLegendStep(step) {
6173 this.state.legendStep = step;
6174 },
6175
6176 /**
6177 * Update legend item width
6178 * @param {number} width Width value
6179 * @private
6180 */
6181 updateLegendItemWidth: function updateLegendItemWidth(width) {
6182 this.state.legendItemWidth = width;
6183 },
6184
6185 /**
6186 * Update legend item height
6187 * @param {number} height Height value
6188 * @private
6189 */
6190 updateLegendItemHeight: function updateLegendItemHeight(height) {
6191 this.state.legendItemHeight = height;
6192 },
6193
6194 /**
6195 * Update legend item color
6196 * @param {string} id Corresponding data ID value
6197 * @param {string} color Color value
6198 * @private
6199 */
6200 updateLegendItemColor: function updateLegendItemColor(id, color) {
6201 var legend = this.$el.legend;
6202
6203 if (legend) {
6204 legend.select("." + config_classes.legendItem + "-" + id + " line").style("stroke", color);
6205 }
6206 },
6207
6208 /**
6209 * Get the width of the legend
6210 * @returns {number} width
6211 * @private
6212 */
6213 getLegendWidth: function getLegendWidth() {
6214 var $$ = this,
6215 _$$$state2 = $$.state,
6216 width = _$$$state2.current.width,
6217 isLegendRight = _$$$state2.isLegendRight,
6218 isLegendInset = _$$$state2.isLegendInset,
6219 legendItemWidth = _$$$state2.legendItemWidth,
6220 legendStep = _$$$state2.legendStep;
6221 return $$.config.legend_show ? isLegendRight || isLegendInset ? legendItemWidth * (legendStep + 1) : width : 0;
6222 },
6223
6224 /**
6225 * Get the height of the legend
6226 * @returns {number} height
6227 * @private
6228 */
6229 getLegendHeight: function getLegendHeight() {
6230 var $$ = this,
6231 _$$$state3 = $$.state,
6232 current = _$$$state3.current,
6233 isLegendRight = _$$$state3.isLegendRight,
6234 legendItemHeight = _$$$state3.legendItemHeight,
6235 legendStep = _$$$state3.legendStep;
6236 return $$.config.legend_show ? isLegendRight ? current.height : Math.max(20, legendItemHeight) * (legendStep + 1) : 0;
6237 },
6238
6239 /**
6240 * Get the opacity of the legend that is unfocused
6241 * @param {d3.selection} legendItem Legend item node
6242 * @returns {string|null} opacity
6243 * @private
6244 */
6245 opacityForUnfocusedLegend: function opacityForUnfocusedLegend(legendItem) {
6246 return legendItem.classed(config_classes.legendItemHidden) ? null : "0.3";
6247 },
6248
6249 /**
6250 * Toggles the focus of the legend
6251 * @param {Array} targetIds ID's of target
6252 * @param {boolean} focus whether or not to focus.
6253 * @private
6254 */
6255 toggleFocusLegend: function toggleFocusLegend(targetIds, focus) {
6256 var $$ = this,
6257 legend = $$.$el.legend,
6258 $T = $$.$T,
6259 targetIdz = $$.mapToTargetIds(targetIds);
6260 legend && $T(legend.selectAll("." + config_classes.legendItem).filter(function (id) {
6261 return targetIdz.indexOf(id) >= 0;
6262 }).classed(config_classes.legendItemFocused, focus)).style("opacity", function () {
6263 return focus ? null : $$.opacityForUnfocusedLegend.call($$, (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this));
6264 });
6265 },
6266
6267 /**
6268 * Revert the legend to its default state
6269 * @private
6270 */
6271 revertLegend: function revertLegend() {
6272 var $$ = this,
6273 legend = $$.$el.legend,
6274 $T = $$.$T;
6275 legend && $T(legend.selectAll("." + config_classes.legendItem).classed(config_classes.legendItemFocused, !1)).style("opacity", null);
6276 },
6277
6278 /**
6279 * Shows the legend
6280 * @param {Array} targetIds ID's of target
6281 * @private
6282 */
6283 showLegend: function showLegend(targetIds) {
6284 var $$ = this,
6285 config = $$.config,
6286 $el = $$.$el,
6287 $T = $$.$T;
6288
6289 if (!config.legend_show) {
6290 config.legend_show = !0;
6291 $el.legend ? $el.legend.style("visibility", null) : $$.initLegend();
6292 $$.state.legendHasRendered || $$.updateLegend();
6293 }
6294
6295 $$.removeHiddenLegendIds(targetIds);
6296 $T($el.legend.selectAll($$.selectorLegends(targetIds)).style("visibility", null)).style("opacity", null);
6297 },
6298
6299 /**
6300 * Hide the legend
6301 * @param {Array} targetIds ID's of target
6302 * @private
6303 */
6304 hideLegend: function hideLegend(targetIds) {
6305 var $$ = this,
6306 config = $$.config,
6307 legend = $$.$el.legend;
6308
6309 if (config.legend_show && isEmpty(targetIds)) {
6310 config.legend_show = !1;
6311 legend.style("visibility", "hidden");
6312 }
6313
6314 $$.addHiddenLegendIds(targetIds);
6315 legend.selectAll($$.selectorLegends(targetIds)).style("opacity", "0").style("visibility", "hidden");
6316 },
6317
6318 /**
6319 * Get legend item textbox dimension
6320 * @param {string} id Data ID
6321 * @param {HTMLElement|d3.selection} textElement Text node element
6322 * @returns {object} Bounding rect
6323 * @private
6324 */
6325 getLegendItemTextBox: function getLegendItemTextBox(id, textElement) {
6326 var $$ = this,
6327 cache = $$.cache,
6328 state = $$.state,
6329 data,
6330 cacheKey = KEY.legendItemTextBox;
6331
6332 if (id) {
6333 data = !state.redrawing && cache.get(cacheKey) || {};
6334
6335 if (!data[id]) {
6336 data[id] = $$.getTextRect(textElement, config_classes.legendItem);
6337 cache.add(cacheKey, data);
6338 }
6339
6340 data = data[id];
6341 }
6342
6343 return data;
6344 },
6345
6346 /**
6347 * Set legend item style & bind events
6348 * @param {d3.selection} item Item node
6349 * @private
6350 */
6351 setLegendItem: function setLegendItem(item) {
6352 var $$ = this,
6353 api = $$.api,
6354 config = $$.config,
6355 state = $$.state,
6356 isTouch = state.inputType === "touch",
6357 hasGauge = $$.hasType("gauge");
6358 item.attr("class", function (id) {
6359 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
6360 itemClass = !node.empty() && node.attr("class") || "";
6361 return itemClass + $$.generateClass(config_classes.legendItem, id);
6362 }).style("visibility", function (id) {
6363 return $$.isLegendToShow(id) ? null : "hidden";
6364 });
6365
6366 if (config.interaction_enabled) {
6367 item.style("cursor", "pointer").on("click", function (event, id) {
6368 if (!callFn(config.legend_item_onclick, api, id)) {
6369 if (event.altKey) {
6370 api.hide();
6371 api.show(id);
6372 } else {
6373 api.toggle(id);
6374 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused, !1);
6375 }
6376 }
6377
6378 isTouch && $$.hideTooltip();
6379 });
6380 isTouch || item.on("mouseout", function (event, id) {
6381 if (!callFn(config.legend_item_onout, api, id)) {
6382 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused, !1);
6383
6384 if (hasGauge) {
6385 $$.undoMarkOverlapped($$, "." + config_classes.gaugeValue);
6386 }
6387
6388 $$.api.revert();
6389 }
6390 }).on("mouseover", function (event, id) {
6391 if (!callFn(config.legend_item_onover, api, id)) {
6392 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused, !0);
6393
6394 if (hasGauge) {
6395 $$.markOverlapped(id, $$, "." + config_classes.gaugeValue);
6396 }
6397
6398 if (!state.transiting && $$.isTargetToShow(id)) {
6399 api.focus(id);
6400 }
6401 }
6402 });
6403 }
6404 },
6405
6406 /**
6407 * Update the legend
6408 * @param {Array} targetIds ID's of target
6409 * @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.
6410 * @private
6411 */
6412 updateLegendElement: function updateLegendElement(targetIds, options) {
6413 var $$ = this,
6414 config = $$.config,
6415 state = $$.state,
6416 legend = $$.$el.legend,
6417 $T = $$.$T,
6418 posMin = 10,
6419 tileWidth = config.legend_item_tile_width + 5,
6420 maxWidth = 0,
6421 maxHeight = 0,
6422 xForLegend,
6423 yForLegend,
6424 totalLength = 0,
6425 offsets = {},
6426 widths = {},
6427 heights = {},
6428 margins = [0],
6429 steps = {},
6430 step = 0,
6431 background,
6432 isLegendRightOrInset = state.isLegendRight || state.isLegendInset,
6433 targetIdz = targetIds.filter(function (id) {
6434 return !isDefined(config.data_names[id]) || config.data_names[id] !== null;
6435 }),
6436 withTransition = options.withTransition,
6437 updatePositions = function (textElement, id, index) {
6438 var isLast = index === targetIdz.length - 1,
6439 box = $$.getLegendItemTextBox(id, textElement),
6440 itemWidth = box.width + tileWidth + (isLast && !isLegendRightOrInset ? 0 : 10) + config.legend_padding,
6441 itemHeight = box.height + 4,
6442 itemLength = isLegendRightOrInset ? itemHeight : itemWidth,
6443 areaLength = isLegendRightOrInset ? $$.getLegendHeight() : $$.getLegendWidth(),
6444 margin,
6445 updateValues = function (id2, withoutStep) {
6446 if (!withoutStep) {
6447 margin = (areaLength - totalLength - itemLength) / 2;
6448
6449 if (margin < posMin) {
6450 margin = (areaLength - itemLength) / 2;
6451 totalLength = 0;
6452 step++;
6453 }
6454 }
6455
6456 steps[id2] = step;
6457 margins[step] = state.isLegendInset ? 10 : margin;
6458 offsets[id2] = totalLength;
6459 totalLength += itemLength;
6460 };
6461
6462 if (index === 0) {
6463 totalLength = 0;
6464 step = 0;
6465 maxWidth = 0;
6466 maxHeight = 0;
6467 }
6468
6469 if (config.legend_show && !$$.isLegendToShow(id)) {
6470 widths[id] = 0;
6471 heights[id] = 0;
6472 steps[id] = 0;
6473 offsets[id] = 0;
6474 return;
6475 }
6476
6477 widths[id] = itemWidth;
6478 heights[id] = itemHeight;
6479
6480 if (!maxWidth || itemWidth >= maxWidth) {
6481 maxWidth = itemWidth;
6482 }
6483
6484 if (!maxHeight || itemHeight >= maxHeight) {
6485 maxHeight = itemHeight;
6486 }
6487
6488 var maxLength = isLegendRightOrInset ? maxHeight : maxWidth;
6489
6490 if (config.legend_equally) {
6491 Object.keys(widths).forEach(function (id2) {
6492 return widths[id2] = maxWidth;
6493 });
6494 Object.keys(heights).forEach(function (id2) {
6495 return heights[id2] = maxHeight;
6496 });
6497 margin = (areaLength - maxLength * targetIdz.length) / 2;
6498
6499 if (margin < posMin) {
6500 totalLength = 0;
6501 step = 0;
6502 targetIdz.forEach(function (id2) {
6503 return updateValues(id2);
6504 });
6505 } else {
6506 updateValues(id, !0);
6507 }
6508 } else {
6509 updateValues(id);
6510 }
6511 };
6512
6513 if (state.isLegendInset) {
6514 step = config.legend_inset_step ? config.legend_inset_step : targetIdz.length;
6515 $$.updateLegendStep(step);
6516 }
6517
6518 if (state.isLegendRight) {
6519 xForLegend = function (id) {
6520 return maxWidth * steps[id];
6521 };
6522
6523 yForLegend = function (id) {
6524 return margins[steps[id]] + offsets[id];
6525 };
6526 } else if (state.isLegendInset) {
6527 xForLegend = function (id) {
6528 return maxWidth * steps[id] + 10;
6529 };
6530
6531 yForLegend = function (id) {
6532 return margins[steps[id]] + offsets[id];
6533 };
6534 } else {
6535 xForLegend = function (id) {
6536 return margins[steps[id]] + offsets[id];
6537 };
6538
6539 yForLegend = function (id) {
6540 return maxHeight * steps[id];
6541 };
6542 }
6543
6544 var xForLegendText = function (id, i) {
6545 return xForLegend(id, i) + 4 + config.legend_item_tile_width;
6546 },
6547 xForLegendRect = function (id, i) {
6548 return xForLegend(id, i);
6549 },
6550 x1ForLegendTile = function (id, i) {
6551 return xForLegend(id, i) - 2;
6552 },
6553 x2ForLegendTile = function (id, i) {
6554 return xForLegend(id, i) - 2 + config.legend_item_tile_width;
6555 },
6556 yForLegendText = function (id, i) {
6557 return yForLegend(id, i) + 9;
6558 },
6559 yForLegendRect = function (id, i) {
6560 return yForLegend(id, i) - 5;
6561 },
6562 yForLegendTile = function (id, i) {
6563 return yForLegend(id, i) + 4;
6564 },
6565 pos = -200,
6566 l = legend.selectAll("." + config_classes.legendItem).data(targetIdz).enter().append("g");
6567
6568 $$.setLegendItem(l);
6569 l.append("text").text(function (id) {
6570 return isDefined(config.data_names[id]) ? config.data_names[id] : id;
6571 }).each(function (id, i) {
6572 updatePositions(this, id, i);
6573 }).style("pointer-events", "none").attr("x", isLegendRightOrInset ? xForLegendText : pos).attr("y", isLegendRightOrInset ? pos : yForLegendText);
6574 l.append("rect").attr("class", config_classes.legendItemEvent).style("fill-opacity", "0").attr("x", isLegendRightOrInset ? xForLegendRect : pos).attr("y", isLegendRightOrInset ? pos : yForLegendRect);
6575
6576 var getColor = function (id) {
6577 var data = $$.getDataById(id);
6578 return $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
6579 },
6580 usePoint = config.legend_usePoint;
6581
6582 if (usePoint) {
6583 var ids = [];
6584 l.append(function (d) {
6585 var pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
6586 ids.indexOf(d) === -1 && ids.push(d);
6587 var point = pattern[ids.indexOf(d) % pattern.length];
6588
6589 if (point === "rectangle") {
6590 point = "rect";
6591 }
6592
6593 return browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, "hasValidPointType" in $$ && $$.hasValidPointType(point) ? point : "use");
6594 }).attr("class", config_classes.legendItemPoint).style("fill", getColor).style("pointer-events", "none").attr("href", function (data, idx, selection) {
6595 var node = selection[idx],
6596 nodeName = node.nodeName.toLowerCase(),
6597 id = $$.getTargetSelectorSuffix(data);
6598 return nodeName === "use" ? "#" + state.datetimeId + "-point" + id : undefined;
6599 });
6600 } else {
6601 l.append("line").attr("class", config_classes.legendItemTile).style("stroke", getColor).style("pointer-events", "none").attr("x1", isLegendRightOrInset ? x1ForLegendTile : pos).attr("y1", isLegendRightOrInset ? pos : yForLegendTile).attr("x2", isLegendRightOrInset ? x2ForLegendTile : pos).attr("y2", isLegendRightOrInset ? pos : yForLegendTile).attr("stroke-width", config.legend_item_tile_height);
6602 } // Set background for inset legend
6603
6604
6605 background = legend.select("." + config_classes.legendBackground + " rect");
6606
6607 if (state.isLegendInset && maxWidth > 0 && background.size() === 0) {
6608 background = legend.insert("g", "." + config_classes.legendItem).attr("class", config_classes.legendBackground).append("rect");
6609 }
6610
6611 var texts = legend.selectAll("text").data(targetIdz).text(function (id) {
6612 return isDefined(config.data_names[id]) ? config.data_names[id] : id;
6613 }) // MEMO: needed for update
6614 .each(function (id, i) {
6615 updatePositions(this, id, i);
6616 });
6617 $T(texts, withTransition).attr("x", xForLegendText).attr("y", yForLegendText);
6618 var rects = legend.selectAll("rect." + config_classes.legendItemEvent).data(targetIdz);
6619 $T(rects, withTransition).attr("width", function (id) {
6620 return widths[id];
6621 }).attr("height", function (id) {
6622 return heights[id];
6623 }).attr("x", xForLegendRect).attr("y", yForLegendRect);
6624
6625 if (usePoint) {
6626 var tiles = legend.selectAll("." + config_classes.legendItemPoint).data(targetIdz);
6627 $T(tiles, withTransition).each(function () {
6628 var nodeName = this.nodeName.toLowerCase(),
6629 pointR = config.point_r,
6630 x = "x",
6631 y = "y",
6632 xOffset = 2,
6633 yOffset = 2.5,
6634 radius,
6635 width,
6636 height;
6637
6638 if (nodeName === "circle") {
6639 var size = pointR * .2;
6640 x = "cx";
6641 y = "cy";
6642 radius = pointR + size;
6643 xOffset = pointR * 2;
6644 yOffset = -size;
6645 } else if (nodeName === "rect") {
6646 var _size = pointR * 2.5;
6647
6648 width = _size;
6649 height = _size;
6650 yOffset = 3;
6651 }
6652
6653 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).attr(x, function (d) {
6654 return x1ForLegendTile(d) + xOffset;
6655 }).attr(y, function (d) {
6656 return yForLegendTile(d) - yOffset;
6657 }).attr("r", radius).attr("width", width).attr("height", height);
6658 });
6659 } else {
6660 var _tiles = legend.selectAll("line." + config_classes.legendItemTile).data(targetIdz);
6661
6662 $T(_tiles, withTransition).style("stroke", getColor).attr("x1", x1ForLegendTile).attr("y1", yForLegendTile).attr("x2", x2ForLegendTile).attr("y2", yForLegendTile);
6663 }
6664
6665 if (background) {
6666 $T(background, withTransition).attr("height", $$.getLegendHeight() - 12).attr("width", maxWidth * (step + 1) + 10);
6667 } // Update all to reflect change of legend
6668
6669
6670 $$.updateLegendItemWidth(maxWidth);
6671 $$.updateLegendItemHeight(maxHeight);
6672 $$.updateLegendStep(step);
6673 }
6674});
6675// EXTERNAL MODULE: external {"commonjs":"d3-transition","commonjs2":"d3-transition","amd":"d3-transition","root":"d3"}
6676var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_ = __webpack_require__(8);
6677;// CONCATENATED MODULE: ./src/ChartInternal/internals/redraw.ts
6678/**
6679 * Copyright (c) 2017 ~ present NAVER Corp.
6680 * billboard.js project is licensed under the MIT license
6681 */
6682
6683
6684
6685
6686/* harmony default export */ var redraw = ({
6687 redraw: function redraw(options) {
6688 var _$$$axis;
6689
6690 if (options === void 0) {
6691 options = {};
6692 }
6693
6694 var $$ = this,
6695 config = $$.config,
6696 state = $$.state,
6697 $el = $$.$el,
6698 main = $el.main;
6699 state.redrawing = !0;
6700 var targetsToShow = $$.filterTargetsToShow($$.data.targets),
6701 _options = options,
6702 flow = _options.flow,
6703 initializing = _options.initializing,
6704 wth = $$.getWithOption(options),
6705 duration = wth.Transition ? config.transition_duration : 0,
6706 durationForExit = wth.TransitionForExit ? duration : 0,
6707 durationForAxis = wth.TransitionForAxis ? duration : 0,
6708 transitions = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.generateTransitions(durationForAxis);
6709 $$.updateSizes(initializing); // update legend and transform each g
6710
6711 if (wth.Legend && config.legend_show) {
6712 options.withTransition = !!duration;
6713 $$.updateLegend($$.mapToIds($$.data.targets), options, transitions);
6714 } else if (wth.Dimension) {
6715 // need to update dimension (e.g. axis.y.tick.values) because y tick values should change
6716 // no need to update axis in it because they will be updated in redraw()
6717 $$.updateDimension(!0);
6718 } // update circleY based on updated parameters
6719
6720
6721 if (!$$.hasArcType() || state.hasRadar) {
6722 $$.updateCircleY && ($$.circleY = $$.updateCircleY());
6723 } // update axis
6724
6725
6726 if (state.hasAxis) {
6727 // @TODO: Make 'init' state to be accessible everywhere not passing as argument.
6728 $$.axis.redrawAxis(targetsToShow, wth, transitions, flow, initializing); // Data empty label positioning and text.
6729
6730 config.data_empty_label_text && main.select("text." + config_classes.text + "." + config_classes.empty).attr("x", state.width / 2).attr("y", state.height / 2).text(config.data_empty_label_text).style("display", targetsToShow.length ? "none" : null); // grid
6731
6732 $$.hasGrid() && $$.updateGrid(); // rect for regions
6733
6734 config.regions.length && $$.updateRegion();
6735 ["bar", "candlestick", "line", "area"].forEach(function (v) {
6736 var name = capitalize(v);
6737
6738 if (/^(line|area)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
6739 $$["update" + name](wth.TransitionForExit);
6740 }
6741 }); // circles for select
6742
6743 $el.text && main.selectAll("." + config_classes.selectedCircles).filter($$.isBarType.bind($$)).selectAll("circle").remove(); // event rects will redrawn when flow called
6744
6745 if (config.interaction_enabled && !flow && wth.EventRect) {
6746 $$.redrawEventRect();
6747 $$.bindZoomEvent == null ? void 0 : $$.bindZoomEvent();
6748 }
6749 } else {
6750 // arc
6751 $el.arcs && $$.redrawArc(duration, durationForExit, wth.Transform); // radar
6752
6753 $el.radar && $$.redrawRadar();
6754 } // @TODO: Axis & Radar type
6755
6756
6757 if (!state.resizing && ($$.hasPointType() || state.hasRadar)) {
6758 $$.updateCircle();
6759 } // text
6760
6761
6762 $$.hasDataLabel() && !$$.hasArcType(null, ["radar"]) && $$.updateText(); // title
6763
6764 $$.redrawTitle == null ? void 0 : $$.redrawTitle();
6765 initializing && $$.updateTypesElements();
6766 $$.generateRedrawList(targetsToShow, flow, duration, wth.Subchart);
6767 $$.callPluginHook("$redraw", options, duration);
6768 },
6769
6770 /**
6771 * Generate redraw list
6772 * @param {object} targets targets data to be shown
6773 * @param {object} flow flow object
6774 * @param {number} duration duration value
6775 * @param {boolean} withSubchart whether or not to show subchart
6776 * @private
6777 */
6778 generateRedrawList: function generateRedrawList(targets, flow, duration, withSubchart) {
6779 var $$ = this,
6780 config = $$.config,
6781 state = $$.state,
6782 shape = $$.getDrawShape();
6783
6784 if (state.hasAxis) {
6785 // subchart
6786 config.subchart_show && $$.redrawSubchart(withSubchart, duration, shape);
6787 } // generate flow
6788
6789
6790 var flowFn = flow && $$.generateFlow({
6791 targets: targets,
6792 flow: flow,
6793 duration: flow.duration,
6794 shape: shape,
6795 xv: $$.xv.bind($$)
6796 }),
6797 withTransition = (duration || flowFn) && isTabVisible(),
6798 redrawList = $$.getRedrawList(shape, flow, flowFn, withTransition),
6799 afterRedraw = function () {
6800 flowFn && flowFn();
6801 state.redrawing = !1;
6802 callFn(config.onrendered, $$.api);
6803 };
6804
6805 if (afterRedraw) {
6806 // Only use transition when current tab is visible.
6807 if (withTransition && redrawList.length) {
6808 // Wait for end of transitions for callback
6809 var waitForDraw = generateWait(); // transition should be derived from one transition
6810
6811 (0,external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_.transition)().duration(duration).each(function () {
6812 redrawList.reduce(function (acc, t1) {
6813 return acc.concat(t1);
6814 }, []).forEach(function (t) {
6815 return waitForDraw.add(t);
6816 });
6817 }).call(waitForDraw, afterRedraw);
6818 } else if (!state.transiting) {
6819 afterRedraw();
6820 }
6821 } // update fadein condition
6822
6823
6824 $$.mapToIds($$.data.targets).forEach(function (id) {
6825 state.withoutFadeIn[id] = !0;
6826 });
6827 },
6828 getRedrawList: function getRedrawList(shape, flow, flowFn, withTransition) {
6829 var $$ = this,
6830 config = $$.config,
6831 _$$$state = $$.state,
6832 hasAxis = _$$$state.hasAxis,
6833 hasRadar = _$$$state.hasRadar,
6834 grid = $$.$el.grid,
6835 _shape$pos = shape.pos,
6836 cx = _shape$pos.cx,
6837 cy = _shape$pos.cy,
6838 xForText = _shape$pos.xForText,
6839 yForText = _shape$pos.yForText,
6840 list = [];
6841
6842 if (hasAxis) {
6843 if (config.grid_x_lines.length || config.grid_y_lines.length) {
6844 list.push($$.redrawGrid(withTransition));
6845 }
6846
6847 if (config.regions.length) {
6848 list.push($$.redrawRegion(withTransition));
6849 }
6850
6851 Object.keys(shape.type).forEach(function (v) {
6852 var name = capitalize(v),
6853 drawFn = shape.type[v];
6854
6855 if (/^(area|line)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
6856 list.push($$["redraw" + name](drawFn, withTransition));
6857 }
6858 });
6859 !flow && grid.main && list.push($$.updateGridFocus());
6860 }
6861
6862 if (!$$.hasArcType() || hasRadar) {
6863 notEmpty(config.data_labels) && config.data_labels !== !1 && list.push($$.redrawText(xForText, yForText, flow, withTransition));
6864 }
6865
6866 if (($$.hasPointType() || hasRadar) && !config.point_focus_only) {
6867 $$.redrawCircle && list.push($$.redrawCircle(cx, cy, withTransition, flowFn));
6868 }
6869
6870 return list;
6871 },
6872 updateAndRedraw: function updateAndRedraw(options) {
6873 if (options === void 0) {
6874 options = {};
6875 }
6876
6877 var $$ = this,
6878 config = $$.config,
6879 state = $$.state,
6880 transitions;
6881 // same with redraw
6882 options.withTransition = getOption(options, "withTransition", !0);
6883 options.withTransform = getOption(options, "withTransform", !1);
6884 options.withLegend = getOption(options, "withLegend", !1); // NOT same with redraw
6885
6886 options.withUpdateXDomain = !0;
6887 options.withUpdateOrgXDomain = !0;
6888 options.withTransitionForExit = !1;
6889 options.withTransitionForTransform = getOption(options, "withTransitionForTransform", options.withTransition); // MEMO: called in updateLegend in redraw if withLegend
6890
6891 if (!(options.withLegend && config.legend_show)) {
6892 if (state.hasAxis) {
6893 transitions = $$.axis.generateTransitions(options.withTransitionForAxis ? config.transition_duration : 0);
6894 } // Update scales
6895
6896
6897 $$.updateScales();
6898 $$.updateSvgSize(); // Update g positions
6899
6900 $$.transformAll(options.withTransitionForTransform, transitions);
6901 } // Draw with new sizes & scales
6902
6903
6904 $$.redraw(options, transitions);
6905 },
6906 redrawWithoutRescale: function redrawWithoutRescale() {
6907 this.redraw({
6908 withY: !1,
6909 withLegend: !0,
6910 withSubchart: !1,
6911 withEventRect: !1,
6912 withTransitionForAxis: !1
6913 });
6914 }
6915});
6916;// CONCATENATED MODULE: ./src/ChartInternal/internals/scale.ts
6917/**
6918 * Copyright (c) 2017 ~ present NAVER Corp.
6919 * billboard.js project is licensed under the MIT license
6920 */
6921
6922
6923
6924/**
6925 * Get scale
6926 * @param {string} [type='linear'] Scale type
6927 * @param {number} [min] Min range
6928 * @param {number} [max] Max range
6929 * @returns {d3.scaleLinear|d3.scaleTime} scale
6930 * @private
6931 */
6932function getScale(type, min, max) {
6933 if (type === void 0) {
6934 type = "linear";
6935 }
6936
6937 if (min === void 0) {
6938 min = 0;
6939 }
6940
6941 if (max === void 0) {
6942 max = 1;
6943 }
6944
6945 var scale = {
6946 linear: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear,
6947 log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSymlog,
6948 _log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLog,
6949 time: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleTime,
6950 utc: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleUtc
6951 }[type]();
6952 scale.type = type;
6953 /_?log/.test(type) && scale.clamp(!0);
6954 return scale.range([min, max]);
6955}
6956/* harmony default export */ var scale = ({
6957 /**
6958 * Get x Axis scale function
6959 * @param {number} min Min value
6960 * @param {number} max Max value
6961 * @param {Array} domain Domain value
6962 * @param {Function} offset The offset getter to be sum
6963 * @returns {Function} scale
6964 * @private
6965 */
6966 getXScale: function getXScale(min, max, domain, offset) {
6967 var $$ = this,
6968 scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
6969 return $$.getCustomizedScale(domain ? scale.domain(domain) : scale, offset);
6970 },
6971
6972 /**
6973 * Get y Axis scale function
6974 * @param {string} id Axis id: 'y' or 'y2'
6975 * @param {number} min Min value
6976 * @param {number} max Max value
6977 * @param {Array} domain Domain value
6978 * @returns {Function} Scale function
6979 * @private
6980 */
6981 getYScale: function getYScale(id, min, max, domain) {
6982 var $$ = this,
6983 scale = getScale($$.axis.getAxisType(id), min, max);
6984 domain && scale.domain(domain);
6985 return scale;
6986 },
6987
6988 /**
6989 * Get y Axis scale
6990 * @param {string} id Axis id
6991 * @param {boolean} isSub Weather is sub Axis
6992 * @returns {Function} Scale function
6993 * @private
6994 */
6995 getYScaleById: function getYScaleById(id, isSub) {
6996 if (isSub === void 0) {
6997 isSub = !1;
6998 }
6999
7000 var isY2 = this.axis.getId(id) === "y2",
7001 key = isSub ? isY2 ? "subY2" : "subY" : isY2 ? "y2" : "y";
7002 return this.scale[key];
7003 },
7004
7005 /**
7006 * Get customized scale
7007 * @param {d3.scaleLinear|d3.scaleTime} scaleValue Scale function
7008 * @param {Function} offsetValue Offset getter to be sum
7009 * @returns {Function} Scale function
7010 * @private
7011 */
7012 getCustomizedScale: function getCustomizedScale(scaleValue, offsetValue) {
7013 var $$ = this,
7014 offset = offsetValue || function () {
7015 return $$.axis.x.tickOffset();
7016 },
7017 scale = function (d, raw) {
7018 var v = scaleValue(d) + offset();
7019 return raw ? v : Math.ceil(v);
7020 };
7021
7022 // copy original scale methods
7023 for (var key in scaleValue) {
7024 scale[key] = scaleValue[key];
7025 }
7026
7027 scale.orgDomain = function () {
7028 return scaleValue.domain();
7029 };
7030
7031 scale.orgScale = function () {
7032 return scaleValue;
7033 }; // define custom domain() for categorized axis
7034
7035
7036 if ($$.axis.isCategorized()) {
7037 scale.domain = function (domainValue) {
7038 var domain = domainValue;
7039
7040 if (!arguments.length) {
7041 domain = this.orgDomain();
7042 return [domain[0], domain[1] + 1];
7043 }
7044
7045 scaleValue.domain(domain);
7046 return scale;
7047 };
7048 }
7049
7050 return scale;
7051 },
7052
7053 /**
7054 * Update scale
7055 * @param {boolean} isInit Param is given at the init rendering
7056 * @param {boolean} updateXDomain If update x domain
7057 * @private
7058 */
7059 updateScales: function updateScales(isInit, updateXDomain) {
7060 if (updateXDomain === void 0) {
7061 updateXDomain = !0;
7062 }
7063
7064 var $$ = this,
7065 axis = $$.axis,
7066 config = $$.config,
7067 format = $$.format,
7068 org = $$.org,
7069 scale = $$.scale,
7070 _$$$state = $$.state,
7071 width = _$$$state.width,
7072 height = _$$$state.height,
7073 width2 = _$$$state.width2,
7074 height2 = _$$$state.height2,
7075 hasAxis = _$$$state.hasAxis;
7076
7077 if (hasAxis) {
7078 var _scale$x,
7079 isRotated = config.axis_rotated,
7080 min = {
7081 x: isRotated ? 1 : 0,
7082 y: isRotated ? 0 : height,
7083 subX: isRotated ? 1 : 0,
7084 subY: isRotated ? 0 : height2
7085 },
7086 max = {
7087 x: isRotated ? height : width,
7088 y: isRotated ? width : 1,
7089 subX: isRotated ? height : width,
7090 subY: isRotated ? width2 : 1
7091 },
7092 xDomain = updateXDomain && ((_scale$x = scale.x) == null ? void 0 : _scale$x.orgDomain()),
7093 xSubDomain = updateXDomain && org.xDomain;
7094
7095 scale.x = $$.getXScale(min.x, max.x, xDomain, function () {
7096 return axis.x.tickOffset();
7097 });
7098 scale.subX = $$.getXScale(min.x, max.x, xSubDomain, function (d) {
7099 return d % 1 ? 0 : axis.subX.tickOffset();
7100 });
7101 format.xAxisTick = axis.getXAxisTickFormat();
7102 format.subXAxisTick = axis.getXAxisTickFormat(!0);
7103 axis.setAxis("x", scale.x, config.axis_x_tick_outer, isInit);
7104
7105 if (config.subchart_show) {
7106 axis.setAxis("subX", scale.subX, config.axis_x_tick_outer, isInit);
7107 } // y Axis
7108
7109
7110 scale.y = $$.getYScale("y", min.y, max.y, scale.y ? scale.y.domain() : config.axis_y_default);
7111 scale.subY = $$.getYScale("y", min.subY, max.subY, scale.subY ? scale.subY.domain() : config.axis_y_default);
7112 axis.setAxis("y", scale.y, config.axis_y_tick_outer, isInit); // y2 Axis
7113
7114 if (config.axis_y2_show) {
7115 scale.y2 = $$.getYScale("y2", min.y, max.y, scale.y2 ? scale.y2.domain() : config.axis_y2_default);
7116 scale.subY2 = $$.getYScale("y2", min.subY, max.subY, scale.subY2 ? scale.subY2.domain() : config.axis_y2_default);
7117 axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
7118 }
7119 } else {
7120 // update for arc
7121 $$.updateArc == null ? void 0 : $$.updateArc();
7122 }
7123 },
7124
7125 /**
7126 * Get the zoom or unzoomed scaled value
7127 * @param {Date|number|object} d Data value
7128 * @returns {number|null}
7129 * @private
7130 */
7131 xx: function xx(d) {
7132 var $$ = this,
7133 config = $$.config,
7134 _$$$scale = $$.scale,
7135 x = _$$$scale.x,
7136 zoom = _$$$scale.zoom,
7137 fn = config.zoom_enabled && zoom ? zoom : x;
7138 return d ? fn(isValue(d.x) ? d.x : d) : null;
7139 },
7140 xv: function xv(d) {
7141 var $$ = this,
7142 axis = $$.axis,
7143 config = $$.config,
7144 _$$$scale2 = $$.scale,
7145 x = _$$$scale2.x,
7146 zoom = _$$$scale2.zoom,
7147 fn = config.zoom_enabled && zoom ? zoom : x,
7148 value = $$.getBaseValue(d);
7149
7150 if (axis.isTimeSeries()) {
7151 value = parseDate.call($$, value);
7152 } else if (axis.isCategorized() && isString(value)) {
7153 value = config.axis_x_categories.indexOf(value);
7154 }
7155
7156 return Math.ceil(fn(value));
7157 },
7158 yv: function yv(d) {
7159 var $$ = this,
7160 _$$$scale3 = $$.scale,
7161 y = _$$$scale3.y,
7162 y2 = _$$$scale3.y2,
7163 yScale = d.axis && d.axis === "y2" ? y2 : y;
7164 return Math.ceil(yScale($$.getBaseValue(d)));
7165 },
7166 subxx: function subxx(d) {
7167 return d ? this.scale.subX(d.x) : null;
7168 }
7169});
7170// EXTERNAL MODULE: external {"commonjs":"d3-shape","commonjs2":"d3-shape","amd":"d3-shape","root":"d3"}
7171var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webpack_require__(9);
7172;// CONCATENATED MODULE: ./src/ChartInternal/shape/shape.ts
7173/**
7174 * Copyright (c) 2017 ~ present NAVER Corp.
7175 * billboard.js project is licensed under the MIT license
7176 */
7177
7178
7179
7180
7181/* harmony default export */ var shape = ({
7182 /**
7183 * Get the shape draw function
7184 * @returns {object}
7185 * @private
7186 */
7187 getDrawShape: function getDrawShape() {
7188 var $$ = this,
7189 isRotated = $$.config.axis_rotated,
7190 hasRadar = $$.state.hasRadar,
7191 shape = {
7192 type: {},
7193 indices: {},
7194 pos: {}
7195 };
7196 ["bar", "candlestick", "line", "area"].forEach(function (v) {
7197 var name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
7198
7199 if ($$.hasType(v) || $$.hasTypeOf(name) || v === "line" && ($$.hasType("bubble") || $$.hasType("scatter"))) {
7200 var indices = $$.getShapeIndices($$["is" + name + "Type"]),
7201 drawFn = $$["generateDraw" + name];
7202 shape.indices[v] = indices;
7203 shape.type[v] = drawFn ? drawFn.bind($$)(indices, !1) : undefined;
7204 }
7205 });
7206
7207 if (!$$.hasArcType() || hasRadar) {
7208 // generate circle x/y functions depending on updated params
7209 var cx = hasRadar ? $$.radarCircleX : isRotated ? $$.circleY : $$.circleX,
7210 cy = hasRadar ? $$.radarCircleY : isRotated ? $$.circleX : $$.circleY;
7211 shape.pos = {
7212 xForText: $$.generateXYForText(shape.indices, !0),
7213 yForText: $$.generateXYForText(shape.indices, !1),
7214 cx: (cx || function () {}).bind($$),
7215 cy: (cy || function () {}).bind($$)
7216 };
7217 }
7218
7219 return shape;
7220 },
7221 getShapeIndices: function getShapeIndices(typeFilter) {
7222 var $$ = this,
7223 config = $$.config,
7224 xs = config.data_xs,
7225 hasXs = notEmpty(xs),
7226 indices = {},
7227 i = hasXs ? {} : 0;
7228
7229 if (hasXs) {
7230 getUnique(Object.keys(xs).map(function (v) {
7231 return xs[v];
7232 })).forEach(function (v) {
7233 i[v] = 0;
7234 indices[v] = {};
7235 });
7236 }
7237
7238 $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) {
7239 var xKey = d.id in xs ? xs[d.id] : "",
7240 ind = xKey ? indices[xKey] : indices;
7241
7242 for (var j = 0, groups; groups = config.data_groups[j]; j++) {
7243 if (groups.indexOf(d.id) < 0) {
7244 continue;
7245 }
7246
7247 for (var k = 0, row; row = groups[k]; k++) {
7248 if (row in ind) {
7249 ind[d.id] = ind[row];
7250 break;
7251 }
7252 }
7253 }
7254
7255 if (isUndefined(ind[d.id])) {
7256 ind[d.id] = xKey ? i[xKey]++ : i++;
7257 ind.__max__ = (xKey ? i[xKey] : i) - 1;
7258 }
7259 });
7260 return indices;
7261 },
7262
7263 /**
7264 * Get indices value based on data ID value
7265 * @param {object} indices Indices object
7266 * @param {string} id Data id value
7267 * @returns {object} Indices object
7268 * @private
7269 */
7270 getIndices: function getIndices(indices, id) {
7271 var xs = this.config.data_xs;
7272 return notEmpty(xs) ? indices[xs[id]] : indices;
7273 },
7274
7275 /**
7276 * Get indices max number
7277 * @param {object} indices Indices object
7278 * @returns {number} Max number
7279 * @private
7280 */
7281 getIndicesMax: function getIndicesMax(indices) {
7282 return notEmpty(this.config.data_xs) ? // if is multiple xs, return total sum of xs' __max__ value
7283 Object.keys(indices).map(function (v) {
7284 return indices[v].__max__ || 0;
7285 }).reduce(function (acc, curr) {
7286 return acc + curr;
7287 }) : indices.__max__;
7288 },
7289 getShapeX: function getShapeX(offset, indices, isSub) {
7290 var $$ = this,
7291 config = $$.config,
7292 scale = $$.scale,
7293 currScale = isSub ? scale.subX : scale.zoom || scale.x,
7294 barPadding = config.bar_padding,
7295 sum = function (p, c) {
7296 return p + c;
7297 },
7298 halfWidth = isObjectType(offset) && (offset._$total.length ? offset._$total.reduce(sum) / 2 : 0);
7299
7300 return function (d) {
7301 var ind = $$.getIndices(indices, d.id, "getShapeX"),
7302 index = d.id in ind ? ind[d.id] : 0,
7303 targetsNum = (ind.__max__ || 0) + 1,
7304 x = 0;
7305
7306 if (notEmpty(d.x)) {
7307 var xPos = currScale(d.x, !0);
7308
7309 if (halfWidth) {
7310 x = xPos - (offset[d.id] || offset._$width) + offset._$total.slice(0, index + 1).reduce(sum) - halfWidth;
7311 } else {
7312 x = xPos - (isNumber(offset) ? offset : offset._$width) * (targetsNum / 2 - index);
7313 }
7314 } // adjust x position for bar.padding optionq
7315
7316
7317 if (offset && x && targetsNum > 1 && barPadding) {
7318 if (index) {
7319 x += barPadding * index;
7320 }
7321
7322 if (targetsNum > 2) {
7323 x -= (targetsNum - 1) * barPadding / 2;
7324 } else if (targetsNum === 2) {
7325 x -= barPadding / 2;
7326 }
7327 }
7328
7329 return x;
7330 };
7331 },
7332 getShapeY: function getShapeY(isSub) {
7333 var $$ = this,
7334 isStackNormalized = $$.isStackNormalized();
7335 return function (d) {
7336 var value = d.value;
7337
7338 if (isNumber(d)) {
7339 value = d;
7340 } else if (isStackNormalized) {
7341 value = $$.getRatio("index", d, !0);
7342 } else if ($$.isBubbleZType(d)) {
7343 value = $$.getBubbleZData(d.value, "y");
7344 }
7345
7346 return $$.getYScaleById(d.id, isSub)(value);
7347 };
7348 },
7349
7350 /**
7351 * Get shape based y Axis min value
7352 * @param {string} id Data id
7353 * @returns {number}
7354 * @private
7355 */
7356 getShapeYMin: function getShapeYMin(id) {
7357 var $$ = this,
7358 scale = $$.scale[$$.axis.getId(id)],
7359 _scale$domain = scale.domain(),
7360 yMin = _scale$domain[0];
7361
7362 return !$$.isGrouped(id) && yMin > 0 ? yMin : 0;
7363 },
7364
7365 /**
7366 * Get Shape's offset data
7367 * @param {Function} typeFilter Type filter function
7368 * @returns {object}
7369 * @private
7370 */
7371 getShapeOffsetData: function getShapeOffsetData(typeFilter) {
7372 var $$ = this,
7373 targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))),
7374 isStackNormalized = $$.isStackNormalized(),
7375 shapeOffsetTargets = targets.map(function (target) {
7376 var rowValues = target.values,
7377 values = {};
7378
7379 if ($$.isStepType(target)) {
7380 rowValues = $$.convertValuesToStep(rowValues);
7381 }
7382
7383 var rowValueMapByXValue = rowValues.reduce(function (out, d) {
7384 var key = +d.x;
7385 out[key] = d;
7386 values[key] = isStackNormalized ? $$.getRatio("index", d, !0) : d.value;
7387 return out;
7388 }, {});
7389 return {
7390 id: target.id,
7391 rowValues: rowValues,
7392 rowValueMapByXValue: rowValueMapByXValue,
7393 values: values
7394 };
7395 }),
7396 indexMapByTargetId = targets.reduce(function (out, _ref, index) {
7397 var id = _ref.id;
7398 out[id] = index;
7399 return out;
7400 }, {});
7401 return {
7402 indexMapByTargetId: indexMapByTargetId,
7403 shapeOffsetTargets: shapeOffsetTargets
7404 };
7405 },
7406 getShapeOffset: function getShapeOffset(typeFilter, indices, isSub) {
7407 var $$ = this,
7408 _$$$getShapeOffsetDat = $$.getShapeOffsetData(typeFilter),
7409 shapeOffsetTargets = _$$$getShapeOffsetDat.shapeOffsetTargets,
7410 indexMapByTargetId = _$$$getShapeOffsetDat.indexMapByTargetId;
7411
7412 return function (d, idx) {
7413 var id = d.id,
7414 value = d.value,
7415 x = d.x,
7416 ind = $$.getIndices(indices, id),
7417 scale = $$.getYScaleById(id, isSub),
7418 y0 = scale($$.getShapeYMin(id)),
7419 dataXAsNumber = +x,
7420 offset = y0;
7421 shapeOffsetTargets.filter(function (t) {
7422 return t.id !== id;
7423 }).forEach(function (t) {
7424 var tid = t.id,
7425 rowValueMapByXValue = t.rowValueMapByXValue,
7426 rowValues = t.rowValues,
7427 tvalues = t.values;
7428
7429 if (ind[tid] === ind[id] && indexMapByTargetId[tid] < indexMapByTargetId[id]) {
7430 var _row,
7431 row = rowValues[idx];
7432
7433 // check if the x values line up
7434 if (!row || +row.x !== dataXAsNumber) {
7435 row = rowValueMapByXValue[dataXAsNumber];
7436 }
7437
7438 if (((_row = row) == null ? void 0 : _row.value) * value >= 0 && isNumber(tvalues[dataXAsNumber])) {
7439 offset += scale(tvalues[dataXAsNumber]) - y0;
7440 }
7441 }
7442 });
7443 return offset;
7444 };
7445 },
7446 getBarW: function getBarW(type, axis, targetsNum) {
7447 var $$ = this,
7448 config = $$.config,
7449 org = $$.org,
7450 scale = $$.scale,
7451 maxDataCount = $$.getMaxDataCount(),
7452 isGrouped = type === "bar" && config.data_groups.length,
7453 configName = type + "_width",
7454 tickInterval = scale.zoom && !$$.axis.isCategorized() ? org.xDomain.map(function (v) {
7455 return scale.zoom(v);
7456 }).reduce(function (a, c) {
7457 return Math.abs(a) + c;
7458 }) / maxDataCount : axis.tickInterval(maxDataCount),
7459 getWidth = function (id) {
7460 var width = id ? config[configName][id] : config[configName],
7461 ratio = id ? width.ratio : config[configName + "_ratio"],
7462 max = id ? width.max : config[configName + "_max"],
7463 w = isNumber(width) ? width : targetsNum ? tickInterval * ratio / targetsNum : 0;
7464 return max && w > max ? max : w;
7465 },
7466 result = getWidth();
7467
7468 if (!isGrouped && isObjectType(config[configName])) {
7469 result = {
7470 _$width: result,
7471 _$total: []
7472 };
7473 $$.filterTargetsToShow($$.data.targets).forEach(function (v) {
7474 if (config[configName][v.id]) {
7475 result[v.id] = getWidth(v.id);
7476
7477 result._$total.push(result[v.id] || result._$width);
7478 }
7479 });
7480 }
7481
7482 return result;
7483 },
7484
7485 /**
7486 * Get shape element
7487 * @param {string} shapeName Shape string
7488 * @param {number} i Index number
7489 * @param {string} id Data series id
7490 * @returns {d3Selection}
7491 * @private
7492 */
7493 getShapeByIndex: function getShapeByIndex(shapeName, i, id) {
7494 var $$ = this,
7495 $el = $$.$el,
7496 suffix = isValue(i) ? "-" + i : "",
7497 shape = $el[shapeName];
7498
7499 // filter from shape reference if has
7500 if (shape && !shape.empty()) {
7501 shape = shape.filter(function (d) {
7502 return id ? d.id === id : !0;
7503 }).filter(function (d) {
7504 return isValue(i) ? d.index === i : !0;
7505 });
7506 } else {
7507 shape = (id ? $el.main.selectAll("." + config_classes[shapeName + "s"] + $$.getTargetSelectorSuffix(id)) : $el.main).selectAll("." + config_classes[shapeName] + suffix);
7508 }
7509
7510 return shape;
7511 },
7512 isWithinShape: function isWithinShape(that, d) {
7513 var $$ = this,
7514 shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that),
7515 isWithin;
7516
7517 if (!$$.isTargetToShow(d.id)) {
7518 isWithin = !1;
7519 } else if ($$.hasValidPointType != null && $$.hasValidPointType(that.nodeName)) {
7520 isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) : $$.isWithinCircle(that, $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0);
7521 } else if (that.nodeName === "path") {
7522 isWithin = shape.classed(config_classes.bar) ? $$.isWithinBar(that) : !0;
7523 }
7524
7525 return isWithin;
7526 },
7527 getInterpolate: function getInterpolate(d) {
7528 var $$ = this,
7529 interpolation = $$.getInterpolateType(d);
7530 return {
7531 "basis": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasis,
7532 "basis-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisClosed,
7533 "basis-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisOpen,
7534 "bundle": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBundle,
7535 "cardinal": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinal,
7536 "cardinal-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalClosed,
7537 "cardinal-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalOpen,
7538 "catmull-rom": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRom,
7539 "catmull-rom-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomClosed,
7540 "catmull-rom-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomOpen,
7541 "monotone-x": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneX,
7542 "monotone-y": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneY,
7543 "natural": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveNatural,
7544 "linear-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinearClosed,
7545 "linear": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinear,
7546 "step": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStep,
7547 "step-after": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepAfter,
7548 "step-before": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepBefore
7549 }[interpolation];
7550 },
7551 getInterpolateType: function getInterpolateType(d) {
7552 var $$ = this,
7553 config = $$.config,
7554 type = config.spline_interpolation_type,
7555 interpolation = $$.isInterpolationType(type) ? type : "cardinal";
7556 return $$.isSplineType(d) ? interpolation : $$.isStepType(d) ? config.line_step_type : "linear";
7557 }
7558});
7559;// CONCATENATED MODULE: ./src/ChartInternal/internals/size.ts
7560/**
7561 * Copyright (c) 2017 ~ present NAVER Corp.
7562 * billboard.js project is licensed under the MIT license
7563 */
7564
7565
7566
7567/* harmony default export */ var size = ({
7568 /**
7569 * Update container size
7570 * @private
7571 */
7572 setContainerSize: function setContainerSize() {
7573 var $$ = this,
7574 state = $$.state;
7575 state.current.width = $$.getCurrentWidth();
7576 state.current.height = $$.getCurrentHeight();
7577 },
7578 getCurrentWidth: function getCurrentWidth() {
7579 var $$ = this;
7580 return $$.config.size_width || $$.getParentWidth();
7581 },
7582 getCurrentHeight: function getCurrentHeight() {
7583 var $$ = this,
7584 config = $$.config,
7585 h = config.size_height || $$.getParentHeight();
7586 return h > 0 ? h : 320 / ($$.hasType("gauge") && !config.gauge_fullCircle ? 2 : 1);
7587 },
7588 getCurrentPaddingTop: function getCurrentPaddingTop() {
7589 var $$ = this,
7590 config = $$.config,
7591 hasAxis = $$.state.hasAxis,
7592 $el = $$.$el,
7593 axesLen = hasAxis ? config.axis_y2_axes.length : 0,
7594 padding = isValue(config.padding_top) ? config.padding_top : 0;
7595
7596 if ($el.title && $el.title.node()) {
7597 padding += $$.getTitlePadding();
7598 }
7599
7600 if (axesLen && config.axis_rotated) {
7601 padding += $$.getHorizontalAxisHeight("y2") * axesLen;
7602 }
7603
7604 return padding;
7605 },
7606 getCurrentPaddingBottom: function getCurrentPaddingBottom() {
7607 var $$ = this,
7608 config = $$.config,
7609 hasAxis = $$.state.hasAxis,
7610 axisId = config.axis_rotated ? "y" : "x",
7611 axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
7612 padding = isValue(config.padding_bottom) ? config.padding_bottom : 0;
7613 return padding + (axesLen ? $$.getHorizontalAxisHeight(axisId) * axesLen : 0);
7614 },
7615 getCurrentPaddingLeft: function getCurrentPaddingLeft(withoutRecompute) {
7616 var $$ = this,
7617 config = $$.config,
7618 hasAxis = $$.state.hasAxis,
7619 isRotated = config.axis_rotated,
7620 axisId = isRotated ? "x" : "y",
7621 axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
7622 axisWidth = hasAxis ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : 0,
7623 padding;
7624
7625 if (isValue(config.padding_left)) {
7626 padding = config.padding_left;
7627 } else if (hasAxis && isRotated) {
7628 padding = !config.axis_x_show ? 1 : Math.max(ceil10(axisWidth), 40);
7629 } else if (hasAxis && (!config.axis_y_show || config.axis_y_inner)) {
7630 // && !config.axis_rotated
7631 padding = $$.axis.getAxisLabelPosition("y").isOuter ? 30 : 1;
7632 } else {
7633 padding = ceil10(axisWidth);
7634 }
7635
7636 return padding + axisWidth * axesLen;
7637 },
7638 getCurrentPaddingRight: function getCurrentPaddingRight(withXAxisTickTextOverflow) {
7639 if (withXAxisTickTextOverflow === void 0) {
7640 withXAxisTickTextOverflow = !1;
7641 }
7642
7643 var $$ = this,
7644 config = $$.config,
7645 hasAxis = $$.state.hasAxis,
7646 defaultPadding = 10,
7647 legendWidthOnRight = $$.state.isLegendRight ? $$.getLegendWidth() + 20 : 0,
7648 axesLen = hasAxis ? config.axis_y2_axes.length : 0,
7649 axisWidth = hasAxis ? $$.getAxisWidthByAxisId("y2") : 0,
7650 xAxisTickTextOverflow = withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0,
7651 padding;
7652
7653 if (isValue(config.padding_right)) {
7654 padding = config.padding_right + 1; // 1 is needed not to hide tick line
7655 } else if ($$.axis && config.axis_rotated) {
7656 padding = defaultPadding + legendWidthOnRight;
7657 } else if ($$.axis && (!config.axis_y2_show || config.axis_y2_inner)) {
7658 // && !config.axis_rotated
7659 padding = Math.max(2 + legendWidthOnRight + ($$.axis.getAxisLabelPosition("y2").isOuter ? 20 : 0), xAxisTickTextOverflow);
7660 } else {
7661 padding = Math.max(ceil10(axisWidth) + legendWidthOnRight, xAxisTickTextOverflow);
7662 }
7663
7664 return padding + axisWidth * axesLen;
7665 },
7666
7667 /**
7668 * Get the parent rect element's size
7669 * @param {string} key property/attribute name
7670 * @returns {number}
7671 * @private
7672 */
7673 getParentRectValue: function getParentRectValue(key) {
7674 var offsetName = "offset" + capitalize(key),
7675 parent = this.$el.chart.node(),
7676 v = 0;
7677
7678 while (v < 30 && parent && parent.tagName !== "BODY") {
7679 try {
7680 v = parent.getBoundingClientRect()[key];
7681 } catch (e) {
7682 if (offsetName in parent) {
7683 // In IE in certain cases getBoundingClientRect
7684 // will cause an "unspecified error"
7685 v = parent[offsetName];
7686 }
7687 }
7688
7689 parent = parent.parentNode;
7690 } // Sometimes element's dimension value is incorrect(ex. flex container)
7691 // In this case, use body's offset instead.
7692
7693
7694 var bodySize = browser_doc.body[offsetName];
7695 v > bodySize && (v = bodySize);
7696 return v;
7697 },
7698 getParentWidth: function getParentWidth() {
7699 return this.getParentRectValue("width");
7700 },
7701 getParentHeight: function getParentHeight() {
7702 var h = this.$el.chart.style("height"),
7703 height = 0;
7704
7705 if (h) {
7706 height = /px$/.test(h) ? parseInt(h, 10) : this.getParentRectValue("height");
7707 }
7708
7709 return height;
7710 },
7711 getSvgLeft: function getSvgLeft(withoutRecompute) {
7712 var $$ = this,
7713 config = $$.config,
7714 $el = $$.$el,
7715 hasLeftAxisRect = config.axis_rotated || !config.axis_rotated && !config.axis_y_inner,
7716 leftAxisClass = config.axis_rotated ? config_classes.axisX : config_classes.axisY,
7717 leftAxis = $el.main.select("." + leftAxisClass).node(),
7718 svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : {
7719 right: 0
7720 },
7721 chartRect = $el.chart.node().getBoundingClientRect(),
7722 hasArc = $$.hasArcType(),
7723 svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute));
7724 return svgLeft > 0 ? svgLeft : 0;
7725 },
7726 updateDimension: function updateDimension(withoutAxis) {
7727 var $$ = this,
7728 config = $$.config,
7729 hasAxis = $$.state.hasAxis,
7730 $el = $$.$el;
7731
7732 if (hasAxis && !withoutAxis && $$.axis.x && config.axis_rotated) {
7733 var _$$$axis$subX;
7734
7735 (_$$$axis$subX = $$.axis.subX) == null ? void 0 : _$$$axis$subX.create($el.axis.subX);
7736 } // pass 'withoutAxis' param to not animate at the init rendering
7737
7738
7739 $$.updateScales(withoutAxis);
7740 $$.updateSvgSize();
7741 $$.transformAll(!1);
7742 },
7743 updateSvgSize: function updateSvgSize() {
7744 var $$ = this,
7745 _$$$state = $$.state,
7746 clip = _$$$state.clip,
7747 current = _$$$state.current,
7748 hasAxis = _$$$state.hasAxis,
7749 width = _$$$state.width,
7750 height = _$$$state.height,
7751 svg = $$.$el.svg;
7752 svg.attr("width", current.width).attr("height", current.height);
7753
7754 if (hasAxis) {
7755 var brush = svg.select("." + config_classes.brush + " .overlay"),
7756 brushSize = {
7757 width: 0,
7758 height: 0
7759 };
7760
7761 if (brush.size()) {
7762 brushSize.width = +brush.attr("width");
7763 brushSize.height = +brush.attr("height");
7764 }
7765
7766 svg.selectAll(["#" + clip.id, "#" + clip.idGrid]).select("rect").attr("width", width).attr("height", height);
7767 svg.select("#" + clip.idXAxis).select("rect").call($$.setXAxisClipPath.bind($$));
7768 svg.select("#" + clip.idYAxis).select("rect").call($$.setYAxisClipPath.bind($$));
7769 clip.idSubchart && svg.select("#" + clip.idSubchart).select("rect").attr("width", width).attr("height", brushSize.height);
7770 }
7771 },
7772
7773 /**
7774 * Update size values
7775 * @param {boolean} isInit If is called at initialization
7776 * @private
7777 */
7778 updateSizes: function updateSizes(isInit) {
7779 var $$ = this,
7780 config = $$.config,
7781 state = $$.state,
7782 legend = $$.$el.legend,
7783 isRotated = config.axis_rotated,
7784 hasArc = $$.hasArcType();
7785 isInit || $$.setContainerSize();
7786 var currLegend = {
7787 width: legend ? $$.getLegendWidth() : 0,
7788 height: legend ? $$.getLegendHeight() : 0
7789 };
7790
7791 if (!hasArc && config.axis_x_show && config.axis_x_tick_autorotate) {
7792 $$.updateXAxisTickClip();
7793 }
7794
7795 var legendHeightForBottom = state.isLegendRight || state.isLegendInset ? 0 : currLegend.height,
7796 xAxisHeight = isRotated || hasArc ? 0 : $$.getHorizontalAxisHeight("x"),
7797 subchartXAxisHeight = config.subchart_axis_x_show && config.subchart_axis_x_tick_text_show ? xAxisHeight : 30,
7798 subchartHeight = config.subchart_show && !hasArc ? config.subchart_size_height + subchartXAxisHeight : 0;
7799 // for main
7800 state.margin = !hasArc && isRotated ? {
7801 top: $$.getHorizontalAxisHeight("y2") + $$.getCurrentPaddingTop(),
7802 right: hasArc ? 0 : $$.getCurrentPaddingRight(!0),
7803 bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom + $$.getCurrentPaddingBottom(),
7804 left: subchartHeight + (hasArc ? 0 : $$.getCurrentPaddingLeft())
7805 } : {
7806 top: 4 + $$.getCurrentPaddingTop(),
7807 // for top tick text
7808 right: hasArc ? 0 : $$.getCurrentPaddingRight(!0),
7809 bottom: xAxisHeight + subchartHeight + legendHeightForBottom + $$.getCurrentPaddingBottom(),
7810 left: hasArc ? 0 : $$.getCurrentPaddingLeft()
7811 }; // for subchart
7812
7813 state.margin2 = isRotated ? {
7814 top: state.margin.top,
7815 right: NaN,
7816 bottom: 20 + legendHeightForBottom,
7817 left: $$.state.rotatedPadding.left
7818 } : {
7819 top: state.current.height - subchartHeight - legendHeightForBottom,
7820 right: NaN,
7821 bottom: subchartXAxisHeight + legendHeightForBottom,
7822 left: state.margin.left
7823 }; // for legend
7824
7825 state.margin3 = {
7826 top: 0,
7827 right: NaN,
7828 bottom: 0,
7829 left: 0
7830 };
7831 $$.updateSizeForLegend == null ? void 0 : $$.updateSizeForLegend(currLegend);
7832 state.width = state.current.width - state.margin.left - state.margin.right;
7833 state.height = state.current.height - state.margin.top - state.margin.bottom;
7834
7835 if (state.width < 0) {
7836 state.width = 0;
7837 }
7838
7839 if (state.height < 0) {
7840 state.height = 0;
7841 }
7842
7843 state.width2 = isRotated ? state.margin.left - state.rotatedPadding.left - state.rotatedPadding.right : state.width;
7844 state.height2 = isRotated ? state.height : state.current.height - state.margin2.top - state.margin2.bottom;
7845
7846 if (state.width2 < 0) {
7847 state.width2 = 0;
7848 }
7849
7850 if (state.height2 < 0) {
7851 state.height2 = 0;
7852 } // for arc
7853
7854
7855 var hasGauge = $$.hasType("gauge"),
7856 isLegendRight = config.legend_show && state.isLegendRight;
7857 state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0);
7858 state.arcHeight = state.height - (isLegendRight && !hasGauge ? 0 : 10);
7859
7860 if (hasGauge && !config.gauge_fullCircle) {
7861 state.arcHeight += state.height - $$.getPaddingBottomForGauge();
7862 }
7863
7864 $$.updateRadius == null ? void 0 : $$.updateRadius();
7865
7866 if (state.isLegendRight && hasArc) {
7867 state.margin3.left = state.arcWidth / 2 + state.radiusExpanded * 1.1;
7868 }
7869 }
7870});
7871;// CONCATENATED MODULE: ./src/ChartInternal/internals/text.ts
7872/**
7873 * Copyright (c) 2017 ~ present NAVER Corp.
7874 * billboard.js project is licensed under the MIT license
7875 */
7876
7877
7878
7879
7880/* harmony default export */ var internals_text = ({
7881 opacityForText: function opacityForText(d) {
7882 var $$ = this;
7883 return $$.isBarType(d) && !$$.meetsLabelThreshold(Math.abs($$.getRatio("bar", d)), "bar") ? "0" : $$.hasDataLabel ? null : "0";
7884 },
7885
7886 /**
7887 * Initializes the text
7888 * @private
7889 */
7890 initText: function initText() {
7891 var $el = this.$el;
7892 $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartTexts);
7893 },
7894
7895 /**
7896 * Update chartText
7897 * @param {object} targets $$.data.targets
7898 * @private
7899 */
7900 updateTargetsForText: function updateTargetsForText(targets) {
7901 var $$ = this,
7902 classChartText = $$.getChartClass("Text"),
7903 classTexts = $$.getClass("texts", "id"),
7904 classFocus = $$.classFocus.bind($$),
7905 mainTextUpdate = $$.$el.main.select("." + config_classes.chartTexts).selectAll("." + config_classes.chartText).data(targets).attr("class", function (d) {
7906 return classChartText(d) + classFocus(d);
7907 }),
7908 mainTextEnter = mainTextUpdate.enter().append("g").style("opacity", "0").attr("class", classChartText).style("pointer-events", "none");
7909 mainTextEnter.append("g").attr("class", classTexts);
7910 },
7911
7912 /**
7913 * Update text
7914 * @private
7915 */
7916 updateText: function updateText() {
7917 var $$ = this,
7918 $el = $$.$el,
7919 $T = $$.$T,
7920 config = $$.config,
7921 classText = $$.getClass("text", "index"),
7922 text = $el.main.selectAll("." + config_classes.texts).selectAll("." + config_classes.text).data($$.labelishData.bind($$));
7923 $T(text.exit()).style("fill-opacity", "0").remove();
7924 $el.text = text.enter().append("text").merge(text).attr("class", classText).attr("text-anchor", function (d) {
7925 // when value is negative or
7926 var isEndAnchor = d.value < 0;
7927
7928 if ($$.isCandlestickType(d)) {
7929 var data = $$.getCandlestickData(d);
7930 isEndAnchor = !(data != null && data._isUp);
7931 }
7932
7933 return config.axis_rotated ? isEndAnchor ? "end" : "start" : "middle";
7934 }).style("fill", $$.updateTextColor.bind($$)).style("fill-opacity", "0").each(function (d, i, texts) {
7935 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
7936 value = d.value;
7937
7938 if ($$.isBubbleZType(d)) {
7939 value = $$.getBubbleZData(value, "z");
7940 } else if ($$.isCandlestickType(d)) {
7941 var data = $$.getCandlestickData(d);
7942
7943 if (data) {
7944 value = data.close;
7945 }
7946 }
7947
7948 value = $$.dataLabelFormat(d.id)(value, d.id, i, texts);
7949
7950 if (isNumber(value)) {
7951 this.textContent = value;
7952 } else {
7953 setTextValue(node, value);
7954 }
7955 });
7956 },
7957 updateTextColor: function updateTextColor(d) {
7958 var $$ = this,
7959 config = $$.config,
7960 labelColors = config.data_labels_colors,
7961 defaultColor = $$.isArcType(d) && !$$.isRadarType(d) ? null : $$.color(d),
7962 color;
7963
7964 if (isString(labelColors)) {
7965 color = labelColors;
7966 } else if (isObject(labelColors)) {
7967 var _ref = d.data || d,
7968 id = _ref.id;
7969
7970 color = labelColors[id];
7971 } else if (isFunction(labelColors)) {
7972 color = labelColors.bind($$.api)(defaultColor, d);
7973 }
7974
7975 if ($$.isCandlestickType(d) && !isFunction(labelColors)) {
7976 var value = $$.getCandlestickData(d);
7977
7978 if (!(value != null && value._isUp)) {
7979 var downColor = config.candlestick_color_down;
7980 color = isObject(downColor) ? downColor[d.id] : downColor;
7981 }
7982 }
7983
7984 return color || defaultColor;
7985 },
7986
7987 /**
7988 * Update data label text background color
7989 * @param {object} d Data object
7990 * @returns {string|null}
7991 * @private
7992 */
7993 updateTextBacgroundColor: function updateTextBacgroundColor(d) {
7994 var $$ = this,
7995 $el = $$.$el,
7996 config = $$.config,
7997 backgroundColor = config.data_labels_backgroundColors,
7998 color = "";
7999
8000 if (isString(backgroundColor) || isObject(backgroundColor)) {
8001 var id = isString(backgroundColor) ? "" : $$.getTargetSelectorSuffix("id" in d ? d.id : d.data.id),
8002 filter = $el.defs.select(["filter[id*='labels-bg", "']"].join(id));
8003
8004 if (filter.size()) {
8005 color = "url(#" + filter.attr("id") + ")";
8006 }
8007 }
8008
8009 return color || null;
8010 },
8011
8012 /**
8013 * Redraw chartText
8014 * @param {Function} x Positioning function for x
8015 * @param {Function} y Positioning function for y
8016 * @param {boolean} forFlow Weather is flow
8017 * @param {boolean} withTransition transition is enabled
8018 * @returns {Array}
8019 * @private
8020 */
8021 redrawText: function redrawText(x, y, forFlow, withTransition) {
8022 var $$ = this,
8023 $T = $$.$T,
8024 t = getRandom(!0);
8025 $$.$el.text.style("fill", $$.updateTextColor.bind($$)).attr("filter", $$.updateTextBacgroundColor.bind($$)).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function (d, i) {
8026 // do not apply transition for newly added text elements
8027 var node = $T(this, !!(withTransition && this.getAttribute("x")), t),
8028 posX = x.bind(this)(d, i),
8029 posY = y.bind(this)(d, i);
8030
8031 // when is multiline
8032 if (this.childElementCount) {
8033 node.attr("transform", "translate(" + posX + " " + posY + ")");
8034 } else {
8035 node.attr("x", posX).attr("y", posY);
8036 }
8037 }); // need to return 'true' as of being pushed to the redraw list
8038 // ref: getRedrawList()
8039
8040 return !0;
8041 },
8042
8043 /**
8044 * Gets the getBoundingClientRect value of the element
8045 * @param {HTMLElement|d3.selection} element Target element
8046 * @param {string} className Class name
8047 * @returns {object} value of element.getBoundingClientRect()
8048 * @private
8049 */
8050 getTextRect: function getTextRect(element, className) {
8051 var $$ = this,
8052 base = element.node ? element.node() : element;
8053
8054 if (!/text/i.test(base.tagName)) {
8055 base = base.querySelector("text");
8056 }
8057
8058 var text = base.textContent,
8059 cacheKey = KEY.textRect + "-" + text.replace(/\W/g, "_"),
8060 rect = $$.cache.get(cacheKey);
8061
8062 if (!rect) {
8063 $$.$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) {
8064 rect = getBoundingRect(v.node());
8065 }).remove();
8066 $$.cache.add(cacheKey, rect);
8067 }
8068
8069 return rect;
8070 },
8071
8072 /**
8073 * Gets the x or y coordinate of the text
8074 * @param {object} indices Indices values
8075 * @param {boolean} forX whether or not to x
8076 * @returns {number} coordinates
8077 * @private
8078 */
8079 generateXYForText: function generateXYForText(indices, forX) {
8080 var $$ = this,
8081 types = Object.keys(indices),
8082 points = {},
8083 getter = forX ? $$.getXForText : $$.getYForText;
8084 $$.hasType("radar") && types.push("radar");
8085 types.forEach(function (v) {
8086 points[v] = $$["generateGet" + capitalize(v) + "Points"](indices[v], !1);
8087 });
8088 return function (d, i) {
8089 var type = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar" || $$.isCandlestickType(d) && "candlestick" || $$.isRadarType(d) && "radar" || "line";
8090 return getter.call($$, points[type](d, i), d, this);
8091 };
8092 },
8093
8094 /**
8095 * Get centerized text position for bar type data.label.text
8096 * @param {object} d Data object
8097 * @param {Array} points Data points position
8098 * @param {HTMLElement} textElement Data label text element
8099 * @returns {number} Position value
8100 * @private
8101 */
8102 getCenteredTextPos: function getCenteredTextPos(d, points, textElement) {
8103 var $$ = this,
8104 config = $$.config,
8105 isRotated = config.axis_rotated;
8106
8107 if (config.data_labels.centered && $$.isBarType(d)) {
8108 var rect = getBoundingRect(textElement),
8109 isPositive = d.value >= 0;
8110
8111 if (isRotated) {
8112 var w = (isPositive ? points[1][1] - points[0][1] : points[0][1] - points[1][1]) / 2 + rect.width / 2;
8113 return isPositive ? -w - 3 : w + 2;
8114 } else {
8115 var h = (isPositive ? points[0][1] - points[1][1] : points[1][1] - points[0][1]) / 2 + rect.height / 2;
8116 return isPositive ? h : -h - 2;
8117 }
8118 }
8119
8120 return 0;
8121 },
8122
8123 /**
8124 * Get data.labels.position value
8125 * @param {string} id Data id value
8126 * @param {string} type x | y
8127 * @returns {number} Position value
8128 * @private
8129 */
8130 getTextPos: function getTextPos(id, type) {
8131 var pos = this.config.data_labels_position;
8132 return (id in pos ? pos[id] : pos)[type] || 0;
8133 },
8134
8135 /**
8136 * Gets the x coordinate of the text
8137 * @param {object} points Data points position
8138 * @param {object} d Data object
8139 * @param {HTMLElement} textElement Data label text element
8140 * @returns {number} x coordinate
8141 * @private
8142 */
8143 getXForText: function getXForText(points, d, textElement) {
8144 var $$ = this,
8145 config = $$.config,
8146 state = $$.state,
8147 isRotated = config.axis_rotated,
8148 xPos = points[0][0];
8149
8150 if ($$.hasType("candlestick")) {
8151 if (isRotated) {
8152 xPos = $$.getCandlestickData(d)._isUp ? points[2][2] + 4 : points[2][1] - 4;
8153 } else {
8154 xPos += (points[1][0] - xPos) / 2;
8155 }
8156 } else {
8157 if (isRotated) {
8158 var padding = $$.isBarType(d) ? 4 : 6;
8159 xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1);
8160 } else {
8161 xPos = $$.hasType("bar") ? (points[2][0] + points[0][0]) / 2 : xPos;
8162 }
8163 } // show labels regardless of the domain if value is null
8164
8165
8166 if (d.value === null) {
8167 if (xPos > state.width) {
8168 var _getBoundingRect = getBoundingRect(textElement),
8169 width = _getBoundingRect.width;
8170
8171 xPos = state.width - width;
8172 } else if (xPos < 0) {
8173 xPos = 4;
8174 }
8175 }
8176
8177 if (isRotated) {
8178 xPos += $$.getCenteredTextPos(d, points, textElement);
8179 }
8180
8181 return xPos + $$.getTextPos(d.id, "x");
8182 },
8183
8184 /**
8185 * Gets the y coordinate of the text
8186 * @param {object} points Data points position
8187 * @param {object} d Data object
8188 * @param {HTMLElement} textElement Data label text element
8189 * @returns {number} y coordinate
8190 * @private
8191 */
8192 getYForText: function getYForText(points, d, textElement) {
8193 var $$ = this,
8194 config = $$.config,
8195 state = $$.state,
8196 isRotated = config.axis_rotated,
8197 r = config.point_r,
8198 rect = getBoundingRect(textElement),
8199 value = d.value,
8200 baseY = 3,
8201 yPos;
8202
8203 if ($$.isCandlestickType(d)) {
8204 value = $$.getCandlestickData(d);
8205
8206 if (isRotated) {
8207 yPos = points[0][0];
8208 yPos += (points[1][0] - yPos) / 2 + baseY;
8209 } else {
8210 yPos = value && value._isUp ? points[2][2] - baseY : points[2][1] + baseY * 4;
8211 }
8212 } else {
8213 if (isRotated) {
8214 yPos = (points[0][0] + points[2][0] + rect.height * .6) / 2;
8215 } else {
8216 yPos = points[2][1];
8217
8218 if (isNumber(r) && r > 5 && ($$.isLineType(d) || $$.isScatterType(d))) {
8219 baseY += config.point_r / 2.3;
8220 }
8221
8222 if (value < 0 || value === 0 && !state.hasPositiveValue && state.hasNegativeValue) {
8223 yPos += rect.height + ($$.isBarType(d) ? -baseY : baseY);
8224 } else {
8225 var diff = -baseY * 2;
8226
8227 if ($$.isBarType(d)) {
8228 diff = -baseY;
8229 } else if ($$.isBubbleType(d)) {
8230 diff = baseY;
8231 }
8232
8233 yPos += diff;
8234 }
8235 }
8236 } // show labels regardless of the domain if value is null
8237
8238
8239 if (d.value === null && !isRotated) {
8240 var boxHeight = rect.height;
8241
8242 if (yPos < boxHeight) {
8243 yPos = boxHeight;
8244 } else if (yPos > state.height) {
8245 yPos = state.height - 4;
8246 }
8247 }
8248
8249 if (!isRotated) {
8250 yPos += $$.getCenteredTextPos(d, points, textElement);
8251 }
8252
8253 return yPos + $$.getTextPos(d.id, "y");
8254 },
8255
8256 /**
8257 * Calculate if two or more text nodes are overlapping
8258 * Mark overlapping text nodes with "text-overlapping" class
8259 * @param {string} id Axis id
8260 * @param {ChartInternal} $$ ChartInternal context
8261 * @param {string} selector Selector string
8262 * @private
8263 */
8264 markOverlapped: function markOverlapped(id, $$, selector) {
8265 var textNodes = $$.$el.arcs.selectAll(selector),
8266 filteredTextNodes = textNodes.filter(function (node) {
8267 return node.data.id !== id;
8268 }),
8269 textNode = textNodes.filter(function (node) {
8270 return node.data.id === id;
8271 }),
8272 translate = getTranslation(textNode.node()),
8273 calcHypo = function (x, y) {
8274 return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
8275 };
8276
8277 textNode.node() && filteredTextNodes.each(function () {
8278 var coordinate = getTranslation(this),
8279 filteredTextNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
8280 nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : filteredTextNode,
8281 overlapsX = Math.ceil(Math.abs(translate.e - coordinate.e)) < Math.ceil(nodeForWidth.node().getComputedTextLength()),
8282 overlapsY = Math.ceil(Math.abs(translate.f - coordinate.f)) < parseInt(textNode.style("font-size"), 10);
8283 filteredTextNode.classed(config_classes.TextOverlapping, overlapsX && overlapsY);
8284 });
8285 },
8286
8287 /**
8288 * Calculate if two or more text nodes are overlapping
8289 * Remove "text-overlapping" class on selected text nodes
8290 * @param {ChartInternal} $$ ChartInternal context
8291 * @param {string} selector Selector string
8292 * @private
8293 */
8294 undoMarkOverlapped: function undoMarkOverlapped($$, selector) {
8295 $$.$el.arcs.selectAll(selector).each(function () {
8296 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([this, this.previousSibling]).classed(config_classes.TextOverlapping, !1);
8297 });
8298 },
8299
8300 /**
8301 * Check if meets the ratio to show data label text
8302 * @param {number} ratio ratio to meet
8303 * @param {string} type chart type
8304 * @returns {boolean}
8305 * @private
8306 */
8307 meetsLabelThreshold: function meetsLabelThreshold(ratio, type) {
8308 if (ratio === void 0) {
8309 ratio = 0;
8310 }
8311
8312 var $$ = this,
8313 config = $$.config,
8314 threshold = config[type + "_label_threshold"] || 0;
8315 return ratio >= threshold;
8316 }
8317});
8318;// CONCATENATED MODULE: ./src/ChartInternal/internals/title.ts
8319/**
8320 * Copyright (c) 2017 ~ present NAVER Corp.
8321 * billboard.js project is licensed under the MIT license
8322 */
8323
8324
8325/**
8326 * Get the text position
8327 * @param {string} pos right, left or center
8328 * @param {number} width chart width
8329 * @returns {string|number} text-anchor value or position in pixel
8330 * @private
8331 */
8332
8333function getTextPos(pos, width) {
8334 if (pos === void 0) {
8335 pos = "left";
8336 }
8337
8338 var isNum = isNumber(width),
8339 position;
8340
8341 if (pos.indexOf("center") > -1) {
8342 position = isNum ? width / 2 : "middle";
8343 } else if (pos.indexOf("right") > -1) {
8344 position = isNum ? width : "end";
8345 } else {
8346 position = isNum ? 0 : "start";
8347 }
8348
8349 return position;
8350}
8351
8352/* harmony default export */ var internals_title = ({
8353 /**
8354 * Initializes the title
8355 * @private
8356 */
8357 initTitle: function initTitle() {
8358 var $$ = this,
8359 config = $$.config,
8360 $el = $$.$el;
8361
8362 if (config.title_text) {
8363 $el.title = $el.svg.append("g");
8364 var text = $el.title.append("text").style("text-anchor", getTextPos(config.title_position)).attr("class", config_classes.title);
8365 setTextValue(text, config.title_text, [.3, 1.5]);
8366 }
8367 },
8368
8369 /**
8370 * Redraw title
8371 * @private
8372 */
8373 redrawTitle: function redrawTitle() {
8374 var $$ = this,
8375 config = $$.config,
8376 current = $$.state.current,
8377 title = $$.$el.title;
8378
8379 if (title) {
8380 var y = $$.yForTitle.call($$);
8381
8382 if (/g/i.test(title.node().tagName)) {
8383 title.attr("transform", "translate(" + getTextPos(config.title_position, current.width) + ", " + y + ")");
8384 } else {
8385 title.attr("x", $$.xForTitle.call($$)).attr("y", y);
8386 }
8387 }
8388 },
8389
8390 /**
8391 * Returns the x attribute value of the title
8392 * @returns {number} x attribute value
8393 * @private
8394 */
8395 xForTitle: function xForTitle() {
8396 var $$ = this,
8397 config = $$.config,
8398 current = $$.state.current,
8399 position = config.title_position || "left",
8400 textRectWidth = $$.getTextRect($$.$el.title, config_classes.title).width,
8401 x;
8402
8403 if (/(right|center)/.test(position)) {
8404 x = current.width - textRectWidth;
8405
8406 if (position.indexOf("right") >= 0) {
8407 x = current.width - textRectWidth - config.title_padding.right;
8408 } else if (position.indexOf("center") >= 0) {
8409 x = (current.width - textRectWidth) / 2;
8410 }
8411 } else {
8412 // left
8413 x = config.title_padding.left || 0;
8414 }
8415
8416 return x;
8417 },
8418
8419 /**
8420 * Returns the y attribute value of the title
8421 * @returns {number} y attribute value
8422 * @private
8423 */
8424 yForTitle: function yForTitle() {
8425 var $$ = this;
8426 return ($$.config.title_padding.top || 0) + $$.getTextRect($$.$el.title, config_classes.title).height;
8427 },
8428
8429 /**
8430 * Get title padding
8431 * @returns {number} padding value
8432 * @private
8433 */
8434 getTitlePadding: function getTitlePadding() {
8435 var $$ = this;
8436 return $$.yForTitle() + ($$.config.title_padding.bottom || 0);
8437 }
8438});
8439;// CONCATENATED MODULE: ./src/ChartInternal/internals/tooltip.ts
8440/**
8441 * Copyright (c) 2017 ~ present NAVER Corp.
8442 * billboard.js project is licensed under the MIT license
8443 */
8444
8445
8446
8447
8448/* harmony default export */ var internals_tooltip = ({
8449 /**
8450 * Initializes the tooltip
8451 * @private
8452 */
8453 initTooltip: function initTooltip() {
8454 var $$ = this,
8455 config = $$.config,
8456 $el = $$.$el;
8457 $el.tooltip = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.tooltip_contents.bindto);
8458
8459 if ($el.tooltip.empty()) {
8460 $el.tooltip = $el.chart.style("position", "relative").append("div").attr("class", config_classes.tooltipContainer).style("position", "absolute").style("pointer-events", "none").style("display", "none");
8461 }
8462
8463 $$.bindTooltipResizePos();
8464 },
8465 initShowTooltip: function initShowTooltip() {
8466 var $$ = this,
8467 config = $$.config,
8468 $el = $$.$el,
8469 _$$$state = $$.state,
8470 hasAxis = _$$$state.hasAxis,
8471 hasRadar = _$$$state.hasRadar;
8472
8473 // Show tooltip if needed
8474 if (config.tooltip_init_show) {
8475 var _$$$axis,
8476 _$$$axis2,
8477 isArc = !(hasAxis && hasRadar);
8478
8479 if ((_$$$axis = $$.axis) != null && _$$$axis.isTimeSeries() && isString(config.tooltip_init_x)) {
8480 var targets = $$.data.targets[0],
8481 i,
8482 val;
8483 config.tooltip_init_x = parseDate.call($$, config.tooltip_init_x);
8484
8485 for (i = 0; val = targets.values[i]; i++) {
8486 if (val.x - config.tooltip_init_x === 0) {
8487 break;
8488 }
8489 }
8490
8491 config.tooltip_init_x = i;
8492 }
8493
8494 var data = $$.data.targets.map(function (d) {
8495 var x = isArc ? 0 : config.tooltip_init_x;
8496 return $$.addName(d.values[x]);
8497 });
8498
8499 if (isArc) {
8500 data = [data[config.tooltip_init_x]];
8501 }
8502
8503 $el.tooltip.html($$.getTooltipHTML(data, (_$$$axis2 = $$.axis) == null ? void 0 : _$$$axis2.getXAxisTickFormat(), $$.getDefaultValueFormat(), $$.color));
8504
8505 if (!config.tooltip_contents.bindto) {
8506 $el.tooltip.style("top", config.tooltip_init_position.top).style("left", config.tooltip_init_position.left).style("display", null);
8507 }
8508 }
8509 },
8510
8511 /**
8512 * Get the tooltip HTML string
8513 * @param {Array} args Arguments
8514 * @returns {string} Formatted HTML string
8515 * @private
8516 */
8517 getTooltipHTML: function getTooltipHTML() {
8518 var $$ = this,
8519 api = $$.api,
8520 config = $$.config;
8521 return isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api).apply(void 0, arguments) : $$.getTooltipContent.apply($$, arguments);
8522 },
8523
8524 /**
8525 * Returns the tooltip content(HTML string)
8526 * @param {object} d data
8527 * @param {Function} defaultTitleFormat Default title format
8528 * @param {Function} defaultValueFormat Default format for each data value in the tooltip.
8529 * @param {Function} color Color function
8530 * @returns {string} html
8531 * @private
8532 */
8533 getTooltipContent: function getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) {
8534 var $$ = this,
8535 api = $$.api,
8536 config = $$.config,
8537 state = $$.state,
8538 _map = ["title", "name", "value"].map(function (v) {
8539 var fn = config["tooltip_format_" + v];
8540 return isFunction(fn) ? fn.bind(api) : fn;
8541 }),
8542 titleFormat = _map[0],
8543 nameFormat = _map[1],
8544 valueFormat = _map[2];
8545
8546 titleFormat = titleFormat || defaultTitleFormat;
8547
8548 nameFormat = nameFormat || function (name) {
8549 return name;
8550 };
8551
8552 valueFormat = valueFormat || ($$.isStackNormalized() ? function (v, ratio) {
8553 return (ratio * 100).toFixed(2) + "%";
8554 } : defaultValueFormat);
8555
8556 var order = config.tooltip_order,
8557 getRowValue = function (row) {
8558 return $$.axis && $$.isBubbleZType(row) ? $$.getBubbleZData(row.value, "z") : $$.getBaseValue(row);
8559 },
8560 getBgColor = $$.levelColor ? function (row) {
8561 return $$.levelColor(row.value);
8562 } : function (row) {
8563 return color(row);
8564 },
8565 contents = config.tooltip_contents,
8566 tplStr = contents.template,
8567 targetIds = $$.mapToTargetIds();
8568
8569 if (order === null && config.data_groups.length) {
8570 // for stacked data, order should aligned with the visually displayed data
8571 var ids = $$.orderTargets($$.data.targets).map(function (i2) {
8572 return i2.id;
8573 }).reverse();
8574 d.sort(function (a, b) {
8575 var v1 = a ? a.value : null,
8576 v2 = b ? b.value : null;
8577
8578 if (v1 > 0 && v2 > 0) {
8579 v1 = a.id ? ids.indexOf(a.id) : null;
8580 v2 = b.id ? ids.indexOf(b.id) : null;
8581 }
8582
8583 return v1 - v2;
8584 });
8585 } else if (/^(asc|desc)$/.test(order)) {
8586 d.sort(function (a, b) {
8587 var v1 = a ? getRowValue(a) : null,
8588 v2 = b ? getRowValue(b) : null;
8589 return order === "asc" ? v1 - v2 : v2 - v1;
8590 });
8591 } else if (isFunction(order)) {
8592 d.sort(order.bind(api));
8593 }
8594
8595 var tpl = $$.getTooltipContentTemplate(tplStr),
8596 len = d.length,
8597 text,
8598 row,
8599 param,
8600 value,
8601 i;
8602
8603 for (i = 0; i < len; i++) {
8604 row = d[i];
8605
8606 if (!row || !(getRowValue(row) || getRowValue(row) === 0)) {
8607 continue;
8608 }
8609
8610 if (isUndefined(text)) {
8611 var title = (state.hasAxis || state.hasRadar) && sanitise(titleFormat ? titleFormat(row.x) : row.x);
8612 text = tplProcess(tpl[0], {
8613 CLASS_TOOLTIP: config_classes.tooltip,
8614 TITLE: isValue(title) ? tplStr ? title : "<tr><th colspan=\"2\">" + title + "</th></tr>" : ""
8615 });
8616 }
8617
8618 if (!row.ratio && $$.$el.arcs) {
8619 row.ratio = $$.getRatio("arc", $$.$el.arcs.select("path." + config_classes.arc + "-" + row.id).data()[0]);
8620 }
8621
8622 param = [row.ratio, row.id, row.index, d];
8623 value = sanitise(valueFormat.apply(void 0, [getRowValue(row)].concat(param)));
8624
8625 if ($$.isAreaRangeType(row)) {
8626 var _map2 = ["high", "low"].map(function (v) {
8627 return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v)].concat(param)));
8628 }),
8629 high = _map2[0],
8630 low = _map2[1];
8631
8632 value = "<b>Mid:</b> " + value + " <b>High:</b> " + high + " <b>Low:</b> " + low;
8633 } else if ($$.isCandlestickType(row)) {
8634 var _map3 = ["open", "high", "low", "close", "volume"].map(function (v) {
8635 return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v, "candlestick")].concat(param)));
8636 }),
8637 open = _map3[0],
8638 _high = _map3[1],
8639 _low = _map3[2],
8640 close = _map3[3],
8641 volume = _map3[4];
8642
8643 value = "<b>Open:</b> " + open + " <b>High:</b> " + _high + " <b>Low:</b> " + _low + " <b>Close:</b> " + close + (volume ? " <b>Volume:</b> " + volume : "");
8644 }
8645
8646 if (value !== undefined) {
8647 var _ret = function () {
8648 // Skip elements when their name is set to null
8649 if (row.name === null) {
8650 return "continue";
8651 }
8652
8653 var name = sanitise(nameFormat.apply(void 0, [row.name].concat(param))),
8654 color = getBgColor(row),
8655 contentValue = {
8656 CLASS_TOOLTIP_NAME: config_classes.tooltipName + $$.getTargetSelectorSuffix(row.id),
8657 COLOR: tplStr || !$$.patterns ? color : "<svg><rect style=\"fill:" + color + "\" width=\"10\" height=\"10\"></rect></svg>",
8658 NAME: name,
8659 VALUE: value
8660 };
8661
8662 if (tplStr && isObject(contents.text)) {
8663 var index = targetIds.indexOf(row.id);
8664 Object.keys(contents.text).forEach(function (key) {
8665 contentValue[key] = contents.text[key][index];
8666 });
8667 }
8668
8669 text += tplProcess(tpl[1], contentValue);
8670 }();
8671
8672 if (_ret === "continue") continue;
8673 }
8674 }
8675
8676 return text + "</table>";
8677 },
8678
8679 /**
8680 * Get the content template string
8681 * @param {string} tplStr Tempalte string
8682 * @returns {Array} Template string
8683 * @private
8684 */
8685 getTooltipContentTemplate: function getTooltipContentTemplate(tplStr) {
8686 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(/{{(.*)}}/);
8687 },
8688
8689 /**
8690 * Returns the position of the tooltip
8691 * @param {object} dataToShow data
8692 * @param {string} tWidth Width value of tooltip element
8693 * @param {string} tHeight Height value of tooltip element
8694 * @param {HTMLElement} element Tooltip element
8695 * @returns {object} top, left value
8696 * @private
8697 */
8698 tooltipPosition: function tooltipPosition(dataToShow, tWidth, tHeight, element) {
8699 var $$ = this,
8700 config = $$.config,
8701 scale = $$.scale,
8702 state = $$.state,
8703 _state = state,
8704 width = _state.width,
8705 height = _state.height,
8706 current = _state.current,
8707 isLegendRight = _state.isLegendRight,
8708 inputType = _state.inputType,
8709 event = _state.event,
8710 hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle,
8711 svgLeft = $$.getSvgLeft(!0),
8712 chartRight = svgLeft + current.width - $$.getCurrentPaddingRight(),
8713 chartLeft = $$.getCurrentPaddingLeft(!0),
8714 size = 20,
8715 _getPointer = getPointer(event, element),
8716 x = _getPointer[0],
8717 y = _getPointer[1];
8718
8719 // Determine tooltip position
8720 if ($$.hasArcType()) {
8721 var raw = inputType === "touch" || $$.hasType("radar");
8722
8723 if (!raw) {
8724 y += hasGauge ? height : height / 2;
8725 x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
8726 }
8727 } else {
8728 var dataScale = scale.x(dataToShow[0].x);
8729
8730 if (config.axis_rotated) {
8731 y = dataScale + size;
8732 x += svgLeft + 100;
8733 chartRight -= svgLeft;
8734 } else {
8735 y -= 5;
8736 x = svgLeft + chartLeft + size + ($$.scale.zoom ? x : dataScale);
8737 }
8738 } // when tooltip left + tWidth > chart's width
8739
8740
8741 if (x + tWidth + 15 > chartRight) {
8742 x -= tWidth + chartLeft;
8743 }
8744
8745 if (y + tHeight > current.height) {
8746 y -= hasGauge ? tHeight * 3 : tHeight + 30;
8747 }
8748
8749 var pos = {
8750 top: y,
8751 left: x
8752 }; // make sure to not be positioned out of viewport
8753
8754 Object.keys(pos).forEach(function (v) {
8755 if (pos[v] < 0) {
8756 pos[v] = 0;
8757 }
8758 });
8759 return pos;
8760 },
8761
8762 /**
8763 * Show the tooltip
8764 * @param {object} selectedData Data object
8765 * @param {SVGElement} eventRect Event <rect> element
8766 * @private
8767 */
8768 showTooltip: function showTooltip(selectedData, eventRect) {
8769 var $$ = this,
8770 config = $$.config,
8771 scale = $$.scale,
8772 state = $$.state,
8773 tooltip = $$.$el.tooltip,
8774 bindto = config.tooltip_contents.bindto,
8775 dataToShow = selectedData.filter(function (d) {
8776 return d && isValue($$.getBaseValue(d));
8777 });
8778
8779 if (!tooltip || dataToShow.length === 0 || !config.tooltip_show) {
8780 return;
8781 }
8782
8783 var datum = tooltip.datum(),
8784 _ref = datum || {},
8785 _ref$width = _ref.width,
8786 width = _ref$width === void 0 ? 0 : _ref$width,
8787 _ref$height = _ref.height,
8788 height = _ref$height === void 0 ? 0 : _ref$height,
8789 dataStr = JSON.stringify(selectedData);
8790
8791 if (!datum || datum.current !== dataStr) {
8792 var index = selectedData.concat().sort()[0].index;
8793 callFn(config.tooltip_onshow, $$.api, selectedData); // set tooltip content
8794
8795 tooltip.html($$.getTooltipHTML(selectedData, // data
8796 $$.axis ? $$.axis.getXAxisTickFormat() : $$.categoryName.bind($$), // defaultTitleFormat
8797 $$.getDefaultValueFormat(), // defaultValueFormat
8798 $$.color // color
8799 )).style("display", null).style("visibility", null) // for IE9
8800 .datum(datum = {
8801 index: index,
8802 current: dataStr,
8803 width: width = tooltip.property("offsetWidth"),
8804 height: height = tooltip.property("offsetHeight")
8805 });
8806 callFn(config.tooltip_onshown, $$.api, selectedData);
8807
8808 $$._handleLinkedCharts(!0, index);
8809 }
8810
8811 if (!bindto) {
8812 var _config$tooltip_posit,
8813 _selectedData$filter,
8814 fnPos = ((_config$tooltip_posit = config.tooltip_position) == null ? void 0 : _config$tooltip_posit.bind($$.api)) || $$.tooltipPosition.bind($$),
8815 _getPointer2 = getPointer(state.event, eventRect),
8816 x = _getPointer2[0],
8817 y = _getPointer2[1],
8818 currPos = {
8819 x: x,
8820 y: y
8821 },
8822 data = (_selectedData$filter = selectedData.filter(Boolean)) == null ? void 0 : _selectedData$filter.shift();
8823
8824 if (scale.x && data && "x" in data) {
8825 currPos.xAxis = scale.x(data.x);
8826 } // Get tooltip dimensions
8827
8828
8829 var pos = fnPos(dataToShow, width, height, eventRect, currPos);
8830 ["top", "left"].forEach(function (v) {
8831 var value = pos[v];
8832 tooltip.style(v, value + "px"); // Remember left pos in percentage to be used on resize call
8833
8834 if (v === "left" && !datum.xPosInPercent) {
8835 datum.xPosInPercent = value / state.current.width * 100;
8836 }
8837 });
8838 }
8839 },
8840
8841 /**
8842 * Adjust tooltip position on resize event
8843 * @private
8844 */
8845 bindTooltipResizePos: function bindTooltipResizePos() {
8846 var $$ = this,
8847 resizeFunction = $$.resizeFunction,
8848 state = $$.state,
8849 tooltip = $$.$el.tooltip;
8850 resizeFunction.add(function () {
8851 if (tooltip.style("display") === "block") {
8852 var current = state.current,
8853 _tooltip$datum = tooltip.datum(),
8854 width = _tooltip$datum.width,
8855 xPosInPercent = _tooltip$datum.xPosInPercent,
8856 _value = current.width / 100 * xPosInPercent,
8857 diff = current.width - (_value + width);
8858
8859 // if tooltip size overs current viewport size
8860 if (diff < 0) {
8861 _value += diff;
8862 }
8863
8864 tooltip.style("left", _value + "px");
8865 }
8866 });
8867 },
8868
8869 /**
8870 * Hide the tooltip
8871 * @param {boolean} force Force to hide
8872 * @private
8873 */
8874 hideTooltip: function hideTooltip(force) {
8875 var $$ = this,
8876 api = $$.api,
8877 config = $$.config,
8878 tooltip = $$.$el.tooltip;
8879
8880 if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
8881 var selectedData = JSON.parse(tooltip.datum().current);
8882 callFn(config.tooltip_onhide, api, selectedData); // hide tooltip
8883
8884 tooltip.style("display", "none").style("visibility", "hidden") // for IE9
8885 .datum(null);
8886 callFn(config.tooltip_onhidden, api, selectedData);
8887 }
8888 },
8889
8890 /**
8891 * Toggle display for linked chart instances
8892 * @param {boolean} show true: show, false: hide
8893 * @param {number} index x Axis index
8894 * @private
8895 */
8896 _handleLinkedCharts: function _handleLinkedCharts(show, index) {
8897 var _event,
8898 $$ = this,
8899 charts = $$.charts,
8900 config = $$.config,
8901 event = $$.state.event;
8902
8903 // Prevent propagation among instances if isn't instantiated from the user's event
8904 // https://github.com/naver/billboard.js/issues/1979
8905 if ((_event = event) != null && _event.isTrusted && config.tooltip_linked && charts.length > 1) {
8906 var linkedName = config.tooltip_linked_name;
8907 charts.filter(function (c) {
8908 return c !== $$.api;
8909 }).forEach(function (c) {
8910 var _c$internal = c.internal,
8911 config = _c$internal.config,
8912 $el = _c$internal.$el,
8913 isLinked = config.tooltip_linked,
8914 name = config.tooltip_linked_name,
8915 isInDom = browser_doc.body.contains($el.chart.node());
8916
8917 if (isLinked && linkedName === name && isInDom) {
8918 var data = $el.tooltip.data()[0],
8919 isNotSameIndex = index !== (data == null ? void 0 : data.index);
8920
8921 try {
8922 c.tooltip[show && isNotSameIndex ? "show" : "hide"]({
8923 index: index
8924 });
8925 } catch (e) {}
8926 }
8927 });
8928 }
8929 }
8930});
8931;// CONCATENATED MODULE: ./src/ChartInternal/internals/transform.ts
8932/**
8933 * Copyright (c) 2017 ~ present NAVER Corp.
8934 * billboard.js project is licensed under the MIT license
8935 */
8936
8937
8938/* harmony default export */ var transform = ({
8939 getTranslate: function getTranslate(target, index) {
8940 if (index === void 0) {
8941 index = 0;
8942 }
8943
8944 var $$ = this,
8945 config = $$.config,
8946 state = $$.state,
8947 isRotated = config.axis_rotated,
8948 padding = 0,
8949 x,
8950 y;
8951
8952 if (index && /^(x|y2?)$/.test(target)) {
8953 padding = $$.getAxisSize(target) * index;
8954 }
8955
8956 if (target === "main") {
8957 x = asHalfPixel(state.margin.left);
8958 y = asHalfPixel(state.margin.top);
8959 } else if (target === "context") {
8960 x = asHalfPixel(state.margin2.left);
8961 y = asHalfPixel(state.margin2.top);
8962 } else if (target === "legend") {
8963 x = state.margin3.left;
8964 y = state.margin3.top;
8965 } else if (target === "x") {
8966 x = isRotated ? -padding : 0;
8967 y = isRotated ? 0 : state.height + padding;
8968 } else if (target === "y") {
8969 x = isRotated ? 0 : -padding;
8970 y = isRotated ? state.height + padding : 0;
8971 } else if (target === "y2") {
8972 x = isRotated ? 0 : state.width + padding;
8973 y = isRotated ? 1 - padding : 0;
8974 } else if (target === "subX") {
8975 x = 0;
8976 y = isRotated ? 0 : state.height2;
8977 } else if (target === "arc") {
8978 x = state.arcWidth / 2;
8979 y = state.arcHeight / 2;
8980 } else if (target === "radar") {
8981 var _$$$getRadarSize = $$.getRadarSize(),
8982 width = _$$$getRadarSize[0];
8983
8984 x = state.width / 2 - width;
8985 y = asHalfPixel(state.margin.top);
8986 }
8987
8988 return "translate(" + x + ", " + y + ")";
8989 },
8990 transformMain: function transformMain(withTransition, transitions) {
8991 var $$ = this,
8992 main = $$.$el.main,
8993 $T = $$.$T,
8994 xAxis = transitions != null && transitions.axisX ? transitions.axisX : $T(main.select("." + config_classes.axisX), withTransition),
8995 yAxis = transitions != null && transitions.axisY ? transitions.axisY : $T(main.select("." + config_classes.axisY), withTransition),
8996 y2Axis = transitions != null && transitions.axisY2 ? transitions.axisY2 : $T(main.select("." + config_classes.axisY2), withTransition);
8997 $T(main, withTransition).attr("transform", $$.getTranslate("main"));
8998 xAxis.attr("transform", $$.getTranslate("x"));
8999 yAxis.attr("transform", $$.getTranslate("y"));
9000 y2Axis.attr("transform", $$.getTranslate("y2"));
9001 main.select("." + config_classes.chartArcs).attr("transform", $$.getTranslate("arc"));
9002 },
9003 transformAll: function transformAll(withTransition, transitions) {
9004 var $$ = this,
9005 config = $$.config,
9006 hasAxis = $$.state.hasAxis,
9007 $el = $$.$el;
9008 $$.transformMain(withTransition, transitions);
9009 hasAxis && config.subchart_show && $$.transformContext(withTransition, transitions);
9010 $el.legend && $$.transformLegend(withTransition);
9011 }
9012});
9013;// CONCATENATED MODULE: ./src/ChartInternal/internals/type.ts
9014/**
9015 * Copyright (c) 2017 ~ present NAVER Corp.
9016 * billboard.js project is licensed under the MIT license
9017 */
9018
9019
9020/* harmony default export */ var type = ({
9021 setTargetType: function setTargetType(targetIds, type) {
9022 var $$ = this,
9023 config = $$.config,
9024 withoutFadeIn = $$.state.withoutFadeIn;
9025 $$.mapToTargetIds(targetIds).forEach(function (id) {
9026 withoutFadeIn[id] = type === config.data_types[id];
9027 config.data_types[id] = type;
9028 });
9029
9030 if (!targetIds) {
9031 config.data_type = type;
9032 }
9033 },
9034
9035 /**
9036 * Updte current used chart types
9037 * @private
9038 */
9039 updateTypesElements: function updateTypesElements() {
9040 var $$ = this,
9041 current = $$.state.current;
9042 Object.keys(TYPE).forEach(function (v) {
9043 var t = TYPE[v],
9044 has = $$.hasType(t, null, !0),
9045 idx = current.types.indexOf(t);
9046
9047 if (idx === -1 && has) {
9048 current.types.push(t);
9049 } else if (idx > -1 && !has) {
9050 current.types.splice(idx, 1);
9051 }
9052 }); // Update current chart elements reference
9053
9054 $$.setChartElements();
9055 },
9056
9057 /**
9058 * Check if given chart types exists
9059 * @param {string} type Chart type
9060 * @param {Array} targetsValue Data array
9061 * @param {boolean} checkFromData Force to check type cotains from data targets
9062 * @returns {boolean}
9063 * @private
9064 */
9065 hasType: function hasType(type, targetsValue, checkFromData) {
9066 var _current$types, _targets;
9067
9068 if (checkFromData === void 0) {
9069 checkFromData = !1;
9070 }
9071
9072 var $$ = this,
9073 config = $$.config,
9074 current = $$.state.current,
9075 types = config.data_types,
9076 targets = targetsValue || $$.data.targets,
9077 has = !1;
9078
9079 if (!checkFromData && ((_current$types = current.types) == null ? void 0 : _current$types.indexOf(type)) > -1) {
9080 has = !0;
9081 } else if ((_targets = targets) != null && _targets.length) {
9082 targets.forEach(function (target) {
9083 var t = types[target.id];
9084
9085 if (t === type || !t && type === "line") {
9086 has = !0;
9087 }
9088 });
9089 } else if (Object.keys(types).length) {
9090 Object.keys(types).forEach(function (id) {
9091 if (types[id] === type) {
9092 has = !0;
9093 }
9094 });
9095 } else {
9096 has = config.data_type === type;
9097 }
9098
9099 return has;
9100 },
9101
9102 /**
9103 * Check if contains given chart types
9104 * @param {string} type Type key
9105 * @param {object} targets Target data
9106 * @param {Array} exclude Excluded types
9107 * @returns {boolean}
9108 * @private
9109 */
9110 hasTypeOf: function hasTypeOf(type, targets, exclude) {
9111 var _this = this;
9112
9113 if (exclude === void 0) {
9114 exclude = [];
9115 }
9116
9117 if (type in TYPE_BY_CATEGORY) {
9118 return !TYPE_BY_CATEGORY[type].filter(function (v) {
9119 return exclude.indexOf(v) === -1;
9120 }).every(function (v) {
9121 return !_this.hasType(v, targets);
9122 });
9123 }
9124
9125 return !1;
9126 },
9127
9128 /**
9129 * Check if given data is certain chart type
9130 * @param {object} d Data object
9131 * @param {string|Array} type chart type
9132 * @returns {boolean}
9133 * @private
9134 */
9135 isTypeOf: function isTypeOf(d, type) {
9136 var id = isString(d) ? d : d.id,
9137 dataType = this.config.data_types[id] || this.config.data_type;
9138 return isArray(type) ? type.indexOf(dataType) >= 0 : dataType === type;
9139 },
9140 hasPointType: function hasPointType() {
9141 var $$ = this;
9142 return $$.hasTypeOf("Line") || $$.hasType("bubble") || $$.hasType("scatter");
9143 },
9144
9145 /**
9146 * Check if contains arc types chart
9147 * @param {object} targets Target data
9148 * @param {Array} exclude Excluded types
9149 * @returns {boolean}
9150 * @private
9151 */
9152 hasArcType: function hasArcType(targets, exclude) {
9153 return this.hasTypeOf("Arc", targets, exclude);
9154 },
9155 hasMultiArcGauge: function hasMultiArcGauge() {
9156 return this.hasType("gauge") && this.config.gauge_type === "multi";
9157 },
9158 isLineType: function isLineType(d) {
9159 var id = isString(d) ? d : d.id;
9160 return !this.config.data_types[id] || this.isTypeOf(id, TYPE_BY_CATEGORY.Line);
9161 },
9162 isStepType: function isStepType(d) {
9163 return this.isTypeOf(d, TYPE_BY_CATEGORY.Step);
9164 },
9165 isSplineType: function isSplineType(d) {
9166 return this.isTypeOf(d, TYPE_BY_CATEGORY.Spline);
9167 },
9168 isAreaType: function isAreaType(d) {
9169 return this.isTypeOf(d, TYPE_BY_CATEGORY.Area);
9170 },
9171 isAreaRangeType: function isAreaRangeType(d) {
9172 return this.isTypeOf(d, TYPE_BY_CATEGORY.AreaRange);
9173 },
9174 isBarType: function isBarType(d) {
9175 return this.isTypeOf(d, "bar");
9176 },
9177 isBubbleType: function isBubbleType(d) {
9178 return this.isTypeOf(d, "bubble");
9179 },
9180 isCandlestickType: function isCandlestickType(d) {
9181 return this.isTypeOf(d, "candlestick");
9182 },
9183 isScatterType: function isScatterType(d) {
9184 return this.isTypeOf(d, "scatter");
9185 },
9186 isPieType: function isPieType(d) {
9187 return this.isTypeOf(d, "pie");
9188 },
9189 isGaugeType: function isGaugeType(d) {
9190 return this.isTypeOf(d, "gauge");
9191 },
9192 isDonutType: function isDonutType(d) {
9193 return this.isTypeOf(d, "donut");
9194 },
9195 isRadarType: function isRadarType(d) {
9196 return this.isTypeOf(d, "radar");
9197 },
9198 isArcType: function isArcType(d) {
9199 return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d) || this.isRadarType(d);
9200 },
9201 // determine if is 'circle' data point
9202 isCirclePoint: function isCirclePoint(node) {
9203 var config = this.config,
9204 pattern = config.point_pattern,
9205 isCircle = !1;
9206
9207 if ((node == null ? void 0 : node.tagName) === "circle") {
9208 isCircle = !0;
9209 } else {
9210 isCircle = config.point_type === "circle" && (!pattern || isArray(pattern) && pattern.length === 0);
9211 }
9212
9213 return isCircle;
9214 },
9215 lineData: function lineData(d) {
9216 return this.isLineType(d) ? [d] : [];
9217 },
9218 arcData: function arcData(d) {
9219 return this.isArcType(d.data) ? [d] : [];
9220 },
9221
9222 /**
9223 * Get data adapt for data label showing
9224 * @param {object} d Data object
9225 * @returns {Array}
9226 * @private
9227 */
9228 labelishData: function labelishData(d) {
9229 return this.isBarType(d) || this.isLineType(d) || this.isScatterType(d) || this.isBubbleType(d) || this.isCandlestickType(d) || this.isRadarType(d) ? d.values.filter(function (v) {
9230 return isNumber(v.value) || !!v.value;
9231 }) : [];
9232 },
9233 barLineBubbleData: function barLineBubbleData(d) {
9234 return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ? d.values : [];
9235 },
9236 // https://github.com/d3/d3-shape#curves
9237 isInterpolationType: function isInterpolationType(type) {
9238 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;
9239 }
9240});
9241;// CONCATENATED MODULE: ./src/ChartInternal/ChartInternal.ts
9242/**
9243 * Copyright (c) 2017 ~ present NAVER Corp.
9244 * billboard.js project is licensed under the MIT license
9245 * @ignore
9246 */
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256 // data
9257
9258
9259
9260 // interactions
9261
9262 // internals
9263
9264
9265 // used to retrieve radar Axis name
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280/**
9281 * Internal chart class.
9282 * - Note: Instantiated internally, not exposed for public.
9283 * @class ChartInternal
9284 * @ignore
9285 * @private
9286 */
9287
9288var ChartInternal = /*#__PURE__*/function () {
9289 // API interface
9290 // config object
9291 // cache instance
9292 // elements
9293 // state variables
9294 // all Chart instances array within page (equivalent of 'bb.instances')
9295 // data object
9296 // Axis
9297 // Axis
9298 // scales
9299 // original values
9300 // formatter function
9301 // format function
9302 function ChartInternal(api) {
9303 this.api = void 0;
9304 this.config = void 0;
9305 this.cache = void 0;
9306 this.$el = void 0;
9307 this.state = void 0;
9308 this.charts = void 0;
9309 this.data = {
9310 xs: {},
9311 targets: []
9312 };
9313 this.axis = void 0;
9314 this.scale = {
9315 x: null,
9316 y: null,
9317 y2: null,
9318 subX: null,
9319 subY: null,
9320 subY2: null,
9321 zoom: null
9322 };
9323 this.org = {
9324 xScale: null,
9325 xDomain: null
9326 };
9327 this.color = void 0;
9328 this.patterns = void 0;
9329 this.levelColor = void 0;
9330 this.point = void 0;
9331 this.brush = void 0;
9332 this.format = {
9333 extraLineClasses: null,
9334 xAxisTick: null,
9335 dataTime: null,
9336 // dataTimeFormat
9337 defaultAxisTime: null,
9338 // defaultAxisTimeFormat
9339 axisTime: null // axisTimeFormat
9340
9341 };
9342 var $$ = this;
9343 $$.api = api; // Chart class instance alias
9344
9345 $$.config = new Options();
9346 $$.cache = new Cache();
9347 var store = new Store();
9348 $$.$el = store.getStore("element");
9349 $$.state = store.getStore("state");
9350 $$.$T = $$.$T.bind($$);
9351 }
9352 /**
9353 * Get the selection based on transition config
9354 * @param {SVGElement|d3Selection} selection Target selection
9355 * @param {boolean} force Force transition
9356 * @param {string} name Transition name
9357 * @returns {d3Selection}
9358 * @private
9359 */
9360
9361
9362 var _proto = ChartInternal.prototype;
9363
9364 _proto.$T = function $T(selection, force, name) {
9365 var config = this.config,
9366 state = this.state,
9367 duration = config.transition_duration,
9368 subchart = config.subchart_show,
9369 t = selection;
9370
9371 if (t) {
9372 // in case of non d3 selection, wrap with d3 selection
9373 if ("tagName" in t) {
9374 t = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(t);
9375 } // do not transit on:
9376 // - wheel zoom (state.zooming = true)
9377 // - when has no subchart
9378 // - initialization
9379 // - resizing
9380
9381
9382 var transit = (force !== !1 && duration || force) && (!state.zooming || state.dragging) && !state.resizing && state.rendered && !subchart;
9383 t = transit ? t.transition(name).duration(duration) : t;
9384 }
9385
9386 return t;
9387 };
9388
9389 _proto.beforeInit = function beforeInit() {
9390 var $$ = this;
9391 $$.callPluginHook("$beforeInit"); // can do something
9392
9393 callFn($$.config.onbeforeinit, $$.api);
9394 };
9395
9396 _proto.afterInit = function afterInit() {
9397 var $$ = this;
9398 $$.callPluginHook("$afterInit"); // can do something
9399
9400 callFn($$.config.onafterinit, $$.api);
9401 };
9402
9403 _proto.init = function init() {
9404 var $$ = this,
9405 config = $$.config,
9406 state = $$.state,
9407 $el = $$.$el;
9408 checkModuleImport($$);
9409 state.hasAxis = !$$.hasArcType();
9410 state.hasRadar = !state.hasAxis && $$.hasType("radar");
9411 $$.initParams();
9412 var bindto = {
9413 element: config.bindto,
9414 classname: "bb"
9415 };
9416
9417 if (isObject(config.bindto)) {
9418 bindto.element = config.bindto.element || "#chart";
9419 bindto.classname = config.bindto.classname || bindto.classname;
9420 } // select bind element
9421
9422
9423 $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 || []);
9424
9425 if ($el.chart.empty()) {
9426 $el.chart = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.body.appendChild(browser_doc.createElement("div")));
9427 }
9428
9429 $el.chart.html("").classed(bindto.classname, !0);
9430 $$.initToRender();
9431 }
9432 /**
9433 * Initialize the rendering process
9434 * @param {boolean} forced Force to render process
9435 * @private
9436 */
9437 ;
9438
9439 _proto.initToRender = function initToRender(forced) {
9440 var $$ = this,
9441 config = $$.config,
9442 state = $$.state,
9443 chart = $$.$el.chart,
9444 isHidden = function () {
9445 return chart.style("display") === "none" || chart.style("visibility") === "hidden";
9446 },
9447 isLazy = config.render.lazy || isHidden(),
9448 MutationObserver = win.MutationObserver;
9449
9450 if (isLazy && MutationObserver && config.render.observe !== !1 && !forced) {
9451 new MutationObserver(function (mutation, observer) {
9452 if (!isHidden()) {
9453 observer.disconnect();
9454 state.rendered || $$.initToRender(!0);
9455 }
9456 }).observe(chart.node(), {
9457 attributes: !0,
9458 attributeFilter: ["class", "style"]
9459 });
9460 }
9461
9462 if (!isLazy || forced) {
9463 var convertedData = $$.convertData(config, $$.initWithData);
9464 convertedData && $$.initWithData(convertedData);
9465 $$.afterInit();
9466 }
9467 };
9468
9469 _proto.initParams = function initParams() {
9470 var $$ = this,
9471 _ref = $$,
9472 config = _ref.config,
9473 format = _ref.format,
9474 state = _ref.state,
9475 isRotated = config.axis_rotated;
9476 // datetime to be used for uniqueness
9477 state.datetimeId = "bb-" + +new Date();
9478 $$.color = $$.generateColor();
9479 $$.levelColor = $$.generateLevelColor();
9480
9481 if ($$.hasPointType()) {
9482 $$.point = $$.generatePoint();
9483 }
9484
9485 if (state.hasAxis) {
9486 $$.initClip();
9487 format.extraLineClasses = $$.generateExtraLineClass();
9488 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;
9489 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;
9490 var isDragZoom = $$.config.zoom_enabled && $$.config.zoom_type === "drag";
9491
9492 format.defaultAxisTime = function (d) {
9493 var _$$$scale = $$.scale,
9494 x = _$$$scale.x,
9495 zoom = _$$$scale.zoom,
9496 isZoomed = isDragZoom ? zoom : zoom && x.orgDomain().toString() !== zoom.domain().toString(),
9497 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";
9498 return format.axisTime(specifier)(d);
9499 };
9500 }
9501
9502 state.isLegendRight = config.legend_position === "right";
9503 state.isLegendInset = config.legend_position === "inset";
9504 state.isLegendTop = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "top-right";
9505 state.isLegendLeft = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "bottom-left";
9506 state.rotatedPaddingRight = isRotated && !config.axis_x_show ? 0 : 30;
9507 state.inputType = convertInputType(config.interaction_inputType_mouse, config.interaction_inputType_touch);
9508 };
9509
9510 _proto.initWithData = function initWithData(data) {
9511 var $$ = this,
9512 config = $$.config,
9513 scale = $$.scale,
9514 state = $$.state,
9515 $el = $$.$el,
9516 org = $$.org,
9517 hasAxis = state.hasAxis,
9518 hasInteraction = config.interaction_enabled;
9519
9520 // for arc type, set axes to not be shown
9521 // $$.hasArcType() && ["x", "y", "y2"].forEach(id => (config[`axis_${id}_show`] = false));
9522 if (hasAxis) {
9523 $$.axis = $$.getAxisInstance();
9524 config.zoom_enabled && $$.initZoom();
9525 } // Init data as targets
9526
9527
9528 $$.data.xs = {};
9529 $$.data.targets = $$.convertDataToTargets(data);
9530
9531 if (config.data_filter) {
9532 $$.data.targets = $$.data.targets.filter(config.data_filter.bind($$.api));
9533 } // Set targets to hide if needed
9534
9535
9536 if (config.data_hide) {
9537 $$.addHiddenTargetIds(config.data_hide === !0 ? $$.mapToIds($$.data.targets) : config.data_hide);
9538 }
9539
9540 if (config.legend_hide) {
9541 $$.addHiddenLegendIds(config.legend_hide === !0 ? $$.mapToIds($$.data.targets) : config.legend_hide);
9542 } // Init sizes and scales
9543
9544
9545 $$.updateSizes();
9546 $$.updateScales(!0); // retrieve scale after the 'updateScales()' is called
9547
9548 var x = scale.x,
9549 y = scale.y,
9550 y2 = scale.y2,
9551 subX = scale.subX,
9552 subY = scale.subY,
9553 subY2 = scale.subY2; // Set domains for each scale
9554
9555 if (x) {
9556 x.domain(sortValue($$.getXDomain($$.data.targets)));
9557 subX.domain(x.domain()); // Save original x domain for zoom update
9558
9559 org.xDomain = x.domain();
9560 }
9561
9562 if (y) {
9563 y.domain($$.getYDomain($$.data.targets, "y"));
9564 subY.domain(y.domain());
9565 }
9566
9567 if (y2) {
9568 y2.domain($$.getYDomain($$.data.targets, "y2"));
9569 subY2 && subY2.domain(y2.domain());
9570 } // -- Basic Elements --
9571
9572
9573 $el.svg = $el.chart.append("svg").style("overflow", "hidden").style("display", "block");
9574
9575 if (hasInteraction && state.inputType) {
9576 var isTouch = state.inputType === "touch";
9577 $el.svg.on(isTouch ? "touchstart" : "mouseenter", function () {
9578 return callFn(config.onover, $$.api);
9579 }).on(isTouch ? "touchend" : "mouseleave", function () {
9580 return callFn(config.onout, $$.api);
9581 });
9582 }
9583
9584 config.svg_classname && $el.svg.attr("class", config.svg_classname); // Define defs
9585
9586 var hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
9587
9588 if (hasAxis || hasColorPatterns || config.data_labels_backgroundColors) {
9589 $el.defs = $el.svg.append("defs");
9590
9591 if (hasAxis) {
9592 ["id", "idXAxis", "idYAxis", "idGrid"].forEach(function (v) {
9593 $$.appendClip($el.defs, state.clip[v]);
9594 });
9595 } // Append data backgound color filter definition
9596
9597
9598 $$.generateDataLabelBackgroundColorFilter(); // set color patterns
9599
9600 if (hasColorPatterns) {
9601 $$.patterns.forEach(function (p) {
9602 return $el.defs.append(function () {
9603 return p.node;
9604 });
9605 });
9606 }
9607 }
9608
9609 $$.updateSvgSize(); // Bind resize event
9610
9611 $$.bindResize(); // Define regions
9612
9613 var main = $el.svg.append("g").classed(config_classes.main, !0).attr("transform", $$.getTranslate("main"));
9614 $el.main = main; // initialize subchart when subchart show option is set
9615
9616 config.subchart_show && $$.initSubchart();
9617 config.tooltip_show && $$.initTooltip();
9618 config.title_text && $$.initTitle();
9619 config.legend_show && $$.initLegend(); // -- Main Region --
9620 // text when empty
9621
9622 if (config.data_empty_label_text) {
9623 main.append("text").attr("class", config_classes.text + " " + config_classes.empty).attr("text-anchor", "middle") // horizontal centering of text at x position in all browsers.
9624 .attr("dominant-baseline", "middle"); // vertical centering of text at y position in all browsers, except IE.
9625 }
9626
9627 if (hasAxis) {
9628 // Regions
9629 config.regions.length && $$.initRegion(); // Add Axis here, when clipPath is 'false'
9630
9631 config.clipPath || $$.axis.init();
9632 } // Define g for chart area
9633
9634
9635 main.append("g").attr("class", config_classes.chart).attr("clip-path", state.clip.path);
9636 $$.callPluginHook("$init");
9637
9638 if (hasAxis) {
9639 var _$$$axis;
9640
9641 // Cover whole with rects for events
9642 hasInteraction && ($$.initEventRect == null ? void 0 : $$.initEventRect()); // Grids
9643
9644 $$.initGrid(); // Add Axis here, when clipPath is 'true'
9645
9646 config.clipPath && ((_$$$axis = $$.axis) == null ? void 0 : _$$$axis.init());
9647 }
9648
9649 $$.initChartElements(); // Set targets
9650
9651 $$.updateTargets($$.data.targets); // Draw with targets
9652
9653 $$.updateDimension(); // oninit callback
9654
9655 callFn(config.oninit, $$.api); // Set background
9656
9657 $$.setBackground();
9658 $$.redraw({
9659 withTransition: !1,
9660 withTransform: !0,
9661 withUpdateXDomain: !0,
9662 withUpdateOrgXDomain: !0,
9663 withTransitionForAxis: !1,
9664 initializing: !0
9665 }); // data.onmin/max callback
9666
9667 if (config.data_onmin || config.data_onmax) {
9668 var minMax = $$.getMinMaxData();
9669 callFn(config.data_onmin, $$.api, minMax.min);
9670 callFn(config.data_onmax, $$.api, minMax.max);
9671 }
9672
9673 config.tooltip_show && $$.initShowTooltip();
9674 state.rendered = !0;
9675 }
9676 /**
9677 * Initialize chart elements
9678 * @private
9679 */
9680 ;
9681
9682 _proto.initChartElements = function initChartElements() {
9683 var $$ = this,
9684 _$$$state = $$.state,
9685 hasAxis = _$$$state.hasAxis,
9686 hasRadar = _$$$state.hasRadar,
9687 types = [];
9688
9689 if (hasAxis) {
9690 ["bar", "bubble", "candlestick", "line"].forEach(function (v) {
9691 var name = capitalize(v);
9692
9693 if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
9694 types.push(name);
9695 }
9696 });
9697 } else {
9698 if (!hasRadar) {
9699 types.push("Arc", "Pie");
9700 }
9701
9702 if ($$.hasType("gauge")) {
9703 types.push("Gauge");
9704 } else if (hasRadar) {
9705 types.push("Radar");
9706 }
9707 }
9708
9709 types.forEach(function (v) {
9710 $$["init" + v]();
9711 });
9712 notEmpty($$.config.data_labels) && !$$.hasArcType(null, ["radar"]) && $$.initText();
9713 }
9714 /**
9715 * Set chart elements
9716 * @private
9717 */
9718 ;
9719
9720 _proto.setChartElements = function setChartElements() {
9721 var $$ = this,
9722 _$$$$el = $$.$el,
9723 chart = _$$$$el.chart,
9724 svg = _$$$$el.svg,
9725 defs = _$$$$el.defs,
9726 main = _$$$$el.main,
9727 tooltip = _$$$$el.tooltip,
9728 legend = _$$$$el.legend,
9729 title = _$$$$el.title,
9730 grid = _$$$$el.grid,
9731 arc = _$$$$el.arcs,
9732 circles = _$$$$el.circle,
9733 bars = _$$$$el.bar,
9734 candlestick = _$$$$el.candlestick,
9735 lines = _$$$$el.line,
9736 areas = _$$$$el.area,
9737 texts = _$$$$el.text;
9738 $$.api.$ = {
9739 chart: chart,
9740 svg: svg,
9741 defs: defs,
9742 main: main,
9743 tooltip: tooltip,
9744 legend: legend,
9745 title: title,
9746 grid: grid,
9747 arc: arc,
9748 circles: circles,
9749 bar: {
9750 bars: bars
9751 },
9752 candlestick: candlestick,
9753 line: {
9754 lines: lines,
9755 areas: areas
9756 },
9757 text: {
9758 texts: texts
9759 }
9760 };
9761 }
9762 /**
9763 * Set background element/image
9764 * @private
9765 */
9766 ;
9767
9768 _proto.setBackground = function setBackground() {
9769 var $$ = this,
9770 bg = $$.config.background,
9771 state = $$.state,
9772 svg = $$.$el.svg;
9773
9774 if (notEmpty(bg)) {
9775 var element = svg.select("g").insert(bg.imgUrl ? "image" : "rect", ":first-child");
9776
9777 if (bg.imgUrl) {
9778 element.attr("href", bg.imgUrl);
9779 } else if (bg.color) {
9780 element.style("fill", bg.color).attr("clip-path", state.clip.path);
9781 }
9782
9783 element.attr("class", bg.class || null).attr("width", "100%").attr("height", "100%");
9784 }
9785 }
9786 /**
9787 * Update targeted element with given data
9788 * @param {object} targets Data object formatted as 'target'
9789 * @private
9790 */
9791 ;
9792
9793 _proto.updateTargets = function updateTargets(targets) {
9794 var $$ = this,
9795 _$$$state2 = $$.state,
9796 hasAxis = _$$$state2.hasAxis,
9797 hasRadar = _$$$state2.hasRadar;
9798 // Text
9799 $$.updateTargetsForText(targets);
9800
9801 if (hasAxis) {
9802 ["bar", "candlestick", "line"].forEach(function (v) {
9803 var name = capitalize(v);
9804
9805 if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
9806 $$["updateTargetsFor" + name](targets.filter($$["is" + name + "Type"].bind($$)));
9807 }
9808 }); // Sub Chart
9809
9810 $$.updateTargetsForSubchart && $$.updateTargetsForSubchart(targets);
9811 } else {
9812 // Arc & Radar
9813 $$.hasArcType(targets) && (hasRadar ? $$.updateTargetsForRadar(targets.filter($$.isRadarType.bind($$))) : $$.updateTargetsForArc(targets.filter($$.isArcType.bind($$))));
9814 } // circle
9815
9816
9817 if ($$.hasType("bubble") || $$.hasType("scatter")) {
9818 $$.updateTargetForCircle == null ? void 0 : $$.updateTargetForCircle();
9819 } // Fade-in each chart
9820
9821
9822 $$.showTargets();
9823 }
9824 /**
9825 * Display targeted elements
9826 * @private
9827 */
9828 ;
9829
9830 _proto.showTargets = function showTargets() {
9831 var $$ = this,
9832 svg = $$.$el.svg,
9833 $T = $$.$T;
9834 $T(svg.selectAll("." + config_classes.target).filter(function (d) {
9835 return $$.isTargetToShow(d.id);
9836 })).style("opacity", null);
9837 };
9838
9839 _proto.getWithOption = function getWithOption(options) {
9840 var withOptions = {
9841 Dimension: !0,
9842 EventRect: !0,
9843 Legend: !1,
9844 Subchart: !0,
9845 Transform: !1,
9846 Transition: !0,
9847 TrimXDomain: !0,
9848 UpdateXAxis: "UpdateXDomain",
9849 UpdateXDomain: !1,
9850 UpdateOrgXDomain: !1,
9851 TransitionForExit: "Transition",
9852 TransitionForAxis: "Transition",
9853 Y: !0
9854 };
9855 Object.keys(withOptions).forEach(function (key) {
9856 var defVal = withOptions[key];
9857
9858 if (isString(defVal)) {
9859 defVal = withOptions[defVal];
9860 }
9861
9862 withOptions[key] = getOption(options, "with" + key, defVal);
9863 });
9864 return withOptions;
9865 };
9866
9867 _proto.initialOpacity = function initialOpacity(d) {
9868 var $$ = this,
9869 withoutFadeIn = $$.state.withoutFadeIn;
9870 return $$.getBaseValue(d) !== null && withoutFadeIn[d.id] ? null : "0";
9871 };
9872
9873 _proto.bindResize = function bindResize() {
9874 var $$ = this,
9875 config = $$.config,
9876 state = $$.state,
9877 resizeFunction = generateResize(),
9878 list = [];
9879 list.push(function () {
9880 return callFn(config.onresize, $$, $$.api);
9881 });
9882
9883 if (config.resize_auto) {
9884 list.push(function () {
9885 state.resizing = !0;
9886 $$.api.flush(!1);
9887 });
9888 }
9889
9890 list.push(function () {
9891 callFn(config.onresized, $$, $$.api);
9892 state.resizing = !1;
9893 }); // add resize functions
9894
9895 list.forEach(function (v) {
9896 return resizeFunction.add(v);
9897 });
9898 $$.resizeFunction = resizeFunction; // attach resize event
9899
9900 win.addEventListener("resize", $$.resizeFunction = resizeFunction);
9901 }
9902 /**
9903 * Call plugin hook
9904 * @param {string} phase The lifecycle phase
9905 * @param {Array} args Arguments
9906 * @private
9907 */
9908 ;
9909
9910 _proto.callPluginHook = function callPluginHook(phase) {
9911 for (var _this = this, _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
9912 args[_key - 1] = arguments[_key];
9913 }
9914
9915 this.config.plugins.forEach(function (v) {
9916 if (phase === "$beforeInit") {
9917 v.$$ = _this;
9918
9919 _this.api.plugins.push(v);
9920 }
9921
9922 v[phase].apply(v, args);
9923 });
9924 };
9925
9926 return ChartInternal;
9927}();
9928
9929
9930extend(ChartInternal.prototype, [// common
9931convert, data_data, load, category, internals_class, internals_color, domain, interactions_interaction, format, internals_legend, redraw, scale, shape, size, internals_text, internals_title, internals_tooltip, transform, type]);
9932;// CONCATENATED MODULE: ./src/config/config.ts
9933/**
9934 * Copyright (c) 2017 ~ present NAVER Corp.
9935 * billboard.js project is licensed under the MIT license
9936 */
9937
9938
9939/**
9940 * Load configuration option
9941 * @param {object} config User's generation config value
9942 * @private
9943 */
9944function loadConfig(config) {
9945 var thisConfig = this.config,
9946 target,
9947 keys,
9948 read,
9949 find = function () {
9950 var key = keys.shift();
9951
9952 if (key && target && isObjectType(target) && key in target) {
9953 target = target[key];
9954 return find();
9955 } else if (!key) {
9956 return target;
9957 }
9958
9959 return undefined;
9960 };
9961
9962 Object.keys(thisConfig).forEach(function (key) {
9963 target = config;
9964 keys = key.split("_");
9965 read = find();
9966
9967 if (isDefined(read)) {
9968 thisConfig[key] = read;
9969 }
9970 });
9971}
9972;// CONCATENATED MODULE: ./src/Chart/api/chart.ts
9973/**
9974 * Copyright (c) 2017 ~ present NAVER Corp.
9975 * billboard.js project is licensed under the MIT license
9976 */
9977
9978
9979/* harmony default export */ var chart = ({
9980 /**
9981 * Resize the chart.
9982 * @function resize
9983 * @instance
9984 * @memberof Chart
9985 * @param {object} size This argument should include width and height in pixels.
9986 * @param {number} [size.width] width value
9987 * @param {number} [size.height] height value
9988 * @example
9989 * // Resize to 640x480
9990 * chart.resize({
9991 * width: 640,
9992 * height: 480
9993 * });
9994 */
9995 resize: function resize(size) {
9996 var $$ = this.internal,
9997 config = $$.config,
9998 state = $$.state;
9999
10000 if (state.rendered) {
10001 config.size_width = size ? size.width : null;
10002 config.size_height = size ? size.height : null;
10003 state.resizing = !0;
10004 this.flush(!1, !0);
10005 $$.resizeFunction();
10006 }
10007 },
10008
10009 /**
10010 * Force to redraw.
10011 * - **NOTE:** When zoom/subchart is used, the zoomed state will be resetted.
10012 * @function flush
10013 * @instance
10014 * @memberof Chart
10015 * @param {boolean} [soft] For soft redraw.
10016 * @example
10017 * chart.flush();
10018 *
10019 * // for soft redraw
10020 * chart.flush(true);
10021 */
10022 flush: function flush(soft) {
10023 var $$ = this.internal,
10024 state = $$.state,
10025 zoomResetBtn = $$.$el.zoomResetBtn;
10026
10027 if (state.rendered) {
10028 var _zoomResetBtn;
10029
10030 // reset possible zoom scale when is called from resize event
10031 // eslint-disable-next-line prefer-rest-params
10032 if (state.resizing) {
10033 var _$$$brush;
10034
10035 // arguments[1] is given when is called from resize
10036 (_$$$brush = $$.brush) == null ? void 0 : _$$$brush.updateResize();
10037 } else {
10038 var _$$$axis;
10039
10040 // re-update config info
10041 (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.setOrient();
10042 } // hide possible reset zoom button
10043 // https://github.com/naver/billboard.js/issues/2201
10044
10045
10046 (_zoomResetBtn = zoomResetBtn) == null ? void 0 : _zoomResetBtn.style("display", "none");
10047 $$.scale.zoom = null;
10048 soft ? $$.redraw({
10049 withTransform: !0,
10050 withUpdateXDomain: !0,
10051 withUpdateOrgXDomain: !0,
10052 withLegend: !0
10053 }) : $$.updateAndRedraw({
10054 withLegend: !0,
10055 withTransition: !1,
10056 withTransitionForTransform: !1
10057 }); // reset subchart selection & selection state
10058
10059 if (!state.resizing && $$.brush) {
10060 $$.brush.getSelection().call($$.brush.move);
10061 $$.unselectRect();
10062 }
10063 } else {
10064 $$.initToRender(!0);
10065 }
10066 },
10067
10068 /**
10069 * Reset the chart object and remove element and events completely.
10070 * @function destroy
10071 * @instance
10072 * @memberof Chart
10073 * @returns {null}
10074 * @example
10075 * chart.destroy();
10076 */
10077 destroy: function destroy() {
10078 var _this = this,
10079 $$ = this.internal,
10080 _$$$$el = $$.$el,
10081 chart = _$$$$el.chart,
10082 svg = _$$$$el.svg;
10083
10084 if (notEmpty($$)) {
10085 $$.callPluginHook("$willDestroy");
10086 $$.charts.splice($$.charts.indexOf(this), 1); // clear timers && pending transition
10087
10088 svg.select("*").interrupt();
10089 $$.resizeFunction.clear();
10090 win.removeEventListener("resize", $$.resizeFunction);
10091 chart.classed("bb", !1).html(""); // releasing own references
10092
10093 Object.keys(this).forEach(function (key) {
10094 key === "internal" && Object.keys($$).forEach(function (k) {
10095 $$[k] = null;
10096 });
10097 _this[key] = null;
10098 delete _this[key];
10099 }); // release prototype chains
10100
10101 for (var key in this) {
10102 this[key] = function () {};
10103 }
10104 }
10105
10106 return null;
10107 },
10108
10109 /**
10110 * Get or set single config option value.
10111 * @function config
10112 * @instance
10113 * @memberof Chart
10114 * @param {string} name The option key name.
10115 * @param {*} [value] The value accepted for indicated option.
10116 * @param {boolean} [redraw] Set to redraw with the new option changes.
10117 * - **NOTE:** Doesn't guarantee work in all circumstances. It can be applied for limited options only.
10118 * @returns {*}
10119 * @example
10120 * // Getter
10121 * chart.config("gauge.max");
10122 *
10123 * // Setter
10124 * chart.config("gauge.max", 100);
10125 *
10126 * // Setter & redraw with the new option
10127 * chart.config("gauge.max", 100, true);
10128 */
10129 config: function (name, value, redraw) {
10130 var $$ = this.internal,
10131 config = $$.config,
10132 key = name == null ? void 0 : name.replace(/\./g, "_"),
10133 res;
10134
10135 if (key in config) {
10136 if (isDefined(value)) {
10137 config[key] = value;
10138 res = value;
10139 redraw && this.flush();
10140 } else {
10141 res = config[key];
10142 }
10143 }
10144
10145 return res;
10146 }
10147});
10148;// CONCATENATED MODULE: ./src/Chart/api/color.ts
10149/**
10150 * Copyright (c) 2017 ~ present NAVER Corp.
10151 * billboard.js project is licensed under the MIT license
10152 */
10153/* harmony default export */ var api_color = ({
10154 /**
10155 * Get the color
10156 * @function color
10157 * @instance
10158 * @memberof Chart
10159 * @param {string} id id to get the color
10160 * @returns {string}
10161 * @example
10162 * chart.color("data1");
10163 */
10164 color: function color(id) {
10165 return this.internal.color(id); // more patterns
10166 }
10167});
10168;// CONCATENATED MODULE: ./src/Chart/api/data.ts
10169/**
10170 * Copyright (c) 2017 ~ present NAVER Corp.
10171 * billboard.js project is licensed under the MIT license
10172 */
10173
10174
10175/**
10176 * Get data loaded in the chart.
10177 * @function data
10178 * @instance
10179 * @memberof Chart
10180 * @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.
10181 * @returns {Array} Data objects
10182 * @example
10183 * // Get only data1 data
10184 * chart.data("data1");
10185 * // --> [{id: "data1", id_org: "data1", values: Array(6)}, ...]
10186 *
10187 * // Get data1 and data2 data
10188 * chart.data(["data1", "data2"]);
10189 *
10190 * // Get all data
10191 * chart.data();
10192 */
10193function api_data_data(targetIds) {
10194 var targets = this.internal.data.targets;
10195
10196 if (!isUndefined(targetIds)) {
10197 var ids = isArray(targetIds) ? targetIds : [targetIds];
10198 return targets.filter(function (t) {
10199 return ids.some(function (v) {
10200 return v === t.id;
10201 });
10202 });
10203 }
10204
10205 return targets;
10206}
10207
10208extend(api_data_data, {
10209 /**
10210 * Get data shown in the chart.
10211 * @function data․shown
10212 * @instance
10213 * @memberof Chart
10214 * @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.
10215 * @returns {Array} Data objects
10216 * @example
10217 * // Get shown data by filtering to include only data1 data
10218 * chart.data.shown("data1");
10219 * // --> [{id: "data1", id_org: "data1", values: Array(6)}, ...]
10220 *
10221 * // Get shown data by filtering to include data1 and data2 data
10222 * chart.data.shown(["data1", "data2"]);
10223 *
10224 * // Get all shown data
10225 * chart.data.shown();
10226 */
10227 shown: function shown(targetIds) {
10228 return this.internal.filterTargetsToShow(this.data(targetIds));
10229 },
10230
10231 /**
10232 * Get values of the data loaded in the chart.
10233 * @function data․values
10234 * @instance
10235 * @memberof Chart
10236 * @param {string|Array|null} targetIds This API returns the values of specified target. If this argument is not given, null will be retruned
10237 * @param {boolean} [flat=true] Get flatten values
10238 * @returns {Array} Data values
10239 * @example
10240 * // Get data1 values
10241 * chart.data.values("data1");
10242 * // --> [10, 20, 30, 40]
10243 */
10244 values: function (targetIds, flat) {
10245 if (flat === void 0) {
10246 flat = !0;
10247 }
10248
10249 var values = null;
10250
10251 if (targetIds) {
10252 var targets = this.data(targetIds);
10253
10254 if (isArray(targets)) {
10255 values = [];
10256 targets.forEach(function (v) {
10257 var dataValue = v.values.map(function (d) {
10258 return d.value;
10259 });
10260 flat ? values = values.concat(dataValue) : values.push(dataValue);
10261 });
10262 }
10263 }
10264
10265 return values;
10266 },
10267
10268 /**
10269 * Get and set names of the data loaded in the chart.
10270 * @function data․names
10271 * @instance
10272 * @memberof Chart
10273 * @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
10274 * @returns {object} Corresponding names according its key value, if specified names values.
10275 * @example
10276 * // Get current names
10277 * chart.data.names();
10278 * // --> {data1: "test1", data2: "test2"}
10279 *
10280 * // Update names
10281 * chart.data.names({
10282 * data1: "New Name 1",
10283 * data2: "New Name 2"
10284 *});
10285 */
10286 names: function names(_names) {
10287 var $$ = this.internal;
10288 return $$.updateDataAttributes("names", _names);
10289 },
10290
10291 /**
10292 * Get and set colors of the data loaded in the chart.
10293 * @function data․colors
10294 * @instance
10295 * @memberof Chart
10296 * @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).
10297 * @returns {object} Corresponding data color value according its key value.
10298 * @example
10299 * // Get current colors
10300 * chart.data.colors();
10301 * // --> {data1: "#00c73c", data2: "#fa7171"}
10302 *
10303 * // Update colors
10304 * chart.data.colors({
10305 * data1: "#FFFFFF",
10306 * data2: "#000000"
10307 * });
10308 */
10309 colors: function colors(_colors) {
10310 return this.internal.updateDataAttributes("colors", _colors);
10311 },
10312
10313 /**
10314 * Get and set axes of the data loaded in the chart.
10315 * - **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
10316 * @function data․axes
10317 * @instance
10318 * @memberof Chart
10319 * @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
10320 * @returns {object} Corresponding axes value for data, if specified axes value.
10321 * @example
10322 * // Get current axes
10323 * chart.data.axes();
10324 * // --> {data1: "y"}
10325 *
10326 * // Update axes
10327 * chart.data.axes({
10328 * data1: "y",
10329 * data2: "y2"
10330 * });
10331 */
10332 axes: function axes(_axes) {
10333 return this.internal.updateDataAttributes("axes", _axes);
10334 },
10335
10336 /**
10337 * Get the minimum data value bound to the chart
10338 * @function data․min
10339 * @instance
10340 * @memberof Chart
10341 * @returns {Array} Data objects
10342 * @example
10343 * // Get current axes
10344 * chart.data.min();
10345 * // --> [{x: 0, value: 30, id: "data1", index: 0}, ...]
10346 */
10347 min: function min() {
10348 return this.internal.getMinMaxData().min;
10349 },
10350
10351 /**
10352 * Get the maximum data value bound to the chart
10353 * @function data․max
10354 * @instance
10355 * @memberof Chart
10356 * @returns {Array} Data objects
10357 * @example
10358 * // Get current axes
10359 * chart.data.max();
10360 * // --> [{x: 3, value: 400, id: "data1", index: 3}, ...]
10361 */
10362 max: function max() {
10363 return this.internal.getMinMaxData().max;
10364 }
10365});
10366/* harmony default export */ var api_data = ({
10367 data: api_data_data
10368});
10369;// CONCATENATED MODULE: ./src/Chart/api/export.ts
10370/**
10371 * Copyright (c) 2017 ~ present NAVER Corp.
10372 * billboard.js project is licensed under the MIT license
10373 */
10374
10375
10376
10377
10378/**
10379 * Encode to base64
10380 * @param {string} str string to be encoded
10381 * @returns {string}
10382 * @private
10383 * @see https://developer.mozilla.org/ko/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
10384 */
10385var b64EncodeUnicode = function (str) {
10386 return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p) {
10387 return String.fromCharCode(+("0x" + p));
10388 }));
10389};
10390/**
10391 * Convert svg node to data url
10392 * @param {HTMLElement} node target node
10393 * @param {object} option object containing {width, height, preserveAspectRatio}
10394 * @param {object} orgSize object containing {width, height}
10395 * @returns {string}
10396 * @private
10397 */
10398
10399
10400function nodeToSvgDataUrl(node, option, orgSize) {
10401 var _ref = option || orgSize,
10402 width = _ref.width,
10403 height = _ref.height,
10404 serializer = new XMLSerializer(),
10405 clone = node.cloneNode(!0),
10406 cssText = getCssRules(toArray(browser_doc.styleSheets)).filter(function (r) {
10407 return r.cssText;
10408 }).map(function (r) {
10409 return r.cssText;
10410 });
10411
10412 clone.setAttribute("xmlns", external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.xhtml);
10413 var nodeXml = serializer.serializeToString(clone),
10414 style = browser_doc.createElement("style"); // escape css for XML
10415
10416 style.appendChild(browser_doc.createTextNode(cssText.join("\n")));
10417 var styleXml = serializer.serializeToString(style),
10418 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
10419 // https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx
10420
10421 return "data:image/svg+xml;base64," + b64EncodeUnicode(dataStr);
10422}
10423
10424/* harmony default export */ var api_export = ({
10425 /**
10426 * Export chart as an image.
10427 * - **NOTE:**
10428 * - 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
10429 * - The basic CSS file(ex. billboard.css) should be at same domain as API call context to get correct styled export image.
10430 * @function export
10431 * @instance
10432 * @memberof Chart
10433 * @param {object} option Export option
10434 * @param {string} [option.mimeType="image/png"] The desired output image format. (ex. 'image/png' for png, 'image/jpeg' for jpeg format)
10435 * @param {number} [option.width={currentWidth}] width
10436 * @param {number} [option.height={currentHeigth}] height
10437 * @param {boolean} [option.preserveAspectRatio=true] Preserve aspect ratio on given size
10438 * @param {Function} [callback] The callback to be invoked when export is ready.
10439 * @returns {string} dataURI
10440 * @example
10441 * chart.export();
10442 * // --> "data:image/svg+xml;base64,PHN..."
10443 *
10444 * // Initialize the download automatically
10445 * chart.export({mimeType: "image/png"}, dataUrl => {
10446 * const link = document.createElement("a");
10447 *
10448 * link.download = `${Date.now()}.png`;
10449 * link.href = dataUrl;
10450 * link.innerHTML = "Download chart as image";
10451 *
10452 * document.body.appendChild(link);
10453 * });
10454 *
10455 * // Resize the exported image
10456 * chart.export(
10457 * {
10458 * width: 800,
10459 * height: 600,
10460 * preserveAspectRatio: false,
10461 * mimeType: "image/png"
10462 * },
10463 * dataUrl => { ... }
10464 * );
10465 */
10466 export: function _export(option, callback) {
10467 var _this = this,
10468 $$ = this.internal,
10469 state = $$.state,
10470 chart = $$.$el.chart,
10471 _state$current = state.current,
10472 width = _state$current.width,
10473 height = _state$current.height,
10474 opt = mergeObj({
10475 width: width,
10476 height: height,
10477 preserveAspectRatio: !0,
10478 mimeType: "image/png"
10479 }, option),
10480 svgDataUrl = nodeToSvgDataUrl(chart.node(), opt, {
10481 width: width,
10482 height: height
10483 });
10484
10485 if (callback && isFunction(callback)) {
10486 var img = new Image();
10487 img.crossOrigin = "Anonymous";
10488
10489 img.onload = function () {
10490 var canvas = browser_doc.createElement("canvas"),
10491 ctx = canvas.getContext("2d");
10492 canvas.width = opt.width || width;
10493 canvas.height = opt.height || height;
10494 ctx.drawImage(img, 0, 0);
10495 callback.bind(_this)(canvas.toDataURL(opt.mimeType));
10496 };
10497
10498 img.src = svgDataUrl;
10499 }
10500
10501 return svgDataUrl;
10502 }
10503});
10504;// CONCATENATED MODULE: ./src/Chart/api/focus.ts
10505/**
10506 * Copyright (c) 2017 ~ present NAVER Corp.
10507 * billboard.js project is licensed under the MIT license
10508 */
10509
10510
10511/* harmony default export */ var api_focus = ({
10512 /**
10513 * This API highlights specified targets and fade out the others.<br><br>
10514 * 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.
10515 * @function focus
10516 * @instance
10517 * @memberof Chart
10518 * @param {string|Array} targetIdsValue Target ids to be highlighted.
10519 * @example
10520 * // data1 will be highlighted and the others will be faded out
10521 * chart.focus("data1");
10522 *
10523 * // data1 and data2 will be highlighted and the others will be faded out
10524 * chart.focus(["data1", "data2"]);
10525 *
10526 * // all targets will be highlighted
10527 * chart.focus();
10528 */
10529 focus: function focus(targetIdsValue) {
10530 var $$ = this.internal,
10531 state = $$.state,
10532 targetIds = $$.mapToTargetIds(targetIdsValue),
10533 candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
10534 this.revert();
10535 this.defocus();
10536 candidates.classed(config_classes.focused, !0).classed(config_classes.defocused, !1);
10537
10538 if ($$.hasArcType() && !state.hasRadar) {
10539 $$.expandArc(targetIds);
10540 $$.hasType("gauge") && $$.markOverlapped(targetIdsValue, $$, "." + config_classes.gaugeValue);
10541 }
10542
10543 $$.toggleFocusLegend(targetIds, !0);
10544 state.focusedTargetIds = targetIds;
10545 state.defocusedTargetIds = state.defocusedTargetIds.filter(function (id) {
10546 return targetIds.indexOf(id) < 0;
10547 });
10548 },
10549
10550 /**
10551 * This API fades out specified targets and reverts the others.<br><br>
10552 * 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.
10553 * @function defocus
10554 * @instance
10555 * @memberof Chart
10556 * @param {string|Array} targetIdsValue Target ids to be faded out.
10557 * @example
10558 * // data1 will be faded out and the others will be reverted.
10559 * chart.defocus("data1");
10560 *
10561 * // data1 and data2 will be faded out and the others will be reverted.
10562 * chart.defocus(["data1", "data2"]);
10563 *
10564 * // all targets will be faded out.
10565 * chart.defocus();
10566 */
10567 defocus: function defocus(targetIdsValue) {
10568 var $$ = this.internal,
10569 state = $$.state,
10570 targetIds = $$.mapToTargetIds(targetIdsValue),
10571 candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
10572 candidates.classed(config_classes.focused, !1).classed(config_classes.defocused, !0);
10573
10574 if ($$.hasArcType()) {
10575 $$.unexpandArc(targetIds);
10576 $$.hasType("gauge") && $$.undoMarkOverlapped($$, "." + config_classes.gaugeValue);
10577 }
10578
10579 $$.toggleFocusLegend(targetIds, !1);
10580 state.focusedTargetIds = state.focusedTargetIds.filter(function (id) {
10581 return targetIds.indexOf(id) < 0;
10582 });
10583 state.defocusedTargetIds = targetIds;
10584 },
10585
10586 /**
10587 * This API reverts specified targets.<br><br>
10588 * 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.
10589 * @function revert
10590 * @instance
10591 * @memberof Chart
10592 * @param {string|Array} targetIdsValue Target ids to be reverted
10593 * @example
10594 * // data1 will be reverted.
10595 * chart.revert("data1");
10596 *
10597 * // data1 and data2 will be reverted.
10598 * chart.revert(["data1", "data2"]);
10599 *
10600 * // all targets will be reverted.
10601 * chart.revert();
10602 */
10603 revert: function revert(targetIdsValue) {
10604 var $$ = this.internal,
10605 config = $$.config,
10606 state = $$.state,
10607 $el = $$.$el,
10608 targetIds = $$.mapToTargetIds(targetIdsValue),
10609 candidates = $el.svg.selectAll($$.selectorTargets(targetIds));
10610 // should be for all targets
10611 candidates.classed(config_classes.focused, !1).classed(config_classes.defocused, !1);
10612 $$.hasArcType() && $$.unexpandArc(targetIds);
10613
10614 if (config.legend_show) {
10615 $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
10616 $el.legend.selectAll($$.selectorLegends(targetIds)).filter(function () {
10617 return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused);
10618 }).classed(config_classes.legendItemFocused, !1);
10619 }
10620
10621 state.focusedTargetIds = [];
10622 state.defocusedTargetIds = [];
10623 }
10624});
10625;// CONCATENATED MODULE: ./src/Chart/api/legend.ts
10626/**
10627 * Copyright (c) 2017 ~ present NAVER Corp.
10628 * billboard.js project is licensed under the MIT license
10629 */
10630
10631/**
10632 * Define legend
10633 * @ignore
10634 */
10635var legend_legend = {
10636 /**
10637 * Show legend for each target.
10638 * @function legend․show
10639 * @instance
10640 * @memberof Chart
10641 * @param {string|Array} targetIds
10642 * - If targetIds is given, specified target's legend will be shown.
10643 * - If only one target is the candidate, String can be passed.
10644 * - If no argument is given, all of target's legend will be shown.
10645 * @example
10646 * // Show legend for data1.
10647 * chart.legend.show("data1");
10648 *
10649 * // Show legend for data1 and data2.
10650 * chart.legend.show(["data1", "data2"]);
10651 *
10652 * // Show all legend.
10653 * chart.legend.show();
10654 */
10655 show: function show(targetIds) {
10656 var $$ = this.internal;
10657 $$.showLegend($$.mapToTargetIds(targetIds));
10658 $$.updateAndRedraw({
10659 withLegend: !0
10660 });
10661 },
10662
10663 /**
10664 * Hide legend for each target.
10665 * @function legend․hide
10666 * @instance
10667 * @memberof Chart
10668 * @param {string|Array} targetIds
10669 * - If targetIds is given, specified target's legend will be hidden.
10670 * - If only one target is the candidate, String can be passed.
10671 * - If no argument is given, all of target's legend will be hidden.
10672 * @example
10673 * // Hide legend for data1.
10674 * chart.legend.hide("data1");
10675 *
10676 * // Hide legend for data1 and data2.
10677 * chart.legend.hide(["data1", "data2"]);
10678 *
10679 * // Hide all legend.
10680 * chart.legend.hide();
10681 */
10682 hide: function hide(targetIds) {
10683 var $$ = this.internal;
10684 $$.hideLegend($$.mapToTargetIds(targetIds));
10685 $$.updateAndRedraw({
10686 withLegend: !0
10687 });
10688 }
10689};
10690/* harmony default export */ var api_legend = ({
10691 legend: legend_legend
10692});
10693;// CONCATENATED MODULE: ./src/Chart/api/load.ts
10694/**
10695 * Copyright (c) 2017 ~ present NAVER Corp.
10696 * billboard.js project is licensed under the MIT license
10697 */
10698
10699
10700/* harmony default export */ var api_load = ({
10701 /**
10702 * Load data to the chart.<br><br>
10703 * 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.
10704 * - <b>Note:</b>
10705 * - unload should be used if some data needs to be unloaded simultaneously.
10706 * 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>
10707 * - done will be called after data loaded, but it's not after rendering.
10708 * It's because rendering will finish after some transition and there is some time lag between loading and rendering
10709 * @function load
10710 * @instance
10711 * @memberof Chart
10712 * @param {object} args The object can consist with following members:<br>
10713 *
10714 * | Key | Description |
10715 * | --- | --- |
10716 * | - 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 |
10717 * | data | Data objects to be loaded. Checkout the example. |
10718 * | 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. |
10719 * | names | Same as data.names() |
10720 * | xs | Same as data.xs option |
10721 * | classes | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
10722 * | categories | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
10723 * | axes | The axes specified by data.axes will be updated. axes must be Object that has target id as keys. |
10724 * | colors | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
10725 * | headers | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
10726 * | 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) |
10727 * | mimeType | Set 'json' if loading JSON via url.<br>@see [data․mimeType](Options.html#.data%25E2%2580%25A4mimeType) |
10728 * | - type<br>- types | The type of targets will be updated. type must be String and types must be Object. |
10729 * | 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. |
10730 * | done | The specified function will be called after data loaded.|
10731 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataFromURL)
10732 * @example
10733 * // Load data1 and unload data2 and data3
10734 * chart.load({
10735 * columns: [
10736 * ["data1", 100, 200, 150, ...],
10737 * ...
10738 * ],
10739 * unload: ["data2", "data3"],
10740 * url: "...",
10741 * done: function() { ... }
10742 * });
10743 * @example
10744 * const chart = bb.generate({
10745 * data: {
10746 * columns: [
10747 * ["data1", 20, 30, 40]
10748 * ]
10749 * }
10750 * });
10751 *
10752 * chart.load({
10753 * columns: [
10754 * // with 'append' option, the 'data1' will have `[20,30,40,50,60]`.
10755 * ["data1", 50, 60]
10756 * ],
10757 * append: true
10758 * });
10759 * @example
10760 * const chart = bb.generate({
10761 * data: {
10762 * x: "x",
10763 * xFormat: "%Y-%m-%dT%H:%M:%S",
10764 * columns: [
10765 * ["x", "2021-01-03T03:00:00", "2021-01-04T12:00:00", "2021-01-05T21:00:00"],
10766 * ["data1", 36, 30, 24]
10767 * ]
10768 * },
10769 * axis: {
10770 * x: {
10771 * type: "timeseries"
10772 * }
10773 * }
10774 * };
10775 *
10776 * chart.load({
10777 * columns: [
10778 * // when existing chart has `x` value, should provide correponding 'x' value.
10779 * // with 'append' option, the 'data1' will have `[36,30,24,37]`.
10780 * ["x", "2021-02-01T08:00:00"],
10781 * ["data1", 37]
10782 * ],
10783 * append: true
10784 * });
10785 * @example
10786 * // myAPI.json
10787 * // {
10788 * // "data1": [220, 240, 270, 250, 280],
10789 * // "data2": [180, 150, 300, 70, 120]
10790 * // }
10791 *
10792 * chart.load({
10793 * url: './data/myAPI.json',
10794 * mimeType: "json",
10795 *
10796 * // set request header if is needed
10797 * headers: {
10798 * "Content-Type": "text/json"
10799 * }
10800 * });
10801 * @example
10802 * chart.load({
10803 * data: [
10804 * // equivalent as: columns: [["data1", 30, 200, 100]]
10805 * {"data1": 30}, {"data1": 200}, {"data1": 100}
10806 *
10807 * // or
10808 * // equivalent as: columns: [["data1", 10, 20], ["data2", 13, 30]]
10809 * // {"data1": 10, "data2": 13}, {"data1": 20, "data2": 30}}
10810 * ]
10811 * });
10812 * @example
10813 * chart.load({
10814 * json: [
10815 * {name: "www.site1.com", upload: 800, download: 500, total: 400},
10816 * ],
10817 * keys: {
10818 * x: "name",
10819 * value: ["upload", "download"]
10820 * }
10821 * });
10822 * @example
10823 * chart.load({
10824 * json: {
10825 * data1:[30, 20, 50, 40, 60, 50],
10826 * data2:[200, 130, 90, 240, 130, 220],
10827 * }
10828 * });
10829 */
10830 load: function load(args) {
10831 var $$ = this.internal,
10832 config = $$.config;
10833 // update xs if specified
10834 args.xs && $$.addXs(args.xs); // update names if exists
10835
10836 "names" in args && this.data.names(args.names); // update classes if exists
10837
10838 "classes" in args && Object.keys(args.classes).forEach(function (id) {
10839 config.data_classes[id] = args.classes[id];
10840 }); // update categories if exists
10841
10842 if ("categories" in args && $$.axis.isCategorized()) {
10843 config.axis_x_categories = args.categories;
10844 } // update axes if exists
10845
10846
10847 "axes" in args && Object.keys(args.axes).forEach(function (id) {
10848 config.data_axes[id] = args.axes[id];
10849 }); // update colors if exists
10850
10851 "colors" in args && Object.keys(args.colors).forEach(function (id) {
10852 config.data_colors[id] = args.colors[id];
10853 }); // unload if needed
10854
10855 if ("unload" in args && args.unload !== !1) {
10856 // TODO: do not unload if target will load (included in url/rows/columns)
10857 $$.unload($$.mapToTargetIds(args.unload === !0 ? null : args.unload), function () {
10858 // to mitigate improper rendering for multiple consecutive calls
10859 // https://github.com/naver/billboard.js/issues/2121
10860 win.requestIdleCallback(function () {
10861 return $$.loadFromArgs(args);
10862 });
10863 });
10864 } else {
10865 $$.loadFromArgs(args);
10866 }
10867 },
10868
10869 /**
10870 * Unload data to the chart.<br><br>
10871 * 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.
10872 * - <b>Note:</b>
10873 * 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>
10874 * `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.
10875 * @function unload
10876 * @instance
10877 * @memberof Chart
10878 * @param {object} argsValue
10879 * | key | Type | Description |
10880 * | --- | --- | --- |
10881 * | ids | String &vert; Array | Target id data to be unloaded. If not given, all data will be unloaded. |
10882 * | done | Fuction | Callback after data is unloaded. |
10883 * @example
10884 * // Unload data2 and data3
10885 * chart.unload({
10886 * ids: ["data2", "data3"],
10887 * done: function() {
10888 * // called after the unloaded
10889 * }
10890 * });
10891 */
10892 unload: function unload(argsValue) {
10893 var _this = this,
10894 $$ = this.internal,
10895 args = argsValue || {};
10896
10897 if (isArray(args)) {
10898 args = {
10899 ids: args
10900 };
10901 } else if (isString(args)) {
10902 args = {
10903 ids: [args]
10904 };
10905 }
10906
10907 var ids = $$.mapToTargetIds(args.ids);
10908 $$.unload(ids, function () {
10909 $$.redraw({
10910 withUpdateOrgXDomain: !0,
10911 withUpdateXDomain: !0,
10912 withLegend: !0
10913 });
10914 $$.cache.remove(ids);
10915 args.done && args.done.call(_this);
10916 });
10917 }
10918});
10919;// CONCATENATED MODULE: ./src/Chart/api/show.ts
10920/**
10921 * Copyright (c) 2017 ~ present NAVER Corp.
10922 * billboard.js project is licensed under the MIT license
10923 */
10924
10925/**
10926 * Show/Hide data series
10927 * @param {boolean} show Show or hide
10928 * @param {Array} targetIdsValue Target id values
10929 * @param {object} options Options
10930 * @private
10931 */
10932
10933function showHide(show, targetIdsValue, options) {
10934 var _this = this,
10935 $$ = this.internal,
10936 targetIds = $$.mapToTargetIds(targetIdsValue),
10937 hiddenIds = $$.state.hiddenTargetIds.map(function (v) {
10938 return targetIds.indexOf(v) > -1 && v;
10939 }).filter(Boolean);
10940
10941 $$.state.toggling = !0;
10942 $$[(show ? "remove" : "add") + "HiddenTargetIds"](targetIds);
10943 var targets = $$.$el.svg.selectAll($$.selectorTargets(targetIds)),
10944 opacity = show ? null : "0";
10945
10946 if (show && hiddenIds.length) {
10947 targets.style("display", null);
10948 callFn($$.config.data_onshown, this, hiddenIds);
10949 }
10950
10951 $$.$T(targets).style("opacity", opacity, "important").call(endall, function () {
10952 // https://github.com/naver/billboard.js/issues/1758
10953 if (!show && hiddenIds.length === 0) {
10954 targets.style("display", "none");
10955 callFn($$.config.data_onhidden, _this, targetIds);
10956 }
10957
10958 targets.style("opacity", opacity);
10959 });
10960 options.withLegend && $$[(show ? "show" : "hide") + "Legend"](targetIds);
10961 $$.redraw({
10962 withUpdateOrgXDomain: !0,
10963 withUpdateXDomain: !0,
10964 withLegend: !0
10965 });
10966 $$.state.toggling = !1;
10967}
10968
10969/* harmony default export */ var show = ({
10970 /**
10971 * Show data series on chart
10972 * @function show
10973 * @instance
10974 * @memberof Chart
10975 * @param {string|Array} [targetIdsValue] The target id value.
10976 * @param {object} [options] The object can consist with following members:<br>
10977 *
10978 * | Key | Type | default | Description |
10979 * | --- | --- | --- | --- |
10980 * | withLegend | boolean | false | whether or not display legend |
10981 *
10982 * @example
10983 * // show 'data1'
10984 * chart.show("data1");
10985 *
10986 * // show 'data1' and 'data3'
10987 * chart.show(["data1", "data3"]);
10988 */
10989 show: function show(targetIdsValue, options) {
10990 if (options === void 0) {
10991 options = {};
10992 }
10993
10994 showHide.call(this, !0, targetIdsValue, options);
10995 },
10996
10997 /**
10998 * Hide data series from chart
10999 * @function hide
11000 * @instance
11001 * @memberof Chart
11002 * @param {string|Array} [targetIdsValue] The target id value.
11003 * @param {object} [options] The object can consist with following members:<br>
11004 *
11005 * | Key | Type | default | Description |
11006 * | --- | --- | --- | --- |
11007 * | withLegend | boolean | false | whether or not display legend |
11008 *
11009 * @example
11010 * // hide 'data1'
11011 * chart.hide("data1");
11012 *
11013 * // hide 'data1' and 'data3'
11014 * chart.hide(["data1", "data3"]);
11015 */
11016 hide: function hide(targetIdsValue, options) {
11017 if (options === void 0) {
11018 options = {};
11019 }
11020
11021 showHide.call(this, !1, targetIdsValue, options);
11022 },
11023
11024 /**
11025 * Toggle data series on chart. When target data is hidden, it will show. If is shown, it will hide in vice versa.
11026 * @function toggle
11027 * @instance
11028 * @memberof Chart
11029 * @param {string|Array} [targetIds] The target id value.
11030 * @param {object} [options] The object can consist with following members:<br>
11031 *
11032 * | Key | Type | default | Description |
11033 * | --- | --- | --- | --- |
11034 * | withLegend | boolean | false | whether or not display legend |
11035 *
11036 * @example
11037 * // toggle 'data1'
11038 * chart.toggle("data1");
11039 *
11040 * // toggle 'data1' and 'data3'
11041 * chart.toggle(["data1", "data3"]);
11042 */
11043 toggle: function toggle(targetIds, options) {
11044 var _this2 = this;
11045
11046 if (options === void 0) {
11047 options = {};
11048 }
11049
11050 var $$ = this.internal,
11051 targets = {
11052 show: [],
11053 hide: []
11054 };
11055 // sort show & hide target ids
11056 $$.mapToTargetIds(targetIds).forEach(function (id) {
11057 return targets[$$.isTargetToShow(id) ? "hide" : "show"].push(id);
11058 }); // perform show & hide task separately
11059 // https://github.com/naver/billboard.js/issues/454
11060
11061 targets.show.length && this.show(targets.show, options);
11062 targets.hide.length && setTimeout(function () {
11063 return _this2.hide(targets.hide, options);
11064 }, 0);
11065 }
11066});
11067;// CONCATENATED MODULE: ./src/Chart/api/tooltip.ts
11068/**
11069 * Copyright (c) 2017 ~ present NAVER Corp.
11070 * billboard.js project is licensed under the MIT license
11071 */
11072
11073/**
11074 * Define tooltip
11075 * @ignore
11076 */
11077
11078var tooltip_tooltip = {
11079 /**
11080 * Show tooltip
11081 * @function tooltip․show
11082 * @instance
11083 * @memberof Chart
11084 * @param {object} args The object can consist with following members:<br>
11085 *
11086 * | Key | Type | Description |
11087 * | --- | --- | --- |
11088 * | index | Number | Determine focus by index |
11089 * | x | Number &vert; Date | Determine focus by x Axis index |
11090 * | 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]` |
11091 * | 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. |
11092 *
11093 * @example
11094 * // show the 2nd x Axis coordinate tooltip
11095 * // for Arc(gauge, donut & pie) and radar type, approch showing tooltip by using "index" number.
11096 * chart.tooltip.show({
11097 * index: 1
11098 * });
11099 *
11100 * // show tooltip for the 3rd x Axis in x:50 and y:100 coordinate of '.bb-event-rect' of the x Axis.
11101 * chart.tooltip.show({
11102 * x: 2,
11103 * mouse: [50, 100]
11104 * });
11105 *
11106 * // show tooltip for timeseries x axis
11107 * chart.tooltip.show({
11108 * x: new Date("2018-01-02 00:00")
11109 * });
11110 *
11111 * // when data.xs is used
11112 * chart.tooltip.show({
11113 * data: {
11114 * x: 3, // x Axis value
11115 * id: "data1", // data id
11116 * value: 500 // data value
11117 * }
11118 * });
11119 *
11120 * // when data.xs isn't used, but tooltip.grouped=false is set
11121 * chart.tooltip.show({
11122 * data: {
11123 * index: 3, // or 'x' key value
11124 * id: "data1", // data id
11125 * value: 500 // data value
11126 * }
11127 * });
11128 */
11129 show: function show(args) {
11130 var $$ = this.internal,
11131 config = $$.config,
11132 inputType = $$.state.inputType,
11133 index,
11134 mouse;
11135
11136 // determine mouse position on the chart
11137 if (args.mouse) {
11138 mouse = args.mouse;
11139 } // determine focus data
11140
11141
11142 if (args.data) {
11143 var data = args.data,
11144 y = $$.getYScaleById(data.id)(data.value);
11145
11146 if ($$.isMultipleX()) {
11147 // if multiple xs, target point will be determined by mouse
11148 mouse = [$$.scale.x(data.x), y];
11149 } else {
11150 if (!config.tooltip_grouped) {
11151 mouse = [0, y];
11152 }
11153
11154 index = isValue(data.index) ? data.index : $$.getIndexByX(data.x);
11155 }
11156 } else if (isDefined(args.x)) {
11157 index = $$.getIndexByX(args.x);
11158 } else if (isDefined(args.index)) {
11159 index = args.index;
11160 }
11161
11162 (inputType === "mouse" ? ["mouseover", "mousemove"] : ["touchstart"]).forEach(function (eventName) {
11163 $$.dispatchEvent(eventName, index, mouse);
11164 });
11165 },
11166
11167 /**
11168 * Hide tooltip
11169 * @function tooltip․hide
11170 * @instance
11171 * @memberof Chart
11172 */
11173 hide: function hide() {
11174 var $$ = this.internal,
11175 inputType = $$.state.inputType,
11176 tooltip = $$.$el.tooltip,
11177 data = tooltip == null ? void 0 : tooltip.datum();
11178
11179 if (data) {
11180 var index = JSON.parse(data.current)[0].index; // make to finalize, possible pending event flow set from '.tooltip.show()' call
11181
11182 (inputType === "mouse" ? ["mouseout"] : ["touchend"]).forEach(function (eventName) {
11183 $$.dispatchEvent(eventName, index);
11184 });
11185 } // reset last touch point index
11186
11187
11188 inputType === "touch" && $$.callOverOutForTouch();
11189 $$.hideTooltip(!0);
11190 $$.hideGridFocus();
11191 $$.unexpandCircles == null ? void 0 : $$.unexpandCircles();
11192 $$.expandBarTypeShapes(!1);
11193 }
11194};
11195/* harmony default export */ var api_tooltip = ({
11196 tooltip: tooltip_tooltip
11197});
11198;// CONCATENATED MODULE: ./src/Chart/Chart.ts
11199/**
11200 * Copyright (c) 2017 ~ present NAVER Corp.
11201 * billboard.js project is licensed under the MIT license
11202 */
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215/**
11216 * Main chart class.
11217 * - Note: Instantiated via `bb.generate()`.
11218 * @class Chart
11219 * @example
11220 * var chart = bb.generate({
11221 * data: {
11222 * columns: [
11223 * ["x", "2015-11-02", "2015-12-01", "2016-01-01", "2016-02-01", "2016-03-01"],
11224 * ["count1", 11, 8, 7, 6, 5 ],
11225 * ["count2", 9, 3, 6, 2, 8 ]
11226 * ]}
11227 * }
11228 * @see {@link bb.generate} for the initialization.
11229 */
11230
11231/**
11232 * Access instance's primary node elements
11233 * @member {object} $
11234 * @property {object} $ Access instance's primary node elements
11235 * @property {d3.selection} $.chart Wrapper element
11236 * @property {d3.selection} $.svg Main svg element
11237 * @property {d3.selection} $.defs Definition element
11238 * @property {d3.selection} $.main Main grouping element
11239 * @property {d3.selection} $.tooltip Tooltip element
11240 * @property {d3.selection} $.legend Legend element
11241 * @property {d3.selection} $.title Title element
11242 * @property {d3.selection} $.grid Grid element
11243 * @property {d3.selection} $.arc Arc element
11244 * @property {d3.selection} $.circles Data point circle elements
11245 * @property {object} $.bar Bar element object
11246 * @property {d3.selection} $.bar.bars Bar elements
11247 * @property {d3.selection} $.candlestick Candlestick elements
11248 * @property {object} $.line Line element object
11249 * @property {d3.selection} $.line.lines Line elements
11250 * @property {d3.selection} $.line.areas Areas elements
11251 * @property {object} $.text Text element object
11252 * @property {d3.selection} $.text.texts Data label text elements
11253 * @memberof Chart
11254 * @example
11255 * var chart = bb.generate({ ... });
11256 *
11257 * chart.$.chart; // wrapper element
11258 * chart.$.line.circles; // all data point circle elements
11259 */
11260
11261/**
11262 * Plugin instance array
11263 * @member {Array} plugins
11264 * @memberof Chart
11265 * @example
11266 * var chart = bb.generate({
11267 * ...
11268 * plugins: [
11269 * new bb.plugin.stanford({ ... }),
11270 * new PluginA()
11271 * ]
11272 * });
11273 *
11274 * chart.plugins; // [Stanford, PluginA] - instance array
11275 */
11276
11277var Chart = function Chart(options) {
11278 this.plugins = [];
11279 this.internal = void 0;
11280 var $$ = new ChartInternal(this);
11281 this.internal = $$; // bind to namespaced APIs
11282
11283 (function bindThis(fn, target, argThis) {
11284 Object.keys(fn).forEach(function (key) {
11285 var isFunc = isFunction(fn[key]),
11286 isChild = target !== argThis,
11287 isNotNil = notEmpty(fn[key]),
11288 hasChild = isNotNil && Object.keys(fn[key]).length > 0;
11289
11290 if (isFunc && (!isChild && hasChild || isChild)) {
11291 target[key] = fn[key].bind(argThis);
11292 } else if (isNotNil && !isFunc) {
11293 target[key] = {};
11294 } else {
11295 target[key] = fn[key];
11296 }
11297
11298 hasChild && bindThis(fn[key], target[key], argThis);
11299 });
11300 })(Chart.prototype, this, this);
11301
11302 loadConfig.call($$, options);
11303 $$.beforeInit();
11304 $$.init();
11305}; // extend common APIs as part of Chart class
11306
11307
11308
11309extend(Chart.prototype, [chart, api_color, api_data, api_export, api_focus, api_legend, api_load, show, api_tooltip]);
11310;// CONCATENATED MODULE: ./src/Chart/api/axis.ts
11311/**
11312 * Copyright (c) 2017 ~ present NAVER Corp.
11313 * billboard.js project is licensed under the MIT license
11314 */
11315
11316/**
11317 * Set the min/max value
11318 * @param {Chart} $$ Chart instance
11319 * @param {string} type Set type 'min' or 'max'
11320 * @param {object} value Value to be set
11321 * @private
11322 */
11323
11324function setMinMax($$, type, value) {
11325 var config = $$.config,
11326 axisY = "axis_y_" + type,
11327 axisY2 = "axis_y2_" + type;
11328
11329 if (isDefined(value)) {
11330 if (isObjectType(value)) {
11331 isValue(value.x) && (config["axis_x_" + type] = value.x);
11332 isValue(value.y) && (config[axisY] = value.y);
11333 isValue(value.y2) && (config[axisY2] = value.y2);
11334 } else {
11335 config[axisY] = value;
11336 config[axisY2] = value;
11337 }
11338
11339 $$.redraw({
11340 withUpdateOrgXDomain: !0,
11341 withUpdateXDomain: !0
11342 });
11343 }
11344}
11345/**
11346 * Get the min/max value
11347 * @param {Chart} $$ Chart instance
11348 * @param {string} type Set type 'min' or 'max'
11349 * @returns {{x, y, y2}}
11350 * @private
11351 */
11352
11353
11354function axis_getMinMax($$, type) {
11355 var config = $$.config;
11356 return {
11357 x: config["axis_x_" + type],
11358 y: config["axis_y_" + type],
11359 y2: config["axis_y2_" + type]
11360 };
11361}
11362/**
11363 * Define axis
11364 * @ignore
11365 */
11366
11367
11368var axis = {
11369 /**
11370 * Get and set axis labels.
11371 * @function axis․labels
11372 * @instance
11373 * @memberof Chart
11374 * @param {object} labels specified axis' label to be updated.
11375 * @param {string} [labels.x] x Axis string
11376 * @param {string} [labels.y] y Axis string
11377 * @param {string} [labels.y2] y2 Axis string
11378 * @returns {object|undefined} axis labels text object
11379 * @example
11380 * // Update axis' label
11381 * chart.axis.labels({
11382 * x: "New X Axis Label",
11383 * y: "New Y Axis Label",
11384 * y2: "New Y2 Axis Label"
11385 * });
11386 *
11387 * chart.axis.labels();
11388 * // --> {
11389 * // x: "New X Axis Label",
11390 * // y: "New Y Axis Label",
11391 * // y2: "New Y2 Axis Label"
11392 * // }
11393 */
11394 labels: function labels(_labels) {
11395 var $$ = this.internal,
11396 labelText;
11397
11398 if (_labels) {
11399 Object.keys(_labels).forEach(function (axisId) {
11400 $$.axis.setLabelText(axisId, _labels[axisId]);
11401 });
11402 $$.axis.updateLabels();
11403 }
11404
11405 ["x", "y", "y2"].forEach(function (v) {
11406 var text = $$.axis.getLabelText(v);
11407
11408 if (text) {
11409 labelText || (labelText = {});
11410 labelText[v] = text;
11411 }
11412 });
11413 return labelText;
11414 },
11415
11416 /**
11417 * Get and set axis min value.
11418 * @function axis․min
11419 * @instance
11420 * @memberof Chart
11421 * @param {object} min If min is given, specified axis' min value will be updated.<br>
11422 * If no argument is given, the min values set on generating option for each axis will be returned.
11423 * If not set any min values on generation, it will return `undefined`.
11424 * @returns {object|undefined}
11425 * @example
11426 * // Update axis' min
11427 * chart.axis.min({
11428 * x: -10,
11429 * y: 1000,
11430 * y2: 100
11431 * });
11432 */
11433 min: function min(_min) {
11434 var $$ = this.internal;
11435 return isValue(_min) ? setMinMax($$, "min", _min) : axis_getMinMax($$, "min");
11436 },
11437
11438 /**
11439 * Get and set axis max value.
11440 * @function axis․max
11441 * @instance
11442 * @memberof Chart
11443 * @param {object} max If max is given, specified axis' max value will be updated.<br>
11444 * If no argument is given, the max values set on generating option for each axis will be returned.
11445 * If not set any max values on generation, it will return `undefined`.
11446 * @returns {object|undefined}
11447 * @example
11448 * // Update axis' label
11449 * chart.axis.max({
11450 * x: 100,
11451 * y: 1000,
11452 * y2: 10000
11453 * });
11454 */
11455 max: function max(_max) {
11456 var $$ = this.internal;
11457 return arguments.length ? setMinMax($$, "max", _max) : axis_getMinMax($$, "max");
11458 },
11459
11460 /**
11461 * Get and set axis min and max value.
11462 * @function axis․range
11463 * @instance
11464 * @memberof Chart
11465 * @param {object} range If range is given, specified axis' min and max value will be updated. If no argument is given, the current min and max values for each axis will be returned.
11466 * @returns {object|undefined}
11467 * @example
11468 * // Update axis' label
11469 * chart.axis.range({
11470 * min: {
11471 * x: -10,
11472 * y: -1000,
11473 * y2: -10000
11474 * },
11475 * max: {
11476 * x: 100,
11477 * y: 1000,
11478 * y2: 10000
11479 * },
11480 * });
11481 */
11482 range: function range(_range) {
11483 var axis = this.axis;
11484
11485 if (arguments.length) {
11486 isDefined(_range.max) && axis.max(_range.max);
11487 isDefined(_range.min) && axis.min(_range.min);
11488 } else {
11489 return {
11490 max: axis.max(),
11491 min: axis.min()
11492 };
11493 }
11494
11495 return undefined;
11496 }
11497};
11498/* harmony default export */ var api_axis = ({
11499 axis: axis
11500});
11501;// CONCATENATED MODULE: ./src/Chart/api/category.ts
11502/**
11503 * Copyright (c) 2017 ~ present NAVER Corp.
11504 * billboard.js project is licensed under the MIT license
11505 */
11506/* harmony default export */ var api_category = ({
11507 /**
11508 * Set specified category name on category axis.
11509 * @function category
11510 * @instance
11511 * @memberof Chart
11512 * @param {number} i index of category to be changed
11513 * @param {string} category category value to be changed
11514 * @returns {string}
11515 * @example
11516 * chart.category(2, "Category 3");
11517 */
11518 category: function category(i, _category) {
11519 var $$ = this.internal,
11520 config = $$.config;
11521
11522 if (arguments.length > 1) {
11523 config.axis_x_categories[i] = _category;
11524 $$.redraw();
11525 }
11526
11527 return config.axis_x_categories[i];
11528 },
11529
11530 /**
11531 * Set category names on category axis.
11532 * @function categories
11533 * @instance
11534 * @memberof Chart
11535 * @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.
11536 * @returns {Array}
11537 * @example
11538 * chart.categories([
11539 * "Category 1", "Category 2", ...
11540 * ]);
11541 */
11542 categories: function categories(_categories) {
11543 var $$ = this.internal,
11544 config = $$.config;
11545
11546 if (!arguments.length) {
11547 return config.axis_x_categories;
11548 }
11549
11550 config.axis_x_categories = _categories;
11551 $$.redraw();
11552 return config.axis_x_categories;
11553 }
11554});
11555;// CONCATENATED MODULE: ./src/Chart/api/grid.x.ts
11556/**
11557 * Copyright (c) 2017 ~ present NAVER Corp.
11558 * billboard.js project is licensed under the MIT license
11559 */
11560
11561
11562/**
11563 * Update x grid lines.
11564 * @function xgrids
11565 * @instance
11566 * @memberof Chart
11567 * @param {Array} grids X grid lines will be replaced with this argument. The format of this argument is the same as grid.x.lines.
11568 * @returns {object}
11569 * @example
11570 * // Show 2 x grid lines
11571 * chart.xgrids([
11572 * {value: 1, text: "Label 1"},
11573 * {value: 4, text: "Label 4"}
11574 * ]);
11575 * // --> Returns: [{value: 1, text: "Label 1"}, {value: 4, text: "Label 4"}]
11576 */
11577function xgrids(grids) {
11578 var $$ = this.internal,
11579 config = $$.config;
11580
11581 if (!grids) {
11582 return config.grid_x_lines;
11583 }
11584
11585 config.grid_x_lines = grids;
11586 $$.redrawWithoutRescale();
11587 return config.grid_x_lines;
11588}
11589
11590extend(xgrids, {
11591 /**
11592 * Add x grid lines.<br>
11593 * This API adds new x grid lines instead of replacing like xgrids.
11594 * @function xgrids․add
11595 * @instance
11596 * @memberof Chart
11597 * @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.
11598 * @returns {object}
11599 * @example
11600 * // Add a new x grid line
11601 * chart.xgrids.add(
11602 * {value: 4, text: "Label 4"}
11603 * );
11604 *
11605 * // Add new x grid lines
11606 * chart.xgrids.add([
11607 * {value: 2, text: "Label 2"},
11608 * {value: 4, text: "Label 4"}
11609 * ]);
11610 */
11611 add: function add(grids) {
11612 return this.xgrids(this.internal.config.grid_x_lines.concat(grids || []));
11613 },
11614
11615 /**
11616 * Remove x grid lines.<br>
11617 * This API removes x grid lines.
11618 * @function xgrids․remove
11619 * @instance
11620 * @memberof Chart
11621 * @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.
11622 * @example
11623 * // x grid line on x = 2 will be removed
11624 * chart.xgrids.remove({value: 2});
11625 *
11626 * // x grid lines that have 'grid-A' will be removed
11627 * chart.xgrids.remove({
11628 * class: "grid-A"
11629 * });
11630 *
11631 * // all of x grid lines will be removed
11632 * chart.xgrids.remove();
11633 */
11634 remove: function remove(params) {
11635 // TODO: multiple
11636 this.internal.removeGridLines(params, !0);
11637 }
11638});
11639/* harmony default export */ var grid_x = ({
11640 xgrids: xgrids
11641});
11642;// CONCATENATED MODULE: ./src/Chart/api/grid.y.ts
11643/**
11644 * Copyright (c) 2017 ~ present NAVER Corp.
11645 * billboard.js project is licensed under the MIT license
11646 */
11647
11648/**
11649 * Update y grid lines.
11650 * @function ygrids
11651 * @instance
11652 * @memberof Chart
11653 * @param {Array} grids Y grid lines will be replaced with this argument. The format of this argument is the same as grid.y.lines.
11654 * @returns {object}
11655 * @example
11656 * // Show 2 y grid lines
11657 * chart.ygrids([
11658 * {value: 100, text: "Label 1"},
11659 * {value: 400, text: "Label 4"}
11660 * ]);
11661 * // --> Returns: [{value: 100, text: "Label 1"}, {value: 400, text: "Label 4"}]
11662 */
11663
11664function ygrids(grids) {
11665 var $$ = this.internal,
11666 config = $$.config;
11667
11668 if (!grids) {
11669 return config.grid_y_lines;
11670 }
11671
11672 config.grid_y_lines = grids;
11673 $$.redrawWithoutRescale();
11674 return config.grid_y_lines;
11675}
11676
11677extend(ygrids, {
11678 /**
11679 * Add y grid lines.<br>
11680 * This API adds new y grid lines instead of replacing like ygrids.
11681 * @function ygrids․add
11682 * @instance
11683 * @memberof Chart
11684 * @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.
11685 * @returns {object}
11686 * @example
11687 * // Add a new x grid line
11688 * chart.ygrids.add(
11689 * {value: 400, text: "Label 4"}
11690 * );
11691 *
11692 * // Add new x grid lines
11693 * chart.ygrids.add([
11694 * {value: 200, text: "Label 2"},
11695 * {value: 400, text: "Label 4"}
11696 * ]);
11697 */
11698 add: function add(grids) {
11699 return this.ygrids(this.internal.config.grid_y_lines.concat(grids || []));
11700 },
11701
11702 /**
11703 * Remove y grid lines.<br>
11704 * This API removes x grid lines.
11705 * @function ygrids․remove
11706 * @instance
11707 * @memberof Chart
11708 * @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.
11709 * @param {number} [params.value] target value
11710 * @param {string} [params.class] target class
11711 * @example
11712 * // y grid line on y = 200 will be removed
11713 * chart.ygrids.remove({value: 200});
11714 *
11715 * // y grid lines that have 'grid-A' will be removed
11716 * chart.ygrids.remove({
11717 * class: "grid-A"
11718 * });
11719 *
11720 * // all of y grid lines will be removed
11721 * chart.ygrids.remove();
11722 */
11723 remove: function remove(params) {
11724 // TODO: multiple
11725 this.internal.removeGridLines(params, !1);
11726 }
11727});
11728/* harmony default export */ var grid_y = ({
11729 ygrids: ygrids
11730});
11731;// CONCATENATED MODULE: ./src/Chart/api/group.ts
11732/**
11733 * Copyright (c) 2017 ~ present NAVER Corp.
11734 * billboard.js project is licensed under the MIT license
11735 */
11736
11737/* harmony default export */ var group = ({
11738 /**
11739 * Update groups for the targets.
11740 * @function groups
11741 * @instance
11742 * @memberof Chart
11743 * @param {Array} groups This argument needs to be an Array that includes one or more Array that includes target ids to be grouped.
11744 * @returns {Array} Grouped data names array
11745 * @example
11746 * // data1 and data2 will be a new group.
11747 * chart.groups([
11748 * ["data1", "data2"]
11749 * ]);
11750 */
11751 groups: function groups(_groups) {
11752 var $$ = this.internal,
11753 config = $$.config;
11754
11755 if (isUndefined(_groups)) {
11756 return config.data_groups;
11757 }
11758
11759 config.data_groups = _groups;
11760 $$.redraw();
11761 return config.data_groups;
11762 }
11763});
11764;// CONCATENATED MODULE: ./src/Chart/api/regions.ts
11765/**
11766 * Copyright (c) 2017 ~ present NAVER Corp.
11767 * billboard.js project is licensed under the MIT license
11768 */
11769
11770
11771
11772/**
11773 * Update regions.
11774 * @function regions
11775 * @instance
11776 * @memberof Chart
11777 * @param {Array} regions Regions will be replaced with this argument. The format of this argument is the same as regions.
11778 * @returns {Array} regions
11779 * @example
11780 * // Show 2 regions
11781 * chart.regions([
11782 * {axis: "x", start: 5, class: "regionX"},
11783 * {axis: "y", end: 50, class: "regionY"}
11784 * ]);
11785 */
11786function regions(regions) {
11787 var $$ = this.internal,
11788 config = $$.config;
11789
11790 if (!regions) {
11791 return config.regions;
11792 }
11793
11794 config.regions = regions;
11795 $$.redrawWithoutRescale();
11796 return regions;
11797}
11798
11799extend(regions, {
11800 /**
11801 * Add new region.<br><br>
11802 * This API adds new region instead of replacing like regions.
11803 * @function regions․add
11804 * @instance
11805 * @memberof Chart
11806 * @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.
11807 * @returns {Array} regions
11808 * @example
11809 * // Add a new region
11810 * chart.regions.add(
11811 * {axis: "x", start: 5, class: "regionX"}
11812 * );
11813 *
11814 * // Add new regions
11815 * chart.regions.add([
11816 * {axis: "x", start: 5, class: "regionX"},
11817 * {axis: "y", end: 50, class: "regionY"}
11818 *]);
11819 */
11820 add: function add(regions) {
11821 var $$ = this.internal,
11822 config = $$.config;
11823
11824 if (!regions) {
11825 return config.regions;
11826 }
11827
11828 config.regions = config.regions.concat(regions);
11829 $$.redrawWithoutRescale();
11830 return config.regions;
11831 },
11832
11833 /**
11834 * Remove regions.<br><br>
11835 * This API removes regions.
11836 * @function regions․remove
11837 * @instance
11838 * @memberof Chart
11839 * @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.
11840 * @returns {Array} regions Removed regions
11841 * @example
11842 * // regions that have 'region-A' or 'region-B' will be removed.
11843 * chart.regions.remove({
11844 * classes: [
11845 * "region-A", "region-B"
11846 * ]
11847 * });
11848 *
11849 * // all of regions will be removed.
11850 * chart.regions.remove();
11851 */
11852 remove: function remove(optionsValue) {
11853 var $$ = this.internal,
11854 config = $$.config,
11855 $T = $$.$T,
11856 options = optionsValue || {},
11857 classes = getOption(options, "classes", [config_classes.region]),
11858 regions = $$.$el.main.select("." + config_classes.regions).selectAll(classes.map(function (c) {
11859 return "." + c;
11860 }));
11861 $T(regions).style("opacity", "0").remove();
11862 regions = config.regions;
11863
11864 if (Object.keys(options).length) {
11865 regions = regions.filter(function (region) {
11866 var found = !1;
11867
11868 if (!region.class) {
11869 return !0;
11870 }
11871
11872 region.class.split(" ").forEach(function (c) {
11873 if (classes.indexOf(c) >= 0) {
11874 found = !0;
11875 }
11876 });
11877 return !found;
11878 });
11879 config.regions = regions;
11880 } else {
11881 config.regions = [];
11882 }
11883
11884 return regions;
11885 }
11886});
11887/* harmony default export */ var api_regions = ({
11888 regions: regions
11889});
11890;// CONCATENATED MODULE: ./src/Chart/api/x.ts
11891/**
11892 * Copyright (c) 2017 ~ present NAVER Corp.
11893 * billboard.js project is licensed under the MIT license
11894 */
11895
11896/* harmony default export */ var x = ({
11897 /**
11898 * Get and set x values for the chart.
11899 * @function x
11900 * @instance
11901 * @memberof Chart
11902 * @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.
11903 * @returns {object} xs
11904 * @example
11905 * // Get current x values
11906 * chart.x();
11907 *
11908 * // Update x values for all targets
11909 * chart.x([100, 200, 300, 400, ...]);
11910 */
11911 x: function x(_x) {
11912 var $$ = this.internal,
11913 axis = $$.axis,
11914 data = $$.data,
11915 isCategorized = axis.isCustomX() && axis.isCategorized();
11916
11917 if (isArray(_x)) {
11918 if (isCategorized) {
11919 this.categories(_x);
11920 } else {
11921 $$.updateTargetX(data.targets, _x);
11922 $$.redraw({
11923 withUpdateOrgXDomain: !0,
11924 withUpdateXDomain: !0
11925 });
11926 }
11927 }
11928
11929 return isCategorized ? this.categories() : data.xs;
11930 },
11931
11932 /**
11933 * Get and set x values for the chart.
11934 * @function xs
11935 * @instance
11936 * @memberof Chart
11937 * @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.
11938 * @returns {object} xs
11939 * @example
11940 * // Get current x values
11941 * chart.xs();
11942 *
11943 * // Update x values for all targets
11944 * chart.xs({
11945 * data1: [10, 20, 30, 40, ...],
11946 * data2: [100, 200, 300, 400, ...]
11947 * });
11948 */
11949 xs: function xs(_xs) {
11950 var $$ = this.internal;
11951
11952 if (isObject(_xs)) {
11953 $$.updateTargetXs($$.data.targets, _xs);
11954 $$.redraw({
11955 withUpdateOrgXDomain: !0,
11956 withUpdateXDomain: !0
11957 });
11958 }
11959
11960 return $$.data.xs;
11961 }
11962});
11963;// CONCATENATED MODULE: ./src/Chart/api/flow.ts
11964/**
11965 * Copyright (c) 2017 ~ present NAVER Corp.
11966 * billboard.js project is licensed under the MIT license
11967 */
11968
11969/* harmony default export */ var flow = ({
11970 /**
11971 * Flow data to the chart.<br><br>
11972 * By this API, you can append new data points to the chart.
11973 * @function flow
11974 * @instance
11975 * @memberof Chart
11976 * @param {object} args The object can consist with following members:<br>
11977 *
11978 * | Key | Type | Description |
11979 * | --- | --- | --- |
11980 * | json | Object | Data as JSON format (@see [data․json](Options.html#.data%25E2%2580%25A4json)) |
11981 * | rows | Array | Data in array as row format (@see [data․rows](Options.html#.data%25E2%2580%25A4json)) |
11982 * | columns | Array | Data in array as column format (@see [data․columns](Options.html#.data%25E2%2580%25A4columns)) |
11983 * | 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 |
11984 * | length | Number | The lower x edge will move by the number of this argument |
11985 * | duration | Number | The duration of the transition will be specified value. If not given, transition.duration will be used as default |
11986 * | done | Function | The specified function will be called when flow ends |
11987 *
11988 * - **NOTE:**
11989 * - If json, rows and columns given, the data will be loaded.
11990 * - If data that has the same target id is given, the chart will be appended.
11991 * - Otherwise, new target will be added. One of these is required when calling.
11992 * - If json specified, keys is required as well as data.json.
11993 * - If tab isn't visible(by evaluating `document.hidden`), will not be executed to prevent unnecessary work.
11994 * @example
11995 * // 2 data points will be apprended to the tail and popped from the head.
11996 * // After that, 4 data points will be appended and no data points will be poppoed.
11997 * chart.flow({
11998 * columns: [
11999 * ["x", "2018-01-11", "2018-01-21"],
12000 * ["data1", 500, 200],
12001 * ["data2", 100, 300],
12002 * ["data3", 200, 120]
12003 * ],
12004 * to: "2013-01-11",
12005 * done: function () {
12006 * chart.flow({
12007 * columns: [
12008 * ["x", "2018-02-11", "2018-02-12", "2018-02-13", "2018-02-14"],
12009 * ["data1", 200, 300, 100, 250],
12010 * ["data2", 100, 90, 40, 120],
12011 * ["data3", 100, 100, 300, 500]
12012 * ],
12013 * length: 2,
12014 * duration: 1500
12015 * });
12016 * }
12017 * });
12018 */
12019 flow: function flow(args) {
12020 var $$ = this.internal,
12021 data,
12022 domain,
12023 length = 0,
12024 tail = 0,
12025 diff,
12026 to;
12027
12028 if (args.json || args.rows || args.columns) {
12029 data = $$.convertData(args);
12030 }
12031
12032 if ($$.state.redrawing || !data || !isTabVisible()) {
12033 return;
12034 }
12035
12036 var notfoundIds = [],
12037 orgDataCount = $$.getMaxDataCount(),
12038 targets = $$.convertDataToTargets(data, !0),
12039 isTimeSeries = $$.axis.isTimeSeries();
12040 // Update/Add data
12041 $$.data.targets.forEach(function (t) {
12042 var found = !1;
12043
12044 for (var i = 0; i < targets.length; i++) {
12045 if (t.id === targets[i].id) {
12046 found = !0;
12047
12048 if (t.values[t.values.length - 1]) {
12049 tail = t.values[t.values.length - 1].index + 1;
12050 }
12051
12052 length = targets[i].values.length;
12053
12054 for (var j = 0; j < length; j++) {
12055 targets[i].values[j].index = tail + j;
12056
12057 if (!isTimeSeries) {
12058 targets[i].values[j].x = tail + j;
12059 }
12060 }
12061
12062 t.values = t.values.concat(targets[i].values);
12063 targets.splice(i, 1);
12064 break;
12065 }
12066 }
12067
12068 found || notfoundIds.push(t.id);
12069 }); // Append null for not found targets
12070
12071 $$.data.targets.forEach(function (t) {
12072 for (var i = 0; i < notfoundIds.length; i++) {
12073 if (t.id === notfoundIds[i]) {
12074 tail = t.values[t.values.length - 1].index + 1;
12075
12076 for (var j = 0; j < length; j++) {
12077 t.values.push({
12078 id: t.id,
12079 index: tail + j,
12080 x: isTimeSeries ? $$.getOtherTargetX(tail + j) : tail + j,
12081 value: null
12082 });
12083 }
12084 }
12085 }
12086 }); // Generate null values for new target
12087
12088 if ($$.data.targets.length) {
12089 targets.forEach(function (t) {
12090 var missing = [];
12091
12092 for (var i = $$.data.targets[0].values[0].index; i < tail; i++) {
12093 missing.push({
12094 id: t.id,
12095 index: i,
12096 x: isTimeSeries ? $$.getOtherTargetX(i) : i,
12097 value: null
12098 });
12099 }
12100
12101 t.values.forEach(function (v) {
12102 v.index += tail;
12103
12104 if (!isTimeSeries) {
12105 v.x += tail;
12106 }
12107 });
12108 t.values = missing.concat(t.values);
12109 });
12110 }
12111
12112 $$.data.targets = $$.data.targets.concat(targets); // add remained
12113 // check data count because behavior needs to change when it"s only one
12114 // const dataCount = $$.getMaxDataCount();
12115
12116 var baseTarget = $$.data.targets[0],
12117 baseValue = baseTarget.values[0];
12118
12119 // Update length to flow if needed
12120 if (isDefined(args.to)) {
12121 length = 0;
12122 to = isTimeSeries ? parseDate.call($$, args.to) : args.to;
12123 baseTarget.values.forEach(function (v) {
12124 v.x < to && length++;
12125 });
12126 } else if (isDefined(args.length)) {
12127 length = args.length;
12128 } // If only one data, update the domain to flow from left edge of the chart
12129
12130
12131 if (!orgDataCount) {
12132 if (isTimeSeries) {
12133 diff = baseTarget.values.length > 1 ? baseTarget.values[baseTarget.values.length - 1].x - baseValue.x : baseValue.x - $$.getXDomain($$.data.targets)[0];
12134 } else {
12135 diff = 1;
12136 }
12137
12138 domain = [baseValue.x - diff, baseValue.x];
12139 } else if (orgDataCount === 1 && isTimeSeries) {
12140 diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2;
12141 domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)];
12142 }
12143
12144 domain && $$.updateXDomain(null, !0, !0, !1, domain); // Set targets
12145
12146 $$.updateTargets($$.data.targets); // Redraw with new targets
12147
12148 $$.redraw({
12149 flow: {
12150 index: baseValue.index,
12151 length: length,
12152 duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
12153 done: args.done,
12154 orgDataCount: orgDataCount
12155 },
12156 withLegend: !0,
12157 withTransition: orgDataCount > 1,
12158 withTrimXDomain: !1,
12159 withUpdateXAxis: !0
12160 });
12161 }
12162});
12163// EXTERNAL MODULE: external {"commonjs":"d3-axis","commonjs2":"d3-axis","amd":"d3-axis","root":"d3"}
12164var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack_require__(10);
12165;// CONCATENATED MODULE: ./src/ChartInternal/Axis/AxisRendererHelper.ts
12166/**
12167 * Copyright (c) 2017 ~ present NAVER Corp.
12168 * billboard.js project is licensed under the MIT license
12169 * @ignore
12170 */
12171
12172
12173
12174var AxisRendererHelper = /*#__PURE__*/function () {
12175 function AxisRendererHelper(owner) {
12176 this.owner = void 0;
12177 this.config = void 0;
12178 this.scale = void 0;
12179 var scale = getScale(),
12180 config = owner.config,
12181 params = owner.params;
12182 this.owner = owner;
12183 this.config = config;
12184 this.scale = scale;
12185
12186 if (config.noTransition || !params.config.transition_duration) {
12187 config.withoutTransition = !0;
12188 } // set range
12189
12190
12191 config.range = this.scaleExtent((params.orgXScale || scale).range());
12192 }
12193 /**
12194 * Compute a character dimension
12195 * @param {d3.selection} node <g class=tick> node
12196 * @returns {{w: number, h: number}}
12197 * @private
12198 */
12199
12200
12201 AxisRendererHelper.getSizeFor1Char = function getSizeFor1Char(node) {
12202 // default size for one character
12203 var size = {
12204 w: 5.5,
12205 h: 11.5
12206 };
12207 node.empty() || node.select("text").text("0").call(function (el) {
12208 try {
12209 var _el$node$getBBox = el.node().getBBox(),
12210 width = _el$node$getBBox.width,
12211 height = _el$node$getBBox.height;
12212
12213 if (width && height) {
12214 size.w = width;
12215 size.h = height;
12216 }
12217 } catch (e) {} finally {
12218 el.text("");
12219 }
12220 });
12221
12222 this.getSizeFor1Char = function () {
12223 return size;
12224 };
12225
12226 return size;
12227 }
12228 /**
12229 * Get tick transform setter function
12230 * @param {string} id Axis id
12231 * @returns {Function} transfrom setter function
12232 * @private
12233 */
12234 ;
12235
12236 var _proto = AxisRendererHelper.prototype;
12237
12238 _proto.getTickTransformSetter = function getTickTransformSetter(id) {
12239 var config = this.config,
12240 fn = id === "x" ? function (value) {
12241 return "translate(" + (value + config.tickOffset) + ",0)";
12242 } : function (value) {
12243 return "translate(0," + value + ")";
12244 };
12245 return function (selection, scale) {
12246 selection.attr("transform", function (d) {
12247 return fn(Math.ceil(scale(d)));
12248 });
12249 };
12250 };
12251
12252 _proto.scaleExtent = function scaleExtent(domain) {
12253 var start = domain[0],
12254 stop = domain[domain.length - 1];
12255 return start < stop ? [start, stop] : [stop, start];
12256 };
12257
12258 _proto.generateTicks = function generateTicks(scale, isYAxes) {
12259 var tickStepSize = this.owner.params.tickStepSize,
12260 _scale$domain = scale.domain(),
12261 start = _scale$domain[0],
12262 end = _scale$domain[1],
12263 ticks = [];
12264
12265 // When 'axis[y|y2].tick.stepSize' option is set
12266 if (isYAxes && tickStepSize) {
12267 var interval = Math.round(start);
12268
12269 while (interval <= end) {
12270 ticks.push(interval);
12271 interval += tickStepSize;
12272 }
12273 } else if (scale.ticks) {
12274 var tickArguments = this.config.tickArguments; // adjust excessive tick count show
12275
12276 if (scale.type === "log" && !tickArguments) {
12277 // nicer symlog ticks didn't implemented yet: https://github.com/d3/d3-scale/issues/162
12278 // get ticks values from logScale
12279 var s = getScale("_log").domain([start > 0 ? start : 1, end]).range(scale.range());
12280 ticks = s.ticks();
12281
12282 for (var cnt = end.toFixed().length; ticks.length > 15; cnt--) {
12283 ticks = s.ticks(cnt);
12284 }
12285
12286 ticks.splice(0, 1, start);
12287 ticks.splice(ticks.length - 1, 1, end);
12288 } else {
12289 ticks = scale.ticks.apply(scale, this.config.tickArguments || []);
12290 }
12291
12292 ticks = ticks.map(function (v) {
12293 // round the tick value if is number
12294 var r = isString(v) && isNumber(v) && !isNaN(v) && Math.round(v * 10) / 10 || v;
12295 return r;
12296 });
12297 } else {
12298 for (var i = Math.ceil(start); i < end; i++) {
12299 ticks.push(i);
12300 }
12301
12302 if (ticks.length > 0 && ticks[0] > 0) {
12303 ticks.unshift(ticks[0] - (ticks[1] - ticks[0]));
12304 }
12305 }
12306
12307 return ticks;
12308 };
12309
12310 _proto.copyScale = function copyScale() {
12311 var newScale = this.scale.copy();
12312
12313 if (!newScale.domain().length) {
12314 newScale.domain(this.scale.domain());
12315 }
12316
12317 newScale.type = this.scale.type;
12318 return newScale;
12319 };
12320
12321 _proto.textFormatted = function textFormatted(v) {
12322 var tickFormat = this.config.tickFormat,
12323 value = /\d+\.\d+0{5,}\d$/.test(v) ? +(v + "").replace(/0+\d$/, "") : v,
12324 formatted = tickFormat ? tickFormat(value) : value; // to round float numbers from 'binary floating point'
12325 // https://en.wikipedia.org/wiki/Double-precision_floating-point_format
12326 // https://stackoverflow.com/questions/17849101/laymans-explanation-for-why-javascript-has-weird-floating-math-ieee-754-stand
12327
12328 return isDefined(formatted) ? formatted : "";
12329 };
12330
12331 _proto.transitionise = function transitionise(selection) {
12332 var config = this.config,
12333 transitionSelection = selection;
12334
12335 if (config.withoutTransition) {
12336 transitionSelection = selection.interrupt();
12337 } else if (config.transition || !this.owner.params.noTransition) {
12338 // prevent for 'transition not found' case
12339 // https://github.com/naver/billboard.js/issues/2140
12340 try {
12341 transitionSelection = selection.transition(config.transition);
12342 } catch (e) {}
12343 }
12344
12345 return transitionSelection;
12346 };
12347
12348 return AxisRendererHelper;
12349}();
12350
12351
12352;// CONCATENATED MODULE: ./src/ChartInternal/Axis/AxisRenderer.ts
12353/**
12354 * Copyright (c) 2017 ~ present NAVER Corp.
12355 * billboard.js project is licensed under the MIT license
12356 * @ignore
12357 */
12358
12359
12360
12361
12362var AxisRenderer = /*#__PURE__*/function () {
12363 function AxisRenderer(params) {
12364 if (params === void 0) {
12365 params = {};
12366 }
12367
12368 this.helper = void 0;
12369 this.config = void 0;
12370 this.params = void 0;
12371 this.g = void 0;
12372 var config = {
12373 innerTickSize: 6,
12374 outerTickSize: params.outerTick ? 6 : 0,
12375 orient: "bottom",
12376 range: [],
12377 tickArguments: null,
12378 tickCentered: null,
12379 tickCulling: !0,
12380 tickFormat: null,
12381 tickLength: 9,
12382 tickOffset: 0,
12383 tickPadding: 3,
12384 tickValues: null,
12385 transition: null,
12386 noTransition: params.noTransition
12387 };
12388 config.tickLength = Math.max(config.innerTickSize, 0) + config.tickPadding;
12389 this.config = config;
12390 this.params = params;
12391 this.helper = new AxisRendererHelper(this);
12392 }
12393 /**
12394 * Create axis element
12395 * @param {d3.selection} g Axis selection
12396 * @private
12397 */
12398
12399
12400 var _proto = AxisRenderer.prototype;
12401
12402 _proto.create = function create(g) {
12403 var ctx = this,
12404 config = this.config,
12405 helper = this.helper,
12406 params = this.params,
12407 scale = helper.scale,
12408 orient = config.orient,
12409 splitTickText = this.splitTickText.bind(this),
12410 isLeftRight = /^(left|right)$/.test(orient),
12411 isTopBottom = /^(top|bottom)$/.test(orient),
12412 tickTransform = helper.getTickTransformSetter(isTopBottom ? "x" : "y"),
12413 axisPx = tickTransform === helper.axisX ? "y" : "x",
12414 sign = /^(top|left)$/.test(orient) ? -1 : 1,
12415 rotate = params.tickTextRotate;
12416 this.config.range = scale.rangeExtent ? scale.rangeExtent() : helper.scaleExtent((params.orgXScale || scale).range());
12417 var _config2 = config,
12418 innerTickSize = _config2.innerTickSize,
12419 tickLength = _config2.tickLength,
12420 range = _config2.range,
12421 id = params.id,
12422 tickTextPos = id && /^(x|y|y2)$/.test(id) ? params.config["axis_" + id + "_tick_text_position"] : {
12423 x: 0,
12424 y: 0
12425 },
12426 prefix = id === "subX" ? "subchart_axis_x" : "axis_" + id,
12427 axisShow = params.config[prefix + "_show"],
12428 tickShow = {
12429 tick: axisShow ? params.config[prefix + "_tick_show"] : !1,
12430 text: axisShow ? params.config[prefix + "_tick_text_show"] : !1
12431 },
12432 $g; // // get the axis' tick position configuration
12433
12434 g.each(function () {
12435 var g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
12436 scale0 = this.__chart__ || scale,
12437 scale1 = helper.copyScale();
12438 $g = g;
12439 this.__chart__ = scale1;
12440 config.tickOffset = params.isCategory ? Math.ceil((scale1(1) - scale1(0)) / 2) : 0; // update selection - data join
12441
12442 var path = g.selectAll(".domain").data([0]); // enter + update selection
12443
12444 path.enter().append("path").attr("class", "domain") // https://observablehq.com/@d3/d3-selection-2-0
12445 .merge(path).attr("d", function () {
12446 var outerTickSized = config.outerTickSize * sign;
12447 return isTopBottom ? "M" + range[0] + "," + outerTickSized + "V0H" + range[1] + "V" + outerTickSized : "M" + outerTickSized + "," + range[0] + "H0V" + range[1] + "H" + outerTickSized;
12448 });
12449
12450 if (tickShow.tick || tickShow.text) {
12451 // count of tick data in array
12452 var ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight),
12453 tick = g.selectAll(".tick").data(ticks, scale1),
12454 tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick"),
12455 tickExit = tick.exit().remove(); // update selection
12456
12457 // enter + update selection
12458 tick = tickEnter.merge(tick);
12459 tickShow.tick && tickEnter.append("line");
12460 tickShow.text && tickEnter.append("text");
12461 var sizeFor1Char = AxisRendererHelper.getSizeFor1Char(tick),
12462 counts = [],
12463 tspan = tick.select("text").selectAll("tspan").data(function (d, index) {
12464 var split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
12465 counts[index] = split.length;
12466 return split.map(function (splitted) {
12467 return {
12468 index: index,
12469 splitted: splitted
12470 };
12471 });
12472 });
12473 tspan.exit().remove();
12474 tspan = tspan.enter().append("tspan").merge(tspan).text(function (d) {
12475 return d.splitted;
12476 }); // set <tspan>'s position
12477
12478 tspan.attr("x", isTopBottom ? 0 : tickLength * sign).attr("dx", function () {
12479 var dx = 0;
12480
12481 if (/(top|bottom)/.test(orient) && rotate) {
12482 dx = 8 * Math.sin(Math.PI * (rotate / 180)) * (orient === "top" ? -1 : 1);
12483 }
12484
12485 return dx + (tickTextPos.x || 0);
12486 }()).attr("dy", function (d, i) {
12487 var dy = 0;
12488
12489 if (orient !== "top") {
12490 dy = sizeFor1Char.h;
12491
12492 if (i === 0) {
12493 dy = isLeftRight ? -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3) : tickTextPos.y === 0 ? ".71em" : 0;
12494 }
12495 }
12496
12497 return isNumber(dy) && tickTextPos.y ? dy + tickTextPos.y : dy || ".71em";
12498 });
12499 var lineUpdate = tick.select("line"),
12500 textUpdate = tick.select("text");
12501 tickEnter.select("line").attr(axisPx + "2", innerTickSize * sign);
12502 tickEnter.select("text").attr(axisPx, tickLength * sign);
12503 ctx.setTickLineTextPosition(lineUpdate, textUpdate); // Append <title> for tooltip display
12504
12505 if (params.tickTitle) {
12506 var title = textUpdate.select("title");
12507 (title.empty() ? textUpdate.append("title") : title).text(function (index) {
12508 return params.tickTitle[index];
12509 });
12510 }
12511
12512 if (scale1.bandwidth) {
12513 var x = scale1,
12514 dx = x.bandwidth() / 2;
12515
12516 scale0 = function (d) {
12517 return x(d) + dx;
12518 };
12519
12520 scale1 = scale0;
12521 } else if (scale0.bandwidth) {
12522 scale0 = scale1;
12523 } else {
12524 tickTransform(tickExit, scale1);
12525 } // when .flow(), it should follow flow's transition config
12526 // otherwise make to use ChartInternals.$T()
12527
12528
12529 tick = params.owner.state.flowing ? helper.transitionise(tick) : params.owner.$T(tick);
12530 tickTransform(tickEnter, scale0);
12531 tickTransform(tick.style("opacity", null), scale1);
12532 }
12533 });
12534 this.g = $g;
12535 }
12536 /**
12537 * Get tick x/y coordinate
12538 * @returns {{x: number, y: number}}
12539 * @private
12540 */
12541 ;
12542
12543 _proto.getTickXY = function getTickXY() {
12544 var config = this.config,
12545 pos = {
12546 x: 0,
12547 y: 0
12548 };
12549
12550 if (this.params.isCategory) {
12551 pos.x = config.tickCentered ? 0 : config.tickOffset;
12552 pos.y = config.tickCentered ? config.tickOffset : 0;
12553 }
12554
12555 return pos;
12556 }
12557 /**
12558 * Get tick size
12559 * @param {object} d data object
12560 * @returns {number}
12561 * @private
12562 */
12563 ;
12564
12565 _proto.getTickSize = function getTickSize(d) {
12566 var scale = this.helper.scale,
12567 config = this.config,
12568 _config3 = config,
12569 innerTickSize = _config3.innerTickSize,
12570 range = _config3.range,
12571 tickPosition = scale(d) + (config.tickCentered ? 0 : config.tickOffset);
12572 return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0;
12573 }
12574 /**
12575 * Set tick's line & text position
12576 * @param {d3.selection} lineUpdate Line selection
12577 * @param {d3.selection} textUpdate Text selection
12578 * @private
12579 */
12580 ;
12581
12582 _proto.setTickLineTextPosition = function setTickLineTextPosition(lineUpdate, textUpdate) {
12583 var tickPos = this.getTickXY(),
12584 _this$config = this.config,
12585 innerTickSize = _this$config.innerTickSize,
12586 orient = _this$config.orient,
12587 tickLength = _this$config.tickLength,
12588 tickOffset = _this$config.tickOffset,
12589 rotate = this.params.tickTextRotate,
12590 textAnchorForText = function (r) {
12591 var value = ["start", "end"];
12592 orient === "top" && value.reverse();
12593 return !r ? "middle" : value[r > 0 ? 0 : 1];
12594 },
12595 textTransform = function (r) {
12596 return r ? "rotate(" + r + ")" : null;
12597 },
12598 yForText = function (r) {
12599 var r2 = r / (orient === "bottom" ? 15 : 23);
12600 return r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
12601 };
12602
12603 switch (orient) {
12604 case "bottom":
12605 lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", this.getTickSize.bind(this));
12606 textUpdate.attr("x", 0).attr("y", yForText(rotate)).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
12607 break;
12608
12609 case "top":
12610 lineUpdate.attr("x2", 0).attr("y2", -innerTickSize);
12611 textUpdate.attr("x", 0).attr("y", -yForText(rotate) * 2).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
12612 break;
12613
12614 case "left":
12615 lineUpdate.attr("x2", -innerTickSize).attr("y1", tickPos.y).attr("y2", tickPos.y);
12616 textUpdate.attr("x", -tickLength).attr("y", tickOffset).style("text-anchor", "end");
12617 break;
12618
12619 case "right":
12620 lineUpdate.attr("x2", innerTickSize).attr("y2", 0);
12621 textUpdate.attr("x", tickLength).attr("y", 0).style("text-anchor", "start");
12622 }
12623 } // this should be called only when category axis
12624 ;
12625
12626 _proto.splitTickText = function splitTickText(d, scale, ticks, isLeftRight, charWidth) {
12627 var params = this.params,
12628 tickText = this.helper.textFormatted(d),
12629 splitted = isString(tickText) && tickText.indexOf("\n") > -1 ? tickText.split("\n") : [];
12630
12631 if (splitted.length) {
12632 return splitted;
12633 }
12634
12635 if (isArray(tickText)) {
12636 return tickText;
12637 }
12638
12639 var tickWidth = params.tickWidth;
12640
12641 if (!tickWidth || tickWidth <= 0) {
12642 tickWidth = isLeftRight ? 95 : params.isCategory ? Math.ceil(scale(ticks[1]) - scale(ticks[0])) - 12 : 110;
12643 } // split given text by tick width size
12644 // eslint-disable-next-line
12645
12646
12647 function split(splitted, text) {
12648 var subtext, spaceIndex, textWidth;
12649
12650 for (var i = 1; i < text.length; i++) {
12651 if (text.charAt(i) === " ") {
12652 spaceIndex = i;
12653 }
12654
12655 subtext = text.substr(0, i + 1);
12656 textWidth = charWidth * subtext.length; // if text width gets over tick width, split by space index or current index
12657
12658 if (tickWidth < textWidth) {
12659 return split(splitted.concat(text.substr(0, spaceIndex || i)), text.slice(spaceIndex ? spaceIndex + 1 : i));
12660 }
12661 }
12662
12663 return splitted.concat(text);
12664 }
12665
12666 return split(splitted, tickText + "");
12667 };
12668
12669 _proto.scale = function scale(x) {
12670 if (!arguments.length) {
12671 return this.helper.scale;
12672 }
12673
12674 this.helper.scale = x;
12675 return this;
12676 };
12677
12678 _proto.orient = function orient(x) {
12679 if (!arguments.length) {
12680 return this.config.orient;
12681 }
12682
12683 this.config.orient = x in {
12684 top: 1,
12685 right: 1,
12686 bottom: 1,
12687 left: 1
12688 } ? x + "" : "bottom";
12689 return this;
12690 };
12691
12692 _proto.tickFormat = function tickFormat(format) {
12693 var config = this.config;
12694
12695 if (!arguments.length) {
12696 return config.tickFormat;
12697 }
12698
12699 config.tickFormat = format;
12700 return this;
12701 };
12702
12703 _proto.tickCentered = function tickCentered(isCentered) {
12704 var config = this.config;
12705
12706 if (!arguments.length) {
12707 return config.tickCentered;
12708 }
12709
12710 config.tickCentered = isCentered;
12711 return this;
12712 }
12713 /**
12714 * Return tick's offset value.
12715 * The value will be set for 'category' axis type.
12716 * @returns {number}
12717 * @private
12718 */
12719 ;
12720
12721 _proto.tickOffset = function tickOffset() {
12722 return this.config.tickOffset;
12723 }
12724 /**
12725 * Get tick interval count
12726 * @private
12727 * @param {number} size Total data size
12728 * @returns {number}
12729 */
12730 ;
12731
12732 _proto.tickInterval = function tickInterval(size) {
12733 var _this = this,
12734 _this$config2 = this.config,
12735 outerTickSize = _this$config2.outerTickSize,
12736 tickOffset = _this$config2.tickOffset,
12737 tickValues = _this$config2.tickValues,
12738 interval;
12739
12740 if (this.params.isCategory) {
12741 interval = tickOffset * 2;
12742 } else {
12743 var length = this.g.select("path.domain").node().getTotalLength() - outerTickSize * 2;
12744 interval = length / (size || this.g.selectAll("line").size()); // get the interval by its values
12745
12746 var intervalByValue = tickValues ? tickValues.map(function (v, i, arr) {
12747 var next = i + 1;
12748 return next < arr.length ? _this.helper.scale(arr[next]) - _this.helper.scale(v) : null;
12749 }).filter(Boolean) : [];
12750 interval = Math.min.apply(Math, intervalByValue.concat([interval]));
12751 }
12752
12753 return interval === Infinity ? 0 : interval;
12754 };
12755
12756 _proto.ticks = function ticks() {
12757 for (var config = this.config, _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
12758 args[_key] = arguments[_key];
12759 }
12760
12761 if (!args.length) {
12762 return config.tickArguments;
12763 }
12764
12765 config.tickArguments = toArray(args);
12766 return this;
12767 };
12768
12769 _proto.tickCulling = function tickCulling(culling) {
12770 var config = this.config;
12771
12772 if (!arguments.length) {
12773 return config.tickCulling;
12774 }
12775
12776 config.tickCulling = culling;
12777 return this;
12778 };
12779
12780 _proto.tickValues = function tickValues(x) {
12781 var _this2 = this,
12782 config = this.config;
12783
12784 if (isFunction(x)) {
12785 config.tickValues = function () {
12786 return x(_this2.helper.scale.domain());
12787 };
12788 } else {
12789 if (!arguments.length) {
12790 return config.tickValues;
12791 }
12792
12793 config.tickValues = x;
12794 }
12795
12796 return this;
12797 };
12798
12799 _proto.setTransition = function setTransition(t) {
12800 this.config.transition = t;
12801 return this;
12802 };
12803
12804 return AxisRenderer;
12805}();
12806
12807
12808;// CONCATENATED MODULE: ./src/ChartInternal/Axis/Axis.ts
12809/**
12810 * Copyright (c) 2017 ~ present NAVER Corp.
12811 * billboard.js project is licensed under the MIT license
12812 */
12813
12814
12815
12816
12817
12818/* harmony default export */ var Axis = ({
12819 getAxisInstance: function getAxisInstance() {
12820 return this.axis || new Axis_Axis(this);
12821 }
12822});
12823
12824var Axis_Axis = /*#__PURE__*/function () {
12825 function Axis(owner) {
12826 this.owner = void 0;
12827 this.x = void 0;
12828 this.subX = void 0;
12829 this.y = void 0;
12830 this.y2 = void 0;
12831 this.axesList = {};
12832 this.tick = {
12833 x: null,
12834 y: null,
12835 y2: null
12836 };
12837 this.xs = [];
12838 this.orient = {
12839 x: "bottom",
12840 y: "left",
12841 y2: "right",
12842 subX: "bottom"
12843 };
12844 this.owner = owner;
12845 this.setOrient();
12846 }
12847
12848 var _proto = Axis.prototype;
12849
12850 _proto.getAxisClassName = function getAxisClassName(id) {
12851 return config_classes.axis + " " + config_classes["axis" + capitalize(id)];
12852 };
12853
12854 _proto.isHorizontal = function isHorizontal($$, forHorizontal) {
12855 var isRotated = $$.config.axis_rotated;
12856 return forHorizontal ? isRotated : !isRotated;
12857 };
12858
12859 _proto.isCategorized = function isCategorized() {
12860 var _this$owner = this.owner,
12861 config = _this$owner.config,
12862 state = _this$owner.state;
12863 return config.axis_x_type.indexOf("category") >= 0 || state.hasRadar;
12864 };
12865
12866 _proto.isCustomX = function isCustomX() {
12867 var config = this.owner.config;
12868 return !this.isTimeSeries() && (config.data_x || notEmpty(config.data_xs));
12869 };
12870
12871 _proto.isTimeSeries = function isTimeSeries(id) {
12872 if (id === void 0) {
12873 id = "x";
12874 }
12875
12876 return this.owner.config["axis_" + id + "_type"] === "timeseries";
12877 };
12878
12879 _proto.isLog = function isLog(id) {
12880 if (id === void 0) {
12881 id = "x";
12882 }
12883
12884 return this.owner.config["axis_" + id + "_type"] === "log";
12885 };
12886
12887 _proto.isTimeSeriesY = function isTimeSeriesY() {
12888 return this.isTimeSeries("y");
12889 };
12890
12891 _proto.getAxisType = function getAxisType(id) {
12892 if (id === void 0) {
12893 id = "x";
12894 }
12895
12896 var type = "linear";
12897
12898 if (this.isTimeSeries(id)) {
12899 type = this.owner.config.axis_x_localtime ? "time" : "utc";
12900 } else if (this.isLog(id)) {
12901 type = "log";
12902 }
12903
12904 return type;
12905 };
12906
12907 _proto.init = function init() {
12908 var _this = this,
12909 $$ = this.owner,
12910 config = $$.config,
12911 _$$$$el = $$.$el,
12912 main = _$$$$el.main,
12913 axis = _$$$$el.axis,
12914 clip = $$.state.clip,
12915 isRotated = config.axis_rotated,
12916 target = ["x", "y"];
12917
12918 config.axis_y2_show && target.push("y2");
12919 target.forEach(function (v) {
12920 var classAxis = _this.getAxisClassName(v),
12921 classLabel = config_classes["axis" + v.toUpperCase() + "Label"];
12922
12923 axis[v] = main.append("g").attr("class", classAxis).attr("clip-path", function () {
12924 var res = null;
12925
12926 if (v === "x") {
12927 res = clip.pathXAxis;
12928 } else if (v === "y") {
12929 // && config.axis_y_inner) {
12930 res = clip.pathYAxis;
12931 }
12932
12933 return res;
12934 }).attr("transform", $$.getTranslate(v)).style("visibility", config["axis_" + v + "_show"] ? null : "hidden");
12935 axis[v].append("text").attr("class", classLabel).attr("transform", ["rotate(-90)", null][v === "x" ? +!isRotated : +isRotated]).style("text-anchor", function () {
12936 return _this.textAnchorForAxisLabel(v);
12937 });
12938
12939 _this.generateAxes(v);
12940 });
12941 }
12942 /**
12943 * Set axis orient according option value
12944 * @private
12945 */
12946 ;
12947
12948 _proto.setOrient = function setOrient() {
12949 var $$ = this.owner,
12950 _$$$config = $$.config,
12951 isRotated = _$$$config.axis_rotated,
12952 yInner = _$$$config.axis_y_inner,
12953 y2Inner = _$$$config.axis_y2_inner;
12954 this.orient = {
12955 x: isRotated ? "left" : "bottom",
12956 y: isRotated ? yInner ? "top" : "bottom" : yInner ? "right" : "left",
12957 y2: isRotated ? y2Inner ? "bottom" : "top" : y2Inner ? "left" : "right",
12958 subX: isRotated ? "left" : "bottom"
12959 };
12960 }
12961 /**
12962 * Generate axes
12963 * It's used when axis' axes option is set
12964 * @param {string} id Axis id
12965 * @private
12966 */
12967 ;
12968
12969 _proto.generateAxes = function generateAxes(id) {
12970 var $$ = this.owner,
12971 config = $$.config,
12972 axes = [],
12973 axesConfig = config["axis_" + id + "_axes"],
12974 isRotated = config.axis_rotated,
12975 d3Axis;
12976
12977 if (id === "x") {
12978 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;
12979 } else if (id === "y") {
12980 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;
12981 } else if (id === "y2") {
12982 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;
12983 }
12984
12985 if (axesConfig.length) {
12986 axesConfig.forEach(function (v) {
12987 var tick = v.tick || {},
12988 scale = $$.scale[id].copy();
12989 v.domain && scale.domain(v.domain);
12990 axes.push(d3Axis(scale).ticks(tick.count).tickFormat(isFunction(tick.format) ? tick.format.bind($$.api) : function (x) {
12991 return x;
12992 }).tickValues(tick.values).tickSizeOuter(tick.outer === !1 ? 0 : 6));
12993 });
12994 }
12995
12996 this.axesList[id] = axes;
12997 }
12998 /**
12999 * Update axes nodes
13000 * @private
13001 */
13002 ;
13003
13004 _proto.updateAxes = function updateAxes() {
13005 var _this2 = this,
13006 $$ = this.owner,
13007 config = $$.config,
13008 main = $$.$el.main;
13009
13010 Object.keys(this.axesList).forEach(function (id) {
13011 var axesConfig = config["axis_" + id + "_axes"],
13012 scale = $$.scale[id].copy(),
13013 range = scale.range();
13014
13015 _this2.axesList[id].forEach(function (v, i) {
13016 var axisRange = v.scale().range(); // adjust range value with the current
13017 // https://github.com/naver/billboard.js/issues/859
13018
13019 if (!range.every(function (v, i) {
13020 return v === axisRange[i];
13021 })) {
13022 v.scale().range(range);
13023 }
13024
13025 var className = _this2.getAxisClassName(id) + "-" + (i + 1),
13026 g = main.select("." + className.replace(/\s/, "."));
13027
13028 if (g.empty()) {
13029 g = main.append("g").attr("class", className).style("visibility", config["axis_" + id + "_show"] ? null : "hidden").call(v);
13030 } else {
13031 axesConfig[i].domain && scale.domain(axesConfig[i].domain);
13032 $$.$T(g).call(v.scale(scale));
13033 }
13034
13035 g.attr("transform", $$.getTranslate(id, i + 1));
13036 });
13037 });
13038 }
13039 /**
13040 * Set Axis & tick values
13041 * called from: updateScales()
13042 * @param {string} id Axis id string
13043 * @param {d3Scale} scale Scale
13044 * @param {boolean} outerTick If show outer tick
13045 * @param {boolean} noTransition If with no transition
13046 * @private
13047 */
13048 ;
13049
13050 _proto.setAxis = function setAxis(id, scale, outerTick, noTransition) {
13051 var $$ = this.owner;
13052
13053 if (id !== "subX") {
13054 this.tick[id] = this.getTickValues(id);
13055 } // @ts-ignore
13056
13057
13058 this[id] = this.getAxis(id, scale, outerTick, // do not transit x Axis on zoom and resizing
13059 // https://github.com/naver/billboard.js/issues/1949
13060 id === "x" && ($$.scale.zoom || $$.config.subchart_show || $$.state.resizing) ? !0 : noTransition);
13061 } // called from : getMaxTickWidth()
13062 ;
13063
13064 _proto.getAxis = function getAxis(id, scale, outerTick, noTransition, noTickTextRotate) {
13065 var $$ = this.owner,
13066 config = $$.config,
13067 isX = /^(x|subX)$/.test(id),
13068 type = isX ? "x" : id,
13069 isCategory = isX && this.isCategorized(),
13070 orient = this.orient[id],
13071 tickTextRotate = noTickTextRotate ? 0 : $$.getAxisTickRotate(type),
13072 tickFormat;
13073
13074 if (isX) {
13075 tickFormat = id === "subX" ? $$.format.subXAxisTick : $$.format.xAxisTick;
13076 } else {
13077 var fn = config["axis_" + id + "_tick_format"];
13078
13079 if (isFunction(fn)) {
13080 tickFormat = fn.bind($$.api);
13081 }
13082 }
13083
13084 var tickValues = this.tick[type],
13085 axisParams = mergeObj({
13086 outerTick: outerTick,
13087 noTransition: noTransition,
13088 config: config,
13089 id: id,
13090 tickTextRotate: tickTextRotate,
13091 owner: $$
13092 }, isX && {
13093 isCategory: isCategory,
13094 tickMultiline: config.axis_x_tick_multiline,
13095 tickWidth: config.axis_x_tick_width,
13096 tickTitle: isCategory && config.axis_x_tick_tooltip && $$.api.categories(),
13097 orgXScale: $$.scale.x
13098 });
13099
13100 if (!isX) {
13101 axisParams.tickStepSize = config["axis_" + type + "_tick_stepSize"];
13102 }
13103
13104 var axis = new AxisRenderer(axisParams).scale(isX && $$.scale.zoom || scale).orient(orient);
13105
13106 if (isX && this.isTimeSeries() && tickValues && !isFunction(tickValues)) {
13107 var _fn = parseDate.bind($$);
13108
13109 tickValues = tickValues.map(function (v) {
13110 return _fn(v);
13111 });
13112 } else if (!isX && this.isTimeSeriesY()) {
13113 // https://github.com/d3/d3/blob/master/CHANGES.md#time-intervals-d3-time
13114 axis.ticks(config.axis_y_tick_time_value);
13115 tickValues = null;
13116 }
13117
13118 tickValues && axis.tickValues(tickValues); // Set tick
13119
13120 axis.tickFormat(tickFormat || !isX && $$.isStackNormalized() && function (x) {
13121 return x + "%";
13122 });
13123
13124 if (isCategory) {
13125 axis.tickCentered(config.axis_x_tick_centered);
13126
13127 if (isEmpty(config.axis_x_tick_culling)) {
13128 config.axis_x_tick_culling = !1;
13129 }
13130 }
13131
13132 var tickCount = config["axis_" + type + "_tick_count"];
13133 tickCount && axis.ticks(tickCount);
13134 return axis;
13135 };
13136
13137 _proto.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) {
13138 var $$ = this.owner,
13139 config = $$.config,
13140 fit = config.axis_x_tick_fit,
13141 count = config.axis_x_tick_count,
13142 values;
13143
13144 if (fit || count && fit) {
13145 values = $$.mapTargetsToUniqueXs(targets); // if given count is greater than the value length, then limit the count.
13146
13147 if (this.isCategorized() && count > values.length) {
13148 count = values.length;
13149 }
13150
13151 values = this.generateTickValues(values, count, this.isTimeSeries());
13152 }
13153
13154 if (axis) {
13155 axis.tickValues(values);
13156 } else if (this.x) {
13157 var _this$subX;
13158
13159 this.x.tickValues(values);
13160 (_this$subX = this.subX) == null ? void 0 : _this$subX.tickValues(values);
13161 }
13162
13163 return values;
13164 };
13165
13166 _proto.getId = function getId(id) {
13167 var _this$owner2 = this.owner,
13168 config = _this$owner2.config,
13169 scale = _this$owner2.scale,
13170 axis = config.data_axes[id];
13171
13172 // when data.axes option has 'y2', but 'axis.y2.show=true' isn't set will return 'y'
13173 if (!axis || !scale[axis]) {
13174 axis = "y";
13175 }
13176
13177 return axis;
13178 };
13179
13180 _proto.getXAxisTickFormat = function getXAxisTickFormat(forSubchart) {
13181 var $$ = this.owner,
13182 config = $$.config,
13183 format = $$.format,
13184 tickFormat = forSubchart ? config.subchart_axis_x_tick_format || config.axis_x_tick_format : config.axis_x_tick_format,
13185 isTimeSeries = this.isTimeSeries(),
13186 isCategorized = this.isCategorized(),
13187 currFormat;
13188
13189 if (tickFormat) {
13190 if (isFunction(tickFormat)) {
13191 currFormat = tickFormat.bind($$.api);
13192 } else if (isTimeSeries) {
13193 currFormat = function (date) {
13194 return date ? format.axisTime(tickFormat)(date) : "";
13195 };
13196 }
13197 } else {
13198 currFormat = isTimeSeries ? format.defaultAxisTime : isCategorized ? $$.categoryName : function (v) {
13199 return v < 0 ? v.toFixed(0) : v;
13200 };
13201 }
13202
13203 return isFunction(currFormat) ? function (v) {
13204 return currFormat.apply($$, isCategorized ? [v, $$.categoryName(v)] : [v]);
13205 } : currFormat;
13206 };
13207
13208 _proto.getTickValues = function getTickValues(id) {
13209 var $$ = this.owner,
13210 tickValues = $$.config["axis_" + id + "_tick_values"],
13211 axis = $$[id + "Axis"];
13212 return (isFunction(tickValues) ? tickValues.call($$.api) : tickValues) || (axis ? axis.tickValues() : undefined);
13213 };
13214
13215 _proto.getLabelOptionByAxisId = function getLabelOptionByAxisId(id) {
13216 return this.owner.config["axis_" + id + "_label"];
13217 };
13218
13219 _proto.getLabelText = function getLabelText(id) {
13220 var option = this.getLabelOptionByAxisId(id);
13221 return isString(option) ? option : option ? option.text : null;
13222 };
13223
13224 _proto.setLabelText = function setLabelText(id, text) {
13225 var $$ = this.owner,
13226 config = $$.config,
13227 option = this.getLabelOptionByAxisId(id);
13228
13229 if (isString(option)) {
13230 config["axis_" + id + "_label"] = text;
13231 } else if (option) {
13232 option.text = text;
13233 }
13234 };
13235
13236 _proto.getLabelPosition = function getLabelPosition(id, defaultPosition) {
13237 var isRotated = this.owner.config.axis_rotated,
13238 option = this.getLabelOptionByAxisId(id),
13239 position = isObjectType(option) && option.position ? option.position : defaultPosition[+!isRotated],
13240 has = function (v) {
13241 return !!~position.indexOf(v);
13242 };
13243
13244 return {
13245 isInner: has("inner"),
13246 isOuter: has("outer"),
13247 isLeft: has("left"),
13248 isCenter: has("center"),
13249 isRight: has("right"),
13250 isTop: has("top"),
13251 isMiddle: has("middle"),
13252 isBottom: has("bottom")
13253 };
13254 };
13255
13256 _proto.getAxisLabelPosition = function getAxisLabelPosition(id) {
13257 return this.getLabelPosition(id, id === "x" ? ["inner-top", "inner-right"] : ["inner-right", "inner-top"]);
13258 };
13259
13260 _proto.getLabelPositionById = function getLabelPositionById(id) {
13261 return this.getAxisLabelPosition(id);
13262 };
13263
13264 _proto.xForAxisLabel = function xForAxisLabel(id) {
13265 var $$ = this.owner,
13266 _$$$state = $$.state,
13267 width = _$$$state.width,
13268 height = _$$$state.height,
13269 position = this.getAxisLabelPosition(id),
13270 x = position.isMiddle ? -height / 2 : 0;
13271
13272 if (this.isHorizontal($$, id !== "x")) {
13273 x = position.isLeft ? 0 : position.isCenter ? width / 2 : width;
13274 } else if (position.isBottom) {
13275 x = -height;
13276 }
13277
13278 return x;
13279 };
13280
13281 _proto.dxForAxisLabel = function dxForAxisLabel(id) {
13282 var $$ = this.owner,
13283 position = this.getAxisLabelPosition(id),
13284 dx = position.isBottom ? "0.5em" : "0";
13285
13286 if (this.isHorizontal($$, id !== "x")) {
13287 dx = position.isLeft ? "0.5em" : position.isRight ? "-0.5em" : "0";
13288 } else if (position.isTop) {
13289 dx = "-0.5em";
13290 }
13291
13292 return dx;
13293 };
13294
13295 _proto.textAnchorForAxisLabel = function textAnchorForAxisLabel(id) {
13296 var $$ = this.owner,
13297 position = this.getAxisLabelPosition(id),
13298 anchor = position.isMiddle ? "middle" : "end";
13299
13300 if (this.isHorizontal($$, id !== "x")) {
13301 anchor = position.isLeft ? "start" : position.isCenter ? "middle" : "end";
13302 } else if (position.isBottom) {
13303 anchor = "start";
13304 }
13305
13306 return anchor;
13307 };
13308
13309 _proto.dyForAxisLabel = function dyForAxisLabel(id) {
13310 var $$ = this.owner,
13311 config = $$.config,
13312 isRotated = config.axis_rotated,
13313 isInner = this.getAxisLabelPosition(id).isInner,
13314 tickRotate = config["axis_" + id + "_tick_rotate"] ? $$.getHorizontalAxisHeight(id) : 0,
13315 maxTickWidth = this.getMaxTickWidth(id),
13316 dy;
13317
13318 if (id === "x") {
13319 var xHeight = config.axis_x_height;
13320
13321 if (isRotated) {
13322 dy = isInner ? "1.2em" : -25 - maxTickWidth;
13323 } else if (isInner) {
13324 dy = "-0.5em";
13325 } else if (xHeight) {
13326 dy = xHeight - 10;
13327 } else if (tickRotate) {
13328 dy = tickRotate - 10;
13329 } else {
13330 dy = "3em";
13331 }
13332 } else {
13333 dy = {
13334 y: ["-0.5em", 10, "3em", "1.2em", 10],
13335 y2: ["1.2em", -20, "-2.2em", "-0.5em", 15]
13336 }[id];
13337
13338 if (isRotated) {
13339 if (isInner) {
13340 dy = dy[0];
13341 } else if (tickRotate) {
13342 dy = tickRotate * (id === "y2" ? -1 : 1) - dy[1];
13343 } else {
13344 dy = dy[2];
13345 }
13346 } else {
13347 dy = isInner ? dy[3] : (dy[4] + (config["axis_" + id + "_inner"] ? 0 : maxTickWidth + dy[4])) * (id === "y" ? -1 : 1);
13348 }
13349 }
13350
13351 return dy;
13352 };
13353
13354 _proto.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) {
13355 var $$ = this.owner,
13356 config = $$.config,
13357 current = $$.state.current,
13358 _$$$$el2 = $$.$el,
13359 svg = _$$$$el2.svg,
13360 chart = _$$$$el2.chart,
13361 currentTickMax = current.maxTickWidths[id],
13362 maxWidth = 0;
13363
13364 if (withoutRecompute || !config["axis_" + id + "_show"] || $$.filterTargetsToShow().length === 0) {
13365 return currentTickMax.size;
13366 }
13367
13368 if (svg) {
13369 var isYAxis = /^y2?$/.test(id),
13370 targetsToShow = $$.filterTargetsToShow($$.data.targets),
13371 scale = $$.scale[id].copy().domain($$["get" + (isYAxis ? "Y" : "X") + "Domain"](targetsToShow, id)),
13372 domain = scale.domain(),
13373 isDomainSame = domain[0] === domain[1] && domain.every(function (v) {
13374 return v > 0;
13375 }),
13376 isCurrentMaxTickDomainSame = isArray(currentTickMax.domain) && currentTickMax.domain[0] === currentTickMax.domain[1] && currentTickMax.domain.every(function (v) {
13377 return v > 0;
13378 });
13379
13380 // do not compute if domain or currentMaxTickDomain is same
13381 if (isDomainSame || isCurrentMaxTickDomainSame) {
13382 return currentTickMax.size;
13383 } else {
13384 currentTickMax.domain = domain;
13385 } // reset old max state value to prevent from new data loading
13386
13387
13388 if (!isYAxis) {
13389 currentTickMax.ticks.splice(0);
13390 }
13391
13392 var axis = this.getAxis(id, scale, !1, !1, !0),
13393 tickCount = config["axis_" + id + "_tick_count"],
13394 tickValues = config["axis_" + id + "_tick_values"];
13395
13396 // Make to generate the final tick text to be rendered
13397 // https://github.com/naver/billboard.js/issues/920
13398 // Do not generate if 'tick values' option is given
13399 // https://github.com/naver/billboard.js/issues/1251
13400 if (!tickValues && tickCount) {
13401 axis.tickValues(this.generateTickValues(domain, tickCount, isYAxis ? this.isTimeSeriesY() : this.isTimeSeries()));
13402 }
13403
13404 isYAxis || this.updateXAxisTickValues(targetsToShow, axis);
13405 var dummy = chart.append("svg").style("visibility", "hidden").style("position", "fixed").style("top", "0").style("left", "0");
13406 axis.create(dummy);
13407 dummy.selectAll("text").each(function (d, i) {
13408 var currentTextWidth = this.getBoundingClientRect().width;
13409 maxWidth = Math.max(maxWidth, currentTextWidth); // cache tick text width for getXAxisTickTextY2Overflow()
13410
13411 if (!isYAxis) {
13412 currentTickMax.ticks[i] = currentTextWidth;
13413 }
13414 });
13415 dummy.remove();
13416 }
13417
13418 if (maxWidth > 0) {
13419 currentTickMax.size = maxWidth;
13420 }
13421
13422 return currentTickMax.size;
13423 };
13424
13425 _proto.getXAxisTickTextY2Overflow = function getXAxisTickTextY2Overflow(defaultPadding) {
13426 var $$ = this.owner,
13427 axis = $$.axis,
13428 config = $$.config,
13429 state = $$.state,
13430 xAxisTickRotate = $$.getAxisTickRotate("x");
13431
13432 if ((axis.isCategorized() || axis.isTimeSeries()) && config.axis_x_tick_fit && !config.axis_x_tick_culling && !config.axis_x_tick_multiline && xAxisTickRotate > 0 && xAxisTickRotate < 90) {
13433 var widthWithoutCurrentPaddingLeft = state.current.width - $$.getCurrentPaddingLeft(),
13434 maxOverflow = this.getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft - defaultPadding),
13435 xAxisTickTextY2Overflow = Math.max(0, maxOverflow) + defaultPadding;
13436 // for display inconsistencies between browsers
13437 return Math.min(xAxisTickTextY2Overflow, widthWithoutCurrentPaddingLeft / 2);
13438 }
13439
13440 return 0;
13441 };
13442
13443 _proto.getXAxisTickMaxOverflow = function getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft) {
13444 var $$ = this.owner,
13445 axis = $$.axis,
13446 config = $$.config,
13447 state = $$.state,
13448 isTimeSeries = axis.isTimeSeries(),
13449 tickTextWidths = state.current.maxTickWidths.x.ticks,
13450 tickCount = tickTextWidths.length,
13451 _state$axis$x$padding = state.axis.x.padding,
13452 left = _state$axis$x$padding.left,
13453 right = _state$axis$x$padding.right,
13454 maxOverflow = 0,
13455 remaining = tickCount - (isTimeSeries && config.axis_x_tick_fit ? .5 : 0);
13456
13457 for (var i = 0; i < tickCount; i++) {
13458 var tickIndex = i + 1,
13459 rotatedTickTextWidth = Math.cos(Math.PI * xAxisTickRotate / 180) * tickTextWidths[i],
13460 ticksBeforeTickText = tickIndex - (isTimeSeries ? 1 : .5) + left;
13461
13462 // Skip ticks if there are no ticks before them
13463 if (ticksBeforeTickText <= 0) {
13464 continue;
13465 }
13466
13467 var tickLength = (widthWithoutCurrentPaddingLeft - rotatedTickTextWidth) / ticksBeforeTickText;
13468 maxOverflow = Math.max(maxOverflow, rotatedTickTextWidth - tickLength / 2 - ((remaining - tickIndex) * tickLength + right * tickLength));
13469 }
13470
13471 var filteredTargets = $$.filterTargetsToShow($$.data.targets),
13472 tickOffset = 0;
13473
13474 if (!isTimeSeries && config.axis_x_tick_count <= filteredTargets.length && filteredTargets[0].values.length) {
13475 var scale = getScale($$.axis.getAxisType("x"), 0, widthWithoutCurrentPaddingLeft - maxOverflow).domain([left * -1, $$.getXDomainMax($$.data.targets) + 1 + right]);
13476 tickOffset = Math.ceil((scale(1) - scale(0)) / 2);
13477 }
13478
13479 return maxOverflow + tickOffset;
13480 };
13481
13482 _proto.updateLabels = function updateLabels(withTransition) {
13483 var _this3 = this,
13484 $$ = this.owner,
13485 main = $$.$el.main,
13486 $T = $$.$T,
13487 labels = {
13488 x: main.select("." + config_classes.axisX + " ." + config_classes.axisXLabel),
13489 y: main.select("." + config_classes.axisY + " ." + config_classes.axisYLabel),
13490 y2: main.select("." + config_classes.axisY2 + " ." + config_classes.axisY2Label)
13491 };
13492
13493 Object.keys(labels).filter(function (id) {
13494 return !labels[id].empty();
13495 }).forEach(function (v) {
13496 var node = labels[v]; // @check $$.$T(node, withTransition)
13497
13498 $T(node, withTransition).attr("x", function () {
13499 return _this3.xForAxisLabel(v);
13500 }).attr("dx", function () {
13501 return _this3.dxForAxisLabel(v);
13502 }).attr("dy", function () {
13503 return _this3.dyForAxisLabel(v);
13504 }).text(function () {
13505 return _this3.getLabelText(v);
13506 });
13507 });
13508 }
13509 /**
13510 * Get axis padding value
13511 * @param {number|object} padding Padding object
13512 * @param {string} key Key string of padding
13513 * @param {Date|number} defaultValue Default value
13514 * @param {number} domainLength Domain length
13515 * @returns {number} Padding value in scale
13516 * @private
13517 */
13518 ;
13519
13520 _proto.getPadding = function getPadding(padding, key, defaultValue, domainLength) {
13521 var p = isNumber(padding) ? padding : padding[key];
13522
13523 if (!isValue(p)) {
13524 return defaultValue;
13525 }
13526
13527 return this.owner.convertPixelToScale(/(bottom|top)/.test(key) ? "y" : "x", p, domainLength);
13528 };
13529
13530 _proto.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) {
13531 var tickValues = values;
13532
13533 if (tickCount) {
13534 var targetCount = isFunction(tickCount) ? tickCount() : tickCount; // compute ticks according to tickCount
13535
13536 if (targetCount === 1) {
13537 tickValues = [values[0]];
13538 } else if (targetCount === 2) {
13539 tickValues = [values[0], values[values.length - 1]];
13540 } else if (targetCount > 2) {
13541 var isCategorized = this.isCategorized(),
13542 count = targetCount - 2,
13543 start = values[0],
13544 end = values[values.length - 1],
13545 tickValue;
13546 // re-construct unique values
13547 tickValues = [start];
13548
13549 for (var i = 0; i < count; i++) {
13550 tickValue = +start + (end - start) / (count + 1) * (i + 1);
13551 tickValues.push(forTimeSeries ? new Date(tickValue) : isCategorized ? Math.round(tickValue) : tickValue);
13552 }
13553
13554 tickValues.push(end);
13555 }
13556 }
13557
13558 if (!forTimeSeries) {
13559 tickValues = tickValues.sort(function (a, b) {
13560 return a - b;
13561 });
13562 }
13563
13564 return tickValues;
13565 };
13566
13567 _proto.generateTransitions = function generateTransitions(withTransition) {
13568 var $$ = this.owner,
13569 axis = $$.$el.axis,
13570 $T = $$.$T,
13571 _map = ["x", "y", "y2", "subX"].map(function (v) {
13572 return $T(axis[v], withTransition);
13573 }),
13574 axisX = _map[0],
13575 axisY = _map[1],
13576 axisY2 = _map[2],
13577 axisSubX = _map[3];
13578
13579 return {
13580 axisX: axisX,
13581 axisY: axisY,
13582 axisY2: axisY2,
13583 axisSubX: axisSubX
13584 };
13585 };
13586
13587 _proto.redraw = function redraw(transitions, isHidden, isInit) {
13588 var _this4 = this,
13589 $$ = this.owner,
13590 config = $$.config,
13591 $el = $$.$el,
13592 opacity = isHidden ? "0" : null;
13593
13594 ["x", "y", "y2", "subX"].forEach(function (id) {
13595 var axis = _this4[id],
13596 $axis = $el.axis[id];
13597
13598 if (axis && $axis) {
13599 if (!isInit && !config.transition_duration) {
13600 axis.config.withoutTransition = !0;
13601 }
13602
13603 $axis.style("opacity", opacity);
13604 axis.create(transitions["axis" + capitalize(id)]);
13605 }
13606 });
13607 this.updateAxes();
13608 }
13609 /**
13610 * Redraw axis
13611 * @param {Array} targetsToShow targets data to be shown
13612 * @param {object} wth option object
13613 * @param {d3.Transition} transitions Transition object
13614 * @param {object} flow flow object
13615 * @param {boolean} isInit called from initialization
13616 * @private
13617 */
13618 ;
13619
13620 _proto.redrawAxis = function redrawAxis(targetsToShow, wth, transitions, flow, isInit) {
13621 var _this5 = this,
13622 $$ = this.owner,
13623 config = $$.config,
13624 scale = $$.scale,
13625 $el = $$.$el,
13626 hasZoom = !!scale.zoom,
13627 xDomainForZoom;
13628
13629 if (!hasZoom && this.isCategorized() && targetsToShow.length === 0) {
13630 scale.x.domain([0, $el.axis.x.selectAll(".tick").size()]);
13631 }
13632
13633 if (scale.x && targetsToShow.length) {
13634 hasZoom || $$.updateXDomain(targetsToShow, wth.UpdateXDomain, wth.UpdateOrgXDomain, wth.TrimXDomain);
13635
13636 if (!config.axis_x_tick_values) {
13637 this.updateXAxisTickValues(targetsToShow);
13638 }
13639 } else if (this.x) {
13640 var _this$subX2;
13641
13642 this.x.tickValues([]);
13643 (_this$subX2 = this.subX) == null ? void 0 : _this$subX2.tickValues([]);
13644 }
13645
13646 if (config.zoom_rescale && !flow) {
13647 xDomainForZoom = scale.x.orgDomain();
13648 }
13649
13650 ["y", "y2"].forEach(function (key) {
13651 var axisScale = scale[key];
13652
13653 if (axisScale) {
13654 var tickValues = config["axis_" + key + "_tick_values"],
13655 tickCount = config["axis_" + key + "_tick_count"];
13656 axisScale.domain($$.getYDomain(targetsToShow, key, xDomainForZoom));
13657
13658 if (!tickValues && tickCount) {
13659 var _axis = $$.axis[key],
13660 domain = axisScale.domain();
13661
13662 _axis.tickValues(_this5.generateTickValues(domain, domain.every(function (v) {
13663 return v === 0;
13664 }) ? 1 : tickCount, _this5.isTimeSeriesY()));
13665 }
13666 }
13667 }); // axes
13668
13669 this.redraw(transitions, $$.hasArcType(), isInit); // Update axis label
13670
13671 this.updateLabels(wth.Transition); // show/hide if manual culling needed
13672
13673 if ((wth.UpdateXDomain || wth.UpdateXAxis || wth.Y) && targetsToShow.length) {
13674 this.setCulling();
13675 } // Update sub domain
13676
13677
13678 if (wth.Y) {
13679 var _scale$subY, _scale$subY2;
13680
13681 (_scale$subY = scale.subY) == null ? void 0 : _scale$subY.domain($$.getYDomain(targetsToShow, "y"));
13682 (_scale$subY2 = scale.subY2) == null ? void 0 : _scale$subY2.domain($$.getYDomain(targetsToShow, "y2"));
13683 }
13684 }
13685 /**
13686 * Set manual culling
13687 * @private
13688 */
13689 ;
13690
13691 _proto.setCulling = function setCulling() {
13692 var $$ = this.owner,
13693 config = $$.config,
13694 _$$$state2 = $$.state,
13695 clip = _$$$state2.clip,
13696 current = _$$$state2.current,
13697 $el = $$.$el;
13698 ["subX", "x", "y", "y2"].forEach(function (type) {
13699 var axis = $el.axis[type],
13700 id = type === "subX" ? "x" : type,
13701 toCull = config["axis_" + id + "_tick_culling"]; // subchart x axis should be aligned with x axis culling
13702
13703 if (axis && toCull) {
13704 var tickText = axis.selectAll(".tick text"),
13705 tickValues = sortValue(tickText.data()),
13706 tickSize = tickValues.length,
13707 cullingMax = config["axis_" + id + "_tick_culling_max"],
13708 intervalForCulling;
13709
13710 if (tickSize) {
13711 for (var i = 1; i < tickSize; i++) {
13712 if (tickSize / i < cullingMax) {
13713 intervalForCulling = i;
13714 break;
13715 }
13716 }
13717
13718 tickText.each(function (d) {
13719 this.style.display = tickValues.indexOf(d) % intervalForCulling ? "none" : null;
13720 });
13721 } else {
13722 tickText.style("display", null);
13723 } // set/unset x_axis_tick_clippath
13724
13725
13726 if (type === "x") {
13727 var clipPath = current.maxTickWidths.x.clipPath ? clip.pathXAxisTickTexts : null;
13728 $el.svg.selectAll("." + config_classes.axisX + " .tick text").attr("clip-path", clipPath);
13729 }
13730 }
13731 });
13732 };
13733
13734 return Axis;
13735}();
13736;// CONCATENATED MODULE: ./src/ChartInternal/interactions/eventrect.ts
13737/**
13738 * Copyright (c) 2017 ~ present NAVER Corp.
13739 * billboard.js project is licensed under the MIT license
13740 */
13741
13742
13743/* harmony default export */ var eventrect = ({
13744 /**
13745 * Initialize the area that detects the event.
13746 * Add a container for the zone that detects the event.
13747 * @private
13748 */
13749 initEventRect: function initEventRect() {
13750 var $$ = this;
13751 $$.$el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.eventRects).style("fill-opacity", "0");
13752 },
13753
13754 /**
13755 * Redraws the area that detects the event.
13756 * @private
13757 */
13758 redrawEventRect: function redrawEventRect() {
13759 var $$ = this,
13760 config = $$.config,
13761 state = $$.state,
13762 $el = $$.$el,
13763 isMultipleX = $$.isMultipleX();
13764
13765 if ($el.eventRect) {
13766 $$.updateEventRect($el.eventRect, !0);
13767 } else {
13768 var eventRects = $$.$el.main.select("." + config_classes.eventRects).style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ? config.axis_rotated ? "ns-resize" : "ew-resize" : null).classed(config_classes.eventRectsMultiple, isMultipleX).classed(config_classes.eventRectsSingle, !isMultipleX),
13769 eventRectUpdate = eventRects.selectAll("." + config_classes.eventRect).data([0]).enter().append("rect"); // append event <rect>
13770
13771 $$.updateEventRect(eventRectUpdate); // bind event to <rect> element
13772
13773 isMultipleX ? $$.generateEventRectsForMultipleXs(eventRectUpdate) : $$.generateEventRectsForSingleX(eventRectUpdate); // bind draggable selection
13774
13775 eventRectUpdate.call($$.getDraggableSelection());
13776 $el.eventRect = eventRectUpdate;
13777
13778 if ($$.state.inputType === "touch" && !$el.svg.on("touchstart.eventRect") && !$$.hasArcType()) {
13779 $$.bindTouchOnEventRect(isMultipleX);
13780 }
13781 }
13782
13783 if (!isMultipleX) {
13784 // Set data and update eventReceiver.data
13785 var xAxisTickValues = $$.getMaxDataCountTarget(); // update data's index value to be alinged with the x Axis
13786
13787 $$.updateDataIndexByX(xAxisTickValues);
13788 $$.updateXs(xAxisTickValues);
13789 $$.updatePointClass == null ? void 0 : $$.updatePointClass(!0);
13790 state.eventReceiver.data = xAxisTickValues;
13791 }
13792
13793 $$.updateEventRectData();
13794 },
13795 bindTouchOnEventRect: function bindTouchOnEventRect(isMultipleX) {
13796 var $$ = this,
13797 config = $$.config,
13798 state = $$.state,
13799 _$$$$el = $$.$el,
13800 eventRect = _$$$$el.eventRect,
13801 svg = _$$$$el.svg,
13802 selectRect = function (context) {
13803 if (isMultipleX) {
13804 $$.selectRectForMultipleXs(context);
13805 } else {
13806 var index = $$.getDataIndexFromEvent(state.event);
13807 $$.callOverOutForTouch(index);
13808 index === -1 ? $$.unselectRect() : $$.selectRectForSingle(context, eventRect, index);
13809 }
13810 },
13811 unselectRect = function () {
13812 $$.unselectRect();
13813 $$.callOverOutForTouch();
13814 },
13815 preventDefault = config.interaction_inputType_touch.preventDefault,
13816 isPrevented = isboolean(preventDefault) && preventDefault || !1,
13817 preventThreshold = !isNaN(preventDefault) && preventDefault || null,
13818 startPx,
13819 preventEvent = function (event) {
13820 var eventType = event.type,
13821 touch = event.changedTouches[0],
13822 currentXY = touch["client" + (config.axis_rotated ? "Y" : "X")];
13823
13824 // prevent document scrolling
13825 if (eventType === "touchstart") {
13826 if (isPrevented) {
13827 event.preventDefault();
13828 } else if (preventThreshold !== null) {
13829 startPx = currentXY;
13830 }
13831 } else if (eventType === "touchmove") {
13832 if (isPrevented || startPx === !0 || preventThreshold !== null && Math.abs(startPx - currentXY) >= preventThreshold) {
13833 // once prevented, keep prevented during whole 'touchmove' context
13834 startPx = !0;
13835 event.preventDefault();
13836 }
13837 }
13838 };
13839
13840 // bind touch events
13841 eventRect.on("touchstart", function (event) {
13842 state.event = event;
13843 $$.updateEventRect();
13844 }).on("touchstart.eventRect touchmove.eventRect", function (event) {
13845 state.event = event;
13846
13847 if (!eventRect.empty() && eventRect.classed(config_classes.eventRect)) {
13848 // if touch points are > 1, means doing zooming interaction. In this case do not execute tooltip codes.
13849 if (state.dragging || state.flowing || $$.hasArcType() || event.touches.length > 1) {
13850 return;
13851 }
13852
13853 preventEvent(event);
13854 selectRect(eventRect.node());
13855 } else {
13856 unselectRect();
13857 }
13858 }, !0).on("touchend.eventRect", function (event) {
13859 state.event = event;
13860
13861 if (!eventRect.empty() && eventRect.classed(config_classes.eventRect)) {
13862 if ($$.hasArcType() || !$$.toggleShape || state.cancelClick) {
13863 state.cancelClick && (state.cancelClick = !1);
13864 }
13865 }
13866 }, !0);
13867 svg.on("touchstart", function (event) {
13868 state.event = event;
13869 var target = event.target;
13870
13871 if (target && target !== eventRect.node()) {
13872 unselectRect();
13873 }
13874 });
13875 },
13876
13877 /**
13878 * Update event rect size
13879 * @param {d3Selection} eventRect Event <rect> element
13880 * @param {boolean} force Force to update
13881 * @private
13882 */
13883 updateEventRect: function updateEventRect(eventRect, force) {
13884 if (force === void 0) {
13885 force = !1;
13886 }
13887
13888 var $$ = this,
13889 state = $$.state,
13890 $el = $$.$el,
13891 _state = state,
13892 eventReceiver = _state.eventReceiver,
13893 width = _state.width,
13894 height = _state.height,
13895 rendered = _state.rendered,
13896 resizing = _state.resizing,
13897 rectElement = eventRect || $el.eventRect;
13898
13899 if (!rendered || resizing || force) {
13900 rectElement.attr("x", 0).attr("y", 0).attr("width", width).attr("height", height); // only for init
13901
13902 if (!rendered) {
13903 rectElement.attr("class", config_classes.eventRect);
13904 }
13905 }
13906
13907 (function updateClientRect() {
13908 eventReceiver && (eventReceiver.rect = rectElement.node().getBoundingClientRect());
13909 })();
13910 },
13911
13912 /**
13913 * Updates the location and size of the eventRect.
13914 * @private
13915 */
13916 updateEventRectData: function updateEventRectData() {
13917 var $$ = this,
13918 config = $$.config,
13919 scale = $$.scale,
13920 state = $$.state,
13921 xScale = scale.zoom || scale.x,
13922 isRotated = config.axis_rotated,
13923 x,
13924 y,
13925 w,
13926 h;
13927
13928 if ($$.isMultipleX()) {
13929 // TODO: rotated not supported yet
13930 x = 0;
13931 y = 0;
13932 w = state.width;
13933 h = state.height;
13934 } else {
13935 var rectW, rectX;
13936
13937 if ($$.axis.isCategorized()) {
13938 rectW = $$.getEventRectWidth();
13939
13940 rectX = function (d) {
13941 return xScale(d.x) - rectW / 2;
13942 };
13943 } else {
13944 var getPrevNextX = function (_ref) {
13945 var index = _ref.index;
13946 return {
13947 prev: $$.getPrevX(index),
13948 next: $$.getNextX(index)
13949 };
13950 };
13951
13952 rectW = function (d) {
13953 var x = getPrevNextX(d),
13954 xDomain = xScale.domain();
13955
13956 // if there this is a single data point make the eventRect full width (or height)
13957 if (x.prev === null && x.next === null) {
13958 return isRotated ? state.height : state.width;
13959 }
13960
13961 Object.keys(x).forEach(function (key, i) {
13962 var _x$key;
13963
13964 x[key] = (_x$key = x[key]) != null ? _x$key : xDomain[i];
13965 });
13966 return Math.max(0, (xScale(x.next) - xScale(x.prev)) / 2);
13967 };
13968
13969 rectX = function (d) {
13970 var x = getPrevNextX(d),
13971 thisX = d.x;
13972
13973 // if there this is a single data point position the eventRect at 0
13974 if (x.prev === null && x.next === null) {
13975 return 0;
13976 }
13977
13978 if (x.prev === null) {
13979 x.prev = xScale.domain()[0];
13980 }
13981
13982 return (xScale(thisX) + xScale(x.prev)) / 2;
13983 };
13984 }
13985
13986 x = isRotated ? 0 : rectX;
13987 y = isRotated ? rectX : 0;
13988 w = isRotated ? state.width : rectW;
13989 h = isRotated ? rectW : state.height;
13990 }
13991
13992 var eventReceiver = state.eventReceiver,
13993 call = function (fn, v) {
13994 return isFunction(fn) ? fn(v) : fn;
13995 };
13996
13997 // reset for possible remains coords data before the data loading
13998 eventReceiver.coords.splice(eventReceiver.data.length);
13999 eventReceiver.data.forEach(function (d, i) {
14000 eventReceiver.coords[i] = {
14001 x: call(x, d),
14002 y: call(y, d),
14003 w: call(w, d),
14004 h: call(h, d)
14005 };
14006 });
14007 },
14008 selectRectForMultipleXs: function selectRectForMultipleXs(context) {
14009 var $$ = this,
14010 config = $$.config,
14011 state = $$.state,
14012 targetsToShow = $$.filterTargetsToShow($$.data.targets);
14013
14014 // do nothing when dragging
14015 if (state.dragging || $$.hasArcType(targetsToShow)) {
14016 return;
14017 }
14018
14019 var mouse = getPointer(state.event, context),
14020 closest = $$.findClosestFromTargets(targetsToShow, mouse);
14021
14022 if (state.mouseover && (!closest || closest.id !== state.mouseover.id)) {
14023 config.data_onout.call($$.api, state.mouseover);
14024 state.mouseover = undefined;
14025 }
14026
14027 if (!closest) {
14028 $$.unselectRect();
14029 return;
14030 }
14031
14032 var sameXData = $$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped ? [closest] : $$.filterByX(targetsToShow, closest.x),
14033 selectedData = sameXData.map(function (d) {
14034 return $$.addName(d);
14035 }); // show tooltip when cursor is close to some point
14036
14037 $$.showTooltip(selectedData, context); // expand points
14038
14039 $$.setExpand(closest.index, closest.id, !0); // Show xgrid focus line
14040
14041 $$.showGridFocus(selectedData); // Show cursor as pointer if point is close to mouse position
14042
14043 if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
14044 $$.$el.svg.select("." + config_classes.eventRect).style("cursor", "pointer");
14045
14046 if (!state.mouseover) {
14047 config.data_onover.call($$.api, closest);
14048 state.mouseover = closest;
14049 }
14050 }
14051 },
14052
14053 /**
14054 * Unselect EventRect.
14055 * @private
14056 */
14057 unselectRect: function unselectRect() {
14058 var $$ = this,
14059 config = $$.config,
14060 _$$$$el2 = $$.$el,
14061 circle = _$$$$el2.circle,
14062 tooltip = _$$$$el2.tooltip;
14063 $$.$el.svg.select("." + config_classes.eventRect).style("cursor", null);
14064 $$.hideGridFocus();
14065
14066 if (tooltip) {
14067 $$.hideTooltip();
14068
14069 $$._handleLinkedCharts(!1);
14070 }
14071
14072 circle && !config.point_focus_only && $$.unexpandCircles();
14073 $$.expandBarTypeShapes(!1);
14074 },
14075
14076 /**
14077 * Create eventRect for each data on the x-axis.
14078 * Register touch and drag events.
14079 * @param {object} eventRectEnter d3.select(CLASS.eventRects) object.
14080 * @returns {object} d3.select(CLASS.eventRects) object.
14081 * @private
14082 */
14083 generateEventRectsForSingleX: function generateEventRectsForSingleX(eventRectEnter) {
14084 var $$ = this,
14085 config = $$.config,
14086 state = $$.state,
14087 eventReceiver = state.eventReceiver,
14088 rect = eventRectEnter.style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null).on("click", function (event) {
14089 state.event = event;
14090 var _eventReceiver = eventReceiver,
14091 currentIdx = _eventReceiver.currentIdx,
14092 data = _eventReceiver.data,
14093 d = data[currentIdx === -1 ? $$.getDataIndexFromEvent(event) : currentIdx];
14094 $$.clickHandlerForSingleX.bind(this)(d, $$);
14095 });
14096
14097 if (state.inputType === "mouse") {
14098 var getData = function (event) {
14099 var index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
14100 return index > -1 ? eventReceiver.data[index] : null;
14101 };
14102
14103 rect.on("mouseover", function (event) {
14104 state.event = event;
14105 $$.updateEventRect();
14106 }).on("mousemove", function (event) {
14107 var d = getData(event);
14108 state.event = event;
14109
14110 if (!d) {
14111 return;
14112 }
14113
14114 var index = d.index,
14115 stepType = config.line_step_type;
14116
14117 // tooltip position match for step-before & step-after
14118 if (config.line_step_tooltipMatch && $$.hasType("step") && /^step\-(before|after)$/.test(stepType)) {
14119 var scale = $$.scale.zoom || $$.scale.x,
14120 xs = $$.axis.xs[index],
14121 inverted = scale.invert(getPointer(event, this)[0]);
14122
14123 if (stepType === "step-after" && inverted < xs) {
14124 index -= 1;
14125 } else if (stepType === "step-before" && inverted > xs) {
14126 index += 1;
14127 }
14128 } // do nothing while dragging/flowing
14129
14130
14131 if (state.dragging || state.flowing || $$.hasArcType() || config.tooltip_grouped && index === eventReceiver.currentIdx) {
14132 return;
14133 }
14134
14135 if (index !== eventReceiver.currentIdx) {
14136 $$.setOverOut(!1, eventReceiver.currentIdx);
14137 eventReceiver.currentIdx = index;
14138 }
14139
14140 index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, rect, index); // As of individual data point(or <path>) element can't bind mouseover/out event
14141 // to determine current interacting element, so use 'mousemove' event instead.
14142
14143 $$.setOverOut(index !== -1, index);
14144 }).on("mouseout", function (event) {
14145 state.event = event; // chart is destroyed
14146
14147 if (!config || $$.hasArcType() || eventReceiver.currentIdx === -1) {
14148 return;
14149 }
14150
14151 $$.unselectRect();
14152 $$.setOverOut(!1, eventReceiver.currentIdx); // reset the event current index
14153
14154 eventReceiver.currentIdx = -1;
14155 });
14156 }
14157
14158 return rect;
14159 },
14160 clickHandlerForSingleX: function clickHandlerForSingleX(d, ctx) {
14161 var $$ = ctx,
14162 config = $$.config,
14163 state = $$.state,
14164 main = $$.$el.main;
14165
14166 if (!d || $$.hasArcType() || state.cancelClick) {
14167 state.cancelClick && (state.cancelClick = !1);
14168 return;
14169 }
14170
14171 var index = d.index;
14172 main.selectAll("." + config_classes.shape + "-" + index).each(function (d2) {
14173 if (config.data_selection_grouped || $$.isWithinShape(this, d2)) {
14174 $$.toggleShape == null ? void 0 : $$.toggleShape(this, d2, index);
14175 config.data_onclick.bind($$.api)(d2, this);
14176 }
14177 });
14178 },
14179
14180 /**
14181 * Create an eventRect,
14182 * Register touch and drag events.
14183 * @param {object} eventRectEnter d3.select(CLASS.eventRects) object.
14184 * @private
14185 */
14186 generateEventRectsForMultipleXs: function generateEventRectsForMultipleXs(eventRectEnter) {
14187 var $$ = this,
14188 state = $$.state;
14189 eventRectEnter.on("click", function (event) {
14190 state.event = event;
14191 $$.clickHandlerForMultipleXS.bind(this)($$);
14192 });
14193
14194 if (state.inputType === "mouse") {
14195 eventRectEnter.on("mouseover mousemove", function (event) {
14196 state.event = event;
14197 $$.selectRectForMultipleXs(this);
14198 }).on("mouseout", function (event) {
14199 state.event = event; // chart is destroyed
14200
14201 if (!$$.config || $$.hasArcType()) {
14202 return;
14203 }
14204
14205 $$.unselectRect();
14206 });
14207 }
14208 },
14209 clickHandlerForMultipleXS: function clickHandlerForMultipleXS(ctx) {
14210 var $$ = ctx,
14211 config = $$.config,
14212 state = $$.state,
14213 targetsToShow = $$.filterTargetsToShow($$.data.targets);
14214
14215 if ($$.hasArcType(targetsToShow)) {
14216 return;
14217 }
14218
14219 var mouse = getPointer(state.event, this),
14220 closest = $$.findClosestFromTargets(targetsToShow, mouse);
14221
14222 if (!closest) {
14223 return;
14224 } // select if selection enabled
14225
14226
14227 if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
14228 $$.$el.main.selectAll("." + config_classes.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll("." + config_classes.shape + "-" + closest.index).each(function () {
14229 if (config.data_selection_grouped || $$.isWithinShape(this, closest)) {
14230 $$.toggleShape == null ? void 0 : $$.toggleShape(this, closest, closest.index);
14231 config.data_onclick.bind($$.api)(closest, this);
14232 }
14233 });
14234 }
14235 }
14236});
14237// EXTERNAL MODULE: external {"commonjs":"d3-ease","commonjs2":"d3-ease","amd":"d3-ease","root":"d3"}
14238var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack_require__(11);
14239;// CONCATENATED MODULE: ./src/ChartInternal/interactions/flow.ts
14240/**
14241 * Copyright (c) 2017 ~ present NAVER Corp.
14242 * billboard.js project is licensed under the MIT license
14243 */
14244
14245
14246
14247
14248/* harmony default export */ var interactions_flow = ({
14249 /**
14250 * Generate flow
14251 * @param {object} args option object
14252 * @returns {Function}
14253 * @private
14254 */
14255 generateFlow: function generateFlow(args) {
14256 var $$ = this,
14257 data = $$.data,
14258 state = $$.state,
14259 $el = $$.$el;
14260 return function () {
14261 var flowLength = args.flow.length; // set flag
14262
14263 state.flowing = !0; // remove head data after rendered
14264
14265 data.targets.forEach(function (d) {
14266 d.values.splice(0, flowLength);
14267 }); // update elements related to x scale
14268
14269 if ($$.updateXGrid) {
14270 $$.updateXGrid(!0);
14271 } // target elements
14272
14273
14274 var elements = {};
14275 ["axis.x", "grid.x", "gridLines.x", "region.list", "text", "bar", "line", "area", "circle"].forEach(function (v) {
14276 var _node,
14277 name = v.split("."),
14278 node = $el[name[0]];
14279
14280 if (node && name.length > 1) {
14281 node = node[name[1]];
14282 }
14283
14284 if ((_node = node) != null && _node.size()) {
14285 elements[v] = node;
14286 }
14287 });
14288 $$.hideGridFocus();
14289 $$.setFlowList(elements, args);
14290 };
14291 },
14292
14293 /**
14294 * Set flow list
14295 * @param {object} elements Target elements
14296 * @param {object} args option object
14297 * @private
14298 */
14299 setFlowList: function setFlowList(elements, args) {
14300 var $$ = this,
14301 flow = args.flow,
14302 targets = args.targets,
14303 _flow = flow,
14304 _flow$duration = _flow.duration,
14305 duration = _flow$duration === void 0 ? args.duration : _flow$duration,
14306 flowIndex = _flow.index,
14307 flowLength = _flow.length,
14308 orgDataCount = _flow.orgDataCount,
14309 transform = $$.getFlowTransform(targets, orgDataCount, flowIndex, flowLength),
14310 wait = generateWait(),
14311 n;
14312 wait.add(Object.keys(elements).map(function (v) {
14313 n = elements[v].transition().ease(external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_.easeLinear).duration(duration);
14314
14315 if (v === "axis.x") {
14316 n = n.call(function (g) {
14317 $$.axis.x.setTransition(g).create(g);
14318 });
14319 } else if (v === "region.list") {
14320 n = n.filter($$.isRegionOnX).attr("transform", transform);
14321 } else {
14322 n = n.attr("transform", transform);
14323 }
14324
14325 return n;
14326 }));
14327 n.call(wait, function () {
14328 $$.cleanUpFlow(elements, args);
14329 });
14330 },
14331
14332 /**
14333 * Clean up flow
14334 * @param {object} elements Target elements
14335 * @param {object} args option object
14336 * @private
14337 */
14338 cleanUpFlow: function cleanUpFlow(elements, args) {
14339 var $$ = this,
14340 config = $$.config,
14341 state = $$.state,
14342 svg = $$.$el.svg,
14343 isRotated = config.axis_rotated,
14344 flow = args.flow,
14345 shape = args.shape,
14346 xv = args.xv,
14347 _shape$pos = shape.pos,
14348 cx = _shape$pos.cx,
14349 cy = _shape$pos.cy,
14350 xForText = _shape$pos.xForText,
14351 yForText = _shape$pos.yForText,
14352 _flow2 = flow,
14353 _flow2$done = _flow2.done,
14354 done = _flow2$done === void 0 ? function () {} : _flow2$done,
14355 flowLength = _flow2.length;
14356
14357 // Remove flowed elements
14358 if (flowLength) {
14359 ["circle", "text", "shape", "eventRect"].forEach(function (v) {
14360 var target = [];
14361
14362 for (var i = 0; i < flowLength; i++) {
14363 target.push("." + config_classes[v] + "-" + i);
14364 }
14365
14366 svg.selectAll("." + config_classes[v + "s"]) // circles, shapes, texts, eventRects
14367 .selectAll(target).remove();
14368 });
14369 svg.select("." + config_classes.xgrid).remove();
14370 } // draw again for removing flowed elements and reverting attr
14371
14372
14373 Object.keys(elements).forEach(function (v) {
14374 var n = elements[v];
14375
14376 if (v !== "axis.x") {
14377 n.attr("transform", null);
14378 }
14379
14380 if (v === "grid.x") {
14381 n.attr(state.xgridAttr);
14382 } else if (v === "gridLines.x") {
14383 n.attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);
14384 } else if (v === "gridLines.x") {
14385 n.select("line").attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);
14386 n.select("text").attr("x", isRotated ? state.width : 0).attr("y", xv);
14387 } else if (/^(area|bar|line)$/.test(v)) {
14388 n.attr("d", shape.type[v]);
14389 } else if (v === "text") {
14390 n.attr("x", xForText).attr("y", yForText).style("fill-opacity", $$.opacityForText.bind($$));
14391 } else if (v === "circle") {
14392 if ($$.isCirclePoint()) {
14393 n.attr("cx", cx).attr("cy", cy);
14394 } else {
14395 var xFunc = function (d) {
14396 return cx(d) - config.point_r;
14397 },
14398 yFunc = function (d) {
14399 return cy(d) - config.point_r;
14400 };
14401
14402 n.attr("x", xFunc).attr("y", yFunc).attr("cx", cx) // when pattern is used, it possibly contain 'circle' also.
14403 .attr("cy", cy);
14404 }
14405 } else if (v === "region.list") {
14406 n.select("rect").filter($$.isRegionOnX).attr("x", $$.regionX.bind($$)).attr("width", $$.regionWidth.bind($$));
14407 }
14408 });
14409 config.interaction_enabled && $$.redrawEventRect(); // callback for end of flow
14410
14411 done.call($$.api);
14412 state.flowing = !1;
14413 },
14414
14415 /**
14416 * Get flow transform value
14417 * @param {object} targets target
14418 * @param {number} orgDataCount original data count
14419 * @param {number} flowIndex flow index
14420 * @param {number} flowLength flow length
14421 * @returns {string}
14422 * @private
14423 */
14424 getFlowTransform: function getFlowTransform(targets, orgDataCount, flowIndex, flowLength) {
14425 var _flowStart,
14426 _flowEnd,
14427 $$ = this,
14428 data = $$.data,
14429 x = $$.scale.x,
14430 dataValues = data.targets[0].values,
14431 flowStart = $$.getValueOnIndex(dataValues, flowIndex),
14432 flowEnd = $$.getValueOnIndex(dataValues, flowIndex + flowLength),
14433 translateX,
14434 orgDomain = x.domain(),
14435 domain = $$.updateXDomain(targets, !0, !0);
14436
14437 // generate transform to flow
14438 if (!orgDataCount) {
14439 // if empty
14440 if (dataValues.length !== 1) {
14441 translateX = x(orgDomain[0]) - x(domain[0]);
14442 } else {
14443 if ($$.axis.isTimeSeries()) {
14444 flowStart = $$.getValueOnIndex(dataValues, 0);
14445 flowEnd = $$.getValueOnIndex(dataValues, dataValues.length - 1);
14446 translateX = x(flowStart.x) - x(flowEnd.x);
14447 } else {
14448 translateX = diffDomain(domain) / 2;
14449 }
14450 }
14451 } else if (orgDataCount === 1 || ((_flowStart = flowStart) == null ? void 0 : _flowStart.x) === ((_flowEnd = flowEnd) == null ? void 0 : _flowEnd.x)) {
14452 translateX = x(orgDomain[0]) - x(domain[0]);
14453 } else {
14454 translateX = $$.axis.isTimeSeries() ? x(orgDomain[0]) - x(domain[0]) : x(flowStart.x) - x(flowEnd.x);
14455 }
14456
14457 var scaleX = diffDomain(orgDomain) / diffDomain(domain);
14458 return "translate(" + translateX + ",0) scale(" + scaleX + ",1)";
14459 }
14460});
14461;// CONCATENATED MODULE: ./src/ChartInternal/internals/clip.ts
14462/**
14463 * Copyright (c) 2017 ~ present NAVER Corp.
14464 * billboard.js project is licensed under the MIT license
14465 */
14466
14467/* harmony default export */ var clip = ({
14468 initClip: function initClip() {
14469 var $$ = this,
14470 clip = $$.state.clip;
14471 // MEMO: clipId needs to be unique because it conflicts when multiple charts exist
14472 clip.id = $$.state.datetimeId + "-clip";
14473 clip.idXAxis = clip.id + "-xaxis";
14474 clip.idYAxis = clip.id + "-yaxis";
14475 clip.idGrid = clip.id + "-grid"; // Define 'clip-path' attribute values
14476
14477 clip.path = $$.getClipPath(clip.id);
14478 clip.pathXAxis = $$.getClipPath(clip.idXAxis);
14479 clip.pathYAxis = $$.getClipPath(clip.idYAxis);
14480 clip.pathGrid = $$.getClipPath(clip.idGrid);
14481 },
14482 getClipPath: function getClipPath(id) {
14483 var $$ = this,
14484 config = $$.config;
14485
14486 if (!config.clipPath && /-clip$/.test(id) || !config.axis_x_clipPath && /-clip-xaxis$/.test(id) || !config.axis_y_clipPath && /-clip-yaxis$/.test(id)) {
14487 return null;
14488 }
14489
14490 var isIE9 = win.navigator ? win.navigator.appVersion.toLowerCase().indexOf("msie 9.") >= 0 : !1;
14491 return "url(" + (isIE9 ? "" : browser_doc.URL.split("#")[0]) + "#" + id + ")";
14492 },
14493 appendClip: function appendClip(parent, id) {
14494 id && parent.append("clipPath").attr("id", id).append("rect");
14495 },
14496
14497 /**
14498 * Set x Axis clipPath dimension
14499 * @param {d3Selecton} node clipPath <rect> selection
14500 * @private
14501 */
14502 setXAxisClipPath: function setXAxisClipPath(node) {
14503 var $$ = this,
14504 config = $$.config,
14505 _$$$state = $$.state,
14506 margin = _$$$state.margin,
14507 width = _$$$state.width,
14508 height = _$$$state.height,
14509 isRotated = config.axis_rotated,
14510 left = Math.max(30, margin.left) - (isRotated ? 0 : 20),
14511 x = isRotated ? -(1 + left) : -(left - 1),
14512 y = -Math.max(15, margin.top),
14513 w = isRotated ? margin.left + 20 : width + 10 + left,
14514 h = (isRotated ? margin.top + height + 10 : margin.bottom) + 20;
14515 node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
14516 },
14517
14518 /**
14519 * Set y Axis clipPath dimension
14520 * @param {d3Selecton} node clipPath <rect> selection
14521 * @private
14522 */
14523 setYAxisClipPath: function setYAxisClipPath(node) {
14524 var $$ = this,
14525 config = $$.config,
14526 _$$$state2 = $$.state,
14527 margin = _$$$state2.margin,
14528 width = _$$$state2.width,
14529 height = _$$$state2.height,
14530 isRotated = config.axis_rotated,
14531 left = Math.max(30, margin.left) - (isRotated ? 20 : 0),
14532 isInner = config.axis_y_inner,
14533 x = isInner ? -1 : isRotated ? -(1 + left) : -(left - 1),
14534 y = -(isRotated ? 20 : margin.top),
14535 w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0),
14536 h = (isRotated ? margin.bottom : margin.top + height) + 10;
14537 node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
14538 },
14539 updateXAxisTickClip: function updateXAxisTickClip() {
14540 var $$ = this,
14541 config = $$.config,
14542 _$$$state3 = $$.state,
14543 clip = _$$$state3.clip,
14544 xAxisHeight = _$$$state3.xAxisHeight,
14545 defs = $$.$el.defs,
14546 newXAxisHeight = $$.getHorizontalAxisHeight("x");
14547
14548 if (defs && !clip.idXAxisTickTexts) {
14549 var clipId = clip.id + "-xaxisticktexts";
14550 $$.appendClip(defs, clipId);
14551 clip.pathXAxisTickTexts = $$.getClipPath(clip.idXAxisTickTexts);
14552 clip.idXAxisTickTexts = clipId;
14553 }
14554
14555 if (!config.axis_x_tick_multiline && $$.getAxisTickRotate("x") && newXAxisHeight !== xAxisHeight) {
14556 $$.setXAxisTickClipWidth();
14557 $$.setXAxisTickTextClipPathWidth();
14558 }
14559
14560 $$.state.xAxisHeight = newXAxisHeight;
14561 },
14562 setXAxisTickClipWidth: function setXAxisTickClipWidth() {
14563 var $$ = this,
14564 config = $$.config,
14565 maxTickWidths = $$.state.current.maxTickWidths,
14566 xAxisTickRotate = $$.getAxisTickRotate("x");
14567
14568 if (!config.axis_x_tick_multiline && xAxisTickRotate) {
14569 var sinRotation = Math.sin(Math.PI / 180 * Math.abs(xAxisTickRotate));
14570 maxTickWidths.x.clipPath = ($$.getHorizontalAxisHeight("x") - 20) / sinRotation;
14571 } else {
14572 maxTickWidths.x.clipPath = null;
14573 }
14574 },
14575 setXAxisTickTextClipPathWidth: function setXAxisTickTextClipPathWidth() {
14576 var $$ = this,
14577 _$$$state4 = $$.state,
14578 clip = _$$$state4.clip,
14579 current = _$$$state4.current,
14580 svg = $$.$el.svg;
14581
14582 if (svg) {
14583 svg.select("#" + clip.idXAxisTickTexts + " rect").attr("width", current.maxTickWidths.x.clipPath).attr("height", 30);
14584 }
14585 }
14586});
14587;// CONCATENATED MODULE: ./src/ChartInternal/internals/grid.ts
14588/**
14589 * Copyright (c) 2017 ~ present NAVER Corp.
14590 * billboard.js project is licensed under the MIT license
14591 */
14592
14593
14594 // Grid position and text anchor helpers
14595
14596var getGridTextAnchor = function (d) {
14597 return isValue(d.position) || "end";
14598},
14599 getGridTextDx = function (d) {
14600 return d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
14601};
14602
14603/**
14604 * Get grid text x value getter function
14605 * @param {boolean} isX Is x Axis
14606 * @param {number} width Width value
14607 * @param {number} height Height value
14608 * @returns {Function}
14609 * @private
14610 */
14611function getGridTextX(isX, width, height) {
14612 return function (d) {
14613 var x = isX ? 0 : width;
14614
14615 if (d.position === "start") {
14616 x = isX ? -height : 0;
14617 } else if (d.position === "middle") {
14618 x = (isX ? -height : width) / 2;
14619 }
14620
14621 return x;
14622 };
14623}
14624/**
14625 * Update coordinate attributes value
14626 * @param {d3.selection} el Target node
14627 * @param {string} type Type
14628 * @private
14629 */
14630
14631
14632function smoothLines(el, type) {
14633 if (type === "grid") {
14634 el.each(function () {
14635 var g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
14636 ["x1", "x2", "y1", "y2"].forEach(function (v) {
14637 return g.attr(v, Math.ceil(+g.attr(v)));
14638 });
14639 });
14640 }
14641}
14642
14643/* harmony default export */ var grid = ({
14644 hasGrid: function hasGrid() {
14645 var config = this.config;
14646 return ["x", "y"].some(function (v) {
14647 return config["grid_" + v + "_show"] || config["grid_" + v + "_lines"].length;
14648 });
14649 },
14650 initGrid: function initGrid() {
14651 var $$ = this;
14652 $$.hasGrid() && $$.initGridLines();
14653 $$.initFocusGrid();
14654 },
14655 initGridLines: function initGridLines() {
14656 var $$ = this,
14657 config = $$.config,
14658 clip = $$.state.clip,
14659 $el = $$.$el;
14660
14661 if (config.grid_x_lines.length || config.grid_y_lines.length) {
14662 $el.gridLines.main = $el.main.insert("g", "." + config_classes.chart + (config.grid_lines_front ? " + *" : "")).attr("clip-path", clip.pathGrid).attr("class", config_classes.grid + " " + config_classes.gridLines);
14663 $el.gridLines.main.append("g").attr("class", config_classes.xgridLines);
14664 $el.gridLines.main.append("g").attr("class", config_classes.ygridLines);
14665 $el.gridLines.x = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([]);
14666 }
14667 },
14668 updateXGrid: function updateXGrid(withoutUpdate) {
14669 var $$ = this,
14670 config = $$.config,
14671 scale = $$.scale,
14672 state = $$.state,
14673 _$$$$el = $$.$el,
14674 main = _$$$$el.main,
14675 grid = _$$$$el.grid,
14676 isRotated = config.axis_rotated,
14677 xgridData = $$.generateGridData(config.grid_x_type, scale.x),
14678 tickOffset = $$.axis.isCategorized() ? $$.axis.x.tickOffset() : 0,
14679 pos = function (d) {
14680 return (scale.zoom || scale.x)(d) + tickOffset * (isRotated ? -1 : 1);
14681 };
14682
14683 state.xgridAttr = isRotated ? {
14684 "x1": 0,
14685 "x2": state.width,
14686 "y1": pos,
14687 "y2": pos
14688 } : {
14689 "x1": pos,
14690 "x2": pos,
14691 "y1": 0,
14692 "y2": state.height
14693 };
14694 grid.x = main.select("." + config_classes.xgrids).selectAll("." + config_classes.xgrid).data(xgridData);
14695 grid.x.exit().remove();
14696 grid.x = grid.x.enter().append("line").attr("class", config_classes.xgrid).merge(grid.x);
14697
14698 if (!withoutUpdate) {
14699 grid.x.each(function () {
14700 var grid = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
14701 Object.keys(state.xgridAttr).forEach(function (id) {
14702 grid.attr(id, state.xgridAttr[id]).style("opacity", function () {
14703 return grid.attr(isRotated ? "y1" : "x1") === (isRotated ? state.height : 0) ? "0" : null;
14704 });
14705 });
14706 });
14707 }
14708 },
14709 updateYGrid: function updateYGrid() {
14710 var $$ = this,
14711 config = $$.config,
14712 state = $$.state,
14713 _$$$$el2 = $$.$el,
14714 grid = _$$$$el2.grid,
14715 main = _$$$$el2.main,
14716 isRotated = config.axis_rotated,
14717 gridValues = $$.axis.y.tickValues() || $$.scale.y.ticks(config.grid_y_ticks),
14718 pos = function (d) {
14719 return Math.ceil($$.scale.y(d));
14720 };
14721
14722 grid.y = main.select("." + config_classes.ygrids).selectAll("." + config_classes.ygrid).data(gridValues);
14723 grid.y.exit().remove();
14724 grid.y = grid.y.enter().append("line").attr("class", config_classes.ygrid).merge(grid.y);
14725 grid.y.attr("x1", isRotated ? pos : 0).attr("x2", isRotated ? pos : state.width).attr("y1", isRotated ? 0 : pos).attr("y2", isRotated ? state.height : pos);
14726 smoothLines(grid.y, "grid");
14727 },
14728 updateGrid: function updateGrid() {
14729 var $$ = this,
14730 _$$$$el3 = $$.$el,
14731 grid = _$$$$el3.grid,
14732 gridLines = _$$$$el3.gridLines;
14733 gridLines.main || $$.initGridLines(); // hide if arc type
14734
14735 grid.main.style("visibility", $$.hasArcType() ? "hidden" : null);
14736 $$.hideGridFocus();
14737 $$.updateXGridLines();
14738 $$.updateYGridLines();
14739 },
14740
14741 /**
14742 * Update X Grid lines
14743 * @private
14744 */
14745 updateXGridLines: function updateXGridLines() {
14746 var $$ = this,
14747 config = $$.config,
14748 _$$$$el4 = $$.$el,
14749 gridLines = _$$$$el4.gridLines,
14750 main = _$$$$el4.main,
14751 $T = $$.$T,
14752 isRotated = config.axis_rotated;
14753 config.grid_x_show && $$.updateXGrid();
14754 var xLines = main.select("." + config_classes.xgridLines).selectAll("." + config_classes.xgridLine).data(config.grid_x_lines); // exit
14755
14756 $T(xLines.exit()).style("opacity", "0").remove(); // enter
14757
14758 var xgridLine = xLines.enter().append("g");
14759 xgridLine.append("line").style("opacity", "0");
14760 xgridLine.append("text").attr("transform", isRotated ? "" : "rotate(-90)").attr("dy", -5).style("opacity", "0");
14761 xLines = xgridLine.merge(xLines);
14762 $T(xLines.attr("class", function (d) {
14763 return (config_classes.xgridLine + " " + (d.class || "")).trim();
14764 }).select("text").attr("text-anchor", getGridTextAnchor).attr("dx", getGridTextDx)).text(function (d) {
14765 return d.text;
14766 }).style("opacity", null);
14767 gridLines.x = xLines;
14768 },
14769
14770 /**
14771 * Update Y Grid lines
14772 * @private
14773 */
14774 updateYGridLines: function updateYGridLines() {
14775 var $$ = this,
14776 config = $$.config,
14777 _$$$state = $$.state,
14778 width = _$$$state.width,
14779 height = _$$$state.height,
14780 $el = $$.$el,
14781 $T = $$.$T,
14782 isRotated = config.axis_rotated;
14783 config.grid_y_show && $$.updateYGrid();
14784 var ygridLines = $el.main.select("." + config_classes.ygridLines).selectAll("." + config_classes.ygridLine).data(config.grid_y_lines); // exit
14785
14786 $T(ygridLines.exit()).style("opacity", "0").remove(); // enter
14787
14788 var ygridLine = ygridLines.enter().append("g");
14789 ygridLine.append("line").style("opacity", "0");
14790 ygridLine.append("text").attr("transform", isRotated ? "rotate(-90)" : "").style("opacity", "0");
14791 ygridLines = ygridLine.merge(ygridLines); // update
14792
14793 var yv = $$.yv.bind($$);
14794 $T(ygridLines.attr("class", function (d) {
14795 return (config_classes.ygridLine + " " + (d.class || "")).trim();
14796 }).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);
14797 $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) {
14798 return d.text;
14799 }).style("opacity", null);
14800 $el.gridLines.y = ygridLines;
14801 },
14802 redrawGrid: function redrawGrid(withTransition) {
14803 var $$ = this,
14804 isRotated = $$.config.axis_rotated,
14805 _$$$state2 = $$.state,
14806 width = _$$$state2.width,
14807 height = _$$$state2.height,
14808 gridLines = $$.$el.gridLines,
14809 $T = $$.$T,
14810 xv = $$.xv.bind($$),
14811 lines = gridLines.x.select("line"),
14812 texts = gridLines.x.select("text");
14813 lines = $T(lines, withTransition).attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? width : xv).attr("y1", isRotated ? xv : 0).attr("y2", isRotated ? xv : height);
14814 texts = $T(texts, withTransition).attr("x", getGridTextX(!isRotated, width, height)).attr("y", xv).text(function (d) {
14815 return d.text;
14816 });
14817 return [lines.style("opacity", null), texts.style("opacity", null)];
14818 },
14819 initFocusGrid: function initFocusGrid() {
14820 var $$ = this,
14821 config = $$.config,
14822 clip = $$.state.clip,
14823 $el = $$.$el,
14824 isFront = config.grid_front,
14825 className = "." + config_classes[isFront && $el.gridLines.main ? "gridLines" : "chart"] + (isFront ? " + *" : ""),
14826 grid = $el.main.insert("g", className).attr("clip-path", clip.pathGrid).attr("class", config_classes.grid);
14827 $el.grid.main = grid;
14828 config.grid_x_show && grid.append("g").attr("class", config_classes.xgrids);
14829 config.grid_y_show && grid.append("g").attr("class", config_classes.ygrids);
14830
14831 if (config.interaction_enabled && config.grid_focus_show) {
14832 grid.append("g").attr("class", config_classes.xgridFocus).append("line").attr("class", config_classes.xgridFocus); // to show xy focus grid line, should be 'tooltip.grouped=false'
14833
14834 if (config.grid_focus_y && !config.tooltip_grouped) {
14835 grid.append("g").attr("class", config_classes.ygridFocus).append("line").attr("class", config_classes.ygridFocus);
14836 }
14837 }
14838 },
14839
14840 /**
14841 * Show grid focus line
14842 * @param {Array} data Selected data
14843 * @private
14844 */
14845 showGridFocus: function showGridFocus(data) {
14846 var $$ = this,
14847 config = $$.config,
14848 _$$$state3 = $$.state,
14849 width = _$$$state3.width,
14850 height = _$$$state3.height,
14851 isRotated = config.axis_rotated,
14852 focusEl = $$.$el.main.selectAll("line." + config_classes.xgridFocus + ", line." + config_classes.ygridFocus),
14853 dataToShow = (data || [focusEl.datum()]).filter(function (d) {
14854 return d && isValue($$.getBaseValue(d));
14855 });
14856
14857 // Hide when bubble/scatter/stanford plot exists
14858 if (!config.tooltip_show || dataToShow.length === 0 || $$.hasType("bubble") || $$.hasArcType()) {
14859 return;
14860 }
14861
14862 var isEdge = config.grid_focus_edge && !config.tooltip_grouped,
14863 xx = $$.xx.bind($$);
14864 focusEl.style("visibility", null).data(dataToShow.concat(dataToShow)).each(function (d) {
14865 var el = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
14866 pos = {
14867 x: xx(d),
14868 y: $$.getYScaleById(d.id)(d.value)
14869 },
14870 xy;
14871
14872 if (el.classed(config_classes.xgridFocus)) {
14873 // will contain 'x1, y1, x2, y2' order
14874 xy = isRotated ? [null, // x1
14875 pos.x, // y1
14876 isEdge ? pos.y : width, // x2
14877 pos.x // y2
14878 ] : [pos.x, isEdge ? pos.y : null, pos.x, height];
14879 } else {
14880 var isY2 = $$.axis.getId(d.id) === "y2";
14881 xy = isRotated ? [pos.y, // x1
14882 isEdge && !isY2 ? pos.x : null, // y1
14883 pos.y, // x2
14884 isEdge && isY2 ? pos.x : height // y2
14885 ] : [isEdge && isY2 ? pos.x : null, pos.y, isEdge && !isY2 ? pos.x : width, pos.y];
14886 }
14887
14888 ["x1", "y1", "x2", "y2"].forEach(function (v, i) {
14889 return el.attr(v, xy[i]);
14890 });
14891 });
14892 smoothLines(focusEl, "grid");
14893 $$.showCircleFocus == null ? void 0 : $$.showCircleFocus(data);
14894 },
14895 hideGridFocus: function hideGridFocus() {
14896 var $$ = this,
14897 _$$$state4 = $$.state,
14898 inputType = _$$$state4.inputType,
14899 resizing = _$$$state4.resizing,
14900 main = $$.$el.main;
14901
14902 if (inputType === "mouse" || !resizing) {
14903 main.selectAll("line." + config_classes.xgridFocus + ", line." + config_classes.ygridFocus).style("visibility", "hidden");
14904 $$.hideCircleFocus == null ? void 0 : $$.hideCircleFocus();
14905 }
14906 },
14907 updateGridFocus: function updateGridFocus() {
14908 var $$ = this,
14909 _$$$state5 = $$.state,
14910 inputType = _$$$state5.inputType,
14911 width = _$$$state5.width,
14912 height = _$$$state5.height,
14913 resizing = _$$$state5.resizing,
14914 grid = $$.$el.grid,
14915 xgridFocus = grid.main.select("line." + config_classes.xgridFocus);
14916
14917 if (inputType === "touch") {
14918 if (xgridFocus.empty()) {
14919 resizing && ($$.showCircleFocus == null ? void 0 : $$.showCircleFocus());
14920 } else {
14921 $$.showGridFocus();
14922 }
14923 } else {
14924 var _isRotated = $$.config.axis_rotated;
14925 xgridFocus.attr("x1", _isRotated ? 0 : -10).attr("x2", _isRotated ? width : -10).attr("y1", _isRotated ? -10 : 0).attr("y2", _isRotated ? -10 : height);
14926 } // need to return 'true' as of being pushed to the redraw list
14927 // ref: getRedrawList()
14928
14929
14930 return !0;
14931 },
14932 generateGridData: function generateGridData(type, scale) {
14933 var $$ = this,
14934 tickNum = $$.$el.main.select("." + config_classes.axisX).selectAll(".tick").size(),
14935 gridData = [];
14936
14937 if (type === "year") {
14938 var xDomain = $$.getXDomain(),
14939 _xDomain$map = xDomain.map(function (v) {
14940 return v.getFullYear();
14941 }),
14942 firstYear = _xDomain$map[0],
14943 lastYear = _xDomain$map[1];
14944
14945 for (var i = firstYear; i <= lastYear; i++) {
14946 gridData.push(new Date(i + "-01-01 00:00:00"));
14947 }
14948 } else {
14949 gridData = scale.ticks(10);
14950
14951 if (gridData.length > tickNum) {
14952 // use only int
14953 gridData = gridData.filter(function (d) {
14954 return (d + "").indexOf(".") < 0;
14955 });
14956 }
14957 }
14958
14959 return gridData;
14960 },
14961 getGridFilterToRemove: function getGridFilterToRemove(params) {
14962 return params ? function (line) {
14963 var found = !1;
14964 (isArray(params) ? params.concat() : [params]).forEach(function (param) {
14965 if ("value" in param && line.value === param.value || "class" in param && line.class === param.class) {
14966 found = !0;
14967 }
14968 });
14969 return found;
14970 } : function () {
14971 return !0;
14972 };
14973 },
14974 removeGridLines: function removeGridLines(params, forX) {
14975 var $$ = this,
14976 config = $$.config,
14977 $T = $$.$T,
14978 toRemove = $$.getGridFilterToRemove(params),
14979 classLines = forX ? config_classes.xgridLines : config_classes.ygridLines,
14980 classLine = forX ? config_classes.xgridLine : config_classes.ygridLine;
14981 $T($$.$el.main.select("." + classLines).selectAll("." + classLine).filter(toRemove)).style("opacity", "0").remove();
14982 var gridLines = "grid_" + (forX ? "x" : "y") + "_lines";
14983 config[gridLines] = config[gridLines].filter(function toShow(line) {
14984 return !toRemove(line);
14985 });
14986 }
14987});
14988;// CONCATENATED MODULE: ./src/ChartInternal/internals/region.ts
14989/**
14990 * Copyright (c) 2017 ~ present NAVER Corp.
14991 * billboard.js project is licensed under the MIT license
14992 */
14993 // selection
14994
14995
14996
14997/* harmony default export */ var region = ({
14998 initRegion: function initRegion() {
14999 var $$ = this,
15000 $el = $$.$el;
15001 $el.region.main = $el.main.insert("g", ":first-child").attr("clip-path", $$.state.clip.path).attr("class", config_classes.regions);
15002 },
15003 updateRegion: function updateRegion() {
15004 var $$ = this,
15005 config = $$.config,
15006 region = $$.$el.region,
15007 $T = $$.$T;
15008
15009 if (!region.main) {
15010 $$.initRegion();
15011 } // hide if arc type
15012
15013
15014 region.main.style("visibility", $$.hasArcType() ? "hidden" : null); // select <g> element
15015
15016 var list = region.main.selectAll("." + config_classes.region).data(config.regions);
15017 $T(list.exit()).style("opacity", "0").remove();
15018 list = list.enter().append("g").merge(list).attr("class", $$.classRegion.bind($$));
15019 list.append("rect").style("fill-opacity", "0");
15020 region.list = list;
15021 },
15022 redrawRegion: function redrawRegion(withTransition) {
15023 var $$ = this,
15024 region = $$.$el.region,
15025 $T = $$.$T,
15026 regions = region.list.select("rect");
15027 regions = $T(regions, withTransition).attr("x", $$.regionX.bind($$)).attr("y", $$.regionY.bind($$)).attr("width", $$.regionWidth.bind($$)).attr("height", $$.regionHeight.bind($$));
15028 return [regions.style("fill-opacity", function (d) {
15029 return isValue(d.opacity) ? d.opacity : null;
15030 }).on("end", function () {
15031 // remove unnecessary rect after transition
15032 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode).selectAll("rect:not([x])").remove();
15033 })];
15034 },
15035 getRegionXY: function getRegionXY(type, d) {
15036 var $$ = this,
15037 config = $$.config,
15038 scale = $$.scale,
15039 isRotated = config.axis_rotated,
15040 isX = type === "x",
15041 key = "start",
15042 currScale,
15043 pos = 0;
15044
15045 if (d.axis === "y" || d.axis === "y2") {
15046 if (!isX) {
15047 key = "end";
15048 }
15049
15050 if ((isX ? isRotated : !isRotated) && key in d) {
15051 currScale = scale[d.axis];
15052 pos = currScale(d[key]);
15053 }
15054 } else if ((isX ? !isRotated : isRotated) && key in d) {
15055 currScale = scale.zoom || scale.x;
15056 pos = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key]);
15057 }
15058
15059 return pos;
15060 },
15061 regionX: function regionX(d) {
15062 return this.getRegionXY("x", d);
15063 },
15064 regionY: function regionY(d) {
15065 return this.getRegionXY("y", d);
15066 },
15067 getRegionSize: function getRegionSize(type, d) {
15068 var $$ = this,
15069 config = $$.config,
15070 scale = $$.scale,
15071 state = $$.state,
15072 isRotated = config.axis_rotated,
15073 isWidth = type === "width",
15074 start = $$[isWidth ? "regionX" : "regionY"](d),
15075 currScale,
15076 key = "end",
15077 end = state[type];
15078
15079 if (d.axis === "y" || d.axis === "y2") {
15080 if (!isWidth) {
15081 key = "start";
15082 }
15083
15084 if ((isWidth ? isRotated : !isRotated) && key in d) {
15085 currScale = scale[d.axis];
15086 end = currScale(d[key]);
15087 }
15088 } else if ((isWidth ? !isRotated : isRotated) && key in d) {
15089 currScale = scale.zoom || scale.x;
15090 end = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key]);
15091 }
15092
15093 return end < start ? 0 : end - start;
15094 },
15095 regionWidth: function regionWidth(d) {
15096 return this.getRegionSize("width", d);
15097 },
15098 regionHeight: function regionHeight(d) {
15099 return this.getRegionSize("height", d);
15100 },
15101 isRegionOnX: function isRegionOnX(d) {
15102 return !d.axis || d.axis === "x";
15103 }
15104});
15105;// CONCATENATED MODULE: ./src/ChartInternal/internals/size.axis.ts
15106/**
15107 * Copyright (c) 2017 ~ present NAVER Corp.
15108 * billboard.js project is licensed under the MIT license
15109 */
15110/* harmony default export */ var size_axis = ({
15111 /**
15112 * Get Axis size according its position
15113 * @param {string} id Axis id value - x, y or y2
15114 * @returns {number} size Axis size value
15115 * @private
15116 */
15117 getAxisSize: function getAxisSize(id) {
15118 var $$ = this,
15119 isRotated = $$.config.axis_rotated;
15120 return isRotated && id === "x" || !isRotated && /y2?/.test(id) ? $$.getAxisWidthByAxisId(id, !0) : $$.getHorizontalAxisHeight(id);
15121 },
15122 getAxisWidthByAxisId: function getAxisWidthByAxisId(id, withoutRecompute) {
15123 var $$ = this;
15124
15125 if ($$.axis) {
15126 var _$$$axis,
15127 position = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.getLabelPositionById(id);
15128
15129 return $$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40);
15130 } else {
15131 return 40;
15132 }
15133 },
15134 getHorizontalAxisHeight: function getHorizontalAxisHeight(id) {
15135 var $$ = this,
15136 config = $$.config,
15137 state = $$.state,
15138 _state = state,
15139 current = _state.current,
15140 rotatedPadding = _state.rotatedPadding,
15141 isLegendRight = _state.isLegendRight,
15142 isLegendInset = _state.isLegendInset,
15143 isRotated = config.axis_rotated,
15144 h = 30;
15145
15146 if (id === "x" && !config.axis_x_show) {
15147 return 8;
15148 }
15149
15150 if (id === "x" && config.axis_x_height) {
15151 return config.axis_x_height;
15152 }
15153
15154 if (id === "y" && !config.axis_y_show) {
15155 return config.legend_show && !isLegendRight && !isLegendInset ? 10 : 1;
15156 }
15157
15158 if (id === "y2" && !config.axis_y2_show) {
15159 return rotatedPadding.top;
15160 }
15161
15162 var rotate = $$.getAxisTickRotate(id); // Calculate x/y axis height when tick rotated
15163
15164 if ((id === "x" && !isRotated || /y2?/.test(id) && isRotated) && rotate) {
15165 h = 30 + $$.axis.getMaxTickWidth(id) * Math.cos(Math.PI * (90 - Math.abs(rotate)) / 180);
15166
15167 if (!config.axis_x_tick_multiline && current.height) {
15168 if (h > current.height / 2) {
15169 h = current.height / 2;
15170 }
15171 }
15172 }
15173
15174 return h + ($$.axis.getLabelPositionById(id).isInner ? 0 : 10) + (id === "y2" && !isRotated ? -10 : 0);
15175 },
15176 getEventRectWidth: function getEventRectWidth() {
15177 return Math.max(0, this.axis.x.tickInterval());
15178 },
15179
15180 /**
15181 * Get axis tick test rotate value
15182 * @param {string} id Axis id
15183 * @returns {number} rotate value
15184 * @private
15185 */
15186 getAxisTickRotate: function getAxisTickRotate(id) {
15187 var $$ = this,
15188 axis = $$.axis,
15189 config = $$.config,
15190 state = $$.state,
15191 $el = $$.$el,
15192 rotate = config["axis_" + id + "_tick_rotate"];
15193
15194 if (id === "x") {
15195 var allowedXAxisTypes = axis.isCategorized() || axis.isTimeSeries();
15196
15197 if (config.axis_x_tick_fit && allowedXAxisTypes) {
15198 var xTickCount = config.axis_x_tick_count,
15199 currentXTicksLength = state.current.maxTickWidths.x.ticks.length,
15200 tickCount = 0;
15201
15202 if (xTickCount) {
15203 tickCount = xTickCount > currentXTicksLength ? currentXTicksLength : xTickCount;
15204 } else if (currentXTicksLength) {
15205 tickCount = currentXTicksLength;
15206 }
15207
15208 if (tickCount !== state.axis.x.tickCount) {
15209 var targets = $$.data.targets;
15210 state.axis.x.padding = $$.getXDomainPadding([$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")], tickCount);
15211 }
15212
15213 state.axis.x.tickCount = tickCount;
15214 }
15215
15216 if ($el.svg && config.axis_x_tick_fit && !config.axis_x_tick_multiline && !config.axis_x_tick_culling && config.axis_x_tick_autorotate && allowedXAxisTypes) {
15217 rotate = $$.needToRotateXAxisTickTexts() ? config.axis_x_tick_rotate : 0;
15218 }
15219 }
15220
15221 return rotate;
15222 },
15223
15224 /**
15225 * Check weather axis tick text needs to be rotated
15226 * @returns {boolean}
15227 * @private
15228 */
15229 needToRotateXAxisTickTexts: function needToRotateXAxisTickTexts() {
15230 var $$ = this,
15231 _$$$state = $$.state,
15232 axis = _$$$state.axis,
15233 current = _$$$state.current,
15234 xAxisLength = current.width - $$.getCurrentPaddingLeft(!1) - $$.getCurrentPaddingRight(),
15235 tickCountWithPadding = axis.x.tickCount + axis.x.padding.left + axis.x.padding.right,
15236 maxTickWidth = $$.axis.getMaxTickWidth("x"),
15237 tickLength = tickCountWithPadding ? xAxisLength / tickCountWithPadding : 0;
15238 return maxTickWidth > tickLength;
15239 }
15240});
15241;// CONCATENATED MODULE: ./src/config/Options/data/axis.ts
15242/**
15243 * Copyright (c) 2017 ~ present NAVER Corp.
15244 * billboard.js project is licensed under the MIT license
15245 */
15246
15247/**
15248 * Axis based chart data config options
15249 */
15250/* harmony default export */ var data_axis = ({
15251 /**
15252 * Specify the keys of the x values for each data.<br><br>
15253 * This option can be used if we want to show the data that has different x values.
15254 * @name data․xs
15255 * @memberof Options
15256 * @type {object}
15257 * @default {}
15258 * @example
15259 * data: {
15260 * xs: {
15261 * data1: "x1",
15262 * data2: "x2"
15263 * }
15264 * }
15265 */
15266 data_xs: {},
15267
15268 /**
15269 * Set a format specifier to parse string specifed as x.
15270 * @name data․xFormat
15271 * @memberof Options
15272 * @type {string}
15273 * @default %Y-%m-%d
15274 * @example
15275 * data: {
15276 * x: "x",
15277 * columns: [
15278 * ["x", "01012019", "02012019", "03012019"],
15279 * ["data1", 30, 200, 100]
15280 * ],
15281 * // Format specifier to parse as datetime for given 'x' string value
15282 * xFormat: "%m%d%Y"
15283 * },
15284 * axis: {
15285 * x: {
15286 * type: "timeseries"
15287 * }
15288 * }
15289 * @see [D3's time specifier](https://github.com/d3/d3-time-format#locale_format)
15290 */
15291 data_xFormat: "%Y-%m-%d",
15292
15293 /**
15294 * Set localtime format to parse x axis.
15295 * @name data․xLocaltime
15296 * @memberof Options
15297 * @type {boolean}
15298 * @default true
15299 * @example
15300 * data: {
15301 * xLocaltime: false
15302 * }
15303 */
15304 data_xLocaltime: !0,
15305
15306 /**
15307 * Sort on x axis.
15308 * @name data․xSort
15309 * @memberof Options
15310 * @type {boolean}
15311 * @default true
15312 * @example
15313 * data: {
15314 * xSort: false
15315 * }
15316 */
15317 data_xSort: !0,
15318
15319 /**
15320 * Set y axis the data related to. y and y2 can be used.
15321 * - **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
15322 * @name data․axes
15323 * @memberof Options
15324 * @type {object}
15325 * @default {}
15326 * @example
15327 * data: {
15328 * axes: {
15329 * data1: "y",
15330 * data2: "y2"
15331 * }
15332 * }
15333 */
15334 data_axes: {},
15335
15336 /**
15337 * Define regions for each data.<br>
15338 * The values must be an array for each data and it should include an object that has `start`, `end` and `style`.
15339 * - The object type should be as:
15340 * - start {number}: Start data point number. If not set, the start will be the first data point.
15341 * - [end] {number}: End data point number. If not set, the end will be the last data point.
15342 * - [style.dasharray="2 2"] {object}: The first number specifies a distance for the filled area, and the second a distance for the unfilled area.
15343 * - **NOTE:** Currently this option supports only line chart and dashed style. If this option specified, the line will be dashed only in the regions.
15344 * @name data․regions
15345 * @memberof Options
15346 * @type {object}
15347 * @default {}
15348 * @example
15349 * data: {
15350 * regions: {
15351 * data1: [{
15352 * start: 1,
15353 * end: 2,
15354 * style: {
15355 * dasharray: "5 2"
15356 * }
15357 * }, {
15358 * start: 3
15359 * }],
15360 * ...
15361 * }
15362 * }
15363 */
15364 data_regions: {},
15365
15366 /**
15367 * Set the stacking to be normalized
15368 * - **NOTE:**
15369 * - For stacking, '[data.groups](#.data%25E2%2580%25A4groups)' option should be set
15370 * - y Axis will be set in percentage value (0 ~ 100%)
15371 * - Must have postive values
15372 * @name data․stack․normalize
15373 * @memberof Options
15374 * @type {boolean}
15375 * @default false
15376 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
15377 * @example
15378 * data: {
15379 * stack: {
15380 * normalize: true
15381 * }
15382 * }
15383 */
15384 data_stack_normalize: !1
15385});
15386;// CONCATENATED MODULE: ./src/config/Options/axis/x.ts
15387/**
15388 * Copyright (c) 2017 ~ present NAVER Corp.
15389 * billboard.js project is licensed under the MIT license
15390 */
15391
15392/**
15393 * x Axis config options
15394 */
15395/* harmony default export */ var axis_x = ({
15396 /**
15397 * Set clip-path attribute for x axis element
15398 * @name axis․x․clipPath
15399 * @memberof Options
15400 * @type {boolean}
15401 * @default true
15402 * @see [Demo]()
15403 * @example
15404 * // don't set 'clip-path' attribute
15405 * clipPath: false
15406 */
15407 axis_x_clipPath: !0,
15408
15409 /**
15410 * Show or hide x axis.
15411 * @name axis․x․show
15412 * @memberof Options
15413 * @type {boolean}
15414 * @default true
15415 * @example
15416 * axis: {
15417 * x: {
15418 * show: false
15419 * }
15420 * }
15421 */
15422 axis_x_show: !0,
15423
15424 /**
15425 * Set type of x axis.<br><br>
15426 * **Available Values:**
15427 * - category
15428 * - indexed
15429 * - log
15430 * - timeseries
15431 *
15432 * **NOTE:**<br>
15433 * - **log** type:
15434 * - the x values specified by [`data.x`](#.data%25E2%2580%25A4x)(or by any equivalent option), must be exclusively-positive.
15435 * - x axis min value should be >= 0.
15436 *
15437 * @name axis․x․type
15438 * @memberof Options
15439 * @type {string}
15440 * @default indexed
15441 * @see [Demo: indexed](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
15442 * @see [Demo: timeseries](https://naver.github.io/billboard.js/demo/#Chart.TimeseriesChart)
15443 * @see [Demo: category](https://naver.github.io/billboard.js/demo/#Data.CategoryData)
15444 * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
15445 * @example
15446 * axis: {
15447 * x: {
15448 * type: "timeseries"
15449 * }
15450 * }
15451 */
15452 axis_x_type: "indexed",
15453
15454 /**
15455 * Set how to treat the timezone of x values.<br>
15456 * If true, treat x value as localtime. If false, convert to UTC internally.
15457 * @name axis․x․localtime
15458 * @memberof Options
15459 * @type {boolean}
15460 * @default true
15461 * @example
15462 * axis: {
15463 * x: {
15464 * localtime: false
15465 * }
15466 * }
15467 */
15468 axis_x_localtime: !0,
15469
15470 /**
15471 * Set category names on category axis.
15472 * 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.
15473 * @name axis․x․categories
15474 * @memberof Options
15475 * @type {Array}
15476 * @default []
15477 * @example
15478 * axis: {
15479 * x: {
15480 * categories: ["Category 1", "Category 2", ...]
15481 * }
15482 * }
15483 */
15484 axis_x_categories: [],
15485
15486 /**
15487 * centerize ticks on category axis.
15488 * @name axis․x․tick․centered
15489 * @memberof Options
15490 * @type {boolean}
15491 * @default false
15492 * @example
15493 * axis: {
15494 * x: {
15495 * tick: {
15496 * centered: true
15497 * }
15498 * }
15499 * }
15500 */
15501 axis_x_tick_centered: !1,
15502
15503 /**
15504 * A function to format tick value. Format string is also available for timeseries data.
15505 * @name axis․x․tick․format
15506 * @memberof Options
15507 * @type {Function|string}
15508 * @default undefined
15509 * @see [D3's time specifier](https://github.com/d3/d3-time-format#locale_format)
15510 * @example
15511 * axis: {
15512 * x: {
15513 * tick: {
15514 * // for timeseries, a 'datetime' object is given as parameter
15515 * format: function(x) {
15516 * return x.getFullYear();
15517 * }
15518 *
15519 * // for category, index(Number) and categoryName(String) are given as parameter
15520 * format: function(index, categoryName) {
15521 * return categoryName.substr(0, 10);
15522 * },
15523 *
15524 * // for timeseries format specifier
15525 * format: "%Y-%m-%d %H:%M:%S"
15526 * }
15527 * }
15528 * }
15529 */
15530 axis_x_tick_format: undefined,
15531
15532 /**
15533 * Setting for culling ticks.<br><br>
15534 * If true is set, the ticks will be culled, then only limitted tick text will be shown. This option does not hide the tick lines. If false is set, all of ticks will be shown.<br><br>
15535 * We can change the number of ticks to be shown by axis.x.tick.culling.max.
15536 * @name axis․x․tick․culling
15537 * @memberof Options
15538 * @type {boolean}
15539 * @default
15540 * - true for indexed axis and timeseries axis
15541 * - false for category axis
15542 * @example
15543 * axis: {
15544 * x: {
15545 * tick: {
15546 * culling: false
15547 * }
15548 * }
15549 * }
15550 */
15551 axis_x_tick_culling: {},
15552
15553 /**
15554 * The number of tick texts will be adjusted to less than this value.
15555 * @name axis․x․tick․culling․max
15556 * @memberof Options
15557 * @type {number}
15558 * @default 10
15559 * @example
15560 * axis: {
15561 * x: {
15562 * tick: {
15563 * culling: {
15564 * max: 5
15565 * }
15566 * }
15567 * }
15568 * }
15569 */
15570 axis_x_tick_culling_max: 10,
15571
15572 /**
15573 * The number of x axis ticks to show.<br><br>
15574 * 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).
15575 * @name axis․x․tick․count
15576 * @memberof Options
15577 * @type {number}
15578 * @default undefined
15579 * @example
15580 * axis: {
15581 * x: {
15582 * tick: {
15583 * count: 5
15584 * }
15585 * }
15586 * }
15587 */
15588 axis_x_tick_count: undefined,
15589
15590 /**
15591 * Show or hide x axis tick line.
15592 * @name axis․x․tick․show
15593 * @memberof Options
15594 * @type {boolean}
15595 * @default true
15596 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
15597 * @example
15598 * axis: {
15599 * x: {
15600 * tick: {
15601 * show: false
15602 * }
15603 * }
15604 * }
15605 */
15606 axis_x_tick_show: !0,
15607
15608 /**
15609 * Show or hide x axis tick text.
15610 * @name axis․x․tick․text․show
15611 * @memberof Options
15612 * @type {boolean}
15613 * @default true
15614 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
15615 * @example
15616 * axis: {
15617 * x: {
15618 * tick: {
15619 * text: {
15620 * show: false
15621 * }
15622 * }
15623 * }
15624 * }
15625 */
15626 axis_x_tick_text_show: !0,
15627
15628 /**
15629 * Set the x Axis tick text's position relatively its original position
15630 * @name axis․x․tick․text․position
15631 * @memberof Options
15632 * @type {object}
15633 * @default {x: 0, y:0}
15634 * @example
15635 * axis: {
15636 * x: {
15637 * tick: {
15638 * text: {
15639 * position: {
15640 * x: 10,
15641 * y: 10
15642 * }
15643 * }
15644 * }
15645 * }
15646 * }
15647 */
15648 axis_x_tick_text_position: {
15649 x: 0,
15650 y: 0
15651 },
15652
15653 /**
15654 * Fit x axis ticks.
15655 * - **true**: ticks will be positioned nicely to have same intervals.
15656 * - **false**: ticks will be positioned according to x value of the data points.
15657 * @name axis․x․tick․fit
15658 * @memberof Options
15659 * @type {boolean}
15660 * @default true
15661 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickFitting)
15662 * @see [Demo: for timeseries zoom](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickTimeseries)
15663 * @example
15664 * axis: {
15665 * x: {
15666 * tick: {
15667 * fit: false
15668 * }
15669 * }
15670 * }
15671 */
15672 axis_x_tick_fit: !0,
15673
15674 /**
15675 * Set the x values of ticks manually.<br><br>
15676 * If this option is provided, the position of the ticks will be determined based on those values.<br>
15677 * This option works with `timeseries` data and the x values will be parsed accoding to the type of the value and data.xFormat option.
15678 * @name axis․x․tick․values
15679 * @memberof Options
15680 * @type {Array|Function}
15681 * @default null
15682 * @example
15683 * axis: {
15684 * x: {
15685 * tick: {
15686 * values: [1, 2, 4, 8, 16, 32, ...],
15687 *
15688 * // an Array value should be returned
15689 * values: function() {
15690 * return [ ... ];
15691 * }
15692 * }
15693 * }
15694 * }
15695 */
15696 axis_x_tick_values: null,
15697
15698 /**
15699 * Rotate x axis tick text if there is not enough space for 'category' and 'timeseries' type axis.
15700 * - **NOTE:** The conditions where `autorotate` is enabled are:
15701 * - axis.x.type='category' or 'timeseries
15702 * - axis.x.tick.multiline=false
15703 * - axis.x.tick.culling=false
15704 * - axis.x.tick.fit=true
15705 * - **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
15706 * @name axis․x․tick․autorotate
15707 * @memberof Options
15708 * @type {boolean}
15709 * @default false
15710 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickAutorotate)
15711 * @example
15712 * axis: {
15713 * x: {
15714 * tick: {
15715 * rotate: 15,
15716 * autorotate: true,
15717 * multiline: false,
15718 * culling: false,
15719 * fit: true
15720 * },
15721 * clipPath: false
15722 * }
15723 * }
15724 */
15725 axis_x_tick_autorotate: !1,
15726
15727 /**
15728 * Rotate x axis tick text.
15729 * - If you set negative value, it will rotate to opposite direction.
15730 * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `false`.
15731 * - 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.
15732 * @name axis․x․tick․rotate
15733 * @memberof Options
15734 * @type {number}
15735 * @default 0
15736 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.RotateXAxisTickText)
15737 * @example
15738 * axis: {
15739 * x: {
15740 * tick: {
15741 * rotate: 60
15742 * }
15743 * }
15744 * }
15745 */
15746 axis_x_tick_rotate: 0,
15747
15748 /**
15749 * Show x axis outer tick.
15750 * @name axis․x․tick․outer
15751 * @memberof Options
15752 * @type {boolean}
15753 * @default true
15754 * @example
15755 * axis: {
15756 * x: {
15757 * tick: {
15758 * outer: false
15759 * }
15760 * }
15761 * }
15762 */
15763 axis_x_tick_outer: !0,
15764
15765 /**
15766 * Set tick text to be multiline
15767 * - **NOTE:**
15768 * > When x tick text contains `\n`, it's used as line break and 'axis.x.tick.width' option is ignored.
15769 * @name axis․x․tick․multiline
15770 * @memberof Options
15771 * @type {boolean}
15772 * @default true
15773 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickMultiline)
15774 * @example
15775 * axis: {
15776 * x: {
15777 * tick: {
15778 * multiline: false
15779 * }
15780 * }
15781 * }
15782 * @example
15783 * // example of line break with '\n'
15784 * // In this case, 'axis.x.tick.width' is ignored
15785 * data: {
15786 * x: "x",
15787 * columns: [
15788 * ["x", "long\ntext", "Another\nLong\nText"],
15789 * ...
15790 * ],
15791 * }
15792 */
15793 axis_x_tick_multiline: !0,
15794
15795 /**
15796 * Set tick width
15797 * - **NOTE:**
15798 * > When x tick text contains `\n`, this option is ignored.
15799 * @name axis․x․tick․width
15800 * @memberof Options
15801 * @type {number}
15802 * @default null
15803 * @example
15804 * axis: {
15805 * x: {
15806 * tick: {
15807 * width: 50
15808 * }
15809 * }
15810 * }
15811 */
15812 axis_x_tick_width: null,
15813
15814 /**
15815 * Set to display system tooltip(via 'title' attribute) for tick text
15816 * - **NOTE:** Only available for category axis type (`axis.x.type='category'`)
15817 * @name axis․x․tick․tooltip
15818 * @memberof Options
15819 * @type {boolean}
15820 * @default false
15821 * @example
15822 * axis: {
15823 * x: {
15824 * tick: {
15825 * tooltip: true
15826 * }
15827 * }
15828 * }
15829 */
15830 axis_x_tick_tooltip: !1,
15831
15832 /**
15833 * Set max value of x axis range.
15834 * @name axis․x․max
15835 * @memberof Options
15836 * @property {number} max Set the max value
15837 * @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.
15838 * - **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`.
15839 * @property {number} [max.value] Set the max value
15840 * @example
15841 * axis: {
15842 * x: {
15843 * max: 100,
15844 *
15845 * max: {
15846 * // 'fit=true' will make x axis max to be limited as the bound data value max when 'max.value' is greater.
15847 * // - when bound data max is '10' and max.value: '100' ==> x axis max will be '10'
15848 * // - when bound data max is '1000' and max.value: '100' ==> x axis max will be '100'
15849 * fit: true,
15850 * value: 100
15851 * }
15852 * }
15853 * }
15854 */
15855 axis_x_max: undefined,
15856
15857 /**
15858 * Set min value of x axis range.
15859 * @name axis․x․min
15860 * @memberof Options
15861 * @property {number} min Set the min value
15862 * @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.
15863 * - **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`.
15864 * @property {number} [min.value] Set the min value
15865 * @example
15866 * axis: {
15867 * x: {
15868 * min: -100,
15869 *
15870 * min: {
15871 * // 'fit=true' will make x axis min to be limited as the bound data value min when 'min.value' is lower.
15872 * // - when bound data min is '-10' and min.value: '-100' ==> x axis min will be '-10'
15873 * // - when bound data min is '-1000' and min.value: '-100' ==> x axis min will be '-100'
15874 * fit: true,
15875 * value: -100
15876 * }
15877 * }
15878 * }
15879 */
15880 axis_x_min: undefined,
15881
15882 /**
15883 * Set padding for x axis.<br><br>
15884 * If this option is set, the range of x axis will increase/decrease according to the values.
15885 * If no padding is needed in the rage of x axis, 0 should be set.
15886 * By default, left/right padding are set depending on x axis type or chart types.
15887 * - **NOTE:**
15888 * - The meaning of padding values, differs according axis types:<br>
15889 * - **category/indexed:** The unit of tick value
15890 * ex. the given value `1`, is same as the width of 1 tick width
15891 * - **timeseries:** Numeric time value
15892 * 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
15893 * - If want values to be treated as pixels, specify `unit:"px"`.
15894 * - The pixel value will be convered based on the scale values. Hence can not reflect accurate padding result.
15895 * @name axis․x․padding
15896 * @memberof Options
15897 * @type {object|number}
15898 * @default {}
15899 * @example
15900 * axis: {
15901 * x: {
15902 * padding: {
15903 * // when axis type is 'category'
15904 * left: 1, // set left padding width of equivalent value of a tick's width
15905 * right: 0.5 // set right padding width as half of equivalent value of tick's width
15906 *
15907 * // when axis type is 'timeseries'
15908 * left: 1000*60*60*24, // set left padding width of equivalent value of a day tick's width
15909 * right: 1000*60*60*12 // set right padding width as half of equivalent value of a day tick's width
15910 * },
15911 *
15912 * // or set both values at once.
15913 * padding: 10,
15914 *
15915 * // or set padding values as pixel unit.
15916 * padding: {
15917 * left: 100,
15918 * right: 50,
15919 * unit: "px"
15920 * },
15921 * }
15922 * }
15923 */
15924 axis_x_padding: {},
15925
15926 /**
15927 * Set height of x axis.<br><br>
15928 * 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.
15929 * @name axis․x․height
15930 * @memberof Options
15931 * @type {number}
15932 * @default undefined
15933 * @example
15934 * axis: {
15935 * x: {
15936 * height: 20
15937 * }
15938 * }
15939 */
15940 axis_x_height: undefined,
15941
15942 /**
15943 * Set default extent for subchart and zoom. This can be an array or function that returns an array.
15944 * @name axis․x․extent
15945 * @memberof Options
15946 * @type {Array|Function}
15947 * @default undefined
15948 * @example
15949 * axis: {
15950 * x: {
15951 * // extent range as a pixel value
15952 * extent: [0, 200],
15953 *
15954 * // when axis is 'timeseries', parsable datetime string
15955 * extent: ["2019-03-01", "2019-03-05"],
15956 *
15957 * // return extent value
15958 * extent: function(domain, scale) {
15959 * var extent = domain.map(function(v) {
15960 * return scale(v);
15961 * });
15962 *
15963 * // it should return a format of array
15964 * // ex) [0, 584]
15965 * return extent;
15966 * }
15967 * }
15968 * }
15969 */
15970 axis_x_extent: undefined,
15971
15972 /**
15973 * Set label on x axis.<br><br>
15974 * You can set x axis label and change its position by this option.
15975 * `string` and `object` can be passed and we can change the poisiton by passing object that has position key.<br>
15976 * Available position differs according to the axis direction (vertical or horizontal).
15977 * If string set, the position will be the default.
15978 *
15979 * - **If it's horizontal axis:**
15980 * - inner-right [default]
15981 * - inner-center
15982 * - inner-left
15983 * - outer-right
15984 * - outer-center
15985 * - outer-left
15986 * - **If it's vertical axis:**
15987 * - inner-top [default]
15988 * - inner-middle
15989 * - inner-bottom
15990 * - outer-top
15991 * - outer-middle
15992 * - outer-bottom
15993 * @name axis․x․label
15994 * @memberof Options
15995 * @type {string|object}
15996 * @default undefined
15997 * @example
15998 * axis: {
15999 * x: {
16000 * label: "Your X Axis"
16001 * }
16002 * }
16003 *
16004 * axis: {
16005 * x: {
16006 * label: {
16007 * text: "Your X Axis",
16008 * position: "outer-center"
16009 * }
16010 * }
16011 * }
16012 */
16013 axis_x_label: {},
16014
16015 /**
16016 * Set additional axes for x Axis.
16017 * - **NOTE:** Axis' scale is based on x Axis value if domain option isn't set.
16018 *
16019 * Each axis object should consist with following options:
16020 *
16021 * | Name | Type | Default | Description |
16022 * | --- | --- | --- | --- |
16023 * | domain | Array | - | Set the domain value |
16024 * | tick.outer | boolean | true | Show outer tick |
16025 * | tick.format | Function | - | Set formatter for tick text |
16026 * | tick.count | Number | - | Set the number of y axis ticks |
16027 * | tick.values | Array | - | Set tick values manually |
16028 * @name axis․x․axes
16029 * @memberof Options
16030 * @type {Array}
16031 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
16032 * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
16033 * @example
16034 * x: {
16035 * axes: [
16036 * {
16037 * // if set, will not be correlated with the main x Axis domain value
16038 * domain: [0, 1000],
16039 * tick: {
16040 * outer: false,
16041 * format: function(x) {
16042 * return x + "%";
16043 * },
16044 * count: 2,
16045 * values: [10, 20, 30]
16046 * }
16047 * },
16048 * ...
16049 * ]
16050 * }
16051 */
16052 axis_x_axes: []
16053});
16054;// CONCATENATED MODULE: ./src/config/Options/axis/y.ts
16055/**
16056 * Copyright (c) 2017 ~ present NAVER Corp.
16057 * billboard.js project is licensed under the MIT license
16058 */
16059
16060/**
16061 * y Axis config options
16062 */
16063/* harmony default export */ var y = ({
16064 /**
16065 * Set clip-path attribute for y axis element
16066 * - **NOTE**: `clip-path` attribute for y Axis is set only when `axis.y.inner` option is true.
16067 * @name axis․y․clipPath
16068 * @memberof Options
16069 * @type {boolean}
16070 * @default true
16071 * @example
16072 * // don't set 'clip-path' attribute
16073 * clipPath: false
16074 */
16075 axis_y_clipPath: !0,
16076
16077 /**
16078 * Show or hide y axis.
16079 * @name axis․y․show
16080 * @memberof Options
16081 * @type {boolean}
16082 * @default true
16083 * @example
16084 * axis: {
16085 * y: {
16086 * show: false
16087 * }
16088 * }
16089 */
16090 axis_y_show: !0,
16091
16092 /**
16093 * Set type of y axis.<br><br>
16094 * **Available Values:**
16095 * - indexed
16096 * - log
16097 * - timeseries
16098 *
16099 * **NOTE:**<br>
16100 * - **log** type:
16101 * - the bound data values must be exclusively-positive.
16102 * - y axis min value should be >= 0.
16103 * - [`data.groups`](#.data%25E2%2580%25A4groups)(stacked data) option aren't supported.
16104 *
16105 * @name axis․y․type
16106 * @memberof Options
16107 * @type {string}
16108 * @default "indexed"
16109 * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
16110 * @example
16111 * axis: {
16112 * y: {
16113 * type: "log"
16114 * }
16115 * }
16116 */
16117 axis_y_type: "indexed",
16118
16119 /**
16120 * Set max value of y axis.
16121 * - **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).
16122 * @name axis․y․max
16123 * @memberof Options
16124 * @type {number}
16125 * @default undefined
16126 * @example
16127 * axis: {
16128 * y: {
16129 * max: 1000
16130 * }
16131 * }
16132 */
16133 axis_y_max: undefined,
16134
16135 /**
16136 * Set min value of y axis.
16137 * - **NOTE:**
16138 * 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).
16139 * @name axis․y․min
16140 * @memberof Options
16141 * @type {number}
16142 * @default undefined
16143 * @example
16144 * axis: {
16145 * y: {
16146 * min: 1000
16147 * }
16148 * }
16149 */
16150 axis_y_min: undefined,
16151
16152 /**
16153 * Change the direction of y axis.<br><br>
16154 * If true set, the direction will be from the top to the bottom.
16155 * @name axis․y․inverted
16156 * @memberof Options
16157 * @type {boolean}
16158 * @default false
16159 * @example
16160 * axis: {
16161 * y: {
16162 * inverted: true
16163 * }
16164 * }
16165 */
16166 axis_y_inverted: !1,
16167
16168 /**
16169 * Set center value of y axis.
16170 * @name axis․y․center
16171 * @memberof Options
16172 * @type {number}
16173 * @default undefined
16174 * @example
16175 * axis: {
16176 * y: {
16177 * center: 0
16178 * }
16179 * }
16180 */
16181 axis_y_center: undefined,
16182
16183 /**
16184 * Show y axis inside of the chart.
16185 * @name axis․y․inner
16186 * @memberof Options
16187 * @type {boolean}
16188 * @default false
16189 * @example
16190 * axis: {
16191 * y: {
16192 * inner: true
16193 * }
16194 * }
16195 */
16196 axis_y_inner: !1,
16197
16198 /**
16199 * Set label on y axis.<br><br>
16200 * 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).
16201 * @name axis․y․label
16202 * @memberof Options
16203 * @type {string|object}
16204 * @default {}
16205 * @see [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label) for position string value.
16206 * @example
16207 * axis: {
16208 * y: {
16209 * label: "Your Y Axis"
16210 * }
16211 * }
16212 *
16213 * axis: {
16214 * y: {
16215 * label: {
16216 * text: "Your Y Axis",
16217 * position: "outer-middle"
16218 * }
16219 * }
16220 * }
16221 */
16222 axis_y_label: {},
16223
16224 /**
16225 * Set formatter for y axis tick text.<br><br>
16226 * This option accepts d3.format object as well as a function you define.
16227 * @name axis․y․tick․format
16228 * @memberof Options
16229 * @type {Function}
16230 * @default undefined
16231 * @example
16232 * axis: {
16233 * y: {
16234 * tick: {
16235 * format: function(x) {
16236 * return x.getFullYear();
16237 * }
16238 * }
16239 * }
16240 * }
16241 */
16242 axis_y_tick_format: undefined,
16243
16244 /**
16245 * Setting for culling ticks.<br><br>
16246 * If true is set, the ticks will be culled, then only limitted tick text will be shown. This option does not hide the tick lines. If false is set, all of ticks will be shown.<br><br>
16247 * We can change the number of ticks to be shown by axis.y.tick.culling.max.
16248 * @name axis․y․tick․culling
16249 * @memberof Options
16250 * @type {boolean}
16251 * @default false
16252 * @example
16253 * axis: {
16254 * y: {
16255 * tick: {
16256 * culling: false
16257 * }
16258 * }
16259 * }
16260 */
16261 axis_y_tick_culling: !1,
16262
16263 /**
16264 * The number of tick texts will be adjusted to less than this value.
16265 * @name axis․y․tick․culling․max
16266 * @memberof Options
16267 * @type {number}
16268 * @default 5
16269 * @example
16270 * axis: {
16271 * y: {
16272 * tick: {
16273 * culling: {
16274 * max: 5
16275 * }
16276 * }
16277 * }
16278 * }
16279 */
16280 axis_y_tick_culling_max: 5,
16281
16282 /**
16283 * Show y axis outer tick.
16284 * @name axis․y․tick․outer
16285 * @memberof Options
16286 * @type {boolean}
16287 * @default true
16288 * @example
16289 * axis: {
16290 * y: {
16291 * tick: {
16292 * outer: false
16293 * }
16294 * }
16295 * }
16296 */
16297 axis_y_tick_outer: !0,
16298
16299 /**
16300 * Set y axis tick values manually.
16301 * @name axis․y․tick․values
16302 * @memberof Options
16303 * @type {Array|Function}
16304 * @default null
16305 * @example
16306 * axis: {
16307 * y: {
16308 * tick: {
16309 * values: [100, 1000, 10000],
16310 *
16311 * // an Array value should be returned
16312 * values: function() {
16313 * return [ ... ];
16314 * }
16315 * }
16316 * }
16317 * }
16318 */
16319 axis_y_tick_values: null,
16320
16321 /**
16322 * Rotate y axis tick text.
16323 * - If you set negative value, it will rotate to opposite direction.
16324 * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `true`.
16325 * @name axis․y․tick․rotate
16326 * @memberof Options
16327 * @type {number}
16328 * @default 0
16329 * @example
16330 * axis: {
16331 * y: {
16332 * tick: {
16333 * rotate: 60
16334 * }
16335 * }
16336 * }
16337 */
16338 axis_y_tick_rotate: 0,
16339
16340 /**
16341 * Set the number of y axis ticks.<br><br>
16342 * - **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.
16343 * @name axis․y․tick․count
16344 * @memberof Options
16345 * @type {number}
16346 * @default undefined
16347 * @example
16348 * axis: {
16349 * y: {
16350 * tick: {
16351 * count: 5
16352 * }
16353 * }
16354 * }
16355 */
16356 axis_y_tick_count: undefined,
16357
16358 /**
16359 * Show or hide y axis tick line.
16360 * @name axis․y․tick․show
16361 * @memberof Options
16362 * @type {boolean}
16363 * @default true
16364 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
16365 * @example
16366 * axis: {
16367 * y: {
16368 * tick: {
16369 * show: false
16370 * }
16371 * }
16372 * }
16373 */
16374 axis_y_tick_show: !0,
16375
16376 /**
16377 * Set axis tick step(interval) size.
16378 * - **NOTE:** Will be ignored if `axis.y.tick.count` or `axis.y.tick.values` options are set.
16379 * @name axis․y․tick․stepSize
16380 * @memberof Options
16381 * @type {number}
16382 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.StepSizeForYAxis)
16383 * @example
16384 * axis: {
16385 * y: {
16386 * tick: {
16387 * // tick value will step as indicated interval value.
16388 * // ex) 'stepSize=15' ==> [0, 15, 30, 45, 60]
16389 * stepSize: 15
16390 * }
16391 * }
16392 * }
16393 */
16394 axis_y_tick_stepSize: null,
16395
16396 /**
16397 * Show or hide y axis tick text.
16398 * @name axis․y․tick․text․show
16399 * @memberof Options
16400 * @type {boolean}
16401 * @default true
16402 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
16403 * @example
16404 * axis: {
16405 * y: {
16406 * tick: {
16407 * text: {
16408 * show: false
16409 * }
16410 * }
16411 * }
16412 * }
16413 */
16414 axis_y_tick_text_show: !0,
16415
16416 /**
16417 * Set the y Axis tick text's position relatively its original position
16418 * @name axis․y․tick․text․position
16419 * @memberof Options
16420 * @type {object}
16421 * @default {x: 0, y:0}
16422 * @example
16423 * axis: {
16424 * y: {
16425 * tick: {
16426 * text: {
16427 * position: {
16428 * x: 10,
16429 * y: 10
16430 * }
16431 * }
16432 * }
16433 * }
16434 * }
16435 */
16436 axis_y_tick_text_position: {
16437 x: 0,
16438 y: 0
16439 },
16440
16441 /**
16442 * Set the number of y axis ticks.<br><br>
16443 * - **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.
16444 * @name axis․y․tick․time
16445 * @memberof Options
16446 * @private
16447 * @type {object}
16448 * @property {object} time time object
16449 * @property {Function} [time.value] D3's time interval function (https://github.com/d3/d3-time#intervals)
16450 * @example
16451 * axis: {
16452 * y: {
16453 * tick: {
16454 * time: {
16455 * // ticks at 15-minute intervals
16456 * // https://github.com/d3/d3-scale/blob/master/README.md#time_ticks
16457 * value: d3.timeMinute.every(15)
16458 * }
16459 * }
16460 * }
16461 * }
16462 */
16463 // @TODO: not fully implemented yet
16464 axis_y_tick_time_value: undefined,
16465
16466 /**
16467 * Set padding for y axis.<br><br>
16468 * You can set padding for y axis to create more space on the edge of the axis.
16469 * This option accepts object and it can include top and bottom. top, bottom will be treated as pixels.
16470 *
16471 * - **NOTE:**
16472 * - Given values are translated relative to the y Axis domain value for padding
16473 * - For area and bar type charts, [area.zerobased](#.area) or [bar.zerobased](#.bar) options should be set to 'false` to get padded bottom.
16474 * @name axis․y․padding
16475 * @memberof Options
16476 * @type {object|number}
16477 * @default {}
16478 * @example
16479 * axis: {
16480 * y: {
16481 * padding: {
16482 * top: 0,
16483 * bottom: 0
16484 * },
16485 *
16486 * // or set both values at once.
16487 * padding: 10
16488 * }
16489 * }
16490 */
16491 axis_y_padding: {},
16492
16493 /**
16494 * Set default range of y axis.<br><br>
16495 * This option set the default value for y axis when there is no data on init.
16496 * @name axis․y․default
16497 * @memberof Options
16498 * @type {Array}
16499 * @default undefined
16500 * @example
16501 * axis: {
16502 * y: {
16503 * default: [0, 1000]
16504 * }
16505 * }
16506 */
16507 axis_y_default: undefined,
16508
16509 /**
16510 * Set additional axes for y Axis.
16511 * - **NOTE:** Axis' scale is based on y Axis value if domain option isn't set.
16512 *
16513 * Each axis object should consist with following options:
16514 *
16515 * | Name | Type | Default | Description |
16516 * | --- | --- | --- | --- |
16517 * | domain | Array | - | Set the domain value |
16518 * | tick.outer | boolean | true | Show outer tick |
16519 * | tick.format | Function | - | Set formatter for tick text |
16520 * | tick.count | Number | - | Set the number of y axis ticks |
16521 * | tick.values | Array | - | Set tick values manually |
16522 * @name axis․y․axes
16523 * @memberof Options
16524 * @type {Array}
16525 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
16526 * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
16527 * @example
16528 * y: {
16529 * axes: [
16530 * {
16531 * // if set, will not be correlated with the main y Axis domain value
16532 * domain: [0, 1000],
16533 * tick: {
16534 * outer: false,
16535 * format: function(x) {
16536 * return x + "%";
16537 * },
16538 * count: 2,
16539 * values: [10, 20, 30]
16540 * }
16541 * },
16542 * ...
16543 * ]
16544 * }
16545 */
16546 axis_y_axes: []
16547});
16548;// CONCATENATED MODULE: ./src/config/Options/axis/y2.ts
16549/**
16550 * Copyright (c) 2017 ~ present NAVER Corp.
16551 * billboard.js project is licensed under the MIT license
16552 */
16553
16554/**
16555 * y2 Axis config options
16556 */
16557/* harmony default export */ var y2 = ({
16558 /**
16559 * Show or hide y2 axis.
16560 * - **NOTE**:
16561 * - When set to `false` will not generate y2 axis node. In this case, all 'y2' axis related functionality won't work properly.
16562 * - If need to use 'y2' related options while y2 isn't visible, set the value `true` and control visibility by css display property.
16563 * @name axis․y2․show
16564 * @memberof Options
16565 * @type {boolean}
16566 * @default false
16567 * @example
16568 * axis: {
16569 * y2: {
16570 * show: true
16571 * }
16572 * }
16573 */
16574 axis_y2_show: !1,
16575
16576 /**
16577 * Set type of y2 axis.<br><br>
16578 * **Available Values:**
16579 * - indexed
16580 * - log
16581 * - timeseries
16582 *
16583 * **NOTE:**<br>
16584 * - **log** type:
16585 * - the bound data values must be exclusively-positive.
16586 * - y2 axis min value should be >= 0.
16587 * - [`data.groups`](#.data%25E2%2580%25A4groups)(stacked data) option aren't supported.
16588 *
16589 * @name axis․y2․type
16590 * @memberof Options
16591 * @type {string}
16592 * @default "indexed"
16593 * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
16594 * @example
16595 * axis: {
16596 * y2: {
16597 * type: "indexed"
16598 * }
16599 * }
16600 */
16601 axis_y2_type: "indexed",
16602
16603 /**
16604 * Set max value of y2 axis.
16605 * @name axis․y2․max
16606 * @memberof Options
16607 * @type {number}
16608 * @default undefined
16609 * @example
16610 * axis: {
16611 * y2: {
16612 * max: 1000
16613 * }
16614 * }
16615 */
16616 axis_y2_max: undefined,
16617
16618 /**
16619 * Set min value of y2 axis.
16620 * @name axis․y2․min
16621 * @memberof Options
16622 * @type {number}
16623 * @default undefined
16624 * @example
16625 * axis: {
16626 * y2: {
16627 * min: -1000
16628 * }
16629 * }
16630 */
16631 axis_y2_min: undefined,
16632
16633 /**
16634 * Change the direction of y2 axis.<br><br>
16635 * If true set, the direction will be from the top to the bottom.
16636 * @name axis․y2․inverted
16637 * @memberof Options
16638 * @type {boolean}
16639 * @default false
16640 * @example
16641 * axis: {
16642 * y2: {
16643 * inverted: true
16644 * }
16645 * }
16646 */
16647 axis_y2_inverted: !1,
16648
16649 /**
16650 * Set center value of y2 axis.
16651 * @name axis․y2․center
16652 * @memberof Options
16653 * @type {number}
16654 * @default undefined
16655 * @example
16656 * axis: {
16657 * y2: {
16658 * center: 0
16659 * }
16660 * }
16661 */
16662 axis_y2_center: undefined,
16663
16664 /**
16665 * Show y2 axis inside of the chart.
16666 * @name axis․y2․inner
16667 * @memberof Options
16668 * @type {boolean}
16669 * @default false
16670 * @example
16671 * axis: {
16672 * y2: {
16673 * inner: true
16674 * }
16675 * }
16676 */
16677 axis_y2_inner: !1,
16678
16679 /**
16680 * Set label on y2 axis.<br><br>
16681 * 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).
16682 * @name axis․y2․label
16683 * @memberof Options
16684 * @type {string|object}
16685 * @default {}
16686 * @see [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label) for position string value.
16687 * @example
16688 * axis: {
16689 * y2: {
16690 * label: "Your Y2 Axis"
16691 * }
16692 * }
16693 *
16694 * axis: {
16695 * y2: {
16696 * label: {
16697 * text: "Your Y2 Axis",
16698 * position: "outer-middle"
16699 * }
16700 * }
16701 * }
16702 */
16703 axis_y2_label: {},
16704
16705 /**
16706 * Set formatter for y2 axis tick text.<br><br>
16707 * This option works in the same way as axis.y.format.
16708 * @name axis․y2․tick․format
16709 * @memberof Options
16710 * @type {Function}
16711 * @default undefined
16712 * @example
16713 * axis: {
16714 * y2: {
16715 * tick: {
16716 * format: d3.format("$,")
16717 * //or format: function(d) { return "$" + d; }
16718 * }
16719 * }
16720 * }
16721 */
16722 axis_y2_tick_format: undefined,
16723
16724 /**
16725 * Setting for culling ticks.<br><br>
16726 * If true is set, the ticks will be culled, then only limitted tick text will be shown. This option does not hide the tick lines. If false is set, all of ticks will be shown.<br><br>
16727 * We can change the number of ticks to be shown by axis.y.tick.culling.max.
16728 * @name axis․y2․tick․culling
16729 * @memberof Options
16730 * @type {boolean}
16731 * @default false
16732 * @example
16733 * axis: {
16734 * y2: {
16735 * tick: {
16736 * culling: false
16737 * }
16738 * }
16739 * }
16740 */
16741 axis_y2_tick_culling: !1,
16742
16743 /**
16744 * The number of tick texts will be adjusted to less than this value.
16745 * @name axis․y2․tick․culling․max
16746 * @memberof Options
16747 * @type {number}
16748 * @default 5
16749 * @example
16750 * axis: {
16751 * y2: {
16752 * tick: {
16753 * culling: {
16754 * max: 5
16755 * }
16756 * }
16757 * }
16758 * }
16759 */
16760 axis_y2_tick_culling_max: 5,
16761
16762 /**
16763 * Show or hide y2 axis outer tick.
16764 * @name axis․y2․tick․outer
16765 * @memberof Options
16766 * @type {boolean}
16767 * @default true
16768 * @example
16769 * axis: {
16770 * y2: {
16771 * tick: {
16772 * outer: false
16773 * }
16774 * }
16775 * }
16776 */
16777 axis_y2_tick_outer: !0,
16778
16779 /**
16780 * Set y2 axis tick values manually.
16781 * @name axis․y2․tick․values
16782 * @memberof Options
16783 * @type {Array|Function}
16784 * @default null
16785 * @example
16786 * axis: {
16787 * y2: {
16788 * tick: {
16789 * values: [100, 1000, 10000],
16790 *
16791 * // an Array value should be returned
16792 * values: function() {
16793 * return [ ... ];
16794 * }
16795 * }
16796 * }
16797 * }
16798 */
16799 axis_y2_tick_values: null,
16800
16801 /**
16802 * Rotate y2 axis tick text.
16803 * - If you set negative value, it will rotate to opposite direction.
16804 * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `true`.
16805 * @name axis․y2․tick․rotate
16806 * @memberof Options
16807 * @type {number}
16808 * @default 0
16809 * @example
16810 * axis: {
16811 * y2: {
16812 * tick: {
16813 * rotate: 60
16814 * }
16815 * }
16816 * }
16817 */
16818 axis_y2_tick_rotate: 0,
16819
16820 /**
16821 * Set the number of y2 axis ticks.
16822 * - **NOTE:** This works in the same way as axis.y.tick.count.
16823 * @name axis․y2․tick․count
16824 * @memberof Options
16825 * @type {number}
16826 * @default undefined
16827 * @example
16828 * axis: {
16829 * y2: {
16830 * tick: {
16831 * count: 5
16832 * }
16833 * }
16834 * }
16835 */
16836 axis_y2_tick_count: undefined,
16837
16838 /**
16839 * Show or hide y2 axis tick line.
16840 * @name axis․y2․tick․show
16841 * @memberof Options
16842 * @type {boolean}
16843 * @default true
16844 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
16845 * @example
16846 * axis: {
16847 * y2: {
16848 * tick: {
16849 * show: false
16850 * }
16851 * }
16852 * }
16853 */
16854 axis_y2_tick_show: !0,
16855
16856 /**
16857 * Set axis tick step(interval) size.
16858 * - **NOTE:** Will be ignored if `axis.y2.tick.count` or `axis.y2.tick.values` options are set.
16859 * @name axis․y2․tick․stepSize
16860 * @memberof Options
16861 * @type {number}
16862 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.StepSizeForYAxis)
16863 * @example
16864 * axis: {
16865 * y2: {
16866 * tick: {
16867 * // tick value will step as indicated interval value.
16868 * // ex) 'stepSize=15' ==> [0, 15, 30, 45, 60]
16869 * stepSize: 15
16870 * }
16871 * }
16872 * }
16873 */
16874 axis_y2_tick_stepSize: null,
16875
16876 /**
16877 * Show or hide y2 axis tick text.
16878 * @name axis․y2․tick․text․show
16879 * @memberof Options
16880 * @type {boolean}
16881 * @default true
16882 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
16883 * @example
16884 * axis: {
16885 * y2: {
16886 * tick: {
16887 * text: {
16888 * show: false
16889 * }
16890 * }
16891 * }
16892 * }
16893 */
16894 axis_y2_tick_text_show: !0,
16895
16896 /**
16897 * Set the y2 Axis tick text's position relatively its original position
16898 * @name axis․y2․tick․text․position
16899 * @memberof Options
16900 * @type {object}
16901 * @default {x: 0, y:0}
16902 * @example
16903 * axis: {
16904 * y2: {
16905 * tick: {
16906 * text: {
16907 * position: {
16908 * x: 10,
16909 * y: 10
16910 * }
16911 * }
16912 * }
16913 * }
16914 * }
16915 */
16916 axis_y2_tick_text_position: {
16917 x: 0,
16918 y: 0
16919 },
16920
16921 /**
16922 * Set padding for y2 axis.<br><br>
16923 * You can set padding for y2 axis to create more space on the edge of the axis.
16924 * This option accepts object and it can include top and bottom. top, bottom will be treated as pixels.
16925 *
16926 * - **NOTE:**
16927 * - Given values are translated relative to the y2 Axis domain value for padding
16928 * - For area and bar type charts, [area.zerobased](#.area) or [bar.zerobased](#.bar) options should be set to 'false` to get padded bottom.
16929 * @name axis․y2․padding
16930 * @memberof Options
16931 * @type {object|number}
16932 * @default {}
16933 * @example
16934 * axis: {
16935 * y2: {
16936 * padding: {
16937 * top: 100,
16938 * bottom: 100
16939 * }
16940 *
16941 * // or set both values at once.
16942 * padding: 10
16943 * }
16944 */
16945 axis_y2_padding: {},
16946
16947 /**
16948 * Set default range of y2 axis.<br><br>
16949 * This option set the default value for y2 axis when there is no data on init.
16950 * @name axis․y2․default
16951 * @memberof Options
16952 * @type {Array}
16953 * @default undefined
16954 * @example
16955 * axis: {
16956 * y2: {
16957 * default: [0, 1000]
16958 * }
16959 * }
16960 */
16961 axis_y2_default: undefined,
16962
16963 /**
16964 * Set additional axes for y2 Axis.
16965 * - **NOTE:** Axis' scale is based on y2 Axis value if domain option isn't set.
16966 *
16967 * Each axis object should consist with following options:
16968 *
16969 * | Name | Type | Default | Description |
16970 * | --- | --- | --- | --- |
16971 * | domain | Array | - | Set the domain value |
16972 * | tick.outer | boolean | true | Show outer tick |
16973 * | tick.format | Function | - | Set formatter for tick text |
16974 * | tick.count | Number | - | Set the number of y axis ticks |
16975 * | tick.values | Array | - | Set tick values manually |
16976 * @name axis․y2․axes
16977 * @memberof Options
16978 * @type {Array}
16979 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
16980 * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
16981 * @example
16982 * y2: {
16983 * axes: [
16984 * {
16985 * // if set, will not be correlated with the main y2 Axis domain value
16986 * domain: [0, 1000],
16987 * tick: {
16988 * outer: false,
16989 * format: function(x) {
16990 * return x + "%";
16991 * },
16992 * count: 2,
16993 * values: [10, 20, 30]
16994 * }
16995 * },
16996 * ...
16997 * ]
16998 * }
16999 */
17000 axis_y2_axes: []
17001});
17002;// CONCATENATED MODULE: ./src/config/Options/axis/axis.ts
17003
17004
17005function axis_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17006
17007function axis_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { axis_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { axis_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17008
17009/**
17010 * Copyright (c) 2017 ~ present NAVER Corp.
17011 * billboard.js project is licensed under the MIT license
17012 */
17013
17014
17015
17016/**
17017 * y Axis config options
17018 */
17019
17020/* harmony default export */ var axis_axis = (axis_objectSpread(axis_objectSpread(axis_objectSpread({
17021 /**
17022 * Switch x and y axis position.
17023 * @name axis․rotated
17024 * @memberof Options
17025 * @type {boolean}
17026 * @default false
17027 * @example
17028 * axis: {
17029 * rotated: true
17030 * }
17031 */
17032 axis_rotated: !1
17033}, axis_x), y), y2));
17034;// CONCATENATED MODULE: ./src/config/Options/common/grid.ts
17035/**
17036 * Copyright (c) 2017 ~ present NAVER Corp.
17037 * billboard.js project is licensed under the MIT license
17038 */
17039
17040/**
17041 * grid config options
17042 */
17043/* harmony default export */ var common_grid = ({
17044 /**
17045 * Set related options
17046 * @name grid
17047 * @memberof Options
17048 * @type {object}
17049 * @property {boolean} [front=false] Set 'grid & focus lines' to be positioned over grid lines and chart elements.
17050 * @property {object} x Grid x object
17051 * @property {boolean} [x.show=false] Show grids along x axis.
17052 * @property {Array} [x.lines=[]] Show additional grid lines along x axis.<br>
17053 * 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.
17054 * 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.
17055 * @property {object} y Grid y object
17056 * @property {boolean} [y.show=false] Show grids along x axis.
17057 * @property {Array} [y.lines=[]] Show additional grid lines along y axis.<br>
17058 * This option accepts array including object that has value, text, position and class.
17059 * @property {number} [y.ticks=10] Number of y grids to be shown.
17060 * @property {object} focus Grid focus object
17061 * @property {boolean} [focus.edge=false] Show edged focus grid line.<br>**NOTE:** Available when [`tooltip.grouped=false`](#.tooltip) option is set.
17062 * @property {boolean} [focus.show=true] Show grid line when focus.
17063 * @property {boolean} [focus.y=false] Show y coordinate focus grid line.<br>**NOTE:** Available when [`tooltip.grouped=false`](#.tooltip) option is set.
17064 * @property {object} lines Grid lines object
17065 * @property {boolean} [lines.front=true] Set grid lines to be positioned over chart elements.
17066 * @default undefined
17067 * @see [Demo](https://naver.github.io/billboard.js/demo/#Grid.GridLines)
17068 * @see [Demo: X Grid Lines](https://naver.github.io/billboard.js/demo/#Grid.OptionalXGridLines)
17069 * @see [Demo: Y Grid Lines](https://naver.github.io/billboard.js/demo/#Grid.OptionalYGridLines)
17070 * @example
17071 * grid: {
17072 * x: {
17073 * show: true,
17074 * lines: [
17075 * {value: 2, text: "Label on 2"},
17076 * {value: 5, text: "Label on 5", class: "label-5"},
17077 * {value: 6, text: "Label on 6", position: "start"}
17078 * ]
17079 * },
17080 * y: {
17081 * show: true,
17082 * lines: [
17083 * {value: 100, text: "Label on 100"},
17084 * {value: 200, text: "Label on 200", class: "label-200"},
17085 * {value: 300, text: "Label on 300", position: 'middle'}
17086 * ],
17087 * ticks: 5
17088 * },
17089 * front: true,
17090 * focus: {
17091 * show: false,
17092 *
17093 * // Below options are available when 'tooltip.grouped=false' option is set
17094 * edge: true,
17095 * y: true
17096 * },
17097 * lines: {
17098 * front: false
17099 * }
17100 * }
17101 */
17102 grid_x_show: !1,
17103 grid_x_type: "tick",
17104 grid_x_lines: [],
17105 grid_y_show: !1,
17106 grid_y_lines: [],
17107 grid_y_ticks: 10,
17108 grid_focus_edge: !1,
17109 grid_focus_show: !0,
17110 grid_focus_y: !1,
17111 grid_front: !1,
17112 grid_lines_front: !0
17113});
17114;// CONCATENATED MODULE: ./src/config/resolver/axis.ts
17115/**
17116 * Copyright (c) 2017 ~ present NAVER Corp.
17117 * billboard.js project is licensed under the MIT license
17118 */
17119
17120/**
17121 * Modules exports for Axis based chart
17122 */
17123// Chart
17124
17125
17126
17127
17128
17129
17130
17131 // ChartInternal
17132
17133
17134
17135
17136
17137
17138
17139 // Axis based options
17140
17141
17142
17143
17144var api = [api_axis, api_category, grid_x, grid_y, flow, group, api_regions, x];
17145var internal = [Axis, clip, eventrect, interactions_flow, grid, region, size_axis];
17146var options = [data_axis, axis_axis, common_grid];
17147// EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
17148var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(12);
17149;// CONCATENATED MODULE: ./src/ChartInternal/shape/arc.ts
17150/**
17151 * Copyright (c) 2017 ~ present NAVER Corp.
17152 * billboard.js project is licensed under the MIT license
17153 */
17154
17155
17156
17157
17158
17159
17160/* harmony default export */ var arc = ({
17161 initPie: function initPie() {
17162 var $$ = this,
17163 config = $$.config,
17164 dataType = config.data_type,
17165 padding = config.pie_padding,
17166 startingAngle = config[dataType + "_startingAngle"] || 0,
17167 padAngle = ($$.hasType("pie") && padding ? padding * .01 : config[dataType + "_padAngle"]) || 0;
17168 $$.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) {
17169 return d.values.reduce(function (a, b) {
17170 return a + b.value;
17171 }, 0);
17172 }).sort($$.getSortCompareFn.bind($$)(!0));
17173 },
17174 updateRadius: function updateRadius() {
17175 var $$ = this,
17176 config = $$.config,
17177 state = $$.state,
17178 padding = config.pie_padding,
17179 w = config.gauge_width || config.donut_width,
17180 gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length * config.gauge_arcs_minWidth;
17181 // determine radius
17182 state.radiusExpanded = Math.min(state.arcWidth, state.arcHeight) / 2 * ($$.hasMultiArcGauge() ? .85 : 1);
17183 state.radius = state.radiusExpanded * .95;
17184 state.innerRadiusRatio = w ? (state.radius - w) / state.radius : .6;
17185 state.gaugeArcWidth = w || (gaugeArcWidth <= state.radius - state.innerRadius ? state.radius - state.innerRadius : gaugeArcWidth <= state.radius ? gaugeArcWidth : state.radius);
17186 var innerRadius = config.pie_innerRadius || (padding ? padding * (state.innerRadiusRatio + .1) : 0); // NOTE: inner/outerRadius can be an object by user setting, only for 'pie' type
17187
17188 state.outerRadius = config.pie_outerRadius;
17189 state.innerRadius = $$.hasType("donut") || $$.hasType("gauge") ? state.radius * state.innerRadiusRatio : innerRadius;
17190 },
17191
17192 /**
17193 * Get pie's inner & outer radius value
17194 * @param {object|undefined} d Data object
17195 * @returns {object}
17196 * @private
17197 */
17198 getRadius: function getRadius(d) {
17199 var $$ = this,
17200 data = d == null ? void 0 : d.data,
17201 _$$$state = $$.state,
17202 innerRadius = _$$$state.innerRadius,
17203 outerRadius = _$$$state.outerRadius;
17204
17205 if (!isNumber(innerRadius) && data) {
17206 innerRadius = innerRadius[data.id] || 0;
17207 }
17208
17209 if (isObject(outerRadius) && data && data.id in outerRadius) {
17210 outerRadius = outerRadius[data.id];
17211 } else if (!isNumber(outerRadius)) {
17212 outerRadius = $$.state.radius;
17213 }
17214
17215 return {
17216 innerRadius: innerRadius,
17217 outerRadius: outerRadius
17218 };
17219 },
17220 updateArc: function updateArc() {
17221 var $$ = this;
17222 $$.updateRadius();
17223 $$.svgArc = $$.getSvgArc();
17224 $$.svgArcExpanded = $$.getSvgArcExpanded();
17225 },
17226 getArcLength: function getArcLength() {
17227 var $$ = this,
17228 config = $$.config,
17229 arcLengthInPercent = config.gauge_arcLength * 3.6,
17230 len = 2 * (arcLengthInPercent / 360);
17231
17232 if (arcLengthInPercent < -360) {
17233 len = -2;
17234 } else if (arcLengthInPercent > 360) {
17235 len = 2;
17236 }
17237
17238 return len * Math.PI;
17239 },
17240 getStartAngle: function getStartAngle() {
17241 var $$ = this,
17242 config = $$.config,
17243 isFullCircle = config.gauge_fullCircle,
17244 defaultStartAngle = -1 * Math.PI / 2,
17245 defaultEndAngle = Math.PI / 2,
17246 startAngle = config.gauge_startingAngle;
17247
17248 if (!isFullCircle && startAngle <= defaultStartAngle) {
17249 startAngle = defaultStartAngle;
17250 } else if (!isFullCircle && startAngle >= defaultEndAngle) {
17251 startAngle = defaultEndAngle;
17252 } else if (startAngle > Math.PI || startAngle < -1 * Math.PI) {
17253 startAngle = Math.PI;
17254 }
17255
17256 return startAngle;
17257 },
17258 updateAngle: function updateAngle(dValue) {
17259 var $$ = this,
17260 config = $$.config,
17261 state = $$.state,
17262 pie = $$.pie,
17263 d = dValue,
17264 found = !1;
17265
17266 if (!config) {
17267 return null;
17268 }
17269
17270 var gStart = $$.getStartAngle(),
17271 radius = config.gauge_fullCircle ? $$.getArcLength() : gStart * -2;
17272
17273 if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
17274 var _config = config,
17275 min = _config.gauge_min,
17276 max = _config.gauge_max,
17277 totalSum = $$.getTotalDataSum(state.rendered); // to prevent excluding total data sum during the init(when data.hide option is used), use $$.rendered state value
17278
17279 pie = pie.startAngle(gStart).endAngle(radius * ((totalSum - min) / (max - min)) + gStart);
17280 }
17281
17282 pie($$.filterTargetsToShow()).forEach(function (t, i) {
17283 if (!found && t.data.id === d.data.id) {
17284 found = !0;
17285 d = t;
17286 d.index = i;
17287 }
17288 });
17289
17290 if (isNaN(d.startAngle)) {
17291 d.startAngle = 0;
17292 }
17293
17294 if (isNaN(d.endAngle)) {
17295 d.endAngle = d.startAngle;
17296 }
17297
17298 if (d.data && $$.hasMultiArcGauge()) {
17299 var gMin = config.gauge_min,
17300 gMax = config.gauge_max,
17301 gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : gMax - gMin;
17302 d.startAngle = gStart;
17303 d.endAngle = gStart + radius / (gMax - gMin) * gValue;
17304 }
17305
17306 return found ? d : null;
17307 },
17308 getSvgArc: function getSvgArc() {
17309 var $$ = this,
17310 state = $$.state,
17311 singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
17312 hasMultiArcGauge = $$.hasMultiArcGauge(),
17313 arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
17314 var _$$$getRadius = $$.getRadius(d),
17315 innerRadius = _$$$getRadius.innerRadius;
17316
17317 return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : isNumber(innerRadius) ? innerRadius : 0;
17318 }).outerRadius(function (d) {
17319 var _$$$getRadius2 = $$.getRadius(d),
17320 outerRadius = _$$$getRadius2.outerRadius;
17321
17322 return hasMultiArcGauge ? state.radius - singleArcWidth * d.index : outerRadius;
17323 }),
17324 newArc = function (d, withoutUpdate) {
17325 var path = "M 0 0";
17326
17327 if (d.value || d.data) {
17328 var updated = !withoutUpdate && $$.updateAngle(d);
17329
17330 if (withoutUpdate) {
17331 path = arc(d);
17332 } else if (updated) {
17333 path = arc(updated);
17334 }
17335 }
17336
17337 return path;
17338 };
17339
17340 // TODO: extends all function
17341 newArc.centroid = arc.centroid;
17342 return newArc;
17343 },
17344 getSvgArcExpanded: function getSvgArcExpanded(rate) {
17345 var $$ = this,
17346 state = $$.state,
17347 newRate = rate || 1,
17348 singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
17349 hasMultiArcGauge = $$.hasMultiArcGauge(),
17350 expandWidth = Math.min(state.radiusExpanded * newRate - state.radius, singleArcWidth * .8 - (1 - newRate) * 100),
17351 arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
17352 return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : $$.getRadius(d).innerRadius;
17353 }).outerRadius(function (d) {
17354 var radius;
17355
17356 if (hasMultiArcGauge) {
17357 radius = state.radius - singleArcWidth * d.index + expandWidth;
17358 } else {
17359 var _$$$getRadius3 = $$.getRadius(d),
17360 outerRadius = _$$$getRadius3.outerRadius,
17361 radiusExpanded = state.radiusExpanded;
17362
17363 if (state.radius !== outerRadius) {
17364 radiusExpanded -= Math.abs(state.radius - outerRadius);
17365 }
17366
17367 radius = radiusExpanded * newRate;
17368 }
17369
17370 return radius;
17371 });
17372 return function (d) {
17373 var updated = $$.updateAngle(d);
17374 return updated ? arc(updated) : "M 0 0";
17375 };
17376 },
17377 getArc: function getArc(d, withoutUpdate, force) {
17378 return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0";
17379 },
17380 transformForArcLabel: function transformForArcLabel(d) {
17381 var $$ = this,
17382 config = $$.config,
17383 radiusExpanded = $$.state.radiusExpanded,
17384 updated = $$.updateAngle(d),
17385 translate = "";
17386
17387 if (updated) {
17388 if ($$.hasMultiArcGauge()) {
17389 var y1 = Math.sin(updated.endAngle - Math.PI / 2),
17390 x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + 25),
17391 y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
17392 translate = "translate(" + x + "," + y + ")";
17393 } else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
17394 var _$$$getRadius4 = $$.getRadius(d),
17395 outerRadius = _$$$getRadius4.outerRadius,
17396 c = this.svgArc.centroid(updated),
17397 _c$map = c.map(function (v) {
17398 return isNaN(v) ? 0 : v;
17399 }),
17400 x = _c$map[0],
17401 y = _c$map[1],
17402 h = Math.sqrt(x * x + y * y),
17403 ratio = $$.hasType("donut") && config.donut_label_ratio || $$.hasType("pie") && config.pie_label_ratio;
17404
17405 if (ratio) {
17406 ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
17407 } else {
17408 ratio = outerRadius && (h ? (36 / outerRadius > .375 ? 1.175 - 36 / outerRadius : .8) * outerRadius / h : 0);
17409 }
17410
17411 translate = "translate(" + x * ratio + "," + y * ratio + ")";
17412 }
17413 }
17414
17415 return translate;
17416 },
17417 convertToArcData: function convertToArcData(d) {
17418 return this.addName({
17419 id: d.data ? d.data.id : d.id,
17420 value: d.value,
17421 ratio: this.getRatio("arc", d),
17422 index: d.index
17423 });
17424 },
17425 textForArcLabel: function textForArcLabel(selection) {
17426 var $$ = this,
17427 hasGauge = $$.hasType("gauge");
17428
17429 if ($$.shouldShowArcLabel()) {
17430 selection.style("fill", $$.updateTextColor.bind($$)).attr("filter", $$.updateTextBacgroundColor.bind($$)).each(function (d) {
17431 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
17432 updated = $$.updateAngle(d),
17433 ratio = $$.getRatio("arc", updated),
17434 isUnderThreshold = $$.meetsLabelThreshold(ratio, $$.hasType("donut") && "donut" || $$.hasType("gauge") && "gauge" || $$.hasType("pie") && "pie");
17435
17436 if (isUnderThreshold) {
17437 var value = (updated || d).value,
17438 text = ($$.getArcLabelFormat() || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
17439 setTextValue(node, text, [-1, 1], hasGauge);
17440 } else {
17441 node.text("");
17442 }
17443 });
17444 }
17445 },
17446 expandArc: function expandArc(targetIds) {
17447 var $$ = this,
17448 transiting = $$.state.transiting,
17449 $el = $$.$el;
17450
17451 // MEMO: avoid to cancel transition
17452 if (transiting) {
17453 var interval = setInterval(function () {
17454 if (!transiting) {
17455 clearInterval(interval);
17456 $el.legend.selectAll("." + config_classes.legendItemFocused).size() > 0 && $$.expandArc(targetIds);
17457 }
17458 }, 10);
17459 return;
17460 }
17461
17462 var newTargetIds = $$.mapToTargetIds(targetIds);
17463 $el.svg.selectAll($$.selectorTargets(newTargetIds, "." + config_classes.chartArc)).each(function (d) {
17464 if (!$$.shouldExpand(d.data.id)) {
17465 return;
17466 }
17467
17468 var expandDuration = $$.getExpandConfig(d.data.id, "duration"),
17469 svgArcExpandedSub = $$.getSvgArcExpanded($$.getExpandConfig(d.data.id, "rate"));
17470 (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);
17471 });
17472 },
17473 unexpandArc: function unexpandArc(targetIds) {
17474 var $$ = this,
17475 transiting = $$.state.transiting,
17476 svg = $$.$el.svg;
17477
17478 if (transiting) {
17479 return;
17480 }
17481
17482 var newTargetIds = $$.mapToTargetIds(targetIds);
17483 svg.selectAll($$.selectorTargets(newTargetIds, "." + config_classes.chartArc)).selectAll("path").transition().duration(function (d) {
17484 return $$.getExpandConfig(d.data.id, "duration");
17485 }).attr("d", $$.svgArc);
17486 svg.selectAll("" + config_classes.arc).style("opacity", null);
17487 },
17488
17489 /**
17490 * Get expand config value
17491 * @param {string} id data ID
17492 * @param {string} key config key: 'duration | rate'
17493 * @returns {number}
17494 * @private
17495 */
17496 getExpandConfig: function getExpandConfig(id, key) {
17497 var $$ = this,
17498 config = $$.config,
17499 type;
17500
17501 if ($$.isDonutType(id)) {
17502 type = "donut";
17503 } else if ($$.isGaugeType(id)) {
17504 type = "gauge";
17505 } else if ($$.isPieType(id)) {
17506 type = "pie";
17507 }
17508
17509 return type ? config[type + "_expand_" + key] : {
17510 duration: 50,
17511 rate: .98
17512 }[key];
17513 },
17514 shouldExpand: function shouldExpand(id) {
17515 var $$ = this,
17516 config = $$.config;
17517 return $$.isDonutType(id) && config.donut_expand || $$.isGaugeType(id) && config.gauge_expand || $$.isPieType(id) && config.pie_expand;
17518 },
17519 shouldShowArcLabel: function shouldShowArcLabel() {
17520 var $$ = this,
17521 config = $$.config;
17522 return ["pie", "donut", "gauge"].some(function (v) {
17523 return $$.hasType(v) && config[v + "_label_show"];
17524 });
17525 },
17526 getArcLabelFormat: function getArcLabelFormat() {
17527 var $$ = this,
17528 config = $$.config,
17529 format = config.pie_label_format;
17530
17531 if ($$.hasType("gauge")) {
17532 format = config.gauge_label_format;
17533 } else if ($$.hasType("donut")) {
17534 format = config.donut_label_format;
17535 }
17536
17537 return isFunction(format) ? format.bind($$.api) : format;
17538 },
17539 getArcTitle: function getArcTitle() {
17540 var $$ = this,
17541 type = $$.hasType("donut") && "donut" || $$.hasType("gauge") && "gauge";
17542 return type ? $$.config[type + "_title"] : "";
17543 },
17544 updateTargetsForArc: function updateTargetsForArc(targets) {
17545 var $$ = this,
17546 $el = $$.$el,
17547 hasGauge = $$.hasType("gauge"),
17548 classChartArc = $$.getChartClass("Arc"),
17549 classArcs = $$.getClass("arcs", !0),
17550 classFocus = $$.classFocus.bind($$),
17551 chartArcs = $el.main.select("." + config_classes.chartArcs),
17552 mainPieUpdate = chartArcs.selectAll("." + config_classes.chartArc).data($$.pie(targets)).attr("class", function (d) {
17553 return classChartArc(d) + classFocus(d.data);
17554 }),
17555 mainPieEnter = mainPieUpdate.enter().append("g").attr("class", classChartArc);
17556 mainPieEnter.append("g").attr("class", classArcs).merge(mainPieUpdate);
17557 mainPieEnter.append("text").attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" : ".35em").style("opacity", "0").style("text-anchor", "middle").style("pointer-events", "none");
17558 $el.text = chartArcs.selectAll("." + config_classes.target + " text"); // MEMO: can not keep same color..., but not bad to update color in redraw
17559 // mainPieUpdate.exit().remove();
17560 },
17561 initArc: function initArc() {
17562 var $$ = this,
17563 $el = $$.$el;
17564 $el.arcs = $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartArcs).attr("transform", $$.getTranslate("arc"));
17565 $$.setArcTitle();
17566 },
17567
17568 /**
17569 * Set arc title text
17570 * @private
17571 */
17572 setArcTitle: function setArcTitle() {
17573 var $$ = this,
17574 title = $$.getArcTitle(),
17575 hasGauge = $$.hasType("gauge");
17576
17577 if (title) {
17578 var text = $$.$el.arcs.append("text").attr("class", config_classes[hasGauge ? "chartArcsGaugeTitle" : "chartArcsTitle"]).style("text-anchor", "middle");
17579 hasGauge && text.attr("dy", "-0.3em");
17580 setTextValue(text, title, hasGauge ? undefined : [-.6, 1.35], !0);
17581 }
17582 },
17583 redrawArc: function redrawArc(duration, durationForExit, withTransform) {
17584 var $$ = this,
17585 config = $$.config,
17586 state = $$.state,
17587 main = $$.$el.main,
17588 hasInteraction = config.interaction_enabled,
17589 isSelectable = hasInteraction && config.data_selection_isselectable,
17590 mainArc = main.selectAll("." + config_classes.arcs).selectAll("." + config_classes.arc).data($$.arcData.bind($$));
17591 mainArc.exit().transition().duration(durationForExit).style("opacity", "0").remove();
17592 mainArc = mainArc.enter().append("path").attr("class", $$.getClass("arc", !0)).style("fill", function (d) {
17593 return $$.color(d.data);
17594 }).style("cursor", function (d) {
17595 var _isSelectable;
17596
17597 return (_isSelectable = isSelectable) != null && _isSelectable.bind != null && _isSelectable.bind($$.api)(d) ? "pointer" : null;
17598 }).style("opacity", "0").each(function (d) {
17599 if ($$.isGaugeType(d.data)) {
17600 d.startAngle = config.gauge_startingAngle;
17601 d.endAngle = config.gauge_startingAngle;
17602 }
17603
17604 this._current = d;
17605 }).merge(mainArc);
17606
17607 if ($$.hasType("gauge")) {
17608 $$.updateGaugeMax();
17609 $$.hasMultiArcGauge() && $$.redrawMultiArcGauge();
17610 }
17611
17612 mainArc.attr("transform", function (d) {
17613 return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : "";
17614 }).style("opacity", function (d) {
17615 return d === this._current ? "0" : null;
17616 }).each(function () {
17617 state.transiting = !0;
17618 }).transition().duration(duration).attrTween("d", function (d) {
17619 var updated = $$.updateAngle(d);
17620
17621 if (!updated) {
17622 return function () {
17623 return "M 0 0";
17624 };
17625 }
17626
17627 if (isNaN(this._current.startAngle)) {
17628 this._current.startAngle = 0;
17629 }
17630
17631 if (isNaN(this._current.endAngle)) {
17632 this._current.endAngle = this._current.startAngle;
17633 }
17634
17635 var interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(this._current, updated);
17636 this._current = interpolate(0);
17637 return function (t) {
17638 var interpolated = interpolate(t);
17639 interpolated.data = d.data; // data.id will be updated by interporator
17640
17641 return $$.getArc(interpolated, !0);
17642 };
17643 }).attr("transform", withTransform ? "scale(1)" : "").style("fill", function (d) {
17644 var color;
17645
17646 if ($$.levelColor) {
17647 color = $$.levelColor(d.data.values[0].value); // update data's color
17648
17649 config.data_colors[d.data.id] = color;
17650 } else {
17651 color = $$.color(d.data);
17652 }
17653
17654 return color;
17655 }) // Where gauge reading color would receive customization.
17656 .style("opacity", null).call(endall, function () {
17657 if ($$.levelColor) {
17658 var path = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
17659 d = path.datum();
17660 $$.updateLegendItemColor(d.data.id, path.style("fill"));
17661 }
17662
17663 state.transiting = !1;
17664 callFn(config.onrendered, $$.api);
17665 }); // bind arc events
17666
17667 hasInteraction && $$.bindArcEvent(mainArc);
17668 $$.hasType("gauge") && $$.redrawBackgroundArcs();
17669 $$.redrawArcText(duration);
17670 },
17671 redrawBackgroundArcs: function redrawBackgroundArcs() {
17672 var $$ = this,
17673 config = $$.config,
17674 state = $$.state,
17675 hasMultiArcGauge = $$.hasMultiArcGauge(),
17676 isFullCircle = config.gauge_fullCircle,
17677 startAngle = $$.getStartAngle(),
17678 endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1,
17679 backgroundArc = $$.$el.arcs.select((hasMultiArcGauge ? "g" : "") + "." + config_classes.chartArcsBackground);
17680
17681 if (hasMultiArcGauge) {
17682 var index = 0;
17683 backgroundArc = backgroundArc.selectAll("path." + config_classes.chartArcsBackground).data($$.data.targets);
17684 backgroundArc.enter().append("path").attr("class", function (d, i) {
17685 return config_classes.chartArcsBackground + " " + config_classes.chartArcsBackground + "-" + i;
17686 }).merge(backgroundArc).style("fill", config.gauge_background || null).attr("d", function (_ref2) {
17687 var id = _ref2.id;
17688
17689 if (state.hiddenTargetIds.indexOf(id) >= 0) {
17690 return "M 0 0";
17691 }
17692
17693 var d = {
17694 data: [{
17695 value: config.gauge_max
17696 }],
17697 startAngle: startAngle,
17698 endAngle: endAngle,
17699 index: index++
17700 };
17701 return $$.getArc(d, !0, !0);
17702 });
17703 backgroundArc.exit().remove();
17704 } else {
17705 backgroundArc.attr("d", function () {
17706 var d = {
17707 data: [{
17708 value: config.gauge_max
17709 }],
17710 startAngle: startAngle,
17711 endAngle: endAngle
17712 };
17713 return $$.getArc(d, !0, !0);
17714 });
17715 }
17716 },
17717 bindArcEvent: function bindArcEvent(arc) {
17718 var $$ = this,
17719 config = $$.config,
17720 state = $$.state,
17721 isTouch = state.inputType === "touch",
17722 isMouse = state.inputType === "mouse";
17723
17724 // eslint-disable-next-line
17725 function selectArc(_this, arcData, id) {
17726 // transitions
17727 $$.expandArc(id);
17728 $$.api.focus(id);
17729 $$.toggleFocusLegend(id, !0);
17730 $$.showTooltip([arcData], _this);
17731 } // eslint-disable-next-line
17732
17733
17734 function unselectArc(arcData) {
17735 var id = (arcData == null ? void 0 : arcData.id) || undefined;
17736 $$.unexpandArc(id);
17737 $$.api.revert();
17738 $$.revertLegend();
17739 $$.hideTooltip();
17740 }
17741
17742 arc.on("click", function (event, d, i) {
17743 var updated = $$.updateAngle(d),
17744 arcData;
17745
17746 if (updated) {
17747 arcData = $$.convertToArcData(updated);
17748 $$.toggleShape == null ? void 0 : $$.toggleShape(this, arcData, i);
17749 config.data_onclick.bind($$.api)(arcData, this);
17750 }
17751 }); // mouse events
17752
17753 if (isMouse) {
17754 arc.on("mouseover", function (event, d) {
17755 var _arcData;
17756
17757 if (state.transiting) {
17758 // skip while transiting
17759 return;
17760 }
17761
17762 state.event = event;
17763 var updated = $$.updateAngle(d),
17764 arcData = updated ? $$.convertToArcData(updated) : null,
17765 id = ((_arcData = arcData) == null ? void 0 : _arcData.id) || undefined;
17766 selectArc(this, arcData, id);
17767 $$.setOverOut(!0, arcData);
17768 }).on("mouseout", function (event, d) {
17769 if (state.transiting) {
17770 // skip while transiting
17771 return;
17772 }
17773
17774 state.event = event;
17775 var updated = $$.updateAngle(d),
17776 arcData = updated ? $$.convertToArcData(updated) : null;
17777 unselectArc();
17778 $$.setOverOut(!1, arcData);
17779 }).on("mousemove", function (event, d) {
17780 var updated = $$.updateAngle(d),
17781 arcData = updated ? $$.convertToArcData(updated) : null;
17782 state.event = event;
17783 $$.showTooltip([arcData], this);
17784 });
17785 } // touch events
17786
17787
17788 if (isTouch && $$.hasArcType() && !$$.radars) {
17789 var getEventArc = function (event) {
17790 var touch = event.changedTouches[0],
17791 eventArc = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.elementFromPoint(touch.clientX, touch.clientY));
17792 return eventArc;
17793 };
17794
17795 $$.$el.svg.on("touchstart touchmove", function (event) {
17796 var _datum, _arcData2;
17797
17798 if (state.transiting) {
17799 // skip while transiting
17800 return;
17801 }
17802
17803 var eventArc = getEventArc(event),
17804 datum = eventArc.datum(),
17805 updated = (_datum = datum) != null && _datum.data && datum.data.id ? $$.updateAngle(datum) : null,
17806 arcData = updated ? $$.convertToArcData(updated) : null,
17807 id = ((_arcData2 = arcData) == null ? void 0 : _arcData2.id) || undefined;
17808 $$.callOverOutForTouch(arcData);
17809 isUndefined(id) ? unselectArc() : selectArc(this, arcData, id);
17810 });
17811 }
17812 },
17813 redrawArcText: function redrawArcText(duration) {
17814 var $$ = this,
17815 config = $$.config,
17816 state = $$.state,
17817 _$$$$el = $$.$el,
17818 main = _$$$$el.main,
17819 arcs = _$$$$el.arcs,
17820 hasGauge = $$.hasType("gauge"),
17821 hasMultiArcGauge = $$.hasMultiArcGauge(),
17822 text;
17823
17824 // for gauge type, update text when has no title & multi data
17825 if (!(hasGauge && $$.data.targets.length === 1 && config.gauge_title)) {
17826 text = main.selectAll("." + config_classes.chartArc).select("text").style("opacity", "0").attr("class", function (d) {
17827 return $$.isGaugeType(d.data) ? config_classes.gaugeValue : null;
17828 }).call($$.textForArcLabel.bind($$)).attr("transform", $$.transformForArcLabel.bind($$)).style("font-size", function (d) {
17829 return $$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ? Math.round(state.radius / 5) + "px" : null;
17830 }).transition().duration(duration).style("opacity", function (d) {
17831 return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0";
17832 });
17833 hasMultiArcGauge && text.attr("dy", "-.1em");
17834 }
17835
17836 main.select("." + config_classes.chartArcsTitle).style("opacity", $$.hasType("donut") || hasGauge ? null : "0");
17837
17838 if (hasGauge) {
17839 var _text,
17840 isFullCircle = config.gauge_fullCircle;
17841
17842 isFullCircle && ((_text = text) == null ? void 0 : _text.attr("dy", "" + (hasMultiArcGauge ? 0 : Math.round(state.radius / 14))));
17843
17844 if (config.gauge_label_show) {
17845 arcs.select("." + config_classes.chartArcsGaugeUnit).attr("dy", (isFullCircle ? 1.5 : .75) + "em").text(config.gauge_units);
17846 arcs.select("." + config_classes.chartArcsGaugeMin).attr("dx", -1 * (state.innerRadius + (state.radius - state.innerRadius) / (isFullCircle ? 1 : 2)) + "px").attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_min, !1)); // show max text when isn't fullCircle
17847
17848 isFullCircle || arcs.select("." + config_classes.chartArcsGaugeMax).attr("dx", state.innerRadius + (state.radius - state.innerRadius) / 2 + "px").attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_max, !0));
17849 }
17850 }
17851 }
17852});
17853;// CONCATENATED MODULE: ./src/ChartInternal/shape/area.ts
17854/**
17855 * Copyright (c) 2017 ~ present NAVER Corp.
17856 * billboard.js project is licensed under the MIT license
17857 */
17858
17859
17860
17861
17862/* harmony default export */ var shape_area = ({
17863 initArea: function initArea(mainLine) {
17864 var $$ = this,
17865 config = $$.config;
17866 mainLine.insert("g", "." + config_classes[config.area_front ? "circles" : "lines"]).attr("class", $$.getClass("areas", !0));
17867 },
17868 updateAreaGradient: function updateAreaGradient() {
17869 var $$ = this,
17870 config = $$.config,
17871 datetimeId = $$.state.datetimeId,
17872 defs = $$.$el.defs;
17873 $$.data.targets.forEach(function (d) {
17874 var id = datetimeId + "-areaGradient" + $$.getTargetSelectorSuffix(d.id);
17875
17876 if ($$.isAreaType(d) && defs.select("#" + id).empty()) {
17877 var color = $$.color(d),
17878 _config$area_linearGr = config.area_linearGradient,
17879 _config$area_linearGr2 = _config$area_linearGr.x,
17880 x = _config$area_linearGr2 === void 0 ? [0, 0] : _config$area_linearGr2,
17881 _config$area_linearGr3 = _config$area_linearGr.y,
17882 y = _config$area_linearGr3 === void 0 ? [0, 1] : _config$area_linearGr3,
17883 _config$area_linearGr4 = _config$area_linearGr.stops,
17884 stops = _config$area_linearGr4 === void 0 ? [[0, color, 1], [1, color, 0]] : _config$area_linearGr4,
17885 linearGradient = defs.append("linearGradient").attr("id", "" + id).attr("x1", x[0]).attr("x2", x[1]).attr("y1", y[0]).attr("y2", y[1]);
17886 stops.forEach(function (v) {
17887 var stopColor = isFunction(v[1]) ? v[1].bind($$.api)(d.id) : v[1];
17888 linearGradient.append("stop").attr("offset", v[0]).attr("stop-color", stopColor || color).attr("stop-opacity", v[2]);
17889 });
17890 }
17891 });
17892 },
17893 updateAreaColor: function updateAreaColor(d) {
17894 var $$ = this;
17895 return $$.config.area_linearGradient ? "url(#" + $$.state.datetimeId + "-areaGradient" + $$.getTargetSelectorSuffix(d.id) + ")" : $$.color(d);
17896 },
17897
17898 /**
17899 * Generate/Update elements
17900 * @param {boolean} withTransition Transition for exit elements
17901 * @param {boolean} isSub Subchart draw
17902 * @private
17903 */
17904 updateArea: function updateArea(withTransition, isSub) {
17905 if (isSub === void 0) {
17906 isSub = !1;
17907 }
17908
17909 var $$ = this,
17910 config = $$.config,
17911 state = $$.state,
17912 $el = $$.$el,
17913 $T = $$.$T,
17914 $root = isSub ? $el.subchart : $el;
17915 config.area_linearGradient && $$.updateAreaGradient();
17916 var area = $root.main.selectAll("." + config_classes.areas).selectAll("." + config_classes.area).data($$.lineData.bind($$));
17917 $T(area.exit(), withTransition).style("opacity", "0").remove();
17918 $root.area = area.enter().append("path").attr("class", $$.getClass("area", !0)).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function () {
17919 state.orgAreaOpacity = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).style("opacity");
17920 return "0";
17921 }).merge(area);
17922 area.style("opacity", state.orgAreaOpacity);
17923 },
17924
17925 /**
17926 * Redraw function
17927 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
17928 * @param {boolean} withTransition With or without transition
17929 * @param {boolean} isSub Subchart draw
17930 * @returns {Array}
17931 */
17932 redrawArea: function redrawArea(drawFn, withTransition, isSub) {
17933 if (isSub === void 0) {
17934 isSub = !1;
17935 }
17936
17937 var $$ = this,
17938 _ref = isSub ? this.$el.subchart : this.$el,
17939 area = _ref.area,
17940 orgAreaOpacity = $$.state.orgAreaOpacity;
17941
17942 return [$$.$T(area, withTransition, getRandom()).attr("d", drawFn).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function (d) {
17943 return ($$.isAreaRangeType(d) ? orgAreaOpacity / 1.75 : orgAreaOpacity) + "";
17944 })];
17945 },
17946
17947 /**
17948 * Generate area path data
17949 * @param {object} areaIndices Indices
17950 * @param {boolean} isSub Weather is sub axis
17951 * @returns {Function}
17952 * @private
17953 */
17954 generateDrawArea: function generateDrawArea(areaIndices, isSub) {
17955 var $$ = this,
17956 config = $$.config,
17957 lineConnectNull = config.line_connectNull,
17958 isRotated = config.axis_rotated,
17959 getPoints = $$.generateGetAreaPoints(areaIndices, isSub),
17960 yScale = $$.getYScaleById.bind($$),
17961 xValue = function (d) {
17962 return (isSub ? $$.subxx : $$.xx).call($$, d);
17963 },
17964 value0 = function (d, i) {
17965 return $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : $$.getShapeYMin(d.id));
17966 },
17967 value1 = function (d, i) {
17968 return $$.isGrouped(d.id) ? getPoints(d, i)[1][1] : yScale(d.id, isSub)($$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : d.value);
17969 };
17970
17971 return function (d) {
17972 var values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
17973 x0 = 0,
17974 y0 = 0,
17975 path;
17976
17977 if ($$.isAreaType(d)) {
17978 var area = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.area)();
17979 area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue) // @ts-ignore
17980 .y0(config.area_above ? 0 : value0).y1(value1);
17981
17982 if (!lineConnectNull) {
17983 area = area.defined(function (d) {
17984 return $$.getBaseValue(d) !== null;
17985 });
17986 }
17987
17988 if ($$.isStepType(d)) {
17989 values = $$.convertValuesToStep(values);
17990 }
17991
17992 path = area.curve($$.getCurve(d))(values);
17993 } else {
17994 if (values[0]) {
17995 x0 = $$.scale.x(values[0].x);
17996 y0 = $$.getYScaleById(d.id)(values[0].value);
17997 }
17998
17999 path = isRotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
18000 }
18001
18002 return path || "M 0 0";
18003 };
18004 },
18005 generateGetAreaPoints: function generateGetAreaPoints(areaIndices, isSub) {
18006 // partial duplication of generateGetBarPoints
18007 var $$ = this,
18008 config = $$.config,
18009 x = $$.getShapeX(0, areaIndices, isSub),
18010 y = $$.getShapeY(!!isSub),
18011 areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, isSub),
18012 yScale = $$.getYScaleById.bind($$);
18013 return function (d, i) {
18014 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
18015 offset = areaOffset(d, i) || y0,
18016 posX = x(d),
18017 posY = y(d);
18018
18019 // fix posY not to overflow opposite quadrant
18020 if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
18021 posY = y0;
18022 } // 1 point that marks the area position
18023
18024
18025 return [[posX, offset], [posX, posY - (y0 - offset)], [posX, posY - (y0 - offset)], // needed for compatibility
18026 [posX, offset] // needed for compatibility
18027 ];
18028 };
18029 }
18030});
18031;// CONCATENATED MODULE: ./src/ChartInternal/shape/bar.ts
18032/**
18033 * Copyright (c) 2017 ~ present NAVER Corp.
18034 * billboard.js project is licensed under the MIT license
18035 */
18036
18037
18038/* harmony default export */ var bar = ({
18039 initBar: function initBar() {
18040 var $el = this.$el,
18041 config = this.config,
18042 clip = this.state.clip;
18043 $el.bar = $el.main.select("." + config_classes.chart) // should positioned at the beginning of the shape node to not overlap others
18044 .insert("g", ":first-child").attr("class", config_classes.chartBars); // set clip-path attribute when condition meet
18045 // https://github.com/naver/billboard.js/issues/2421
18046
18047 if (config.clipPath === !1 && (config.bar_radius || config.bar_radius_ratio)) {
18048 $el.bar.attr("clip-path", clip.pathXAxis.replace(/#[^)]*/, "#" + clip.id));
18049 }
18050 },
18051 updateTargetsForBar: function updateTargetsForBar(targets) {
18052 var $$ = this,
18053 config = $$.config,
18054 $el = $$.$el,
18055 classChartBar = $$.getChartClass("Bar"),
18056 classBars = $$.getClass("bars", !0),
18057 classFocus = $$.classFocus.bind($$),
18058 isSelectable = config.interaction_enabled && config.data_selection_isselectable;
18059
18060 if (!$el.bar) {
18061 $$.initBar();
18062 }
18063
18064 var mainBarUpdate = $$.$el.main.select("." + config_classes.chartBars).selectAll("." + config_classes.chartBar).data( // remove
18065 targets.filter(function (v) {
18066 return !v.values.every(function (d) {
18067 return !isNumber(d.value);
18068 });
18069 })).attr("class", function (d) {
18070 return classChartBar(d) + classFocus(d);
18071 }),
18072 mainBarEnter = mainBarUpdate.enter().append("g").attr("class", classChartBar).style("opacity", "0").style("pointer-events", "none");
18073 // Bars for each data
18074 mainBarEnter.append("g").attr("class", classBars).style("cursor", function (d) {
18075 var _isSelectable;
18076
18077 return (_isSelectable = isSelectable) != null && _isSelectable.bind != null && _isSelectable.bind($$.api)(d) ? "pointer" : null;
18078 });
18079 },
18080
18081 /**
18082 * Generate/Update elements
18083 * @param {boolean} withTransition Transition for exit elements
18084 * @param {boolean} isSub Subchart draw
18085 * @private
18086 */
18087 updateBar: function updateBar(withTransition, isSub) {
18088 if (isSub === void 0) {
18089 isSub = !1;
18090 }
18091
18092 var $$ = this,
18093 $el = $$.$el,
18094 $T = $$.$T,
18095 $root = isSub ? $el.subchart : $el,
18096 classBar = $$.getClass("bar", !0),
18097 initialOpacity = $$.initialOpacity.bind($$),
18098 bar = $root.main.selectAll("." + config_classes.bars).selectAll("." + config_classes.bar).data($$.labelishData.bind($$));
18099 $T(bar.exit(), withTransition).style("opacity", "0").remove();
18100 $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.color).merge(bar).style("opacity", initialOpacity);
18101 },
18102
18103 /**
18104 * Redraw function
18105 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
18106 * @param {boolean} withTransition With or without transition
18107 * @param {boolean} isSub Subchart draw
18108 * @returns {Array}
18109 */
18110 redrawBar: function redrawBar(drawFn, withTransition, isSub) {
18111 if (isSub === void 0) {
18112 isSub = !1;
18113 }
18114
18115 var $$ = this,
18116 _ref = isSub ? $$.$el.subchart : $$.$el,
18117 bar = _ref.bar;
18118
18119 return [$$.$T(bar, withTransition, getRandom()).attr("d", function (d) {
18120 return isNumber(d.value) && drawFn(d);
18121 }).style("fill", this.color).style("opacity", null)];
18122 },
18123 generateDrawBar: function generateDrawBar(barIndices, isSub) {
18124 var $$ = this,
18125 config = $$.config,
18126 getPoints = $$.generateGetBarPoints(barIndices, isSub),
18127 isRotated = config.axis_rotated,
18128 isGrouped = config.data_groups.length,
18129 barRadius = config.bar_radius,
18130 barRadiusRatio = config.bar_radius_ratio,
18131 getRadius = isNumber(barRadius) && barRadius > 0 ? function () {
18132 return barRadius;
18133 } : isNumber(barRadiusRatio) ? function (w) {
18134 return w * barRadiusRatio;
18135 } : null;
18136 return function (d, i) {
18137 // 4 points that make a bar
18138 var points = getPoints(d, i),
18139 indexX = +isRotated,
18140 indexY = +!indexX,
18141 isNegative = d.value < 0,
18142 pathRadius = ["", ""],
18143 radius = 0; // switch points if axis is rotated, not applicable for sub chart
18144
18145 if (d.value !== 0 && getRadius && !isGrouped) {
18146 var index = isRotated ? indexY : indexX,
18147 barW = points[2][index] - points[0][index];
18148 radius = getRadius(barW);
18149 var arc = "a" + radius + "," + radius + " " + (isNegative ? "1 0 0" : "0 0 1") + " ";
18150 pathRadius[+!isRotated] = "" + arc + radius + "," + radius;
18151 pathRadius[+isRotated] = "" + arc + [-radius, radius][isRotated ? "sort" : "reverse"]();
18152 isNegative && pathRadius.reverse();
18153 } // path string data shouldn't be containing new line chars
18154 // https://github.com/naver/billboard.js/issues/530
18155
18156
18157 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];
18158 return "M" + points[0][indexX] + "," + points[0][indexY] + path + "z";
18159 };
18160 },
18161 generateGetBarPoints: function generateGetBarPoints(barIndices, isSub) {
18162 var $$ = this,
18163 config = $$.config,
18164 axis = isSub ? $$.axis.subX : $$.axis.x,
18165 barTargetsNum = $$.getIndicesMax(barIndices) + 1,
18166 barW = $$.getBarW("bar", axis, barTargetsNum),
18167 barX = $$.getShapeX(barW, barIndices, !!isSub),
18168 barY = $$.getShapeY(!!isSub),
18169 barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub),
18170 yScale = $$.getYScaleById.bind($$);
18171 return function (d, i) {
18172 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
18173 offset = barOffset(d, i) || y0,
18174 width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
18175 posX = barX(d),
18176 posY = barY(d);
18177
18178 // fix posY not to overflow opposite quadrant
18179 if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
18180 posY = y0;
18181 }
18182
18183 posY -= y0 - offset;
18184 var startPosX = posX + width; // 4 points that make a bar
18185
18186 return [[posX, offset], [posX, posY], [startPosX, posY], [startPosX, offset]];
18187 };
18188 },
18189 isWithinBar: function isWithinBar(that) {
18190 var mouse = getPointer(this.state.event, that),
18191 list = getRectSegList(that),
18192 _list = list,
18193 seg0 = _list[0],
18194 seg1 = _list[1],
18195 x = Math.min(seg0.x, seg1.x),
18196 y = Math.min(seg0.y, seg1.y),
18197 offset = this.config.bar_sensitivity,
18198 _that$getBBox = that.getBBox(),
18199 width = _that$getBBox.width,
18200 height = _that$getBBox.height,
18201 isWithin = x - offset < mouse[0] && mouse[0] < x + width + offset && y - offset < mouse[1] && mouse[1] < y + height + offset;
18202
18203 return isWithin;
18204 }
18205});
18206;// CONCATENATED MODULE: ./src/ChartInternal/shape/candlestick.ts
18207
18208
18209function candlestick_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
18210
18211function candlestick_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { candlestick_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { candlestick_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18212
18213/**
18214 * Copyright (c) 2017 ~ present NAVER Corp.
18215 * billboard.js project is licensed under the MIT license
18216 */
18217
18218
18219
18220/* harmony default export */ var candlestick = ({
18221 initCandlestick: function initCandlestick() {
18222 var $el = this.$el;
18223 $el.candlestick = $el.main.select("." + config_classes.chart) // should positioned at the beginning of the shape node to not overlap others
18224 .append("g").attr("class", config_classes.chartCandlesticks);
18225 },
18226
18227 /**
18228 * Update targets by its data
18229 * called from: ChartInternal.updateTargets()
18230 * @param {Array} targets Filtered target by type
18231 * @private
18232 */
18233 updateTargetsForCandlestick: function updateTargetsForCandlestick(targets) {
18234 var $$ = this,
18235 $el = $$.$el,
18236 classChart = $$.getChartClass("Candlestick"),
18237 classFocus = $$.classFocus.bind($$);
18238
18239 if (!$el.candlestick) {
18240 $$.initCandlestick();
18241 }
18242
18243 var mainUpdate = $$.$el.main.select("." + config_classes.chartCandlesticks).selectAll("." + config_classes.chartCandlestick).data(targets).attr("class", function (d) {
18244 return classChart(d) + classFocus(d);
18245 });
18246 mainUpdate.enter().append("g").attr("class", classChart).style("pointer-events", "none");
18247 },
18248
18249 /**
18250 * Generate/Update elements
18251 * @param {boolean} withTransition Transition for exit elements
18252 * @param {boolean} isSub Subchart draw
18253 * @private
18254 */
18255 updateCandlestick: function updateCandlestick(withTransition, isSub) {
18256 if (isSub === void 0) {
18257 isSub = !1;
18258 }
18259
18260 var $$ = this,
18261 $el = $$.$el,
18262 $T = $$.$T,
18263 $root = isSub ? $el.subchart : $el,
18264 classSetter = $$.getClass("candlestick", !0),
18265 initialOpacity = $$.initialOpacity.bind($$),
18266 candlestick = $root.main.selectAll("." + config_classes.chartCandlestick).selectAll("." + config_classes.candlestick).data($$.labelishData.bind($$));
18267 $T(candlestick.exit(), withTransition).style("opacity", "0").remove();
18268 var candlestickEnter = candlestick.enter().filter(function (d) {
18269 return d.value;
18270 }).append("g").attr("class", classSetter);
18271 candlestickEnter.append("line");
18272 candlestickEnter.append("path");
18273
18274 if (!$root.candlestick) {
18275 $root.candlestick = {};
18276 }
18277
18278 $root.candlestick = candlestick.merge(candlestickEnter).style("opacity", initialOpacity);
18279 },
18280
18281 /**
18282 * Get draw function
18283 * @param {object} indices Indice data
18284 * @param {boolean} isSub Subchart draw
18285 * @returns {Function}
18286 * @private
18287 */
18288 generateDrawCandlestick: function generateDrawCandlestick(indices, isSub) {
18289 var $$ = this,
18290 config = $$.config,
18291 getPoints = $$.generateGetCandlestickPoints(indices, isSub),
18292 isRotated = config.axis_rotated,
18293 downColor = config.candlestick_color_down;
18294 return function (d, i, g) {
18295 var _value,
18296 points = getPoints(d, i),
18297 value = $$.getCandlestickData(d),
18298 isUp = (_value = value) == null ? void 0 : _value._isUp,
18299 indexX = +isRotated;
18300
18301 if (g.classed) {
18302 g.classed(config_classes[isUp ? "valueUp" : "valueDown"], !0);
18303 }
18304
18305 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];
18306 g.select("path").attr("d", "M" + points[0][indexX] + "," + points[0][+!indexX] + path + "z").style("fill", function (d) {
18307 var color = isUp ? $$.color(d) : isObject(downColor) ? downColor[d.id] : downColor;
18308 return color || $$.color(d);
18309 }); // set line position
18310
18311 var line = g.select("line"),
18312 pos = isRotated ? {
18313 x1: points[2][1],
18314 x2: points[2][2],
18315 y1: points[2][0],
18316 y2: points[2][0]
18317 } : {
18318 x1: points[2][0],
18319 x2: points[2][0],
18320 y1: points[2][1],
18321 y2: points[2][2]
18322 };
18323
18324 for (var x in pos) {
18325 line.attr(x, pos[x]);
18326 }
18327 };
18328 },
18329
18330 /**
18331 * Generate shape drawing points
18332 * @param {object} indices Indice data
18333 * @param {boolean} isSub Subchart draw
18334 * @returns {Function}
18335 */
18336 generateGetCandlestickPoints: function generateGetCandlestickPoints(indices, isSub) {
18337 if (isSub === void 0) {
18338 isSub = !1;
18339 }
18340
18341 var $$ = this,
18342 config = $$.config,
18343 axis = isSub ? $$.axis.subX : $$.axis.x,
18344 targetsNum = $$.getIndicesMax(indices) + 1,
18345 barW = $$.getBarW("candlestick", axis, targetsNum),
18346 x = $$.getShapeX(barW, indices, !!isSub),
18347 y = $$.getShapeY(!!isSub),
18348 shapeOffset = $$.getShapeOffset($$.isBarType, indices, !!isSub),
18349 yScale = $$.getYScaleById.bind($$);
18350 return function (d, i) {
18351 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
18352 offset = shapeOffset(d, i) || y0,
18353 width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
18354 value = $$.getCandlestickData(d),
18355 points;
18356
18357 if (value) {
18358 var posX = {
18359 start: x(d),
18360 end: 0
18361 };
18362 posX.end = posX.start + width;
18363 var posY = {
18364 start: y(value.open),
18365 end: y(value.close)
18366 },
18367 posLine = {
18368 x: posX.start + width / 2,
18369 high: y(value.high),
18370 low: y(value.low)
18371 };
18372
18373 // fix posY not to overflow opposite quadrant
18374 if (config.axis_rotated && (d.value > 0 && posY.start < y0 || d.value < 0 && y0 < posY.start)) {
18375 posY.start = y0;
18376 }
18377
18378 posY.start -= y0 - offset;
18379 points = [[posX.start, posY.start], [posX.end, posY.end], [posLine.x, posLine.low, posLine.high]];
18380 } else {
18381 points = [[0, 0], [0, 0], [0, 0, 0]];
18382 }
18383
18384 return points;
18385 };
18386 },
18387
18388 /**
18389 * Redraw function
18390 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
18391 * @param {boolean} withTransition With or without transition
18392 * @param {boolean} isSub Subchart draw
18393 * @returns {Array}
18394 */
18395 redrawCandlestick: function redrawCandlestick(drawFn, withTransition, isSub) {
18396 if (isSub === void 0) {
18397 isSub = !1;
18398 }
18399
18400 var $$ = this,
18401 $el = $$.$el,
18402 $T = $$.$T,
18403 _ref = isSub ? $el.subchart : $el,
18404 candlestick = _ref.candlestick,
18405 rand = getRandom(!0);
18406
18407 return [candlestick.each(function (d, i) {
18408 var g = $T((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), withTransition, rand);
18409 drawFn(d, i, g);
18410 }).style("opacity", null)];
18411 },
18412
18413 /**
18414 * Get candlestick data as object
18415 * @param {object} param Data object
18416 * @param {Array|object} param.value Data value
18417 * @returns {object|null} Converted data object
18418 * @private
18419 */
18420 getCandlestickData: function getCandlestickData(_ref2) {
18421 var value = _ref2.value,
18422 d;
18423
18424 if (isArray(value)) {
18425 var open = value[0],
18426 high = value[1],
18427 low = value[2],
18428 close = value[3],
18429 _value$ = value[4],
18430 volume = _value$ === void 0 ? !1 : _value$;
18431 d = {
18432 open: open,
18433 high: high,
18434 low: low,
18435 close: close
18436 };
18437
18438 if (volume !== !1) {
18439 d.volume = volume;
18440 }
18441 } else if (isObject(value)) {
18442 d = candlestick_objectSpread({}, value);
18443 }
18444
18445 if (d) {
18446 d._isUp = d.close >= d.open;
18447 }
18448
18449 return d || null;
18450 }
18451});
18452;// CONCATENATED MODULE: ./src/ChartInternal/shape/gauge.ts
18453/**
18454 * Copyright (c) 2017 ~ present NAVER Corp.
18455 * billboard.js project is licensed under the MIT license
18456 */
18457
18458
18459
18460/* harmony default export */ var gauge = ({
18461 initGauge: function initGauge() {
18462 var $$ = this,
18463 config = $$.config,
18464 arcs = $$.$el.arcs,
18465 appendText = function (className) {
18466 arcs.append("text").attr("class", className).style("text-anchor", "middle").style("pointer-events", "none");
18467 };
18468
18469 if ($$.hasType("gauge")) {
18470 var hasMulti = $$.hasMultiArcGauge();
18471 arcs.append(hasMulti ? "g" : "path").attr("class", config_classes.chartArcsBackground).style("fill", !hasMulti && config.gauge_background || null);
18472 config.gauge_units && appendText(config_classes.chartArcsGaugeUnit);
18473
18474 if (config.gauge_label_show) {
18475 appendText(config_classes.chartArcsGaugeMin);
18476 config.gauge_fullCircle || appendText(config_classes.chartArcsGaugeMax);
18477 }
18478 }
18479 },
18480 updateGaugeMax: function updateGaugeMax() {
18481 var $$ = this,
18482 config = $$.config,
18483 state = $$.state,
18484 hasMultiGauge = $$.hasMultiArcGauge(),
18485 max = hasMultiGauge ? $$.getMinMaxData().max[0].value : $$.getTotalDataSum(state.rendered);
18486
18487 // if gauge_max less than max, make max to max value
18488 if (max + config.gauge_min * (config.gauge_min > 0 ? -1 : 1) > config.gauge_max) {
18489 config.gauge_max = max - config.gauge_min;
18490 }
18491 },
18492 redrawMultiArcGauge: function redrawMultiArcGauge() {
18493 var $$ = this,
18494 config = $$.config,
18495 state = $$.state,
18496 $el = $$.$el,
18497 hiddenTargetIds = $$.state.hiddenTargetIds,
18498 arcLabelLines = $el.main.selectAll("." + config_classes.arcs).selectAll("." + config_classes.arcLabelLine).data($$.arcData.bind($$)),
18499 mainArcLabelLine = arcLabelLines.enter().append("rect").attr("class", function (d) {
18500 return config_classes.arcLabelLine + " " + config_classes.target + " " + config_classes.target + "-" + d.data.id;
18501 }).merge(arcLabelLines);
18502 mainArcLabelLine.style("fill", function (d) {
18503 return $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data);
18504 }).style("display", config.gauge_label_show ? null : "none").each(function (d) {
18505 var lineLength = 0,
18506 lineThickness = 2,
18507 x = 0,
18508 y = 0,
18509 transform = "";
18510
18511 if (hiddenTargetIds.indexOf(d.data.id) < 0) {
18512 var updated = $$.updateAngle(d),
18513 innerLineLength = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length * (updated.index + 1),
18514 lineAngle = updated.endAngle - Math.PI / 2,
18515 arcInnerRadius = state.radius - innerLineLength,
18516 linePositioningAngle = lineAngle - (arcInnerRadius === 0 ? 0 : 1 / arcInnerRadius);
18517 lineLength = state.radiusExpanded - state.radius + innerLineLength;
18518 x = Math.cos(linePositioningAngle) * arcInnerRadius;
18519 y = Math.sin(linePositioningAngle) * arcInnerRadius;
18520 transform = "rotate(" + lineAngle * 180 / Math.PI + ", " + x + ", " + y + ")";
18521 }
18522
18523 (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");
18524 });
18525 },
18526 textForGaugeMinMax: function textForGaugeMinMax(value, isMax) {
18527 var $$ = this,
18528 config = $$.config,
18529 format = config.gauge_label_extents;
18530 return isFunction(format) ? format.bind($$.api)(value, isMax) : value;
18531 },
18532 getGaugeLabelHeight: function getGaugeLabelHeight() {
18533 var config = this.config;
18534 return this.config.gauge_label_show && !config.gauge_fullCircle ? 20 : 0;
18535 },
18536 getPaddingBottomForGauge: function getPaddingBottomForGauge() {
18537 var $$ = this;
18538 return $$.getGaugeLabelHeight() * ($$.config.gauge_label_show ? 2 : 2.5);
18539 }
18540});
18541;// CONCATENATED MODULE: ./src/ChartInternal/shape/bubble.ts
18542/**
18543 * Copyright (c) 2017 ~ present NAVER Corp.
18544 * billboard.js project is licensed under the MIT license
18545 */
18546
18547
18548/* harmony default export */ var bubble = ({
18549 /**
18550 * Initializer
18551 * @private
18552 */
18553 initBubble: function initBubble() {
18554 var $$ = this,
18555 config = $$.config;
18556
18557 if ($$.hasType("bubble")) {
18558 config.point_show = !0;
18559 config.point_type = "circle";
18560 config.point_sensitivity = 25;
18561 }
18562 },
18563
18564 /**
18565 * Get user agent's computed value
18566 * @returns {number}
18567 * @private
18568 */
18569 getBaseLength: function getBaseLength() {
18570 var $$ = this,
18571 _$$$state = $$.state,
18572 width = _$$$state.width,
18573 height = _$$$state.height,
18574 cacheKey = KEY.bubbleBaseLength,
18575 baseLength = $$.cache.get(cacheKey);
18576
18577 if (!baseLength) {
18578 $$.cache.add(cacheKey, baseLength = getMinMax("min", [width, height]));
18579 }
18580
18581 return baseLength;
18582 },
18583
18584 /**
18585 * Get the radius value for bubble circle
18586 * @param {object} d Data object
18587 * @returns {number}
18588 * @private
18589 */
18590 getBubbleR: function getBubbleR(d) {
18591 var $$ = this,
18592 maxR = $$.config.bubble_maxR;
18593
18594 if (isFunction(maxR)) {
18595 maxR = maxR.bind($$.api)(d);
18596 } else if (!isNumber(maxR)) {
18597 maxR = $$.getBaseLength() / ($$.getMaxDataCount() * 2) + 12;
18598 }
18599
18600 var max = getMinMax("max", $$.getMinMaxData().max.map(function (d) {
18601 return $$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "y") : isObject(d.value) ? d.value.mid : d.value;
18602 })),
18603 maxArea = maxR * maxR * Math.PI,
18604 area = ($$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "z") : d.value) * (maxArea / max);
18605 return Math.sqrt(area / Math.PI);
18606 },
18607
18608 /**
18609 * Get bubble dimension data
18610 * @param {object|Array} d data value
18611 * @param {string} type - y or z
18612 * @returns {number}
18613 * @private
18614 */
18615 getBubbleZData: function getBubbleZData(d, type) {
18616 return isObject(d) ? d[type] : d[type === "y" ? 0 : 1];
18617 }
18618});
18619;// CONCATENATED MODULE: ./src/ChartInternal/shape/line.ts
18620/**
18621 * Copyright (c) 2017 ~ present NAVER Corp.
18622 * billboard.js project is licensed under the MIT license
18623 */
18624
18625
18626
18627
18628/* harmony default export */ var line = ({
18629 initLine: function initLine() {
18630 var $el = this.$el;
18631 $el.line = $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartLines);
18632 },
18633 updateTargetsForLine: function updateTargetsForLine(t) {
18634 var $$ = this,
18635 _$$$$el = $$.$el,
18636 area = _$$$$el.area,
18637 line = _$$$$el.line,
18638 main = _$$$$el.main,
18639 classChartLine = $$.getChartClass("Line"),
18640 classLines = $$.getClass("lines", !0),
18641 classFocus = $$.classFocus.bind($$);
18642
18643 if (!line) {
18644 $$.initLine();
18645 }
18646
18647 var targets = t.filter(function (d) {
18648 return !($$.isScatterType(d) || $$.isBubbleType(d));
18649 }),
18650 mainLineUpdate = main.select("." + config_classes.chartLines).selectAll("." + config_classes.chartLine).data(targets).attr("class", function (d) {
18651 return classChartLine(d) + classFocus(d);
18652 }),
18653 mainLineEnter = mainLineUpdate.enter().append("g").attr("class", classChartLine).style("opacity", "0").style("pointer-events", "none");
18654 // Lines for each data
18655 mainLineEnter.append("g").attr("class", classLines); // Areas
18656
18657 if ($$.hasTypeOf("Area")) {
18658 $$.initArea(!area && mainLineEnter.empty() ? mainLineUpdate : mainLineEnter);
18659 }
18660
18661 $$.updateTargetForCircle(targets, mainLineEnter);
18662 },
18663
18664 /**
18665 * Generate/Update elements
18666 * @param {boolean} withTransition Transition for exit elements
18667 * @param {boolean} isSub Subchart draw
18668 * @private
18669 */
18670 updateLine: function updateLine(withTransition, isSub) {
18671 if (isSub === void 0) {
18672 isSub = !1;
18673 }
18674
18675 var $$ = this,
18676 extraLineClasses = $$.format.extraLineClasses,
18677 $el = $$.$el,
18678 $T = $$.$T,
18679 $root = isSub ? $el.subchart : $el,
18680 line = $root.main.selectAll("." + config_classes.lines).selectAll("." + config_classes.line).data($$.lineData.bind($$));
18681 $T(line.exit(), withTransition).style("opacity", "0").remove();
18682 $root.line = line.enter().append("path").attr("class", function (d) {
18683 return $$.getClass("line", !0)(d) + " " + (extraLineClasses(d) || "");
18684 }).style("stroke", $$.color).merge(line).style("opacity", $$.initialOpacity.bind($$)).style("shape-rendering", function (d) {
18685 return $$.isStepType(d) ? "crispEdges" : "";
18686 }).attr("transform", null);
18687 },
18688
18689 /**
18690 * Redraw function
18691 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
18692 * @param {boolean} withTransition With or without transition
18693 * @param {boolean} isSub Subchart draw
18694 * @returns {Array}
18695 */
18696 redrawLine: function redrawLine(drawFn, withTransition, isSub) {
18697 if (isSub === void 0) {
18698 isSub = !1;
18699 }
18700
18701 var $$ = this,
18702 $el = $$.$el,
18703 $T = $$.$T,
18704 _ref = isSub ? $el.subchart : $el,
18705 line = _ref.line;
18706
18707 return [$T(line, withTransition, getRandom()).attr("d", drawFn).style("stroke", this.color).style("opacity", null)];
18708 },
18709
18710 /**
18711 * Get the curve interpolate
18712 * @param {Array} d Data object
18713 * @returns {Function}
18714 * @private
18715 */
18716 getCurve: function getCurve(d) {
18717 var $$ = this,
18718 isRotatedStepType = $$.config.axis_rotated && $$.isStepType(d);
18719 // when is step & rotated, should be computed in different way
18720 // https://github.com/naver/billboard.js/issues/471
18721 return isRotatedStepType ? function (context) {
18722 var step = $$.getInterpolate(d)(context); // keep the original method
18723
18724 step.orgPoint = step.point; // to get rotated path data
18725
18726 step.pointRotated = function (x, y) {
18727 this._point === 1 && (this._point = 2);
18728 var y1 = this._y * (1 - this._t) + y * this._t;
18729
18730 this._context.lineTo(this._x, y1);
18731
18732 this._context.lineTo(x, y1);
18733
18734 this._x = x;
18735 this._y = y;
18736 };
18737
18738 step.point = function (x, y) {
18739 this._point === 0 ? this.orgPoint(x, y) : this.pointRotated(x, y);
18740 };
18741
18742 return step;
18743 } : $$.getInterpolate(d);
18744 },
18745 generateDrawLine: function generateDrawLine(lineIndices, isSub) {
18746 var $$ = this,
18747 config = $$.config,
18748 scale = $$.scale,
18749 lineConnectNull = config.line_connectNull,
18750 isRotated = config.axis_rotated,
18751 getPoints = $$.generateGetLinePoints(lineIndices, isSub),
18752 yScale = $$.getYScaleById.bind($$),
18753 xValue = function (d) {
18754 return (isSub ? $$.subxx : $$.xx).call($$, d);
18755 },
18756 yValue = function (d, i) {
18757 return $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.getBaseValue(d));
18758 },
18759 line = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.line)();
18760
18761 line = isRotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
18762
18763 if (!lineConnectNull) {
18764 line = line.defined(function (d) {
18765 return $$.getBaseValue(d) !== null;
18766 });
18767 }
18768
18769 var x = isSub ? scale.subX : scale.x;
18770 return function (d) {
18771 var y = yScale(d.id, isSub),
18772 values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
18773 x0 = 0,
18774 y0 = 0,
18775 path;
18776
18777 if ($$.isLineType(d)) {
18778 var regions = config.data_regions[d.id];
18779
18780 if (regions) {
18781 path = $$.lineWithRegions(values, scale.zoom || x, y, regions);
18782 } else {
18783 if ($$.isStepType(d)) {
18784 values = $$.convertValuesToStep(values);
18785 }
18786
18787 path = line.curve($$.getCurve(d))(values);
18788 }
18789 } else {
18790 if (values[0]) {
18791 x0 = x(values[0].x);
18792 y0 = y(values[0].value);
18793 }
18794
18795 path = isRotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
18796 }
18797
18798 return path || "M 0 0";
18799 };
18800 },
18801 lineWithRegions: function lineWithRegions(d, x, y, _regions) {
18802 var $$ = this,
18803 config = $$.config,
18804 isRotated = config.axis_rotated,
18805 isTimeSeries = $$.axis.isTimeSeries(),
18806 xOffset = $$.axis.isCategorized() ? .5 : 0,
18807 regions = [],
18808 dasharray = "2 2",
18809 xp,
18810 yp,
18811 diff,
18812 diffx2,
18813 isWithinRegions = function (withinX, withinRegions) {
18814 for (var i = 0, reg; reg = withinRegions[i]; i++) {
18815 if (reg.start < withinX && withinX <= reg.end) {
18816 return reg.style;
18817 }
18818 }
18819
18820 return !1;
18821 };
18822
18823 // Check start/end of regions
18824 if (isDefined(_regions)) {
18825 var getValue = function (v, def) {
18826 return isUndefined(v) ? def : isTimeSeries ? parseDate.call($$, v) : v;
18827 };
18828
18829 for (var i = 0, reg; reg = _regions[i]; i++) {
18830 var start = getValue(reg.start, d[0].x),
18831 end = getValue(reg.end, d[d.length - 1].x),
18832 style = reg.style || {
18833 dasharray: dasharray
18834 };
18835 regions[i] = {
18836 start: start,
18837 end: end,
18838 style: style
18839 };
18840 }
18841 } // Set scales
18842
18843
18844 var xValue = isRotated ? function (dt) {
18845 return y(dt.value);
18846 } : function (dt) {
18847 return x(dt.x);
18848 },
18849 yValue = isRotated ? function (dt) {
18850 return x(dt.x);
18851 } : function (dt) {
18852 return y(dt.value);
18853 },
18854 generateM = function (points) {
18855 return "M" + points[0][0] + "," + points[0][1] + "L" + points[1][0] + "," + points[1][1];
18856 },
18857 sWithRegion = isTimeSeries ? function (d0, d1, k, timeseriesDiff) {
18858 var x0 = d0.x.getTime(),
18859 xDiff = d1.x - d0.x,
18860 xv0 = new Date(x0 + xDiff * k),
18861 xv1 = new Date(x0 + xDiff * (k + timeseriesDiff)),
18862 points = isRotated ? [[y(yp(k)), x(xv0)], [y(yp(k + diff)), x(xv1)]] : [[x(xv0), y(yp(k))], [x(xv1), y(yp(k + diff))]];
18863 return generateM(points);
18864 } : function (d0, d1, k, otherDiff) {
18865 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))]];
18866 return generateM(points);
18867 },
18868 axisType = {
18869 x: $$.axis.getAxisType("x"),
18870 y: $$.axis.getAxisType("y")
18871 },
18872 path = "";
18873
18874 for (var _i = 0, data; data = d[_i]; _i++) {
18875 var prevData = d[_i - 1],
18876 hasPrevData = prevData && isValue(prevData.value),
18877 style = isWithinRegions(data.x, regions);
18878
18879 // https://github.com/naver/billboard.js/issues/1172
18880 if (!isValue(data.value)) {
18881 continue;
18882 } // Draw as normal
18883
18884
18885 if (isUndefined(regions) || !style || !hasPrevData) {
18886 path += "" + (_i && hasPrevData ? "L" : "M") + xValue(data) + "," + yValue(data);
18887 } else if (hasPrevData) {
18888 try {
18889 style = style.dasharray.split(" ");
18890 } catch (e) {
18891 style = dasharray.split(" ");
18892 } // Draw with region // TODO: Fix for horizotal charts
18893
18894
18895 xp = getScale(axisType.x, prevData.x + xOffset, data.x + xOffset);
18896 yp = getScale(axisType.y, prevData.value, data.value);
18897 var dx = x(data.x) - x(prevData.x),
18898 dy = y(data.value) - y(prevData.value),
18899 dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
18900 diff = style[0] / dd;
18901 diffx2 = diff * style[1];
18902
18903 for (var j = diff; j <= 1; j += diffx2) {
18904 path += sWithRegion(prevData, data, j, diff); // to make sure correct line drawing
18905
18906 if (j + diffx2 >= 1) {
18907 path += sWithRegion(prevData, data, 1, 0);
18908 }
18909 }
18910 }
18911 }
18912
18913 return path;
18914 },
18915 isWithinStep: function isWithinStep(that, y) {
18916 return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
18917 },
18918 shouldDrawPointsForLine: function shouldDrawPointsForLine(d) {
18919 var linePoint = this.config.line_point;
18920 return linePoint === !0 || isArray(linePoint) && linePoint.indexOf(d.id) !== -1;
18921 }
18922});
18923;// CONCATENATED MODULE: ./src/ChartInternal/shape/point.ts
18924/**
18925 * Copyright (c) 2017 ~ present NAVER Corp.
18926 * billboard.js project is licensed under the MIT license
18927 */
18928
18929
18930
18931
18932
18933var getTransitionName = function () {
18934 return getRandom();
18935};
18936
18937/* harmony default export */ var point = ({
18938 hasValidPointType: function hasValidPointType(type) {
18939 return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
18940 },
18941 hasValidPointDrawMethods: function hasValidPointDrawMethods(type) {
18942 var pointType = type || this.config.point_type;
18943 return isObjectType(pointType) && isFunction(pointType.create) && isFunction(pointType.update);
18944 },
18945 initialOpacityForCircle: function initialOpacityForCircle(d) {
18946 var config = this.config,
18947 withoutFadeIn = this.state.withoutFadeIn,
18948 opacity = config.point_opacity;
18949
18950 if (isUndefined(opacity)) {
18951 opacity = this.getBaseValue(d) !== null && withoutFadeIn[d.id] ? this.opacityForCircle(d) : "0";
18952 }
18953
18954 return opacity;
18955 },
18956 opacityForCircle: function opacityForCircle(d) {
18957 var config = this.config,
18958 opacity = config.point_opacity;
18959
18960 if (isUndefined(opacity)) {
18961 opacity = config.point_show && !config.point_focus_only ? null : "0";
18962 opacity = isValue(this.getBaseValue(d)) ? this.isBubbleType(d) || this.isScatterType(d) ? "0.5" : opacity : "0";
18963 }
18964
18965 return opacity;
18966 },
18967 initCircle: function initCircle() {
18968 var $$ = this,
18969 main = $$.$el.main;
18970 $$.point = $$.generatePoint();
18971
18972 if (($$.hasType("bubble") || $$.hasType("scatter")) && main.select("." + config_classes.chartCircles).empty()) {
18973 main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartCircles);
18974 }
18975 },
18976 updateTargetForCircle: function updateTargetForCircle(targetsValue, enterNodeValue) {
18977 var _this = this,
18978 $$ = this,
18979 config = $$.config,
18980 data = $$.data,
18981 $el = $$.$el,
18982 selectionEnabled = config.interaction_enabled && config.data_selection_enabled,
18983 isSelectable = selectionEnabled && config.data_selection_isselectable,
18984 classCircles = $$.getClass("circles", !0);
18985
18986 if (!config.point_show) {
18987 return;
18988 }
18989
18990 $el.circle || $$.initCircle();
18991 var targets = targetsValue,
18992 enterNode = enterNodeValue;
18993
18994 // only for scatter & bubble type should generate seprate <g> node
18995 if (!targets) {
18996 targets = data.targets.filter(function (d) {
18997 return _this.isScatterType(d) || _this.isBubbleType(d);
18998 });
18999 var mainCircle = $el.main.select("." + config_classes.chartCircles).style("pointer-events", "none").selectAll("." + config_classes.circles).data(targets).attr("class", classCircles);
19000 mainCircle.exit().remove();
19001 enterNode = mainCircle.enter();
19002 } // Circles for each data point on lines
19003
19004
19005 selectionEnabled && enterNode.append("g").attr("class", function (d) {
19006 return $$.generateClass(config_classes.selectedCircles, d.id);
19007 });
19008 enterNode.append("g").attr("class", classCircles).style("cursor", function (d) {
19009 return isFunction(isSelectable) && isSelectable(d) ? "pointer" : null;
19010 }); // Update date for selected circles
19011
19012 selectionEnabled && targets.forEach(function (t) {
19013 $el.main.selectAll("." + config_classes.selectedCircles + $$.getTargetSelectorSuffix(t.id)).selectAll("" + config_classes.selectedCircle).each(function (d) {
19014 d.value = t.values[d.index].value;
19015 });
19016 });
19017 },
19018 updateCircle: function updateCircle(isSub) {
19019 if (isSub === void 0) {
19020 isSub = !1;
19021 }
19022
19023 var $$ = this,
19024 config = $$.config,
19025 state = $$.state,
19026 $el = $$.$el,
19027 focusOnly = config.point_focus_only,
19028 $root = isSub ? $el.subchart : $el;
19029
19030 if (config.point_show && !state.toggling) {
19031 var circles = $root.main.selectAll("." + config_classes.circles).selectAll("." + config_classes.circle).data(function (d) {
19032 return $$.isLineType(d) && $$.shouldDrawPointsForLine(d) || $$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ? focusOnly ? [d.values[0]] : d.values : [];
19033 });
19034 circles.exit().remove();
19035 circles.enter().filter(Boolean).append($$.point("create", this, $$.pointR.bind($$), $$.color));
19036 $root.circle = $root.main.selectAll("." + config_classes.circles + " ." + config_classes.circle).style("stroke", $$.color).style("opacity", $$.initialOpacityForCircle.bind($$));
19037 }
19038 },
19039 redrawCircle: function redrawCircle(cx, cy, withTransition, flow, isSub) {
19040 if (isSub === void 0) {
19041 isSub = !1;
19042 }
19043
19044 var $$ = this,
19045 rendered = $$.state.rendered,
19046 $el = $$.$el,
19047 $T = $$.$T,
19048 $root = isSub ? $el.subchart : $el,
19049 selectedCircles = $root.main.selectAll("." + config_classes.selectedCircle);
19050
19051 if (!$$.config.point_show) {
19052 return [];
19053 }
19054
19055 var fn = $$.point("update", $$, cx, cy, $$.color, withTransition, flow, selectedCircles),
19056 posAttr = $$.isCirclePoint() ? "c" : "",
19057 t = getRandom(),
19058 opacityStyleFn = $$.opacityForCircle.bind($$),
19059 mainCircles = [];
19060 $root.circle.each(function (d) {
19061 var result = fn.bind(this)(d);
19062 result = $T(result, withTransition || !rendered, t).style("opacity", opacityStyleFn);
19063 mainCircles.push(result);
19064 });
19065 return [mainCircles, $T(selectedCircles, withTransition).attr(posAttr + "x", cx).attr(posAttr + "y", cy)];
19066 },
19067
19068 /**
19069 * Show focused data point circle
19070 * @param {object} d Selected data
19071 * @private
19072 */
19073 showCircleFocus: function showCircleFocus(d) {
19074 var $$ = this,
19075 config = $$.config,
19076 _$$$state = $$.state,
19077 hasRadar = _$$$state.hasRadar,
19078 resizing = _$$$state.resizing,
19079 toggling = _$$$state.toggling,
19080 transiting = _$$$state.transiting,
19081 $el = $$.$el,
19082 circle = $el.circle;
19083
19084 if (transiting === !1 && config.point_focus_only && circle) {
19085 var cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$),
19086 cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$),
19087 withTransition = toggling || isUndefined(d),
19088 fn = $$.point("update", $$, cx, cy, $$.color, resizing ? !1 : withTransition);
19089
19090 if (d) {
19091 circle = circle.filter(function (t) {
19092 var data = d.filter(function (v) {
19093 return v.id === t.id;
19094 });
19095 return data.length ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).datum(data[0]) : !1;
19096 });
19097 }
19098
19099 circle.attr("class", this.updatePointClass.bind(this)).style("opacity", null).each(function (d) {
19100 var id = d.id,
19101 index = d.index,
19102 value = d.value,
19103 visibility = "hidden";
19104
19105 if (isValue(value)) {
19106 fn.bind(this)(d);
19107 $$.expandCircles(index, id);
19108 visibility = "";
19109 }
19110
19111 this.style.visibility = visibility;
19112 });
19113 }
19114 },
19115
19116 /**
19117 * Hide focused data point circle
19118 * @private
19119 */
19120 hideCircleFocus: function hideCircleFocus() {
19121 var $$ = this,
19122 config = $$.config,
19123 circle = $$.$el.circle;
19124
19125 if (config.point_focus_only && circle) {
19126 $$.unexpandCircles();
19127 circle.style("visibility", "hidden");
19128 }
19129 },
19130 circleX: function circleX(d) {
19131 return this.xx(d);
19132 },
19133 updateCircleY: function updateCircleY(isSub) {
19134 if (isSub === void 0) {
19135 isSub = !1;
19136 }
19137
19138 var $$ = this,
19139 getPoints = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType), isSub);
19140 return function (d, i) {
19141 var id = d.id;
19142 return $$.isGrouped(id) ? getPoints(d, i)[0][1] : $$.getYScaleById(id, isSub)($$.getBaseValue(d));
19143 };
19144 },
19145 expandCircles: function expandCircles(i, id, reset) {
19146 var $$ = this,
19147 r = $$.pointExpandedR.bind($$);
19148 reset && $$.unexpandCircles();
19149 var circles = $$.getShapeByIndex("circle", i, id).classed(config_classes.EXPANDED, !0),
19150 scale = r(circles) / $$.config.point_r,
19151 ratio = 1 - scale;
19152
19153 if ($$.isCirclePoint()) {
19154 circles.attr("r", r);
19155 } else {
19156 // transform must be applied to each node individually
19157 circles.each(function () {
19158 var point = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
19159
19160 if (this.tagName === "circle") {
19161 point.attr("r", r);
19162 } else {
19163 var _this$getBBox = this.getBBox(),
19164 width = _this$getBBox.width,
19165 height = _this$getBBox.height,
19166 x = ratio * (+point.attr("x") + width / 2),
19167 y = ratio * (+point.attr("y") + height / 2);
19168
19169 point.attr("transform", "translate(" + x + " " + y + ") scale(" + scale + ")");
19170 }
19171 });
19172 }
19173 },
19174 unexpandCircles: function unexpandCircles(i) {
19175 var $$ = this,
19176 r = $$.pointR.bind($$),
19177 circles = $$.getShapeByIndex("circle", i).filter(function () {
19178 return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.EXPANDED);
19179 }).classed(config_classes.EXPANDED, !1);
19180 circles.attr("r", r);
19181 $$.isCirclePoint() || circles.attr("transform", "scale(" + r(circles) / $$.config.point_r + ")");
19182 },
19183 pointR: function (d) {
19184 var $$ = this,
19185 config = $$.config,
19186 pointR = config.point_r,
19187 r = pointR;
19188
19189 if ($$.isBubbleType(d)) {
19190 r = $$.getBubbleR(d);
19191 } else if (isFunction(pointR)) {
19192 r = pointR.bind($$.api)(d);
19193 }
19194
19195 return r;
19196 },
19197 pointExpandedR: function pointExpandedR(d) {
19198 var $$ = this,
19199 config = $$.config,
19200 scale = $$.isBubbleType(d) ? 1.15 : 1.75;
19201 return config.point_focus_expand_enabled ? config.point_focus_expand_r || $$.pointR(d) * scale : $$.pointR(d);
19202 },
19203 pointSelectR: function pointSelectR(d) {
19204 var $$ = this,
19205 selectR = $$.config.point_select_r;
19206 return isFunction(selectR) ? selectR(d) : selectR || $$.pointR(d) * 4;
19207 },
19208 isWithinCircle: function isWithinCircle(node, r) {
19209 var mouse = getPointer(this.state.event, node),
19210 element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(node),
19211 prefix = this.isCirclePoint(node) ? "c" : "",
19212 cx = +element.attr(prefix + "x"),
19213 cy = +element.attr(prefix + "y");
19214
19215 // if node don't have cx/y or x/y attribute value
19216 if (!(cx || cy) && node.nodeType === 1) {
19217 var _getBoundingRect = getBoundingRect(node),
19218 x = _getBoundingRect.x,
19219 y = _getBoundingRect.y;
19220
19221 cx = x;
19222 cy = y;
19223 }
19224
19225 return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < (r || this.config.point_sensitivity);
19226 },
19227 insertPointInfoDefs: function insertPointInfoDefs(point, id) {
19228 var _node$childNodes,
19229 $$ = this,
19230 copyAttr = function (from, target) {
19231 for (var attribs = from.attributes, i = 0, name; name = attribs[i]; i++) {
19232 name = name.name;
19233 target.setAttribute(name, from.getAttribute(name));
19234 }
19235 },
19236 doc = new DOMParser().parseFromString(point, "image/svg+xml"),
19237 node = doc.documentElement,
19238 clone = browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, node.nodeName.toLowerCase());
19239
19240 clone.id = id;
19241 clone.style.fill = "inherit";
19242 clone.style.stroke = "inherit";
19243 copyAttr(node, clone);
19244
19245 if ((_node$childNodes = node.childNodes) != null && _node$childNodes.length) {
19246 var parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(clone);
19247
19248 if ("innerHTML" in clone) {
19249 parent.html(node.innerHTML);
19250 } else {
19251 toArray(node.childNodes).forEach(function (v) {
19252 copyAttr(v, parent.append(v.tagName).node());
19253 });
19254 }
19255 }
19256
19257 $$.$el.defs.node().appendChild(clone);
19258 },
19259 pointFromDefs: function pointFromDefs(id) {
19260 return this.$el.defs.select("#" + id);
19261 },
19262 updatePointClass: function updatePointClass(d) {
19263 var $$ = this,
19264 circle = $$.$el.circle,
19265 pointClass = !1;
19266
19267 if (isObject(d) || circle) {
19268 pointClass = d === !0 ? circle.each(function (d) {
19269 var className = $$.getClass("circle", !0)(d);
19270
19271 if (this.getAttribute("class").indexOf(config_classes.EXPANDED) > -1) {
19272 className += " " + config_classes.EXPANDED;
19273 }
19274
19275 this.setAttribute("class", className);
19276 }) : $$.getClass("circle", !0)(d);
19277 }
19278
19279 return pointClass;
19280 },
19281 generateGetLinePoints: function generateGetLinePoints(lineIndices, isSub) {
19282 // partial duplication of generateGetBarPoints
19283 var $$ = this,
19284 config = $$.config,
19285 x = $$.getShapeX(0, lineIndices, isSub),
19286 y = $$.getShapeY(isSub),
19287 lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, isSub),
19288 yScale = $$.getYScaleById.bind($$);
19289 return function (d, i) {
19290 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
19291 offset = lineOffset(d, i) || y0,
19292 posX = x(d),
19293 posY = y(d);
19294
19295 // fix posY not to overflow opposite quadrant
19296 if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
19297 posY = y0;
19298 } // 1 point that marks the line position
19299
19300
19301 var point = [posX, posY - (y0 - offset)];
19302 return [point, point, // from here and below, needed for compatibility
19303 point, point];
19304 };
19305 },
19306 generatePoint: function generatePoint() {
19307 var $$ = this,
19308 config = $$.config,
19309 datetimeId = $$.state.datetimeId,
19310 ids = [],
19311 pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
19312 return function (method, context) {
19313 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
19314 args[_key - 2] = arguments[_key];
19315 }
19316
19317 return function (d) {
19318 var _d$data,
19319 id = $$.getTargetSelectorSuffix(d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d),
19320 element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
19321
19322 ids.indexOf(id) < 0 && ids.push(id);
19323 var point = pattern[ids.indexOf(id) % pattern.length];
19324
19325 if ($$.hasValidPointType(point)) {
19326 point = $$[point];
19327 } else if (!$$.hasValidPointDrawMethods(point)) {
19328 var pointId = datetimeId + "-point" + id,
19329 pointFromDefs = $$.pointFromDefs(pointId);
19330
19331 if (pointFromDefs.size() < 1) {
19332 $$.insertPointInfoDefs(point, pointId);
19333 }
19334
19335 if (method === "create") {
19336 return $$.custom.create.bind(context).apply(void 0, [element, pointId].concat(args));
19337 } else if (method === "update") {
19338 return $$.custom.update.bind(context).apply(void 0, [element].concat(args));
19339 }
19340 }
19341
19342 return point[method].bind(context).apply(void 0, [element].concat(args));
19343 };
19344 };
19345 },
19346 custom: {
19347 create: function create(element, id, sizeFn, fillStyleFn) {
19348 return element.append("use").attr("xlink:href", "#" + id).attr("class", this.updatePointClass.bind(this)).style("fill", fillStyleFn).node();
19349 },
19350 update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
19351 var $$ = this,
19352 _element$node$getBBox = element.node().getBBox(),
19353 width = _element$node$getBBox.width,
19354 height = _element$node$getBBox.height,
19355 xPosFn2 = function (d) {
19356 return isValue(d.value) ? xPosFn(d) - width / 2 : 0;
19357 },
19358 mainCircles = element;
19359
19360 if (withTransition) {
19361 flow && mainCircles.attr("x", xPosFn2);
19362 mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
19363 selectedCircles && $$.$T(selectedCircles, withTransition, getTransitionName());
19364 }
19365
19366 return mainCircles.attr("x", xPosFn2).attr("y", function yPosFn2(d) {
19367 return isValue(d.value) ? yPosFn(d) - height / 2 : 0;
19368 }).style("fill", fillStyleFn);
19369 }
19370 },
19371 // 'circle' data point
19372 circle: {
19373 create: function create(element, sizeFn, fillStyleFn) {
19374 return element.append("circle").attr("class", this.updatePointClass.bind(this)).attr("r", sizeFn).style("fill", fillStyleFn).node();
19375 },
19376 update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
19377 var $$ = this,
19378 mainCircles = element;
19379
19380 // when '.load()' called, bubble size should be updated
19381 if ($$.hasType("bubble")) {
19382 mainCircles.attr("r", $$.pointR.bind($$));
19383 }
19384
19385 if (withTransition) {
19386 flow && mainCircles.attr("cx", xPosFn);
19387
19388 if (mainCircles.attr("cx")) {
19389 mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
19390 }
19391
19392 selectedCircles && $$.$T(mainCircles, withTransition, getTransitionName());
19393 }
19394
19395 return mainCircles.attr("cx", xPosFn).attr("cy", yPosFn).style("fill", fillStyleFn);
19396 }
19397 },
19398 // 'rectangle' data point
19399 rectangle: {
19400 create: function create(element, sizeFn, fillStyleFn) {
19401 var rectSizeFn = function (d) {
19402 return sizeFn(d) * 2;
19403 };
19404
19405 return element.append("rect").attr("class", this.updatePointClass.bind(this)).attr("width", rectSizeFn).attr("height", rectSizeFn).style("fill", fillStyleFn).node();
19406 },
19407 update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
19408 var $$ = this,
19409 r = $$.config.point_r,
19410 rectXPosFn = function (d) {
19411 return xPosFn(d) - r;
19412 },
19413 mainCircles = element;
19414
19415 if (withTransition) {
19416 flow && mainCircles.attr("x", rectXPosFn);
19417 mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
19418 selectedCircles && $$.$T(selectedCircles, withTransition, getTransitionName());
19419 }
19420
19421 return mainCircles.attr("x", rectXPosFn).attr("y", function rectYPosFn(d) {
19422 return yPosFn(d) - r;
19423 }).style("fill", fillStyleFn);
19424 }
19425 }
19426});
19427;// CONCATENATED MODULE: ./src/ChartInternal/shape/radar.ts
19428/**
19429 * Copyright (c) 2017 ~ present NAVER Corp.
19430 * billboard.js project is licensed under the MIT license
19431 */
19432
19433
19434
19435
19436/**
19437 * Get the position value
19438 * @param {boolean} isClockwise If the direction is clockwise
19439 * @param {string} type Coordinate type 'x' or 'y'
19440 * @param {number} edge Number of edge
19441 * @param {number} pos The indexed position
19442 * @param {number} range Range value
19443 * @param {number} ratio Ratio value
19444 * @returns {number}
19445 * @private
19446 */
19447
19448function getPosition(isClockwise, type, edge, pos, range, ratio) {
19449 var index = isClockwise && pos > 0 ? edge - pos : pos,
19450 r = 2 * Math.PI,
19451 func = type === "x" ? Math.sin : Math.cos;
19452 return range * (1 - ratio * func(index * r / edge));
19453} // cache key
19454
19455
19456var cacheKey = KEY.radarPoints;
19457/* harmony default export */ var radar = ({
19458 initRadar: function initRadar() {
19459 var $$ = this,
19460 config = $$.config,
19461 current = $$.state.current,
19462 $el = $$.$el;
19463
19464 if ($$.hasType("radar")) {
19465 $el.radar = $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartRadars); // level
19466
19467 $el.radar.levels = $el.radar.append("g").attr("class", config_classes.levels); // axis
19468
19469 $el.radar.axes = $el.radar.append("g").attr("class", config_classes.axis); // shapes
19470
19471 $el.radar.shapes = $el.radar.append("g").attr("class", config_classes.shapes);
19472 current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value;
19473 }
19474 },
19475 getRadarSize: function getRadarSize() {
19476 var $$ = this,
19477 config = $$.config,
19478 _$$$state = $$.state,
19479 arcWidth = _$$$state.arcWidth,
19480 arcHeight = _$$$state.arcHeight,
19481 padding = config.axis_x_categories.length < 4 ? -20 : 10,
19482 size = (Math.min(arcWidth, arcHeight) - padding) / 2;
19483 return [size, size];
19484 },
19485 updateTargetsForRadar: function updateTargetsForRadar(targets) {
19486 var $$ = this,
19487 config = $$.config;
19488
19489 if (isEmpty(config.axis_x_categories)) {
19490 config.axis_x_categories = getRange(0, getMinMax("max", targets.map(function (v) {
19491 return v.values.length;
19492 })));
19493 }
19494
19495 $$.generateRadarPoints();
19496 },
19497 getRadarPosition: function getRadarPosition(type, index, range, ratio) {
19498 var $$ = this,
19499 config = $$.config,
19500 _$$$getRadarSize = $$.getRadarSize(),
19501 width = _$$$getRadarSize[0],
19502 height = _$$$getRadarSize[1],
19503 edge = config.axis_x_categories.length,
19504 isClockwise = config.radar_direction_clockwise,
19505 pos = toArray(type).map(function (v) {
19506 return getPosition(isClockwise, v, edge, index, isDefined(range) ? range : type === "x" ? width : height, isNumber(ratio) ? ratio : config.radar_size_ratio);
19507 });
19508
19509 return pos.length === 1 ? pos[0] : pos;
19510 },
19511
19512 /**
19513 * Generate data points
19514 * @private
19515 */
19516 generateRadarPoints: function generateRadarPoints() {
19517 var $$ = this,
19518 targets = $$.data.targets,
19519 _$$$getRadarSize2 = $$.getRadarSize(),
19520 width = _$$$getRadarSize2[0],
19521 height = _$$$getRadarSize2[1],
19522 points = $$.cache.get(cacheKey) || {},
19523 size = points._size;
19524
19525 // recalculate position only when the previous dimension has been changed
19526 if (!size || size.width !== width && size.height !== height) {
19527 targets.forEach(function (d) {
19528 points[d.id] = d.values.map(function (v, i) {
19529 return $$.getRadarPosition(["x", "y"], i, undefined, $$.getRatio("radar", v));
19530 });
19531 });
19532 points._size = {
19533 width: width,
19534 height: height
19535 };
19536 $$.cache.add(cacheKey, points);
19537 }
19538 },
19539 redrawRadar: function redrawRadar() {
19540 var $$ = this,
19541 _$$$$el = $$.$el,
19542 radar = _$$$$el.radar,
19543 main = _$$$$el.main,
19544 translate = $$.getTranslate("radar");
19545
19546 // Adjust radar, circles and texts' position
19547 if (translate) {
19548 radar.attr("transform", translate);
19549 main.select("." + config_classes.chartTexts).attr("transform", translate);
19550 $$.generateRadarPoints();
19551 $$.updateRadarLevel();
19552 $$.updateRadarAxes();
19553 $$.updateRadarShape();
19554 }
19555 },
19556 generateGetRadarPoints: function generateGetRadarPoints() {
19557 var points = this.cache.get(cacheKey);
19558 return function (d, i) {
19559 var point = points[d.id][i];
19560 return [point, point, point, point];
19561 };
19562 },
19563 updateRadarLevel: function updateRadarLevel() {
19564 var $$ = this,
19565 config = $$.config,
19566 state = $$.state,
19567 radar = $$.$el.radar,
19568 _$$$getRadarSize3 = $$.getRadarSize(),
19569 width = _$$$getRadarSize3[0],
19570 height = _$$$getRadarSize3[1],
19571 depth = config.radar_level_depth,
19572 edge = config.axis_x_categories.length,
19573 showText = config.radar_level_text_show,
19574 radarLevels = radar.levels,
19575 levelData = getRange(0, depth),
19576 radius = config.radar_size_ratio * Math.min(width, height),
19577 levelRatio = levelData.map(function (l) {
19578 return radius * ((l + 1) / depth);
19579 }),
19580 levelTextFormat = (config.radar_level_text_format || function () {}).bind($$.api),
19581 points = levelData.map(function (v) {
19582 var range = levelRatio[v],
19583 pos = getRange(0, edge).map(function (i) {
19584 return $$.getRadarPosition(["x", "y"], i, range, 1).join(",");
19585 });
19586 return pos.join(" ");
19587 }),
19588 level = radarLevels.selectAll("." + config_classes.level).data(levelData);
19589
19590 level.exit().remove();
19591 var levelEnter = level.enter().append("g").attr("class", function (d, i) {
19592 return config_classes.level + " " + config_classes.level + "-" + i;
19593 });
19594 levelEnter.append("polygon").style("visibility", config.radar_level_show ? null : "hidden");
19595
19596 if (showText) {
19597 if (radarLevels.select("text").empty()) {
19598 radarLevels.append("text").attr("dx", "-.5em").attr("dy", "-.7em").style("text-anchor", "end").text(function () {
19599 return levelTextFormat(0);
19600 });
19601 }
19602
19603 levelEnter.append("text").attr("dx", "-.5em").style("text-anchor", "end").text(function (d) {
19604 return levelTextFormat(state.current.dataMax / levelData.length * (d + 1));
19605 });
19606 }
19607
19608 levelEnter.merge(level).attr("transform", function (d) {
19609 return "translate(" + (width - levelRatio[d]) + ", " + (height - levelRatio[d]) + ")";
19610 }).selectAll("polygon").attr("points", function (d) {
19611 return points[d];
19612 }); // update level text position
19613
19614 if (showText) {
19615 radarLevels.selectAll("text").attr("x", function (d) {
19616 return isUndefined(d) ? width : points[d].split(",")[0];
19617 }).attr("y", function (d) {
19618 return isUndefined(d) ? height : 0;
19619 });
19620 }
19621 },
19622 updateRadarAxes: function updateRadarAxes() {
19623 var $$ = this,
19624 config = $$.config,
19625 radar = $$.$el.radar,
19626 _$$$getRadarSize4 = $$.getRadarSize(),
19627 width = _$$$getRadarSize4[0],
19628 height = _$$$getRadarSize4[1],
19629 categories = config.axis_x_categories,
19630 axis = radar.axes.selectAll("g").data(categories);
19631
19632 axis.exit().remove();
19633 var axisEnter = axis.enter().append("g").attr("class", function (d, i) {
19634 return config_classes.axis + "-" + i;
19635 });
19636 config.radar_axis_line_show && axisEnter.append("line");
19637 config.radar_axis_text_show && axisEnter.append("text");
19638 axis = axisEnter.merge(axis); // axis line
19639
19640 if (config.radar_axis_line_show) {
19641 axis.select("line").attr("x1", width).attr("y1", height).attr("x2", function (d, i) {
19642 return $$.getRadarPosition("x", i);
19643 }).attr("y2", function (d, i) {
19644 return $$.getRadarPosition("y", i);
19645 });
19646 } // axis text
19647
19648
19649 if (config.radar_axis_text_show) {
19650 var _config$radar_axis_te = config.radar_axis_text_position,
19651 _config$radar_axis_te2 = _config$radar_axis_te.x,
19652 x = _config$radar_axis_te2 === void 0 ? 0 : _config$radar_axis_te2,
19653 _config$radar_axis_te3 = _config$radar_axis_te.y,
19654 y = _config$radar_axis_te3 === void 0 ? 0 : _config$radar_axis_te3;
19655 axis.select("text").style("text-anchor", "middle").attr("dy", ".5em").call(function (selection) {
19656 selection.each(function (d) {
19657 setTextValue((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), d + "", [-.6, 1.2]);
19658 });
19659 }).datum(function (d, i) {
19660 return {
19661 index: i
19662 };
19663 }).attr("transform", function (d) {
19664 if (isUndefined(this.width)) {
19665 // cache evaluated axis text width
19666 this.width = this.getBoundingClientRect().width / 2;
19667 }
19668
19669 var posX = $$.getRadarPosition("x", d.index, undefined, 1),
19670 posY = Math.round($$.getRadarPosition("y", d.index, undefined, 1));
19671
19672 if (posX > width) {
19673 posX += this.width + x;
19674 } else if (Math.round(posX) < width) {
19675 posX -= this.width + x;
19676 }
19677
19678 if (posY > height) {
19679 // update vertical centered edge axis text dy position
19680 if (posY / 2 === height && this.firstChild.tagName === "tspan") {
19681 this.firstChild.setAttribute("dy", "0em");
19682 }
19683
19684 posY += y;
19685 } else if (posY < height) {
19686 posY -= y;
19687 }
19688
19689 return "translate(" + posX + " " + posY + ")";
19690 });
19691 }
19692
19693 $$.bindEvent();
19694 },
19695 bindEvent: function bindEvent() {
19696 var $$ = this,
19697 config = $$.config,
19698 state = $$.state,
19699 _$$$$el2 = $$.$el,
19700 radar = _$$$$el2.radar,
19701 svg = _$$$$el2.svg,
19702 focusOnly = config.point_focus_only,
19703 _state = state,
19704 inputType = _state.inputType,
19705 transiting = _state.transiting;
19706
19707 if (config.interaction_enabled) {
19708 var isMouse = inputType === "mouse",
19709 getIndex = function (event) {
19710 var target = event.target; // in case of multilined axis text
19711
19712 if (/tspan/i.test(target.tagName)) {
19713 target = target.parentNode;
19714 }
19715
19716 var d = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
19717 return d && Object.keys(d).length === 1 ? d.index : undefined;
19718 },
19719 hide = function (event) {
19720 var index = getIndex(event),
19721 noIndex = isUndefined(index);
19722
19723 if (isMouse || noIndex) {
19724 $$.hideTooltip();
19725 focusOnly ? $$.hideCircleFocus() : $$.unexpandCircles();
19726
19727 if (isMouse) {
19728 $$.setOverOut(!1, index);
19729 } else if (noIndex) {
19730 $$.callOverOutForTouch();
19731 }
19732 }
19733 };
19734
19735 radar.axes.selectAll("text").on(isMouse ? "mouseover " : "touchstart", function (event) {
19736 if (transiting) {
19737 // skip while transiting
19738 return;
19739 }
19740
19741 state.event = event;
19742 var index = getIndex(event);
19743 $$.selectRectForSingle(svg.node(), null, index);
19744 isMouse ? $$.setOverOut(!0, index) : $$.callOverOutForTouch(index);
19745 }).on("mouseout", isMouse ? hide : null);
19746
19747 if (!isMouse) {
19748 svg.on("touchstart", hide);
19749 }
19750 }
19751 },
19752 updateRadarShape: function updateRadarShape() {
19753 var $$ = this,
19754 targets = $$.data.targets.filter(function (d) {
19755 return $$.isRadarType(d);
19756 }),
19757 points = $$.cache.get(cacheKey),
19758 areas = $$.$el.radar.shapes.selectAll("polygon").data(targets),
19759 areasEnter = areas.enter().append("g").attr("class", $$.getChartClass("Radar"));
19760 $$.$T(areas.exit()).remove();
19761 areasEnter.append("polygon").merge(areas).style("fill", $$.color).style("stroke", $$.color).attr("points", function (d) {
19762 return points[d.id].join(" ");
19763 });
19764 $$.updateTargetForCircle(targets, areasEnter);
19765 },
19766
19767 /**
19768 * Get data point x coordinate
19769 * @param {object} d Data object
19770 * @returns {number}
19771 * @private
19772 */
19773 radarCircleX: function radarCircleX(d) {
19774 return this.cache.get(cacheKey)[d.id][d.index][0];
19775 },
19776
19777 /**
19778 * Get data point y coordinate
19779 * @param {object} d Data object
19780 * @returns {number}
19781 * @private
19782 */
19783 radarCircleY: function radarCircleY(d) {
19784 return this.cache.get(cacheKey)[d.id][d.index][1];
19785 }
19786});
19787;// CONCATENATED MODULE: ./src/config/Options/common/point.ts
19788/**
19789 * Copyright (c) 2017 ~ present NAVER Corp.
19790 * billboard.js project is licensed under the MIT license
19791 */
19792
19793/**
19794 * point config options
19795 */
19796/* harmony default export */ var common_point = ({
19797 /**
19798 * Set point options
19799 * @name point
19800 * @memberof Options
19801 * @type {object}
19802 * @property {object} point Point object
19803 * @property {boolean} [point.show=true] Whether to show each point in line.
19804 * @property {number|Function} [point.r=2.5] The radius size of each point.
19805 * - **NOTE:** Disabled for 'bubble' type
19806 * @property {boolean} [point.focus.expand.enabled=true] Whether to expand each point on focus.
19807 * @property {number} [point.focus.expand.r=point.r*1.75] The radius size of each point on focus.
19808 * - **NOTE:** For 'bubble' type, the default is `bubbleSize*1.15`
19809 * @property {boolean} [point.focus.only=false] Show point only when is focused.
19810 * @property {number|null} [point.opacity=undefined] Set point opacity value.
19811 * - **NOTE:**
19812 * - `null` will make to not set inline 'opacity' css prop.
19813 * - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
19814 * @property {number} [point.sensitivity=10] The senstivity value for interaction boundary.
19815 * @property {number} [point.select.r=point.r*4] The radius size of each point on selected.
19816 * @property {string} [point.type="circle"] The type of point to be drawn
19817 * - **NOTE:**
19818 * - If chart has 'bubble' type, only circle can be used.
19819 * - For IE, non circle point expansions are not supported due to lack of transform support.
19820 * - **Available Values:**
19821 * - circle
19822 * - rectangle
19823 * @property {Array} [point.pattern=[]] The type of point or svg shape as string, to be drawn for each line
19824 * - **NOTE:**
19825 * - This is an `experimental` feature and can have some unexpected behaviors.
19826 * - If chart has 'bubble' type, only circle can be used.
19827 * - For IE, non circle point expansions are not supported due to lack of transform support.
19828 * - **Available Values:**
19829 * - circle
19830 * - rectangle
19831 * - svg shape tag interpreted as string<br>
19832 * (ex. `<polygon points='2.5 0 0 5 5 5'></polygon>`)
19833 * @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
19834 * @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
19835 * @example
19836 * point: {
19837 * show: false,
19838 * r: 5,
19839 *
19840 * // or customize the radius
19841 * r: function(d) {
19842 * ...
19843 * return r;
19844 * },
19845 *
19846 * focus: {
19847 * expand: {
19848 * enabled: true,
19849 * r: 1
19850 * },
19851 * only: true
19852 * },
19853 *
19854 * // do not set inline 'opacity' css prop setting
19855 * opacity: null,
19856 *
19857 * // set every data point's opacity value
19858 * opacity: 0.7,
19859 *
19860 * select: {
19861 * r: 3
19862 * },
19863 *
19864 * // having lower value, means how closer to be for interaction
19865 * sensitivity: 3,
19866 *
19867 * // valid values are "circle" or "rectangle"
19868 * type: "rectangle",
19869 *
19870 * // or indicate as pattern
19871 * pattern: [
19872 * "circle",
19873 * "rectangle",
19874 * "<polygon points='0 6 4 0 -4 0'></polygon>"
19875 * ],
19876 * }
19877 */
19878 point_show: !0,
19879 point_r: 2.5,
19880 point_sensitivity: 10,
19881 point_focus_expand_enabled: !0,
19882 point_focus_expand_r: undefined,
19883 point_focus_only: !1,
19884 point_opacity: undefined,
19885 point_pattern: [],
19886 point_select_r: undefined,
19887 point_type: "circle"
19888});
19889;// CONCATENATED MODULE: ./src/config/Options/shape/area.ts
19890/**
19891 * Copyright (c) 2017 ~ present NAVER Corp.
19892 * billboard.js project is licensed under the MIT license
19893 */
19894
19895/**
19896 * area config options
19897 */
19898/* harmony default export */ var Options_shape_area = ({
19899 /**
19900 * Set area options
19901 * @name area
19902 * @memberof Options
19903 * @type {object}
19904 * @property {object} area Area object
19905 * @property {boolean} [area.above=false] Set background area above the data chart line.
19906 * @property {boolean} [area.front=true] Set area node to be positioned over line node.
19907 * @property {boolean|object} [area.linearGradient=false] Set the linear gradient on area.<br><br>
19908 * Or customize by giving below object value:
19909 * - x {Array}: `x1`, `x2` value
19910 * - y {Array}: `y1`, `y2` value
19911 * - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
19912 * @property {boolean} [area.zerobased=true] Set if min or max value will be 0 on area chart.
19913 * @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)
19914 * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
19915 * @see [Demo: above](https://naver.github.io/billboard.js/demo/#AreaChartOptions.Above)
19916 * @see [Demo: linearGradient](https://naver.github.io/billboard.js/demo/#AreaChartOptions.LinearGradient)
19917 * @example
19918 * area: {
19919 * above: true,
19920 * zerobased: false,
19921 *
19922 * // <g class='bb-areas'> will be positioned behind the line <g class='bb-lines'> in stacking order
19923 * front: false,
19924 *
19925 * // will generate follwing linearGradient:
19926 * // <linearGradient x1="0" x2="0" y1="0" y2="1">
19927 * // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
19928 * // <stop offset="1" stop-color="$DATA_COLOR" stop-opacity="0"></stop>
19929 * // </linearGradient>
19930 * linearGradient: true,
19931 *
19932 * // Or customized gradient
19933 * linearGradient: {
19934 * x: [0, 0], // x1, x2 attributes
19935 * y: [0, 0], // y1, y2 attributes
19936 * stops: [
19937 * // offset, stop-color, stop-opacity
19938 * [0, "#7cb5ec", 1],
19939 *
19940 * // setting 'null' for stop-color, will set its original data color
19941 * [0.5, null, 0],
19942 *
19943 * // setting 'function' for stop-color, will pass data id as argument.
19944 * // It should return color string or null value
19945 * [1, function(id) { return id === "data1" ? "red" : "blue"; }, 0],
19946 * ]
19947 * }
19948 * }
19949 */
19950 area_above: !1,
19951 area_front: !0,
19952 area_linearGradient: !1,
19953 area_zerobased: !0
19954});
19955;// CONCATENATED MODULE: ./src/config/Options/shape/bar.ts
19956/**
19957 * Copyright (c) 2017 ~ present NAVER Corp.
19958 * billboard.js project is licensed under the MIT license
19959 */
19960
19961/**
19962 * bar config options
19963 */
19964/* harmony default export */ var shape_bar = ({
19965 /**
19966 * Set bar options
19967 * @name bar
19968 * @memberof Options
19969 * @type {object}
19970 * @property {object} bar Bar object
19971 * @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
19972 * @property {number} [bar.padding=0] The padding pixel value between each bar.
19973 * @property {number} [bar.radius] Set the radius of bar edge in pixel.
19974 * - **NOTE:** Works only for non-stacked bar
19975 * @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
19976 * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
19977 * @property {number} [bar.width] Change the width of bar chart.
19978 * @property {number} [bar.width.ratio=0.6] Change the width of bar chart by ratio.
19979 * @property {number} [bar.width.max] The maximum width value for ratio.
19980 * @property {number} [bar.width.dataname] Change the width of bar for indicated dataset only.
19981 * - **NOTE:**
19982 * - Works only for non-stacked bar
19983 * - Bars are centered accoding its total width value
19984 * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
19985 * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
19986 * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
19987 * @see [Demo: bar padding](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarPadding)
19988 * @see [Demo: bar radius](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarRadius)
19989 * @see [Demo: bar width](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidth)
19990 * @see [Demo: bar width variant](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidthVariant)
19991 * @example
19992 * bar: {
19993 * padding: 1,
19994 *
19995 * // the 'radius' option can be used only for non-stacking bars
19996 * radius: 10,
19997 * // or
19998 * radius: {
19999 * ratio: 0.5
20000 * }
20001 *
20002 * label: {
20003 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the y Axis domain range value.
20004 * // if data value is below than 0.1, text label will be hidden.
20005 * threshold: 0.1,
20006 * },
20007 *
20008 * // will not have offset between each bar elements for interaction
20009 * sensitivity: 0,
20010 *
20011 * width: 10,
20012 *
20013 * // or
20014 * width: {
20015 * ratio: 0.2,
20016 * max: 20
20017 * },
20018 *
20019 * // or specify width per dataset
20020 * width: {
20021 * data1: 20,
20022 * data2: {
20023 * ratio: 0.2,
20024 * max: 20
20025 * }
20026 * },
20027 *
20028 * zerobased: false
20029 * }
20030 */
20031 bar_label_threshold: 0,
20032 bar_padding: 0,
20033 bar_radius: undefined,
20034 bar_radius_ratio: undefined,
20035 bar_sensitivity: 2,
20036 bar_width: undefined,
20037 bar_width_ratio: .6,
20038 bar_width_max: undefined,
20039 bar_zerobased: !0
20040});
20041;// CONCATENATED MODULE: ./src/config/Options/shape/bubble.ts
20042/**
20043 * Copyright (c) 2017 ~ present NAVER Corp.
20044 * billboard.js project is licensed under the MIT license
20045 */
20046
20047/**
20048 * bubble config options
20049 */
20050/* harmony default export */ var shape_bubble = ({
20051 /**
20052 * Set bubble options
20053 * @name bubble
20054 * @memberof Options
20055 * @type {object}
20056 * @property {object} bubble bubble object
20057 * @property {number|Function} [bubble.maxR=35] Set the max bubble radius value
20058 * @property {boolean} [bubble.zerobased=false] Set if min or max value will be 0 on bubble chart.
20059 * @example
20060 * bubble: {
20061 * // ex) If 100 is the highest value among data bound, the representation bubble of 100 will have radius of 50.
20062 * // And the lesser will have radius relatively from tha max value.
20063 * maxR: 50,
20064 *
20065 * // or set radius callback
20066 * maxR: function(d) {
20067 * // ex. of d param - {x: Fri Oct 06 2017 00:00:00 GMT+0900, value: 80, id: "data2", index: 5}
20068 * ...
20069 * return Math.sqrt(d.value * 2);
20070 * },
20071 * zerobased: false
20072 * }
20073 */
20074 bubble_maxR: 35,
20075 bubble_zerobased: !1
20076});
20077;// CONCATENATED MODULE: ./src/config/Options/shape/candlestick.ts
20078/**
20079 * Copyright (c) 2017 ~ present NAVER Corp.
20080 * billboard.js project is licensed under the MIT license
20081 */
20082
20083/**
20084 * candlestick config options
20085 */
20086/* harmony default export */ var shape_candlestick = ({
20087 /**
20088 * Set candlestick options
20089 * @name candlestick
20090 * @memberof Options
20091 * @type {object}
20092 * @property {object} candlestick Candlestick object
20093 * @property {number} [candlestick.width] Change the width.
20094 * @property {number} [candlestick.width.ratio=0.6] Change the width by ratio.
20095 * @property {number} [candlestick.width.max] The maximum width value for ratio.
20096 * @property {number} [candlestick.width.dataname] Change the width for indicated dataset only.
20097 * @property {number} [candlestick.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
20098 * @property {number} [candlestick.width.dataname.max] The maximum width value for ratio.
20099 * @property {object} [candlestick.color] Color setting.
20100 * @property {string|object} [candlestick.color.down] Change down(bearish) value color.
20101 * @property {string} [candlestick.color.down.dataname] Change down value color for indicated dataset only.
20102 *
20103 * @see [Demo](https://naver.github.io/billboard.js/demo/##Chart.CandlestickChart)
20104 * @example
20105 * candlestick: {
20106 * width: 10,
20107 *
20108 * // or
20109 * width: {
20110 * ratio: 0.2,
20111 * max: 20
20112 * },
20113 *
20114 * // or specify width per dataset
20115 * width: {
20116 * data1: 20,
20117 * data2: {
20118 * ratio: 0.2,
20119 * max: 20
20120 * }
20121 * },
20122 * color: {
20123 * // spcify bearish color
20124 * down: "red",
20125 *
20126 * // or specify color per dataset
20127 * down: {
20128 * data1: "red",
20129 * data2: "blue",
20130 * }
20131 * }
20132 * }
20133 */
20134 candlestick_width: undefined,
20135 candlestick_width_ratio: .6,
20136 candlestick_width_max: undefined,
20137 candlestick_color_down: "red"
20138});
20139;// CONCATENATED MODULE: ./src/config/Options/shape/line.ts
20140/**
20141 * Copyright (c) 2017 ~ present NAVER Corp.
20142 * billboard.js project is licensed under the MIT license
20143 */
20144
20145/**
20146 * line config options
20147 */
20148/* harmony default export */ var shape_line = ({
20149 /**
20150 * Set line options
20151 * @name line
20152 * @memberof Options
20153 * @type {object}
20154 * @property {object} line Line object
20155 * @property {boolean} [line.connectNull=false] Set if null data point will be connected or not.<br>
20156 * 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.
20157 * @property {Array} [line.classes=undefined] If set, used to set a css class on each line.
20158 * @property {boolean} [line.step.type=step] Change step type for step chart.<br>
20159 * **Available values:**
20160 * - step
20161 * - step-before
20162 * - step-after
20163 * @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.
20164 * @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.
20165 * @property {boolean} [line.zerobased=false] Set if min or max value will be 0 on line chart.
20166 * @example
20167 * line: {
20168 * connectNull: true,
20169 * classes: [
20170 * "line-class1",
20171 * "line-class2"
20172 * ],
20173 * step: {
20174 * type: "step-after",
20175 *
20176 * // to have cursor/tooltip match to hovered step's point instead of nearest point.
20177 * tooltipMatch: true
20178 * },
20179 *
20180 * // hide all data points ('point.show=false' also has similar effect)
20181 * point: false,
20182 *
20183 * // show data points for only indicated datas
20184 * point: [
20185 * "data1", "data3"
20186 * ],
20187 *
20188 * zerobased: false
20189 * }
20190 */
20191 line_connectNull: !1,
20192 line_step_type: "step",
20193 line_step_tooltipMatch: !1,
20194 line_zerobased: !1,
20195 line_classes: undefined,
20196 line_point: !0
20197});
20198;// CONCATENATED MODULE: ./src/config/Options/shape/scatter.ts
20199/**
20200 * Copyright (c) 2017 ~ present NAVER Corp.
20201 * billboard.js project is licensed under the MIT license
20202 */
20203
20204/**
20205 * scatter config options
20206 */
20207/* harmony default export */ var scatter = ({
20208 /**
20209 * Set scatter options
20210 * @name scatter
20211 * @memberof Options
20212 * @type {object}
20213 * @property {object} [scatter] scatter object
20214 * @property {boolean} [scatter.zerobased=false] Set if min or max value will be 0 on scatter chart.
20215 * @example
20216 * scatter: {
20217 * connectNull: true,
20218 * step: {
20219 * type: "step-after"
20220 * },
20221 *
20222 * // hide all data points ('point.show=false' also has similar effect)
20223 * point: false,
20224 *
20225 * // show data points for only indicated datas
20226 * point: [
20227 * "data1", "data3"
20228 * ],
20229 *
20230 * zerobased: false
20231 * }
20232 */
20233 scatter_zerobased: !1
20234});
20235;// CONCATENATED MODULE: ./src/config/Options/shape/spline.ts
20236/**
20237 * Copyright (c) 2017 ~ present NAVER Corp.
20238 * billboard.js project is licensed under the MIT license
20239 */
20240
20241/**
20242 * x Axis config options
20243 */
20244/* harmony default export */ var spline = ({
20245 /**
20246 * Set spline options
20247 * - **Available interpolation type values:**
20248 * - basis (d3.curveBasis)
20249 * - basis-closed (d3.curveBasisClosed)
20250 * - basis-open (d3.curveBasisOpen)
20251 * - bundle (d3.curveBundle)
20252 * - cardinal (d3.curveCardinal)
20253 * - cardinal-closed (d3.curveCardinalClosed)
20254 * - cardinal-open (d3.curveCardinalOpen)
20255 * - catmull-rom (d3.curveCatmullRom)
20256 * - catmull-rom-closed (d3.curveCatmullRomClosed)
20257 * - catmull-rom-open (d3.curveCatmullRomOpen)
20258 * - monotone-x (d3.curveMonotoneX)
20259 * - monotone-y (d3.curveMonotoneY)
20260 * - natural (d3.curveNatural)
20261 * - linear-closed (d3.curveLinearClosed)
20262 * - linear (d3.curveLinear)
20263 * - step (d3.curveStep)
20264 * - step-after (d3.curveStepAfter)
20265 * - step-before (d3.curveStepBefore)
20266 * @name spline
20267 * @memberof Options
20268 * @type {object}
20269 * @property {object} spline Spline object
20270 * @property {object} spline.interpolation Spline interpolation object
20271 * @property {string} [spline.interpolation.type="cardinal"] Interpolation type
20272 * @see [Interpolation (d3 v4)](http://bl.ocks.org/emmasaunders/c25a147970def2b02d8c7c2719dc7502)
20273 * @example
20274 * spline: {
20275 * interpolation: {
20276 * type: "cardinal"
20277 * }
20278 * }
20279 */
20280 spline_interpolation_type: "cardinal"
20281});
20282;// CONCATENATED MODULE: ./src/config/Options/shape/donut.ts
20283/**
20284 * Copyright (c) 2017 ~ present NAVER Corp.
20285 * billboard.js project is licensed under the MIT license
20286 */
20287
20288/**
20289 * donut config options
20290 */
20291/* harmony default export */ var donut = ({
20292 /**
20293 * Set donut options
20294 * @name donut
20295 * @memberof Options
20296 * @type {object}
20297 * @property {object} donut Donut object
20298 * @property {boolean} [donut.label.show=true] Show or hide label on each donut piece.
20299 * @property {Function} [donut.label.format] Set formatter for the label on each donut piece.
20300 * @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
20301 * @property {number|Function} [donut.label.ratio=undefined] Set ratio of labels position.
20302 * @property {boolean} [donut.expand=true] Enable or disable expanding donut pieces.
20303 * @property {number} [donut.expand.rate=0.98] Set expand rate.
20304 * @property {number} [donut.expand.duration=50] Set expand transition time in ms.
20305 * @property {number} [donut.width] Set width of donut chart.
20306 * @property {string} [donut.title=""] Set title of donut chart. Use `\n` character for line break.
20307 * @property {number} [donut.padAngle=0] Set padding between data.
20308 * @property {number} [donut.startingAngle=0] Set starting angle where data draws.
20309 * @example
20310 * donut: {
20311 * label: {
20312 * show: false,
20313 * format: function(value, ratio, id) {
20314 * return d3.format("$")(value);
20315 *
20316 * // to multiline, return with '\n' character
20317 * // return value +"%\nLine1\n2Line2";
20318 * },
20319 *
20320 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
20321 * // if data value is below than 0.1, text label will be hidden.
20322 * threshold: 0.1,
20323 *
20324 * // set ratio callback. Should return ratio value
20325 * ratio: function(d, radius, h) {
20326 * ...
20327 * return ratio;
20328 * },
20329 * // or set ratio number
20330 * ratio: 0.5
20331 * },
20332 *
20333 * // disable expand transition for interaction
20334 * expand: false,
20335 *
20336 * expand: {
20337 * // set duration of expand transition to 500ms.
20338 * duration: 500,
20339 *
20340 * // set expand area rate
20341 * rate: 1
20342 * },
20343 *
20344 * width: 10,
20345 * padAngle: 0.2,
20346 * startingAngle: 1,
20347 * title: "Donut Title"
20348 *
20349 * // title with line break
20350 * title: "Title1\nTitle2"
20351 * }
20352 */
20353 donut_label_show: !0,
20354 donut_label_format: undefined,
20355 donut_label_threshold: .05,
20356 donut_label_ratio: undefined,
20357 donut_width: undefined,
20358 donut_title: "",
20359 donut_expand: {},
20360 donut_expand_rate: .98,
20361 donut_expand_duration: 50,
20362 donut_padAngle: 0,
20363 donut_startingAngle: 0
20364});
20365;// CONCATENATED MODULE: ./src/config/Options/shape/gauge.ts
20366/**
20367 * Copyright (c) 2017 ~ present NAVER Corp.
20368 * billboard.js project is licensed under the MIT license
20369 */
20370
20371/**
20372 * gauge config options
20373 */
20374/* harmony default export */ var shape_gauge = ({
20375 /**
20376 * Set gauge options
20377 * @name gauge
20378 * @memberof Options
20379 * @type {object}
20380 * @property {object} gauge Gauge object
20381 * @property {boolean} [gauge.background=""] Set background color. (The `.bb-chart-arcs-background` element)
20382 * @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.
20383 * @property {boolean} [gauge.label.show=true] Show or hide label on gauge.
20384 * @property {Function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.<br>
20385 * Will pass following arguments to the given function:
20386 * - value {number}: absolute value
20387 * - ratio {number}: value's ratio
20388 * - id {string}: data's id value
20389 * @property {Function} [gauge.label.extents] Set customized min/max label text.
20390 * @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
20391 * @property {boolean} [gauge.expand=true] Enable or disable expanding gauge.
20392 * @property {number} [gauge.expand.rate=0.98] Set expand rate.
20393 * @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
20394 * @property {number} [gauge.min=0] Set min value of the gauge.
20395 * @property {number} [gauge.max=100] Set max value of the gauge.
20396 * @property {number} [gauge.startingAngle=-1 * Math.PI / 2] Set starting angle where data draws.
20397 *
20398 * **Limitations:**
20399 * - when `gauge.fullCircle=false`:
20400 * - -1 * Math.PI / 2 <= startingAngle <= Math.PI / 2
20401 * - `startingAngle <= -1 * Math.PI / 2` defaults to `-1 * Math.PI / 2`
20402 * - `startingAngle >= Math.PI / 2` defaults to `Math.PI / 2`
20403 * - when `gauge.fullCircle=true`:
20404 * - -1 * Math.PI < startingAngle < Math.PI
20405 * - `startingAngle < -1 * Math.PI` defaults to `Math.PI`
20406 * - `startingAngle > Math.PI` defaults to `Math.PI`
20407 * @property {number} [gauge.arcLength=100] Set the length of the arc to be drawn in percent from -100 to 100.<br>
20408 * Negative value will draw the arc **counterclockwise**.
20409 *
20410 * **Limitations:**
20411 * - -100 <= arcLength (in percent) <= 100
20412 * - 'arcLength < -100' defaults to -100
20413 * - 'arcLength > 100' defaults to 100
20414 * @property {string} [gauge.title=""] Set title of gauge chart. Use `\n` character for line break.
20415 * @property {string} [gauge.units] Set units of the gauge.
20416 * @property {number} [gauge.width] Set width of gauge chart.
20417 * @property {string} [gauge.type="single"] Set type of gauge to be displayed.<br><br>
20418 * **Available Values:**
20419 * - single
20420 * - multi
20421 * @property {string} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
20422 * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
20423 * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
20424 * @example
20425 * gauge: {
20426 * background: "#eee", // will set 'fill' css prop for '.bb-chart-arcs-background' classed element.
20427 * fullCircle: false,
20428 * label: {
20429 * show: false,
20430 * format: function(value, ratio, id) {
20431 * return value;
20432 *
20433 * // to multiline, return with '\n' character
20434 * // return value +"%\nLine1\n2Line2";
20435 * },
20436 *
20437 * extents: function(value, isMax) {
20438 * return (isMax ? "Max:" : "Min:") + value;
20439 * },
20440 *
20441 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
20442 * // if data value is below than 0.1, text label will be hidden.
20443 * threshold: 0.1,
20444 * },
20445 *
20446 * // disable expand transition for interaction
20447 * expand: false,
20448 *
20449 * expand: {
20450 * // set duration of expand transition to 500ms.
20451 * duration: 500,
20452 *
20453 * // set expand area rate
20454 * rate: 1
20455 * },
20456 *
20457 * min: -100,
20458 * max: 200,
20459 * type: "single" // or 'multi'
20460 * title: "Title Text",
20461 * units: "%",
20462 * width: 10,
20463 * startingAngle: -1 * Math.PI / 2,
20464 * arcLength: 100,
20465 * arcs: {
20466 * minWidth: 5
20467 * }
20468 * }
20469 */
20470 gauge_background: "",
20471 gauge_fullCircle: !1,
20472 gauge_label_show: !0,
20473 gauge_label_format: undefined,
20474 gauge_label_extents: undefined,
20475 gauge_label_threshold: 0,
20476 gauge_min: 0,
20477 gauge_max: 100,
20478 gauge_type: "single",
20479 gauge_startingAngle: -1 * Math.PI / 2,
20480 gauge_arcLength: 100,
20481 gauge_title: "",
20482 gauge_units: undefined,
20483 gauge_width: undefined,
20484 gauge_arcs_minWidth: 5,
20485 gauge_expand: {},
20486 gauge_expand_rate: .98,
20487 gauge_expand_duration: 50
20488});
20489;// CONCATENATED MODULE: ./src/config/Options/shape/pie.ts
20490/**
20491 * Copyright (c) 2017 ~ present NAVER Corp.
20492 * billboard.js project is licensed under the MIT license
20493 */
20494
20495/**
20496 * x Axis config options
20497 */
20498/* harmony default export */ var pie = ({
20499 /**
20500 * Set pie options
20501 * @name pie
20502 * @memberof Options
20503 * @type {object}
20504 * @property {object} pie Pie object
20505 * @property {boolean} [pie.label.show=true] Show or hide label on each pie piece.
20506 * @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
20507 * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
20508 * @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
20509 * @property {boolean|object} [pie.expand=true] Enable or disable expanding pie pieces.
20510 * @property {number} [pie.expand.rate=0.98] Set expand rate.
20511 * @property {number} [pie.expand.duration=50] Set expand transition time in ms.
20512 * @property {number|object} [pie.innerRadius=0] Sets the inner radius of pie arc.
20513 * @property {number|object|undefined} [pie.outerRadius=undefined] Sets the outer radius of pie arc.
20514 * @property {number} [pie.padAngle=0] Set padding between data.
20515 * @property {number} [pie.padding=0] Sets the gap between pie arcs.
20516 * @property {number} [pie.startingAngle=0] Set starting angle where data draws.
20517 * @see [Demo: expand.rate](https://naver.github.io/billboard.js/demo/#PieChartOptions.ExpandRate)
20518 * @see [Demo: innerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.InnerRadius)
20519 * @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
20520 * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
20521 * @example
20522 * pie: {
20523 * label: {
20524 * show: false,
20525 * format: function(value, ratio, id) {
20526 * return d3.format("$")(value);
20527 *
20528 * // to multiline, return with '\n' character
20529 * // return value +"%\nLine1\n2Line2";
20530 * },
20531 *
20532 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
20533 * // if data value is below than 0.1, text label will be hidden.
20534 * threshold: 0.1,
20535 *
20536 * // set ratio callback. Should return ratio value
20537 * ratio: function(d, radius, h) {
20538 * ...
20539 * return ratio;
20540 * },
20541 * // or set ratio number
20542 * ratio: 0.5
20543 * },
20544 *
20545 * // disable expand transition for interaction
20546 * expand: false,
20547 *
20548 * expand: {
20549 * // set duration of expand transition to 500ms.
20550 * duration: 500,
20551 *
20552 * // set expand area rate
20553 * rate: 1
20554 * },
20555 *
20556 * innerRadius: 0,
20557 *
20558 * // set different innerRadius for each data
20559 * innerRadius: {
20560 * data1: 10,
20561 * data2: 0
20562 * },
20563 *
20564 * outerRadius: 100,
20565 *
20566 * // set different outerRadius for each data
20567 * outerRadius: {
20568 * data1: 50,
20569 * data2: 100
20570 * }
20571 *
20572 * padAngle: 0.1,
20573 * padding: 0,
20574 * startingAngle: 1
20575 * }
20576 */
20577 pie_label_show: !0,
20578 pie_label_format: undefined,
20579 pie_label_threshold: .05,
20580 pie_label_ratio: undefined,
20581 pie_expand: {},
20582 pie_expand_rate: .98,
20583 pie_expand_duration: 50,
20584 pie_innerRadius: 0,
20585 pie_outerRadius: undefined,
20586 pie_padAngle: 0,
20587 pie_padding: 0,
20588 pie_startingAngle: 0
20589});
20590;// CONCATENATED MODULE: ./src/config/Options/shape/radar.ts
20591/**
20592 * Copyright (c) 2017 ~ present NAVER Corp.
20593 * billboard.js project is licensed under the MIT license
20594 */
20595
20596/**
20597 * x Axis config options
20598 */
20599/* harmony default export */ var shape_radar = ({
20600 /**
20601 * Set radar options
20602 * - **NOTE:**
20603 * > When x tick text contains `\n`, it's used as line break.
20604 * @name radar
20605 * @memberof Options
20606 * @type {object}
20607 * @property {object} radar Radar object
20608 * @property {number} [radar.axis.max=undefined] The max value of axis. If not given, it'll take the max value from the given data.
20609 * @property {boolean} [radar.axis.line.show=true] Show or hide axis line.
20610 * @property {number} [radar.axis.text.position.x=0] x coordinate position, relative the original.
20611 * @property {number} [radar.axis.text.position.y=0] y coordinate position, relative the original.
20612 * @property {boolean} [radar.axis.text.show=true] Show or hide axis text.
20613 * @property {boolean} [radar.direction.clockwise=false] Set the direction to be drawn.
20614 * @property {number} [radar.level.depth=3] Set the level depth.
20615 * @property {boolean} [radar.level.show=true] Show or hide level.
20616 * @property {Function} [radar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
20617 * @property {boolean} [radar.level.text.show=true] Show or hide level text.
20618 * @property {number} [radar.size.ratio=0.87] Set size ratio.
20619 * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.RadarChart)
20620 * @see [Demo: radar axis](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarAxis)
20621 * @see [Demo: radar level](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarLevel)
20622 * @see [Demo: radar size](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarSize)
20623 * @see [Demo: radar axis multiline](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarAxisMultiline)
20624 * @example
20625 * radar: {
20626 * axis: {
20627 * max: 50,
20628 * line: {
20629 * show: false
20630 * },
20631 * text: {
20632 * position: {
20633 * x: 0,
20634 * y: 0
20635 * },
20636 * show: false
20637 * }
20638 * },
20639 * direction: {
20640 * clockwise: true
20641 * },
20642 * level: {
20643 * show: false,
20644 * text: {
20645 * format: function(x) {
20646 * return x + "%";
20647 * },
20648 * show: true
20649 * }
20650 * },
20651 * size: {
20652 * ratio: 0.7
20653 * }
20654 * }
20655 */
20656 radar_axis_max: undefined,
20657 radar_axis_line_show: !0,
20658 radar_axis_text_show: !0,
20659 radar_axis_text_position: {},
20660 radar_level_depth: 3,
20661 radar_level_show: !0,
20662 radar_level_text_format: function radar_level_text_format(x) {
20663 return x % 1 === 0 ? x : x.toFixed(2);
20664 },
20665 radar_level_text_show: !0,
20666 radar_size_ratio: .87,
20667 radar_direction_clockwise: !1
20668});
20669;// CONCATENATED MODULE: ./src/config/resolver/shape.ts
20670/**
20671 * Copyright (c) 2017 ~ present NAVER Corp.
20672 * billboard.js project is licensed under the MIT license
20673 */
20674
20675
20676
20677
20678 // Axis
20679
20680 // Shape
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690 // Options
20691
20692
20693
20694
20695
20696
20697
20698
20699 // Non-Axis based
20700
20701
20702
20703
20704
20705
20706/**
20707 * Extend Axis
20708 * @param {Array} module Module to be extended
20709 * @param {Array} option Option object to be extended
20710 * @private
20711 */
20712
20713function extendAxis(module, option) {
20714 extend(ChartInternal.prototype, internal.concat(module));
20715 extend(Chart.prototype, api);
20716 Options.setOptions(options.concat(option || []));
20717}
20718/**
20719 * Extend Line type modules
20720 * @param {object} module Module to be extended
20721 * @param {Array} option Option object to be extended
20722 * @private
20723 */
20724
20725
20726function extendLine(module, option) {
20727 extendAxis([point, line].concat(module || []));
20728 Options.setOptions([common_point, shape_line].concat(option || []));
20729}
20730/**
20731 * Extend Arc type modules
20732 * @param {Array} module Module to be extended
20733 * @param {Array} option Option object to be extended
20734 * @private
20735 */
20736
20737
20738function extendArc(module, option) {
20739 extend(ChartInternal.prototype, [arc].concat(module || []));
20740 Options.setOptions(option);
20741} // Area types
20742
20743
20744var _area = function area() {
20745 return extendLine(shape_area, [Options_shape_area]), (_area = function area() {
20746 return TYPE.AREA;
20747 })();
20748},
20749 areaLineRange = function () {
20750 return extendLine(shape_area, [Options_shape_area]), (areaLineRange = function () {
20751 return TYPE.AREA_LINE_RANGE;
20752 })();
20753},
20754 areaSpline = function () {
20755 return extendLine(shape_area, [Options_shape_area, spline]), (areaSpline = function () {
20756 return TYPE.AREA_SPLINE;
20757 })();
20758},
20759 areaSplineRange = function () {
20760 return extendLine(shape_area, [Options_shape_area, spline]), (areaSplineRange = function () {
20761 return TYPE.AREA_SPLINE_RANGE;
20762 })();
20763},
20764 areaStep = function () {
20765 return extendLine(shape_area, [Options_shape_area]), (areaStep = function () {
20766 return TYPE.AREA_STEP;
20767 })();
20768},
20769 resolver_shape_line = function () {
20770 return extendLine(), (resolver_shape_line = function () {
20771 return TYPE.LINE;
20772 })();
20773},
20774 shape_spline = function () {
20775 return extendLine(undefined, [spline]), (shape_spline = function () {
20776 return TYPE.SPLINE;
20777 })();
20778},
20779 step = function () {
20780 return extendLine(), (step = function () {
20781 return TYPE.STEP;
20782 })();
20783},
20784 shape_donut = function () {
20785 return extendArc(undefined, [donut]), (shape_donut = function () {
20786 return TYPE.DONUT;
20787 })();
20788},
20789 resolver_shape_gauge = function () {
20790 return extendArc([gauge], [shape_gauge]), (resolver_shape_gauge = function () {
20791 return TYPE.GAUGE;
20792 })();
20793},
20794 shape_pie = function () {
20795 return extendArc(undefined, [pie]), (shape_pie = function () {
20796 return TYPE.PIE;
20797 })();
20798},
20799 resolver_shape_radar = function () {
20800 return extendArc([point, radar], [common_point, shape_radar]), (resolver_shape_radar = function () {
20801 return TYPE.RADAR;
20802 })();
20803},
20804 resolver_shape_bar = function () {
20805 return extendAxis([bar], shape_bar), (resolver_shape_bar = function () {
20806 return TYPE.BAR;
20807 })();
20808},
20809 resolver_shape_bubble = function () {
20810 return extendAxis([point, bubble], [shape_bubble, common_point]), (resolver_shape_bubble = function () {
20811 return TYPE.BUBBLE;
20812 })();
20813},
20814 resolver_shape_candlestick = function () {
20815 return extendAxis([candlestick], [shape_candlestick]), (resolver_shape_candlestick = function () {
20816 return TYPE.CANDLESTICK;
20817 })();
20818},
20819 shape_scatter = function () {
20820 return extendAxis([point], [common_point, scatter]), (shape_scatter = function () {
20821 return TYPE.SCATTER;
20822 })();
20823};
20824;// CONCATENATED MODULE: ./src/Chart/api/selection.ts
20825/**
20826 * Copyright (c) 2017 ~ present NAVER Corp.
20827 * billboard.js project is licensed under the MIT license
20828 */
20829
20830
20831
20832/* harmony default export */ var selection = ({
20833 /**
20834 * Get selected data points.<br><br>
20835 * By this API, you can get selected data points information. To use this API, data.selection.enabled needs to be set true.
20836 * @function selected
20837 * @instance
20838 * @memberof Chart
20839 * @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.
20840 * @returns {Array} dataPoint Array of the data points.<br>ex.) `[{x: 1, value: 200, id: "data1", index: 1, name: "data1"}, ...]`
20841 * @example
20842 * // all selected data points will be returned.
20843 * chart.selected();
20844 * // --> ex.) [{x: 1, value: 200, id: "data1", index: 1, name: "data1"}, ... ]
20845 *
20846 * // all selected data points of data1 will be returned.
20847 * chart.selected("data1");
20848 */
20849 selected: function selected(targetId) {
20850 var $$ = this.internal,
20851 dataPoint = [];
20852 $$.$el.main.selectAll("." + (config_classes.shapes + $$.getTargetSelectorSuffix(targetId))).selectAll("." + config_classes.shape).filter(function () {
20853 return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.SELECTED);
20854 }).each(function (d) {
20855 return dataPoint.push(d);
20856 });
20857 return dataPoint;
20858 },
20859
20860 /**
20861 * 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)
20862 * @function select
20863 * @instance
20864 * @memberof Chart
20865 * @param {string|Array} [ids] id value to get selected.
20866 * @param {Array} [indices] The index array of data points. If falsy value given, will select all data points.
20867 * @param {boolean} [resetOther] Unselect already selected.
20868 * @example
20869 * // select all data points
20870 * chart.select();
20871 *
20872 * // select all from 'data2'
20873 * chart.select("data2");
20874 *
20875 * // select all from 'data1' and 'data2'
20876 * chart.select(["data1", "data2"]);
20877 *
20878 * // select from 'data1', indices 2 and unselect others selected
20879 * chart.select("data1", [2], true);
20880 *
20881 * // select from 'data1', indices 0, 3 and 5
20882 * chart.select("data1", [0, 3, 5]);
20883 */
20884 select: function select(ids, indices, resetOther) {
20885 var $$ = this.internal,
20886 config = $$.config,
20887 $el = $$.$el;
20888
20889 if (!config.data_selection_enabled) {
20890 return;
20891 }
20892
20893 $el.main.selectAll("." + config_classes.shapes).selectAll("." + config_classes.shape).each(function (d, i) {
20894 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
20895 id = d.data ? d.data.id : d.id,
20896 toggle = $$.getToggle(this, d).bind($$),
20897 isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
20898 isTargetIndex = !indices || indices.indexOf(i) >= 0,
20899 isSelected = shape.classed(config_classes.SELECTED);
20900
20901 // line/area selection not supported yet
20902 if (shape.classed(config_classes.line) || shape.classed(config_classes.area)) {
20903 return;
20904 }
20905
20906 if (isTargetId && isTargetIndex) {
20907 if (config.data_selection_isselectable.bind($$.api)(d) && !isSelected) {
20908 toggle(!0, shape.classed(config_classes.SELECTED, !0), d, i);
20909 }
20910 } else if (isDefined(resetOther) && resetOther && isSelected) {
20911 toggle(!1, shape.classed(config_classes.SELECTED, !1), d, i);
20912 }
20913 });
20914 },
20915
20916 /**
20917 * Set data points to be un-selected.
20918 * @function unselect
20919 * @instance
20920 * @memberof Chart
20921 * @param {string|Array} [ids] id value to be unselected.
20922 * @param {Array} [indices] The index array of data points. If falsy value given, will select all data points.
20923 * @example
20924 * // unselect all data points
20925 * chart.unselect();
20926 *
20927 * // unselect all from 'data1'
20928 * chart.unselect("data1");
20929 *
20930 * // unselect from 'data1', indices 2
20931 * chart.unselect("data1", [2]);
20932 */
20933 unselect: function unselect(ids, indices) {
20934 var $$ = this.internal,
20935 config = $$.config,
20936 $el = $$.$el;
20937
20938 if (!config.data_selection_enabled) {
20939 return;
20940 }
20941
20942 $el.main.selectAll("." + config_classes.shapes).selectAll("." + config_classes.shape).each(function (d, i) {
20943 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
20944 id = d.data ? d.data.id : d.id,
20945 toggle = $$.getToggle(this, d).bind($$),
20946 isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
20947 isTargetIndex = !indices || indices.indexOf(i) >= 0,
20948 isSelected = shape.classed(config_classes.SELECTED);
20949
20950 // line/area selection not supported yet
20951 if (shape.classed(config_classes.line) || shape.classed(config_classes.area)) {
20952 return;
20953 }
20954
20955 if (isTargetId && isTargetIndex && config.data_selection_isselectable.bind($$.api)(d) && isSelected) {
20956 toggle(!1, shape.classed(config_classes.SELECTED, !1), d, i);
20957 }
20958 });
20959 }
20960});
20961;// CONCATENATED MODULE: ./src/Chart/api/subchart.ts
20962/**
20963 * Copyright (c) 2017 ~ present NAVER Corp.
20964 * billboard.js project is licensed under the MIT license
20965 */
20966
20967/* harmony default export */ var subchart = ({
20968 subchart: {
20969 /**
20970 * Show subchart
20971 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
20972 * @function subchart․show
20973 * @instance
20974 * @memberof Chart
20975 * @example
20976 * // for ESM imports, needs to import 'subchart' and must be instantiated first to enable subchart's API.
20977 * import {subchart} from "billboard.js";
20978 *
20979 * const chart = bb.generate({
20980 * ...
20981 * subchart: {
20982 * // need to be instantiated by calling 'subchart()'
20983 * enabled: subchart()
20984 *
20985 * // in case don't want subchart to be shown at initialization, instantiate with '!subchart()'
20986 * enabled: !subchart()
20987 * }
20988 * });
20989 *
20990 * chart.subchart.show();
20991 */
20992 show: function () {
20993 var $$ = this.internal,
20994 subchart = $$.$el.subchart,
20995 config = $$.config,
20996 show = config.subchart_show;
20997
20998 if (!show) {
20999 // unbind zoom event bound to chart rect area
21000 $$.unbindZoomEvent();
21001 config.subchart_show = !show;
21002 subchart.main || $$.initSubchart();
21003 var $target = subchart.main.selectAll("." + config_classes.target); // need to cover when new data has been loaded
21004
21005 if ($$.data.targets.length !== $target.size()) {
21006 $$.updateSizes();
21007 $$.updateTargetsForSubchart($$.data.targets);
21008 $target = subchart.main.selectAll("." + config_classes.target);
21009 }
21010
21011 $target.style("opacity", null);
21012 subchart.main.style("display", null);
21013 this.flush();
21014 }
21015 },
21016
21017 /**
21018 * Hide generated subchart
21019 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
21020 * @function subchart․hide
21021 * @instance
21022 * @memberof Chart
21023 * @example
21024 * chart.subchart.hide();
21025 */
21026 hide: function hide() {
21027 var $$ = this.internal,
21028 subchart = $$.$el.subchart,
21029 config = $$.config;
21030
21031 if (config.subchart_show && subchart.main.style("display") !== "none") {
21032 config.subchart_show = !1;
21033 subchart.main.style("display", "none");
21034 this.flush();
21035 }
21036 },
21037
21038 /**
21039 * Toggle the visiblity of subchart
21040 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
21041 * @function subchart․toggle
21042 * @instance
21043 * @memberof Chart
21044 * @example
21045 * // When subchart is hidden, will be shown
21046 * // When subchart is shown, will be hidden
21047 * chart.subchart.toggle();
21048 */
21049 toggle: function toggle() {
21050 var $$ = this.internal,
21051 config = $$.config;
21052 this.subchart[config.subchart_show ? "hide" : "show"]();
21053 }
21054 }
21055});
21056// EXTERNAL MODULE: external {"commonjs":"d3-zoom","commonjs2":"d3-zoom","amd":"d3-zoom","root":"d3"}
21057var external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_ = __webpack_require__(13);
21058;// CONCATENATED MODULE: ./src/Chart/api/zoom.ts
21059/**
21060 * Copyright (c) 2017 ~ present NAVER Corp.
21061 * billboard.js project is licensed under the MIT license
21062 */
21063
21064
21065/**
21066 * Check if the given domain is within zoom range
21067 * @param {Array} domain Target domain value
21068 * @param {Array} current Current zoom domain value
21069 * @param {Array} range Zoom range value
21070 * @returns {boolean}
21071 * @private
21072 */
21073
21074function withinRange(domain, current, range) {
21075 var min = range[0],
21076 max = range[1];
21077 return domain.every(function (v, i) {
21078 return (i === 0 ? v >= min : v <= max) && !domain.every(function (v, i) {
21079 return v === current[i];
21080 });
21081 });
21082}
21083/**
21084 * Zoom by giving x domain range.
21085 * - **NOTE:**
21086 * - 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.
21087 * - To be used [zoom.enabled](Options.html#.zoom) option should be set as `truthy`.
21088 * @function zoom
21089 * @instance
21090 * @memberof Chart
21091 * @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.
21092 * @returns {Array} domain value in array
21093 * @example
21094 * // Zoom to specified domain range
21095 * chart.zoom([10, 20]);
21096 *
21097 * // For timeseries, the domain value can be string, but the format should match with the 'data.xFormat' option.
21098 * chart.zoom(["2021-02-03", "2021-02-08"]);
21099 *
21100 * // Get the current zoomed domain range
21101 * chart.zoom();
21102 */
21103
21104
21105var zoom = function (domainValue) {
21106 var $$ = this.internal,
21107 $el = $$.$el,
21108 axis = $$.axis,
21109 config = $$.config,
21110 org = $$.org,
21111 scale = $$.scale,
21112 isRotated = config.axis_rotated,
21113 isCategorized = axis.isCategorized(),
21114 domain = domainValue;
21115
21116 if (config.zoom_enabled && domain) {
21117 if (axis.isTimeSeries()) {
21118 domain = domain.map(function (x) {
21119 return parseDate.bind($$)(x);
21120 });
21121 }
21122
21123 if (withinRange(domain, $$.getZoomDomain(!0), $$.getZoomDomain())) {
21124 if (isCategorized) {
21125 domain = domain.map(function (v, i) {
21126 return +v + (i === 0 ? 0 : 1);
21127 });
21128 } // hide any possible tooltip show before the zoom
21129
21130
21131 $$.api.tooltip.hide();
21132
21133 if (config.subchart_show) {
21134 var x = scale.zoom || scale.x;
21135 $$.brush.getSelection().call($$.brush.move, domain.map(x)); // resultDomain = domain;
21136 } else {
21137 var _d3ZoomIdentity$scale,
21138 _x = isCategorized ? scale.x.orgScale() : org.xScale || scale.x,
21139 translate = [-_x(domain[0]), 0],
21140 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);
21141
21142 $el.eventRect.call($$.zoom.transform, transform);
21143 }
21144
21145 $$.setZoomResetButton();
21146 }
21147 } else {
21148 domain = scale.zoom ? scale.zoom.domain() : scale.x.orgDomain();
21149 }
21150
21151 return domain;
21152};
21153
21154extend(zoom, {
21155 /**
21156 * Enable and disable zooming.
21157 * @function zoom․enable
21158 * @instance
21159 * @memberof Chart
21160 * @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.
21161 * @example
21162 * // Enable zooming using the mouse wheel
21163 * chart.zoom.enable(true);
21164 * // Or
21165 * chart.zoom.enable("wheel");
21166 *
21167 * // Enable zooming by dragging
21168 * chart.zoom.enable("drag");
21169 *
21170 * // Disable zooming
21171 * chart.zoom.enable(false);
21172 */
21173 enable: function enable(enabled) {
21174 var $$ = this.internal,
21175 config = $$.config;
21176
21177 if (/^(drag|wheel)$/.test(enabled)) {
21178 config.zoom_type = enabled;
21179 }
21180
21181 config.zoom_enabled = !!enabled;
21182
21183 if (!$$.zoom) {
21184 $$.initZoom();
21185 $$.bindZoomEvent();
21186 } else if (enabled === !1) {
21187 $$.bindZoomEvent(!1);
21188 }
21189
21190 $$.updateAndRedraw();
21191 },
21192
21193 /**
21194 * Set or get x Axis maximum zoom range value
21195 * @function zoom․max
21196 * @instance
21197 * @memberof Chart
21198 * @param {number} [max] maximum value to set for zoom
21199 * @returns {number} zoom max value
21200 * @example
21201 * // Set maximum range value
21202 * chart.zoom.max(20);
21203 */
21204 max: function max(_max) {
21205 var $$ = this.internal,
21206 config = $$.config,
21207 xDomain = $$.org.xDomain;
21208
21209 if (_max === 0 || _max) {
21210 config.zoom_x_max = getMinMax("max", [xDomain[1], _max]);
21211 }
21212
21213 return config.zoom_x_max;
21214 },
21215
21216 /**
21217 * Set or get x Axis minimum zoom range value
21218 * @function zoom․min
21219 * @instance
21220 * @memberof Chart
21221 * @param {number} [min] minimum value to set for zoom
21222 * @returns {number} zoom min value
21223 * @example
21224 * // Set minimum range value
21225 * chart.zoom.min(-1);
21226 */
21227 min: function min(_min) {
21228 var $$ = this.internal,
21229 config = $$.config,
21230 xDomain = $$.org.xDomain;
21231
21232 if (_min === 0 || _min) {
21233 config.zoom_x_min = getMinMax("min", [xDomain[0], _min]);
21234 }
21235
21236 return config.zoom_x_min;
21237 },
21238
21239 /**
21240 * Set zoom range
21241 * @function zoom․range
21242 * @instance
21243 * @memberof Chart
21244 * @param {object} [range] zoom range
21245 * @returns {object} zoom range value
21246 * {
21247 * min: 0,
21248 * max: 100
21249 * }
21250 * @example
21251 * chart.zoom.range({
21252 * min: 10,
21253 * max: 100
21254 * });
21255 */
21256 range: function range(_range) {
21257 var zoom = this.zoom;
21258
21259 if (isObject(_range)) {
21260 var min = _range.min,
21261 max = _range.max;
21262 isDefined(min) && zoom.min(min);
21263 isDefined(max) && zoom.max(max);
21264 }
21265
21266 return {
21267 min: zoom.min(),
21268 max: zoom.max()
21269 };
21270 }
21271});
21272/* harmony default export */ var api_zoom = ({
21273 zoom: zoom,
21274
21275 /**
21276 * Unzoom zoomed area
21277 * - **NOTE:** Calling .unzoom() will not trigger zoom events.
21278 * @function unzoom
21279 * @instance
21280 * @memberof Chart
21281 * @example
21282 * chart.unzoom();
21283 */
21284 unzoom: function unzoom() {
21285 var $$ = this.internal,
21286 config = $$.config,
21287 _$$$$el = $$.$el,
21288 eventRect = _$$$$el.eventRect,
21289 zoomResetBtn = _$$$$el.zoomResetBtn;
21290
21291 if ($$.scale.zoom) {
21292 var _zoomResetBtn;
21293
21294 config.subchart_show ? $$.brush.getSelection().call($$.brush.move, null) : $$.zoom.updateTransformScale(external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
21295 $$.updateZoom(!0);
21296 (_zoomResetBtn = zoomResetBtn) == null ? void 0 : _zoomResetBtn.style("display", "none"); // reset transform
21297
21298 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) {
21299 $$.zoom.transform(eventRect, external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
21300 }
21301 }
21302 }
21303});
21304;// CONCATENATED MODULE: ./src/ChartInternal/interactions/drag.ts
21305/**
21306 * Copyright (c) 2017 ~ present NAVER Corp.
21307 * billboard.js project is licensed under the MIT license
21308 */
21309
21310
21311
21312/**
21313 * Module used for data.selection.draggable option
21314 */
21315
21316/* harmony default export */ var drag = ({
21317 /**
21318 * Called when dragging.
21319 * Data points can be selected.
21320 * @private
21321 * @param {object} mouse Object
21322 */
21323 drag: function drag(mouse) {
21324 var $$ = this,
21325 config = $$.config,
21326 state = $$.state,
21327 main = $$.$el.main,
21328 isSelectionGrouped = config.data_selection_grouped,
21329 isSelectable = config.interaction_enabled && config.data_selection_isselectable;
21330
21331 if ($$.hasArcType() || !config.data_selection_enabled || // do nothing if not selectable
21332 config.zoom_enabled && !$$.zoom.altDomain || // skip if zoomable because of conflict drag behavior
21333 !config.data_selection_multiple // skip when single selection because drag is used for multiple selection
21334 ) {
21335 return;
21336 }
21337
21338 var _ref = state.dragStart || [0, 0],
21339 sx = _ref[0],
21340 sy = _ref[1],
21341 mx = mouse[0],
21342 my = mouse[1],
21343 minX = Math.min(sx, mx),
21344 maxX = Math.max(sx, mx),
21345 minY = isSelectionGrouped ? state.margin.top : Math.min(sy, my),
21346 maxY = isSelectionGrouped ? state.height : Math.max(sy, my);
21347
21348 main.select("." + config_classes.dragarea).attr("x", minX).attr("y", minY).attr("width", maxX - minX).attr("height", maxY - minY); // TODO: binary search when multiple xs
21349
21350 main.selectAll("." + config_classes.shapes).selectAll("." + config_classes.shape).filter(function (d) {
21351 var _isSelectable;
21352
21353 return (_isSelectable = isSelectable) == null ? void 0 : _isSelectable.bind($$.api)(d);
21354 }).each(function (d, i) {
21355 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
21356 isSelected = shape.classed(config_classes.SELECTED),
21357 isIncluded = shape.classed(config_classes.INCLUDED),
21358 isWithin = !1,
21359 toggle;
21360
21361 if (shape.classed(config_classes.circle)) {
21362 var x = +shape.attr("cx") * 1,
21363 y = +shape.attr("cy") * 1;
21364 toggle = $$.togglePoint;
21365 isWithin = minX < x && x < maxX && minY < y && y < maxY;
21366 } else if (shape.classed(config_classes.bar)) {
21367 var _getPathBox = getPathBox(this),
21368 _x = _getPathBox.x,
21369 y = _getPathBox.y,
21370 width = _getPathBox.width,
21371 height = _getPathBox.height;
21372
21373 toggle = $$.togglePath;
21374 isWithin = !(maxX < _x || _x + width < minX) && !(maxY < y || y + height < minY);
21375 } else {
21376 // line/area selection not supported yet
21377 return;
21378 } // @ts-ignore
21379
21380
21381 if (isWithin ^ isIncluded) {
21382 shape.classed(config_classes.INCLUDED, !isIncluded); // TODO: included/unincluded callback here
21383
21384 shape.classed(config_classes.SELECTED, !isSelected);
21385 toggle.call($$, !isSelected, shape, d, i);
21386 }
21387 });
21388 },
21389
21390 /**
21391 * Called when the drag starts.
21392 * Adds and Shows the drag area.
21393 * @private
21394 * @param {object} mouse Object
21395 */
21396 dragstart: function dragstart(mouse) {
21397 var $$ = this,
21398 config = $$.config,
21399 state = $$.state,
21400 main = $$.$el.main;
21401
21402 if ($$.hasArcType() || !config.data_selection_enabled) {
21403 return;
21404 }
21405
21406 state.dragStart = mouse;
21407 main.select("." + config_classes.chart).append("rect").attr("class", config_classes.dragarea).style("opacity", "0.1");
21408 $$.setDragStatus(!0);
21409 },
21410
21411 /**
21412 * Called when the drag finishes.
21413 * Removes the drag area.
21414 * @private
21415 */
21416 dragend: function dragend() {
21417 var $$ = this,
21418 config = $$.config,
21419 main = $$.$el.main,
21420 $T = $$.$T;
21421
21422 if ($$.hasArcType() || !config.data_selection_enabled) {
21423 // do nothing if not selectable
21424 return;
21425 }
21426
21427 $T(main.select("." + config_classes.dragarea)).style("opacity", "0").remove();
21428 main.selectAll("." + config_classes.shape).classed(config_classes.INCLUDED, !1);
21429 $$.setDragStatus(!1);
21430 }
21431});
21432;// CONCATENATED MODULE: ./src/ChartInternal/internals/selection.ts
21433
21434
21435function selection_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
21436
21437function selection_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { selection_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { selection_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21438
21439/**
21440 * Copyright (c) 2017 ~ present NAVER Corp.
21441 * billboard.js project is licensed under the MIT license
21442 */
21443
21444
21445
21446
21447/* harmony default export */ var internals_selection = (selection_objectSpread(selection_objectSpread({}, drag), {}, {
21448 /**
21449 * Select a point
21450 * @param {object} target Target point
21451 * @param {object} d Data object
21452 * @param {number} i Index number
21453 * @private
21454 */
21455 selectPoint: function selectPoint(target, d, i) {
21456 var $$ = this,
21457 config = $$.config,
21458 main = $$.$el.main,
21459 $T = $$.$T,
21460 isRotated = config.axis_rotated,
21461 cx = (isRotated ? $$.circleY : $$.circleX).bind($$),
21462 cy = (isRotated ? $$.circleX : $$.circleY).bind($$),
21463 r = $$.pointSelectR.bind($$);
21464 callFn(config.data_onselected, $$.api, d, target.node()); // add selected-circle on low layer g
21465
21466 $T(main.select("." + config_classes.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll("." + config_classes.selectedCircle + "-" + i).data([d]).enter().append("circle").attr("class", function () {
21467 return $$.generateClass(config_classes.selectedCircle, i);
21468 }).attr("cx", cx).attr("cy", cy).attr("stroke", $$.color).attr("r", function (d2) {
21469 return $$.pointSelectR(d2) * 1.4;
21470 })).attr("r", r);
21471 },
21472
21473 /**
21474 * Unelect a point
21475 * @param {object} target Target point
21476 * @param {object} d Data object
21477 * @param {number} i Index number
21478 * @private
21479 */
21480 unselectPoint: function unselectPoint(target, d, i) {
21481 var $$ = this,
21482 config = $$.config,
21483 main = $$.$el.main,
21484 $T = $$.$T;
21485 callFn(config.data_onunselected, $$.api, d, target.node()); // remove selected-circle from low layer g
21486
21487 $T(main.select("." + config_classes.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll("." + config_classes.selectedCircle + "-" + i)).attr("r", 0).remove();
21488 },
21489
21490 /**
21491 * Toggles the selection of points
21492 * @param {boolean} selected whether or not to select.
21493 * @param {object} target Target object
21494 * @param {object} d Data object
21495 * @param {number} i Index number
21496 * @private
21497 */
21498 togglePoint: function togglePoint(selected, target, d, i) {
21499 var method = (selected ? "" : "un") + "selectPoint";
21500 this[method](target, d, i);
21501 },
21502
21503 /**
21504 * Select a path
21505 * @param {object} target Target path
21506 * @param {object} d Data object
21507 * @private
21508 */
21509 selectPath: function selectPath(target, d) {
21510 var $$ = this,
21511 config = $$.config;
21512 callFn(config.data_onselected, $$.api, d, target.node());
21513
21514 if (config.interaction_brighten) {
21515 target.style("filter", "brightness(1.25)");
21516 }
21517 },
21518
21519 /**
21520 * Unelect a path
21521 * @private
21522 * @param {object} target Target path
21523 * @param {object} d Data object
21524 */
21525 unselectPath: function unselectPath(target, d) {
21526 var $$ = this,
21527 config = $$.config;
21528 callFn(config.data_onunselected, $$.api, d, target.node());
21529
21530 if (config.interaction_brighten) {
21531 target.style("filter", null);
21532 }
21533 },
21534
21535 /**
21536 * Toggles the selection of lines
21537 * @param {boolean} selected whether or not to select.
21538 * @param {object} target Target object
21539 * @param {object} d Data object
21540 * @param {number} i Index number
21541 * @private
21542 */
21543 togglePath: function togglePath(selected, target, d, i) {
21544 this[(selected ? "" : "un") + "selectPath"](target, d, i);
21545 },
21546
21547 /**
21548 * Returns the toggle method of the target
21549 * @param {object} that shape
21550 * @param {object} d Data object
21551 * @returns {Function} toggle method
21552 * @private
21553 */
21554 getToggle: function getToggle(that, d) {
21555 var $$ = this;
21556 return that.nodeName === "path" ? $$.togglePath : $$.isStepType(d) ? function () {} : // circle is hidden in step chart, so treat as within the click area
21557 $$.togglePoint;
21558 },
21559
21560 /**
21561 * Toggles the selection of shapes
21562 * @param {object} that shape
21563 * @param {object} d Data object
21564 * @param {number} i Index number
21565 * @private
21566 */
21567 toggleShape: function toggleShape(that, d, i) {
21568 var $$ = this,
21569 config = $$.config,
21570 main = $$.$el.main,
21571 shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that),
21572 isSelected = shape.classed(config_classes.SELECTED),
21573 toggle = $$.getToggle(that, d).bind($$),
21574 toggledShape;
21575
21576 if (config.data_selection_enabled && config.data_selection_isselectable.bind($$.api)(d)) {
21577 if (!config.data_selection_multiple) {
21578 var selector = "." + config_classes.shapes;
21579
21580 if (config.data_selection_grouped) {
21581 selector += $$.getTargetSelectorSuffix(d.id);
21582 }
21583
21584 main.selectAll(selector).selectAll("." + config_classes.shape).each(function (d, i) {
21585 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
21586
21587 if (shape.classed(config_classes.SELECTED)) {
21588 toggledShape = shape;
21589 toggle(!1, shape.classed(config_classes.SELECTED, !1), d, i);
21590 }
21591 });
21592 }
21593
21594 if (!toggledShape || toggledShape.node() !== shape.node()) {
21595 shape.classed(config_classes.SELECTED, !isSelected);
21596 toggle(!isSelected, shape, d, i);
21597 }
21598 }
21599 }
21600}));
21601;// CONCATENATED MODULE: ./src/ChartInternal/interactions/subchart.ts
21602/**
21603 * Copyright (c) 2017 ~ present NAVER Corp.
21604 * billboard.js project is licensed under the MIT license
21605 */
21606
21607
21608
21609
21610/* harmony default export */ var interactions_subchart = ({
21611 /**
21612 * Initialize the brush.
21613 * @private
21614 */
21615 initBrush: function initBrush() {
21616 var $$ = this,
21617 config = $$.config,
21618 scale = $$.scale,
21619 subchart = $$.$el.subchart,
21620 isRotated = config.axis_rotated,
21621 lastDomain,
21622 timeout;
21623 // set the brush
21624 $$.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);
21625
21626 var getBrushSize = function () {
21627 var brush = $$.$el.svg.select("." + config_classes.brush + " .overlay"),
21628 brushSize = {
21629 width: 0,
21630 height: 0
21631 };
21632
21633 if (brush.size()) {
21634 brushSize.width = +brush.attr("width");
21635 brushSize.height = +brush.attr("height");
21636 }
21637
21638 return brushSize[isRotated ? "width" : "height"];
21639 }; // bind brush event
21640
21641
21642 $$.brush.on("start brush end", function (event) {
21643 var selection = event.selection,
21644 target = event.target,
21645 type = event.type;
21646
21647 if (type === "start") {
21648 $$.state.inputType === "touch" && $$.hideTooltip();
21649 }
21650
21651 if (/(start|brush)/.test(type)) {
21652 $$.redrawForBrush();
21653 }
21654
21655 if (type === "end") {
21656 lastDomain = scale.x.orgDomain();
21657 } // handle brush's handle position & visibility
21658
21659
21660 if (target != null && target.handle) {
21661 if (selection === null) {
21662 $$.brush.handle.attr("display", "none");
21663 } else {
21664 $$.brush.handle.attr("display", null).attr("transform", function (d, i) {
21665 var pos = isRotated ? [33, selection[i] - (i === 0 ? 30 : 24)] : [selection[i], 3];
21666 return "translate(" + pos + ")";
21667 });
21668 }
21669 }
21670 });
21671
21672 $$.brush.updateResize = function () {
21673 var _this = this;
21674
21675 timeout && clearTimeout(timeout);
21676 timeout = setTimeout(function () {
21677 var selection = _this.getSelection();
21678
21679 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()));
21680 }, 0);
21681 };
21682
21683 $$.brush.update = function () {
21684 var extent = this.extent()();
21685
21686 if (extent[1].filter(function (v) {
21687 return isNaN(v);
21688 }).length === 0) {
21689 var _subchart$main;
21690
21691 (_subchart$main = subchart.main) == null ? void 0 : _subchart$main.select("." + config_classes.brush).call(this);
21692 }
21693
21694 return this;
21695 }; // set the brush extent
21696
21697
21698 $$.brush.scale = function (scale) {
21699 var h = config.subchart_size_height || getBrushSize(),
21700 extent = $$.getExtent();
21701
21702 if (!extent && scale.range) {
21703 extent = [[0, 0], [scale.range()[1], h]];
21704 } else if (isArray(extent)) {
21705 extent = extent.map(function (v, i) {
21706 return [v, i > 0 ? h : i];
21707 });
21708 } // [[x0, y0], [x1, y1]], where [x0, y0] is the top-left corner and [x1, y1] is the bottom-right corner
21709
21710
21711 isRotated && extent[1].reverse();
21712 this.extent(extent); // when extent updates, brush selection also be re-applied
21713 // https://github.com/d3/d3/issues/2918
21714
21715 this.update();
21716 };
21717
21718 $$.brush.getSelection = function () {
21719 return (// @ts-ignore
21720 subchart.main ? subchart.main.select("." + config_classes.brush) : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)([])
21721 );
21722 };
21723 },
21724
21725 /**
21726 * Initialize the subchart.
21727 * @private
21728 */
21729 initSubchart: function initSubchart() {
21730 var $$ = this,
21731 config = $$.config,
21732 _$$$state = $$.state,
21733 clip = _$$$state.clip,
21734 hasAxis = _$$$state.hasAxis,
21735 _$$$$el = $$.$el,
21736 defs = _$$$$el.defs,
21737 svg = _$$$$el.svg,
21738 subchart = _$$$$el.subchart,
21739 axis = _$$$$el.axis;
21740
21741 if (!hasAxis) {
21742 return;
21743 }
21744
21745 var visibility = config.subchart_show ? null : "hidden",
21746 clipId = clip.id + "-subchart",
21747 clipPath = $$.getClipPath(clipId);
21748 clip.idSubchart = clipId;
21749 $$.appendClip(defs, clipId);
21750 $$.initBrush();
21751 subchart.main = svg.append("g").classed(config_classes.subchart, !0).attr("transform", $$.getTranslate("context"));
21752 var main = subchart.main;
21753 main.style("visibility", visibility); // Define g for chart area
21754
21755 main.append("g").attr("clip-path", clipPath).attr("class", config_classes.chart); // Define g for chart types area
21756
21757 ["bar", "line", "bubble", "candlestick", "scatter"].forEach(function (v) {
21758 var type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
21759
21760 if ($$.hasType(v) || $$.hasTypeOf(type)) {
21761 var chart = main.select("." + config_classes.chart),
21762 chartClassName = config_classes["chart" + type + "s"];
21763
21764 if (chart.select("." + chartClassName).empty()) {
21765 chart.append("g").attr("class", chartClassName);
21766 }
21767 }
21768 }); // Add extent rect for Brush
21769
21770 var brush = main.append("g").attr("clip-path", clipPath).attr("class", config_classes.brush).call($$.brush);
21771 config.subchart_showHandle && $$.addBrushHandle(brush); // ATTENTION: This must be called AFTER chart added
21772 // Add Axis
21773
21774 axis.subX = main.append("g").attr("class", config_classes.axisX).attr("transform", $$.getTranslate("subX")).attr("clip-path", config.axis_rotated ? "" : clip.pathXAxis).style("visibility", config.subchart_axis_x_show ? visibility : "hidden");
21775 },
21776
21777 /**
21778 * Add brush handle
21779 * Enabled when: subchart.showHandle=true
21780 * @param {d3Selection} brush Brush selection
21781 * @private
21782 */
21783 addBrushHandle: function addBrushHandle(brush) {
21784 var $$ = this,
21785 config = $$.config,
21786 isRotated = config.axis_rotated,
21787 initRange = config.subchart_init_range,
21788 customHandleClass = "handle--custom",
21789 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"];
21790 $$.brush.handle = brush.selectAll("." + customHandleClass).data(isRotated ? [{
21791 type: "n"
21792 }, {
21793 type: "s"
21794 }] : [{
21795 type: "w"
21796 }, {
21797 type: "e"
21798 }]).enter().append("path").attr("class", customHandleClass).attr("cursor", (isRotated ? "ns" : "ew") + "-resize").attr("d", function (d) {
21799 return path[+/[se]/.test(d.type)];
21800 }).attr("display", initRange ? null : "none");
21801 },
21802
21803 /**
21804 * Update sub chart
21805 * @param {object} targets $$.data.targets
21806 * @private
21807 */
21808 updateTargetsForSubchart: function updateTargetsForSubchart(targets) {
21809 var $$ = this,
21810 config = $$.config,
21811 state = $$.state,
21812 main = $$.$el.subchart.main;
21813
21814 if (config.subchart_show) {
21815 ["bar", "line", "bubble", "candlestick", "scatter"].filter(function (v) {
21816 return $$.hasType(v) || $$.hasTypeOf(capitalize(v));
21817 }).forEach(function (v) {
21818 var isPointType = /^(bubble|scatter)$/.test(v),
21819 name = capitalize(isPointType ? "circle" : v),
21820 chartClass = $$.getChartClass(name, !0),
21821 shapeClass = $$.getClass(isPointType ? "circles" : v + "s", !0),
21822 shapeChart = main.select("." + config_classes["chart" + (name + "s")]);
21823
21824 if (isPointType) {
21825 var circle = shapeChart.selectAll("." + config_classes.circles).data(targets.filter($$["is" + capitalize(v) + "Type"].bind($$))).attr("class", shapeClass);
21826 circle.exit().remove();
21827 circle.enter().append("g").attr("class", shapeClass);
21828 } else {
21829 var shapeUpdate = shapeChart.selectAll("." + config_classes["chart" + name]).attr("class", chartClass).data(targets.filter($$["is" + name + "Type"].bind($$))),
21830 shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
21831 shapeUpdate.exit().remove(); // Area
21832
21833 v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", !0));
21834 }
21835 }); // -- Brush --//
21836
21837 main.selectAll("." + config_classes.brush + " rect").attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? state.width2 : state.height2);
21838 }
21839 },
21840
21841 /**
21842 * Redraw subchart.
21843 * @private
21844 * @param {boolean} withSubchart whether or not to show subchart
21845 * @param {number} duration duration
21846 * @param {object} shape Shape's info
21847 */
21848 redrawSubchart: function redrawSubchart(withSubchart, duration, shape) {
21849 var $$ = this,
21850 config = $$.config,
21851 main = $$.$el.subchart.main,
21852 state = $$.state,
21853 withTransition = !!duration;
21854 main.style("visibility", config.subchart_show ? null : "hidden"); // subchart
21855
21856 if (config.subchart_show) {
21857 var _state$event;
21858
21859 // reflect main chart to extent on subchart if zoomed
21860 if (((_state$event = state.event) == null ? void 0 : _state$event.type) === "zoom") {
21861 $$.brush.update();
21862 } // update subchart elements if needed
21863
21864
21865 if (withSubchart) {
21866 var initRange = config.subchart_init_range; // extent rect
21867
21868 brushEmpty($$) || $$.brush.update();
21869 Object.keys(shape.type).forEach(function (v) {
21870 var name = capitalize(v),
21871 drawFn = $$["generateDraw" + name](shape.indices[v], !0);
21872 // call shape's update & redraw method
21873 $$["update" + name](withTransition, !0);
21874 $$["redraw" + name](drawFn, withTransition, !0);
21875 });
21876
21877 if ($$.hasType("bubble") || $$.hasType("scatter")) {
21878 var cx = shape.pos.cx,
21879 cy = $$.updateCircleY(!0);
21880 $$.updateCircle(!0);
21881 $$.redrawCircle(cx, cy, withTransition, undefined, !0);
21882 }
21883
21884 !state.rendered && initRange && $$.brush.move($$.brush.getSelection(), initRange.map($$.scale.x));
21885 }
21886 }
21887 },
21888
21889 /**
21890 * Redraw the brush.
21891 * @private
21892 */
21893 redrawForBrush: function redrawForBrush() {
21894 var $$ = this,
21895 _$$$config = $$.config,
21896 onBrush = _$$$config.subchart_onbrush,
21897 withY = _$$$config.zoom_rescale,
21898 scale = $$.scale;
21899 $$.redraw({
21900 withTransition: !1,
21901 withY: withY,
21902 withSubchart: !1,
21903 withUpdateXDomain: !0,
21904 withDimension: !1
21905 });
21906 onBrush.bind($$.api)(scale.x.orgDomain());
21907 },
21908
21909 /**
21910 * Transform context
21911 * @param {boolean} withTransition indicates transition is enabled
21912 * @param {object} transitions The return value of the generateTransitions method of Axis.
21913 * @private
21914 */
21915 transformContext: function transformContext(withTransition, transitions) {
21916 var $$ = this,
21917 subchart = $$.$el.subchart,
21918 $T = $$.$T,
21919 subXAxis = transitions != null && transitions.axisSubX ? transitions.axisSubX : $T(subchart.main.select("." + config_classes.axisX), withTransition);
21920 subchart.main.attr("transform", $$.getTranslate("context"));
21921 subXAxis.attr("transform", $$.getTranslate("subX"));
21922 },
21923
21924 /**
21925 * Get extent value
21926 * @returns {Array} default extent
21927 * @private
21928 */
21929 getExtent: function getExtent() {
21930 var $$ = this,
21931 config = $$.config,
21932 scale = $$.scale,
21933 extent = config.axis_x_extent;
21934
21935 if (extent) {
21936 if (isFunction(extent)) {
21937 extent = extent.bind($$.api)($$.getXDomain($$.data.targets), scale.subX);
21938 } else if ($$.axis.isTimeSeries() && extent.every(isNaN)) {
21939 var fn = parseDate.bind($$);
21940 extent = extent.map(function (v) {
21941 return scale.subX(fn(v));
21942 });
21943 }
21944 }
21945
21946 return extent;
21947 }
21948});
21949;// CONCATENATED MODULE: ./src/ChartInternal/interactions/zoom.ts
21950/**
21951 * Copyright (c) 2017 ~ present NAVER Corp.
21952 * billboard.js project is licensed under the MIT license
21953 */
21954
21955
21956
21957
21958/* harmony default export */ var interactions_zoom = ({
21959 /**
21960 * Initialize zoom.
21961 * @private
21962 */
21963 initZoom: function initZoom() {
21964 var $$ = this;
21965 $$.scale.zoom = null;
21966 $$.generateZoom();
21967 $$.initZoomBehaviour();
21968 },
21969
21970 /**
21971 * Bind zoom event
21972 * @param {boolean} bind Weather bind or unbound
21973 * @private
21974 */
21975 bindZoomEvent: function bindZoomEvent(bind) {
21976 if (bind === void 0) {
21977 bind = !0;
21978 }
21979
21980 var $$ = this,
21981 config = $$.config,
21982 zoomEnabled = config.zoom_enabled;
21983
21984 if (zoomEnabled && bind) {
21985 // Do not bind zoom event when subchart is shown
21986 config.subchart_show || $$.bindZoomOnEventRect();
21987 } else if (bind === !1) {
21988 $$.api.unzoom();
21989 $$.unbindZoomEvent();
21990 }
21991 },
21992
21993 /**
21994 * Generate zoom
21995 * @private
21996 */
21997 generateZoom: function generateZoom() {
21998 var $$ = this,
21999 config = $$.config,
22000 org = $$.org,
22001 scale = $$.scale,
22002 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($$));
22003
22004 // get zoom extent
22005 // @ts-ignore
22006 zoom.orgScaleExtent = function () {
22007 var extent = config.zoom_extent || [1, 10];
22008 return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])];
22009 }; // @ts-ignore
22010
22011
22012 zoom.updateScaleExtent = function () {
22013 var ratio = diffDomain($$.scale.x.orgDomain()) / diffDomain($$.getZoomDomain()),
22014 extent = this.orgScaleExtent();
22015 this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
22016 return this;
22017 };
22018 /**
22019 * Update scale according zoom transform value
22020 * @param {object} transform transform object
22021 * @private
22022 */
22023 // @ts-ignore
22024
22025
22026 zoom.updateTransformScale = function (transform) {
22027 var _org$xScale;
22028
22029 // in case of resize, update range of orgXScale
22030 (_org$xScale = org.xScale) == null ? void 0 : _org$xScale.range(scale.x.range()); // rescale from the original scale
22031
22032 var newScale = transform[config.axis_rotated ? "rescaleY" : "rescaleX"](org.xScale || scale.x),
22033 domain = $$.trimXDomain(newScale.domain()),
22034 rescale = config.zoom_rescale;
22035 newScale.domain(domain, org.xDomain);
22036
22037 if (!$$.state.xTickOffset) {
22038 $$.state.xTickOffset = $$.axis.x.tickOffset();
22039 }
22040
22041 scale.zoom = $$.getCustomizedScale(newScale);
22042 $$.axis.x.scale(scale.zoom);
22043
22044 if (rescale) {
22045 // copy current initial x scale in case of rescale option is used
22046 org.xScale || (org.xScale = scale.x.copy());
22047 scale.x.domain(domain);
22048 }
22049 };
22050 /**
22051 * Get zoom domain
22052 * @returns {Array} zoom domain
22053 * @private
22054 */
22055 // @ts-ignore
22056
22057
22058 zoom.getDomain = function () {
22059 var domain = scale[scale.zoom ? "zoom" : "subX"].domain(),
22060 isCategorized = $$.axis.isCategorized();
22061
22062 if (isCategorized) {
22063 domain[1] -= 2;
22064 }
22065
22066 return domain;
22067 };
22068
22069 $$.zoom = zoom;
22070 },
22071
22072 /**
22073 * 'start' event listener
22074 * @param {object} event Event object
22075 * @private
22076 */
22077 onZoomStart: function onZoomStart(event) {
22078 var $$ = this,
22079 sourceEvent = event.sourceEvent;
22080
22081 if (sourceEvent) {
22082 $$.zoom.startEvent = sourceEvent;
22083 $$.state.zooming = !0;
22084 callFn($$.config.zoom_onzoomstart, $$.api, event);
22085 }
22086 },
22087
22088 /**
22089 * 'zoom' event listener
22090 * @param {object} event Event object
22091 * @private
22092 */
22093 onZoom: function onZoom(event) {
22094 var _sourceEvent,
22095 _sourceEvent2,
22096 _sourceEvent3,
22097 _sourceEvent4,
22098 $$ = this,
22099 config = $$.config,
22100 scale = $$.scale,
22101 state = $$.state,
22102 org = $$.org,
22103 sourceEvent = event.sourceEvent,
22104 isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
22105
22106 if (!config.zoom_enabled || $$.filterTargetsToShow($$.data.targets).length === 0 || !scale.zoom && ((_sourceEvent = sourceEvent) == null ? void 0 : _sourceEvent.type.indexOf("touch")) > -1 && ((_sourceEvent2 = sourceEvent) == null ? void 0 : _sourceEvent2.touches.length) === 1) {
22107 return;
22108 }
22109
22110 if (event.sourceEvent) {
22111 state.zooming = !0;
22112 }
22113
22114 var isMousemove = ((_sourceEvent3 = sourceEvent) == null ? void 0 : _sourceEvent3.type) === "mousemove",
22115 isZoomOut = ((_sourceEvent4 = sourceEvent) == null ? void 0 : _sourceEvent4.wheelDelta) < 0,
22116 transform = event.transform;
22117
22118 if (!isMousemove && isZoomOut && scale.x.domain().every(function (v, i) {
22119 return v !== org.xDomain[i];
22120 })) {
22121 scale.x.domain(org.xDomain);
22122 }
22123
22124 $$.zoom.updateTransformScale(transform); // do zoom transiton when:
22125 // - zoom type 'drag'
22126 // - when .unzoom() is called (event.transform === d3ZoomIdentity)
22127
22128 var doTransition = config.transition_duration > 0 && !config.subchart_show && (state.dragging || isUnZoom || !event.sourceEvent);
22129 $$.redraw({
22130 withTransition: doTransition,
22131 withY: config.zoom_rescale,
22132 withSubchart: !1,
22133 withEventRect: !1,
22134 withDimension: !1
22135 });
22136 $$.state.cancelClick = isMousemove; // do not call event cb when is .unzoom() is called
22137
22138 isUnZoom || callFn(config.zoom_onzoom, $$.api, $$.zoom.getDomain());
22139 },
22140
22141 /**
22142 * 'end' event listener
22143 * @param {object} event Event object
22144 * @private
22145 */
22146 onZoomEnd: function onZoomEnd(event) {
22147 var _startEvent,
22148 $$ = this,
22149 config = $$.config,
22150 state = $$.state,
22151 startEvent = $$.zoom.startEvent,
22152 e = event == null ? void 0 : event.sourceEvent,
22153 isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
22154
22155 if (((_startEvent = startEvent) == null ? void 0 : _startEvent.type.indexOf("touch")) > -1) {
22156 var _e, _e$changedTouches;
22157
22158 startEvent = startEvent.changedTouches[0];
22159 e = (_e = e) == null ? void 0 : (_e$changedTouches = _e.changedTouches) == null ? void 0 : _e$changedTouches[0];
22160 } // if click, do nothing. otherwise, click interaction will be canceled.
22161
22162
22163 if (config.zoom_type === "drag" && e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY) {
22164 return;
22165 }
22166
22167 $$.redrawEventRect();
22168 $$.updateZoom();
22169 state.zooming = !1; // do not call event cb when is .unzoom() is called
22170
22171 !isUnZoom && (e || state.dragging) && callFn(config.zoom_onzoomend, $$.api, $$.zoom.getDomain());
22172 },
22173
22174 /**
22175 * Update zoom
22176 * @param {boolean} force Force unzoom
22177 * @private
22178 */
22179 updateZoom: function updateZoom(force) {
22180 var $$ = this,
22181 _$$$scale = $$.scale,
22182 subX = _$$$scale.subX,
22183 x = _$$$scale.x,
22184 zoom = _$$$scale.zoom;
22185
22186 if (zoom) {
22187 var zoomDomain = zoom.domain(),
22188 xDomain = subX.domain(),
22189 delta = .015,
22190 isfullyShown = (zoomDomain[0] <= xDomain[0] || zoomDomain[0] - delta <= xDomain[0]) && (xDomain[1] <= zoomDomain[1] || xDomain[1] <= zoomDomain[1] - delta);
22191
22192 // check if the zoomed chart is fully shown, then reset scale when zoom is out as initial
22193 if (force || isfullyShown) {
22194 $$.axis.x.scale(subX);
22195 x.domain(subX.orgDomain());
22196 $$.scale.zoom = null;
22197 }
22198 }
22199 },
22200
22201 /**
22202 * Attach zoom event on <rect>
22203 * @private
22204 */
22205 bindZoomOnEventRect: function bindZoomOnEventRect() {
22206 var $$ = this,
22207 config = $$.config,
22208 eventRect = $$.$el.eventRect,
22209 behaviour = config.zoom_type === "drag" ? $$.zoomBehaviour : $$.zoom;
22210 // Since Chrome 89, wheel zoom not works properly
22211 // Applying the workaround: https://github.com/d3/d3-zoom/issues/231#issuecomment-802305692
22212 $$.$el.svg.on("wheel", function () {});
22213 eventRect.call(behaviour).on("dblclick.zoom", null);
22214 },
22215
22216 /**
22217 * Initialize the drag behaviour used for zooming.
22218 * @private
22219 */
22220 initZoomBehaviour: function initZoomBehaviour() {
22221 var $$ = this,
22222 config = $$.config,
22223 state = $$.state,
22224 isRotated = config.axis_rotated,
22225 start = 0,
22226 end = 0,
22227 zoomRect,
22228 prop = {
22229 axis: isRotated ? "y" : "x",
22230 attr: isRotated ? "height" : "width",
22231 index: isRotated ? 1 : 0
22232 };
22233 $$.zoomBehaviour = (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().clickDistance(4).on("start", function (event) {
22234 state.event = event;
22235 $$.setDragStatus(!0);
22236 $$.unselectRect();
22237
22238 if (!zoomRect) {
22239 zoomRect = $$.$el.main.append("rect").attr("clip-path", state.clip.path).attr("class", config_classes.zoomBrush).attr("width", isRotated ? state.width : 0).attr("height", isRotated ? 0 : state.height);
22240 }
22241
22242 start = getPointer(event, this)[prop.index];
22243 end = start;
22244 zoomRect.attr(prop.axis, start).attr(prop.attr, 0);
22245 $$.onZoomStart(event);
22246 }).on("drag", function (event) {
22247 end = getPointer(event, this)[prop.index];
22248 zoomRect.attr(prop.axis, Math.min(start, end)).attr(prop.attr, Math.abs(end - start));
22249 }).on("end", function (event) {
22250 var scale = $$.scale.zoom || $$.scale.x;
22251 state.event = event;
22252 zoomRect.attr(prop.axis, 0).attr(prop.attr, 0);
22253
22254 if (start > end) {
22255 var _ref = [end, start];
22256 start = _ref[0];
22257 end = _ref[1];
22258 }
22259
22260 if (start < 0) {
22261 end += Math.abs(start);
22262 start = 0;
22263 }
22264
22265 if (start !== end) {
22266 $$.api.zoom([start, end].map(function (v) {
22267 return scale.invert(v);
22268 }));
22269 }
22270
22271 $$.setDragStatus(!1);
22272 });
22273 },
22274 setZoomResetButton: function setZoomResetButton() {
22275 var $$ = this,
22276 config = $$.config,
22277 $el = $$.$el,
22278 resetButton = config.zoom_resetButton;
22279
22280 if (resetButton && config.zoom_type === "drag") {
22281 if (!$el.zoomResetBtn) {
22282 $el.zoomResetBtn = $$.$el.chart.append("div").classed(config_classes.button, !0).append("span").on("click", function () {
22283 isFunction(resetButton.onclick) && resetButton.onclick.bind($$.api)(this);
22284 $$.api.unzoom();
22285 }).classed(config_classes.buttonZoomReset, !0).text(resetButton.text || "Reset Zoom");
22286 } else {
22287 $el.zoomResetBtn.style("display", null);
22288 }
22289 }
22290 }
22291});
22292;// CONCATENATED MODULE: ./src/config/Options/data/selection.ts
22293/**
22294 * Copyright (c) 2017 ~ present NAVER Corp.
22295 * billboard.js project is licensed under the MIT license
22296 */
22297
22298/**
22299 * data.selection config options
22300 */
22301/* harmony default export */ var data_selection = ({
22302 /**
22303 * Set data selection enabled<br><br>
22304 * 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).
22305 * - **NOTE:** for ESM imports, needs to import 'selection' exports and instantiate it by calling `selection()`.
22306 * - `enabled: selection()`
22307 * @name data․selection․enabled
22308 * @memberof Options
22309 * @type {boolean}
22310 * @default false
22311 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataSelection)
22312 * @example
22313 * data: {
22314 * selection: {
22315 * enabled: true
22316 * }
22317 * }
22318 * @example
22319 * // importing ESM
22320 * import bb, {selection} from "billboard.js";
22321 *
22322 * data: {
22323 * selection: {
22324 * enabled: selection(),
22325 * ...
22326 * }
22327 * }
22328 */
22329 data_selection_enabled: !1,
22330
22331 /**
22332 * Set grouped selection enabled.<br><br>
22333 * If this option set true, multiple data points that have same x value will be selected by one selection.
22334 * @name data․selection․grouped
22335 * @memberof Options
22336 * @type {boolean}
22337 * @default false
22338 * @example
22339 * data: {
22340 * selection: {
22341 * grouped: true
22342 * }
22343 * }
22344 */
22345 data_selection_grouped: !1,
22346
22347 /**
22348 * Set a callback for each data point to determine if it's selectable or not.<br><br>
22349 * The callback will receive d as an argument and it has some parameters like id, value, index. This callback should return boolean.
22350 * @name data․selection․isselectable
22351 * @memberof Options
22352 * @type {Function}
22353 * @default function() { return true; }
22354 * @example
22355 * data: {
22356 * selection: {
22357 * isselectable: function(d) { ... }
22358 * }
22359 * }
22360 */
22361 data_selection_isselectable: function data_selection_isselectable() {
22362 return !0;
22363 },
22364
22365 /**
22366 * Set multiple data points selection enabled.<br><br>
22367 * 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.
22368 * @name data․selection․multiple
22369 * @memberof Options
22370 * @type {boolean}
22371 * @default true
22372 * @example
22373 * data: {
22374 * selection: {
22375 * multiple: false
22376 * }
22377 * }
22378 */
22379 data_selection_multiple: !0,
22380
22381 /**
22382 * Enable to select data points by dragging.
22383 * If this option set true, data points can be selected by dragging.
22384 * - **NOTE:** If this option set true, scrolling on the chart will be disabled because dragging event will handle the event.
22385 * @name data․selection․draggable
22386 * @memberof Options
22387 * @type {boolean}
22388 * @default false
22389 * @example
22390 * data: {
22391 * selection: {
22392 * draggable: true
22393 * }
22394 * }
22395 */
22396 data_selection_draggable: !1,
22397
22398 /**
22399 * Set a callback for on data selection.
22400 * @name data․onselected
22401 * @memberof Options
22402 * @type {Function}
22403 * @default function() {}
22404 * @example
22405 * data: {
22406 * onselected: function(d, element) {
22407 * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
22408 * // element - <circle>
22409 * ...
22410 * }
22411 * }
22412 */
22413 data_onselected: function data_onselected() {},
22414
22415 /**
22416 * Set a callback for on data un-selection.
22417 * @name data․onunselected
22418 * @memberof Options
22419 * @type {Function}
22420 * @default function() {}
22421 * @example
22422 * data: {
22423 * onunselected: function(d, element) {
22424 * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
22425 * // element - <circle>
22426 * ...
22427 * }
22428 * }
22429 */
22430 data_onunselected: function data_onunselected() {}
22431});
22432;// CONCATENATED MODULE: ./src/config/Options/interaction/subchart.ts
22433/**
22434 * Copyright (c) 2017 ~ present NAVER Corp.
22435 * billboard.js project is licensed under the MIT license
22436 */
22437
22438/**
22439 * x Axis config options
22440 */
22441/* harmony default export */ var interaction_subchart = ({
22442 /**
22443 * Set subchart options.
22444 * - **NOTE:** Not supported for `bubble`, `scatter` and non-Axis based(pie, donut, gauge, radar) types.
22445 * @name subchart
22446 * @memberof Options
22447 * @type {object}
22448 * @property {object} subchart Subchart object
22449 * @property {boolean} [subchart.show=false] Show sub chart on the bottom of the chart.
22450 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
22451 * - `show: subchart()`
22452 * @property {boolean} [subchart.showHandle=false] Show sub chart's handle.
22453 * @property {boolean} [subchart.axis.x.show=true] Show or hide x axis.
22454 * @property {boolean} [subchart.axis.x.tick.show=true] Show or hide x axis tick line.
22455 * @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.
22456 * @property {boolean} [subchart.axis.x.tick.text.show=true] Show or hide x axis tick text.
22457 * @property {Array} [subchart.init.range] Set initial selection domain range.
22458 * @property {number} [subchart.size.height] Change the height of the subchart.
22459 * @property {Function} [subchart.onbrush] Set callback for brush event.<br>
22460 * Specified function receives the current zoomed x domain.
22461 * @see [Demo](https://naver.github.io/billboard.js/demo/#Interaction.SubChart)
22462 * @example
22463 * subchart: {
22464 * show: true,
22465 * showHandle: true,
22466 * size: {
22467 * height: 20
22468 * },
22469 * init: {
22470 * // specify initial range domain selection
22471 * range: [1, 2]
22472 * },
22473 * axis: {
22474 * x: {
22475 * show: true,
22476 * tick: {
22477 * show: true,
22478 * format: (x) => d3Format(".1f")(x)
22479 * text: {
22480 * show: false
22481 * }
22482 * }
22483 * }
22484 * },
22485 * onbrush: function(domain) { ... }
22486 * }
22487 * @example
22488 * // importing ESM
22489 * import bb, {subchart} from "billboard.js";
22490 *
22491 * subchart: {
22492 * show: subchart(),
22493 * ...
22494 * }
22495 */
22496 subchart_show: !1,
22497 subchart_showHandle: !1,
22498 subchart_size_height: 60,
22499 subchart_axis_x_show: !0,
22500 subchart_axis_x_tick_show: !0,
22501 subchart_axis_x_tick_format: undefined,
22502 subchart_axis_x_tick_text_show: !0,
22503 subchart_init_range: undefined,
22504 subchart_onbrush: function subchart_onbrush() {}
22505});
22506;// CONCATENATED MODULE: ./src/config/Options/interaction/zoom.ts
22507/**
22508 * Copyright (c) 2017 ~ present NAVER Corp.
22509 * billboard.js project is licensed under the MIT license
22510 */
22511
22512/**
22513 * zoom config options
22514 */
22515/* harmony default export */ var interaction_zoom = ({
22516 /**
22517 * Set zoom options
22518 * @name zoom
22519 * @memberof Options
22520 * @type {object}
22521 * @property {object} zoom Zoom object
22522 * @property {boolean} [zoom.enabled=false] Enable zooming.
22523 * - **NOTE:** for ESM imports, needs to import 'zoom' exports and instantiate it by calling `zoom()`.
22524 * - `enabled: zoom()`
22525 * @property {string} [zoom.type='wheel'] Set zoom interaction type.
22526 * - **Available types:**
22527 * - wheel
22528 * - drag
22529 * @property {boolean} [zoom.rescale=false] Enable to rescale after zooming.<br>
22530 * If true set, y domain will be updated according to the zoomed region.
22531 * @property {Array} [zoom.extent=[1, 10]] Change zoom extent.
22532 * @property {number|Date} [zoom.x.min] Set x Axis minimum zoom range
22533 * @property {number|Date} [zoom.x.max] Set x Axis maximum zoom range
22534 * @property {Function} [zoom.onzoomstart=undefined] Set callback that is called when zooming starts.<br>
22535 * Specified function receives the zoom event.
22536 * @property {Function} [zoom.onzoom=undefined] Set callback that is called when the chart is zooming.<br>
22537 * Specified function receives the zoomed domain.
22538 * @property {Function} [zoom.onzoomend=undefined] Set callback that is called when zooming ends.<br>
22539 * Specified function receives the zoomed domain.
22540 * @property {boolean|object} [zoom.resetButton=true] Set to display zoom reset button for 'drag' type zoom
22541 * @property {Function} [zoom.resetButton.onclick] Set callback when clicks the reset button. The callback will receive reset button element reference as argument.
22542 * @property {string} [zoom.resetButton.text='Reset Zoom'] Text value for zoom reset button.
22543 * @see [Demo:zoom](https://naver.github.io/billboard.js/demo/#Interaction.Zoom)
22544 * @see [Demo:drag zoom](https://naver.github.io/billboard.js/demo/#Interaction.DragZoom)
22545 * @example
22546 * zoom: {
22547 * enabled: true,
22548 * type: "drag",
22549 * rescale: true,
22550 * extent: [1, 100] // enable more zooming
22551 * x: {
22552 * min: -1, // set min range
22553 * max: 10 // set max range
22554 * },
22555 * onzoomstart: function(event) { ... },
22556 * onzoom: function(domain) { ... },
22557 * onzoomend: function(domain) { ... },
22558 *
22559 * // show reset button when is zoomed-in
22560 * resetButton: true,
22561 *
22562 * resetButton: {
22563 * // onclick callback when reset button is clicked
22564 * onclick: function(button) {
22565 * button; // Reset button element reference
22566 * ...
22567 * },
22568 *
22569 * // customized text value for reset zoom button
22570 * text: "Unzoom"
22571 * }
22572 * }
22573 * @example
22574 * // importing ESM
22575 * import bb, {zoom} from "billboard.js";
22576 *
22577 * zoom: {
22578 * enabled: zoom(),
22579 * ...
22580 * }
22581 */
22582 zoom_enabled: !1,
22583 zoom_type: "wheel",
22584 zoom_extent: undefined,
22585 zoom_privileged: !1,
22586 zoom_rescale: !1,
22587 zoom_onzoom: undefined,
22588 zoom_onzoomstart: undefined,
22589 zoom_onzoomend: undefined,
22590 zoom_resetButton: !0,
22591 zoom_x_min: undefined,
22592 zoom_x_max: undefined
22593});
22594;// CONCATENATED MODULE: ./src/config/resolver/interaction.ts
22595/**
22596 * Copyright (c) 2017 ~ present NAVER Corp.
22597 * billboard.js project is licensed under the MIT license
22598 */
22599
22600
22601
22602 // Chart
22603
22604
22605
22606 // ChartInternal
22607
22608
22609
22610 // Axis based options
22611
22612
22613
22614
22615
22616
22617var _selectionModule = function selectionModule() {
22618 extend(ChartInternal.prototype, internals_selection);
22619 extend(Chart.prototype, selection);
22620 Options.setOptions([data_selection]);
22621 return (_selectionModule = function selectionModule() {
22622 return !0;
22623 })();
22624},
22625 subchartModule = function () {
22626 extend(ChartInternal.prototype, interactions_subchart);
22627 extend(Chart.prototype, subchart);
22628 Options.setOptions([interaction_subchart]);
22629 return (subchartModule = function () {
22630 return !0;
22631 })();
22632},
22633 zoomModule = function () {
22634 extend(ChartInternal.prototype, interactions_zoom);
22635 extend(Chart.prototype, api_zoom);
22636 Options.setOptions([interaction_zoom]);
22637 return (zoomModule = function () {
22638 return !0;
22639 })();
22640};
22641;// CONCATENATED MODULE: ./src/core.ts
22642/**
22643 * Copyright (c) 2017 ~ present NAVER Corp.
22644 * billboard project is licensed under the MIT license
22645 */
22646
22647 // eslint-disable-next-line no-use-before-define
22648
22649
22650var _defaults = {},
22651 bb = {
22652 /**
22653 * Version information
22654 * @property {string} version version
22655 * @example
22656 * bb.version; // "1.0.0"
22657 * @memberof bb
22658 */
22659 version: "3.2.1",
22660
22661 /**
22662 * Generate chart
22663 * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
22664 * - Unused option value is given.
22665 * - ex) For `data.type="pie"` option, setting 'axis' option can cause unexpected generation error.
22666 * - Insufficient value is given for certain option used.
22667 * - ex) `data: { x: "x", columns: [["x"], ["data1", 30, 200, 100]] }`
22668 * @param {Options} config chart options
22669 * @memberof bb
22670 * @returns {Chart}
22671 * @see {@link Options} for different generation options
22672 * @see {@link Chart} for different methods API
22673 * @example
22674 * <!-- chart holder -->
22675 * <div id="LineChart"></div>
22676 * @example
22677 * // Generate chart with options
22678 * var chart = bb.generate({
22679 * "bindto": "#LineChart"
22680 * "data": {
22681 * "columns": [
22682 * ["data1", 30, 200, 100, 400, 150, 250],
22683 * ["data2", 50, 20, 10, 40, 15, 25]
22684 * ],
22685 * "type": "line"
22686 * }
22687 * });
22688 *
22689 * // call some API
22690 * // ex) get the data of 'data1'
22691 * chart.data("data1");
22692 * @example
22693 * // Generate chart by importing ESM
22694 * // Import types to be used only, where this will make smaller bundle size.
22695 * import bb, {
22696 * area,
22697 * areaLineRange,
22698 * areaSpline,
22699 * areaSplineRange,
22700 * areaStep,
22701 * bar,
22702 * bubble,
22703 * donut,
22704 * gauge,
22705 * line,
22706 * pie,
22707 * radar,
22708 * scatter,
22709 * spline,
22710 * step
22711 * }
22712 *
22713 * bb.generate({
22714 * "bindto": "#LineChart"
22715 * "data": {
22716 * "columns": [
22717 * ["data1", 30, 200, 100, 400, 150, 250],
22718 * ["data2", 50, 20, 10, 40, 15, 25]
22719 * ]
22720 * },
22721 * type: line(),
22722 *
22723 * // or
22724 * types: {
22725 * data1: bar(),
22726 * data2: step()
22727 * }
22728 * });
22729 */
22730 generate: function generate(config) {
22731 var options = mergeObj({}, _defaults, config),
22732 inst = new Chart(options);
22733 inst.internal.charts = this.instance;
22734 this.instance.push(inst);
22735 return inst;
22736 },
22737
22738 /**
22739 * Set or get global default options.
22740 * - **NOTE:**
22741 * - The options values settings are valid within page context only.
22742 * - If is called multiple times, will override the last value.
22743 * @param {Options} options chart options
22744 * @memberof bb
22745 * @returns {Options}
22746 * @see {@link Options}
22747 * @example
22748 * // Set same option value as for `.generate()`
22749 * bb.defaults({
22750 * data: {
22751 * type: "bar"
22752 * }
22753 * });
22754 *
22755 * bb.defaults(); // {data:{type: "bar"}}
22756 *
22757 * // data.type defaults to 'bar'
22758 * var chart = bb.generate({ ... });
22759 */
22760 defaults: function defaults(options) {
22761 if (isObject(options)) {
22762 _defaults = options;
22763 }
22764
22765 return _defaults;
22766 },
22767
22768 /**
22769 * An array containing instance created
22770 * @property {Array} instance instance array
22771 * @example
22772 * // generate charts
22773 * var chart1 = bb.generate(...);
22774 * var chart2 = bb.generate(...);
22775 *
22776 * bb.instance; // [ chart1, chart2, ... ]
22777 * @memberof bb
22778 */
22779 instance: [],
22780
22781 /**
22782 * Namespace for plugins
22783 * @property {object} plugin plugin namespace
22784 * @example
22785 * // Stanford diagram plugin
22786 * bb.plugin.stanford;
22787 * @memberof bb
22788 */
22789 plugin: {}
22790};
22791/**
22792 * @namespace bb
22793 * @version 3.2.1
22794 */
22795;// CONCATENATED MODULE: ./src/index.ts
22796/**
22797 * Copyright (c) 2017 ~ present NAVER Corp.
22798 * billboard project is licensed under the MIT license
22799 */
22800
22801 // extends shape modules
22802
22803Object.keys(resolver_shape_namespaceObject).forEach(function (v) {
22804 return resolver_shape_namespaceObject[v]();
22805}); // extends interaction modules
22806
22807Object.keys(resolver_interaction_namespaceObject).forEach(function (v) {
22808 return resolver_interaction_namespaceObject[v]();
22809});
22810
22811}();
22812/******/ return __webpack_exports__;
22813/******/ })()
22814;
22815});
\No newline at end of file