UNPKG

659 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.0.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-color"), 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-color", "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-color"), 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"], 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__13__, __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__14__) {
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/* 14 */
98/***/ (function(module) {
99
100module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
101
102/***/ })
103/******/ ]);
104/************************************************************************/
105/******/ // The module cache
106/******/ var __webpack_module_cache__ = {};
107/******/
108/******/ // The require function
109/******/ function __webpack_require__(moduleId) {
110/******/ // Check if module is in cache
111/******/ var cachedModule = __webpack_module_cache__[moduleId];
112/******/ if (cachedModule !== undefined) {
113/******/ return cachedModule.exports;
114/******/ }
115/******/ // Create a new module (and put it into the cache)
116/******/ var module = __webpack_module_cache__[moduleId] = {
117/******/ // no module.id needed
118/******/ // no module.loaded needed
119/******/ exports: {}
120/******/ };
121/******/
122/******/ // Execute the module function
123/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
124/******/
125/******/ // Return the exports of the module
126/******/ return module.exports;
127/******/ }
128/******/
129/************************************************************************/
130/******/ /* webpack/runtime/define property getters */
131/******/ !function() {
132/******/ // define getter functions for harmony exports
133/******/ __webpack_require__.d = function(exports, definition) {
134/******/ for(var key in definition) {
135/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
136/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
137/******/ }
138/******/ }
139/******/ };
140/******/ }();
141/******/
142/******/ /* webpack/runtime/hasOwnProperty shorthand */
143/******/ !function() {
144/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
145/******/ }();
146/******/
147/******/ /* webpack/runtime/make namespace object */
148/******/ !function() {
149/******/ // define __esModule on exports
150/******/ __webpack_require__.r = function(exports) {
151/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
152/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
153/******/ }
154/******/ Object.defineProperty(exports, '__esModule', { value: true });
155/******/ };
156/******/ }();
157/******/
158/************************************************************************/
159var __webpack_exports__ = {};
160// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
161!function() {
162// extracted by mini-css-extract-plugin
163
164}();
165// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
166!function() {
167// ESM COMPAT FLAG
168__webpack_require__.r(__webpack_exports__);
169
170// EXPORTS
171__webpack_require__.d(__webpack_exports__, {
172 "bb": function() { return /* reexport */ bb; },
173 "default": function() { return /* reexport */ bb; }
174});
175
176// NAMESPACE OBJECT: ./src/config/resolver/shape.ts
177var resolver_shape_namespaceObject = {};
178__webpack_require__.r(resolver_shape_namespaceObject);
179__webpack_require__.d(resolver_shape_namespaceObject, {
180 "area": function() { return _area; },
181 "areaLineRange": function() { return areaLineRange; },
182 "areaSpline": function() { return areaSpline; },
183 "areaSplineRange": function() { return areaSplineRange; },
184 "areaStep": function() { return areaStep; },
185 "bar": function() { return resolver_shape_bar; },
186 "bubble": function() { return resolver_shape_bubble; },
187 "candlestick": function() { return resolver_shape_candlestick; },
188 "donut": function() { return shape_donut; },
189 "gauge": function() { return resolver_shape_gauge; },
190 "line": function() { return resolver_shape_line; },
191 "pie": function() { return shape_pie; },
192 "radar": function() { return resolver_shape_radar; },
193 "scatter": function() { return shape_scatter; },
194 "spline": function() { return shape_spline; },
195 "step": function() { return step; }
196});
197
198// NAMESPACE OBJECT: ./src/config/resolver/interaction.ts
199var resolver_interaction_namespaceObject = {};
200__webpack_require__.r(resolver_interaction_namespaceObject);
201__webpack_require__.d(resolver_interaction_namespaceObject, {
202 "selection": function() { return _selectionModule; },
203 "subchart": function() { return subchartModule; },
204 "zoom": function() { return zoomModule; }
205});
206
207// EXTERNAL MODULE: external {"commonjs":"d3-time-format","commonjs2":"d3-time-format","amd":"d3-time-format","root":"d3"}
208var external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_ = __webpack_require__(4);
209// EXTERNAL MODULE: external {"commonjs":"d3-selection","commonjs2":"d3-selection","amd":"d3-selection","root":"d3"}
210var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(2);
211;// CONCATENATED MODULE: ./src/config/classes.ts
212/**
213 * Copyright (c) 2017 ~ present NAVER Corp.
214 * billboard.js project is licensed under the MIT license
215 */
216
217/**
218 * CSS class names definition
219 * @private
220 */
221/* harmony default export */ var config_classes = ({
222 arc: "bb-arc",
223 arcLabelLine: "bb-arc-label-line",
224 arcs: "bb-arcs",
225 area: "bb-area",
226 areas: "bb-areas",
227 axis: "bb-axis",
228 axisX: "bb-axis-x",
229 axisXLabel: "bb-axis-x-label",
230 axisY: "bb-axis-y",
231 axisY2: "bb-axis-y2",
232 axisY2Label: "bb-axis-y2-label",
233 axisYLabel: "bb-axis-y-label",
234 bar: "bb-bar",
235 bars: "bb-bars",
236 brush: "bb-brush",
237 button: "bb-button",
238 buttonZoomReset: "bb-zoom-reset",
239 candlestick: "bb-candlestick",
240 candlesticks: "bb-candlesticks",
241 chart: "bb-chart",
242 chartArc: "bb-chart-arc",
243 chartArcs: "bb-chart-arcs",
244 chartArcsBackground: "bb-chart-arcs-background",
245 chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
246 chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
247 chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
248 chartArcsTitle: "bb-chart-arcs-title",
249 chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
250 chartBar: "bb-chart-bar",
251 chartBars: "bb-chart-bars",
252 chartCandlestick: "bb-chart-candlestick",
253 chartCandlesticks: "bb-chart-candlesticks",
254 chartCircles: "bb-chart-circles",
255 chartLine: "bb-chart-line",
256 chartLines: "bb-chart-lines",
257 chartRadar: "bb-chart-radar",
258 chartRadars: "bb-chart-radars",
259 chartText: "bb-chart-text",
260 chartTexts: "bb-chart-texts",
261 circle: "bb-circle",
262 circles: "bb-circles",
263 colorPattern: "bb-color-pattern",
264 colorScale: "bb-colorscale",
265 defocused: "bb-defocused",
266 dragarea: "bb-dragarea",
267 empty: "bb-empty",
268 eventRect: "bb-event-rect",
269 eventRects: "bb-event-rects",
270 eventRectsMultiple: "bb-event-rects-multiple",
271 eventRectsSingle: "bb-event-rects-single",
272 focused: "bb-focused",
273 gaugeValue: "bb-gauge-value",
274 grid: "bb-grid",
275 gridLines: "bb-grid-lines",
276 legend: "bb-legend",
277 legendBackground: "bb-legend-background",
278 legendItem: "bb-legend-item",
279 legendItemEvent: "bb-legend-item-event",
280 legendItemFocused: "bb-legend-item-focused",
281 legendItemHidden: "bb-legend-item-hidden",
282 legendItemPoint: "bb-legend-item-point",
283 legendItemTile: "bb-legend-item-tile",
284 level: "bb-level",
285 levels: "bb-levels",
286 line: "bb-line",
287 lines: "bb-lines",
288 main: "bb-main",
289 region: "bb-region",
290 regions: "bb-regions",
291 selectedCircle: "bb-selected-circle",
292 selectedCircles: "bb-selected-circles",
293 shape: "bb-shape",
294 shapes: "bb-shapes",
295 stanfordElements: "bb-stanford-elements",
296 stanfordLine: "bb-stanford-line",
297 stanfordLines: "bb-stanford-lines",
298 stanfordRegion: "bb-stanford-region",
299 stanfordRegions: "bb-stanford-regions",
300 subchart: "bb-subchart",
301 target: "bb-target",
302 text: "bb-text",
303 texts: "bb-texts",
304 title: "bb-title",
305 tooltip: "bb-tooltip",
306 tooltipContainer: "bb-tooltip-container",
307 tooltipName: "bb-tooltip-name",
308 valueDown: "bb-value-down",
309 valueUp: "bb-value-up",
310 xgrid: "bb-xgrid",
311 xgridFocus: "bb-xgrid-focus",
312 xgridLine: "bb-xgrid-line",
313 xgridLines: "bb-xgrid-lines",
314 xgrids: "bb-xgrids",
315 ygrid: "bb-ygrid",
316 ygridFocus: "bb-ygrid-focus",
317 ygridLine: "bb-ygrid-line",
318 ygridLines: "bb-ygrid-lines",
319 ygrids: "bb-ygrids",
320 zoomBrush: "bb-zoom-brush",
321 EXPANDED: "_expanded_",
322 SELECTED: "_selected_",
323 INCLUDED: "_included_",
324 TextOverlapping: "text-overlapping"
325});
326;// CONCATENATED MODULE: ./src/config/Store/Element.ts
327/**
328 * Copyright (c) 2017 ~ present NAVER Corp.
329 * billboard.js project is licensed under the MIT license
330 */
331
332/**
333 * Elements class.
334 * @class Elements
335 * @ignore
336 * @private
337 */
338var Element = function () {
339 return {
340 chart: null,
341 main: null,
342 svg: null,
343 axis: {
344 // axes
345 x: null,
346 y: null,
347 y2: null,
348 subX: null
349 },
350 defs: null,
351 tooltip: null,
352 legend: null,
353 title: null,
354 subchart: {
355 main: null,
356 // $$.context
357 bar: null,
358 // $$.contextBar
359 line: null,
360 // $$.contextLine
361 area: null // $$.contextArea
362
363 },
364 arcs: null,
365 bar: null,
366 // mainBar,
367 candlestick: null,
368 line: null,
369 // mainLine,
370 area: null,
371 // mainArea,
372 circle: null,
373 // mainCircle,
374 radar: null,
375 text: null,
376 // mainText,
377 grid: {
378 main: null,
379 // grid (also focus)
380 x: null,
381 // xgrid,
382 y: null // ygrid,
383
384 },
385 gridLines: {
386 main: null,
387 // gridLines
388 x: null,
389 // xgridLines,
390 y: null // ygridLines
391
392 },
393 region: {
394 main: null,
395 // region
396 list: null // mainRegion
397
398 },
399 eventRect: null
400 };
401};
402
403
404;// CONCATENATED MODULE: ./src/config/Store/State.ts
405/**
406 * Copyright (c) 2017 ~ present NAVER Corp.
407 * billboard.js project is licensed under the MIT license
408 */
409
410/**
411 * State class.
412 * @class State
413 * @ignore
414 * @private
415 */
416var State = function () {
417 return {
418 width: 0,
419 width2: 0,
420 height: 0,
421 height2: 0,
422 margin: {
423 top: 0,
424 bottom: 0,
425 left: 0,
426 right: 0
427 },
428 margin2: {
429 top: 0,
430 bottom: 0,
431 left: 0,
432 right: 0
433 },
434 margin3: {
435 top: 0,
436 bottom: 0,
437 left: 0,
438 right: 0
439 },
440 arcWidth: 0,
441 arcHeight: 0,
442 xAxisHeight: 0,
443 hasAxis: !1,
444 hasRadar: !1,
445 current: {
446 width: 0,
447 height: 0,
448 dataMax: 0,
449 maxTickWidths: {
450 x: {
451 size: 0,
452 ticks: [],
453 clipPath: 0,
454 domain: ""
455 },
456 y: {
457 size: 0,
458 domain: ""
459 },
460 y2: {
461 size: 0,
462 domain: ""
463 }
464 },
465 // current used chart type list
466 types: []
467 },
468 // legend
469 isLegendRight: !1,
470 isLegendInset: !1,
471 isLegendTop: !1,
472 isLegendLeft: !1,
473 legendStep: 0,
474 legendItemWidth: 0,
475 legendItemHeight: 0,
476 legendHasRendered: !1,
477 eventReceiver: {
478 currentIdx: -1,
479 // current event interaction index
480 rect: {},
481 // event rect's clientBoundingRect
482 data: [],
483 // event data bound of previoous eventRect
484 coords: [] // coordination value of previous eventRect
485
486 },
487 axis: {
488 x: {
489 padding: {
490 left: 0,
491 right: 0
492 },
493 tickCount: 0
494 }
495 },
496 rotatedPadding: {
497 left: 30,
498 right: 0,
499 top: 5
500 },
501 withoutFadeIn: {},
502 inputType: "",
503 datetimeId: "",
504 // clip id string
505 clip: {
506 id: "",
507 idXAxis: "",
508 idYAxis: "",
509 idXAxisTickTexts: "",
510 idGrid: "",
511 idSubchart: "",
512 // clipIdForSubchart
513 path: "",
514 pathXAxis: "",
515 pathYAxis: "",
516 pathXAxisTickTexts: "",
517 pathGrid: ""
518 },
519 // status
520 event: null,
521 // event object
522 dragStart: null,
523 dragging: !1,
524 flowing: !1,
525 cancelClick: !1,
526 mouseover: !1,
527 rendered: !1,
528 transiting: !1,
529 redrawing: !1,
530 // if redraw() is on process
531 resizing: !1,
532 // resize event called
533 toggling: !1,
534 // legend toggle
535 zooming: !1,
536 hasNegativeValue: !1,
537 hasPositiveValue: !0,
538 orgAreaOpacity: "0.2",
539 // ID strings
540 hiddenTargetIds: [],
541 hiddenLegendIds: [],
542 focusedTargetIds: [],
543 defocusedTargetIds: [],
544 // value for Arc
545 radius: 0,
546 innerRadius: 0,
547 outerRadius: undefined,
548 innerRadiusRatio: 0,
549 gaugeArcWidth: 0,
550 radiusExpanded: 0,
551 // xgrid attribute
552 xgridAttr: {
553 x1: null,
554 x2: null,
555 y1: null,
556 y2: null
557 }
558 };
559};
560
561
562;// CONCATENATED MODULE: ./src/config/Store/Store.ts
563/**
564 * Copyright (c) 2017 ~ present NAVER Corp.
565 * billboard.js project is licensed under the MIT license
566 */
567
568 // mapping
569
570var classes = {
571 element: Element,
572 state: State
573};
574/**
575 * Internal store class.
576 * @class Store
577 * @ignore
578 * @private
579 */
580
581var Store = /*#__PURE__*/function () {
582 function Store() {
583 var _this = this;
584
585 Object.keys(classes).forEach(function (v) {
586 _this[v] = new classes[v]();
587 });
588 }
589
590 var _proto = Store.prototype;
591 return _proto.getStore = function getStore(name) {
592 return this[name];
593 }, Store;
594}();
595
596
597;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
598function _defineProperty(obj, key, value) {
599 if (key in obj) {
600 Object.defineProperty(obj, key, {
601 value: value,
602 enumerable: true,
603 configurable: true,
604 writable: true
605 });
606 } else {
607 obj[key] = value;
608 }
609
610 return obj;
611}
612;// CONCATENATED MODULE: ./src/config/Options/common/main.ts
613/**
614 * Copyright (c) 2017 ~ present NAVER Corp.
615 * billboard.js project is licensed under the MIT license
616 */
617
618/**
619 * main config options
620 */
621/* harmony default export */ var main = ({
622 /**
623 * Specify the CSS selector or the element which the chart will be set to. D3 selection object can be specified also.<br>
624 * If other chart is set already, it will be replaced with the new one (only one chart can be set in one element).
625 * - **NOTE:** In case of element doesn't exist or not specified, will add a `<div>` element to the body.
626 * @name bindto
627 * @memberof Options
628 * @property {string|HTMLElement|d3.selection|object} [bindto="#chart"] Specify the element where chart will be drawn.
629 * @property {string|HTMLElement|d3.selection} bindto.element="#chart" Specify the element where chart will be drawn.
630 * @property {string} [bindto.classname=bb] Specify the class name of bind element.<br>
631 * **NOTE:** When class name isn't `bb`, then you also need to update the default CSS to be rendered correctly.
632 * @default #chart
633 * @example
634 * bindto: "#myContainer"
635 *
636 * // or HTMLElement
637 * bindto: document.getElementById("myContainer")
638 *
639 * // or D3 selection object
640 * bindto: d3.select("#myContainer")
641 *
642 * // or to change default classname
643 * bindto: {
644 * element: "#chart",
645 * classname: "bill-board" // ex) <div id='chart' class='bill-board'>
646 * }
647 */
648 bindto: "#chart",
649
650 /**
651 * Set chart background.
652 * @name background
653 * @memberof Options
654 * @property {object} background background object
655 * @property {string} background.class Specify the class name for background element.
656 * @property {string} background.color Specify the fill color for background element.<br>**NOTE:** Will be ignored if `imgUrl` option is set.
657 * @property {string} background.imgUrl Specify the image url string for background.
658 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.Background)
659 * @example
660 * background: {
661 * class: "myClass",
662 * color: "red",
663 *
664 * // Set image url for background.
665 * // If specified, 'color' option will be ignored.
666 * imgUrl: "https://naver.github.io/billboard.js/img/logo/billboard.js.svg",
667 * }
668 */
669 background: {},
670
671 /**
672 * Set 'clip-path' attribute for chart element
673 * - **NOTE:**
674 * > When is false, chart node element is positioned after the axis node in DOM tree hierarchy.
675 * > Is to make chart element positioned over axis element.
676 * @name clipPath
677 * @memberof Options
678 * @type {boolean}
679 * @default true
680 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.clipPath)
681 * @example
682 * // don't set 'clip-path' attribute
683 * clipPath: false
684 */
685 clipPath: !0,
686
687 /**
688 * Set svg element's class name
689 * @name svg
690 * @memberof Options
691 * @type {object}
692 * @property {object} [svg] svg object
693 * @property {string} [svg.classname] class name for svg element
694 * @example
695 * svg: {
696 * classname: "test_class"
697 * }
698 */
699 svg_classname: undefined,
700
701 /**
702 * The desired size of the chart element.
703 * If value is not specified, the width of the chart will be calculated by the size of the parent element it's appended to.
704 * @name size
705 * @memberof Options
706 * @type {object}
707 * @property {object} [size] size object
708 * @property {number} [size.width] width of the chart element
709 * @property {number} [size.height] height of the chart element
710 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.ChartSize)
711 * @example
712 * size: {
713 * width: 640,
714 * height: 480
715 * }
716 */
717 size_width: undefined,
718 size_height: undefined,
719
720 /**
721 * The padding of the chart element.
722 * @name padding
723 * @memberof Options
724 * @type {object}
725 * @property {object} [padding] padding object
726 * @property {number} [padding.top] padding on the top of chart
727 * @property {number} [padding.right] padding on the right of chart
728 * @property {number} [padding.bottom] padding on the bottom of chart
729 * @property {number} [padding.left] padding on the left of chart
730 * @example
731 * padding: {
732 * top: 20,
733 * right: 20,
734 * bottom: 20,
735 * left: 20
736 * }
737 */
738 padding_left: undefined,
739 padding_right: undefined,
740 padding_top: undefined,
741 padding_bottom: undefined,
742
743 /**
744 * Set chart resize options
745 * @name resize
746 * @memberof Options
747 * @type {object}
748 * @property {object} [resize] resize object
749 * @property {boolean} [resize.auto=true] Set chart resize automatically on viewport changes.
750 * @example
751 * resize: {
752 * auto: false
753 * }
754 */
755 resize_auto: !0,
756
757 /**
758 * Set a callback to execute when mouse/touch enters the chart.
759 * @name onover
760 * @memberof Options
761 * @type {Function}
762 * @default undefined
763 * @example
764 * onover: function() {
765 * this; // chart instance itself
766 * ...
767 * }
768 */
769 onover: undefined,
770
771 /**
772 * Set a callback to execute when mouse/touch leaves the chart.
773 * @name onout
774 * @memberof Options
775 * @type {Function}
776 * @default undefined
777 * @example
778 * onout: function() {
779 * this; // chart instance itself
780 * ...
781 * }
782 */
783 onout: undefined,
784
785 /**
786 * Set a callback to execute when user resizes the screen.
787 * @name onresize
788 * @memberof Options
789 * @type {Function}
790 * @default undefined
791 * @example
792 * onresize: function() {
793 * this; // chart instance itself
794 * ...
795 * }
796 */
797 onresize: undefined,
798
799 /**
800 * Set a callback to execute when screen resize finished.
801 * @name onresized
802 * @memberof Options
803 * @type {Function}
804 * @default undefined
805 * @example
806 * onresized: function() {
807 * this; // chart instance itself
808 * ...
809 * }
810 */
811 onresized: undefined,
812
813 /**
814 * Set a callback to execute before the chart is initialized
815 * @name onbeforeinit
816 * @memberof Options
817 * @type {Function}
818 * @default undefined
819 * @example
820 * onbeforeinit: function() {
821 * this; // chart instance itself
822 * ...
823 * }
824 */
825 onbeforeinit: undefined,
826
827 /**
828 * Set a callback to execute when the chart is initialized.
829 * @name oninit
830 * @memberof Options
831 * @type {Function}
832 * @default undefined
833 * @example
834 * oninit: function() {
835 * this; // chart instance itself
836 * ...
837 * }
838 */
839 oninit: undefined,
840
841 /**
842 * Set a callback to execute after the chart is initialized
843 * @name onafterinit
844 * @memberof Options
845 * @type {Function}
846 * @default undefined
847 * @example
848 * onafterinit: function() {
849 * this; // chart instance itself
850 * ...
851 * }
852 */
853 onafterinit: undefined,
854
855 /**
856 * 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.
857 * @name onrendered
858 * @memberof Options
859 * @type {Function}
860 * @default undefined
861 * @example
862 * onrendered: function() {
863 * this; // chart instance itself
864 * ...
865 * }
866 */
867 onrendered: undefined,
868
869 /**
870 * Set duration of transition (in milliseconds) for chart animation.<br><br>
871 * - **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.
872 * @name transition
873 * @memberof Options
874 * @type {object}
875 * @property {object} [transition] transition object
876 * @property {number} [transition.duration=350] duration in milliseconds
877 * @example
878 * transition: {
879 * duration: 500
880 * }
881 */
882 transition_duration: 350,
883
884 /**
885 * Set plugins
886 * @name plugins
887 * @memberof Options
888 * @type {Array}
889 * @example
890 * plugins: [
891 * new bb.plugin.stanford({ ... }),
892 * new PluginA(),
893 * ...
894 * ]
895 */
896 plugins: [],
897
898 /**
899 * Control the render timing
900 * @name render
901 * @memberof Options
902 * @type {object}
903 * @property {object} [render] render object
904 * @property {boolean} [render.lazy=true] Make to not render at initialization (enabled by default when bind element's visibility is hidden).
905 * @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.
906 * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.LazyRender)
907 * @example
908 * render: {
909 * lazy: true,
910 * observe: true
911 * }
912 *
913 * @example
914 * // <!-- render.lazy will detect visibility defined -->
915 * // (a) <div id='chart' class='hide'></div>
916 * // (b) <div id='chart' style='display:none'></div>
917 *
918 * // render.lazy enabled by default when element is hidden
919 * var chart = bb.generate({ ... });
920 *
921 * // chart will be rendered automatically when element's visibility changes
922 * // Note: works only for inlined css property or class attribute changes
923 * document.getElementById('chart').classList.remove('hide') // (a)
924 * document.getElementById('chart').style.display = 'block'; // (b)
925 *
926 * @example
927 * // chart won't be rendered and not observing bind element's visiblity changes
928 * var chart = bb.generate({
929 * render: {
930 * lazy: true,
931 * observe: false
932 * }
933 * });
934 *
935 * // call at any point when you want to render
936 * chart.flush();
937 */
938 render: {},
939
940 /**
941 * Show rectangles inside the chart.<br><br>
942 * This option accepts array including object that has axis, start, end and class.
943 * The keys start, end and class are optional.
944 * axis must be x, y or y2. start and end should be the value where regions start and end.
945 * If not specified, the edge values will be used.
946 * If timeseries x axis, date string, Date object and unixtime integer can be used.
947 * If class is set, the region element will have it as class.
948 * @name regions
949 * @memberof Options
950 * @type {Array}
951 * @default []
952 * @example
953 * regions: [
954 * {
955 * axis: "x",
956 * start: 1,
957 * end: 4,
958 * class: "region-1-4"
959 * }
960 * ]
961 */
962 regions: []
963});
964;// CONCATENATED MODULE: ./src/config/Options/data/data.ts
965/**
966 * Copyright (c) 2017 ~ present NAVER Corp.
967 * billboard.js project is licensed under the MIT license
968 */
969
970/**
971 * data config options
972 */
973/* harmony default export */ var data = ({
974 /**
975 * Specify the key of x values in the data.<br><br>
976 * 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.
977 * @name data․x
978 * @memberof Options
979 * @type {string}
980 * @default undefined
981 * @example
982 * data: {
983 * x: "date"
984 * }
985 */
986 data_x: undefined,
987
988 /**
989 * Converts data id value
990 * @name data․idConverter
991 * @memberof Options
992 * @type {Function}
993 * @default function(id) { return id; }
994 * @example
995 * data: {
996 * idConverter: function(id) {
997 * // when id is 'data1', converts to be 'data2'
998 * // 'data2' should be given as the initial data value
999 * if (id === "data1") {
1000 * return "data2";
1001 * } else {
1002 * return id;
1003 * }
1004 * }
1005 * }
1006 */
1007 data_idConverter: function data_idConverter(id) {
1008 return id;
1009 },
1010
1011 /**
1012 * Set custom data name.
1013 * @name data․names
1014 * @memberof Options
1015 * @type {object}
1016 * @default {}
1017 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataName)
1018 * @example
1019 * data: {
1020 * names: {
1021 * data1: "Data Name 1",
1022 * data2: "Data Name 2"
1023 * }
1024 * }
1025 */
1026 data_names: {},
1027
1028 /**
1029 * Set custom data class.<br><br>
1030 * 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).
1031 * @name data․classes
1032 * @memberof Options
1033 * @type {object}
1034 * @default {}
1035 * @example
1036 * data: {
1037 * classes: {
1038 * data1: "additional-data1-class",
1039 * data2: "additional-data2-class"
1040 * }
1041 * }
1042 */
1043 data_classes: {},
1044
1045 /**
1046 * Set chart type at once.<br><br>
1047 * If this option is specified, the type will be applied to every data. This setting can be overwritten by data.types.<br><br>
1048 * **Available Values:**
1049 * - area
1050 * - area-line-range
1051 * - area-spline
1052 * - area-spline-range
1053 * - area-step
1054 * - bar
1055 * - bubble
1056 * - candlestick
1057 * - donut
1058 * - gauge
1059 * - line
1060 * - pie
1061 * - radar
1062 * - scatter
1063 * - spline
1064 * - step
1065 * @name data․type
1066 * @memberof Options
1067 * @type {string}
1068 * @default "line"<br>NOTE: When importing shapes by ESM, `line()` should be specified for type.
1069 * @example
1070 * data: {
1071 * type: "bar"
1072 * }
1073 * @example
1074 * // Generate chart by importing ESM
1075 * // Import types to be used only, where this will make smaller bundle size.
1076 * import bb, {
1077 * area,
1078 * areaLineRange,
1079 * areaSpline,
1080 * areaSplineRange,
1081 * areaStep,
1082 * bar,
1083 * bubble,
1084 * candlestick,
1085 * donut,
1086 * gauge,
1087 * line,
1088 * pie,
1089 * radar,
1090 * scatter,
1091 * spline,
1092 * step
1093 * }
1094 *
1095 * bb.generate({
1096 * ...,
1097 * data: {
1098 * type: bar()
1099 * }
1100 * });
1101 */
1102 data_type: undefined,
1103
1104 /**
1105 * Set chart type for each data.<br>
1106 * This setting overwrites data.type setting.
1107 * - **NOTE:** `radar` type can't be combined with other types.
1108 * @name data․types
1109 * @memberof Options
1110 * @type {object}
1111 * @default {}
1112 * @example
1113 * data: {
1114 * types: {
1115 * data1: "bar",
1116 * data2: "spline"
1117 * }
1118 * }
1119 * @example
1120 * // Generate chart by importing ESM
1121 * // Import types to be used only, where this will make smaller bundle size.
1122 * import bb, {
1123 * area,
1124 * areaLineRange,
1125 * areaSpline,
1126 * areaSplineRange,
1127 * areaStep,
1128 * bar,
1129 * bubble,
1130 * candlestick,
1131 * donut,
1132 * gauge,
1133 * line,
1134 * pie,
1135 * radar,
1136 * scatter,
1137 * spline,
1138 * step
1139 * }
1140 *
1141 * bb.generate({
1142 * ...,
1143 * data: {
1144 * types: {
1145 * data1: bar(),
1146 * data1: spline()
1147 * }
1148 * }
1149 * });
1150 */
1151 data_types: {},
1152
1153 /**
1154 * This option changes the order of stacking data and pieces of pie/donut.
1155 * - If `null` specified, it will be the order the data loaded.
1156 * - 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>
1157 *
1158 * **Available Values:**
1159 * - `desc`: In descending order
1160 * - `asc`: In ascending order
1161 * - `null`: It keeps the data load order
1162 * - `function(data1, data2) { ... }`: Array.sort compareFunction
1163 *
1164 * **NOTE**: order function, only works for Axis based types & Arc types, except `Radar` type.
1165 * @name data․order
1166 * @memberof Options
1167 * @type {string|Function|null}
1168 * @default desc
1169 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataOrder)
1170 * @example
1171 * data: {
1172 * // in descending order (default)
1173 * order: "desc"
1174 *
1175 * // in ascending order
1176 * order: "asc"
1177 *
1178 * // keeps data input order
1179 * order: null
1180 *
1181 * // specifying sort function
1182 * order: function(a, b) {
1183 * // param data passed format
1184 * // {
1185 * // id: "data1", id_org: "data1", values: [
1186 * // {x: 5, value: 250, id: "data1", index: 5, name: "data1"},
1187 * // ...
1188 * // ]
1189 * // }
1190 *
1191 * const reducer = (p, c) => p + Math.abs(c.value);
1192 * const aSum = a.values.reduce(reducer, 0);
1193 * const bSum = b.values.reduce(reducer, 0);
1194 *
1195 * // ascending order
1196 * return aSum - bSum;
1197 *
1198 * // descending order
1199 * // return bSum - aSum;
1200 * }
1201 * }
1202 */
1203 data_order: "desc",
1204
1205 /**
1206 * Set groups for the data for stacking.
1207 * @name data․groups
1208 * @memberof Options
1209 * @type {Array}
1210 * @default []
1211 * @example
1212 * data: {
1213 * groups: [
1214 * ["data1", "data2"],
1215 * ["data3"]
1216 * ]
1217 * }
1218 */
1219 data_groups: [],
1220
1221 /**
1222 * Set color converter function.<br><br>
1223 * 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').
1224 * @name data․color
1225 * @memberof Options
1226 * @type {Function}
1227 * @default undefined
1228 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataColor)
1229 * @example
1230 * data: {
1231 * color: function(color, d) { ... }
1232 * }
1233 */
1234 data_color: undefined,
1235
1236 /**
1237 * Set color for each data.
1238 * @name data․colors
1239 * @memberof Options
1240 * @type {object}
1241 * @default {}
1242 * @example
1243 * data: {
1244 * colors: {
1245 * data1: "#ff0000",
1246 * data2: function(d) {
1247 * return "#000";
1248 * }
1249 * ...
1250 * }
1251 * }
1252 */
1253 data_colors: {},
1254
1255 /**
1256 * Set labels options
1257 * @name data․labels
1258 * @memberof Options
1259 * @type {object}
1260 * @property {object} data Data object
1261 * @property {boolean} [data.labels=false] Show or hide labels on each data points
1262 * @property {boolean} [data.labels.centered=false] Centerize labels on `bar` shape. (**NOTE:** works only for 'bar' type)
1263 * @property {Function} [data.labels.format] Set formatter function for data labels.<br>
1264 * 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>
1265 * The arguments are:<br>
1266 * - `v` is the value of the data point where the label is shown.
1267 * - `id` is the id of the data where the label is shown.
1268 * - `i` is the index of the data point where the label is shown.
1269 * - `j` is the sub index of the data point where the label is shown.<br><br>
1270 * Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
1271 * @property {string|object|Function} [data.labels.colors] Set label text colors.
1272 * @property {object} [data.labels.position] Set each dataset position, relative the original.
1273 * @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
1274 * @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
1275 * @memberof Options
1276 * @type {object}
1277 * @default {}
1278 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataLabel)
1279 * @see [Demo: label colors](https://naver.github.io/billboard.js/demo/#Data.DataLabelColors)
1280 * @see [Demo: label format](https://naver.github.io/billboard.js/demo/#Data.DataLabelFormat)
1281 * @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
1282 * @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
1283 * @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
1284 * @example
1285 * data: {
1286 * labels: true,
1287 *
1288 * // or set specific options
1289 * labels: {
1290 * format: function(v, id, i, j) {
1291 * ...
1292 * // to multiline, return with '\n' character
1293 * return "Line1\nLine2";
1294 * },
1295 *
1296 * // it's possible to set for each data
1297 * format: {
1298 * data1: function(v, id, i, j) { ... },
1299 * ...
1300 * },
1301 *
1302 * // align text to center of the 'bar' shape (works only for 'bar' type)
1303 * centered: true,
1304 *
1305 * // apply for all label texts
1306 * colors: "red",
1307 *
1308 * // set different colors per dataset
1309 * // for not specified dataset, will have the default color value
1310 * colors: {
1311 * data1: "yellow",
1312 * data3: "green"
1313 * },
1314 *
1315 * // call back for label text color
1316 * colors: function(color, d) {
1317 * // color: the default data label color string
1318 * // data: ex) {x: 0, value: 200, id: "data3", index: 0}
1319 * ....
1320 * return d.value > 200 ? "cyan" : color;
1321 * },
1322 *
1323 * // set x, y coordinate position
1324 * position: {
1325 * x: -10,
1326 * y: 10
1327 * },
1328 *
1329 * // or set x, y coordinate position by each dataset
1330 * position: {
1331 * data1: {x: 5, y: 5},
1332 * data2: {x: 10, y: -20}
1333 * }
1334 * }
1335 * }
1336 */
1337 data_labels: {},
1338 data_labels_colors: undefined,
1339 data_labels_position: {},
1340
1341 /**
1342 * Hide each data when the chart appears.<br><br>
1343 * If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
1344 * @name data․hide
1345 * @memberof Options
1346 * @type {boolean|Array}
1347 * @default false
1348 * @example
1349 * data: {
1350 * // all of data will be hidden
1351 * hide: true
1352 *
1353 * // specified data will be hidden
1354 * hide: ["data1", ...]
1355 * }
1356 */
1357 data_hide: !1,
1358
1359 /**
1360 * Filter values to be shown
1361 * The data value is the same as the returned by `.data()`.
1362 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
1363 * @name data․filter
1364 * @memberof Options
1365 * @type {Function}
1366 * @default undefined
1367 * @example
1368 * data: {
1369 * // filter for id value
1370 * filter: function(v) {
1371 * // v: [{id: "data1", id_org: "data1", values: [
1372 * // {x: 0, value: 130, id: "data2", index: 0}, ...]
1373 * // }, ...]
1374 * return v.id !== "data1";
1375 * }
1376 */
1377 data_filter: undefined,
1378
1379 /**
1380 * Set a callback for click event on each data point.<br><br>
1381 * This callback will be called when each data point clicked and will receive `d` and element as the arguments.
1382 * - `d` is the data clicked and element is the element clicked.
1383 * - `element` is the current interacting svg element.
1384 * - In this callback, `this` will be the Chart object.
1385 * @name data․onclick
1386 * @memberof Options
1387 * @type {Function}
1388 * @default function() {}
1389 * @example
1390 * data: {
1391 * onclick: function(d, element) {
1392 * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
1393 * // element - <circle>
1394 * ...
1395 * }
1396 * }
1397 */
1398 data_onclick: function data_onclick() {},
1399
1400 /**
1401 * Set a callback for mouse/touch over event on each data point.<br><br>
1402 * 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.
1403 * - `d` is the data where mouse cursor moves onto.
1404 * - `element` is the current interacting svg element.
1405 * - In this callback, `this` will be the Chart object.
1406 * @name data․onover
1407 * @memberof Options
1408 * @type {Function}
1409 * @default function() {}
1410 * @example
1411 * data: {
1412 * onover: function(d, element) {
1413 * // d - ex) {x: 4, value: 150, id: "data1", index: 4}
1414 * // element - <circle>
1415 * ...
1416 * }
1417 * }
1418 */
1419 data_onover: function data_onover() {},
1420
1421 /**
1422 * Set a callback for mouse/touch out event on each data point.<br><br>
1423 * This callback will be called when mouse cursor or via touch moves out each data point and will receive `d` as the argument.
1424 * - `d` is the data where mouse cursor moves out.
1425 * - `element` is the current interacting svg element.
1426 * - In this callback, `this` will be the Chart object.
1427 * @name data․onout
1428 * @memberof Options
1429 * @type {Function}
1430 * @default function() {}
1431 * @example
1432 * data: {
1433 * onout: function(d, element) {
1434 * // d - ex) {x: 4, value: 150, id: "data1", index: 4}
1435 * // element - <circle>
1436 * ...
1437 * }
1438 * }
1439 */
1440 data_onout: function data_onout() {},
1441
1442 /**
1443 * Set a callback for minimum data
1444 * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
1445 * @name data․onmin
1446 * @memberof Options
1447 * @type {Function}
1448 * @default undefined
1449 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
1450 * @example
1451 * onmin: function(data) {
1452 * // data - ex) [{x: 3, value: 400, id: "data1", index: 3}, ... ]
1453 * ...
1454 * }
1455 */
1456 data_onmin: undefined,
1457
1458 /**
1459 * Set a callback for maximum data
1460 * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
1461 * @name data․onmax
1462 * @memberof Options
1463 * @type {Function}
1464 * @default undefined
1465 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
1466 * @example
1467 * onmax: function(data) {
1468 * // data - ex) [{x: 3, value: 400, id: "data1", index: 3}, ... ]
1469 * ...
1470 * }
1471 */
1472 data_onmax: undefined,
1473
1474 /**
1475 * 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.
1476 * @name data․url
1477 * @memberof Options
1478 * @type {string}
1479 * @default undefined
1480 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.LoadData)
1481 * @example
1482 * data: {
1483 * url: "/data/test.csv"
1484 * }
1485 */
1486 data_url: undefined,
1487
1488 /**
1489 * XHR header value
1490 * - **NOTE:** Should be used with `data.url` option
1491 * @name data․headers
1492 * @memberof Options
1493 * @type {string}
1494 * @default undefined
1495 * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
1496 * @example
1497 * data: {
1498 * url: "/data/test.csv",
1499 * headers: {
1500 * "Content-Type": "text/xml",
1501 * ...
1502 * }
1503 * }
1504 */
1505 data_headers: undefined,
1506
1507 /**
1508 * Parse a JSON object for data. See also data.keys.
1509 * @name data․json
1510 * @memberof Options
1511 * @type {Array}
1512 * @default undefined
1513 * @see [data․keys](#.data%25E2%2580%25A4keys)
1514 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.JSONData)
1515 * @example
1516 * data: {
1517 * json: [
1518 * {name: "www.site1.com", upload: 200, download: 200, total: 400},
1519 * {name: "www.site2.com", upload: 100, download: 300, total: 400},
1520 * {name: "www.site3.com", upload: 300, download: 200, total: 500},
1521 * {name: "www.site4.com", upload: 400, download: 100, total: 500}
1522 * ],
1523 * keys: {
1524 * // x: "name", // it's possible to specify 'x' when category axis
1525 * value: ["upload", "download"]
1526 * }
1527 * }
1528 */
1529 data_json: undefined,
1530
1531 /**
1532 * Load data from a multidimensional array, with the first element containing the data names, the following containing related data in that order.
1533 * @name data․rows
1534 * @memberof Options
1535 * @type {Array}
1536 * @default undefined
1537 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.RowOrientedData)
1538 * @example
1539 * data: {
1540 * rows: [
1541 * ["A", "B", "C"],
1542 * [90, 120, 300],
1543 * [40, 160, 240],
1544 * [50, 200, 290],
1545 * [120, 160, 230],
1546 * [80, 130, 300],
1547 * [90, 220, 320]
1548 * ]
1549 * }
1550 *
1551 * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
1552 * // - an array of [high, mid, low] data following the order
1553 * // - or an object with 'high', 'mid' and 'low' key value
1554 * data: {
1555 * rows: [
1556 * ["data1", "data2"],
1557 * [
1558 * // or {high:150, mid: 140, low: 110}, 120
1559 * [150, 140, 110], 120
1560 * ],
1561 * [[155, 130, 115], 55],
1562 * [[160, 135, 120], 60]
1563 * ],
1564 * types: {
1565 * data1: "area-line-range",
1566 * data2: "line"
1567 * }
1568 * }
1569 *
1570 * // for 'bubble' type, data can contain dimension value:
1571 * // - an array of [y, z] data following the order
1572 * // - or an object with 'y' and 'z' key value
1573 * // 'y' is for y axis coordination and 'z' is the bubble radius value
1574 * data: {
1575 * rows: [
1576 * ["data1", "data2"],
1577 * [
1578 * // or {y:10, z: 140}, 120
1579 * [10, 140], 120
1580 * ],
1581 * [[100, 30], 55],
1582 * [[50, 100], 60]
1583 * ],
1584 * types: {
1585 * data1: "bubble",
1586 * data2: "line"
1587 * }
1588 * }
1589 *
1590 * // for 'canlestick' type, data should contain:
1591 * // - an array of [open, high, low, close, volume(optional)] data following the order
1592 * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
1593 * data: {
1594 * rows: [
1595 * ["data1", "data2"],
1596 * [
1597 * // open, high, low, close, volume (optional)
1598 * {open: 1300, high: 1369, low: 1200, close: 1339, volume: 100},
1599 * [1000, 1100, 850, 870]
1600 * ],
1601 * [
1602 * {open: 1348, high: 1371, low: 1271, close: 1320},
1603 * [870, 1250, 830, 1200, 50]
1604 * ]
1605 * ],
1606 * type: "candlestick"
1607 * }
1608 */
1609 data_rows: undefined,
1610
1611 /**
1612 * Load data from a multidimensional array, with each element containing an array consisting of a datum name and associated data values.
1613 * @name data․columns
1614 * @memberof Options
1615 * @type {Array}
1616 * @default undefined
1617 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.ColumnOrientedData)
1618 * @example
1619 * data: {
1620 * columns: [
1621 * ["data1", 30, 20, 50, 40, 60, 50],
1622 * ["data2", 200, 130, 90, 240, 130, 220],
1623 * ["data3", 300, 200, 160, 400, 250, 250]
1624 * ]
1625 * }
1626 *
1627 * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
1628 * // - an array of [high, mid, low] data following the order
1629 * // - or an object with 'high', 'mid' and 'low' key value
1630 * data: {
1631 * columns: [
1632 * ["data1",
1633 * [150, 140, 110], // or {high:150, mid: 140, low: 110}
1634 * [150, 140, 110],
1635 * [150, 140, 110]
1636 * ]
1637 * ],
1638 * type: "area-line-range"
1639 * }
1640 *
1641 * // for 'bubble' type, data can contain dimension value:
1642 * // - an array of [y, z] data following the order
1643 * // - or an object with 'y' and 'z' key value
1644 * // 'y' is for y axis coordination and 'z' is the bubble radius value
1645 * data: {
1646 * columns: [
1647 * ["data1",
1648 * [10, 140], // or {y:10, z: 140}
1649 * [100, 30],
1650 * [50, 100]
1651 * ]
1652 * ],
1653 * type: "bubble"
1654 * }
1655 *
1656 * // for 'canlestick' type, data should contain:
1657 * // - an array of [open, high, low, close, volume(optional)] data following the order
1658 * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
1659 * data: {
1660 * columns: [
1661 * ["data1",
1662 * [1000, 1100, 850, 870, 100], // or {open:1000, high: 1100, low: 870, volume: 100}
1663 * [870, 1250, 830, 1200] // 'volume' can be omitted
1664 * ]
1665 * ],
1666 * type: "candlestick"
1667 * }
1668 */
1669 data_columns: undefined,
1670
1671 /**
1672 * Used if loading JSON via data.url.
1673 * - **Available Values:**
1674 * - json
1675 * - csv
1676 * - tsv
1677 * @name data․mimeType
1678 * @memberof Options
1679 * @type {string}
1680 * @default csv
1681 * @example
1682 * data: {
1683 * mimeType: "json"
1684 * }
1685 */
1686 data_mimeType: "csv",
1687
1688 /**
1689 * Choose which JSON object keys correspond to desired data.
1690 * - **NOTE:** Only for JSON object given as array.
1691 * @name data․keys
1692 * @memberof Options
1693 * @type {string}
1694 * @default undefined
1695 * @example
1696 * data: {
1697 * json: [
1698 * {name: "www.site1.com", upload: 200, download: 200, total: 400},
1699 * {name: "www.site2.com", upload: 100, download: 300, total: 400},
1700 * {name: "www.site3.com", upload: 300, download: 200, total: 500},
1701 * {name: "www.site4.com", upload: 400, download: 100, total: 500}
1702 * ],
1703 * keys: {
1704 * // x: "name", // it's possible to specify 'x' when category axis
1705 * value: ["upload", "download"]
1706 * }
1707 * }
1708 */
1709 data_keys: undefined,
1710
1711 /**
1712 * Set text label to be displayed when there's no data to show.
1713 * - ex. Toggling all visible data to not be shown, unloading all current data, etc.
1714 * @name data․empty․label․text
1715 * @memberof Options
1716 * @type {string}
1717 * @default ""
1718 * @example
1719 * data: {
1720 * empty: {
1721 * label: {
1722 * text: "No Data"
1723 * }
1724 * }
1725 * }
1726 */
1727 data_empty_label_text: ""
1728});
1729;// CONCATENATED MODULE: ./src/config/Options/common/color.ts
1730/**
1731 * Copyright (c) 2017 ~ present NAVER Corp.
1732 * billboard.js project is licensed under the MIT license
1733 */
1734
1735/**
1736 * color config options
1737 */
1738/* harmony default export */ var color = ({
1739 /**
1740 * Set color of the data values
1741 * @name color
1742 * @memberof Options
1743 * @type {object}
1744 * @property {object} color color object
1745 * @property {string|object|Function} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
1746 * @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.
1747 * @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).
1748 * - **NOTE:** The pattern element's id will be defined as `bb-colorize-pattern-$COLOR-VALUE`.<br>
1749 * ex. When color pattern value is `['red', '#fff']` and defined 2 patterns,then ids for pattern elements are:<br>
1750 * - `bb-colorize-pattern-red`
1751 * - `bb-colorize-pattern-fff`
1752 * @property {object} [color.threshold] color threshold for gauge and tooltip color
1753 * @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.
1754 * @property {Array} [color.threshold.values] Threshold values for each steps
1755 * @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`.
1756 * @example
1757 * color: {
1758 * pattern: ["#1f77b4", "#aec7e8", ...],
1759 *
1760 * // Set colors' patterns
1761 * // it should return an array of SVGPatternElement
1762 * tiles: function() {
1763 * var pattern = document.createElementNS("http://www.w3.org/2000/svg", "pattern");
1764 * var g = document.createElementNS("http://www.w3.org/2000/svg", "g");
1765 * var circle1 = document.createElementNS("http://www.w3.org/2000/svg", "circle");
1766 *
1767 * pattern.setAttribute("patternUnits", "userSpaceOnUse");
1768 * pattern.setAttribute("width", "32");
1769 * pattern.setAttribute("height", "32");
1770 *
1771 * g.style.fill = "#000";
1772 * g.style.opacity = "0.2";
1773 *
1774 * circle1.setAttribute("cx", "3");
1775 * circle1.setAttribute("cy", "3");
1776 * circle1.setAttribute("r", "3");
1777 *
1778 * g.appendChild(circle1);
1779 * pattern.appendChild(g);
1780 *
1781 * return [pattern];
1782 * },
1783 *
1784 * // for threshold usage, pattern values should be set for each steps
1785 * pattern: ["grey", "green", "yellow", "orange", "red"],
1786 * threshold: {
1787 * unit: "value",
1788 *
1789 * // when value is 20 => 'green', value is 40 => 'orange' will be set.
1790 * values: [10, 20, 30, 40, 50],
1791 *
1792 * // the equation for max:
1793 * // - unit == 'value': max => 30
1794 * // - unit != 'value': max => value*100/30
1795 * max: 30
1796 * },
1797 *
1798 * // set all data to 'red'
1799 * onover: "red",
1800 *
1801 * // set different color for data
1802 * onover: {
1803 * data1: "red",
1804 * data2: "yellow"
1805 * },
1806 *
1807 * // will pass data object to the callback
1808 * onover: function(d) {
1809 * return d.id === "data1" ? "red" : "green";
1810 * }
1811 * }
1812 */
1813 color_pattern: [],
1814 color_tiles: undefined,
1815 color_threshold: {},
1816 color_onover: undefined
1817});
1818;// CONCATENATED MODULE: ./src/config/Options/interaction/interaction.ts
1819/**
1820 * Copyright (c) 2017 ~ present NAVER Corp.
1821 * billboard.js project is licensed under the MIT license
1822 */
1823
1824/**
1825 * interaction config options
1826 */
1827/* harmony default export */ var interaction = ({
1828 /**
1829 * Interaction options
1830 * @name interaction
1831 * @memberof Options
1832 * @type {object}
1833 * @property {object} interaction Intersection object
1834 * @property {boolean} [interaction.enabled=true] Indicate if the chart should have interactions.<br>
1835 * If `false` is set, all of interactions (showing/hiding tooltip, selection, mouse events, etc) will be disabled.
1836 * @property {boolean} [interaction.brighten=true] Make brighter for the selected area (ex. 'pie' type data selected area)
1837 * @property {boolean} [interaction.inputType.mouse=true] enable or disable mouse interaction
1838 * @property {boolean} [interaction.inputType.touch=true] enable or disable touch interaction
1839 * @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.
1840 * @see [Demo: touch.preventDefault](https://naver.github.io/billboard.js/demo/#Interaction.PreventScrollOnTouch)
1841 * @example
1842 * interaction: {
1843 * enabled: false,
1844 * brighten: false,
1845 * inputType: {
1846 * mouse: true,
1847 * touch: false
1848 *
1849 * // or declare preventDefault explicitly.
1850 * // In this case touch inputType is enabled by default
1851 * touch: {
1852 * preventDefault: true
1853 *
1854 * // or threshold pixel value (pixel moved from touchstart to touchmove)
1855 * preventDefault: 5
1856 * }
1857 * }
1858 * }
1859 */
1860 interaction_enabled: !0,
1861 interaction_brighten: !0,
1862 interaction_inputType_mouse: !0,
1863 interaction_inputType_touch: {}
1864});
1865;// CONCATENATED MODULE: ./src/config/Options/common/legend.ts
1866/**
1867 * Copyright (c) 2017 ~ present NAVER Corp.
1868 * billboard.js project is licensed under the MIT license
1869 */
1870
1871/**
1872 * legend config options
1873 */
1874/* harmony default export */ var legend = ({
1875 /**
1876 * Legend options
1877 * @name legend
1878 * @memberof Options
1879 * @type {object}
1880 * @property {object} legend Legend object
1881 * @property {boolean} [legend.show=true] Show or hide legend.
1882 * @property {boolean} [legend.hide=false] Hide legend
1883 * If true given, all legend will be hidden. If string or array given, only the legend that has the id will be hidden.
1884 * @property {string|HTMLElement} [legend.contents.bindto=undefined] Set CSS selector or element reference to bind legend items.
1885 * @property {string|Function} [legend.contents.template=undefined] Set item's template.<br>
1886 * - If set `string` value, within template the 'color' and 'title' can be replaced using template-like syntax string:
1887 * - {=COLOR}: data color value
1888 * - {=TITLE}: data title value
1889 * - If set `function` value, will pass following arguments to the given function:
1890 * - title {string}: data's id value
1891 * - color {string}: color string
1892 * - data {Array}: data array
1893 * @property {string} [legend.position=bottom] Change the position of legend.<br>
1894 * Available values are: `bottom`, `right` and `inset` are supported.
1895 * @property {object} [legend.inset={anchor: 'top-left',x: 10,y: 0,step: undefined}] Change inset legend attributes.<br>
1896 * This option accepts object that has the keys `anchor`, `x`, `y` and `step`.
1897 * - **anchor** decides the position of the legend:
1898 * - top-left
1899 * - top-right
1900 * - bottom-left
1901 * - bottom-right
1902 * - **x** and **y**:
1903 * - set the position of the legend based on the anchor.
1904 * - **step**:
1905 * - defines the max step the legend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).
1906 * @property {boolean} [legend.equally=false] Set to all items have same width size.
1907 * @property {boolean} [legend.padding=0] Set padding value
1908 * @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
1909 * @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
1910 * @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
1911 * @property {number} [legend.item.tile.width=10] Set width of item tile element
1912 * @property {number} [legend.item.tile.height=10] Set height of item tile element
1913 * @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
1914 * @see [Demo: position](https://naver.github.io/billboard.js/demo/#Legend.LegendPosition)
1915 * @see [Demo: contents.template](https://naver.github.io/billboard.js/demo/#Legend.LegendTemplate1)
1916 * @see [Demo: usePoint](https://naver.github.io/billboard.js/demo/#Legend.usePoint)
1917 * @example
1918 * legend: {
1919 * show: true,
1920 * hide: true,
1921 * //or hide: "data1"
1922 * //or hide: ["data1", "data2"]
1923 * contents: {
1924 * bindto: "#legend", // <ul id='legend'></ul>
1925 *
1926 * // will be as: <li style='background-color:#1f77b4'>data1</li>
1927 * template: "<li style='background-color:{=COLOR}'>{=TITLE}</li>"
1928 *
1929 * // or using function
1930 * template: function(id, color, data) {
1931 * // if you want omit some legend, return falsy value
1932 * if (id !== "data1") {
1933 * return "<li style='background-color:"+ color +">"+ id +"</li>";
1934 * }
1935 * }
1936 * },
1937 * position: "bottom", // bottom, right, inset
1938 * inset: {
1939 * anchor: "top-right" // top-left, top-right, bottom-left, bottom-right
1940 * x: 20,
1941 * y: 10,
1942 * step: 2
1943 * },
1944 * equally: false,
1945 * padding: 10,
1946 * item: {
1947 * onclick: function(id) { ... },
1948 * onover: function(id) { ... },
1949 * onout: function(id) { ... },
1950 *
1951 * // set tile's size
1952 * tile: {
1953 * width: 20,
1954 * height: 15
1955 * }
1956 * },
1957 * usePoint: true
1958 * }
1959 */
1960 legend_show: !0,
1961 legend_hide: !1,
1962 legend_contents_bindto: undefined,
1963 legend_contents_template: undefined,
1964 legend_position: "bottom",
1965 legend_inset_anchor: "top-left",
1966 legend_inset_x: 10,
1967 legend_inset_y: 0,
1968 legend_inset_step: undefined,
1969 legend_item_onclick: undefined,
1970 legend_item_onover: undefined,
1971 legend_item_onout: undefined,
1972 legend_equally: !1,
1973 legend_padding: 0,
1974 legend_item_tile_width: 10,
1975 legend_item_tile_height: 10,
1976 legend_usePoint: !1
1977});
1978;// CONCATENATED MODULE: ./src/config/Options/common/title.ts
1979/**
1980 * Copyright (c) 2017 ~ present NAVER Corp.
1981 * billboard.js project is licensed under the MIT license
1982 */
1983
1984/**
1985 * title config options
1986 */
1987/* harmony default export */ var title = ({
1988 /**
1989 * Set title options
1990 * @name title
1991 * @memberof Options
1992 * @type {object}
1993 * @property {object} title Title object
1994 * @property {string} [title.text] Title text. If contains `\n`, it's used as line break allowing multiline title.
1995 * @property {number} [title.padding.top=0] Top padding value.
1996 * @property {number} [title.padding.right=0] Right padding value.
1997 * @property {number} [title.padding.bottom=0] Bottom padding value.
1998 * @property {number} [title.padding.left=0] Left padding value.
1999 * @property {string} [title.position=center] Available values are: 'center', 'right' and 'left'.
2000 * @see [Demo](https://naver.github.io/billboard.js/demo/#Title.MultilinedTitle)
2001 * @example
2002 * title: {
2003 * text: "Title Text",
2004 *
2005 * // or Multiline title text
2006 * text: "Main title text\nSub title text",
2007 *
2008 * padding: {
2009 * top: 10,
2010 * right: 10,
2011 * bottom: 10,
2012 * left: 10
2013 * },
2014 * position: "center"
2015 * }
2016 */
2017 title_text: undefined,
2018 title_padding: {
2019 top: 0,
2020 right: 0,
2021 bottom: 0,
2022 left: 0
2023 },
2024 title_position: "center"
2025});
2026;// CONCATENATED MODULE: ./src/config/Options/common/tooltip.ts
2027/**
2028 * Copyright (c) 2017 ~ present NAVER Corp.
2029 * billboard.js project is licensed under the MIT license
2030 */
2031
2032/**
2033 * tooltip config options
2034 */
2035/* harmony default export */ var tooltip = ({
2036 /**
2037 * Tooltip options
2038 * @name tooltip
2039 * @memberof Options
2040 * @type {object}
2041 * @property {object} tooltip Tooltip object
2042 * @property {boolean} [tooltip.show=true] Show or hide tooltip.
2043 * @property {boolean} [tooltip.doNotHide=false] Make tooltip keep showing not hiding on interaction.
2044 * @property {boolean} [tooltip.grouped=true] Set if tooltip is grouped or not for the data points.
2045 * - **NOTE:** The overlapped data points will be displayed as grouped even if set false.
2046 * @property {boolean} [tooltip.linked=false] Set if tooltips on all visible charts with like x points are shown together when one is shown.
2047 * @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.
2048 * @property {Function} [tooltip.format.title] Set format for the title of tooltip.<br>
2049 * Specified function receives x of the data point to show.
2050 * @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
2051 * 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.
2052 * @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip.<br>
2053 * 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.
2054 * If undefined returned, the row of that value will be skipped.
2055 * @property {Function} [tooltip.position] Set custom position function for the tooltip.<br>
2056 * This option can be used to modify the tooltip position by returning object that has top and left.
2057 * @property {Function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
2058 * Specified function receives data, defaultTitleFormat, defaultValueFormat and color of the data point to show. If tooltip.grouped is true, data includes multiple data points.
2059 * @property {string|HTMLElement} [tooltip.contents.bindto=undefined] Set CSS selector or element reference to bind tooltip.
2060 * - **NOTE:** When is specified, will not be updating tooltip's position.
2061 * @property {string} [tooltip.contents.template=undefined] Set tooltip's template.<br><br>
2062 * Within template, below syntax will be replaced using template-like syntax string:
2063 * - **{{ ... }}**: the doubly curly brackets indicate loop block for data rows.
2064 * - **{=CLASS_TOOLTIP}**: default tooltip class name `bb-tooltip`.
2065 * - **{=CLASS_TOOLTIP_NAME}**: default tooltip data class name (ex. `bb-tooltip-name-data1`)
2066 * - **{=TITLE}**: title value.
2067 * - **{=COLOR}**: data color.
2068 * - **{=VALUE}**: data value.
2069 * @property {object} [tooltip.contents.text=undefined] Set additional text content within data loop, using template syntax.
2070 * - **NOTE:** It should contain `{ key: Array, ... }` value
2071 * - 'key' name is used as substitution within template as '{=KEY}'
2072 * - The value array length should match with the data length
2073 * @property {boolean} [tooltip.init.show=false] Show tooltip at the initialization.
2074 * @property {number} [tooltip.init.x=0] Set x Axis index(or index for Arc(donut, gauge, pie) types) to be shown at the initialization.
2075 * @property {object} [tooltip.init.position={top: "0px",left: "50px"}] Set the position of tooltip at the initialization.
2076 * @property {Function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
2077 * @property {Function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
2078 * @property {Function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
2079 * @property {Function} [tooltip.onhidden] Set a callback that will be invoked after the tooltip is hidden.
2080 * @property {string|Function|null} [tooltip.order=null] Set tooltip data display order.<br><br>
2081 * **Available Values:**
2082 * - `desc`: In descending data value order
2083 * - `asc`: In ascending data value order
2084 * - `null`: It keeps the data display order<br>
2085 * **NOTE:** When `data.groups` is set, the order will follow as the stacked graph order.<br>
2086 * If want to order as data bound, set any value rather than asc, desc or null. (ex. empty string "")
2087 * - `function(data1, data2) { ... }`: [Array.sort compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters)
2088 * @see [Demo: Hide Tooltip](https://naver.github.io/billboard.js/demo/#Tooltip.HideTooltip)
2089 * @see [Demo: Tooltip Grouping](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipGrouping)
2090 * @see [Demo: Tooltip Format](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipFormat)
2091 * @see [Demo: Linked Tooltip](https://naver.github.io/billboard.js/demo/#Tooltip.LinkedTooltips)
2092 * @see [Demo: Tooltip Template](https://naver.github.io/billboard.js/demo/#Tooltip.TooltipTemplate)
2093 * @example
2094 * tooltip: {
2095 * show: true,
2096 * doNotHide: true,
2097 * grouped: false,
2098 * format: {
2099 * title: function(x) { return "Data " + x; },
2100 * name: function(name, ratio, id, index) { return name; },
2101 * value: function(value, ratio, id, index) { return ratio; }
2102 * },
2103 * position: function(data, width, height, element) {
2104 * return {top: 0, left: 0}
2105 * },
2106 *
2107 * contents: function(d, defaultTitleFormat, defaultValueFormat, color) {
2108 * return ... // formatted html as you want
2109 * },
2110 *
2111 * // specify tooltip contents using template
2112 * // - example of HTML returned:
2113 * // <ul class="bb-tooltip">
2114 * // <li class="bb-tooltip-name-data1"><span>250</span><br><span style="color:#00c73c">data1</span></li>
2115 * // <li class="bb-tooltip-name-data2"><span>50</span><br><span style="color:#fa7171">data2</span></li>
2116 * // </ul>
2117 * contents: {
2118 * bindto: "#tooltip",
2119 * template: '<ul class={=CLASS_TOOLTIP}>{{' +
2120 * '<li class="{=CLASS_TOOLTIP_NAME}"><span>{=VALUE}</span><br>' +
2121 * '<span style=color:{=COLOR}>{=NAME}</span></li>' +
2122 * '}}</ul>'
2123 * }
2124 *
2125 * // with additional text value
2126 * // - example of HTML returned:
2127 * // <ul class="bb-tooltip">
2128 * // <li class="bb-tooltip-name-data1"><span>250</span><br>comment1<span style="color:#00c73c">data1</span>text1</li>
2129 * // <li class="bb-tooltip-name-data2"><span>50</span><br>comment2<span style="color:#fa7171">data2</span>text2</li>
2130 * // </ul>
2131 * contents: {
2132 * bindto: "#tooltip",
2133 * text: {
2134 * // a) 'key' name is used as substitution within template as '{=KEY}'
2135 * // b) the length should match with the data length
2136 * VAR1: ["text1", "text2"],
2137 * VAR2: ["comment1", "comment2"],
2138 * },
2139 * template: '<ul class={=CLASS_TOOLTIP}>{{' +
2140 * '<li class="{=CLASS_TOOLTIP_NAME}"><span>{=VALUE}</span>{=VAR2}<br>' +
2141 * '<span style=color:{=COLOR}>{=NAME}</span>{=VAR1}</li>' +
2142 * '}}</ul>'
2143 * }
2144 *
2145 * // sort tooltip data value display in ascending order
2146 * order: "asc",
2147 *
2148 * // specifying sort function
2149 * order: function(a, b) {
2150 * // param data passed format
2151 * {x: 5, value: 250, id: "data1", index: 5, name: "data1"}
2152 * ...
2153 * },
2154 *
2155 * // show at the initialization
2156 * init: {
2157 * show: true,
2158 * x: 2, // x Axis index(or index for Arc(donut, gauge, pie) types)
2159 * position: {
2160 * top: "150px",
2161 * left: "250px"
2162 * }
2163 * },
2164 *
2165 * // fires prior tooltip is shown
2166 * onshow: function(selectedData) {
2167 * // current dataset selected
2168 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
2169 * selectedData;
2170 * },
2171 *
2172 * // fires prior tooltip is hidden
2173 * onhide: function(selectedData) {
2174 * // current dataset selected
2175 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
2176 * selectedData;
2177 * },
2178 *
2179 * // fires after tooltip is shown
2180 * onshown: function(selectedData) {
2181 * // current dataset selected
2182 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
2183 * selectedData;
2184 * },
2185 *
2186 * // fires after tooltip is hidden
2187 * onhidden: function(selectedData) {
2188 * // current dataset selected
2189 * // ==> [{x: 4, value: 150, id: "data2", index: 4, name: "data2"}, ...]
2190 * selectedData;
2191 * },
2192 *
2193 * // Link any tooltips when multiple charts are on the screen where same x coordinates are available
2194 * // Useful for timeseries correlation
2195 * linked: true,
2196 *
2197 * // Specify name to interact those with the same name only.
2198 * linked: {
2199 * name: "some-group"
2200 * }
2201 * }
2202 */
2203 tooltip_show: !0,
2204 tooltip_doNotHide: !1,
2205 tooltip_grouped: !0,
2206 tooltip_format_title: undefined,
2207 tooltip_format_name: undefined,
2208 tooltip_format_value: undefined,
2209 tooltip_position: undefined,
2210 tooltip_contents: {},
2211 tooltip_init_show: !1,
2212 tooltip_init_x: 0,
2213 tooltip_init_position: {
2214 top: "0px",
2215 left: "50px"
2216 },
2217 tooltip_linked: !1,
2218 tooltip_linked_name: "",
2219 tooltip_onshow: function tooltip_onshow() {},
2220 tooltip_onhide: function tooltip_onhide() {},
2221 tooltip_onshown: function tooltip_onshown() {},
2222 tooltip_onhidden: function tooltip_onhidden() {},
2223 tooltip_order: null
2224});
2225// EXTERNAL MODULE: external {"commonjs":"d3-brush","commonjs2":"d3-brush","amd":"d3-brush","root":"d3"}
2226var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(3);
2227;// CONCATENATED MODULE: ./src/module/browser.ts
2228/**
2229 * Copyright (c) 2017 ~ present NAVER Corp.
2230 * billboard.js project is licensed under the MIT license
2231 */
2232
2233/**
2234 * Window object
2235 * @private
2236 */
2237
2238/* eslint-disable no-new-func, no-undef */
2239
2240
2241var win = function () {
2242 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;
2243 return root || Function("return this")();
2244}(),
2245 browser_doc = win && win.document;
2246/* eslint-enable no-new-func, no-undef */
2247;// CONCATENATED MODULE: ./src/module/util.ts
2248
2249
2250function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2251
2252function _objectSpread(target) { for (var source, i = 1; i < arguments.length; i++) source = arguments[i] == null ? {} : arguments[i], i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); return target; }
2253
2254/**
2255 * Copyright (c) 2017 ~ present NAVER Corp.
2256 * billboard.js project is licensed under the MIT license
2257 * @ignore
2258 */
2259
2260
2261
2262
2263
2264
2265var isValue = function (v) {
2266 return v || v === 0;
2267},
2268 isFunction = function (v) {
2269 return typeof v === "function";
2270},
2271 isString = function (v) {
2272 return typeof v === "string";
2273},
2274 isNumber = function (v) {
2275 return typeof v === "number";
2276},
2277 isUndefined = function (v) {
2278 return typeof v === "undefined";
2279},
2280 isDefined = function (v) {
2281 return typeof v !== "undefined";
2282},
2283 isboolean = function (v) {
2284 return typeof v === "boolean";
2285},
2286 ceil10 = function (v) {
2287 return Math.ceil(v / 10) * 10;
2288},
2289 asHalfPixel = function (n) {
2290 return Math.ceil(n) + .5;
2291},
2292 diffDomain = function (d) {
2293 return d[1] - d[0];
2294},
2295 isObjectType = function (v) {
2296 return typeof v === "object";
2297},
2298 isEmpty = function (o) {
2299 return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
2300},
2301 notEmpty = function (o) {
2302 return !isEmpty(o);
2303},
2304 isArray = function (arr) {
2305 return Array.isArray(arr);
2306},
2307 isObject = function (obj) {
2308 return obj && !obj.nodeType && isObjectType(obj) && !isArray(obj);
2309};
2310
2311/**
2312 * Get specified key value from object
2313 * If default value is given, will return if given key value not found
2314 * @param {object} options Source object
2315 * @param {string} key Key value
2316 * @param {*} defaultValue Default value
2317 * @returns {*}
2318 * @private
2319 */
2320function getOption(options, key, defaultValue) {
2321 return isDefined(options[key]) ? options[key] : defaultValue;
2322}
2323/**
2324 * Check if value exist in the given object
2325 * @param {object} dict Target object to be checked
2326 * @param {*} value Value to be checked
2327 * @returns {boolean}
2328 * @private
2329 */
2330
2331
2332function hasValue(dict, value) {
2333 var found = !1;
2334 return Object.keys(dict).forEach(function (key) {
2335 return dict[key] === value && (found = !0);
2336 }), found;
2337}
2338/**
2339 * Call function with arguments
2340 * @param {Function} fn Function to be called
2341 * @param {*} args Arguments
2342 * @returns {boolean} true: fn is function, false: fn is not function
2343 * @private
2344 */
2345
2346
2347function callFn(fn) {
2348 for (var isFn = isFunction(fn), _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) args[_key - 1] = arguments[_key];
2349
2350 return isFn && fn.call.apply(fn, args), isFn;
2351}
2352/**
2353 * Call function after all transitions ends
2354 * @param {d3.transition} transition Transition
2355 * @param {Fucntion} cb Callback function
2356 * @private
2357 */
2358
2359
2360function endall(transition, cb) {
2361 var n = 0;
2362 transition.each(function () {
2363 return ++n;
2364 }).on("end", function () {
2365 for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) args[_key2] = arguments[_key2];
2366
2367 --n || cb.apply.apply(cb, [this].concat(args));
2368 });
2369}
2370/**
2371 * Replace tag sign to html entity
2372 * @param {string} str Target string value
2373 * @returns {string}
2374 * @private
2375 */
2376
2377
2378function sanitise(str) {
2379 return isString(str) ? str.replace(/</g, "&lt;").replace(/>/g, "&gt;") : str;
2380}
2381/**
2382 * Set text value. If there's multiline add nodes.
2383 * @param {d3Selection} node Text node
2384 * @param {string} text Text value string
2385 * @param {Array} dy dy value for multilined text
2386 * @param {boolean} toMiddle To be alingned vertically middle
2387 * @private
2388 */
2389
2390
2391function setTextValue(node, text, dy, toMiddle) {
2392 if (dy === void 0 && (dy = [-1, 1]), toMiddle === void 0 && (toMiddle = !1), node && isString(text)) if (text.indexOf("\n") === -1) node.text(text);else {
2393 var diff = [node.text(), text].map(function (v) {
2394 return v.replace(/[\s\n]/g, "");
2395 });
2396
2397 if (diff[0] !== diff[1]) {
2398 var multiline = text.split("\n"),
2399 len = toMiddle ? multiline.length - 1 : 1;
2400 node.html(""), multiline.forEach(function (v, i) {
2401 node.append("tspan").attr("x", 0).attr("dy", (i === 0 ? dy[0] * len : dy[1]) + "em").text(v);
2402 });
2403 }
2404 }
2405}
2406/**
2407 * Substitution of SVGPathSeg API polyfill
2408 * @param {SVGGraphicsElement} path Target svg element
2409 * @returns {Array}
2410 * @private
2411 */
2412
2413
2414function getRectSegList(path) {
2415 /*
2416 * seg1 ---------- seg2
2417 * | |
2418 * | |
2419 * | |
2420 * seg0 ---------- seg3
2421 * */
2422 var _path$getBBox = path.getBBox(),
2423 x = _path$getBBox.x,
2424 y = _path$getBBox.y,
2425 width = _path$getBBox.width,
2426 height = _path$getBBox.height;
2427
2428 return [{
2429 x: x,
2430 y: y + height
2431 }, // seg0
2432 {
2433 x: x,
2434 y: y
2435 }, // seg1
2436 {
2437 x: x + width,
2438 y: y
2439 }, // seg2
2440 {
2441 x: x + width,
2442 y: y + height
2443 } // seg3
2444 ];
2445}
2446/**
2447 * Get svg bounding path box dimension
2448 * @param {SVGGraphicsElement} path Target svg element
2449 * @returns {object}
2450 * @private
2451 */
2452
2453
2454function getPathBox(path) {
2455 var _path$getBoundingClie = path.getBoundingClientRect(),
2456 width = _path$getBoundingClie.width,
2457 height = _path$getBoundingClie.height,
2458 items = getRectSegList(path),
2459 x = items[0].x,
2460 y = Math.min(items[0].y, items[1].y);
2461
2462 return {
2463 x: x,
2464 y: y,
2465 width: width,
2466 height: height
2467 };
2468}
2469/**
2470 * Get event's current position coordinates
2471 * @param {object} event Event object
2472 * @param {SVGElement|HTMLElement} element Target element
2473 * @returns {Array} [x, y] Coordinates x, y array
2474 * @private
2475 */
2476
2477
2478function getPointer(event, element) {
2479 var touches = event && (event.touches || event.sourceEvent && event.sourceEvent.touches),
2480 pointer = event ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches ? touches[0] : event, element) : [0, 0];
2481 return pointer;
2482}
2483/**
2484 * Return brush selection array
2485 * @param {object} ctx Current instance
2486 * @returns {d3.brushSelection}
2487 * @private
2488 */
2489
2490
2491function getBrushSelection(ctx) {
2492 var selection,
2493 event = ctx.event,
2494 $el = ctx.$el,
2495 main = $el.subchart.main || $el.main;
2496 return event && event.type === "brush" ? selection = event.selection : main && (selection = main.select("." + config_classes.brush).node()) && (selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection)), selection;
2497}
2498/**
2499 * Get boundingClientRect.
2500 * Cache the evaluated value once it was called.
2501 * @param {HTMLElement} node Target element
2502 * @returns {object}
2503 * @private
2504 */
2505
2506
2507function getBoundingRect(node) {
2508 var needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
2509 return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
2510}
2511/**
2512 * Retrun random number
2513 * @param {boolean} asStr Convert returned value as string
2514 * @returns {number|string}
2515 * @private
2516 */
2517
2518
2519function getRandom(asStr) {
2520 asStr === void 0 && (asStr = !0);
2521 var rand = Math.random();
2522 return asStr ? rand + "" : rand;
2523}
2524/**
2525 * Find index based on binary search
2526 * @param {Array} arr Data array
2527 * @param {number} v Target number to find
2528 * @param {number} start Start index of data array
2529 * @param {number} end End index of data arr
2530 * @param {boolean} isRotated Weather is roted axis
2531 * @returns {number} Index number
2532 * @private
2533 */
2534
2535
2536function findIndex(arr, v, start, end, isRotated) {
2537 if (start > end) return -1;
2538 var mid = Math.floor((start + end) / 2),
2539 _arr$mid = arr[mid],
2540 x = _arr$mid.x,
2541 _arr$mid$w = _arr$mid.w,
2542 w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
2543 return isRotated && (x = arr[mid].y, w = arr[mid].h), v >= x && v <= x + w ? mid : v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
2544}
2545/**
2546 * Check if brush is empty
2547 * @param {object} ctx Bursh context
2548 * @returns {boolean}
2549 * @private
2550 */
2551
2552
2553function brushEmpty(ctx) {
2554 var selection = getBrushSelection(ctx);
2555 return !selection || selection[0] === selection[1];
2556}
2557/**
2558 * Deep copy object
2559 * @param {object} objectN Source object
2560 * @returns {object} Cloned object
2561 * @private
2562 */
2563
2564
2565function deepClone() {
2566 for (var clone = function (_clone) {
2567 function clone() {
2568 return _clone.apply(this, arguments);
2569 }
2570
2571 return clone.toString = function () {
2572 return _clone.toString();
2573 }, clone;
2574 }(function (v) {
2575 if (isObject(v) && v.constructor) {
2576 var r = new v.constructor();
2577
2578 for (var k in v) r[k] = clone(v[k]);
2579
2580 return r;
2581 }
2582
2583 return v;
2584 }), _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) objectN[_key3] = arguments[_key3];
2585
2586 return objectN.map(function (v) {
2587 return clone(v);
2588 }).reduce(function (a, c) {
2589 return _objectSpread(_objectSpread({}, a), c);
2590 });
2591}
2592/**
2593 * Extend target from source object
2594 * @param {object} target Target object
2595 * @param {object|Array} source Source object
2596 * @returns {object}
2597 * @private
2598 */
2599
2600
2601function extend(target, source) {
2602 // exclude name with only numbers
2603 for (var p in target === void 0 && (target = {}), isArray(source) && source.forEach(function (v) {
2604 return extend(target, v);
2605 }), source) /^\d+$/.test(p) || p in target || (target[p] = source[p]);
2606
2607 return target;
2608}
2609/**
2610 * Return first letter capitalized
2611 * @param {string} str Target string
2612 * @returns {string} capitalized string
2613 * @private
2614 */
2615
2616
2617var capitalize = function (str) {
2618 return str.charAt(0).toUpperCase() + str.slice(1);
2619},
2620 toArray = function (v) {
2621 return [].slice.call(v);
2622};
2623/**
2624 * Convert to array
2625 * @param {object} v Target to be converted
2626 * @returns {Array}
2627 * @private
2628 */
2629
2630
2631/**
2632 * Get css rules for specified stylesheets
2633 * @param {Array} styleSheets The stylesheets to get the rules from
2634 * @returns {Array}
2635 * @private
2636 */
2637function getCssRules(styleSheets) {
2638 var rules = [];
2639 return styleSheets.forEach(function (sheet) {
2640 try {
2641 sheet.cssRules && sheet.cssRules.length && (rules = rules.concat(toArray(sheet.cssRules)));
2642 } catch (e) {
2643 console.error("Error while reading rules from " + sheet.href + ": " + e.toString());
2644 }
2645 }), rules;
2646}
2647/**
2648 * Gets the SVGMatrix of an SVGGElement
2649 * @param {SVGElement} node Node element
2650 * @returns {SVGMatrix} matrix
2651 * @private
2652 */
2653
2654
2655var getTranslation = function (node) {
2656 var transform = node ? node.transform : null,
2657 baseVal = transform && transform.baseVal;
2658 return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
2659 a: 0,
2660 b: 0,
2661 c: 0,
2662 d: 0,
2663 e: 0,
2664 f: 0
2665 };
2666};
2667/**
2668 * Get unique value from array
2669 * @param {Array} data Source data
2670 * @returns {Array} Unique array value
2671 * @private
2672 */
2673
2674
2675function getUnique(data) {
2676 var isDate = data[0] instanceof Date,
2677 d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
2678 return self.indexOf(v) === i;
2679 });
2680 return isDate ? d.map(function (v) {
2681 return new Date(v);
2682 }) : d;
2683}
2684/**
2685 * Merge array
2686 * @param {Array} arr Source array
2687 * @returns {Array}
2688 * @private
2689 */
2690
2691
2692function mergeArray(arr) {
2693 return arr && arr.length ? arr.reduce(function (p, c) {
2694 return p.concat(c);
2695 }) : [];
2696}
2697/**
2698 * Merge object returning new object
2699 * @param {object} target Target object
2700 * @param {object} objectN Source object
2701 * @returns {object} merged target object
2702 * @private
2703 */
2704
2705
2706function mergeObj(target) {
2707 for (var _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) objectN[_key4 - 1] = arguments[_key4];
2708
2709 if (!objectN.length || objectN.length === 1 && !objectN[0]) return target;
2710 var source = objectN.shift();
2711 return isObject(target) && isObject(source) && Object.keys(source).forEach(function (key) {
2712 var value = source[key];
2713 isObject(value) ? (!target[key] && (target[key] = {}), target[key] = mergeObj(target[key], value)) : target[key] = isArray(value) ? value.concat() : value;
2714 }), mergeObj.apply(void 0, [target].concat(objectN));
2715}
2716/**
2717 * Sort value
2718 * @param {Array} data value to be sorted
2719 * @param {boolean} isAsc true: asc, false: desc
2720 * @returns {number|string|Date} sorted date
2721 * @private
2722 */
2723
2724
2725function sortValue(data, isAsc) {
2726 isAsc === void 0 && (isAsc = !0);
2727 var fn;
2728 return data[0] instanceof Date ? fn = isAsc ? function (a, b) {
2729 return a - b;
2730 } : function (a, b) {
2731 return b - a;
2732 } : isAsc && !data.every(isNaN) ? fn = function (a, b) {
2733 return a - b;
2734 } : !isAsc && (fn = function (a, b) {
2735 return a > b && -1 || a < b && 1 || a === b && 0;
2736 }), data.concat().sort(fn);
2737}
2738/**
2739 * Get min/max value
2740 * @param {string} type 'min' or 'max'
2741 * @param {Array} data Array data value
2742 * @returns {number|Date|undefined}
2743 * @private
2744 */
2745
2746
2747function getMinMax(type, data) {
2748 var res = data.filter(function (v) {
2749 return notEmpty(v);
2750 });
2751 return res.length ? isNumber(res[0]) ? res = Math[type].apply(Math, res) : res[0] instanceof Date && (res = sortValue(res, type === "min")[0]) : res = undefined, res;
2752}
2753/**
2754 * Get range
2755 * @param {number} start Start number
2756 * @param {number} end End number
2757 * @param {number} step Step number
2758 * @returns {Array}
2759 * @private
2760 */
2761
2762
2763var getRange = function (start, end, step) {
2764 step === void 0 && (step = 1);
2765 var res = [],
2766 n = Math.max(0, Math.ceil((end - start) / step)) | 0;
2767
2768 for (var i = start; i < n; i++) res.push(start + i * step);
2769
2770 return res;
2771},
2772 emulateEvent = {
2773 mouse: function () {
2774 var getParams = function () {
2775 return {
2776 bubbles: !1,
2777 cancelable: !1,
2778 screenX: 0,
2779 screenY: 0,
2780 clientX: 0,
2781 clientY: 0
2782 };
2783 };
2784
2785 try {
2786 return new MouseEvent("t"), function (el, eventType, params) {
2787 params === void 0 && (params = getParams()), el.dispatchEvent(new MouseEvent(eventType, params));
2788 };
2789 } catch (e) {
2790 // Polyfills DOM4 MouseEvent
2791 return function (el, eventType, params) {
2792 params === void 0 && (params = getParams());
2793 var mouseEvent = browser_doc.createEvent("MouseEvent"); // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
2794
2795 mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0, // the event's mouse click count
2796 params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null), el.dispatchEvent(mouseEvent);
2797 };
2798 }
2799 }(),
2800 touch: function touch(el, eventType, params) {
2801 var touchObj = new Touch(mergeObj({
2802 identifier: Date.now(),
2803 target: el,
2804 radiusX: 2.5,
2805 radiusY: 2.5,
2806 rotationAngle: 10,
2807 force: .5
2808 }, params));
2809 el.dispatchEvent(new TouchEvent(eventType, {
2810 cancelable: !0,
2811 bubbles: !0,
2812 shiftKey: !0,
2813 touches: [touchObj],
2814 targetTouches: [],
2815 changedTouches: [touchObj]
2816 }));
2817 }
2818}; // emulate event
2819
2820
2821/**
2822 * Process the template & return bound string
2823 * @param {string} tpl Template string
2824 * @param {object} data Data value to be replaced
2825 * @returns {string}
2826 * @private
2827 */
2828function tplProcess(tpl, data) {
2829 var res = tpl;
2830
2831 for (var x in data) res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
2832
2833 return res;
2834}
2835/**
2836 * Get parsed date value
2837 * (It must be called in 'ChartInternal' context)
2838 * @param {Date|string|number} date Value of date to be parsed
2839 * @returns {Date}
2840 * @private
2841 */
2842
2843
2844function parseDate(date) {
2845 var parsedDate;
2846 if (date instanceof Date) parsedDate = date;else if (isString(date)) {
2847 var config = this.config,
2848 format = this.format;
2849 parsedDate = format.dataTime(config.data_xFormat)(date);
2850 } else isNumber(date) && !isNaN(date) && (parsedDate = new Date(+date));
2851 return (!parsedDate || isNaN(+parsedDate)) && console && console.error && console.error("Failed to parse x '" + date + "' to Date object"), parsedDate;
2852}
2853/**
2854 * Return if the current doc is visible or not
2855 * @returns {boolean}
2856 * @private
2857 */
2858
2859
2860function isTabVisible() {
2861 return !browser_doc.hidden;
2862}
2863/**
2864 * Get the current input type
2865 * @param {boolean} mouse Config value: interaction.inputType.mouse
2866 * @param {boolean} touch Config value: interaction.inputType.touch
2867 * @returns {string} "mouse" | "touch" | null
2868 * @private
2869 */
2870
2871
2872function convertInputType(mouse, touch) {
2873 var isMobile = !1; // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#Mobile_Tablet_or_Desktop
2874
2875 if (/Mobi/.test(win.navigator.userAgent) && touch) {
2876 // Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
2877 var hasTouchPoints = win.navigator && "maxTouchPoints" in win.navigator && win.navigator.maxTouchPoints > 0,
2878 hasTouch = "ontouchmove" in win || win.DocumentTouch && browser_doc instanceof win.DocumentTouch; // Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
2879 // On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
2880
2881 isMobile = hasTouchPoints || hasTouch;
2882 }
2883
2884 var hasMouse = !(!mouse || isMobile) && "onmouseover" in win;
2885 return hasMouse && "mouse" || isMobile && "touch" || null;
2886}
2887;// CONCATENATED MODULE: ./src/config/Options/Options.ts
2888
2889
2890function Options_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2891
2892function Options_objectSpread(target) { for (var source, i = 1; i < arguments.length; i++) source = arguments[i] == null ? {} : arguments[i], i % 2 ? Options_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : Options_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); return target; }
2893
2894/**
2895 * Copyright (c) 2017 ~ present NAVER Corp.
2896 * billboard.js project is licensed under the MIT license
2897 */
2898// common
2899
2900
2901
2902
2903
2904
2905
2906
2907/**
2908 * Class to set options on generating chart.
2909 * - It's instantiated internally, not exposed for public.
2910 * @class Options
2911 * @see {@link bb.generate} to use these options on generating the chart
2912 */
2913
2914var Options = /*#__PURE__*/function () {
2915 function Options() {
2916 return deepClone(main, data, color, interaction, legend, title, tooltip, Options.data);
2917 }
2918
2919 return Options.setOptions = function setOptions(options) {
2920 this.data = options.reduce(function (a, c) {
2921 return Options_objectSpread(Options_objectSpread({}, a), c);
2922 }, this.data);
2923 }, Options;
2924}();
2925
2926Options.data = {};
2927
2928;// CONCATENATED MODULE: ./src/module/Cache.ts
2929/**
2930 * Copyright (c) 2017 ~ present NAVER Corp.
2931 * billboard.js project is licensed under the MIT license
2932 */
2933
2934
2935/**
2936 * Constant for cache key
2937 * - NOTE: Prefixed with '$', will be resetted when .load() is called
2938 * @private
2939 */
2940var KEY = {
2941 bubbleBaseLength: "$baseLength",
2942 colorPattern: "__colorPattern__",
2943 dataMinMax: "$dataMinMax",
2944 dataTotalSum: "$dataTotalSum",
2945 dataTotalPerIndex: "$totalPerIndex",
2946 legendItemTextBox: "legendItemTextBox",
2947 radarPoints: "$radarPoints",
2948 setOverOut: "setOverOut",
2949 callOverOutForTouch: "callOverOutForTouch",
2950 textRect: "textRect"
2951};
2952
2953var Cache = /*#__PURE__*/function () {
2954 function Cache() {
2955 this.cache = {};
2956 }
2957
2958 var _proto = Cache.prototype;
2959 return _proto.add =
2960 /**
2961 * Add cache
2962 * @param {string} key Cache key
2963 * @param {*} value Value to be stored
2964 * @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
2965 * @returns {*} Added data value
2966 * @private
2967 */
2968 function add(key, value, isDataType) {
2969 return isDataType === void 0 && (isDataType = !1), this.cache[key] = isDataType ? this.cloneTarget(value) : value, this.cache[key];
2970 }
2971 /**
2972 * Remove cache
2973 * @param {string|Array} key Cache key
2974 * @private
2975 */
2976 , _proto.remove = function remove(key) {
2977 var _this = this;
2978
2979 toArray(key).forEach(function (v) {
2980 return delete _this.cache[v];
2981 });
2982 }
2983 /**
2984 * Get cahce
2985 * @param {string|Array} key Cache key
2986 * @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
2987 * @returns {*}
2988 * @private
2989 */
2990 , _proto.get = function get(key, isDataType) {
2991 if (isDataType === void 0 && (isDataType = !1), isDataType) {
2992 for (var id, targets = [], i = 0; id = key[i]; i++) id in this.cache && targets.push(this.cloneTarget(this.cache[id]));
2993
2994 return targets;
2995 }
2996
2997 var value = this.cache[key];
2998 return isValue(value) ? value : null;
2999 }
3000 /**
3001 * Reset cached data
3002 * @param {boolean} all true: reset all data, false: reset only '$' prefixed key data
3003 * @private
3004 */
3005 , _proto.reset = function reset(all) {
3006 var $$ = this;
3007
3008 for (var x in $$.cache) (all || /^\$/.test(x)) && ($$.cache[x] = null);
3009 }
3010 /**
3011 * Clone data target object
3012 * @param {object} target Data object
3013 * @returns {object}
3014 * @private
3015 */
3016 // eslint-disable-next-line camelcase
3017 , _proto.cloneTarget = function cloneTarget(target) {
3018 return {
3019 id: target.id,
3020 id_org: target.id_org,
3021 values: target.values.map(function (d) {
3022 return {
3023 x: d.x,
3024 value: d.value,
3025 id: d.id
3026 };
3027 })
3028 };
3029 }, Cache;
3030}();
3031
3032
3033;// CONCATENATED MODULE: ./src/module/generator.ts
3034/**
3035 * Copyright (c) 2017 ~ present NAVER Corp.
3036 * billboard.js project is licensed under the MIT license
3037 */
3038
3039
3040var generator_setTimeout = win.setTimeout,
3041 generator_clearTimeout = win.clearTimeout;
3042/**
3043 * Generate resize queue function
3044 * @returns {Fucntion}
3045 * @private
3046 */
3047
3048function generateResize() {
3049 var timeout,
3050 fn = [],
3051 callResizeFn = function () {
3052 callResizeFn.clear(), timeout = generator_setTimeout(function () {
3053 fn.forEach(function (f) {
3054 return f();
3055 });
3056 }, 200);
3057 };
3058
3059 return callResizeFn.clear = function () {
3060 timeout && (generator_clearTimeout(timeout), timeout = null);
3061 }, callResizeFn.add = function (f) {
3062 return fn.push(f);
3063 }, callResizeFn.remove = function (f) {
3064 return fn.splice(fn.indexOf(f), 1);
3065 }, callResizeFn;
3066}
3067/**
3068 * Generate transition queue function
3069 * @returns {Function}
3070 * @private
3071 */
3072
3073function generateWait() {
3074 var transitionsToWait = [],
3075 f = function (t, callback) {
3076 // eslint-disable-next-line
3077 function loop() {
3078 for (var _t, done = 0, i = 0; _t = transitionsToWait[i]; i++) {
3079 if (_t === !0 || _t.empty && _t.empty()) {
3080 done++;
3081 continue;
3082 }
3083
3084 try {
3085 _t.transition();
3086 } catch (e) {
3087 done++;
3088 }
3089 }
3090
3091 timer && generator_clearTimeout(timer), done === transitionsToWait.length ? callback && callback() : timer = generator_setTimeout(loop, 50);
3092 }
3093
3094 var timer;
3095 loop();
3096 };
3097
3098 return f.add = function (t) {
3099 isArray(t) ? transitionsToWait = transitionsToWait.concat(t) : transitionsToWait.push(t);
3100 }, f;
3101}
3102// EXTERNAL MODULE: external {"commonjs":"d3-dsv","commonjs2":"d3-dsv","amd":"d3-dsv","root":"d3"}
3103var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_require__(5);
3104;// CONCATENATED MODULE: ./src/ChartInternal/data/convert.ts
3105/**
3106 * Copyright (c) 2017 ~ present NAVER Corp.
3107 * billboard.js project is licensed under the MIT license
3108 */
3109
3110
3111/**
3112 * Data convert
3113 * @memberof ChartInternal
3114 * @private
3115 */
3116
3117/* harmony default export */ var convert = ({
3118 /**
3119 * Convert data according its type
3120 * @param {object} args data object
3121 * @param {Function} [callback] callback for url(XHR) type loading
3122 * @returns {object}
3123 * @private
3124 */
3125 convertData: function convertData(args, callback) {
3126 var data;
3127 if (args.bindto ? (data = {}, ["url", "mimeType", "headers", "keys", "json", "keys", "rows", "columns"].forEach(function (v) {
3128 var key = "data_" + v;
3129 key in args && (data[v] = args[key]);
3130 })) : data = args, data.url && callback) this.convertUrlToData(data.url, data.mimeType, data.headers, data.keys, callback);else if (data.json) data = this.convertJsonToData(data.json, data.keys);else if (data.rows) data = this.convertRowsToData(data.rows);else if (data.columns) data = this.convertColumnsToData(data.columns);else if (args.bindto) throw Error("url or json or rows or columns is required.");
3131 return isArray(data) && data;
3132 },
3133
3134 /**
3135 * Convert URL data
3136 * @param {string} url Remote URL
3137 * @param {string} mimeType MIME type string: json | csv | tsv
3138 * @param {object} headers Header object
3139 * @param {object} keys Key object
3140 * @param {Function} done Callback function
3141 * @private
3142 */
3143 convertUrlToData: function convertUrlToData(url, mimeType, headers, keys, done) {
3144 var _this = this;
3145
3146 mimeType === void 0 && (mimeType = "csv");
3147 var req = new XMLHttpRequest();
3148 req.open("GET", url), headers && Object.keys(headers).forEach(function (key) {
3149 req.setRequestHeader(key, headers[key]);
3150 }), req.onreadystatechange = function () {
3151 if (req.readyState === 4) if (req.status === 200) {
3152 var response = req.responseText;
3153 response && done.call(_this, _this["convert" + capitalize(mimeType) + "ToData"](mimeType === "json" ? JSON.parse(response) : response, keys));
3154 } else throw new Error(url + ": Something went wrong loading!");
3155 }, req.send();
3156 },
3157
3158 /**
3159 * Convert CSV/TSV data
3160 * @param {object} parser Parser object
3161 * @param {object} xsv Data
3162 * @private
3163 * @returns {object}
3164 */
3165 convertCsvTsvToData: function convertCsvTsvToData(parser, xsv) {
3166 var d,
3167 rows = parser.rows(xsv);
3168 return rows.length === 1 ? (d = [{}], rows[0].forEach(function (id) {
3169 d[0][id] = null;
3170 })) : d = parser.parse(xsv), d;
3171 },
3172 convertCsvToData: function convertCsvToData(xsv) {
3173 return this.convertCsvTsvToData({
3174 rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParseRows,
3175 parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParse
3176 }, xsv);
3177 },
3178 convertTsvToData: function convertTsvToData(tsv) {
3179 return this.convertCsvTsvToData({
3180 rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParseRows,
3181 parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParse
3182 }, tsv);
3183 },
3184 convertJsonToData: function convertJsonToData(json, keysParam) {
3185 var targetKeys,
3186 data,
3187 _this2 = this,
3188 config = this.config,
3189 newRows = [];
3190
3191 if (isArray(json)) {
3192 var keys = keysParam || config.data_keys;
3193 keys.x ? (targetKeys = keys.value.concat(keys.x), config.data_x = keys.x) : targetKeys = keys.value, newRows.push(targetKeys), json.forEach(function (o) {
3194 var newRow = targetKeys.map(function (key) {
3195 // convert undefined to null because undefined data will be removed in convertDataToTargets()
3196 var v = _this2.findValueInJson(o, key);
3197
3198 return isUndefined(v) && (v = null), v;
3199 });
3200 newRows.push(newRow);
3201 }), data = this.convertRowsToData(newRows);
3202 } else Object.keys(json).forEach(function (key) {
3203 var tmp = json[key].concat();
3204 tmp.unshift(key), newRows.push(tmp);
3205 }), data = this.convertColumnsToData(newRows);
3206
3207 return data;
3208 },
3209 findValueInJson: function findValueInJson(object, path) {
3210 if (object[path] !== undefined) return object[path];
3211 var convertedPath = path.replace(/\[(\w+)\]/g, ".$1"),
3212 pathArray = convertedPath.replace(/^\./, "").split("."),
3213 target = object; // convert indexes to properties (replace [] with .)
3214
3215 return pathArray.some(function (k) {
3216 return !(target = target && k in target ? target[k] : undefined);
3217 }), target;
3218 },
3219 convertRowsToData: function convertRowsToData(rows) {
3220 var keys = rows[0],
3221 newRows = [];
3222 return rows.forEach(function (row, i) {
3223 if (i > 0) {
3224 var newRow = {};
3225 row.forEach(function (v, j) {
3226 if (isUndefined(v)) throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
3227 newRow[keys[j]] = v;
3228 }), newRows.push(newRow);
3229 }
3230 }), newRows;
3231 },
3232 convertColumnsToData: function convertColumnsToData(columns) {
3233 var newRows = [];
3234 return columns.forEach(function (col, i) {
3235 var key = col[0];
3236 col.forEach(function (v, j) {
3237 if (j > 0) {
3238 if (isUndefined(newRows[j - 1]) && (newRows[j - 1] = {}), isUndefined(v)) throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
3239 newRows[j - 1][key] = v;
3240 }
3241 });
3242 }), newRows;
3243 },
3244 convertDataToTargets: function convertDataToTargets(data, appendXs) {
3245 var _this3 = this,
3246 $$ = this,
3247 axis = $$.axis,
3248 config = $$.config,
3249 state = $$.state,
3250 isCategorized = !1,
3251 isTimeSeries = !1,
3252 isCustomX = !1;
3253
3254 axis && (isCategorized = axis.isCategorized(), isTimeSeries = axis.isTimeSeries(), isCustomX = axis.isCustomX());
3255 var xsData,
3256 dataKeys = Object.keys(data[0] || {}),
3257 ids = dataKeys.length ? dataKeys.filter($$.isNotX, $$) : [],
3258 xs = dataKeys.length ? dataKeys.filter($$.isX, $$) : [];
3259 ids.forEach(function (id) {
3260 var xKey = _this3.getXKey(id);
3261
3262 isCustomX || isTimeSeries ? xs.indexOf(xKey) >= 0 ? xsData = (appendXs && $$.data.xs[id] || []).concat(data.map(function (d) {
3263 return d[xKey];
3264 }).filter(isValue).map(function (rawX, i) {
3265 return $$.generateTargetX(rawX, id, i);
3266 })) : config.data_x ? xsData = _this3.getOtherTargetXs() : notEmpty(config.data_xs) && (xsData = $$.getXValuesOfXKey(xKey, $$.data.targets)) : xsData = data.map(function (d, i) {
3267 return i;
3268 }), xsData && (_this3.data.xs[id] = xsData);
3269 }), ids.forEach(function (id) {
3270 if (!_this3.data.xs[id]) throw new Error("x is not defined for id = \"" + id + "\".");
3271 });
3272 // convert to target
3273 var targets = ids.map(function (id, index) {
3274 var convertedId = config.data_idConverter.bind($$.api)(id),
3275 xKey = $$.getXKey(id),
3276 isCategory = isCustomX && isCategorized,
3277 hasCategory = isCategory && data.map(function (v) {
3278 return v.x;
3279 }).every(function (v) {
3280 return config.axis_x_categories.indexOf(v) > -1;
3281 });
3282 return {
3283 id: convertedId,
3284 id_org: id,
3285 values: data.map(function (d, i) {
3286 var x,
3287 rawX = d[xKey],
3288 value = d[id];
3289 return value = value === null || isNaN(value) || isObject(value) ? isArray(value) || isObject(value) ? value : null : +value, (isCategory || state.hasRadar) && index === 0 && !isUndefined(rawX) ? (!hasCategory && index === 0 && i === 0 && (config.axis_x_categories = []), x = config.axis_x_categories.indexOf(rawX), x === -1 && (x = config.axis_x_categories.length, config.axis_x_categories.push(rawX))) : x = $$.generateTargetX(rawX, id, i), (isUndefined(value) || $$.data.xs[id].length <= i) && (x = undefined), {
3290 x: x,
3291 value: value,
3292 id: convertedId
3293 };
3294 }).filter(function (v) {
3295 return isDefined(v.x);
3296 })
3297 };
3298 }); // finish targets
3299
3300 return targets.forEach(function (t) {
3301 config.data_xSort && (t.values = t.values.sort(function (v1, v2) {
3302 var x1 = v1.x || v1.x === 0 ? v1.x : Infinity,
3303 x2 = v2.x || v2.x === 0 ? v2.x : Infinity;
3304 return x1 - x2;
3305 })), t.values.forEach(function (v, i) {
3306 return v.index = i;
3307 }), $$.data.xs[t.id].sort(function (v1, v2) {
3308 return v1 - v2;
3309 });
3310 }), state.hasNegativeValue = $$.hasNegativeValueInTargets(targets), state.hasPositiveValue = $$.hasPositiveValueInTargets(targets), config.data_type && $$.setTargetType($$.mapToIds(targets).filter(function (id) {
3311 return !(id in config.data_types);
3312 }), config.data_type), targets.forEach(function (d) {
3313 return $$.cache.add(d.id_org, d, !0);
3314 }), targets;
3315 }
3316});
3317;// CONCATENATED MODULE: ./src/ChartInternal/data/data.ts
3318/**
3319 * Copyright (c) 2017 ~ present NAVER Corp.
3320 * billboard.js project is licensed under the MIT license
3321 */
3322
3323
3324
3325/* harmony default export */ var data_data = ({
3326 isX: function isX(key) {
3327 var $$ = this,
3328 config = $$.config,
3329 dataKey = config.data_x && key === config.data_x,
3330 existValue = notEmpty(config.data_xs) && hasValue(config.data_xs, key);
3331 return dataKey || existValue;
3332 },
3333 isNotX: function isNotX(key) {
3334 return !this.isX(key);
3335 },
3336 isStackNormalized: function isStackNormalized() {
3337 var config = this.config;
3338 return !!(config.data_stack_normalize && config.data_groups.length);
3339 },
3340 isGrouped: function isGrouped(id) {
3341 var groups = this.config.data_groups;
3342 return id ? groups.some(function (v) {
3343 return v.indexOf(id) >= 0 && v.length > 1;
3344 }) : groups.length > 0;
3345 },
3346 getXKey: function getXKey(id) {
3347 var $$ = this,
3348 config = $$.config;
3349 return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null;
3350 },
3351 getXValuesOfXKey: function getXValuesOfXKey(key, targets) {
3352 var xValues,
3353 $$ = this,
3354 ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : [];
3355 return ids.forEach(function (id) {
3356 $$.getXKey(id) === key && (xValues = $$.data.xs[id]);
3357 }), xValues;
3358 },
3359
3360 /**
3361 * Get index number based on given x Axis value
3362 * @param {Date|number|string} x x Axis to be compared
3363 * @param {Array} basedX x Axis list to be based on
3364 * @returns {number} index number
3365 * @private
3366 */
3367 getIndexByX: function getIndexByX(x, basedX) {
3368 var $$ = this;
3369 return basedX ? basedX.indexOf(isString(x) ? x : +x) : ($$.filterByX($$.data.targets, x)[0] || {
3370 index: null
3371 }).index;
3372 },
3373 getXValue: function getXValue(id, i) {
3374 var $$ = this;
3375 return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i;
3376 },
3377 getOtherTargetXs: function getOtherTargetXs() {
3378 var $$ = this,
3379 idsForX = Object.keys($$.data.xs);
3380 return idsForX.length ? $$.data.xs[idsForX[0]] : null;
3381 },
3382 getOtherTargetX: function getOtherTargetX(index) {
3383 var xs = this.getOtherTargetXs();
3384 return xs && index < xs.length ? xs[index] : null;
3385 },
3386 addXs: function addXs(xs) {
3387 var $$ = this,
3388 config = $$.config;
3389 Object.keys(xs).forEach(function (id) {
3390 config.data_xs[id] = xs[id];
3391 });
3392 },
3393 isMultipleX: function isMultipleX() {
3394 return notEmpty(this.config.data_xs) || !this.config.data_xSort || this.hasType("bubble") || this.hasType("scatter");
3395 },
3396 addName: function addName(data) {
3397 var name,
3398 $$ = this,
3399 config = $$.config;
3400 return data && (name = config.data_names[data.id], data.name = name === undefined ? data.id : name), data;
3401 },
3402
3403 /**
3404 * Get all values on given index
3405 * @param {number} index Index
3406 * @param {boolean} filterNull Filter nullish value
3407 * @returns {Array}
3408 * @private
3409 */
3410 getAllValuesOnIndex: function getAllValuesOnIndex(index, filterNull) {
3411 filterNull === void 0 && (filterNull = !1);
3412 var $$ = this,
3413 value = $$.filterTargetsToShow($$.data.targets).map(function (t) {
3414 return $$.addName($$.getValueOnIndex(t.values, index));
3415 });
3416 return filterNull && (value = value.filter(function (v) {
3417 return isValue(v.value);
3418 })), value;
3419 },
3420 getValueOnIndex: function getValueOnIndex(values, index) {
3421 var valueOnIndex = values.filter(function (v) {
3422 return v.index === index;
3423 });
3424 return valueOnIndex.length ? valueOnIndex[0] : null;
3425 },
3426 updateTargetX: function updateTargetX(targets, x) {
3427 var $$ = this;
3428 targets.forEach(function (t) {
3429 t.values.forEach(function (v, i) {
3430 v.x = $$.generateTargetX(x[i], t.id, i);
3431 }), $$.data.xs[t.id] = x;
3432 });
3433 },
3434 updateTargetXs: function updateTargetXs(targets, xs) {
3435 var $$ = this;
3436 targets.forEach(function (t) {
3437 xs[t.id] && $$.updateTargetX([t], xs[t.id]);
3438 });
3439 },
3440 generateTargetX: function generateTargetX(rawX, id, index) {
3441 var $$ = this,
3442 axis = $$.axis,
3443 x = axis && axis.isCategorized() ? index : rawX || index;
3444
3445 if (axis && axis.isTimeSeries()) {
3446 var fn = parseDate.bind($$);
3447 x = rawX ? fn(rawX) : fn($$.getXValue(id, index));
3448 } else axis && axis.isCustomX() && !axis.isCategorized() && (x = isValue(rawX) ? +rawX : $$.getXValue(id, index));
3449
3450 return x;
3451 },
3452 updateXs: function updateXs(values) {
3453 values.length && (this.axis.xs = values.map(function (v) {
3454 return v.x;
3455 }));
3456 },
3457 getPrevX: function getPrevX(i) {
3458 var x = this.axis.xs[i - 1];
3459 return isDefined(x) ? x : null;
3460 },
3461 getNextX: function getNextX(i) {
3462 var x = this.axis.xs[i + 1];
3463 return isDefined(x) ? x : null;
3464 },
3465
3466 /**
3467 * Get base value isAreaRangeType
3468 * @param {object} data Data object
3469 * @returns {number}
3470 * @private
3471 */
3472 getBaseValue: function getBaseValue(data) {
3473 var $$ = this,
3474 hasAxis = $$.state.hasAxis,
3475 value = data.value;
3476 return value && hasAxis && ($$.isAreaRangeType(data) ? value = $$.getRangedData(data, "mid") : $$.isBubbleZType(data) && (value = $$.getBubbleZData(value, "y"))), value;
3477 },
3478
3479 /**
3480 * Get min/max value from the data
3481 * @private
3482 * @param {Array} data array data to be evaluated
3483 * @returns {{min: {number}, max: {number}}}
3484 */
3485 getMinMaxValue: function getMinMaxValue(data) {
3486 var min,
3487 max,
3488 getBaseValue = this.getBaseValue.bind(this);
3489 return (data || this.data.targets.map(function (t) {
3490 return t.values;
3491 })).forEach(function (v, i) {
3492 var value = v.map(getBaseValue).filter(isNumber);
3493 min = Math.min.apply(Math, [i ? min : Infinity].concat(value)), max = Math.max.apply(Math, [i ? max : -Infinity].concat(value));
3494 }), {
3495 min: min,
3496 max: max
3497 };
3498 },
3499
3500 /**
3501 * Get the min/max data
3502 * @private
3503 * @returns {{min: Array, max: Array}}
3504 */
3505 getMinMaxData: function getMinMaxData() {
3506 var $$ = this,
3507 cacheKey = KEY.dataMinMax,
3508 minMaxData = $$.cache.get(cacheKey);
3509
3510 if (!minMaxData) {
3511 var data = $$.data.targets.map(function (t) {
3512 return t.values;
3513 }),
3514 minMax = $$.getMinMaxValue(data),
3515 min = [],
3516 max = [];
3517 // update the cached data
3518 data.forEach(function (v) {
3519 var minData = $$.getFilteredDataByValue(v, minMax.min),
3520 maxData = $$.getFilteredDataByValue(v, minMax.max);
3521 minData.length && (min = min.concat(minData)), maxData.length && (max = max.concat(maxData));
3522 }), $$.cache.add(cacheKey, minMaxData = {
3523 min: min,
3524 max: max
3525 });
3526 }
3527
3528 return minMaxData;
3529 },
3530
3531 /**
3532 * Get sum of data per index
3533 * @private
3534 * @returns {Array}
3535 */
3536 getTotalPerIndex: function getTotalPerIndex() {
3537 var $$ = this,
3538 cacheKey = KEY.dataTotalPerIndex,
3539 sum = $$.cache.get(cacheKey);
3540 return $$.isStackNormalized() && !sum && (sum = [], $$.data.targets.forEach(function (row) {
3541 row.values.forEach(function (v, i) {
3542 sum[i] || (sum[i] = 0), sum[i] += isNumber(v.value) ? v.value : 0;
3543 });
3544 })), sum;
3545 },
3546
3547 /**
3548 * Get total data sum
3549 * @param {boolean} subtractHidden Subtract hidden data from total
3550 * @returns {number}
3551 * @private
3552 */
3553 getTotalDataSum: function getTotalDataSum(subtractHidden) {
3554 var $$ = this,
3555 cacheKey = KEY.dataTotalSum,
3556 total = $$.cache.get(cacheKey);
3557
3558 if (!isNumber(total)) {
3559 var sum = mergeArray($$.data.targets.map(function (t) {
3560 return t.values;
3561 })).map(function (v) {
3562 return v.value;
3563 }).reduce(function (p, c) {
3564 return p + c;
3565 });
3566 $$.cache.add(cacheKey, total = sum);
3567 }
3568
3569 return subtractHidden && (total -= $$.getHiddenTotalDataSum()), total;
3570 },
3571
3572 /**
3573 * Get total hidden data sum
3574 * @returns {number}
3575 * @private
3576 */
3577 getHiddenTotalDataSum: function getHiddenTotalDataSum() {
3578 var $$ = this,
3579 api = $$.api,
3580 hiddenTargetIds = $$.state.hiddenTargetIds,
3581 total = 0;
3582 return hiddenTargetIds.length && (total = api.data.values.bind(api)(hiddenTargetIds).reduce(function (p, c) {
3583 return p + c;
3584 })), total;
3585 },
3586
3587 /**
3588 * Get filtered data by value
3589 * @param {object} data Data
3590 * @param {number} value Value to be filtered
3591 * @returns {Array} filtered array data
3592 * @private
3593 */
3594 getFilteredDataByValue: function getFilteredDataByValue(data, value) {
3595 var _this = this;
3596
3597 return data.filter(function (t) {
3598 return _this.getBaseValue(t) === value;
3599 });
3600 },
3601
3602 /**
3603 * Return the max length of the data
3604 * @returns {number} max data length
3605 * @private
3606 */
3607 getMaxDataCount: function getMaxDataCount() {
3608 return Math.max.apply(Math, this.data.targets.map(function (t) {
3609 return t.values.length;
3610 }));
3611 },
3612 getMaxDataCountTarget: function getMaxDataCountTarget() {
3613 var target = this.filterTargetsToShow() || [],
3614 length = target.length;
3615 return length > 1 ? (target = target.map(function (t) {
3616 return t.values;
3617 }).reduce(function (a, b) {
3618 return a.concat(b);
3619 }).map(function (v) {
3620 return v.x;
3621 }), target = sortValue(getUnique(target)).map(function (x, index) {
3622 return {
3623 x: x,
3624 index: index
3625 };
3626 })) : length && (target = target[0].values), target;
3627 },
3628 mapToIds: function mapToIds(targets) {
3629 return targets.map(function (d) {
3630 return d.id;
3631 });
3632 },
3633 mapToTargetIds: function mapToTargetIds(ids) {
3634 var $$ = this;
3635 return ids ? isArray(ids) ? ids.concat() : [ids] : $$.mapToIds($$.data.targets);
3636 },
3637 hasTarget: function hasTarget(targets, id) {
3638 var ids = this.mapToIds(targets);
3639
3640 for (var val, i = 0; val = ids[i]; i++) if (val === id) return !0;
3641
3642 return !1;
3643 },
3644 isTargetToShow: function isTargetToShow(targetId) {
3645 return this.state.hiddenTargetIds.indexOf(targetId) < 0;
3646 },
3647 isLegendToShow: function isLegendToShow(targetId) {
3648 return this.state.hiddenLegendIds.indexOf(targetId) < 0;
3649 },
3650 filterTargetsToShow: function filterTargetsToShow(targets) {
3651 var $$ = this;
3652 return (targets || $$.data.targets).filter(function (t) {
3653 return $$.isTargetToShow(t.id);
3654 });
3655 },
3656 mapTargetsToUniqueXs: function mapTargetsToUniqueXs(targets) {
3657 var $$ = this,
3658 axis = $$.axis,
3659 xs = [];
3660 return targets && targets.length && (xs = getUnique(mergeArray(targets.map(function (t) {
3661 return t.values.map(function (v) {
3662 return +v.x;
3663 });
3664 }))), xs = axis && axis.isTimeSeries() ? xs.map(function (x) {
3665 return new Date(+x);
3666 }) : xs.map(function (x) {
3667 return +x;
3668 })), sortValue(xs);
3669 },
3670 addHiddenTargetIds: function addHiddenTargetIds(targetIds) {
3671 this.state.hiddenTargetIds = this.state.hiddenTargetIds.concat(targetIds);
3672 },
3673 removeHiddenTargetIds: function removeHiddenTargetIds(targetIds) {
3674 this.state.hiddenTargetIds = this.state.hiddenTargetIds.filter(function (id) {
3675 return targetIds.indexOf(id) < 0;
3676 });
3677 },
3678 addHiddenLegendIds: function addHiddenLegendIds(targetIds) {
3679 this.state.hiddenLegendIds = this.state.hiddenLegendIds.concat(targetIds);
3680 },
3681 removeHiddenLegendIds: function removeHiddenLegendIds(targetIds) {
3682 this.state.hiddenLegendIds = this.state.hiddenLegendIds.filter(function (id) {
3683 return targetIds.indexOf(id) < 0;
3684 });
3685 },
3686 getValuesAsIdKeyed: function getValuesAsIdKeyed(targets) {
3687 var $$ = this,
3688 hasAxis = $$.state.hasAxis,
3689 ys = {},
3690 isMultipleX = $$.isMultipleX(),
3691 xs = isMultipleX ? $$.mapTargetsToUniqueXs(targets).map(function (v) {
3692 return isString(v) ? v : +v;
3693 }) : null;
3694 return targets.forEach(function (t) {
3695 var data = [];
3696 t.values.filter(function (v) {
3697 return isValue(v.value);
3698 }).forEach(function (v) {
3699 var value = v.value; // exclude 'volume' value to correct mis domain calculation
3700
3701 $$.isCandlestickType(v) && (value = isArray(value) ? value.slice(0, 4) : [value.open, value.high, value.low, value.close]), isArray(value) ? data.push.apply(data, value) : isObject(value) && "high" in value ? data.push.apply(data, Object.values(value)) : $$.isBubbleZType(v) ? data.push(hasAxis && $$.getBubbleZData(value, "y")) : isMultipleX ? data[$$.getIndexByX(v.x, xs)] = value : data.push(value);
3702 }), ys[t.id] = data;
3703 }), ys;
3704 },
3705 checkValueInTargets: function checkValueInTargets(targets, checker) {
3706 var values,
3707 ids = Object.keys(targets);
3708
3709 for (var i = 0; i < ids.length; i++) {
3710 values = targets[ids[i]].values;
3711
3712 for (var j = 0; j < values.length; j++) if (checker(values[j].value)) return !0;
3713 }
3714
3715 return !1;
3716 },
3717 hasMultiTargets: function hasMultiTargets() {
3718 return this.filterTargetsToShow().length > 1;
3719 },
3720 hasNegativeValueInTargets: function hasNegativeValueInTargets(targets) {
3721 return this.checkValueInTargets(targets, function (v) {
3722 return v < 0;
3723 });
3724 },
3725 hasPositiveValueInTargets: function hasPositiveValueInTargets(targets) {
3726 return this.checkValueInTargets(targets, function (v) {
3727 return v > 0;
3728 });
3729 },
3730 _checkOrder: function _checkOrder(type) {
3731 var config = this.config,
3732 order = config.data_order;
3733 return isString(order) && order.toLowerCase() === type;
3734 },
3735 isOrderDesc: function isOrderDesc() {
3736 return this._checkOrder("desc");
3737 },
3738 isOrderAsc: function isOrderAsc() {
3739 return this._checkOrder("asc");
3740 },
3741
3742 /**
3743 * Sort targets data
3744 * @param {Array} targetsValue Target value
3745 * @returns {Array}
3746 * @private
3747 */
3748 orderTargets: function orderTargets(targetsValue) {
3749 var $$ = this,
3750 targets = [].concat(targetsValue),
3751 fn = $$.getSortCompareFn();
3752 return fn && targets.sort(fn), targets;
3753 },
3754
3755 /**
3756 * Get data.order compare function
3757 * @param {boolean} isArc Is for Arc type sort or not
3758 * @returns {Function} compare function
3759 * @private
3760 */
3761 getSortCompareFn: function getSortCompareFn(isArc) {
3762 isArc === void 0 && (isArc = !1);
3763 var fn,
3764 $$ = this,
3765 config = $$.config,
3766 orderAsc = $$.isOrderAsc(),
3767 orderDesc = $$.isOrderDesc();
3768 return orderAsc || orderDesc ? fn = function (t1, t2) {
3769 var reducer = function (p, c) {
3770 return p + Math.abs(c.value);
3771 },
3772 t1Sum = t1.values.reduce(reducer, 0),
3773 t2Sum = t2.values.reduce(reducer, 0);
3774
3775 return isArc ? orderAsc ? t1Sum - t2Sum : t2Sum - t1Sum : orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum;
3776 } : isFunction(config.data_order) && (fn = config.data_order.bind($$.api)), fn || null;
3777 },
3778 filterByX: function filterByX(targets, x) {
3779 return mergeArray(targets.map(function (t) {
3780 return t.values;
3781 })).filter(function (v) {
3782 return v.x - x === 0;
3783 });
3784 },
3785 filterRemoveNull: function filterRemoveNull(data) {
3786 var _this2 = this;
3787
3788 return data.filter(function (d) {
3789 return isValue(_this2.getBaseValue(d));
3790 });
3791 },
3792 filterByXDomain: function filterByXDomain(targets, xDomain) {
3793 return targets.map(function (t) {
3794 return {
3795 id: t.id,
3796 id_org: t.id_org,
3797 values: t.values.filter(function (v) {
3798 return xDomain[0] <= v.x && v.x <= xDomain[1];
3799 })
3800 };
3801 });
3802 },
3803 hasDataLabel: function hasDataLabel() {
3804 var dataLabels = this.config.data_labels;
3805 return isboolean(dataLabels) && dataLabels || isObjectType(dataLabels) && notEmpty(dataLabels);
3806 },
3807
3808 /**
3809 * Get data index from the event coodinates
3810 * @param {Event} event Event object
3811 * @returns {number}
3812 */
3813 getDataIndexFromEvent: function getDataIndexFromEvent(event) {
3814 var $$ = this,
3815 config = $$.config,
3816 _$$$state = $$.state,
3817 inputType = _$$$state.inputType,
3818 _$$$state$eventReceiv = _$$$state.eventReceiver,
3819 coords = _$$$state$eventReceiv.coords,
3820 rect = _$$$state$eventReceiv.rect,
3821 isRotated = config.axis_rotated,
3822 e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event,
3823 index = findIndex(coords, isRotated ? e.clientY - rect.top : e.clientX - rect.left, 0, coords.length - 1, isRotated);
3824 return index;
3825 },
3826 getDataLabelLength: function getDataLabelLength(min, max, key) {
3827 var $$ = this,
3828 lengths = [0, 0];
3829 return $$.$el.chart.select("svg").selectAll(".dummy").data([min, max]).enter().append("text").text(function (d) {
3830 return $$.dataLabelFormat(d.id)(d);
3831 }).each(function (d, i) {
3832 lengths[i] = this.getBoundingClientRect()[key] * 1.3;
3833 }).remove(), lengths;
3834 },
3835 isNoneArc: function isNoneArc(d) {
3836 return this.hasTarget(this.data.targets, d.id);
3837 },
3838 isArc: function isArc(d) {
3839 return "data" in d && this.hasTarget(this.data.targets, d.data.id);
3840 },
3841 findSameXOfValues: function findSameXOfValues(values, index) {
3842 var i,
3843 targetX = values[index].x,
3844 sames = [];
3845
3846 for (i = index - 1; i >= 0 && !(targetX !== values[i].x); i--) sames.push(values[i]);
3847
3848 for (i = index; i < values.length && !(targetX !== values[i].x); i++) sames.push(values[i]);
3849
3850 return sames;
3851 },
3852 findClosestFromTargets: function findClosestFromTargets(targets, pos) {
3853 var $$ = this,
3854 candidates = targets.map(function (target) {
3855 return $$.findClosest(target.values, pos);
3856 });
3857 // map to array of closest points of each target
3858 // decide closest point and return
3859 return $$.findClosest(candidates, pos);
3860 },
3861 findClosest: function findClosest(values, pos) {
3862 var closest,
3863 $$ = this,
3864 config = $$.config,
3865 main = $$.$el.main,
3866 data = values.filter(function (v) {
3867 return v && isValue(v.value);
3868 }),
3869 minDist = config.point_sensitivity;
3870 return data.filter(function (v) {
3871 return $$.isBarType(v.id);
3872 }).forEach(function (v) {
3873 var shape = main.select("." + config_classes.bars + $$.getTargetSelectorSuffix(v.id) + " ." + config_classes.bar + "-" + v.index).node();
3874 !closest && $$.isWithinBar(shape) && (closest = v);
3875 }), data.filter(function (v) {
3876 return !$$.isBarType(v.id);
3877 }).forEach(function (v) {
3878 var d = $$.dist(v, pos);
3879 d < minDist && (minDist = d, closest = v);
3880 }), closest;
3881 },
3882 dist: function dist(data, pos) {
3883 var $$ = this,
3884 isRotated = $$.config.axis_rotated,
3885 scale = $$.scale,
3886 xIndex = isRotated ? 1 : 0,
3887 yIndex = isRotated ? 0 : 1,
3888 y = $$.circleY(data, data.index),
3889 x = (scale.zoom || scale.x)(data.x);
3890 return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
3891 },
3892
3893 /**
3894 * Convert data for step type
3895 * @param {Array} values Object data values
3896 * @returns {Array}
3897 * @private
3898 */
3899 convertValuesToStep: function convertValuesToStep(values) {
3900 var $$ = this,
3901 axis = $$.axis,
3902 config = $$.config,
3903 stepType = config.line_step_type,
3904 isCategorized = !!axis && axis.isCategorized(),
3905 converted = isArray(values) ? values.concat() : [values];
3906 if (!(isCategorized || /step\-(after|before)/.test(stepType))) return values; // insert & append cloning first/last value to be fully rendered covering on each gap sides
3907
3908 var head = converted[0],
3909 tail = converted[converted.length - 1],
3910 id = head.id,
3911 x = head.x;
3912 return converted.unshift({
3913 x: --x,
3914 value: head.value,
3915 id: id
3916 }), isCategorized && stepType === "step-after" && converted.unshift({
3917 x: --x,
3918 value: head.value,
3919 id: id
3920 }), x = tail.x, converted.push({
3921 x: ++x,
3922 value: tail.value,
3923 id: id
3924 }), isCategorized && stepType === "step-before" && converted.push({
3925 x: ++x,
3926 value: tail.value,
3927 id: id
3928 }), converted;
3929 },
3930 convertValuesToRange: function convertValuesToRange(values) {
3931 var converted = isArray(values) ? values.concat() : [values],
3932 ranges = [];
3933 return converted.forEach(function (range) {
3934 var x = range.x,
3935 id = range.id;
3936 ranges.push({
3937 x: x,
3938 id: id,
3939 value: range.value[0]
3940 }), ranges.push({
3941 x: x,
3942 id: id,
3943 value: range.value[2]
3944 });
3945 }), ranges;
3946 },
3947 updateDataAttributes: function updateDataAttributes(name, attrs) {
3948 var $$ = this,
3949 config = $$.config,
3950 current = config["data_" + name];
3951 return isUndefined(attrs) ? current : (Object.keys(attrs).forEach(function (id) {
3952 current[id] = attrs[id];
3953 }), $$.redraw({
3954 withLegend: !0
3955 }), current);
3956 },
3957 getRangedData: function getRangedData(d, key, type) {
3958 key === void 0 && (key = ""), type === void 0 && (type = "areaRange");
3959 var value = d == null ? void 0 : d.value;
3960
3961 if (isArray(value)) {
3962 // @ts-ignore
3963 var index = {
3964 areaRange: ["high", "mid", "low"],
3965 candlestick: ["open", "high", "low", "close", "volume"]
3966 }[type].indexOf(key);
3967 return index >= 0 && value ? value[index] : undefined;
3968 }
3969
3970 return value ? value[key] : value;
3971 },
3972
3973 /**
3974 * Get ratio value
3975 * @param {string} type Ratio for given type
3976 * @param {object} d Data value object
3977 * @param {boolean} asPercent Convert the return as percent or not
3978 * @returns {number} Ratio value
3979 * @private
3980 */
3981 getRatio: function getRatio(type, d, asPercent) {
3982 var $$ = this,
3983 config = $$.config,
3984 state = $$.state,
3985 api = $$.api,
3986 ratio = 0;
3987 if (d && api.data.shown().length) if (ratio = d.ratio || d.value, type === "arc") {
3988 // if has padAngle set, calculate rate based on value
3989 if ($$.pie.padAngle()()) ratio = d.value / $$.getTotalDataSum(!0);else {
3990 var gaugeArcLength = config.gauge_fullCircle ? $$.getArcLength() : $$.getStartAngle() * -2,
3991 arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
3992 ratio = (d.endAngle - d.startAngle) / arcLength;
3993 }
3994 } else if (type === "index") {
3995 var dataValues = api.data.values.bind(api),
3996 total = this.getTotalPerIndex();
3997
3998 if (state.hiddenTargetIds.length) {
3999 var hiddenSum = dataValues(state.hiddenTargetIds, !1);
4000 hiddenSum.length && (hiddenSum = hiddenSum.reduce(function (acc, curr) {
4001 return acc.map(function (v, i) {
4002 return (isNumber(v) ? v : 0) + curr[i];
4003 });
4004 }), total = total.map(function (v, i) {
4005 return v - hiddenSum[i];
4006 }));
4007 }
4008
4009 d.ratio = isNumber(d.value) && total && total[d.index] > 0 ? d.value / total[d.index] : 0, ratio = d.ratio;
4010 } else if (type === "radar") ratio = parseFloat(Math.max(d.value, 0) + "") / state.current.dataMax * config.radar_size_ratio;else if (type === "bar") {
4011 var yScale = $$.getYScaleById.bind($$)(d.id),
4012 max = yScale.domain().reduce(function (a, c) {
4013 return c - a;
4014 });
4015 ratio = Math.abs(d.value) / max;
4016 }
4017 return asPercent && ratio ? ratio * 100 : ratio;
4018 },
4019
4020 /**
4021 * Sort data index to be aligned with x axis.
4022 * @param {Array} tickValues Tick array values
4023 * @private
4024 */
4025 updateDataIndexByX: function updateDataIndexByX(tickValues) {
4026 var $$ = this,
4027 tickValueMap = tickValues.reduce(function (out, tick, index) {
4028 return out[+tick.x] = index, out;
4029 }, {});
4030 $$.data.targets.forEach(function (t) {
4031 t.values.forEach(function (value, valueIndex) {
4032 var index = tickValueMap[+value.x];
4033 index === undefined && (index = valueIndex), value.index = index;
4034 });
4035 });
4036 },
4037
4038 /**
4039 * Determine if bubble has dimension data
4040 * @param {object|Array} d data value
4041 * @returns {boolean}
4042 * @private
4043 */
4044 isBubbleZType: function isBubbleZType(d) {
4045 var $$ = this;
4046 return $$.isBubbleType(d) && (isObject(d.value) && ("z" in d.value || "y" in d.value) || isArray(d.value) && d.value.length === 2);
4047 },
4048
4049 /**
4050 * Get data object by id
4051 * @param {string} id data id
4052 * @returns {object}
4053 * @private
4054 */
4055 getDataById: function getDataById(id) {
4056 var d = this.cache.get(id) || this.api.data(id);
4057 return isArray(d) ? d[0] : d;
4058 }
4059});
4060;// CONCATENATED MODULE: ./src/ChartInternal/data/load.ts
4061/**
4062 * Copyright (c) 2017 ~ present NAVER Corp.
4063 * billboard.js project is licensed under the MIT license
4064 */
4065
4066
4067/* harmony default export */ var load = ({
4068 load: function load(rawTargets, args) {
4069 var $$ = this,
4070 targets = rawTargets;
4071 // Set targets
4072 // Redraw with new targets
4073 // Update current state chart type and elements list after redraw
4074 targets && (args.filter && (targets = targets.filter(args.filter)), (args.type || args.types) && targets.forEach(function (t) {
4075 var type = args.types && args.types[t.id] || args.type;
4076 $$.setTargetType(t.id, type);
4077 }), $$.data.targets.forEach(function (d) {
4078 for (var i = 0; i < targets.length; i++) if (d.id === targets[i].id) {
4079 d.values = targets[i].values, targets.splice(i, 1);
4080 break;
4081 }
4082 }), $$.data.targets = $$.data.targets.concat(targets)), $$.updateTargets($$.data.targets), $$.redraw({
4083 withUpdateOrgXDomain: !0,
4084 withUpdateXDomain: !0,
4085 withLegend: !0
4086 }), $$.updateTypesElements(), args.done && args.done.call($$.api);
4087 },
4088 loadFromArgs: function loadFromArgs(args) {
4089 var $$ = this; // prevent load when chart is already destroyed
4090
4091 if ($$.config) {
4092 $$.cache.reset();
4093 var data = args.data || $$.convertData(args, function (d) {
4094 return $$.load($$.convertDataToTargets(d), args);
4095 });
4096 data && $$.load($$.convertDataToTargets(data), args);
4097 } // reset internally cached data
4098
4099 },
4100 unload: function unload(rawTargetIds, customDoneCb) {
4101 var $$ = this,
4102 state = $$.state,
4103 $el = $$.$el,
4104 done = customDoneCb,
4105 targetIds = rawTargetIds;
4106 // If no target, call done and return
4107 return $$.cache.reset(), done || (done = function () {}), targetIds = targetIds.filter(function (id) {
4108 return $$.hasTarget($$.data.targets, id);
4109 }), targetIds && targetIds.length !== 0 ? void ( // Update current state chart type and elements list after redraw
4110 $el.svg.selectAll(targetIds.map(function (id) {
4111 return $$.selectorTarget(id);
4112 })).transition().style("opacity", "0").remove().call(endall, done), targetIds.forEach(function (id) {
4113 state.withoutFadeIn[id] = !1, $el.legend && $el.legend.selectAll("." + config_classes.legendItem + $$.getTargetSelectorSuffix(id)).remove(), $$.data.targets = $$.data.targets.filter(function (t) {
4114 return t.id !== id;
4115 });
4116 }), $$.updateTypesElements()) : void done();
4117 }
4118});
4119// EXTERNAL MODULE: external {"commonjs":"d3-drag","commonjs2":"d3-drag","amd":"d3-drag","root":"d3"}
4120var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack_require__(7);
4121;// CONCATENATED MODULE: ./src/ChartInternal/interactions/interaction.ts
4122/**
4123 * Copyright (c) 2017 ~ present NAVER Corp.
4124 * billboard.js project is licensed under the MIT license
4125 */
4126
4127
4128
4129
4130
4131/* harmony default export */ var interactions_interaction = ({
4132 selectRectForSingle: function selectRectForSingle(context, eventRect, index) {
4133 var $$ = this,
4134 config = $$.config,
4135 main = $$.$el.main,
4136 isSelectionEnabled = config.data_selection_enabled,
4137 isSelectionGrouped = config.data_selection_grouped,
4138 isSelectable = config.data_selection_isselectable,
4139 isTooltipGrouped = config.tooltip_grouped,
4140 selectedData = $$.getAllValuesOnIndex(index);
4141 isTooltipGrouped && ($$.showTooltip(selectedData, context), $$.showGridFocus && $$.showGridFocus(selectedData), !isSelectionEnabled || isSelectionGrouped) || main.selectAll("." + config_classes.shape + "-" + index).each(function () {
4142 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.EXPANDED, !0), isSelectionEnabled && eventRect.style("cursor", isSelectionGrouped ? "pointer" : null), isTooltipGrouped || ($$.hideGridFocus && $$.hideGridFocus(), $$.hideTooltip(), !isSelectionGrouped && $$.expandCirclesBars(index));
4143 }).filter(function (d) {
4144 return $$.isWithinShape(this, d);
4145 }).call(function (selected) {
4146 var d = selected.data();
4147 isSelectionEnabled && (isSelectionGrouped || isSelectable && isSelectable.bind($$.api)(d)) && eventRect.style("cursor", "pointer"), isTooltipGrouped || ($$.showTooltip(d, context), $$.showGridFocus && $$.showGridFocus(d), $$.unexpandCircles && $$.unexpandCircles(), selected.each(function (d) {
4148 return $$.expandCirclesBars(index, d.id);
4149 }));
4150 });
4151 },
4152 expandCirclesBars: function expandCirclesBars(index, id, reset) {
4153 var $$ = this,
4154 config = $$.config,
4155 _$$$$el = $$.$el,
4156 bar = _$$$$el.bar,
4157 circle = _$$$$el.circle;
4158 circle && config.point_focus_expand_enabled && $$.expandCircles(index, id, reset), bar && $$.expandBars(index, id, reset);
4159 },
4160
4161 /**
4162 * Handle data.onover/out callback options
4163 * @param {boolean} isOver Over or not
4164 * @param {number|object} d data object
4165 * @private
4166 */
4167 setOverOut: function setOverOut(isOver, d) {
4168 var $$ = this,
4169 config = $$.config,
4170 hasRadar = $$.state.hasRadar,
4171 main = $$.$el.main,
4172 isArc = isObject(d);
4173
4174 // Call event handler
4175 if (isArc || d !== -1) {
4176 var callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
4177 if (config.color_onover && $$.setOverColor(isOver, d, isArc), isArc) callback(d, main.select("." + config_classes.arc + $$.getTargetSelectorSuffix(d.id)).node());else if (!config.tooltip_grouped) {
4178 var last = $$.cache.get(KEY.setOverOut) || [],
4179 shape = main.selectAll("." + config_classes.shape + "-" + d).filter(function (d) {
4180 return $$.isWithinShape(this, d);
4181 });
4182 shape.each(function (d) {
4183 var _this = this;
4184
4185 (last.length === 0 || last.every(function (v) {
4186 return v !== _this;
4187 })) && (callback(d, this), last.push(this));
4188 }), last.length > 0 && shape.empty() && (callback = config.data_onout.bind($$.api), last.forEach(function (v) {
4189 return callback((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(v).datum(), v);
4190 }), last = []), $$.cache.add(KEY.setOverOut, last);
4191 } else isOver && (config.point_focus_only && hasRadar ? $$.showCircleFocus($$.getAllValuesOnIndex(d, !0)) : $$.expandCirclesBars(d, null, !0)), $$.isMultipleX() || main.selectAll("." + config_classes.shape + "-" + d).each(function (d) {
4192 callback(d, this);
4193 });
4194 }
4195 },
4196
4197 /**
4198 * Call data.onover/out callback for touch event
4199 * @param {number|object} d target index or data object for Arc type
4200 * @private
4201 */
4202 callOverOutForTouch: function callOverOutForTouch(d) {
4203 var $$ = this,
4204 last = $$.cache.get(KEY.callOverOutForTouch);
4205 (isObject(d) && last ? d.id !== last.id : d !== last) && ((last || isNumber(last)) && $$.setOverOut(!1, last), (d || isNumber(d)) && $$.setOverOut(!0, d), $$.cache.add(KEY.callOverOutForTouch, d));
4206 },
4207
4208 /**
4209 * Return draggable selection function
4210 * @returns {Function}
4211 * @private
4212 */
4213 getDraggableSelection: function getDraggableSelection() {
4214 var $$ = this,
4215 config = $$.config,
4216 state = $$.state;
4217 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) {
4218 state.event = event, $$.drag(getPointer(event, this));
4219 }).on("start", function (event) {
4220 state.event = event, $$.dragstart(getPointer(event, this));
4221 }).on("end", function (event) {
4222 state.event = event, $$.dragend();
4223 }) : function () {};
4224 },
4225
4226 /**
4227 * Dispatch a mouse event.
4228 * @private
4229 * @param {string} type event type
4230 * @param {number} index Index of eventRect
4231 * @param {Array} mouse x and y coordinate value
4232 */
4233 dispatchEvent: function dispatchEvent(type, index, mouse) {
4234 var $$ = this,
4235 config = $$.config,
4236 _$$$state = $$.state,
4237 eventReceiver = _$$$state.eventReceiver,
4238 hasAxis = _$$$state.hasAxis,
4239 hasRadar = _$$$state.hasRadar,
4240 _$$$$el2 = $$.$el,
4241 eventRect = _$$$$el2.eventRect,
4242 arcs = _$$$$el2.arcs,
4243 radar = _$$$$el2.radar,
4244 isMultipleX = $$.isMultipleX(),
4245 element = (hasRadar ? radar.axes.select("." + config_classes.axis + "-" + index + " text") : eventRect || arcs.selectAll("." + config_classes.target + " path").filter(function (d, i) {
4246 return i === index;
4247 })).node(),
4248 _element$getBoundingC = element.getBoundingClientRect(),
4249 width = _element$getBoundingC.width,
4250 left = _element$getBoundingC.left,
4251 top = _element$getBoundingC.top;
4252
4253 if (hasAxis && !hasRadar && !isMultipleX) {
4254 var coords = eventReceiver.coords[index];
4255 width = coords.w, left += coords.x, top += coords.y;
4256 }
4257
4258 var x = left + (mouse ? mouse[0] : 0) + (isMultipleX || config.axis_rotated ? 0 : width / 2),
4259 y = top + (mouse ? mouse[1] : 0);
4260 emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](element, type, {
4261 screenX: x,
4262 screenY: y,
4263 clientX: x,
4264 clientY: y
4265 });
4266 },
4267 setDragStatus: function setDragStatus(isDragging) {
4268 this.state.dragging = isDragging;
4269 }
4270});
4271;// CONCATENATED MODULE: ./src/ChartInternal/internals/class.ts
4272/**
4273 * Copyright (c) 2017 ~ present NAVER Corp.
4274 * billboard.js project is licensed under the MIT license
4275 */
4276
4277/* harmony default export */ var internals_class = ({
4278 generateClass: function generateClass(prefix, targetId) {
4279 return " " + prefix + " " + (prefix + this.getTargetSelectorSuffix(targetId));
4280 },
4281
4282 /**
4283 * Get class string
4284 * @param {string} type Shape type
4285 * @param {boolean} withShape Get with shape prefix
4286 * @returns {string} Class string
4287 * @private
4288 */
4289 getClass: function getClass(type, withShape) {
4290 var _this = this,
4291 isPlural = /s$/.test(type),
4292 useIdKey = /^(area|arc|line)s?$/.test(type),
4293 key = isPlural ? "id" : "index";
4294
4295 return function (d) {
4296 var data = d.data || d,
4297 result = (withShape ? _this.generateClass(config_classes[isPlural ? "shapes" : "shape"], data[key]) : "") + _this.generateClass(config_classes[type], data[useIdKey ? "id" : key]);
4298
4299 return result.trim();
4300 };
4301 },
4302
4303 /**
4304 * Get chart class string
4305 * @param {string} type Shape type
4306 * @returns {string} Class string
4307 * @private
4308 */
4309 getChartClass: function getChartClass(type) {
4310 var _this2 = this;
4311
4312 return function (d) {
4313 return config_classes["chart" + type] + _this2.classTarget((d.data ? d.data : d).id);
4314 };
4315 },
4316 generateExtraLineClass: function generateExtraLineClass() {
4317 var $$ = this,
4318 classes = $$.config.line_classes || [],
4319 ids = [];
4320 return function (d) {
4321 var id = d.id || d.data && d.data.id || d;
4322 return ids.indexOf(id) < 0 && ids.push(id), classes[ids.indexOf(id) % classes.length];
4323 };
4324 },
4325 classRegion: function classRegion(d, i) {
4326 return this.generateClass(config_classes.region, i) + " " + ("class" in d ? d.class : "");
4327 },
4328 classTarget: function classTarget(id) {
4329 var additionalClassSuffix = this.config.data_classes[id],
4330 additionalClass = "";
4331 return additionalClassSuffix && (additionalClass = " " + config_classes.target + "-" + additionalClassSuffix), this.generateClass(config_classes.target, id) + additionalClass;
4332 },
4333 classFocus: function classFocus(d) {
4334 return this.classFocused(d) + this.classDefocused(d);
4335 },
4336 classFocused: function classFocused(d) {
4337 return " " + (this.state.focusedTargetIds.indexOf(d.id) >= 0 ? config_classes.focused : "");
4338 },
4339 classDefocused: function classDefocused(d) {
4340 return " " + (this.state.defocusedTargetIds.indexOf(d.id) >= 0 ? config_classes.defocused : "");
4341 },
4342 getTargetSelectorSuffix: function getTargetSelectorSuffix(targetId) {
4343 return targetId || targetId === 0 ? ("-" + targetId).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g, "-") : "";
4344 },
4345 selectorTarget: function selectorTarget(id, prefix) {
4346 var pfx = prefix || "",
4347 target = this.getTargetSelectorSuffix(id);
4348 // select target & circle
4349 return pfx + "." + (config_classes.target + target) + ", " + pfx + "." + (config_classes.circles + target);
4350 },
4351 selectorTargets: function selectorTargets(idsValue, prefix) {
4352 var _this3 = this,
4353 ids = idsValue || [];
4354
4355 return ids.length ? ids.map(function (id) {
4356 return _this3.selectorTarget(id, prefix);
4357 }) : null;
4358 },
4359 selectorLegend: function selectorLegend(id) {
4360 return "." + (config_classes.legendItem + this.getTargetSelectorSuffix(id));
4361 },
4362 selectorLegends: function selectorLegends(ids) {
4363 var _this4 = this;
4364
4365 return ids && ids.length ? ids.map(function (id) {
4366 return _this4.selectorLegend(id);
4367 }) : null;
4368 }
4369});
4370;// CONCATENATED MODULE: ./src/ChartInternal/internals/category.ts
4371/**
4372 * Copyright (c) 2017 ~ present NAVER Corp.
4373 * billboard.js project is licensed under the MIT license
4374 */
4375/* harmony default export */ var category = ({
4376 /**
4377 * Category Name
4378 * @param {number} i Index number
4379 * @returns {string} category Name
4380 * @private
4381 */
4382 categoryName: function categoryName(i) {
4383 var categories = this.config.axis_x_categories;
4384 return categories && i < categories.length ? categories[i] : i;
4385 }
4386});
4387// EXTERNAL MODULE: external {"commonjs":"d3-scale","commonjs2":"d3-scale","amd":"d3-scale","root":"d3"}
4388var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webpack_require__(6);
4389;// CONCATENATED MODULE: ./src/ChartInternal/internals/color.ts
4390/**
4391 * Copyright (c) 2017 ~ present NAVER Corp.
4392 * billboard.js project is licensed under the MIT license
4393 */
4394
4395
4396
4397
4398
4399
4400/**
4401 * Set pattern's background color
4402 * (it adds a <rect> element to simulate bg-color)
4403 * @param {SVGPatternElement} pattern SVG pattern element
4404 * @param {string} color Color string
4405 * @param {string} id ID to be set
4406 * @returns {{id: string, node: SVGPatternElement}}
4407 * @private
4408 */
4409
4410var colorizePattern = function (pattern, color, id) {
4411 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(!0));
4412 return node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color), {
4413 id: id,
4414 node: node.node()
4415 };
4416},
4417 schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"]; // Replacement of d3.schemeCategory10.
4418// Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
4419
4420
4421/* harmony default export */ var internals_color = ({
4422 /**
4423 * Get color pattern from CSS file
4424 * CSS should be defined as: background-image: url("#00c73c;#fa7171; ...");
4425 * @returns {Array}
4426 * @private
4427 */
4428 getColorFromCss: function getColorFromCss() {
4429 var cacheKey = KEY.colorPattern,
4430 body = browser_doc.body,
4431 pattern = body[cacheKey];
4432
4433 if (!pattern) {
4434 var span = browser_doc.createElement("span");
4435 span.className = config_classes.colorPattern, span.style.display = "none", body.appendChild(span);
4436 var content = win.getComputedStyle(span).backgroundImage;
4437 span.parentNode.removeChild(span), content.indexOf(";") > -1 && (pattern = content.replace(/url[^#]*|["'()]|(\s|%20)/g, "").split(";").map(function (v) {
4438 return v.trim().replace(/[\"'\s]/g, "");
4439 }).filter(Boolean), body[cacheKey] = pattern);
4440 }
4441
4442 return pattern;
4443 },
4444 generateColor: function generateColor() {
4445 var $$ = this,
4446 config = $$.config,
4447 colors = config.data_colors,
4448 callback = config.data_color,
4449 ids = [],
4450 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(),
4451 originalColorPattern = pattern;
4452
4453 if (isFunction(config.color_tiles)) {
4454 var tiles = config.color_tiles.bind($$.api)(),
4455 colorizedPatterns = pattern.map(function (p, index) {
4456 var color = p.replace(/[#\(\)\s,]/g, ""),
4457 id = $$.state.datetimeId + "-pattern-" + color + "-" + index;
4458 return colorizePattern(tiles[index % tiles.length], p, id);
4459 }); // Add background color to patterns
4460
4461 pattern = colorizedPatterns.map(function (p) {
4462 return "url(#" + p.id + ")";
4463 }), $$.patterns = colorizedPatterns;
4464 }
4465
4466 return function (d) {
4467 var color,
4468 id = d.id || d.data && d.data.id || d,
4469 isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id];
4470 return isFunction(colors[id]) ? color = colors[id].bind($$.api)(d) : colors[id] ? color = colors[id] : (ids.indexOf(id) < 0 && ids.push(id), color = isLine ? originalColorPattern[ids.indexOf(id) % originalColorPattern.length] : pattern[ids.indexOf(id) % pattern.length], colors[id] = color), isFunction(callback) ? callback.bind($$.api)(color, d) : color;
4471 };
4472 },
4473 generateLevelColor: function generateLevelColor() {
4474 var $$ = this,
4475 config = $$.config,
4476 colors = config.color_pattern,
4477 threshold = config.color_threshold,
4478 asValue = threshold.unit === "value",
4479 max = threshold.max || 100,
4480 values = threshold.values && threshold.values.length ? threshold.values : [];
4481 return notEmpty(threshold) ? function (value) {
4482 var v = asValue ? value : value * 100 / max,
4483 color = colors[colors.length - 1];
4484
4485 for (var i = 0, l = values.length; i < l; i++) if (v <= values[i]) {
4486 color = colors[i];
4487 break;
4488 }
4489
4490 return color;
4491 } : null;
4492 },
4493
4494 /**
4495 * Set the data over color.
4496 * When is out, will restate in its previous color value
4497 * @param {boolean} isOver true: set overed color, false: restore
4498 * @param {number|object} d target index or data object for Arc type
4499 * @private
4500 */
4501 setOverColor: function setOverColor(isOver, d) {
4502 var $$ = this,
4503 config = $$.config,
4504 main = $$.$el.main,
4505 onover = config.color_onover,
4506 color = isOver ? onover : $$.color;
4507 isObject(color) ? color = function (_ref) {
4508 var id = _ref.id;
4509 return id in onover ? onover[id] : $$.color(id);
4510 } : isString(color) ? color = function () {
4511 return onover;
4512 } : isFunction(onover) && (color = color.bind($$.api)), main.selectAll(isObject(d) ? // when is Arc type
4513 "." + config_classes.arc + $$.getTargetSelectorSuffix(d.id) : "." + config_classes.shape + "-" + d).style("fill", color);
4514 }
4515});
4516;// CONCATENATED MODULE: ./src/config/const.ts
4517/**
4518 * Copyright (c) 2017 ~ present NAVER Corp.
4519 * billboard.js project is licensed under the MIT license
4520 */
4521
4522/**
4523 * Chart type constant
4524 * @private
4525 */
4526var TYPE = {
4527 AREA: "area",
4528 AREA_LINE_RANGE: "area-line-range",
4529 AREA_SPLINE: "area-spline",
4530 AREA_SPLINE_RANGE: "area-spline-range",
4531 AREA_STEP: "area-step",
4532 BAR: "bar",
4533 BUBBLE: "bubble",
4534 CANDLESTICK: "candlestick",
4535 DONUT: "donut",
4536 GAUGE: "gauge",
4537 LINE: "line",
4538 PIE: "pie",
4539 RADAR: "radar",
4540 SCATTER: "scatter",
4541 SPLINE: "spline",
4542 STEP: "step"
4543};
4544/**
4545 * chart types by category
4546 * @private
4547 */
4548
4549var TYPE_BY_CATEGORY = {
4550 Area: [TYPE.AREA, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE, TYPE.AREA_STEP],
4551 AreaRange: [TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE],
4552 Arc: [TYPE.PIE, TYPE.DONUT, TYPE.GAUGE, TYPE.RADAR],
4553 Line: [TYPE.LINE, TYPE.SPLINE, TYPE.AREA, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE, TYPE.STEP, TYPE.AREA_STEP],
4554 Step: [TYPE.STEP, TYPE.AREA_STEP],
4555 Spline: [TYPE.SPLINE, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE]
4556};
4557;// CONCATENATED MODULE: ./src/ChartInternal/internals/domain.ts
4558/**
4559 * Copyright (c) 2017 ~ present NAVER Corp.
4560 * billboard.js project is licensed under the MIT license
4561 */
4562
4563
4564/* harmony default export */ var domain = ({
4565 getYDomainMinMax: function getYDomainMinMax(targets, type) {
4566 var $$ = this,
4567 axis = $$.axis,
4568 config = $$.config,
4569 isMin = type === "min",
4570 dataGroups = config.data_groups,
4571 ids = $$.mapToIds(targets),
4572 ys = $$.getValuesAsIdKeyed(targets);
4573 return dataGroups.length > 0 && function () {
4574 for (var idsInGroup, _ret, hasValue = $$["has" + (isMin ? "Negative" : "Positive") + "ValueInTargets"](targets), _loop = function (j, _idsInGroup) {
4575 if (_idsInGroup = _idsInGroup.filter(function (v) {
4576 return ids.indexOf(v) >= 0;
4577 }), _idsInGroup.length === 0) return idsInGroup = _idsInGroup, "continue";
4578 var baseId = _idsInGroup[0],
4579 baseAxisId = axis.getId(baseId);
4580 hasValue && ys[baseId] && (ys[baseId] = ys[baseId].map(function (v) {
4581 return (isMin ? v < 0 : v > 0) ? v : 0;
4582 }));
4583
4584 for (var id, _ret2, _loop2 = function (k, id) {
4585 if (!ys[id]) return "continue";
4586 var axisId = axis.getId(id);
4587 ys[id].forEach(function (v, i) {
4588 var val = +v,
4589 meetCondition = isMin ? val > 0 : val < 0;
4590 axisId !== baseAxisId || hasValue && meetCondition || (ys[baseId][i] += val);
4591 });
4592 }, k = 1; id = _idsInGroup[k]; k++) _ret2 = _loop2(k, id), _ret2 === "continue";
4593
4594 idsInGroup = _idsInGroup;
4595 }, j = 0; idsInGroup = dataGroups[j]; j++) _ret = _loop(j, idsInGroup), _ret === "continue";
4596 }(), getMinMax(type, Object.keys(ys).map(function (key) {
4597 return getMinMax(type, ys[key]);
4598 }));
4599 },
4600 getYDomainMin: function getYDomainMin(targets) {
4601 return this.getYDomainMinMax(targets, "min");
4602 },
4603 getYDomainMax: function getYDomainMax(targets) {
4604 return this.getYDomainMinMax(targets, "max");
4605 },
4606
4607 /**
4608 * Check if hidden targets bound to the given axis id
4609 * @param {string} id ID to be checked
4610 * @returns {boolean}
4611 * @private
4612 */
4613 isHiddenTargetWithYDomain: function isHiddenTargetWithYDomain(id) {
4614 var $$ = this;
4615 return $$.state.hiddenTargetIds.some(function (v) {
4616 return $$.axis.getId(v) === id;
4617 });
4618 },
4619 getYDomain: function getYDomain(targets, axisId, xDomain) {
4620 var $$ = this,
4621 axis = $$.axis,
4622 config = $$.config,
4623 scale = $$.scale,
4624 pfx = "axis_" + axisId;
4625 if ($$.isStackNormalized()) return [0, 100];
4626 var isLog = scale && scale[axisId] && scale[axisId].type === "log",
4627 targetsByAxisId = targets.filter(function (t) {
4628 return axis.getId(t.id) === axisId;
4629 }),
4630 yTargets = xDomain ? $$.filterByXDomain(targetsByAxisId, xDomain) : targetsByAxisId;
4631 if (yTargets.length === 0) // use domain of the other axis if target of axisId is none
4632 return $$.isHiddenTargetWithYDomain(axisId) ? scale[axisId].domain() : axisId === "y2" ? scale.y.domain() : // When all data bounds to y2, y Axis domain is called prior y2.
4633 // So, it needs to call to get y2 domain here
4634 $$.getYDomain(targets, "y2", xDomain);
4635 var yMin = config[pfx + "_min"],
4636 yMax = config[pfx + "_max"],
4637 yDomainMin = $$.getYDomainMin(yTargets),
4638 yDomainMax = $$.getYDomainMax(yTargets),
4639 center = config[pfx + "_center"],
4640 isZeroBased = [TYPE.BAR, TYPE.BUBBLE, TYPE.SCATTER].concat(TYPE_BY_CATEGORY.Line).some(function (v) {
4641 var type = v.indexOf("area") > -1 ? "area" : v;
4642 return $$.hasType(v, yTargets) && config[type + "_zerobased"];
4643 }),
4644 isInverted = config[pfx + "_inverted"],
4645 showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated,
4646 showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated;
4647 yDomainMin = isValue(yMin) ? yMin : isValue(yMax) ? yDomainMin < yMax ? yDomainMin : yMax - 10 : yDomainMin, yDomainMax = isValue(yMax) ? yMax : isValue(yMin) ? yMin < yDomainMax ? yDomainMax : yMin + 10 : yDomainMax, isNaN(yDomainMin) && (yDomainMin = 0), isNaN(yDomainMax) && (yDomainMax = yDomainMin), yDomainMin === yDomainMax && (yDomainMin < 0 ? yDomainMax = 0 : yDomainMin = 0);
4648 var isAllPositive = yDomainMin >= 0 && yDomainMax >= 0,
4649 isAllNegative = yDomainMin <= 0 && yDomainMax <= 0;
4650 (isValue(yMin) && isAllPositive || isValue(yMax) && isAllNegative) && (isZeroBased = !1), isZeroBased && (isAllPositive && (yDomainMin = 0), isAllNegative && (yDomainMax = 0));
4651 var domainLength = Math.abs(yDomainMax - yDomainMin),
4652 padding = {
4653 top: domainLength * .1,
4654 bottom: domainLength * .1
4655 };
4656
4657 if (isDefined(center)) {
4658 var yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
4659 yDomainMax = center + yDomainAbs, yDomainMin = center - yDomainAbs;
4660 } // add padding for data label
4661
4662
4663 if (showHorizontalDataLabel) {
4664 var diff = diffDomain(scale.y.range()),
4665 ratio = $$.getDataLabelLength(yDomainMin, yDomainMax, "width").map(function (v) {
4666 return v / diff;
4667 });
4668 ["bottom", "top"].forEach(function (v, i) {
4669 padding[v] += domainLength * (ratio[i] / (1 - ratio[0] - ratio[1]));
4670 });
4671 } else if (showVerticalDataLabel) {
4672 var lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, "height");
4673 ["bottom", "top"].forEach(function (v, i) {
4674 padding[v] += axis.convertPixelsToAxisPadding(lengths[i], domainLength);
4675 });
4676 } // if padding is set, the domain will be updated relative the current domain value
4677 // ex) $$.height=300, padding.top=150, domainLength=4 --> domain=6
4678
4679
4680 var p = config[pfx + "_padding"];
4681 notEmpty(p) && ["bottom", "top"].forEach(function (v) {
4682 padding[v] = axis.getPadding(p, v, padding[v], domainLength);
4683 }), isZeroBased && (isAllPositive && (padding.bottom = yDomainMin), isAllNegative && (padding.top = -yDomainMax));
4684 var domain = isLog ? [yDomainMin, yDomainMax].map(function (v) {
4685 return v < 0 ? 0 : v;
4686 }) : [yDomainMin - padding.bottom, yDomainMax + padding.top];
4687 return isInverted ? domain.reverse() : domain;
4688 },
4689 getXDomainMinMax: function getXDomainMinMax(targets, type) {
4690 var $$ = this,
4691 configValue = $$.config["axis_x_" + type],
4692 dataValue = getMinMax(type, targets.map(function (t) {
4693 return getMinMax(type, t.values.map(function (v) {
4694 return v.x;
4695 }));
4696 })),
4697 value = isObject(configValue) ? configValue.value : configValue;
4698 return value = isDefined(value) && $$.axis.isTimeSeries() ? parseDate.bind(this)(value) : value, isObject(configValue) && configValue.fit && (type === "min" && value < dataValue || type === "max" && value > dataValue) && (value = undefined), isDefined(value) ? value : dataValue;
4699 },
4700 getXDomainMin: function getXDomainMin(targets) {
4701 return this.getXDomainMinMax(targets, "min");
4702 },
4703 getXDomainMax: function getXDomainMax(targets) {
4704 return this.getXDomainMinMax(targets, "max");
4705 },
4706 getXDomainPadding: function getXDomainPadding(domain) {
4707 var maxDataCount,
4708 padding,
4709 $$ = this,
4710 axis = $$.axis,
4711 config = $$.config,
4712 diff = domain[1] - domain[0],
4713 xPadding = config.axis_x_padding;
4714 axis.isCategorized() ? padding = 0 : $$.hasType("bar") ? (maxDataCount = $$.getMaxDataCount(), padding = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : .5) : padding = diff * .01;
4715 var left = padding,
4716 right = padding;
4717 return isObject(xPadding) && notEmpty(xPadding) ? (left = isValue(xPadding.left) ? xPadding.left : padding, right = isValue(xPadding.right) ? xPadding.right : padding) : isNumber(config.axis_x_padding) && (left = xPadding, right = xPadding), {
4718 left: left,
4719 right: right
4720 };
4721 },
4722 getXDomain: function getXDomain(targets) {
4723 var $$ = this,
4724 isLog = $$.scale.x.type === "log",
4725 xDomain = [$$.getXDomainMin(targets), $$.getXDomainMax(targets)],
4726 min = 0,
4727 max = 0;
4728 if (isLog) min = xDomain[0], max = xDomain[1];else {
4729 var isCategorized = $$.axis.isCategorized(),
4730 isTimeSeries = $$.axis.isTimeSeries(),
4731 padding = $$.getXDomainPadding(xDomain),
4732 _xDomain = xDomain,
4733 firstX = _xDomain[0],
4734 lastX = _xDomain[1];
4735 firstX - lastX !== 0 || isCategorized || (isTimeSeries ? (firstX = new Date(firstX.getTime() * .5), lastX = new Date(lastX.getTime() * 1.5)) : (firstX = firstX === 0 ? 1 : firstX * .5, lastX = lastX === 0 ? -1 : lastX * 1.5)), (firstX || firstX === 0) && (min = isTimeSeries ? new Date(firstX.getTime() - padding.left) : firstX - padding.left), (lastX || lastX === 0) && (max = isTimeSeries ? new Date(lastX.getTime() + padding.right) : lastX + padding.right);
4736 }
4737 return [min, max];
4738 },
4739 updateXDomain: function updateXDomain(targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
4740 var $$ = this,
4741 config = $$.config,
4742 org = $$.org,
4743 _$$$scale = $$.scale,
4744 x = _$$$scale.x,
4745 subX = _$$$scale.subX,
4746 zoomEnabled = config.zoom_enabled;
4747
4748 if (withUpdateOrgXDomain && (x.domain(domain || sortValue($$.getXDomain(targets))), org.xDomain = x.domain(), zoomEnabled && $$.zoom.updateScaleExtent(), subX.domain(x.domain()), $$.brush && $$.brush.scale(subX)), withUpdateXDomain) {
4749 var domainValue = domain || !$$.brush || brushEmpty($$) ? org.xDomain : getBrushSelection($$).map(subX.invert);
4750 x.domain(domainValue), zoomEnabled && $$.zoom.updateScaleExtent();
4751 } // Trim domain when too big by zoom mousemove event
4752
4753
4754 return withTrim && x.domain($$.trimXDomain(x.orgDomain())), x.domain();
4755 },
4756 trimXDomain: function trimXDomain(domain) {
4757 var zoomDomain = this.getZoomDomain(),
4758 min = zoomDomain[0],
4759 max = zoomDomain[1];
4760 return domain[0] <= min && (domain[1] = +domain[1] + (min - domain[0]), domain[0] = min), max <= domain[1] && (domain[0] = +domain[0] - (domain[1] - max), domain[1] = max), domain;
4761 },
4762
4763 /**
4764 * Get zoom domain
4765 * @returns {Array} zoom domain
4766 * @private
4767 */
4768 getZoomDomain: function getZoomDomain() {
4769 var $$ = this,
4770 config = $$.config,
4771 org = $$.org,
4772 _org$xDomain = org.xDomain,
4773 min = _org$xDomain[0],
4774 max = _org$xDomain[1];
4775 return isDefined(config.zoom_x_min) && (min = getMinMax("min", [min, config.zoom_x_min])), isDefined(config.zoom_x_max) && (max = getMinMax("max", [max, config.zoom_x_max])), [min, max];
4776 }
4777});
4778;// CONCATENATED MODULE: ./src/ChartInternal/internals/format.ts
4779/**
4780 * Copyright (c) 2017 ~ present NAVER Corp.
4781 * billboard.js project is licensed under the MIT license
4782 */
4783
4784
4785/**
4786 * Get formatted
4787 * @param {object} $$ Context
4788 * @param {string} typeValue Axis type
4789 * @param {number} v Value to be formatted
4790 * @returns {number | string}
4791 * @private
4792 */
4793function getFormat($$, typeValue, v) {
4794 var config = $$.config,
4795 type = "axis_" + typeValue + "_tick_format",
4796 format = config[type] ? config[type] : $$.defaultValueFormat;
4797 return format(v);
4798}
4799
4800/* harmony default export */ var format = ({
4801 getYFormat: function getYFormat(forArc) {
4802 var $$ = this,
4803 yFormat = $$.yFormat,
4804 y2Format = $$.y2Format;
4805 return forArc && !$$.hasType("gauge") && (yFormat = $$.defaultArcValueFormat, y2Format = $$.defaultArcValueFormat), function (v, ratio, id) {
4806 var format = $$.axis && $$.axis.getId(id) === "y2" ? y2Format : yFormat;
4807 return format.call($$, v, ratio);
4808 };
4809 },
4810 yFormat: function yFormat(v) {
4811 return getFormat(this, "y", v);
4812 },
4813 y2Format: function y2Format(v) {
4814 return getFormat(this, "y2", v);
4815 },
4816 defaultValueFormat: function defaultValueFormat(v) {
4817 return isValue(v) ? +v : "";
4818 },
4819 defaultArcValueFormat: function defaultArcValueFormat(v, ratio) {
4820 return (ratio * 100).toFixed(1) + "%";
4821 },
4822 dataLabelFormat: function dataLabelFormat(targetId) {
4823 var $$ = this,
4824 dataLabels = $$.config.data_labels,
4825 defaultFormat = function (v) {
4826 return isValue(v) ? +v : "";
4827 },
4828 format = defaultFormat;
4829
4830 return isFunction(dataLabels.format) ? format = dataLabels.format : isObjectType(dataLabels.format) && (dataLabels.format[targetId] ? format = dataLabels.format[targetId] === !0 ? defaultFormat : dataLabels.format[targetId] : format = function () {
4831 return "";
4832 }), format.bind($$.api);
4833 }
4834});
4835;// CONCATENATED MODULE: ./src/ChartInternal/internals/legend.ts
4836/**
4837 * Copyright (c) 2017 ~ present NAVER Corp.
4838 * billboard.js project is licensed under the MIT license
4839 */
4840
4841
4842
4843
4844
4845/* harmony default export */ var internals_legend = ({
4846 /**
4847 * Initialize the legend.
4848 * @private
4849 */
4850 initLegend: function initLegend() {
4851 var $$ = this,
4852 config = $$.config,
4853 $el = $$.$el;
4854 $$.legendItemTextBox = {}, $$.state.legendHasRendered = !1, config.legend_show ? (!config.legend_contents_bindto && ($el.legend = $$.$el.svg.append("g").classed(config_classes.legend, !0).attr("transform", $$.getTranslate("legend"))), $$.updateLegend()) : $$.state.hiddenLegendIds = $$.mapToIds($$.data.targets);
4855 },
4856
4857 /**
4858 * Update legend element
4859 * @param {Array} targetIds ID's of target
4860 * @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.
4861 * @param {object} transitions Return value of the generateTransitions
4862 * @private
4863 */
4864 updateLegend: function updateLegend(targetIds, options, transitions) {
4865 var $$ = this,
4866 config = $$.config,
4867 state = $$.state,
4868 scale = $$.scale,
4869 $el = $$.$el,
4870 optionz = options || {
4871 withTransform: !1,
4872 withTransitionForTransform: !1,
4873 withTransition: !1
4874 };
4875 // toggle legend state
4876 // Update size and scale
4877 // Update g positions
4878 optionz.withTransition = getOption(optionz, "withTransition", !0), optionz.withTransitionForTransform = getOption(optionz, "withTransitionForTransform", !0), config.legend_contents_bindto && config.legend_contents_template ? $$.updateLegendTemplate() : $$.updateLegendElement(targetIds || $$.mapToIds($$.data.targets), optionz, transitions), $el.legend.selectAll("." + config_classes.legendItem).classed(config_classes.legendItemHidden, function (id) {
4879 var hide = !$$.isTargetToShow(id);
4880 return hide && (this.style.opacity = null), hide;
4881 }), $$.updateScales(!1, !scale.zoom), $$.updateSvgSize(), $$.transformAll(optionz.withTransitionForTransform, transitions), state.legendHasRendered = !0;
4882 },
4883
4884 /**
4885 * Update legend using template option
4886 * @private
4887 */
4888 updateLegendTemplate: function updateLegendTemplate() {
4889 var $$ = this,
4890 config = $$.config,
4891 $el = $$.$el,
4892 wrapper = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.legend_contents_bindto),
4893 template = config.legend_contents_template;
4894
4895 if (!wrapper.empty()) {
4896 var targets = $$.mapToIds($$.data.targets),
4897 ids = [],
4898 html = "";
4899 targets.forEach(function (v) {
4900 var content = isFunction(template) ? template.bind($$.api)(v, $$.color(v), $$.api.data(v)[0].values) : tplProcess(template, {
4901 COLOR: $$.color(v),
4902 TITLE: v
4903 });
4904 content && (ids.push(v), html += content);
4905 });
4906 var legendItem = wrapper.html(html).selectAll(function () {
4907 return this.childNodes;
4908 }).data(ids);
4909 $$.setLegendItem(legendItem), $el.legend = wrapper;
4910 }
4911 },
4912
4913 /**
4914 * Update the size of the legend.
4915 * @param {Obejct} size Size object
4916 * @private
4917 */
4918 updateSizeForLegend: function updateSizeForLegend(size) {
4919 var $$ = this,
4920 config = $$.config,
4921 _$$$state = $$.state,
4922 isLegendTop = _$$$state.isLegendTop,
4923 isLegendLeft = _$$$state.isLegendLeft,
4924 isLegendRight = _$$$state.isLegendRight,
4925 isLegendInset = _$$$state.isLegendInset,
4926 current = _$$$state.current,
4927 width = size.width,
4928 height = size.height,
4929 insetLegendPosition = {
4930 top: isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : current.height - height - $$.getCurrentPaddingBottom() - config.legend_inset_y,
4931 left: isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + .5 : current.width - width - $$.getCurrentPaddingRight() - config.legend_inset_x + .5
4932 };
4933 $$.state.margin3 = {
4934 top: isLegendRight ? 0 : isLegendInset ? insetLegendPosition.top : current.height - height,
4935 right: NaN,
4936 bottom: 0,
4937 left: isLegendRight ? current.width - width : isLegendInset ? insetLegendPosition.left : 0
4938 };
4939 },
4940
4941 /**
4942 * Transform Legend
4943 * @param {boolean} withTransition whether or not to transition.
4944 * @private
4945 */
4946 transformLegend: function transformLegend(withTransition) {
4947 var $$ = this,
4948 legend = $$.$el.legend;
4949 (withTransition ? legend.transition() : legend).attr("transform", $$.getTranslate("legend"));
4950 },
4951
4952 /**
4953 * Update the legend step
4954 * @param {number} step Step value
4955 * @private
4956 */
4957 updateLegendStep: function updateLegendStep(step) {
4958 this.state.legendStep = step;
4959 },
4960
4961 /**
4962 * Update legend item width
4963 * @param {number} width Width value
4964 * @private
4965 */
4966 updateLegendItemWidth: function updateLegendItemWidth(width) {
4967 this.state.legendItemWidth = width;
4968 },
4969
4970 /**
4971 * Update legend item height
4972 * @param {number} height Height value
4973 * @private
4974 */
4975 updateLegendItemHeight: function updateLegendItemHeight(height) {
4976 this.state.legendItemHeight = height;
4977 },
4978
4979 /**
4980 * Update legend item color
4981 * @param {string} id Corresponding data ID value
4982 * @param {string} color Color value
4983 * @private
4984 */
4985 updateLegendItemColor: function updateLegendItemColor(id, color) {
4986 var legend = this.$el.legend;
4987 legend && legend.select("." + config_classes.legendItem + "-" + id + " line").style("stroke", color);
4988 },
4989
4990 /**
4991 * Get the width of the legend
4992 * @returns {number} width
4993 * @private
4994 */
4995 getLegendWidth: function getLegendWidth() {
4996 var $$ = this,
4997 _$$$state2 = $$.state,
4998 width = _$$$state2.current.width,
4999 isLegendRight = _$$$state2.isLegendRight,
5000 isLegendInset = _$$$state2.isLegendInset,
5001 legendItemWidth = _$$$state2.legendItemWidth,
5002 legendStep = _$$$state2.legendStep;
5003 return $$.config.legend_show ? isLegendRight || isLegendInset ? legendItemWidth * (legendStep + 1) : width : 0;
5004 },
5005
5006 /**
5007 * Get the height of the legend
5008 * @returns {number} height
5009 * @private
5010 */
5011 getLegendHeight: function getLegendHeight() {
5012 var $$ = this,
5013 _$$$state3 = $$.state,
5014 current = _$$$state3.current,
5015 isLegendRight = _$$$state3.isLegendRight,
5016 legendItemHeight = _$$$state3.legendItemHeight,
5017 legendStep = _$$$state3.legendStep;
5018 return $$.config.legend_show ? isLegendRight ? current.height : Math.max(20, legendItemHeight) * (legendStep + 1) : 0;
5019 },
5020
5021 /**
5022 * Get the opacity of the legend
5023 * @param {d3.selection} legendItem Legend item node
5024 * @returns {string|null} opacity
5025 * @private
5026 */
5027 opacityForLegend: function opacityForLegend(legendItem) {
5028 return legendItem.classed(config_classes.legendItemHidden) ? null : "1";
5029 },
5030
5031 /**
5032 * Get the opacity of the legend that is unfocused
5033 * @param {d3.selection} legendItem Legend item node
5034 * @returns {string|null} opacity
5035 * @private
5036 */
5037 opacityForUnfocusedLegend: function opacityForUnfocusedLegend(legendItem) {
5038 return legendItem.classed(config_classes.legendItemHidden) ? null : "0.3";
5039 },
5040
5041 /**
5042 * Toggles the focus of the legend
5043 * @param {Array} targetIds ID's of target
5044 * @param {boolean} focus whether or not to focus.
5045 * @private
5046 */
5047 toggleFocusLegend: function toggleFocusLegend(targetIds, focus) {
5048 var $$ = this,
5049 legend = $$.$el.legend,
5050 targetIdz = $$.mapToTargetIds(targetIds);
5051 legend && legend.selectAll("." + config_classes.legendItem).filter(function (id) {
5052 return targetIdz.indexOf(id) >= 0;
5053 }).classed(config_classes.legendItemFocused, focus).transition().duration(100).style("opacity", function () {
5054 return (focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend).call($$, (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this));
5055 });
5056 },
5057
5058 /**
5059 * Revert the legend to its default state
5060 * @private
5061 */
5062 revertLegend: function revertLegend() {
5063 var $$ = this,
5064 legend = $$.$el.legend;
5065 legend && legend.selectAll("." + config_classes.legendItem).classed(config_classes.legendItemFocused, !1).transition().duration(100).style("opacity", function () {
5066 return $$.opacityForLegend((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this));
5067 });
5068 },
5069
5070 /**
5071 * Shows the legend
5072 * @param {Array} targetIds ID's of target
5073 * @private
5074 */
5075 showLegend: function showLegend(targetIds) {
5076 var $$ = this,
5077 config = $$.config,
5078 $el = $$.$el;
5079 config.legend_show || (config.legend_show = !0, $el.legend ? $el.legend.style("visibility", "visible") : $$.initLegend(), !$$.state.legendHasRendered && $$.updateLegend()), $$.removeHiddenLegendIds(targetIds), $el.legend.selectAll($$.selectorLegends(targetIds)).style("visibility", "visible").transition().style("opacity", function () {
5080 return $$.opacityForLegend((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this));
5081 });
5082 },
5083
5084 /**
5085 * Hide the legend
5086 * @param {Array} targetIds ID's of target
5087 * @private
5088 */
5089 hideLegend: function hideLegend(targetIds) {
5090 var $$ = this,
5091 config = $$.config,
5092 legend = $$.$el.legend;
5093 config.legend_show && isEmpty(targetIds) && (config.legend_show = !1, legend.style("visibility", "hidden")), $$.addHiddenLegendIds(targetIds), legend.selectAll($$.selectorLegends(targetIds)).style("opacity", "0").style("visibility", "hidden");
5094 },
5095
5096 /**
5097 * Get legend item textbox dimension
5098 * @param {string} id Data ID
5099 * @param {HTMLElement|d3.selection} textElement Text node element
5100 * @returns {object} Bounding rect
5101 * @private
5102 */
5103 getLegendItemTextBox: function getLegendItemTextBox(id, textElement) {
5104 var data,
5105 $$ = this,
5106 cache = $$.cache,
5107 state = $$.state,
5108 cacheKey = KEY.legendItemTextBox;
5109 return id && (data = !state.redrawing && cache.get(cacheKey) || {}, !data[id] && (data[id] = $$.getTextRect(textElement, config_classes.legendItem), cache.add(cacheKey, data)), data = data[id]), data;
5110 },
5111
5112 /**
5113 * Set legend item style & bind events
5114 * @param {d3.selection} item Item node
5115 * @private
5116 */
5117 setLegendItem: function setLegendItem(item) {
5118 var $$ = this,
5119 api = $$.api,
5120 config = $$.config,
5121 state = $$.state,
5122 isTouch = state.inputType === "touch",
5123 hasGauge = $$.hasType("gauge");
5124 item.attr("class", function (id) {
5125 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
5126 itemClass = !node.empty() && node.attr("class") || "";
5127 return itemClass + $$.generateClass(config_classes.legendItem, id);
5128 }).style("visibility", function (id) {
5129 return $$.isLegendToShow(id) ? "visible" : "hidden";
5130 }), config.interaction_enabled && (item.style("cursor", "pointer").on("click", function (event, id) {
5131 callFn(config.legend_item_onclick, api, id) || (event.altKey ? (api.hide(), api.show(id)) : (api.toggle(id), (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused, !1).style("opacity", null))), isTouch && $$.hideTooltip();
5132 }), !isTouch && item.on("mouseout", function (event, id) {
5133 callFn(config.legend_item_onout, api, id) || ((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused, !1), hasGauge && $$.undoMarkOverlapped($$, "." + config_classes.gaugeValue), $$.api.revert());
5134 }).on("mouseover", function (event, id) {
5135 callFn(config.legend_item_onover, api, id) || ((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused, !0), hasGauge && $$.markOverlapped(id, $$, "." + config_classes.gaugeValue), !state.transiting && $$.isTargetToShow(id) && api.focus(id));
5136 }));
5137 },
5138
5139 /**
5140 * Update the legend
5141 * @param {Array} targetIds ID's of target
5142 * @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.
5143 * @private
5144 */
5145 updateLegendElement: function updateLegendElement(targetIds, options) {
5146 var xForLegend,
5147 yForLegend,
5148 background,
5149 $$ = this,
5150 config = $$.config,
5151 state = $$.state,
5152 legend = $$.$el.legend,
5153 posMin = 10,
5154 tileWidth = config.legend_item_tile_width + 5,
5155 maxWidth = 0,
5156 maxHeight = 0,
5157 totalLength = 0,
5158 offsets = {},
5159 widths = {},
5160 heights = {},
5161 margins = [0],
5162 steps = {},
5163 step = 0,
5164 isLegendRightOrInset = state.isLegendRight || state.isLegendInset,
5165 targetIdz = targetIds.filter(function (id) {
5166 return !isDefined(config.data_names[id]) || config.data_names[id] !== null;
5167 }),
5168 withTransition = options.withTransition,
5169 updatePositions = function (textElement, id, index) {
5170 var margin,
5171 isLast = index === targetIdz.length - 1,
5172 box = $$.getLegendItemTextBox(id, textElement),
5173 itemWidth = box.width + tileWidth + (isLast && !isLegendRightOrInset ? 0 : 10) + config.legend_padding,
5174 itemHeight = box.height + 4,
5175 itemLength = isLegendRightOrInset ? itemHeight : itemWidth,
5176 areaLength = isLegendRightOrInset ? $$.getLegendHeight() : $$.getLegendWidth(),
5177 updateValues = function (id2, withoutStep) {
5178 withoutStep || (margin = (areaLength - totalLength - itemLength) / 2, margin < posMin && (margin = (areaLength - itemLength) / 2, totalLength = 0, step++)), steps[id2] = step, margins[step] = state.isLegendInset ? 10 : margin, offsets[id2] = totalLength, totalLength += itemLength;
5179 };
5180
5181 if (index === 0 && (totalLength = 0, step = 0, maxWidth = 0, maxHeight = 0), config.legend_show && !$$.isLegendToShow(id)) return widths[id] = 0, heights[id] = 0, steps[id] = 0, void (offsets[id] = 0);
5182 widths[id] = itemWidth, heights[id] = itemHeight, (!maxWidth || itemWidth >= maxWidth) && (maxWidth = itemWidth), (!maxHeight || itemHeight >= maxHeight) && (maxHeight = itemHeight);
5183 var maxLength = isLegendRightOrInset ? maxHeight : maxWidth;
5184 config.legend_equally ? (Object.keys(widths).forEach(function (id2) {
5185 return widths[id2] = maxWidth;
5186 }), Object.keys(heights).forEach(function (id2) {
5187 return heights[id2] = maxHeight;
5188 }), margin = (areaLength - maxLength * targetIdz.length) / 2, margin < posMin ? (totalLength = 0, step = 0, targetIdz.forEach(function (id2) {
5189 return updateValues(id2);
5190 })) : updateValues(id, !0)) : updateValues(id);
5191 };
5192
5193 state.isLegendInset && (step = config.legend_inset_step ? config.legend_inset_step : targetIdz.length, $$.updateLegendStep(step)), state.isLegendRight ? (xForLegend = function (id) {
5194 return maxWidth * steps[id];
5195 }, yForLegend = function (id) {
5196 return margins[steps[id]] + offsets[id];
5197 }) : state.isLegendInset ? (xForLegend = function (id) {
5198 return maxWidth * steps[id] + 10;
5199 }, yForLegend = function (id) {
5200 return margins[steps[id]] + offsets[id];
5201 }) : (xForLegend = function (id) {
5202 return margins[steps[id]] + offsets[id];
5203 }, yForLegend = function (id) {
5204 return maxHeight * steps[id];
5205 });
5206
5207 var xForLegendText = function (id, i) {
5208 return xForLegend(id, i) + 4 + config.legend_item_tile_width;
5209 },
5210 xForLegendRect = function (id, i) {
5211 return xForLegend(id, i);
5212 },
5213 x1ForLegendTile = function (id, i) {
5214 return xForLegend(id, i) - 2;
5215 },
5216 x2ForLegendTile = function (id, i) {
5217 return xForLegend(id, i) - 2 + config.legend_item_tile_width;
5218 },
5219 yForLegendText = function (id, i) {
5220 return yForLegend(id, i) + 9;
5221 },
5222 yForLegendRect = function (id, i) {
5223 return yForLegend(id, i) - 5;
5224 },
5225 yForLegendTile = function (id, i) {
5226 return yForLegend(id, i) + 4;
5227 },
5228 pos = -200,
5229 l = legend.selectAll("." + config_classes.legendItem).data(targetIdz).enter().append("g");
5230
5231 $$.setLegendItem(l), l.append("text").text(function (id) {
5232 return isDefined(config.data_names[id]) ? config.data_names[id] : id;
5233 }).each(function (id, i) {
5234 updatePositions(this, id, i);
5235 }).style("pointer-events", "none").attr("x", isLegendRightOrInset ? xForLegendText : pos).attr("y", isLegendRightOrInset ? pos : yForLegendText), l.append("rect").attr("class", config_classes.legendItemEvent).style("fill-opacity", "0").attr("x", isLegendRightOrInset ? xForLegendRect : pos).attr("y", isLegendRightOrInset ? pos : yForLegendRect);
5236
5237 var getColor = function (id) {
5238 var data = $$.getDataById(id);
5239 return $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
5240 },
5241 usePoint = config.legend_usePoint;
5242
5243 if (usePoint) {
5244 var ids = [];
5245 l.append(function (d) {
5246 var pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
5247 ids.indexOf(d) === -1 && ids.push(d);
5248 var point = pattern[ids.indexOf(d) % pattern.length];
5249 return point === "rectangle" && (point = "rect"), browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, "hasValidPointType" in $$ && $$.hasValidPointType(point) ? point : "use");
5250 }).attr("class", config_classes.legendItemPoint).style("fill", getColor).style("pointer-events", "none").attr("href", function (data, idx, selection) {
5251 var node = selection[idx],
5252 nodeName = node.nodeName.toLowerCase();
5253 return nodeName === "use" ? "#" + state.datetimeId + "-point-" + data : undefined;
5254 });
5255 } else 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); // Set background for inset legend
5256
5257
5258 background = legend.select("." + config_classes.legendBackground + " rect"), state.isLegendInset && maxWidth > 0 && background.size() === 0 && (background = legend.insert("g", "." + config_classes.legendItem).attr("class", config_classes.legendBackground).append("rect"));
5259 var texts = legend.selectAll("text").data(targetIdz).text(function (id) {
5260 return isDefined(config.data_names[id]) ? config.data_names[id] : id;
5261 }) // MEMO: needed for update
5262 .each(function (id, i) {
5263 updatePositions(this, id, i);
5264 });
5265 (withTransition ? texts.transition() : texts).attr("x", xForLegendText).attr("y", yForLegendText);
5266 var rects = legend.selectAll("rect." + config_classes.legendItemEvent).data(targetIdz);
5267
5268 if ((withTransition ? rects.transition() : rects).attr("width", function (id) {
5269 return widths[id];
5270 }).attr("height", function (id) {
5271 return heights[id];
5272 }).attr("x", xForLegendRect).attr("y", yForLegendRect), usePoint) {
5273 var tiles = legend.selectAll("." + config_classes.legendItemPoint).data(targetIdz);
5274 (withTransition ? tiles.transition() : tiles).each(function () {
5275 var radius,
5276 width,
5277 height,
5278 nodeName = this.nodeName.toLowerCase(),
5279 pointR = config.point_r,
5280 x = "x",
5281 y = "y",
5282 xOffset = 2,
5283 yOffset = 2.5;
5284
5285 if (nodeName === "circle") {
5286 var size = pointR * .2;
5287 x = "cx", y = "cy", radius = pointR + size, xOffset = pointR * 2, yOffset = -size;
5288 } else if (nodeName === "rect") {
5289 var _size = pointR * 2.5;
5290
5291 width = _size, height = _size, yOffset = 3;
5292 }
5293
5294 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).attr(x, function (d) {
5295 return x1ForLegendTile(d) + xOffset;
5296 }).attr(y, function (d) {
5297 return yForLegendTile(d) - yOffset;
5298 }).attr("r", radius).attr("width", width).attr("height", height);
5299 });
5300 } else {
5301 var _tiles = legend.selectAll("line." + config_classes.legendItemTile).data(targetIdz);
5302
5303 (withTransition ? _tiles.transition() : _tiles).style("stroke", getColor).attr("x1", x1ForLegendTile).attr("y1", yForLegendTile).attr("x2", x2ForLegendTile).attr("y2", yForLegendTile);
5304 }
5305
5306 background && (withTransition ? background.transition() : background).attr("height", $$.getLegendHeight() - 12).attr("width", maxWidth * (step + 1) + 10), $$.updateLegendItemWidth(maxWidth), $$.updateLegendItemHeight(maxHeight), $$.updateLegendStep(step);
5307 }
5308});
5309// EXTERNAL MODULE: external {"commonjs":"d3-transition","commonjs2":"d3-transition","amd":"d3-transition","root":"d3"}
5310var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_ = __webpack_require__(8);
5311;// CONCATENATED MODULE: ./src/ChartInternal/internals/redraw.ts
5312/**
5313 * Copyright (c) 2017 ~ present NAVER Corp.
5314 * billboard.js project is licensed under the MIT license
5315 */
5316
5317
5318
5319
5320/* harmony default export */ var redraw = ({
5321 redraw: function redraw(options) {
5322 options === void 0 && (options = {});
5323 var $$ = this,
5324 config = $$.config,
5325 state = $$.state,
5326 $el = $$.$el,
5327 main = $el.main;
5328 state.redrawing = !0;
5329 var targetsToShow = $$.filterTargetsToShow($$.data.targets),
5330 initializing = options.initializing,
5331 flow = options.flow,
5332 wth = $$.getWithOption(options),
5333 duration = wth.Transition ? config.transition_duration : 0,
5334 durationForExit = wth.TransitionForExit ? duration : 0,
5335 durationForAxis = wth.TransitionForAxis ? duration : 0,
5336 transitions = $$.axis && $$.axis.generateTransitions(durationForAxis);
5337 // text
5338 // title
5339 $$.updateSizes(initializing), wth.Legend && config.legend_show ? (options.withTransition = !!duration, $$.updateLegend($$.mapToIds($$.data.targets), options, transitions)) : wth.Dimension && $$.updateDimension(!0), (!$$.hasArcType() || state.hasRadar) && $$.updateCircleY && ($$.circleY = $$.updateCircleY()), state.hasAxis ? ($$.axis.redrawAxis(targetsToShow, wth, transitions, flow, initializing), 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), $$.hasGrid() && $$.updateGrid(duration), config.regions.length && $$.updateRegion(duration), ["bar", "candlestick", "line", "area"].forEach(function (v) {
5340 var name = capitalize(v);
5341 (/^(line|area)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) && $$["update" + name](durationForExit);
5342 }), $el.text && main.selectAll("." + config_classes.selectedCircles).filter($$.isBarType.bind($$)).selectAll("circle").remove(), config.interaction_enabled && !flow && wth.EventRect && ($$.redrawEventRect(), $$.bindZoomEvent && $$.bindZoomEvent())) : ($el.arcs && $$.redrawArc(duration, durationForExit, wth.Transform), $el.radar && $$.redrawRadar(durationForExit)), !state.resizing && ($$.hasPointType() || state.hasRadar) && $$.updateCircle(), $$.hasDataLabel() && !$$.hasArcType(null, ["radar"]) && $$.updateText(durationForExit), $$.redrawTitle && $$.redrawTitle(), initializing && $$.updateTypesElements(), $$.generateRedrawList(targetsToShow, flow, duration, wth.Subchart), $$.callPluginHook("$redraw", options, duration);
5343 },
5344
5345 /**
5346 * Generate redraw list
5347 * @param {object} targets targets data to be shown
5348 * @param {object} flow flow object
5349 * @param {number} duration duration value
5350 * @param {boolean} withSubchart whether or not to show subchart
5351 * @private
5352 */
5353 generateRedrawList: function generateRedrawList(targets, flow, duration, withSubchart) {
5354 var $$ = this,
5355 config = $$.config,
5356 state = $$.state,
5357 shape = $$.getDrawShape();
5358 state.hasAxis && config.subchart_show && $$.redrawSubchart(withSubchart, duration, shape);
5359 // generate flow
5360 var flowFn = flow && $$.generateFlow({
5361 targets: targets,
5362 flow: flow,
5363 duration: flow.duration,
5364 shape: shape,
5365 xv: $$.xv.bind($$)
5366 }),
5367 isTransition = (duration || flowFn) && isTabVisible(),
5368 redrawList = $$.getRedrawList(shape, flow, flowFn, isTransition),
5369 afterRedraw = flow || config.onrendered ? function () {
5370 flowFn && flowFn(), state.redrawing = !1, callFn(config.onrendered, $$.api);
5371 } : null;
5372 if (afterRedraw) // Only use transition when current tab is visible.
5373 if (isTransition && redrawList.length) {
5374 // Wait for end of transitions for callback
5375 var waitForDraw = generateWait(); // transition should be derived from one transition
5376
5377 (0,external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_.transition)().duration(duration).each(function () {
5378 redrawList.reduce(function (acc, t1) {
5379 return acc.concat(t1);
5380 }, []).forEach(function (t) {
5381 return waitForDraw.add(t);
5382 });
5383 }).call(waitForDraw, afterRedraw);
5384 } else state.transiting || afterRedraw(); // update fadein condition
5385
5386 $$.mapToIds($$.data.targets).forEach(function (id) {
5387 state.withoutFadeIn[id] = !0;
5388 });
5389 },
5390 getRedrawList: function getRedrawList(shape, flow, flowFn, isTransition) {
5391 var $$ = this,
5392 config = $$.config,
5393 _$$$state = $$.state,
5394 hasAxis = _$$$state.hasAxis,
5395 hasRadar = _$$$state.hasRadar,
5396 grid = $$.$el.grid,
5397 _shape$pos = shape.pos,
5398 cx = _shape$pos.cx,
5399 cy = _shape$pos.cy,
5400 xForText = _shape$pos.xForText,
5401 yForText = _shape$pos.yForText,
5402 list = [];
5403 return hasAxis && ((config.grid_x_lines.length || config.grid_y_lines.length) && list.push($$.redrawGrid(isTransition)), config.regions.length && list.push($$.redrawRegion(isTransition)), Object.keys(shape.type).forEach(function (v) {
5404 var name = capitalize(v),
5405 drawFn = shape.type[v];
5406 (/^(area|line)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) && list.push($$["redraw" + name](drawFn, isTransition));
5407 }), !flow && grid.main && list.push($$.updateGridFocus())), (!$$.hasArcType() || hasRadar) && notEmpty(config.data_labels) && config.data_labels !== !1 && list.push($$.redrawText(xForText, yForText, flow, isTransition)), ($$.hasPointType() || hasRadar) && !config.point_focus_only && $$.redrawCircle && list.push($$.redrawCircle(cx, cy, isTransition, flowFn)), list;
5408 },
5409 updateAndRedraw: function updateAndRedraw(options) {
5410 options === void 0 && (options = {});
5411 var transitions,
5412 $$ = this,
5413 config = $$.config,
5414 state = $$.state;
5415 // same with redraw
5416 // NOT same with redraw
5417 // Draw with new sizes & scales
5418 options.withTransition = getOption(options, "withTransition", !0), options.withTransform = getOption(options, "withTransform", !1), options.withLegend = getOption(options, "withLegend", !1), options.withUpdateXDomain = !0, options.withUpdateOrgXDomain = !0, options.withTransitionForExit = !1, options.withTransitionForTransform = getOption(options, "withTransitionForTransform", options.withTransition), options.withLegend && config.legend_show || (state.hasAxis && (transitions = $$.axis.generateTransitions(options.withTransitionForAxis ? config.transition_duration : 0)), $$.updateScales(), $$.updateSvgSize(), $$.transformAll(options.withTransitionForTransform, transitions)), $$.redraw(options, transitions);
5419 },
5420 redrawWithoutRescale: function redrawWithoutRescale() {
5421 this.redraw({
5422 withY: !1,
5423 withSubchart: !1,
5424 withEventRect: !1,
5425 withTransitionForAxis: !1
5426 });
5427 }
5428});
5429;// CONCATENATED MODULE: ./src/ChartInternal/internals/scale.ts
5430/**
5431 * Copyright (c) 2017 ~ present NAVER Corp.
5432 * billboard.js project is licensed under the MIT license
5433 */
5434
5435
5436/**
5437 * Get scale
5438 * @param {string} [type='linear'] Scale type
5439 * @param {number} [min] Min range
5440 * @param {number} [max] Max range
5441 * @returns {d3.scaleLinear|d3.scaleTime} scale
5442 * @private
5443 */
5444
5445function getScale(type, min, max) {
5446 type === void 0 && (type = "linear"), min === void 0 && (min = 0), max === void 0 && (max = 1);
5447 var scale = {
5448 linear: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear,
5449 log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSymlog,
5450 _log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLog,
5451 time: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleTime
5452 }[type]();
5453 return scale.type = type, /_?log/.test(type) && scale.clamp(!0), scale.range([min, max]);
5454}
5455/* harmony default export */ var scale = ({
5456 /**
5457 * Get x Axis scale function
5458 * @param {number} min Min value
5459 * @param {number} max Max value
5460 * @param {Array} domain Domain value
5461 * @param {Function} offset The offset getter to be sum
5462 * @returns {Function} scale
5463 * @private
5464 */
5465 getXScale: function getXScale(min, max, domain, offset) {
5466 var $$ = this,
5467 scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
5468 return $$.getCustomizedScale(domain ? scale.domain(domain) : scale, offset);
5469 },
5470
5471 /**
5472 * Get y Axis scale function
5473 * @param {string} id Axis id: 'y' or 'y2'
5474 * @param {number} min Min value
5475 * @param {number} max Max value
5476 * @param {Array} domain Domain value
5477 * @returns {Function} Scale function
5478 * @private
5479 */
5480 getYScale: function getYScale(id, min, max, domain) {
5481 var $$ = this,
5482 scale = getScale($$.axis.getAxisType(id), min, max);
5483 return domain && scale.domain(domain), scale;
5484 },
5485
5486 /**
5487 * Get y Axis scale
5488 * @param {string} id Axis id
5489 * @param {boolean} isSub Weather is sub Axis
5490 * @returns {Function} Scale function
5491 * @private
5492 */
5493 getYScaleById: function getYScaleById(id, isSub) {
5494 isSub === void 0 && (isSub = !1);
5495 var isY2 = this.axis.getId(id) === "y2",
5496 key = isSub ? isY2 ? "subY2" : "subY" : isY2 ? "y2" : "y";
5497 return this.scale[key];
5498 },
5499
5500 /**
5501 * Get customized scale
5502 * @param {d3.scaleLinear|d3.scaleTime} scaleValue Scale function
5503 * @param {Function} offsetValue Offset getter to be sum
5504 * @returns {Function} Scale function
5505 * @private
5506 */
5507 getCustomizedScale: function getCustomizedScale(scaleValue, offsetValue) {
5508 var $$ = this,
5509 offset = offsetValue || function () {
5510 return $$.axis.x.tickOffset();
5511 },
5512 scale = function (d, raw) {
5513 var v = scaleValue(d) + offset();
5514 return raw ? v : Math.ceil(v);
5515 };
5516
5517 // copy original scale methods
5518 for (var key in scaleValue) scale[key] = scaleValue[key];
5519
5520 return scale.orgDomain = function () {
5521 return scaleValue.domain();
5522 }, scale.orgScale = function () {
5523 return scaleValue;
5524 }, $$.axis.isCategorized() && (scale.domain = function (domainValue) {
5525 var domain = domainValue;
5526 return arguments.length ? (scaleValue.domain(domain), scale) : (domain = this.orgDomain(), [domain[0], domain[1] + 1]);
5527 }), scale;
5528 },
5529
5530 /**
5531 * Update scale
5532 * @param {boolean} isInit Param is given at the init rendering
5533 * @param {boolean} updateXDomain If update x domain
5534 * @private
5535 */
5536 updateScales: function updateScales(isInit, updateXDomain) {
5537 updateXDomain === void 0 && (updateXDomain = !0);
5538 var $$ = this,
5539 axis = $$.axis,
5540 config = $$.config,
5541 format = $$.format,
5542 org = $$.org,
5543 scale = $$.scale,
5544 _$$$state = $$.state,
5545 width = _$$$state.width,
5546 height = _$$$state.height,
5547 width2 = _$$$state.width2,
5548 height2 = _$$$state.height2,
5549 hasAxis = _$$$state.hasAxis;
5550
5551 if (hasAxis) {
5552 var isRotated = config.axis_rotated,
5553 min = {
5554 x: isRotated ? 1 : 0,
5555 y: isRotated ? 0 : height,
5556 subX: isRotated ? 1 : 0,
5557 subY: isRotated ? 0 : height2
5558 },
5559 max = {
5560 x: isRotated ? height : width,
5561 y: isRotated ? width : 1,
5562 subX: isRotated ? height : width,
5563 subY: isRotated ? width2 : 1
5564 },
5565 xDomain = updateXDomain && scale.x && scale.x.orgDomain(),
5566 xSubDomain = updateXDomain && org.xDomain; // update edges
5567
5568 // y Axis
5569 scale.x = $$.getXScale(min.x, max.x, xDomain, function () {
5570 return axis.x.tickOffset();
5571 }), scale.subX = $$.getXScale(min.x, max.x, xSubDomain, function (d) {
5572 return d % 1 ? 0 : axis.subX.tickOffset();
5573 }), format.xAxisTick = axis.getXAxisTickFormat(), axis.setAxis("x", scale.x, config.axis_x_tick_outer, isInit), config.subchart_show && axis.setAxis("subX", scale.subX, config.axis_x_tick_outer, isInit), scale.y = $$.getYScale("y", min.y, max.y, scale.y ? scale.y.domain() : config.axis_y_default), scale.subY = $$.getYScale("y", min.subY, max.subY, scale.subY ? scale.subY.domain() : config.axis_y_default), axis.setAxis("y", scale.y, config.axis_y_tick_outer, isInit), config.axis_y2_show && (scale.y2 = $$.getYScale("y2", min.y, max.y, scale.y2 ? scale.y2.domain() : config.axis_y2_default), scale.subY2 = $$.getYScale("y2", min.subY, max.subY, scale.subY2 ? scale.subY2.domain() : config.axis_y2_default), axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit));
5574 } else // update for arc
5575 $$.updateArc && $$.updateArc();
5576 },
5577
5578 /**
5579 * Get the zoom or unzoomed scaled value
5580 * @param {Date|number|object} d Data value
5581 * @returns {number|null}
5582 * @private
5583 */
5584 xx: function xx(d) {
5585 var $$ = this,
5586 config = $$.config,
5587 _$$$scale = $$.scale,
5588 x = _$$$scale.x,
5589 zoom = _$$$scale.zoom,
5590 fn = config.zoom_enabled && zoom ? zoom : x;
5591 return d ? fn(isValue(d.x) ? d.x : d) : null;
5592 },
5593 xv: function xv(d) {
5594 var $$ = this,
5595 axis = $$.axis,
5596 config = $$.config,
5597 x = $$.scale.x,
5598 value = $$.getBaseValue(d);
5599 return axis.isTimeSeries() ? value = parseDate.call($$, value) : axis.isCategorized() && isString(value) && (value = config.axis_x_categories.indexOf(value)), Math.ceil(x(value));
5600 },
5601 yv: function yv(d) {
5602 var $$ = this,
5603 _$$$scale2 = $$.scale,
5604 y = _$$$scale2.y,
5605 y2 = _$$$scale2.y2,
5606 yScale = d.axis && d.axis === "y2" ? y2 : y;
5607 return Math.ceil(yScale($$.getBaseValue(d)));
5608 },
5609 subxx: function subxx(d) {
5610 return d ? this.scale.subX(d.x) : null;
5611 }
5612});
5613// EXTERNAL MODULE: external {"commonjs":"d3-shape","commonjs2":"d3-shape","amd":"d3-shape","root":"d3"}
5614var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webpack_require__(9);
5615;// CONCATENATED MODULE: ./src/ChartInternal/shape/shape.ts
5616/**
5617 * Copyright (c) 2017 ~ present NAVER Corp.
5618 * billboard.js project is licensed under the MIT license
5619 */
5620
5621
5622
5623
5624/* harmony default export */ var shape = ({
5625 /**
5626 * Get the shape draw function
5627 * @returns {object}
5628 * @private
5629 */
5630 getDrawShape: function getDrawShape() {
5631 var $$ = this,
5632 isRotated = $$.config.axis_rotated,
5633 hasRadar = $$.state.hasRadar,
5634 shape = {
5635 type: {},
5636 indices: {},
5637 pos: {}
5638 };
5639
5640 if (["bar", "candlestick", "line", "area"].forEach(function (v) {
5641 var name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
5642
5643 if ($$.hasType(v) || $$.hasTypeOf(name) || v === "line" && ($$.hasType("bubble") || $$.hasType("scatter"))) {
5644 var indices = $$.getShapeIndices($$["is" + name + "Type"]),
5645 drawFn = $$["generateDraw" + name];
5646 shape.indices[v] = indices, shape.type[v] = drawFn ? drawFn.bind($$)(indices, !1) : undefined;
5647 }
5648 }), !$$.hasArcType() || hasRadar) {
5649 // generate circle x/y functions depending on updated params
5650 var cx = hasRadar ? $$.radarCircleX : isRotated ? $$.circleY : $$.circleX,
5651 cy = hasRadar ? $$.radarCircleY : isRotated ? $$.circleX : $$.circleY;
5652 shape.pos = {
5653 xForText: $$.generateXYForText(shape.indices, !0),
5654 yForText: $$.generateXYForText(shape.indices, !1),
5655 cx: (cx || function () {}).bind($$),
5656 cy: (cy || function () {}).bind($$)
5657 };
5658 }
5659
5660 return shape;
5661 },
5662 getShapeIndices: function getShapeIndices(typeFilter) {
5663 var $$ = this,
5664 config = $$.config,
5665 xs = config.data_xs,
5666 hasXs = notEmpty(xs),
5667 indices = {},
5668 i = hasXs ? {} : 0;
5669 return hasXs && getUnique(Object.keys(xs).map(function (v) {
5670 return xs[v];
5671 })).forEach(function (v) {
5672 i[v] = 0, indices[v] = {};
5673 }), $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) {
5674 for (var groups, xKey = (d.id in xs) ? xs[d.id] : "", ind = xKey ? indices[xKey] : indices, j = 0; groups = config.data_groups[j]; j++) if (!(groups.indexOf(d.id) < 0)) for (var _row4, _k4 = 0; _row4 = groups[_k4]; _k4++) if (_row4 in ind) {
5675 ind[d.id] = ind[_row4];
5676 break;
5677 }
5678
5679 isUndefined(ind[d.id]) && (ind[d.id] = xKey ? i[xKey]++ : i++, ind.__max__ = (xKey ? i[xKey] : i) - 1);
5680 }), indices;
5681 },
5682
5683 /**
5684 * Get indices value based on data ID value
5685 * @param {object} indices Indices object
5686 * @param {string} id Data id value
5687 * @returns {object} Indices object
5688 * @private
5689 */
5690 getIndices: function getIndices(indices, id) {
5691 var xs = this.config.data_xs;
5692 return notEmpty(xs) ? indices[xs[id]] : indices;
5693 },
5694
5695 /**
5696 * Get indices max number
5697 * @param {object} indices Indices object
5698 * @returns {number} Max number
5699 * @private
5700 */
5701 getIndicesMax: function getIndicesMax(indices) {
5702 return notEmpty(this.config.data_xs) ? // if is multiple xs, return total sum of xs' __max__ value
5703 Object.keys(indices).map(function (v) {
5704 return indices[v].__max__ || 0;
5705 }).reduce(function (acc, curr) {
5706 return acc + curr;
5707 }) : indices.__max__;
5708 },
5709 getShapeX: function getShapeX(offset, indices, isSub) {
5710 var $$ = this,
5711 config = $$.config,
5712 scale = $$.scale,
5713 currScale = isSub ? scale.subX : scale.zoom || scale.x,
5714 barPadding = config.bar_padding,
5715 sum = function (p, c) {
5716 return p + c;
5717 },
5718 halfWidth = isObjectType(offset) && (offset._$total.length ? offset._$total.reduce(sum) / 2 : 0);
5719
5720 return function (d) {
5721 var ind = $$.getIndices(indices, d.id),
5722 index = d.id in ind ? ind[d.id] : 0,
5723 targetsNum = (ind.__max__ || 0) + 1,
5724 x = 0;
5725
5726 if (notEmpty(d.x)) {
5727 var xPos = currScale(d.x, !0);
5728 x = halfWidth ? xPos - (offset[d.id] || offset._$width) + offset._$total.slice(0, index + 1).reduce(sum) - halfWidth : xPos - (isNumber(offset) ? offset : offset._$width) * (targetsNum / 2 - index);
5729 } // adjust x position for bar.padding optionq
5730
5731
5732 return offset && x && targetsNum > 1 && barPadding && (index && (x += barPadding * index), targetsNum > 2 ? x -= (targetsNum - 1) * barPadding / 2 : targetsNum === 2 && (x -= barPadding / 2)), x;
5733 };
5734 },
5735 getShapeY: function getShapeY(isSub) {
5736 var $$ = this,
5737 isStackNormalized = $$.isStackNormalized();
5738 return function (d) {
5739 var value = d.value;
5740 return isNumber(d) ? value = d : isStackNormalized ? value = $$.getRatio("index", d, !0) : $$.isBubbleZType(d) && (value = $$.getBubbleZData(d.value, "y")), $$.getYScaleById(d.id, isSub)(value);
5741 };
5742 },
5743
5744 /**
5745 * Get shape based y Axis min value
5746 * @param {string} id Data id
5747 * @returns {number}
5748 * @private
5749 */
5750 getShapeYMin: function getShapeYMin(id) {
5751 var $$ = this,
5752 scale = $$.scale[$$.axis.getId(id)],
5753 _scale$domain = scale.domain(),
5754 yMin = _scale$domain[0];
5755
5756 return !$$.isGrouped(id) && yMin > 0 ? yMin : 0;
5757 },
5758
5759 /**
5760 * Get Shape's offset data
5761 * @param {Function} typeFilter Type filter function
5762 * @returns {object}
5763 * @private
5764 */
5765 getShapeOffsetData: function getShapeOffsetData(typeFilter) {
5766 var $$ = this,
5767 targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))),
5768 isStackNormalized = $$.isStackNormalized(),
5769 shapeOffsetTargets = targets.map(function (target) {
5770 var rowValues = target.values,
5771 values = {};
5772 $$.isStepType(target) && (rowValues = $$.convertValuesToStep(rowValues));
5773 var rowValueMapByXValue = rowValues.reduce(function (out, d) {
5774 var key = +d.x;
5775 return out[key] = d, values[key] = isStackNormalized ? $$.getRatio("index", d, !0) : d.value, out;
5776 }, {});
5777 return {
5778 id: target.id,
5779 rowValues: rowValues,
5780 rowValueMapByXValue: rowValueMapByXValue,
5781 values: values
5782 };
5783 }),
5784 indexMapByTargetId = targets.reduce(function (out, _ref, index) {
5785 var id = _ref.id;
5786 return out[id] = index, out;
5787 }, {});
5788 return {
5789 indexMapByTargetId: indexMapByTargetId,
5790 shapeOffsetTargets: shapeOffsetTargets
5791 };
5792 },
5793 getShapeOffset: function getShapeOffset(typeFilter, indices, isSub) {
5794 var $$ = this,
5795 _$$$getShapeOffsetDat = $$.getShapeOffsetData(typeFilter),
5796 shapeOffsetTargets = _$$$getShapeOffsetDat.shapeOffsetTargets,
5797 indexMapByTargetId = _$$$getShapeOffsetDat.indexMapByTargetId;
5798
5799 return function (d, idx) {
5800 var ind = $$.getIndices(indices, d.id),
5801 scale = $$.getYScaleById(d.id, isSub),
5802 y0 = scale($$.getShapeYMin(d.id)),
5803 dataXAsNumber = +d.x,
5804 offset = y0;
5805 return shapeOffsetTargets.filter(function (t) {
5806 return t.id !== d.id;
5807 }).forEach(function (t) {
5808 if (ind[t.id] === ind[d.id] && indexMapByTargetId[t.id] < indexMapByTargetId[d.id]) {
5809 var row = t.rowValues[idx]; // check if the x values line up
5810
5811 row && +row.x === dataXAsNumber || (row = t.rowValueMapByXValue[dataXAsNumber]), row && row.value * d.value >= 0 && (offset += scale(t.values[dataXAsNumber]) - y0);
5812 }
5813 }), offset;
5814 };
5815 },
5816 getBarW: function getBarW(type, axis, targetsNum) {
5817 var $$ = this,
5818 config = $$.config,
5819 org = $$.org,
5820 scale = $$.scale,
5821 maxDataCount = $$.getMaxDataCount(),
5822 isGrouped = type === "bar" && config.data_groups.length,
5823 configName = type + "_width",
5824 tickInterval = scale.zoom && !$$.axis.isCategorized() ? org.xDomain.map(function (v) {
5825 return scale.zoom(v);
5826 }).reduce(function (a, c) {
5827 return Math.abs(a) + c;
5828 }) / maxDataCount : axis.tickInterval(maxDataCount),
5829 getWidth = function (id) {
5830 var width = id ? config[configName][id] : config[configName],
5831 ratio = id ? width.ratio : config[configName + "_ratio"],
5832 max = id ? width.max : config[configName + "_max"],
5833 w = isNumber(width) ? width : targetsNum ? tickInterval * ratio / targetsNum : 0;
5834 return max && w > max ? max : w;
5835 },
5836 result = getWidth();
5837
5838 return !isGrouped && isObjectType(config[configName]) && (result = {
5839 _$width: result,
5840 _$total: []
5841 }, $$.filterTargetsToShow($$.data.targets).forEach(function (v) {
5842 config[configName][v.id] && (result[v.id] = getWidth(v.id), result._$total.push(result[v.id] || result._$width));
5843 })), result;
5844 },
5845 isWithinShape: function isWithinShape(that, d) {
5846 var isWithin,
5847 $$ = this,
5848 shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that);
5849 return $$.isTargetToShow(d.id) ? "hasValidPointType" in $$ && $$.hasValidPointType(that.nodeName) ? isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) : $$.isWithinCircle(that, $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0) : that.nodeName === "path" && (isWithin = !shape.classed(config_classes.bar) || $$.isWithinBar(that)) : isWithin = !1, isWithin;
5850 },
5851 getInterpolate: function getInterpolate(d) {
5852 var $$ = this,
5853 interpolation = $$.getInterpolateType(d);
5854 return {
5855 "basis": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasis,
5856 "basis-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisClosed,
5857 "basis-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisOpen,
5858 "bundle": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBundle,
5859 "cardinal": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinal,
5860 "cardinal-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalClosed,
5861 "cardinal-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalOpen,
5862 "catmull-rom": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRom,
5863 "catmull-rom-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomClosed,
5864 "catmull-rom-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomOpen,
5865 "monotone-x": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneX,
5866 "monotone-y": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneY,
5867 "natural": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveNatural,
5868 "linear-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinearClosed,
5869 "linear": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinear,
5870 "step": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStep,
5871 "step-after": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepAfter,
5872 "step-before": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepBefore
5873 }[interpolation];
5874 },
5875 getInterpolateType: function getInterpolateType(d) {
5876 var $$ = this,
5877 config = $$.config,
5878 type = config.spline_interpolation_type,
5879 interpolation = $$.isInterpolationType(type) ? type : "cardinal";
5880 return $$.isSplineType(d) ? interpolation : $$.isStepType(d) ? config.line_step_type : "linear";
5881 }
5882});
5883;// CONCATENATED MODULE: ./src/ChartInternal/internals/size.ts
5884/**
5885 * Copyright (c) 2017 ~ present NAVER Corp.
5886 * billboard.js project is licensed under the MIT license
5887 */
5888
5889
5890
5891/* harmony default export */ var size = ({
5892 /**
5893 * Update container size
5894 * @private
5895 */
5896 setContainerSize: function setContainerSize() {
5897 var $$ = this,
5898 state = $$.state;
5899 state.current.width = $$.getCurrentWidth(), state.current.height = $$.getCurrentHeight();
5900 },
5901 getCurrentWidth: function getCurrentWidth() {
5902 var $$ = this;
5903 return $$.config.size_width || $$.getParentWidth();
5904 },
5905 getCurrentHeight: function getCurrentHeight() {
5906 var $$ = this,
5907 config = $$.config,
5908 h = config.size_height || $$.getParentHeight();
5909 return h > 0 ? h : 320 / ($$.hasType("gauge") && !config.gauge_fullCircle ? 2 : 1);
5910 },
5911 getCurrentPaddingTop: function getCurrentPaddingTop() {
5912 var $$ = this,
5913 config = $$.config,
5914 hasAxis = $$.state.hasAxis,
5915 $el = $$.$el,
5916 axesLen = hasAxis ? config.axis_y2_axes.length : 0,
5917 padding = isValue(config.padding_top) ? config.padding_top : 0;
5918 return $el.title && $el.title.node() && (padding += $$.getTitlePadding()), axesLen && config.axis_rotated && (padding += $$.getHorizontalAxisHeight("y2") * axesLen), padding;
5919 },
5920 getCurrentPaddingBottom: function getCurrentPaddingBottom() {
5921 var $$ = this,
5922 config = $$.config,
5923 hasAxis = $$.state.hasAxis,
5924 axisId = config.axis_rotated ? "y" : "x",
5925 axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
5926 padding = isValue(config.padding_bottom) ? config.padding_bottom : 0;
5927 return padding + (axesLen ? $$.getHorizontalAxisHeight(axisId) * axesLen : 0);
5928 },
5929 getCurrentPaddingLeft: function getCurrentPaddingLeft(withoutRecompute) {
5930 var padding,
5931 $$ = this,
5932 config = $$.config,
5933 hasAxis = $$.state.hasAxis,
5934 isRotated = config.axis_rotated,
5935 axisId = isRotated ? "x" : "y",
5936 axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
5937 axisWidth = hasAxis ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : 0;
5938 return padding = isValue(config.padding_left) ? config.padding_left : hasAxis && isRotated ? config.axis_x_show ? Math.max(ceil10(axisWidth), 40) : 1 : hasAxis && (!config.axis_y_show || config.axis_y_inner) ? $$.axis.getAxisLabelPosition("y").isOuter ? 30 : 1 : ceil10(axisWidth), padding + axisWidth * axesLen;
5939 },
5940 getCurrentPaddingRight: function getCurrentPaddingRight(withXAxisTickTextOverflow) {
5941 withXAxisTickTextOverflow === void 0 && (withXAxisTickTextOverflow = !1);
5942 var padding,
5943 $$ = this,
5944 config = $$.config,
5945 hasAxis = $$.state.hasAxis,
5946 defaultPadding = 10,
5947 legendWidthOnRight = $$.state.isLegendRight ? $$.getLegendWidth() + 20 : 0,
5948 axesLen = hasAxis ? config.axis_y2_axes.length : 0,
5949 axisWidth = hasAxis ? $$.getAxisWidthByAxisId("y2") : 0,
5950 xAxisTickTextOverflow = withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0;
5951 return padding = isValue(config.padding_right) ? config.padding_right + 1 : $$.axis && config.axis_rotated ? defaultPadding + legendWidthOnRight : $$.axis && (!config.axis_y2_show || config.axis_y2_inner) ? Math.max(2 + legendWidthOnRight + ($$.axis.getAxisLabelPosition("y2").isOuter ? 20 : 0), xAxisTickTextOverflow) : Math.max(ceil10(axisWidth) + legendWidthOnRight, xAxisTickTextOverflow), padding + axisWidth * axesLen;
5952 },
5953
5954 /**
5955 * Get the parent rect element's size
5956 * @param {string} key property/attribute name
5957 * @returns {number}
5958 * @private
5959 */
5960 getParentRectValue: function getParentRectValue(key) {
5961 for (var v, offsetName = "offset" + capitalize(key), parent = this.$el.chart.node(); !v && parent && parent.tagName !== "BODY";) {
5962 try {
5963 v = parent.getBoundingClientRect()[key];
5964 } catch (e) {
5965 offsetName in parent && (v = parent[offsetName]);
5966 }
5967
5968 parent = parent.parentNode;
5969 }
5970
5971 if (key === "width") {
5972 // Sometimes element's width value is incorrect(ex. flex container)
5973 // In this case, use body's offsetWidth instead.
5974 var bodyWidth = browser_doc.body.offsetWidth;
5975 v > bodyWidth && (v = bodyWidth);
5976 }
5977
5978 return v;
5979 },
5980 getParentWidth: function getParentWidth() {
5981 return this.getParentRectValue("width");
5982 },
5983 getParentHeight: function getParentHeight() {
5984 var h = this.$el.chart.style("height");
5985 return h.indexOf("px") > 0 ? parseInt(h, 10) : 0;
5986 },
5987 getSvgLeft: function getSvgLeft(withoutRecompute) {
5988 var $$ = this,
5989 config = $$.config,
5990 $el = $$.$el,
5991 hasLeftAxisRect = config.axis_rotated || !config.axis_rotated && !config.axis_y_inner,
5992 leftAxisClass = config.axis_rotated ? config_classes.axisX : config_classes.axisY,
5993 leftAxis = $el.main.select("." + leftAxisClass).node(),
5994 svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : {
5995 right: 0
5996 },
5997 chartRect = $el.chart.node().getBoundingClientRect(),
5998 hasArc = $$.hasArcType(),
5999 svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute));
6000 return svgLeft > 0 ? svgLeft : 0;
6001 },
6002 updateDimension: function updateDimension(withoutAxis) {
6003 var $$ = this,
6004 config = $$.config,
6005 hasAxis = $$.state.hasAxis,
6006 $el = $$.$el;
6007 // pass 'withoutAxis' param to not animate at the init rendering
6008 hasAxis && !withoutAxis && $$.axis.x && config.axis_rotated && $$.axis.subX && $$.axis.subX.create($el.axis.subX), $$.updateScales(withoutAxis), $$.updateSvgSize(), $$.transformAll(!1);
6009 },
6010 updateSvgSize: function updateSvgSize() {
6011 var $$ = this,
6012 _$$$state = $$.state,
6013 clip = _$$$state.clip,
6014 current = _$$$state.current,
6015 hasAxis = _$$$state.hasAxis,
6016 width = _$$$state.width,
6017 height = _$$$state.height,
6018 svg = $$.$el.svg;
6019
6020 if (svg.attr("width", current.width).attr("height", current.height), hasAxis) {
6021 var brush = svg.select("." + config_classes.brush + " .overlay"),
6022 brushSize = {
6023 width: 0,
6024 height: 0
6025 };
6026 brush.size() && (brushSize.width = +brush.attr("width"), brushSize.height = +brush.attr("height")), svg.selectAll(["#" + clip.id, "#" + clip.idGrid]).select("rect").attr("width", width).attr("height", height), svg.select("#" + clip.idXAxis).select("rect").call($$.setXAxisClipPath.bind($$)), svg.select("#" + clip.idYAxis).select("rect").call($$.setYAxisClipPath.bind($$)), clip.idSubchart && svg.select("#" + clip.idSubchart).select("rect").attr("width", width).attr("height", brushSize.height);
6027 }
6028 },
6029
6030 /**
6031 * Update size values
6032 * @param {boolean} isInit If is called at initialization
6033 * @private
6034 */
6035 updateSizes: function updateSizes(isInit) {
6036 var $$ = this,
6037 config = $$.config,
6038 state = $$.state,
6039 legend = $$.$el.legend,
6040 isRotated = config.axis_rotated,
6041 hasArc = $$.hasArcType();
6042 isInit || $$.setContainerSize();
6043 var currLegend = {
6044 width: legend ? $$.getLegendWidth() : 0,
6045 height: legend ? $$.getLegendHeight() : 0
6046 };
6047 !hasArc && config.axis_x_show && config.axis_x_tick_autorotate && $$.updateXAxisTickClip();
6048 var legendHeightForBottom = state.isLegendRight || state.isLegendInset ? 0 : currLegend.height,
6049 xAxisHeight = isRotated || hasArc ? 0 : $$.getHorizontalAxisHeight("x"),
6050 subchartXAxisHeight = config.subchart_axis_x_show && config.subchart_axis_x_tick_text_show ? xAxisHeight : 30,
6051 subchartHeight = config.subchart_show && !hasArc ? config.subchart_size_height + subchartXAxisHeight : 0;
6052 state.margin = !hasArc && isRotated ? {
6053 top: $$.getHorizontalAxisHeight("y2") + $$.getCurrentPaddingTop(),
6054 right: hasArc ? 0 : $$.getCurrentPaddingRight(!0),
6055 bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom + $$.getCurrentPaddingBottom(),
6056 left: subchartHeight + (hasArc ? 0 : $$.getCurrentPaddingLeft())
6057 } : {
6058 top: 4 + $$.getCurrentPaddingTop(),
6059 // for top tick text
6060 right: hasArc ? 0 : $$.getCurrentPaddingRight(!0),
6061 bottom: xAxisHeight + subchartHeight + legendHeightForBottom + $$.getCurrentPaddingBottom(),
6062 left: hasArc ? 0 : $$.getCurrentPaddingLeft()
6063 }, state.margin2 = isRotated ? {
6064 top: state.margin.top,
6065 right: NaN,
6066 bottom: 20 + legendHeightForBottom,
6067 left: $$.state.rotatedPadding.left
6068 } : {
6069 top: state.current.height - subchartHeight - legendHeightForBottom,
6070 right: NaN,
6071 bottom: subchartXAxisHeight + legendHeightForBottom,
6072 left: state.margin.left
6073 }, state.margin3 = {
6074 top: 0,
6075 right: NaN,
6076 bottom: 0,
6077 left: 0
6078 }, $$.updateSizeForLegend && $$.updateSizeForLegend(currLegend), state.width = state.current.width - state.margin.left - state.margin.right, state.height = state.current.height - state.margin.top - state.margin.bottom, state.width < 0 && (state.width = 0), state.height < 0 && (state.height = 0), state.width2 = isRotated ? state.margin.left - state.rotatedPadding.left - state.rotatedPadding.right : state.width, state.height2 = isRotated ? state.height : state.current.height - state.margin2.top - state.margin2.bottom, state.width2 < 0 && (state.width2 = 0), state.height2 < 0 && (state.height2 = 0);
6079 // for arc
6080 var hasGauge = $$.hasType("gauge"),
6081 isLegendRight = config.legend_show && state.isLegendRight;
6082 state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0), state.arcHeight = state.height - (isLegendRight && !hasGauge ? 0 : 10), hasGauge && !config.gauge_fullCircle && (state.arcHeight += state.height - $$.getPaddingBottomForGauge()), $$.updateRadius && $$.updateRadius(), state.isLegendRight && hasArc && (state.margin3.left = state.arcWidth / 2 + state.radiusExpanded * 1.1);
6083 }
6084});
6085;// CONCATENATED MODULE: ./src/ChartInternal/internals/text.ts
6086/**
6087 * Copyright (c) 2017 ~ present NAVER Corp.
6088 * billboard.js project is licensed under the MIT license
6089 */
6090
6091
6092
6093
6094/* harmony default export */ var internals_text = ({
6095 opacityForText: function opacityForText(d) {
6096 var $$ = this;
6097 return $$.isBarType(d) && !$$.meetsLabelThreshold(Math.abs($$.getRatio("bar", d)), "bar") ? "0" : $$.hasDataLabel ? "1" : "0";
6098 },
6099
6100 /**
6101 * Initializes the text
6102 * @private
6103 */
6104 initText: function initText() {
6105 var $el = this.$el;
6106 $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartTexts);
6107 },
6108
6109 /**
6110 * Update chartText
6111 * @param {object} targets $$.data.targets
6112 * @private
6113 */
6114 updateTargetsForText: function updateTargetsForText(targets) {
6115 var $$ = this,
6116 classChartText = $$.getChartClass("Text"),
6117 classTexts = $$.getClass("texts", "id"),
6118 classFocus = $$.classFocus.bind($$),
6119 mainTextUpdate = $$.$el.main.select("." + config_classes.chartTexts).selectAll("." + config_classes.chartText).data(targets).attr("class", function (d) {
6120 return classChartText(d) + classFocus(d);
6121 }),
6122 mainTextEnter = mainTextUpdate.enter().append("g").style("opacity", "0").attr("class", classChartText).style("pointer-events", "none");
6123 mainTextEnter.append("g").attr("class", classTexts);
6124 },
6125
6126 /**
6127 * Update text
6128 * @param {number} durationForExit Fade-out transition duration
6129 * @private
6130 */
6131 updateText: function updateText(durationForExit) {
6132 var $$ = this,
6133 config = $$.config,
6134 $el = $$.$el,
6135 classText = $$.getClass("text", "index"),
6136 text = $el.main.selectAll("." + config_classes.texts).selectAll("." + config_classes.text).data($$.labelishData.bind($$));
6137 text.exit().transition().duration(durationForExit).style("fill-opacity", "0").remove(), $el.text = text.enter().append("text").merge(text).attr("class", classText).attr("text-anchor", function (d) {
6138 // when value is negative or
6139 var isEndAnchor = d.value < 0;
6140
6141 if ($$.isCandlestickType(d)) {
6142 var data = $$.getCandlestickData(d);
6143 isEndAnchor = data && !data._isUp;
6144 }
6145
6146 return config.axis_rotated ? isEndAnchor ? "end" : "start" : "middle";
6147 }).style("fill", $$.updateTextColor.bind($$)).style("fill-opacity", "0").each(function (d, i, j) {
6148 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
6149 value = d.value;
6150 if ($$.isBubbleZType(d)) value = $$.getBubbleZData(value, "z");else if ($$.isCandlestickType(d)) {
6151 var data = $$.getCandlestickData(d);
6152 data && (value = data.close);
6153 }
6154 value = $$.dataLabelFormat(d.id)(value, d.id, i, j), isNumber(value) ? this.textContent = value : setTextValue(node, value);
6155 });
6156 },
6157 updateTextColor: function updateTextColor(d) {
6158 var color,
6159 $$ = this,
6160 config = $$.config,
6161 labelColors = config.data_labels_colors,
6162 defaultColor = $$.isArcType(d) && !$$.isRadarType(d) ? null : $$.color(d);
6163 if (isString(labelColors)) color = labelColors;else if (isObject(labelColors)) {
6164 var _ref = d.data || d,
6165 id = _ref.id;
6166
6167 color = labelColors[id];
6168 } else isFunction(labelColors) && (color = labelColors.bind($$.api)(defaultColor, d));
6169
6170 if ($$.isCandlestickType(d) && !isFunction(labelColors)) {
6171 var value = $$.getCandlestickData(d);
6172
6173 if (value && !value._isUp) {
6174 var downColor = config.candlestick_color_down;
6175 color = isObject(downColor) ? downColor[d.id] : downColor;
6176 }
6177 }
6178
6179 return color || defaultColor;
6180 },
6181
6182 /**
6183 * Redraw chartText
6184 * @param {Function} x Positioning function for x
6185 * @param {Function} y Positioning function for y
6186 * @param {boolean} forFlow Weather is flow
6187 * @param {boolean} withTransition transition is enabled
6188 * @returns {Array}
6189 * @private
6190 */
6191 redrawText: function redrawText(x, y, forFlow, withTransition) {
6192 var $$ = this,
6193 t = getRandom(!0);
6194 // need to return 'true' as of being pushed to the redraw list
6195 // ref: getRedrawList()
6196 return $$.$el.text.style("fill", $$.updateTextColor.bind($$)).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function (d, i) {
6197 // do not apply transition for newly added text elements
6198 var node = withTransition && this.getAttribute("x") ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).transition(t) : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
6199 posX = x.bind(this)(d, i),
6200 posY = y.bind(this)(d, i);
6201 this.childElementCount ? node.attr("transform", "translate(" + posX + " " + posY + ")") : node.attr("x", posX).attr("y", posY);
6202 }), !0;
6203 },
6204
6205 /**
6206 * Gets the getBoundingClientRect value of the element
6207 * @param {HTMLElement|d3.selection} element Target element
6208 * @param {string} className Class name
6209 * @returns {object} value of element.getBoundingClientRect()
6210 * @private
6211 */
6212 getTextRect: function getTextRect(element, className) {
6213 var $$ = this,
6214 base = element.node ? element.node() : element;
6215 /text/i.test(base.tagName) || (base = base.querySelector("text"));
6216 var text = base.textContent,
6217 cacheKey = KEY.textRect + "-" + text.replace(/\W/g, "_"),
6218 rect = $$.cache.get(cacheKey);
6219 return rect || ($$.$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) {
6220 rect = getBoundingRect(v.node());
6221 }).remove(), $$.cache.add(cacheKey, rect)), rect;
6222 },
6223
6224 /**
6225 * Gets the x or y coordinate of the text
6226 * @param {object} indices Indices values
6227 * @param {boolean} forX whether or not to x
6228 * @returns {number} coordinates
6229 * @private
6230 */
6231 generateXYForText: function generateXYForText(indices, forX) {
6232 var $$ = this,
6233 types = Object.keys(indices),
6234 points = {},
6235 getter = forX ? $$.getXForText : $$.getYForText;
6236 return $$.hasType("radar") && types.push("radar"), types.forEach(function (v) {
6237 points[v] = $$["generateGet" + capitalize(v) + "Points"](indices[v], !1);
6238 }), function (d, i) {
6239 var type = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar" || $$.isCandlestickType(d) && "candlestick" || $$.isRadarType(d) && "radar" || "line";
6240 return getter.call($$, points[type](d, i), d, this);
6241 };
6242 },
6243
6244 /**
6245 * Get centerized text position for bar type data.label.text
6246 * @param {object} d Data object
6247 * @param {Array} points Data points position
6248 * @param {HTMLElement} textElement Data label text element
6249 * @returns {number} Position value
6250 * @private
6251 */
6252 getCenteredTextPos: function getCenteredTextPos(d, points, textElement) {
6253 var $$ = this,
6254 config = $$.config,
6255 isRotated = config.axis_rotated;
6256
6257 if (config.data_labels.centered && $$.isBarType(d)) {
6258 var rect = getBoundingRect(textElement),
6259 isPositive = d.value >= 0;
6260
6261 if (isRotated) {
6262 var w = (isPositive ? points[1][1] - points[0][1] : points[0][1] - points[1][1]) / 2 + rect.width / 2;
6263 return isPositive ? -w - 3 : w + 2;
6264 }
6265
6266 var h = (isPositive ? points[0][1] - points[1][1] : points[1][1] - points[0][1]) / 2 + rect.height / 2;
6267 return isPositive ? h : -h - 2;
6268 }
6269
6270 return 0;
6271 },
6272
6273 /**
6274 * Get data.labels.position value
6275 * @param {string} id Data id value
6276 * @param {string} type x | y
6277 * @returns {number} Position value
6278 * @private
6279 */
6280 getTextPos: function getTextPos(id, type) {
6281 var pos = this.config.data_labels_position;
6282 return (id in pos ? pos[id] : pos)[type] || 0;
6283 },
6284
6285 /**
6286 * Gets the x coordinate of the text
6287 * @param {object} points Data points position
6288 * @param {object} d Data object
6289 * @param {HTMLElement} textElement Data label text element
6290 * @returns {number} x coordinate
6291 * @private
6292 */
6293 getXForText: function getXForText(points, d, textElement) {
6294 var $$ = this,
6295 config = $$.config,
6296 state = $$.state,
6297 isRotated = config.axis_rotated,
6298 xPos = points[0][0];
6299 if ($$.hasType("candlestick")) isRotated ? xPos = $$.getCandlestickData(d)._isUp ? points[2][2] + 4 : points[2][1] - 4 : xPos += (points[1][0] - xPos) / 2;else if (isRotated) {
6300 var padding = $$.isBarType(d) ? 4 : 6;
6301 xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1);
6302 } else xPos = $$.hasType("bar") ? (points[2][0] + points[0][0]) / 2 : xPos; // show labels regardless of the domain if value is null
6303
6304 if (d.value === null) if (xPos > state.width) {
6305 var _getBoundingRect = getBoundingRect(textElement),
6306 width = _getBoundingRect.width;
6307
6308 xPos = state.width - width;
6309 } else xPos < 0 && (xPos = 4);
6310 return isRotated && (xPos += $$.getCenteredTextPos(d, points, textElement)), xPos + $$.getTextPos(d.id, "x");
6311 },
6312
6313 /**
6314 * Gets the y coordinate of the text
6315 * @param {object} points Data points position
6316 * @param {object} d Data object
6317 * @param {HTMLElement} textElement Data label text element
6318 * @returns {number} y coordinate
6319 * @private
6320 */
6321 getYForText: function getYForText(points, d, textElement) {
6322 var yPos,
6323 $$ = this,
6324 config = $$.config,
6325 state = $$.state,
6326 isRotated = config.axis_rotated,
6327 r = config.point_r,
6328 rect = getBoundingRect(textElement),
6329 value = d.value,
6330 baseY = 3;
6331 if ($$.isCandlestickType(d)) value = $$.getCandlestickData(d), isRotated ? (yPos = points[0][0], yPos += (points[1][0] - yPos) / 2 + baseY) : yPos = value && value._isUp ? points[2][2] - baseY : points[2][1] + baseY * 4;else if (isRotated) yPos = (points[0][0] + points[2][0] + rect.height * .6) / 2;else if (yPos = points[2][1], isNumber(r) && r > 5 && ($$.isLineType(d) || $$.isScatterType(d)) && (baseY += config.point_r / 2.3), value < 0 || value === 0 && !state.hasPositiveValue && state.hasNegativeValue) yPos += rect.height + ($$.isBarType(d) ? -baseY : baseY);else {
6332 var diff = -baseY * 2;
6333 $$.isBarType(d) ? diff = -baseY : $$.isBubbleType(d) && (diff = baseY), yPos += diff;
6334 } // show labels regardless of the domain if value is null
6335
6336 if (d.value === null && !isRotated) {
6337 var boxHeight = rect.height;
6338 yPos < boxHeight ? yPos = boxHeight : yPos > state.height && (yPos = state.height - 4);
6339 }
6340
6341 return isRotated || (yPos += $$.getCenteredTextPos(d, points, textElement)), yPos + $$.getTextPos(d.id, "y");
6342 },
6343
6344 /**
6345 * Calculate if two or more text nodes are overlapping
6346 * Mark overlapping text nodes with "text-overlapping" class
6347 * @param {string} id Axis id
6348 * @param {ChartInternal} $$ ChartInternal context
6349 * @param {string} selector Selector string
6350 * @private
6351 */
6352 markOverlapped: function markOverlapped(id, $$, selector) {
6353 var textNodes = $$.$el.arcs.selectAll(selector),
6354 filteredTextNodes = textNodes.filter(function (node) {
6355 return node.data.id !== id;
6356 }),
6357 textNode = textNodes.filter(function (node) {
6358 return node.data.id === id;
6359 }),
6360 translate = getTranslation(textNode.node()),
6361 calcHypo = function (x, y) {
6362 return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
6363 };
6364
6365 textNode.node() && filteredTextNodes.each(function () {
6366 var coordinate = getTranslation(this),
6367 filteredTextNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
6368 nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : filteredTextNode,
6369 overlapsX = Math.ceil(Math.abs(translate.e - coordinate.e)) < Math.ceil(nodeForWidth.node().getComputedTextLength()),
6370 overlapsY = Math.ceil(Math.abs(translate.f - coordinate.f)) < parseInt(textNode.style("font-size"), 10);
6371 filteredTextNode.classed(config_classes.TextOverlapping, overlapsX && overlapsY);
6372 });
6373 },
6374
6375 /**
6376 * Calculate if two or more text nodes are overlapping
6377 * Remove "text-overlapping" class on selected text nodes
6378 * @param {ChartInternal} $$ ChartInternal context
6379 * @param {string} selector Selector string
6380 * @private
6381 */
6382 undoMarkOverlapped: function undoMarkOverlapped($$, selector) {
6383 $$.$el.arcs.selectAll(selector).each(function () {
6384 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([this, this.previousSibling]).classed(config_classes.TextOverlapping, !1);
6385 });
6386 },
6387
6388 /**
6389 * Check if meets the ratio to show data label text
6390 * @param {number} ratio ratio to meet
6391 * @param {string} type chart type
6392 * @returns {boolean}
6393 * @private
6394 */
6395 meetsLabelThreshold: function meetsLabelThreshold(ratio, type) {
6396 ratio === void 0 && (ratio = 0);
6397 var $$ = this,
6398 config = $$.config,
6399 threshold = config[type + "_label_threshold"] || 0;
6400 return ratio >= threshold;
6401 }
6402});
6403;// CONCATENATED MODULE: ./src/ChartInternal/internals/title.ts
6404/**
6405 * Copyright (c) 2017 ~ present NAVER Corp.
6406 * billboard.js project is licensed under the MIT license
6407 */
6408
6409
6410/**
6411 * Get the text position
6412 * @param {string} pos right, left or center
6413 * @param {number} width chart width
6414 * @returns {string|number} text-anchor value or position in pixel
6415 * @private
6416 */
6417
6418function getTextPos(pos, width) {
6419 pos === void 0 && (pos = "left");
6420 var position,
6421 isNum = isNumber(width);
6422 return position = pos.indexOf("center") > -1 ? isNum ? width / 2 : "middle" : pos.indexOf("right") > -1 ? isNum ? width : "end" : isNum ? 0 : "start", position;
6423}
6424
6425/* harmony default export */ var internals_title = ({
6426 /**
6427 * Initializes the title
6428 * @private
6429 */
6430 initTitle: function initTitle() {
6431 var $$ = this,
6432 config = $$.config,
6433 $el = $$.$el;
6434
6435 if (config.title_text) {
6436 $el.title = $el.svg.append("g");
6437 var text = $el.title.append("text").style("text-anchor", getTextPos(config.title_position)).attr("class", config_classes.title);
6438 setTextValue(text, config.title_text, [.3, 1.5]);
6439 }
6440 },
6441
6442 /**
6443 * Redraw title
6444 * @private
6445 */
6446 redrawTitle: function redrawTitle() {
6447 var $$ = this,
6448 config = $$.config,
6449 current = $$.state.current,
6450 title = $$.$el.title;
6451
6452 if (title) {
6453 var y = $$.yForTitle.call($$);
6454 /g/i.test(title.node().tagName) ? title.attr("transform", "translate(" + getTextPos(config.title_position, current.width) + ", " + y + ")") : title.attr("x", $$.xForTitle.call($$)).attr("y", y);
6455 }
6456 },
6457
6458 /**
6459 * Returns the x attribute value of the title
6460 * @returns {number} x attribute value
6461 * @private
6462 */
6463 xForTitle: function xForTitle() {
6464 var x,
6465 $$ = this,
6466 config = $$.config,
6467 current = $$.state.current,
6468 position = config.title_position || "left",
6469 textRectWidth = $$.getTextRect($$.$el.title, config_classes.title).width;
6470 return /(right|center)/.test(position) ? (x = current.width - textRectWidth, position.indexOf("right") >= 0 ? x = current.width - textRectWidth - config.title_padding.right : position.indexOf("center") >= 0 && (x = (current.width - textRectWidth) / 2)) : x = config.title_padding.left || 0, x;
6471 },
6472
6473 /**
6474 * Returns the y attribute value of the title
6475 * @returns {number} y attribute value
6476 * @private
6477 */
6478 yForTitle: function yForTitle() {
6479 var $$ = this;
6480 return ($$.config.title_padding.top || 0) + $$.getTextRect($$.$el.title, config_classes.title).height;
6481 },
6482
6483 /**
6484 * Get title padding
6485 * @returns {number} padding value
6486 * @private
6487 */
6488 getTitlePadding: function getTitlePadding() {
6489 var $$ = this;
6490 return $$.yForTitle() + ($$.config.title_padding.bottom || 0);
6491 }
6492});
6493;// CONCATENATED MODULE: ./src/ChartInternal/internals/tooltip.ts
6494/**
6495 * Copyright (c) 2017 ~ present NAVER Corp.
6496 * billboard.js project is licensed under the MIT license
6497 */
6498
6499
6500
6501
6502/* harmony default export */ var internals_tooltip = ({
6503 /**
6504 * Initializes the tooltip
6505 * @private
6506 */
6507 initTooltip: function initTooltip() {
6508 var $$ = this,
6509 config = $$.config,
6510 $el = $$.$el;
6511 $el.tooltip = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.tooltip_contents.bindto), $el.tooltip.empty() && ($el.tooltip = $el.chart.style("position", "relative").append("div").attr("class", config_classes.tooltipContainer).style("position", "absolute").style("pointer-events", "none").style("display", "none")), $$.bindTooltipResizePos();
6512 },
6513 initShowTooltip: function initShowTooltip() {
6514 var $$ = this,
6515 config = $$.config,
6516 $el = $$.$el,
6517 _$$$state = $$.state,
6518 hasAxis = _$$$state.hasAxis,
6519 hasRadar = _$$$state.hasRadar;
6520
6521 // Show tooltip if needed
6522 if (config.tooltip_init_show) {
6523 var isArc = !(hasAxis && hasRadar);
6524
6525 if ($$.axis && $$.axis.isTimeSeries() && isString(config.tooltip_init_x)) {
6526 var i,
6527 val,
6528 targets = $$.data.targets[0];
6529
6530 for (config.tooltip_init_x = parseDate.call($$, config.tooltip_init_x), i = 0; (val = targets.values[i]) && !(val.x - config.tooltip_init_x === 0); i++);
6531
6532 config.tooltip_init_x = i;
6533 }
6534
6535 var data = $$.data.targets.map(function (d) {
6536 var x = isArc ? 0 : config.tooltip_init_x;
6537 return $$.addName(d.values[x]);
6538 });
6539 isArc && (data = [data[config.tooltip_init_x]]), $el.tooltip.html($$.getTooltipHTML(data, $$.axis && $$.axis.getXAxisTickFormat(), $$.getYFormat($$.hasArcType(null, ["radar"])), $$.color)), config.tooltip_contents.bindto || $el.tooltip.style("top", config.tooltip_init_position.top).style("left", config.tooltip_init_position.left).style("display", "block");
6540 }
6541 },
6542
6543 /**
6544 * Get the tooltip HTML string
6545 * @param {Array} args Arguments
6546 * @returns {string} Formatted HTML string
6547 * @private
6548 */
6549 getTooltipHTML: function getTooltipHTML() {
6550 var $$ = this,
6551 api = $$.api,
6552 config = $$.config;
6553 return isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api).apply(void 0, arguments) : $$.getTooltipContent.apply($$, arguments);
6554 },
6555
6556 /**
6557 * Returns the tooltip content(HTML string)
6558 * @param {object} d data
6559 * @param {Function} defaultTitleFormat Default title format
6560 * @param {Function} defaultValueFormat Default format for each data value in the tooltip.
6561 * @param {Function} color Color function
6562 * @returns {string} html
6563 * @private
6564 */
6565 getTooltipContent: function getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) {
6566 var $$ = this,
6567 api = $$.api,
6568 config = $$.config,
6569 state = $$.state,
6570 _map = ["title", "name", "value"].map(function (v) {
6571 var fn = config["tooltip_format_" + v];
6572 return isFunction(fn) ? fn.bind(api) : fn;
6573 }),
6574 titleFormat = _map[0],
6575 nameFormat = _map[1],
6576 valueFormat = _map[2];
6577
6578 titleFormat = titleFormat || defaultTitleFormat, nameFormat = nameFormat || function (name) {
6579 return name;
6580 }, valueFormat = valueFormat || ($$.isStackNormalized() ? function (v, ratio) {
6581 return (ratio * 100).toFixed(2) + "%";
6582 } : defaultValueFormat);
6583
6584 var order = config.tooltip_order,
6585 getRowValue = function (row) {
6586 return $$.axis && $$.isBubbleZType(row) ? $$.getBubbleZData(row.value, "z") : $$.getBaseValue(row);
6587 },
6588 getBgColor = $$.levelColor ? function (row) {
6589 return $$.levelColor(row.value);
6590 } : function (row) {
6591 return color(row);
6592 },
6593 contents = config.tooltip_contents,
6594 tplStr = contents.template,
6595 targetIds = $$.mapToTargetIds();
6596
6597 if (order === null && config.data_groups.length) {
6598 // for stacked data, order should aligned with the visually displayed data
6599 var ids = $$.orderTargets($$.data.targets).map(function (i2) {
6600 return i2.id;
6601 }).reverse();
6602 d.sort(function (a, b) {
6603 var v1 = a ? a.value : null,
6604 v2 = b ? b.value : null;
6605 return v1 > 0 && v2 > 0 && (v1 = a.id ? ids.indexOf(a.id) : null, v2 = b.id ? ids.indexOf(b.id) : null), v1 - v2;
6606 });
6607 } else if (/^(asc|desc)$/.test(order)) {
6608 d.sort(function (a, b) {
6609 var v1 = a ? getRowValue(a) : null,
6610 v2 = b ? getRowValue(b) : null;
6611 return order === "asc" ? v1 - v2 : v2 - v1;
6612 });
6613 } else isFunction(order) && d.sort(order.bind(api));
6614
6615 var text,
6616 row,
6617 param,
6618 value,
6619 i,
6620 tpl = $$.getTooltipContentTemplate(tplStr),
6621 len = d.length;
6622
6623 for (i = 0; i < len; i++) if (row = d[i], row && (getRowValue(row) || getRowValue(row) === 0)) {
6624 if (isUndefined(text)) {
6625 var title = (state.hasAxis || state.hasRadar) && sanitise(titleFormat ? titleFormat(row.x) : row.x);
6626 text = tplProcess(tpl[0], {
6627 CLASS_TOOLTIP: config_classes.tooltip,
6628 TITLE: isValue(title) ? tplStr ? title : "<tr><th colspan=\"2\">" + title + "</th></tr>" : ""
6629 });
6630 }
6631
6632 if (!row.ratio && $$.$el.arcs && (row.ratio = $$.getRatio("arc", $$.$el.arcs.select("path." + config_classes.arc + "-" + row.id).data()[0])), param = [row.ratio, row.id, row.index, d], value = sanitise(valueFormat.apply(void 0, [getRowValue(row)].concat(param))), $$.isAreaRangeType(row)) {
6633 var _map2 = ["high", "low"].map(function (v) {
6634 return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v)].concat(param)));
6635 }),
6636 high = _map2[0],
6637 low = _map2[1];
6638
6639 value = "<b>Mid:</b> " + value + " <b>High:</b> " + high + " <b>Low:</b> " + low;
6640 } else if ($$.isCandlestickType(row)) {
6641 var _map3 = ["open", "high", "low", "close", "volume"].map(function (v) {
6642 return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v, "candlestick")].concat(param)));
6643 }),
6644 open = _map3[0],
6645 _high = _map3[1],
6646 _low = _map3[2],
6647 close = _map3[3],
6648 volume = _map3[4];
6649
6650 value = "<b>Open:</b> " + open + " <b>High:</b> " + _high + " <b>Low:</b> " + _low + " <b>Close:</b> " + close + (volume ? " <b>Volume:</b> " + volume : "");
6651 }
6652
6653 if (value !== undefined) {
6654 var _ret = function () {
6655 // Skip elements when their name is set to null
6656 if (row.name === null) return "continue";
6657 var name = sanitise(nameFormat.apply(void 0, [row.name].concat(param))),
6658 color = getBgColor(row),
6659 contentValue = {
6660 CLASS_TOOLTIP_NAME: config_classes.tooltipName + $$.getTargetSelectorSuffix(row.id),
6661 COLOR: tplStr || !$$.patterns ? color : "<svg><rect style=\"fill:" + color + "\" width=\"10\" height=\"10\"></rect></svg>",
6662 NAME: name,
6663 VALUE: value
6664 };
6665
6666 if (tplStr && isObject(contents.text)) {
6667 var index = targetIds.indexOf(row.id);
6668 Object.keys(contents.text).forEach(function (key) {
6669 contentValue[key] = contents.text[key][index];
6670 });
6671 }
6672
6673 text += tplProcess(tpl[1], contentValue);
6674 }();
6675
6676 if (_ret === "continue") continue;
6677 }
6678 }
6679
6680 return text + "</table>";
6681 },
6682
6683 /**
6684 * Get the content template string
6685 * @param {string} tplStr Tempalte string
6686 * @returns {Array} Template string
6687 * @private
6688 */
6689 getTooltipContentTemplate: function getTooltipContentTemplate(tplStr) {
6690 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(/{{(.*)}}/);
6691 },
6692
6693 /**
6694 * Returns the position of the tooltip
6695 * @param {object} dataToShow data
6696 * @param {string} tWidth Width value of tooltip element
6697 * @param {string} tHeight Height value of tooltip element
6698 * @param {HTMLElement} element Tooltip element
6699 * @returns {object} top, left value
6700 * @private
6701 */
6702 tooltipPosition: function tooltipPosition(dataToShow, tWidth, tHeight, element) {
6703 var $$ = this,
6704 config = $$.config,
6705 scale = $$.scale,
6706 state = $$.state,
6707 _state = state,
6708 width = _state.width,
6709 height = _state.height,
6710 current = _state.current,
6711 isLegendRight = _state.isLegendRight,
6712 inputType = _state.inputType,
6713 event = _state.event,
6714 hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle,
6715 svgLeft = $$.getSvgLeft(!0),
6716 chartRight = svgLeft + current.width - $$.getCurrentPaddingRight(),
6717 chartLeft = $$.getCurrentPaddingLeft(!0),
6718 size = 20,
6719 _getPointer = getPointer(event, element),
6720 x = _getPointer[0],
6721 y = _getPointer[1];
6722
6723 // Determine tooltip position
6724 if ($$.hasArcType()) {
6725 var raw = inputType === "touch" || $$.hasType("radar");
6726 raw || (y += hasGauge ? height : height / 2, x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2);
6727 } else {
6728 var dataScale = scale.x(dataToShow[0].x);
6729 config.axis_rotated ? (y = dataScale + size, x += svgLeft + 100, chartRight -= svgLeft) : (y -= 5, x = svgLeft + chartLeft + size + ($$.zoomScale ? x : dataScale));
6730 } // when tooltip left + tWidth > chart's width
6731
6732
6733 x + tWidth + 15 > chartRight && (x -= tWidth + chartLeft), y + tHeight > current.height && (y -= hasGauge ? tHeight * 3 : tHeight + 30);
6734 var pos = {
6735 top: y,
6736 left: x
6737 }; // make sure to not be positioned out of viewport
6738
6739 return Object.keys(pos).forEach(function (v) {
6740 pos[v] < 0 && (pos[v] = 0);
6741 }), pos;
6742 },
6743
6744 /**
6745 * Show the tooltip
6746 * @param {object} selectedData Data object
6747 * @param {HTMLElement} element Tooltip element
6748 * @private
6749 */
6750 showTooltip: function showTooltip(selectedData, element) {
6751 var $$ = this,
6752 config = $$.config,
6753 state = $$.state,
6754 tooltip = $$.$el.tooltip,
6755 bindto = config.tooltip_contents.bindto,
6756 forArc = $$.hasArcType(null, ["radar"]),
6757 dataToShow = selectedData.filter(function (d) {
6758 return d && isValue($$.getBaseValue(d));
6759 });
6760
6761 if (tooltip && dataToShow.length !== 0 && config.tooltip_show) {
6762 var datum = tooltip.datum(),
6763 _ref = datum || {},
6764 _ref$width = _ref.width,
6765 width = _ref$width === void 0 ? 0 : _ref$width,
6766 _ref$height = _ref.height,
6767 height = _ref$height === void 0 ? 0 : _ref$height,
6768 dataStr = JSON.stringify(selectedData);
6769
6770 if (!datum || datum.current !== dataStr) {
6771 var index = selectedData.concat().sort()[0].index;
6772 callFn(config.tooltip_onshow, $$.api, selectedData), tooltip.html($$.getTooltipHTML(selectedData, // data
6773 $$.axis ? $$.axis.getXAxisTickFormat() : $$.categoryName.bind($$), // defaultTitleFormat
6774 $$.getYFormat(forArc), // defaultValueFormat
6775 $$.color // color
6776 )).style("display", null).style("visibility", null) // for IE9
6777 .datum(datum = {
6778 index: index,
6779 current: dataStr,
6780 width: width = tooltip.property("offsetWidth"),
6781 height: height = tooltip.property("offsetHeight")
6782 }), callFn(config.tooltip_onshown, $$.api, selectedData), $$._handleLinkedCharts(!0, index);
6783 }
6784
6785 if (!bindto) {
6786 var fnPos = config.tooltip_position || $$.tooltipPosition,
6787 pos = fnPos.call(this, dataToShow, width, height, element); // Get tooltip dimensions
6788
6789 ["top", "left"].forEach(function (v) {
6790 var value = pos[v];
6791 tooltip.style(v, value + "px"), v !== "left" || datum.xPosInPercent || (datum.xPosInPercent = value / state.current.width * 100);
6792 });
6793 }
6794 }
6795 },
6796
6797 /**
6798 * Adjust tooltip position on resize event
6799 * @private
6800 */
6801 bindTooltipResizePos: function bindTooltipResizePos() {
6802 var $$ = this,
6803 resizeFunction = $$.resizeFunction,
6804 state = $$.state,
6805 tooltip = $$.$el.tooltip;
6806 resizeFunction.add(function () {
6807 if (tooltip.style("display") === "block") {
6808 var current = state.current,
6809 _tooltip$datum = tooltip.datum(),
6810 width = _tooltip$datum.width,
6811 xPosInPercent = _tooltip$datum.xPosInPercent,
6812 _value = current.width / 100 * xPosInPercent,
6813 diff = current.width - (_value + width);
6814
6815 diff < 0 && (_value += diff), tooltip.style("left", _value + "px");
6816 }
6817 });
6818 },
6819
6820 /**
6821 * Hide the tooltip
6822 * @param {boolean} force Force to hide
6823 * @private
6824 */
6825 hideTooltip: function hideTooltip(force) {
6826 var $$ = this,
6827 api = $$.api,
6828 config = $$.config,
6829 tooltip = $$.$el.tooltip;
6830
6831 if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
6832 var selectedData = JSON.parse(tooltip.datum().current);
6833 // hide tooltip
6834 callFn(config.tooltip_onhide, api, selectedData), tooltip.style("display", "none").style("visibility", "hidden") // for IE9
6835 .datum(null), callFn(config.tooltip_onhidden, api, selectedData);
6836 }
6837 },
6838
6839 /**
6840 * Toggle display for linked chart instances
6841 * @param {boolean} show true: show, false: hide
6842 * @param {number} index x Axis index
6843 * @private
6844 */
6845 _handleLinkedCharts: function _handleLinkedCharts(show, index) {
6846 var $$ = this,
6847 charts = $$.charts,
6848 config = $$.config,
6849 event = $$.state.event;
6850
6851 // Prevent propagation among instances if isn't instantiated from the user's event
6852 // https://github.com/naver/billboard.js/issues/1979
6853 if (event && event.isTrusted && config.tooltip_linked && charts.length > 1) {
6854 var linkedName = config.tooltip_linked_name;
6855 charts.filter(function (c) {
6856 return c !== $$.api;
6857 }).forEach(function (c) {
6858 var _c$internal = c.internal,
6859 config = _c$internal.config,
6860 $el = _c$internal.$el,
6861 isLinked = config.tooltip_linked,
6862 name = config.tooltip_linked_name,
6863 isInDom = browser_doc.body.contains($el.chart.node());
6864
6865 if (isLinked && linkedName === name && isInDom) {
6866 var data = $el.tooltip.data()[0],
6867 isNotSameIndex = index !== (data && data.index);
6868
6869 try {
6870 c.tooltip[show && isNotSameIndex ? "show" : "hide"]({
6871 index: index
6872 });
6873 } catch (e) {}
6874 }
6875 });
6876 }
6877 }
6878});
6879;// CONCATENATED MODULE: ./src/ChartInternal/internals/transform.ts
6880/**
6881 * Copyright (c) 2017 ~ present NAVER Corp.
6882 * billboard.js project is licensed under the MIT license
6883 */
6884
6885
6886/* harmony default export */ var transform = ({
6887 getTranslate: function getTranslate(target, index) {
6888 index === void 0 && (index = 0);
6889 var x,
6890 y,
6891 $$ = this,
6892 config = $$.config,
6893 state = $$.state,
6894 isRotated = config.axis_rotated,
6895 padding = 0;
6896 if (index && /^(x|y2?)$/.test(target) && (padding = $$.getAxisSize(target) * index), target === "main") x = asHalfPixel(state.margin.left), y = asHalfPixel(state.margin.top);else if (target === "context") x = asHalfPixel(state.margin2.left), y = asHalfPixel(state.margin2.top);else if (target === "legend") x = state.margin3.left, y = state.margin3.top;else if (target === "x") x = isRotated ? -padding : 0, y = isRotated ? 0 : state.height + padding;else if (target === "y") x = isRotated ? 0 : -padding, y = isRotated ? state.height + padding : 0;else if (target === "y2") x = isRotated ? 0 : state.width + padding, y = isRotated ? 1 - padding : 0;else if (target === "subX") x = 0, y = isRotated ? 0 : state.height2;else if (target === "arc") x = state.arcWidth / 2, y = state.arcHeight / 2;else if (target === "radar") {
6897 var _$$$getRadarSize = $$.getRadarSize(),
6898 width = _$$$getRadarSize[0];
6899
6900 x = state.width / 2 - width, y = asHalfPixel(state.margin.top);
6901 }
6902 return "translate(" + x + ", " + y + ")";
6903 },
6904 transformMain: function transformMain(withTransition, transitions) {
6905 var xAxis,
6906 yAxis,
6907 y2Axis,
6908 $$ = this,
6909 main = $$.$el.main;
6910 transitions && transitions.axisX ? xAxis = transitions.axisX : (xAxis = main.select("." + config_classes.axisX), withTransition && (xAxis = xAxis.transition())), transitions && transitions.axisY ? yAxis = transitions.axisY : (yAxis = main.select("." + config_classes.axisY), withTransition && (yAxis = yAxis.transition())), transitions && transitions.axisY2 ? y2Axis = transitions.axisY2 : (y2Axis = main.select("." + config_classes.axisY2), withTransition && (y2Axis = y2Axis.transition())), (withTransition ? main.transition() : main).attr("transform", $$.getTranslate("main")), xAxis.attr("transform", $$.getTranslate("x")), yAxis.attr("transform", $$.getTranslate("y")), y2Axis.attr("transform", $$.getTranslate("y2")), main.select("." + config_classes.chartArcs).attr("transform", $$.getTranslate("arc"));
6911 },
6912 transformAll: function transformAll(withTransition, transitions) {
6913 var $$ = this,
6914 config = $$.config,
6915 hasAxis = $$.state.hasAxis,
6916 $el = $$.$el;
6917 $$.transformMain(withTransition, transitions), hasAxis && config.subchart_show && $$.transformContext(withTransition, transitions), $el.legend && $$.transformLegend(withTransition);
6918 }
6919});
6920;// CONCATENATED MODULE: ./src/ChartInternal/internals/type.ts
6921/**
6922 * Copyright (c) 2017 ~ present NAVER Corp.
6923 * billboard.js project is licensed under the MIT license
6924 */
6925
6926
6927/* harmony default export */ var type = ({
6928 setTargetType: function setTargetType(targetIds, type) {
6929 var $$ = this,
6930 config = $$.config,
6931 withoutFadeIn = $$.state.withoutFadeIn;
6932 $$.mapToTargetIds(targetIds).forEach(function (id) {
6933 withoutFadeIn[id] = type === config.data_types[id], config.data_types[id] = type;
6934 }), targetIds || (config.data_type = type);
6935 },
6936
6937 /**
6938 * Updte current used chart types
6939 * @private
6940 */
6941 updateTypesElements: function updateTypesElements() {
6942 var $$ = this,
6943 current = $$.state.current;
6944 // Update current chart elements reference
6945 Object.keys(TYPE).forEach(function (v) {
6946 var t = TYPE[v],
6947 has = $$.hasType(t, null, !0),
6948 idx = current.types.indexOf(t);
6949 idx === -1 && has ? current.types.push(t) : idx > -1 && !has && current.types.splice(idx, 1);
6950 }), $$.setChartElements();
6951 },
6952
6953 /**
6954 * Check if given chart types exists
6955 * @param {string} type Chart type
6956 * @param {Array} targetsValue Data array
6957 * @param {boolean} checkFromData Force to check type cotains from data targets
6958 * @returns {boolean}
6959 * @private
6960 */
6961 hasType: function hasType(type, targetsValue, checkFromData) {
6962 checkFromData === void 0 && (checkFromData = !1);
6963 var $$ = this,
6964 config = $$.config,
6965 current = $$.state.current,
6966 types = config.data_types,
6967 targets = targetsValue || $$.data.targets,
6968 has = !1;
6969 return !checkFromData && current.types.length && current.types.indexOf(type) > -1 ? has = !0 : targets && targets.length ? targets.forEach(function (target) {
6970 var t = types[target.id];
6971 t !== type && (t || type !== "line") || (has = !0);
6972 }) : Object.keys(types).length ? Object.keys(types).forEach(function (id) {
6973 types[id] === type && (has = !0);
6974 }) : has = config.data_type === type, has;
6975 },
6976
6977 /**
6978 * Check if contains given chart types
6979 * @param {string} type Type key
6980 * @param {object} targets Target data
6981 * @param {Array} exclude Excluded types
6982 * @returns {boolean}
6983 * @private
6984 */
6985 hasTypeOf: function hasTypeOf(type, targets, exclude) {
6986 var _this = this;
6987
6988 return exclude === void 0 && (exclude = []), !!(type in TYPE_BY_CATEGORY) && !TYPE_BY_CATEGORY[type].filter(function (v) {
6989 return exclude.indexOf(v) === -1;
6990 }).every(function (v) {
6991 return !_this.hasType(v, targets);
6992 });
6993 },
6994
6995 /**
6996 * Check if given data is certain chart type
6997 * @param {object} d Data object
6998 * @param {string|Array} type chart type
6999 * @returns {boolean}
7000 * @private
7001 */
7002 isTypeOf: function isTypeOf(d, type) {
7003 var id = isString(d) ? d : d.id,
7004 dataType = this.config.data_types[id] || this.config.data_type;
7005 return isArray(type) ? type.indexOf(dataType) >= 0 : dataType === type;
7006 },
7007 hasPointType: function hasPointType() {
7008 var $$ = this;
7009 return $$.hasTypeOf("Line") || $$.hasType("bubble") || $$.hasType("scatter");
7010 },
7011
7012 /**
7013 * Check if contains arc types chart
7014 * @param {object} targets Target data
7015 * @param {Array} exclude Excluded types
7016 * @returns {boolean}
7017 * @private
7018 */
7019 hasArcType: function hasArcType(targets, exclude) {
7020 return this.hasTypeOf("Arc", targets, exclude);
7021 },
7022 hasMultiArcGauge: function hasMultiArcGauge() {
7023 return this.hasType("gauge") && this.config.gauge_type === "multi";
7024 },
7025 isLineType: function isLineType(d) {
7026 var id = isString(d) ? d : d.id;
7027 return !this.config.data_types[id] || this.isTypeOf(id, TYPE_BY_CATEGORY.Line);
7028 },
7029 isStepType: function isStepType(d) {
7030 return this.isTypeOf(d, TYPE_BY_CATEGORY.Step);
7031 },
7032 isSplineType: function isSplineType(d) {
7033 return this.isTypeOf(d, TYPE_BY_CATEGORY.Spline);
7034 },
7035 isAreaType: function isAreaType(d) {
7036 return this.isTypeOf(d, TYPE_BY_CATEGORY.Area);
7037 },
7038 isAreaRangeType: function isAreaRangeType(d) {
7039 return this.isTypeOf(d, TYPE_BY_CATEGORY.AreaRange);
7040 },
7041 isBarType: function isBarType(d) {
7042 return this.isTypeOf(d, "bar");
7043 },
7044 isBubbleType: function isBubbleType(d) {
7045 return this.isTypeOf(d, "bubble");
7046 },
7047 isCandlestickType: function isCandlestickType(d) {
7048 return this.isTypeOf(d, "candlestick");
7049 },
7050 isScatterType: function isScatterType(d) {
7051 return this.isTypeOf(d, "scatter");
7052 },
7053 isPieType: function isPieType(d) {
7054 return this.isTypeOf(d, "pie");
7055 },
7056 isGaugeType: function isGaugeType(d) {
7057 return this.isTypeOf(d, "gauge");
7058 },
7059 isDonutType: function isDonutType(d) {
7060 return this.isTypeOf(d, "donut");
7061 },
7062 isRadarType: function isRadarType(d) {
7063 return this.isTypeOf(d, "radar");
7064 },
7065 isArcType: function isArcType(d) {
7066 return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d) || this.isRadarType(d);
7067 },
7068 // determine if is 'circle' data point
7069 isCirclePoint: function isCirclePoint(node) {
7070 var config = this.config,
7071 pattern = config.point_pattern,
7072 isCircle = !1;
7073 return isCircle = !!(node && node.tagName === "circle") || config.point_type === "circle" && (!pattern || isArray(pattern) && pattern.length === 0), isCircle;
7074 },
7075 lineData: function lineData(d) {
7076 return this.isLineType(d) ? [d] : [];
7077 },
7078 arcData: function arcData(d) {
7079 return this.isArcType(d.data) ? [d] : [];
7080 },
7081
7082 /**
7083 * Get data adapt for data label showing
7084 * @param {object} d Data object
7085 * @returns {Array}
7086 * @private
7087 */
7088 labelishData: function labelishData(d) {
7089 return this.isBarType(d) || this.isLineType(d) || this.isScatterType(d) || this.isBubbleType(d) || this.isCandlestickType(d) || this.isRadarType(d) ? d.values.filter(function (v) {
7090 return isNumber(v.value) || !!v.value;
7091 }) : [];
7092 },
7093 barLineBubbleData: function barLineBubbleData(d) {
7094 return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ? d.values : [];
7095 },
7096 // https://github.com/d3/d3-shape#curves
7097 isInterpolationType: function isInterpolationType(type) {
7098 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;
7099 }
7100});
7101;// CONCATENATED MODULE: ./src/ChartInternal/ChartInternal.ts
7102/**
7103 * Copyright (c) 2017 ~ present NAVER Corp.
7104 * billboard.js project is licensed under the MIT license
7105 * @ignore
7106 */
7107
7108
7109
7110
7111
7112
7113
7114
7115 // data
7116
7117
7118
7119 // interactions
7120
7121 // internals
7122
7123
7124 // used to retrieve radar Axis name
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139/**
7140 * Internal chart class.
7141 * - Note: Instantiated internally, not exposed for public.
7142 * @class ChartInternal
7143 * @ignore
7144 * @private
7145 */
7146
7147var ChartInternal = /*#__PURE__*/function () {
7148 // API interface
7149 // config object
7150 // cache instance
7151 // elements
7152 // state variables
7153 // all Chart instances array within page (equivalent of 'bb.instances')
7154 // data object
7155 // Axis
7156 // Axis
7157 // scales
7158 // original values
7159 // formatter function
7160 // format function
7161 function ChartInternal(api) {
7162 this.api = void 0, this.config = void 0, this.cache = void 0, this.$el = void 0, this.state = void 0, this.charts = void 0, this.data = {
7163 xs: {},
7164 targets: []
7165 }, this.axis = void 0, this.scale = {
7166 x: null,
7167 y: null,
7168 y2: null,
7169 subX: null,
7170 subY: null,
7171 subY2: null,
7172 zoom: null
7173 }, this.org = {
7174 xScale: null,
7175 xDomain: null
7176 }, this.color = void 0, this.patterns = void 0, this.levelColor = void 0, this.point = void 0, this.brush = void 0, this.format = {
7177 extraLineClasses: null,
7178 xAxisTick: null,
7179 dataTime: null,
7180 // dataTimeFormat
7181 defaultAxisTime: null,
7182 // defaultAxisTimeFormat
7183 axisTime: null // axisTimeFormat
7184
7185 };
7186 var $$ = this;
7187 $$.api = api, $$.config = new Options(), $$.cache = new Cache();
7188 var store = new Store();
7189 $$.$el = store.getStore("element"), $$.state = store.getStore("state");
7190 }
7191
7192 var _proto = ChartInternal.prototype;
7193 return _proto.beforeInit = function beforeInit() {
7194 var $$ = this;
7195 $$.callPluginHook("$beforeInit"), callFn($$.config.onbeforeinit, $$.api);
7196 }, _proto.afterInit = function afterInit() {
7197 var $$ = this;
7198 $$.callPluginHook("$afterInit"), callFn($$.config.onafterinit, $$.api);
7199 }, _proto.init = function init() {
7200 var $$ = this,
7201 config = $$.config,
7202 state = $$.state,
7203 $el = $$.$el;
7204 state.hasAxis = !$$.hasArcType(), state.hasRadar = !state.hasAxis && $$.hasType("radar"), $$.initParams();
7205 var bindto = {
7206 element: config.bindto,
7207 classname: "bb"
7208 };
7209 isObject(config.bindto) && (bindto.element = config.bindto.element || "#chart", bindto.classname = config.bindto.classname || bindto.classname), $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 || []), $el.chart.empty() && ($el.chart = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.body.appendChild(browser_doc.createElement("div")))), $el.chart.html("").classed(bindto.classname, !0), $$.initToRender();
7210 }
7211 /**
7212 * Initialize the rendering process
7213 * @param {boolean} forced Force to render process
7214 * @private
7215 */
7216 , _proto.initToRender = function initToRender(forced) {
7217 var $$ = this,
7218 config = $$.config,
7219 state = $$.state,
7220 chart = $$.$el.chart,
7221 isHidden = function () {
7222 return chart.style("display") === "none" || chart.style("visibility") === "hidden";
7223 },
7224 isLazy = config.render.lazy || isHidden(),
7225 MutationObserver = win.MutationObserver;
7226
7227 if (isLazy && MutationObserver && config.render.observe !== !1 && !forced && new MutationObserver(function (mutation, observer) {
7228 isHidden() || (observer.disconnect(), !state.rendered && $$.initToRender(!0));
7229 }).observe(chart.node(), {
7230 attributes: !0,
7231 attributeFilter: ["class", "style"]
7232 }), !isLazy || forced) {
7233 var convertedData = $$.convertData(config, $$.initWithData);
7234 convertedData && $$.initWithData(convertedData), $$.afterInit();
7235 }
7236 }, _proto.initParams = function initParams() {
7237 var $$ = this,
7238 _ref = $$,
7239 config = _ref.config,
7240 format = _ref.format,
7241 state = _ref.state,
7242 isRotated = config.axis_rotated;
7243
7244 if (state.datetimeId = "bb-" + +new Date(), $$.color = $$.generateColor(), $$.levelColor = $$.generateLevelColor(), $$.hasPointType() && ($$.point = $$.generatePoint()), state.hasAxis) {
7245 $$.initClip(), format.extraLineClasses = $$.generateExtraLineClass(), 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, 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;
7246 var isDragZoom = $$.config.zoom_enabled && $$.config.zoom_type === "drag";
7247
7248 format.defaultAxisTime = function (d) {
7249 var _$$$scale = $$.scale,
7250 x = _$$$scale.x,
7251 zoom = _$$$scale.zoom,
7252 isZoomed = isDragZoom ? zoom : zoom && x.orgDomain().toString() !== zoom.domain().toString(),
7253 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";
7254 return format.axisTime(specifier)(d);
7255 };
7256 }
7257
7258 state.isLegendRight = config.legend_position === "right", state.isLegendInset = config.legend_position === "inset", state.isLegendTop = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "top-right", state.isLegendLeft = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "bottom-left", state.rotatedPaddingRight = isRotated && !config.axis_x_show ? 0 : 30, state.inputType = convertInputType(config.interaction_inputType_mouse, config.interaction_inputType_touch);
7259 }, _proto.initWithData = function initWithData(data) {
7260 var $$ = this,
7261 config = $$.config,
7262 scale = $$.scale,
7263 state = $$.state,
7264 $el = $$.$el,
7265 org = $$.org,
7266 hasAxis = state.hasAxis,
7267 hasInteraction = config.interaction_enabled;
7268 hasAxis && ($$.axis = $$.getAxisInstance(), config.zoom_enabled && $$.initZoom()), $$.data.xs = {}, $$.data.targets = $$.convertDataToTargets(data), config.data_filter && ($$.data.targets = $$.data.targets.filter(config.data_filter.bind($$.api))), config.data_hide && $$.addHiddenTargetIds(config.data_hide === !0 ? $$.mapToIds($$.data.targets) : config.data_hide), config.legend_hide && $$.addHiddenLegendIds(config.legend_hide === !0 ? $$.mapToIds($$.data.targets) : config.legend_hide), $$.updateSizes(), $$.updateScales(!0);
7269 // retrieve scale after the 'updateScales()' is called
7270 var x = scale.x,
7271 y = scale.y,
7272 y2 = scale.y2,
7273 subX = scale.subX,
7274 subY = scale.subY,
7275 subY2 = scale.subY2; // Set domains for each scale
7276
7277 if (x && (x.domain(sortValue($$.getXDomain($$.data.targets))), subX.domain(x.domain()), org.xDomain = x.domain()), y && (y.domain($$.getYDomain($$.data.targets, "y")), subY.domain(y.domain())), y2 && (y2.domain($$.getYDomain($$.data.targets, "y2")), subY2 && subY2.domain(y2.domain())), $el.svg = $el.chart.append("svg").style("overflow", "hidden").style("display", "block"), hasInteraction && state.inputType) {
7278 var isTouch = state.inputType === "touch";
7279 $el.svg.on(isTouch ? "touchstart" : "mouseenter", function () {
7280 return callFn(config.onover, $$.api);
7281 }).on(isTouch ? "touchend" : "mouseleave", function () {
7282 return callFn(config.onout, $$.api);
7283 });
7284 }
7285
7286 config.svg_classname && $el.svg.attr("class", config.svg_classname);
7287 // Define defs
7288 var hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
7289 (hasAxis || hasColorPatterns) && ($el.defs = $el.svg.append("defs"), hasAxis && ["id", "idXAxis", "idYAxis", "idGrid"].forEach(function (v) {
7290 $$.appendClip($el.defs, state.clip[v]);
7291 }), hasColorPatterns && $$.patterns.forEach(function (p) {
7292 return $el.defs.append(function () {
7293 return p.node;
7294 });
7295 })), $$.updateSvgSize(), $$.bindResize();
7296 // Define regions
7297 var main = $el.svg.append("g").classed(config_classes.main, !0).attr("transform", $$.getTranslate("main"));
7298
7299 // data.onmin/max callback
7300 if ($el.main = main, config.subchart_show && $$.initSubchart(), config.tooltip_show && $$.initTooltip(), config.title_text && $$.initTitle(), config.legend_show && $$.initLegend(), config.data_empty_label_text && 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.
7301 .attr("dominant-baseline", "middle"), hasAxis && (config.regions.length && $$.initRegion(), !config.clipPath && $$.axis.init()), main.append("g").attr("class", config_classes.chart).attr("clip-path", state.clip.path), $$.callPluginHook("$init"), hasAxis && (hasInteraction && $$.initEventRect && $$.initEventRect(), $$.initGrid(), config.clipPath && $$.axis && $$.axis.init()), $$.initChartElements(), $$.updateTargets($$.data.targets), $$.updateDimension(), callFn(config.oninit, $$.api), $$.setBackground(), $$.redraw({
7302 withTransition: !1,
7303 withTransform: !0,
7304 withUpdateXDomain: !0,
7305 withUpdateOrgXDomain: !0,
7306 withTransitionForAxis: !1,
7307 initializing: !0
7308 }), config.data_onmin || config.data_onmax) {
7309 var minMax = $$.getMinMaxData();
7310 callFn(config.data_onmin, $$.api, minMax.min), callFn(config.data_onmax, $$.api, minMax.max);
7311 }
7312
7313 config.tooltip_show && $$.initShowTooltip(), state.rendered = !0;
7314 }, _proto.initChartElements = function initChartElements() {
7315 var $$ = this,
7316 _$$$state = $$.state,
7317 hasAxis = _$$$state.hasAxis,
7318 hasRadar = _$$$state.hasRadar,
7319 types = [];
7320 hasAxis ? ["bar", "bubble", "candlestick", "line"].forEach(function (v) {
7321 var name = capitalize(v);
7322 (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) && types.push(name);
7323 }) : (!hasRadar && types.push("Arc", "Pie"), $$.hasType("gauge") ? types.push("Gauge") : hasRadar && types.push("Radar")), types.forEach(function (v) {
7324 $$["init" + v]();
7325 }), notEmpty($$.config.data_labels) && !$$.hasArcType(null, ["radar"]) && $$.initText();
7326 }, _proto.setChartElements = function setChartElements() {
7327 var $$ = this,
7328 _$$$$el = $$.$el,
7329 chart = _$$$$el.chart,
7330 svg = _$$$$el.svg,
7331 defs = _$$$$el.defs,
7332 main = _$$$$el.main,
7333 tooltip = _$$$$el.tooltip,
7334 legend = _$$$$el.legend,
7335 title = _$$$$el.title,
7336 grid = _$$$$el.grid,
7337 arc = _$$$$el.arcs,
7338 circles = _$$$$el.circle,
7339 bars = _$$$$el.bar,
7340 candlestick = _$$$$el.candlestick,
7341 lines = _$$$$el.line,
7342 areas = _$$$$el.area,
7343 texts = _$$$$el.text;
7344 $$.api.$ = {
7345 chart: chart,
7346 svg: svg,
7347 defs: defs,
7348 main: main,
7349 tooltip: tooltip,
7350 legend: legend,
7351 title: title,
7352 grid: grid,
7353 arc: arc,
7354 circles: circles,
7355 bar: {
7356 bars: bars
7357 },
7358 candlestick: candlestick,
7359 line: {
7360 lines: lines,
7361 areas: areas
7362 },
7363 text: {
7364 texts: texts
7365 }
7366 };
7367 }
7368 /**
7369 * Set background element/image
7370 * @private
7371 */
7372 , _proto.setBackground = function setBackground() {
7373 var $$ = this,
7374 bg = $$.config.background,
7375 state = $$.state,
7376 svg = $$.$el.svg;
7377
7378 if (notEmpty(bg)) {
7379 var element = svg.select("g").insert(bg.imgUrl ? "image" : "rect", ":first-child");
7380 bg.imgUrl ? element.attr("href", bg.imgUrl) : bg.color && element.style("fill", bg.color).attr("clip-path", state.clip.path), element.attr("class", bg.class || null).attr("width", "100%").attr("height", "100%");
7381 }
7382 }
7383 /**
7384 * Update targeted element with given data
7385 * @param {object} targets Data object formatted as 'target'
7386 * @private
7387 */
7388 , _proto.updateTargets = function updateTargets(targets) {
7389 var $$ = this,
7390 _$$$state2 = $$.state,
7391 hasAxis = _$$$state2.hasAxis,
7392 hasRadar = _$$$state2.hasRadar;
7393 $$.updateTargetsForText(targets), hasAxis ? (["bar", "candlestick", "line"].forEach(function (v) {
7394 var name = capitalize(v);
7395 (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) && $$["updateTargetsFor" + name](targets.filter($$["is" + name + "Type"].bind($$)));
7396 }), $$.updateTargetsForSubchart && $$.updateTargetsForSubchart(targets)) : $$.hasArcType(targets) && (hasRadar ? $$.updateTargetsForRadar(targets.filter($$.isRadarType.bind($$))) : $$.updateTargetsForArc(targets.filter($$.isArcType.bind($$)))), ($$.hasType("bubble") || $$.hasType("scatter")) && $$.updateTargetForCircle && $$.updateTargetForCircle(), $$.showTargets();
7397 }
7398 /**
7399 * Display targeted elements
7400 * @private
7401 */
7402 , _proto.showTargets = function showTargets() {
7403 var $$ = this,
7404 config = $$.config,
7405 svg = $$.$el.svg;
7406 svg.selectAll("." + config_classes.target).filter(function (d) {
7407 return $$.isTargetToShow(d.id);
7408 }).transition().duration(config.transition_duration).style("opacity", "1");
7409 }, _proto.getWithOption = function getWithOption(options) {
7410 var withOptions = {
7411 Y: !0,
7412 Subchart: !0,
7413 Transition: !0,
7414 EventRect: !0,
7415 Dimension: !0,
7416 TrimXDomain: !0,
7417 Transform: !1,
7418 UpdateXDomain: !1,
7419 UpdateOrgXDomain: !1,
7420 Legend: !1,
7421 UpdateXAxis: "UpdateXDomain",
7422 TransitionForExit: "Transition",
7423 TransitionForAxis: "Transition"
7424 };
7425 return Object.keys(withOptions).forEach(function (key) {
7426 var defVal = withOptions[key];
7427 isString(defVal) && (defVal = withOptions[defVal]), withOptions[key] = getOption(options, "with" + key, defVal);
7428 }), withOptions;
7429 }, _proto.initialOpacity = function initialOpacity(d) {
7430 var $$ = this,
7431 withoutFadeIn = $$.state.withoutFadeIn;
7432 return $$.getBaseValue(d) !== null && withoutFadeIn[d.id] ? "1" : "0";
7433 }, _proto.bindResize = function bindResize() {
7434 var $$ = this,
7435 config = $$.config,
7436 state = $$.state,
7437 resizeFunction = generateResize(),
7438 list = [];
7439 list.push(function () {
7440 return callFn(config.onresize, $$, $$.api);
7441 }), config.resize_auto && list.push(function () {
7442 state.resizing = !0, $$.api.flush(!1);
7443 }), list.push(function () {
7444 callFn(config.onresized, $$, $$.api), state.resizing = !1;
7445 }), list.forEach(function (v) {
7446 return resizeFunction.add(v);
7447 }), $$.resizeFunction = resizeFunction, win.addEventListener("resize", $$.resizeFunction = resizeFunction);
7448 }
7449 /**
7450 * Call plugin hook
7451 * @param {string} phase The lifecycle phase
7452 * @param {Array} args Arguments
7453 * @private
7454 */
7455 , _proto.callPluginHook = function callPluginHook(phase) {
7456 for (var _this = this, _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) args[_key - 1] = arguments[_key];
7457
7458 this.config.plugins.forEach(function (v) {
7459 phase === "$beforeInit" && (v.$$ = _this, _this.api.plugins.push(v)), v[phase].apply(v, args);
7460 });
7461 }, ChartInternal;
7462}();
7463
7464
7465extend(ChartInternal.prototype, [// common
7466convert, 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]);
7467;// CONCATENATED MODULE: ./src/config/config.ts
7468/**
7469 * Copyright (c) 2017 ~ present NAVER Corp.
7470 * billboard.js project is licensed under the MIT license
7471 */
7472
7473
7474/**
7475 * Load configuration option
7476 * @param {object} config User's generation config value
7477 * @private
7478 */
7479function loadConfig(config) {
7480 var target,
7481 keys,
7482 read,
7483 thisConfig = this.config,
7484 find = function () {
7485 var key = keys.shift();
7486 return key && target && isObjectType(target) && key in target ? (target = target[key], find()) : key ? undefined : target;
7487 };
7488
7489 Object.keys(thisConfig).forEach(function (key) {
7490 target = config, keys = key.split("_"), read = find(), isDefined(read) && (thisConfig[key] = read);
7491 });
7492}
7493;// CONCATENATED MODULE: ./src/Chart/api/chart.ts
7494/**
7495 * Copyright (c) 2017 ~ present NAVER Corp.
7496 * billboard.js project is licensed under the MIT license
7497 */
7498
7499
7500/* harmony default export */ var chart = ({
7501 /**
7502 * Resize the chart.
7503 * @function resize
7504 * @instance
7505 * @memberof Chart
7506 * @param {object} size This argument should include width and height in pixels.
7507 * @param {number} [size.width] width value
7508 * @param {number} [size.height] height value
7509 * @example
7510 * // Resize to 640x480
7511 * chart.resize({
7512 * width: 640,
7513 * height: 480
7514 * });
7515 */
7516 resize: function resize(size) {
7517 var $$ = this.internal,
7518 config = $$.config,
7519 state = $$.state;
7520 state.rendered && (config.size_width = size ? size.width : null, config.size_height = size ? size.height : null, state.resizing = !0, this.flush(!1, !0), $$.resizeFunction());
7521 },
7522
7523 /**
7524 * Force to redraw.
7525 * - **NOTE:** When zoom/subchart is used, the zoomed state will be resetted.
7526 * @function flush
7527 * @instance
7528 * @memberof Chart
7529 * @param {boolean} [soft] For soft redraw.
7530 * @example
7531 * chart.flush();
7532 *
7533 * // for soft redraw
7534 * chart.flush(true);
7535 */
7536 flush: function flush(soft) {
7537 var $$ = this.internal,
7538 state = $$.state;
7539 state.rendered ? (state.resizing ? $$.brush && $$.brush.updateResize() : $$.axis && $$.axis.setOrient(), $$.scale.zoom = null, soft ? $$.redraw({
7540 withTransform: !0,
7541 withUpdateXDomain: !0,
7542 withUpdateOrgXDomain: !0,
7543 withLegend: !0
7544 }) : $$.updateAndRedraw({
7545 withLegend: !0,
7546 withTransition: !1,
7547 withTransitionForTransform: !1
7548 }), !state.resizing && $$.brush && ($$.brush.getSelection().call($$.brush.move), $$.unselectRect())) : $$.initToRender(!0);
7549 },
7550
7551 /**
7552 * Reset the chart object and remove element and events completely.
7553 * @function destroy
7554 * @instance
7555 * @memberof Chart
7556 * @returns {null}
7557 * @example
7558 * chart.destroy();
7559 */
7560 destroy: function destroy() {
7561 var _this = this,
7562 $$ = this.internal,
7563 _$$$$el = $$.$el,
7564 chart = _$$$$el.chart,
7565 svg = _$$$$el.svg;
7566
7567 if (notEmpty($$)) // release prototype chains
7568 for (var _key in $$.callPluginHook("$willDestroy"), $$.charts.splice($$.charts.indexOf(this), 1), svg.select("*").interrupt(), $$.resizeFunction.clear(), win.removeEventListener("resize", $$.resizeFunction), chart.classed("bb", !1).html(""), Object.keys(this).forEach(function (key) {
7569 key === "internal" && Object.keys($$).forEach(function (k) {
7570 $$[k] = null;
7571 }), _this[key] = null, delete _this[key];
7572 }), this) this[_key] = function () {};
7573 return null;
7574 },
7575
7576 /**
7577 * Get or set single config option value.
7578 * @function config
7579 * @instance
7580 * @memberof Chart
7581 * @param {string} name The option key name.
7582 * @param {*} [value] The value accepted for indicated option.
7583 * @param {boolean} [redraw] Set to redraw with the new option changes.
7584 * - **NOTE:** Doesn't guarantee work in all circumstances. It can be applied for limited options only.
7585 * @returns {*}
7586 * @example
7587 * // Getter
7588 * chart.config("gauge.max");
7589 *
7590 * // Setter
7591 * chart.config("gauge.max", 100);
7592 *
7593 * // Setter & redraw with the new option
7594 * chart.config("gauge.max", 100, true);
7595 */
7596 config: function (name, value, redraw) {
7597 var res,
7598 $$ = this.internal,
7599 config = $$.config,
7600 key = name && name.replace(/\./g, "_");
7601 return key in config && (isDefined(value) ? (config[key] = value, res = value, redraw && this.flush()) : res = config[key]), res;
7602 }
7603});
7604;// CONCATENATED MODULE: ./src/Chart/api/color.ts
7605/**
7606 * Copyright (c) 2017 ~ present NAVER Corp.
7607 * billboard.js project is licensed under the MIT license
7608 */
7609/* harmony default export */ var api_color = ({
7610 /**
7611 * Get the color
7612 * @function color
7613 * @instance
7614 * @memberof Chart
7615 * @param {string} id id to get the color
7616 * @returns {string}
7617 * @example
7618 * chart.color("data1");
7619 */
7620 color: function color(id) {
7621 return this.internal.color(id); // more patterns
7622 }
7623});
7624;// CONCATENATED MODULE: ./src/Chart/api/data.ts
7625/**
7626 * Copyright (c) 2017 ~ present NAVER Corp.
7627 * billboard.js project is licensed under the MIT license
7628 */
7629
7630
7631/**
7632 * Get data loaded in the chart.
7633 * @function data
7634 * @instance
7635 * @memberof Chart
7636 * @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.
7637 * @returns {Array} Data objects
7638 * @example
7639 * // Get only data1 data
7640 * chart.data("data1");
7641 * // --> [{id: "data1", id_org: "data1", values: Array(6)}, ...]
7642 *
7643 * // Get data1 and data2 data
7644 * chart.data(["data1", "data2"]);
7645 *
7646 * // Get all data
7647 * chart.data();
7648 */
7649function api_data_data(targetIds) {
7650 var targets = this.internal.data.targets;
7651
7652 if (!isUndefined(targetIds)) {
7653 var ids = isArray(targetIds) ? targetIds : [targetIds];
7654 return targets.filter(function (t) {
7655 return ids.some(function (v) {
7656 return v === t.id;
7657 });
7658 });
7659 }
7660
7661 return targets;
7662}
7663
7664extend(api_data_data, {
7665 /**
7666 * Get data shown in the chart.
7667 * @function data․shown
7668 * @instance
7669 * @memberof Chart
7670 * @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.
7671 * @returns {Array} Data objects
7672 * @example
7673 * // Get shown data by filtering to include only data1 data
7674 * chart.data.shown("data1");
7675 * // --> [{id: "data1", id_org: "data1", values: Array(6)}, ...]
7676 *
7677 * // Get shown data by filtering to include data1 and data2 data
7678 * chart.data.shown(["data1", "data2"]);
7679 *
7680 * // Get all shown data
7681 * chart.data.shown();
7682 */
7683 shown: function shown(targetIds) {
7684 return this.internal.filterTargetsToShow(this.data(targetIds));
7685 },
7686
7687 /**
7688 * Get values of the data loaded in the chart.
7689 * @function data․values
7690 * @instance
7691 * @memberof Chart
7692 * @param {string|Array|null} targetIds This API returns the values of specified target. If this argument is not given, null will be retruned
7693 * @param {boolean} [flat=true] Get flatten values
7694 * @returns {Array} Data values
7695 * @example
7696 * // Get data1 values
7697 * chart.data.values("data1");
7698 * // --> [10, 20, 30, 40]
7699 */
7700 values: function (targetIds, flat) {
7701 flat === void 0 && (flat = !0);
7702 var values = null;
7703
7704 if (targetIds) {
7705 var targets = this.data(targetIds);
7706 targets && isArray(targets) && (values = [], targets.forEach(function (v) {
7707 var dataValue = v.values.map(function (d) {
7708 return d.value;
7709 });
7710 flat ? values = values.concat(dataValue) : values.push(dataValue);
7711 }));
7712 }
7713
7714 return values;
7715 },
7716
7717 /**
7718 * Get and set names of the data loaded in the chart.
7719 * @function data․names
7720 * @instance
7721 * @memberof Chart
7722 * @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
7723 * @returns {object} Corresponding names according its key value, if specified names values.
7724 * @example
7725 * // Get current names
7726 * chart.data.names();
7727 * // --> {data1: "test1", data2: "test2"}
7728 *
7729 * // Update names
7730 * chart.data.names({
7731 * data1: "New Name 1",
7732 * data2: "New Name 2"
7733 *});
7734 */
7735 names: function names(_names) {
7736 var $$ = this.internal;
7737 return $$.updateDataAttributes("names", _names);
7738 },
7739
7740 /**
7741 * Get and set colors of the data loaded in the chart.
7742 * @function data․colors
7743 * @instance
7744 * @memberof Chart
7745 * @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).
7746 * @returns {object} Corresponding data color value according its key value.
7747 * @example
7748 * // Get current colors
7749 * chart.data.colors();
7750 * // --> {data1: "#00c73c", data2: "#fa7171"}
7751 *
7752 * // Update colors
7753 * chart.data.colors({
7754 * data1: "#FFFFFF",
7755 * data2: "#000000"
7756 * });
7757 */
7758 colors: function colors(_colors) {
7759 return this.internal.updateDataAttributes("colors", _colors);
7760 },
7761
7762 /**
7763 * Get and set axes of the data loaded in the chart.
7764 * - **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
7765 * @function data․axes
7766 * @instance
7767 * @memberof Chart
7768 * @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
7769 * @returns {object} Corresponding axes value for data, if specified axes value.
7770 * @example
7771 * // Get current axes
7772 * chart.data.axes();
7773 * // --> {data1: "y"}
7774 *
7775 * // Update axes
7776 * chart.data.axes({
7777 * data1: "y",
7778 * data2: "y2"
7779 * });
7780 */
7781 axes: function axes(_axes) {
7782 return this.internal.updateDataAttributes("axes", _axes);
7783 },
7784
7785 /**
7786 * Get the minimum data value bound to the chart
7787 * @function data․min
7788 * @instance
7789 * @memberof Chart
7790 * @returns {Array} Data objects
7791 * @example
7792 * // Get current axes
7793 * chart.data.min();
7794 * // --> [{x: 0, value: 30, id: "data1", index: 0}, ...]
7795 */
7796 min: function min() {
7797 return this.internal.getMinMaxData().min;
7798 },
7799
7800 /**
7801 * Get the maximum data value bound to the chart
7802 * @function data․max
7803 * @instance
7804 * @memberof Chart
7805 * @returns {Array} Data objects
7806 * @example
7807 * // Get current axes
7808 * chart.data.max();
7809 * // --> [{x: 3, value: 400, id: "data1", index: 3}, ...]
7810 */
7811 max: function max() {
7812 return this.internal.getMinMaxData().max;
7813 }
7814});
7815/* harmony default export */ var api_data = ({
7816 data: api_data_data
7817});
7818;// CONCATENATED MODULE: ./src/Chart/api/export.ts
7819/**
7820 * Copyright (c) 2017 ~ present NAVER Corp.
7821 * billboard.js project is licensed under the MIT license
7822 */
7823
7824
7825
7826
7827/**
7828 * Encode to base64
7829 * @param {string} str string to be encoded
7830 * @returns {string}
7831 * @private
7832 * @see https://developer.mozilla.org/ko/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
7833 */
7834var b64EncodeUnicode = function (str) {
7835 return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p) {
7836 return String.fromCharCode(+("0x" + p));
7837 }));
7838};
7839/**
7840 * Convert svg node to data url
7841 * @param {HTMLElement} node target node
7842 * @param {object} option object containing {width, height, preserveAspectRatio}
7843 * @param {object} orgSize object containing {width, height}
7844 * @returns {string}
7845 * @private
7846 */
7847
7848
7849function nodeToSvgDataUrl(node, option, orgSize) {
7850 var _ref = option || orgSize,
7851 width = _ref.width,
7852 height = _ref.height,
7853 serializer = new XMLSerializer(),
7854 clone = node.cloneNode(!0),
7855 cssText = getCssRules(toArray(browser_doc.styleSheets)).filter(function (r) {
7856 return r.cssText;
7857 }).map(function (r) {
7858 return r.cssText;
7859 });
7860
7861 clone.setAttribute("xmlns", external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.xhtml);
7862 var nodeXml = serializer.serializeToString(clone),
7863 style = browser_doc.createElement("style"); // escape css for XML
7864
7865 style.appendChild(browser_doc.createTextNode(cssText.join("\n")));
7866 var styleXml = serializer.serializeToString(style),
7867 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 && 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
7868 // https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx
7869
7870 return "data:image/svg+xml;base64," + b64EncodeUnicode(dataStr);
7871}
7872
7873/* harmony default export */ var api_export = ({
7874 /**
7875 * Export chart as an image.
7876 * - **NOTE:**
7877 * - 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
7878 * - The basic CSS file(ex. billboard.css) should be at same domain as API call context to get correct styled export image.
7879 * @function export
7880 * @instance
7881 * @memberof Chart
7882 * @param {object} option Export option
7883 * @param {string} [option.mimeType="image/png"] The desired output image format. (ex. 'image/png' for png, 'image/jpeg' for jpeg format)
7884 * @param {number} [option.width={currentWidth}] width
7885 * @param {number} [option.height={currentHeigth}] height
7886 * @param {boolean} [option.preserveAspectRatio=true] Preserve aspect ratio on given size
7887 * @param {Function} [callback] The callback to be invoked when export is ready.
7888 * @returns {string} dataURI
7889 * @example
7890 * chart.export();
7891 * // --> "data:image/svg+xml;base64,PHN..."
7892 *
7893 * // Initialize the download automatically
7894 * chart.export({mimeType: "image/png"}, dataUrl => {
7895 * const link = document.createElement("a");
7896 *
7897 * link.download = `${Date.now()}.png`;
7898 * link.href = dataUrl;
7899 * link.innerHTML = "Download chart as image";
7900 *
7901 * document.body.appendChild(link);
7902 * });
7903 *
7904 * // Resize the exported image
7905 * chart.export(
7906 * {
7907 * width: 800,
7908 * height: 600,
7909 * preserveAspectRatio: false,
7910 * mimeType: "image/png"
7911 * },
7912 * dataUrl => { ... }
7913 * );
7914 */
7915 export: function _export(option, callback) {
7916 var _this = this,
7917 $$ = this.internal,
7918 state = $$.state,
7919 chart = $$.$el.chart,
7920 _state$current = state.current,
7921 width = _state$current.width,
7922 height = _state$current.height,
7923 opt = mergeObj({
7924 width: width,
7925 height: height,
7926 preserveAspectRatio: !0,
7927 mimeType: "image/png"
7928 }, option),
7929 svgDataUrl = nodeToSvgDataUrl(chart.node(), opt, {
7930 width: width,
7931 height: height
7932 });
7933
7934 if (callback && isFunction(callback)) {
7935 var img = new Image();
7936 img.crossOrigin = "Anonymous", img.onload = function () {
7937 var canvas = browser_doc.createElement("canvas"),
7938 ctx = canvas.getContext("2d");
7939 canvas.width = opt.width || width, canvas.height = opt.height || height, ctx.drawImage(img, 0, 0), callback.bind(_this)(canvas.toDataURL(opt.mimeType));
7940 }, img.src = svgDataUrl;
7941 }
7942
7943 return svgDataUrl;
7944 }
7945});
7946;// CONCATENATED MODULE: ./src/Chart/api/focus.ts
7947/**
7948 * Copyright (c) 2017 ~ present NAVER Corp.
7949 * billboard.js project is licensed under the MIT license
7950 */
7951
7952
7953/* harmony default export */ var api_focus = ({
7954 /**
7955 * This API highlights specified targets and fade out the others.<br><br>
7956 * 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.
7957 * @function focus
7958 * @instance
7959 * @memberof Chart
7960 * @param {string|Array} targetIdsValue Target ids to be highlighted.
7961 * @example
7962 * // data1 will be highlighted and the others will be faded out
7963 * chart.focus("data1");
7964 *
7965 * // data1 and data2 will be highlighted and the others will be faded out
7966 * chart.focus(["data1", "data2"]);
7967 *
7968 * // all targets will be highlighted
7969 * chart.focus();
7970 */
7971 focus: function focus(targetIdsValue) {
7972 var $$ = this.internal,
7973 state = $$.state,
7974 targetIds = $$.mapToTargetIds(targetIdsValue),
7975 candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
7976 this.revert(), this.defocus(), candidates.classed(config_classes.focused, !0).classed(config_classes.defocused, !1), $$.hasArcType() && !state.hasRadar && ($$.expandArc(targetIds), $$.hasType("gauge") && $$.markOverlapped(targetIdsValue, $$, "." + config_classes.gaugeValue)), $$.toggleFocusLegend(targetIds, !0), state.focusedTargetIds = targetIds, state.defocusedTargetIds = state.defocusedTargetIds.filter(function (id) {
7977 return targetIds.indexOf(id) < 0;
7978 });
7979 },
7980
7981 /**
7982 * This API fades out specified targets and reverts the others.<br><br>
7983 * 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.
7984 * @function defocus
7985 * @instance
7986 * @memberof Chart
7987 * @param {string|Array} targetIdsValue Target ids to be faded out.
7988 * @example
7989 * // data1 will be faded out and the others will be reverted.
7990 * chart.defocus("data1");
7991 *
7992 * // data1 and data2 will be faded out and the others will be reverted.
7993 * chart.defocus(["data1", "data2"]);
7994 *
7995 * // all targets will be faded out.
7996 * chart.defocus();
7997 */
7998 defocus: function defocus(targetIdsValue) {
7999 var $$ = this.internal,
8000 state = $$.state,
8001 targetIds = $$.mapToTargetIds(targetIdsValue),
8002 candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
8003 candidates.classed(config_classes.focused, !1).classed(config_classes.defocused, !0), $$.hasArcType() && ($$.unexpandArc(targetIds), $$.hasType("gauge") && $$.undoMarkOverlapped($$, "." + config_classes.gaugeValue)), $$.toggleFocusLegend(targetIds, !1), state.focusedTargetIds = state.focusedTargetIds.filter(function (id) {
8004 return targetIds.indexOf(id) < 0;
8005 }), state.defocusedTargetIds = targetIds;
8006 },
8007
8008 /**
8009 * This API reverts specified targets.<br><br>
8010 * 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.
8011 * @function revert
8012 * @instance
8013 * @memberof Chart
8014 * @param {string|Array} targetIdsValue Target ids to be reverted
8015 * @example
8016 * // data1 will be reverted.
8017 * chart.revert("data1");
8018 *
8019 * // data1 and data2 will be reverted.
8020 * chart.revert(["data1", "data2"]);
8021 *
8022 * // all targets will be reverted.
8023 * chart.revert();
8024 */
8025 revert: function revert(targetIdsValue) {
8026 var $$ = this.internal,
8027 config = $$.config,
8028 state = $$.state,
8029 $el = $$.$el,
8030 targetIds = $$.mapToTargetIds(targetIdsValue),
8031 candidates = $el.svg.selectAll($$.selectorTargets(targetIds));
8032 // should be for all targets
8033 candidates.classed(config_classes.focused, !1).classed(config_classes.defocused, !1), $$.hasArcType() && $$.unexpandArc(targetIds), config.legend_show && ($$.showLegend(targetIds.filter($$.isLegendToShow.bind($$))), $el.legend.selectAll($$.selectorLegends(targetIds)).filter(function () {
8034 return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused);
8035 }).classed(config_classes.legendItemFocused, !1)), state.focusedTargetIds = [], state.defocusedTargetIds = [];
8036 }
8037});
8038;// CONCATENATED MODULE: ./src/Chart/api/legend.ts
8039/**
8040 * Copyright (c) 2017 ~ present NAVER Corp.
8041 * billboard.js project is licensed under the MIT license
8042 */
8043
8044/**
8045 * Define legend
8046 * @ignore
8047 */
8048var legend_legend = {
8049 /**
8050 * Show legend for each target.
8051 * @function legend․show
8052 * @instance
8053 * @memberof Chart
8054 * @param {string|Array} targetIds
8055 * - If targetIds is given, specified target's legend will be shown.
8056 * - If only one target is the candidate, String can be passed.
8057 * - If no argument is given, all of target's legend will be shown.
8058 * @example
8059 * // Show legend for data1.
8060 * chart.legend.show("data1");
8061 *
8062 * // Show legend for data1 and data2.
8063 * chart.legend.show(["data1", "data2"]);
8064 *
8065 * // Show all legend.
8066 * chart.legend.show();
8067 */
8068 show: function show(targetIds) {
8069 var $$ = this.internal;
8070 $$.showLegend($$.mapToTargetIds(targetIds)), $$.updateAndRedraw({
8071 withLegend: !0
8072 });
8073 },
8074
8075 /**
8076 * Hide legend for each target.
8077 * @function legend․hide
8078 * @instance
8079 * @memberof Chart
8080 * @param {string|Array} targetIds
8081 * - If targetIds is given, specified target's legend will be hidden.
8082 * - If only one target is the candidate, String can be passed.
8083 * - If no argument is given, all of target's legend will be hidden.
8084 * @example
8085 * // Hide legend for data1.
8086 * chart.legend.hide("data1");
8087 *
8088 * // Hide legend for data1 and data2.
8089 * chart.legend.hide(["data1", "data2"]);
8090 *
8091 * // Hide all legend.
8092 * chart.legend.hide();
8093 */
8094 hide: function hide(targetIds) {
8095 var $$ = this.internal;
8096 $$.hideLegend($$.mapToTargetIds(targetIds)), $$.updateAndRedraw({
8097 withLegend: !0
8098 });
8099 }
8100};
8101/* harmony default export */ var api_legend = ({
8102 legend: legend_legend
8103});
8104;// CONCATENATED MODULE: ./src/Chart/api/load.ts
8105/**
8106 * Copyright (c) 2017 ~ present NAVER Corp.
8107 * billboard.js project is licensed under the MIT license
8108 */
8109
8110/* harmony default export */ var api_load = ({
8111 /**
8112 * Load data to the chart.<br><br>
8113 * 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.
8114 * - <b>Note:</b>
8115 * - unload should be used if some data needs to be unloaded simultaneously.
8116 * 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>
8117 * - done will be called after data loaded, but it's not after rendering.
8118 * It's because rendering will finish after some transition and there is some time lag between loading and rendering
8119 * @function load
8120 * @instance
8121 * @memberof Chart
8122 * @param {object} args The object can consist with following members:<br>
8123 *
8124 * | Key | Description |
8125 * | --- | --- |
8126 * | - 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 |
8127 * | data | Data objects to be loaded. Checkout the example. |
8128 * | names | Same as data.names() |
8129 * | xs | Same as data.xs option |
8130 * | classes | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
8131 * | categories | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
8132 * | axes | The axes specified by data.axes will be updated. axes must be Object that has target id as keys. |
8133 * | colors | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
8134 * | headers | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
8135 * | 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) |
8136 * | mimeType | Set 'json' if loading JSON via url.<br>@see [data․mimeType](Options.html#.data%25E2%2580%25A4mimeType) |
8137 * | - type<br>- types | The type of targets will be updated. type must be String and types must be Object. |
8138 * | 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. |
8139 * | done | The specified function will be called after data loaded.|
8140 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataFromURL)
8141 * @example
8142 * // Load data1 and unload data2 and data3
8143 * chart.load({
8144 * columns: [
8145 * ["data1", 100, 200, 150, ...],
8146 * ...
8147 * ],
8148 * unload: ["data2", "data3"],
8149 * url: "...",
8150 * done: function() { ... }
8151 * });
8152 * @example
8153 * // myAPI.json
8154 * // {
8155 * // "data1": [220, 240, 270, 250, 280],
8156 * // "data2": [180, 150, 300, 70, 120]
8157 * // }
8158 *
8159 * chart.load({
8160 * url: './data/myAPI.json',
8161 * mimeType: "json",
8162 *
8163 * // set request header if is needed
8164 * headers: {
8165 * "Content-Type": "text/json"
8166 * }
8167 * });
8168 * @example
8169 * chart.load({
8170 * data: [
8171 * // equivalent as: columns: [["data1", 30, 200, 100]]
8172 * {"data1": 30}, {"data1": 200}, {"data1": 100}
8173 *
8174 * // or
8175 * // equivalent as: columns: [["data1", 10, 20], ["data2", 13, 30]]
8176 * // {"data1": 10, "data2": 13}, {"data1": 20, "data2": 30}}
8177 * ]
8178 * });
8179 * @example
8180 * chart.load({
8181 * json: [
8182 * {name: "www.site1.com", upload: 800, download: 500, total: 400},
8183 * ],
8184 * keys: {
8185 * x: "name",
8186 * value: ["upload", "download"]
8187 * }
8188 * });
8189 */
8190 load: function load(args) {
8191 var $$ = this.internal,
8192 config = $$.config;
8193 // update xs if specified
8194 // update names if exists
8195 // update classes if exists
8196 // update axes if exists
8197 // update colors if exists
8198 args.xs && $$.addXs(args.xs), "names" in args && this.data.names(args.names), "classes" in args && Object.keys(args.classes).forEach(function (id) {
8199 config.data_classes[id] = args.classes[id];
8200 }), "categories" in args && $$.axis.isCategorized() && (config.axis_x_categories = args.categories), "axes" in args && Object.keys(args.axes).forEach(function (id) {
8201 config.data_axes[id] = args.axes[id];
8202 }), "colors" in args && Object.keys(args.colors).forEach(function (id) {
8203 config.data_colors[id] = args.colors[id];
8204 }), "unload" in args && args.unload !== !1 ? $$.unload($$.mapToTargetIds(args.unload === !0 ? null : args.unload), function () {
8205 return $$.loadFromArgs(args);
8206 }) : $$.loadFromArgs(args);
8207 },
8208
8209 /**
8210 * Unload data to the chart.<br><br>
8211 * 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.
8212 * - <b>Note:</b>
8213 * 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>
8214 * `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.
8215 * @function unload
8216 * @instance
8217 * @memberof Chart
8218 * @param {object} argsValue
8219 * | key | Type | Description |
8220 * | --- | --- | --- |
8221 * | ids | String &vert; Array | Target id data to be unloaded. If not given, all data will be unloaded. |
8222 * | done | Fuction | Callback after data is unloaded. |
8223 * @example
8224 * // Unload data2 and data3
8225 * chart.unload({
8226 * ids: ["data2", "data3"],
8227 * done: function() {
8228 * // called after the unloaded
8229 * }
8230 * });
8231 */
8232 unload: function unload(argsValue) {
8233 var _this = this,
8234 $$ = this.internal,
8235 args = argsValue || {};
8236
8237 isArray(args) ? args = {
8238 ids: args
8239 } : isString(args) && (args = {
8240 ids: [args]
8241 });
8242 var ids = $$.mapToTargetIds(args.ids);
8243 $$.unload(ids, function () {
8244 $$.redraw({
8245 withUpdateOrgXDomain: !0,
8246 withUpdateXDomain: !0,
8247 withLegend: !0
8248 }), $$.cache.remove(ids), args.done && args.done.call(_this);
8249 });
8250 }
8251});
8252;// CONCATENATED MODULE: ./src/Chart/api/show.ts
8253/**
8254 * Copyright (c) 2017 ~ present NAVER Corp.
8255 * billboard.js project is licensed under the MIT license
8256 */
8257
8258/**
8259 * Show/Hide data series
8260 * @param {boolean} show Show or hide
8261 * @param {Array} targetIdsValue Target id values
8262 * @param {object} options Options
8263 * @private
8264 */
8265
8266function showHide(show, targetIdsValue, options) {
8267 var $$ = this.internal,
8268 targetIds = $$.mapToTargetIds(targetIdsValue);
8269 $$.state.toggling = !0, $$[(show ? "remove" : "add") + "HiddenTargetIds"](targetIds);
8270 var targets = $$.$el.svg.selectAll($$.selectorTargets(targetIds)),
8271 opacity = show ? "1" : "0";
8272 show && targets.style("display", null), targets.transition().style("opacity", opacity, "important").call(endall, function () {
8273 // https://github.com/naver/billboard.js/issues/1758
8274 show || targets.style("display", "none"), targets.style("opacity", opacity);
8275 }), options.withLegend && $$[(show ? "show" : "hide") + "Legend"](targetIds), $$.redraw({
8276 withUpdateOrgXDomain: !0,
8277 withUpdateXDomain: !0,
8278 withLegend: !0
8279 }), $$.state.toggling = !1;
8280}
8281
8282/* harmony default export */ var show = ({
8283 /**
8284 * Show data series on chart
8285 * @function show
8286 * @instance
8287 * @memberof Chart
8288 * @param {string|Array} [targetIdsValue] The target id value.
8289 * @param {object} [options] The object can consist with following members:<br>
8290 *
8291 * | Key | Type | default | Description |
8292 * | --- | --- | --- | --- |
8293 * | withLegend | boolean | false | whether or not display legend |
8294 *
8295 * @example
8296 * // show 'data1'
8297 * chart.show("data1");
8298 *
8299 * // show 'data1' and 'data3'
8300 * chart.show(["data1", "data3"]);
8301 */
8302 show: function show(targetIdsValue, options) {
8303 options === void 0 && (options = {}), showHide.call(this, !0, targetIdsValue, options);
8304 },
8305
8306 /**
8307 * Hide data series from chart
8308 * @function hide
8309 * @instance
8310 * @memberof Chart
8311 * @param {string|Array} [targetIdsValue] The target id value.
8312 * @param {object} [options] The object can consist with following members:<br>
8313 *
8314 * | Key | Type | default | Description |
8315 * | --- | --- | --- | --- |
8316 * | withLegend | boolean | false | whether or not display legend |
8317 *
8318 * @example
8319 * // hide 'data1'
8320 * chart.hide("data1");
8321 *
8322 * // hide 'data1' and 'data3'
8323 * chart.hide(["data1", "data3"]);
8324 */
8325 hide: function hide(targetIdsValue, options) {
8326 options === void 0 && (options = {}), showHide.call(this, !1, targetIdsValue, options);
8327 },
8328
8329 /**
8330 * Toggle data series on chart. When target data is hidden, it will show. If is shown, it will hide in vice versa.
8331 * @function toggle
8332 * @instance
8333 * @memberof Chart
8334 * @param {string|Array} [targetIds] The target id value.
8335 * @param {object} [options] The object can consist with following members:<br>
8336 *
8337 * | Key | Type | default | Description |
8338 * | --- | --- | --- | --- |
8339 * | withLegend | boolean | false | whether or not display legend |
8340 *
8341 * @example
8342 * // toggle 'data1'
8343 * chart.toggle("data1");
8344 *
8345 * // toggle 'data1' and 'data3'
8346 * chart.toggle(["data1", "data3"]);
8347 */
8348 toggle: function toggle(targetIds, options) {
8349 var _this = this;
8350
8351 options === void 0 && (options = {});
8352 var $$ = this.internal,
8353 targets = {
8354 show: [],
8355 hide: []
8356 };
8357 // sort show & hide target ids
8358 // perform show & hide task separately
8359 // https://github.com/naver/billboard.js/issues/454
8360 $$.mapToTargetIds(targetIds).forEach(function (id) {
8361 return targets[$$.isTargetToShow(id) ? "hide" : "show"].push(id);
8362 }), targets.show.length && this.show(targets.show, options), targets.hide.length && setTimeout(function () {
8363 return _this.hide(targets.hide, options);
8364 }, 0);
8365 }
8366});
8367;// CONCATENATED MODULE: ./src/Chart/api/tooltip.ts
8368/**
8369 * Copyright (c) 2017 ~ present NAVER Corp.
8370 * billboard.js project is licensed under the MIT license
8371 */
8372
8373/**
8374 * Define tooltip
8375 * @ignore
8376 */
8377
8378var tooltip_tooltip = {
8379 /**
8380 * Show tooltip
8381 * @function tooltip․show
8382 * @instance
8383 * @memberof Chart
8384 * @param {object} args The object can consist with following members:<br>
8385 *
8386 * | Key | Type | Description |
8387 * | --- | --- | --- |
8388 * | index | Number | Determine focus by index |
8389 * | x | Number &vert; Date | Determine focus by x Axis index |
8390 * | 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]` |
8391 * | 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. |
8392 *
8393 * @example
8394 * // show the 2nd x Axis coordinate tooltip
8395 * // for Arc(gauge, donut & pie) and radar type, approch showing tooltip by using "index" number.
8396 * chart.tooltip.show({
8397 * index: 1
8398 * });
8399 *
8400 * // show tooltip for the 3rd x Axis in x:50 and y:100 coordinate of '.bb-event-rect' of the x Axis.
8401 * chart.tooltip.show({
8402 * x: 2,
8403 * mouse: [50, 100]
8404 * });
8405 *
8406 * // show tooltip for timeseries x axis
8407 * chart.tooltip.show({
8408 * x: new Date("2018-01-02 00:00")
8409 * });
8410 *
8411 * // when data.xs is used
8412 * chart.tooltip.show({
8413 * data: {
8414 * x: 3, // x Axis value
8415 * id: "data1", // data id
8416 * value: 500 // data value
8417 * }
8418 * });
8419 *
8420 * // when data.xs isn't used, but tooltip.grouped=false is set
8421 * chart.tooltip.show({
8422 * data: {
8423 * index: 3, // or 'x' key value
8424 * id: "data1", // data id
8425 * value: 500 // data value
8426 * }
8427 * });
8428 */
8429 show: function show(args) {
8430 var index,
8431 mouse,
8432 $$ = this.internal,
8433 config = $$.config,
8434 inputType = $$.state.inputType;
8435
8436 // determine focus data
8437 if (args.mouse && (mouse = args.mouse), args.data) {
8438 var data = args.data,
8439 y = $$.getYScaleById(data.id)(data.value);
8440 $$.isMultipleX() ? mouse = [$$.scale.x(data.x), y] : (!config.tooltip_grouped && (mouse = [0, y]), index = isValue(data.index) ? data.index : $$.getIndexByX(data.x));
8441 } else isDefined(args.x) ? index = $$.getIndexByX(args.x) : isDefined(args.index) && (index = args.index);
8442
8443 (inputType === "mouse" ? ["mouseover", "mousemove"] : ["touchstart"]).forEach(function (eventName) {
8444 $$.dispatchEvent(eventName, index, mouse);
8445 });
8446 },
8447
8448 /**
8449 * Hide tooltip
8450 * @function tooltip․hide
8451 * @instance
8452 * @memberof Chart
8453 */
8454 hide: function hide() {
8455 var $$ = this.internal,
8456 inputType = $$.state.inputType,
8457 tooltip = $$.$el.tooltip,
8458 data = tooltip && tooltip.datum();
8459
8460 if (data) {
8461 var index = JSON.parse(data.current)[0].index; // make to finalize, possible pending event flow set from '.tooltip.show()' call
8462
8463 (inputType === "mouse" ? ["mouseout"] : ["touchend"]).forEach(function (eventName) {
8464 $$.dispatchEvent(eventName, index);
8465 });
8466 } // reset last touch point index
8467
8468
8469 inputType === "touch" && $$.callOverOutForTouch(), $$.hideTooltip(!0), $$.hideGridFocus(), $$.unexpandCircles && $$.unexpandCircles(), $$.unexpandBars && $$.unexpandBars();
8470 }
8471};
8472/* harmony default export */ var api_tooltip = ({
8473 tooltip: tooltip_tooltip
8474});
8475;// CONCATENATED MODULE: ./src/Chart/Chart.ts
8476/**
8477 * Copyright (c) 2017 ~ present NAVER Corp.
8478 * billboard.js project is licensed under the MIT license
8479 */
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492/**
8493 * Main chart class.
8494 * - Note: Instantiated via `bb.generate()`.
8495 * @class Chart
8496 * @example
8497 * var chart = bb.generate({
8498 * data: {
8499 * columns: [
8500 * ["x", "2015-11-02", "2015-12-01", "2016-01-01", "2016-02-01", "2016-03-01"],
8501 * ["count1", 11, 8, 7, 6, 5 ],
8502 * ["count2", 9, 3, 6, 2, 8 ]
8503 * ]}
8504 * }
8505 * @see {@link bb.generate} for the initialization.
8506 */
8507
8508/**
8509 * Access instance's primary node elements
8510 * @member {object} $
8511 * @property {object} $ Access instance's primary node elements
8512 * @property {d3.selection} $.chart Wrapper element
8513 * @property {d3.selection} $.svg Main svg element
8514 * @property {d3.selection} $.defs Definition element
8515 * @property {d3.selection} $.main Main grouping element
8516 * @property {d3.selection} $.tooltip Tooltip element
8517 * @property {d3.selection} $.legend Legend element
8518 * @property {d3.selection} $.title Title element
8519 * @property {d3.selection} $.grid Grid element
8520 * @property {d3.selection} $.arc Arc element
8521 * @property {d3.selection} $.circles Data point circle elements
8522 * @property {object} $.bar Bar element object
8523 * @property {d3.selection} $.bar.bars Bar elements
8524 * @property {d3.selection} $.candlestick Candlestick elements
8525 * @property {object} $.line Line element object
8526 * @property {d3.selection} $.line.lines Line elements
8527 * @property {d3.selection} $.line.areas Areas elements
8528 * @property {object} $.text Text element object
8529 * @property {d3.selection} $.text.texts Data label text elements
8530 * @memberof Chart
8531 * @example
8532 * var chart = bb.generate({ ... });
8533 *
8534 * chart.$.chart; // wrapper element
8535 * chart.$.line.circles; // all data point circle elements
8536 */
8537
8538/**
8539 * Plugin instance array
8540 * @member {Array} plugins
8541 * @memberof Chart
8542 * @example
8543 * var chart = bb.generate({
8544 * ...
8545 * plugins: [
8546 * new bb.plugin.stanford({ ... }),
8547 * new PluginA()
8548 * ]
8549 * });
8550 *
8551 * chart.plugins; // [Stanford, PluginA] - instance array
8552 */
8553
8554var Chart = function Chart(options) {
8555 this.plugins = [], this.internal = void 0;
8556 var $$ = new ChartInternal(this);
8557 // bind to namespaced APIs
8558 this.internal = $$, function bindThis(fn, target, argThis) {
8559 Object.keys(fn).forEach(function (key) {
8560 var isFunc = isFunction(fn[key]),
8561 isChild = target !== argThis,
8562 hasChild = Object.keys(fn[key]).length > 0;
8563 isFunc && (!isChild && hasChild || isChild) ? target[key] = fn[key].bind(argThis) : !isFunc && (target[key] = {}), hasChild && bindThis(fn[key], target[key], argThis);
8564 });
8565 }(Chart.prototype, this, this), loadConfig.call($$, options), $$.beforeInit(), $$.init();
8566}; // extend common APIs as part of Chart class
8567
8568
8569
8570extend(Chart.prototype, [chart, api_color, api_data, api_export, api_focus, api_legend, api_load, show, api_tooltip]);
8571;// CONCATENATED MODULE: ./src/Chart/api/axis.ts
8572/**
8573 * Copyright (c) 2017 ~ present NAVER Corp.
8574 * billboard.js project is licensed under the MIT license
8575 */
8576
8577/**
8578 * Set the min/max value
8579 * @param {Chart} $$ Chart instance
8580 * @param {string} type Set type 'min' or 'max'
8581 * @param {object} value Value to be set
8582 * @private
8583 */
8584
8585function setMinMax($$, type, value) {
8586 var config = $$.config,
8587 axisY = "axis_y_" + type,
8588 axisY2 = "axis_y2_" + type;
8589 isDefined(value) && (isObjectType(value) ? (isValue(value.x) && (config["axis_x_" + type] = value.x), isValue(value.y) && (config[axisY] = value.y), isValue(value.y2) && (config[axisY2] = value.y2)) : (config[axisY] = value, config[axisY2] = value), $$.redraw({
8590 withUpdateOrgXDomain: !0,
8591 withUpdateXDomain: !0
8592 }));
8593}
8594/**
8595 * Get the min/max value
8596 * @param {Chart} $$ Chart instance
8597 * @param {string} type Set type 'min' or 'max'
8598 * @returns {{x, y, y2}}
8599 * @private
8600 */
8601
8602
8603function axis_getMinMax($$, type) {
8604 var config = $$.config;
8605 return {
8606 x: config["axis_x_" + type],
8607 y: config["axis_y_" + type],
8608 y2: config["axis_y2_" + type]
8609 };
8610}
8611/**
8612 * Define axis
8613 * @ignore
8614 */
8615
8616
8617var axis = {
8618 /**
8619 * Get and set axis labels.
8620 * @function axis․labels
8621 * @instance
8622 * @memberof Chart
8623 * @param {object} labels specified axis' label to be updated.
8624 * @param {string} [labels.x] x Axis string
8625 * @param {string} [labels.y] y Axis string
8626 * @param {string} [labels.y2] y2 Axis string
8627 * @returns {object|undefined} axis labels text object
8628 * @example
8629 * // Update axis' label
8630 * chart.axis.labels({
8631 * x: "New X Axis Label",
8632 * y: "New Y Axis Label",
8633 * y2: "New Y2 Axis Label"
8634 * });
8635 *
8636 * chart.axis.labels();
8637 * // --> {
8638 * // x: "New X Axis Label",
8639 * // y: "New Y Axis Label",
8640 * // y2: "New Y2 Axis Label"
8641 * // }
8642 */
8643 labels: function labels(_labels) {
8644 var labelText,
8645 $$ = this.internal;
8646 return _labels && (Object.keys(_labels).forEach(function (axisId) {
8647 $$.axis.setLabelText(axisId, _labels[axisId]);
8648 }), $$.axis.updateLabels()), ["x", "y", "y2"].forEach(function (v) {
8649 var text = $$.axis.getLabelText(v);
8650 text && (!labelText && (labelText = {}), labelText[v] = text);
8651 }), labelText;
8652 },
8653
8654 /**
8655 * Get and set axis min value.
8656 * @function axis․min
8657 * @instance
8658 * @memberof Chart
8659 * @param {object} min If min is given, specified axis' min value will be updated.<br>
8660 * If no argument is given, the min values set on generating option for each axis will be returned.
8661 * If not set any min values on generation, it will return `undefined`.
8662 * @returns {object|undefined}
8663 * @example
8664 * // Update axis' min
8665 * chart.axis.min({
8666 * x: -10,
8667 * y: 1000,
8668 * y2: 100
8669 * });
8670 */
8671 min: function min(_min) {
8672 var $$ = this.internal;
8673 return isValue(_min) ? setMinMax($$, "min", _min) : axis_getMinMax($$, "min");
8674 },
8675
8676 /**
8677 * Get and set axis max value.
8678 * @function axis․max
8679 * @instance
8680 * @memberof Chart
8681 * @param {object} max If max is given, specified axis' max value will be updated.<br>
8682 * If no argument is given, the max values set on generating option for each axis will be returned.
8683 * If not set any max values on generation, it will return `undefined`.
8684 * @returns {object|undefined}
8685 * @example
8686 * // Update axis' label
8687 * chart.axis.max({
8688 * x: 100,
8689 * y: 1000,
8690 * y2: 10000
8691 * });
8692 */
8693 max: function max(_max) {
8694 var $$ = this.internal;
8695 return arguments.length ? setMinMax($$, "max", _max) : axis_getMinMax($$, "max");
8696 },
8697
8698 /**
8699 * Get and set axis min and max value.
8700 * @function axis․range
8701 * @instance
8702 * @memberof Chart
8703 * @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.
8704 * @returns {object|undefined}
8705 * @example
8706 * // Update axis' label
8707 * chart.axis.range({
8708 * min: {
8709 * x: -10,
8710 * y: -1000,
8711 * y2: -10000
8712 * },
8713 * max: {
8714 * x: 100,
8715 * y: 1000,
8716 * y2: 10000
8717 * },
8718 * });
8719 */
8720 range: function range(_range) {
8721 var axis = this.axis;
8722 if (arguments.length) isDefined(_range.max) && axis.max(_range.max), isDefined(_range.min) && axis.min(_range.min);else return {
8723 max: axis.max(),
8724 min: axis.min()
8725 };
8726 return undefined;
8727 }
8728};
8729/* harmony default export */ var api_axis = ({
8730 axis: axis
8731});
8732;// CONCATENATED MODULE: ./src/Chart/api/category.ts
8733/**
8734 * Copyright (c) 2017 ~ present NAVER Corp.
8735 * billboard.js project is licensed under the MIT license
8736 */
8737/* harmony default export */ var api_category = ({
8738 /**
8739 * Set specified category name on category axis.
8740 * @function category
8741 * @instance
8742 * @memberof Chart
8743 * @param {number} i index of category to be changed
8744 * @param {string} category category value to be changed
8745 * @returns {string}
8746 * @example
8747 * chart.category(2, "Category 3");
8748 */
8749 category: function category(i, _category) {
8750 var $$ = this.internal,
8751 config = $$.config;
8752 return arguments.length > 1 && (config.axis_x_categories[i] = _category, $$.redraw()), config.axis_x_categories[i];
8753 },
8754
8755 /**
8756 * Set category names on category axis.
8757 * @function categories
8758 * @instance
8759 * @memberof Chart
8760 * @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.
8761 * @returns {Array}
8762 * @example
8763 * chart.categories([
8764 * "Category 1", "Category 2", ...
8765 * ]);
8766 */
8767 categories: function categories(_categories) {
8768 var $$ = this.internal,
8769 config = $$.config;
8770 return arguments.length ? (config.axis_x_categories = _categories, $$.redraw(), config.axis_x_categories) : config.axis_x_categories;
8771 }
8772});
8773;// CONCATENATED MODULE: ./src/Chart/api/grid.x.ts
8774/**
8775 * Copyright (c) 2017 ~ present NAVER Corp.
8776 * billboard.js project is licensed under the MIT license
8777 */
8778
8779
8780/**
8781 * Update x grid lines.
8782 * @function xgrids
8783 * @instance
8784 * @memberof Chart
8785 * @param {Array} grids X grid lines will be replaced with this argument. The format of this argument is the same as grid.x.lines.
8786 * @returns {object}
8787 * @example
8788 * // Show 2 x grid lines
8789 * chart.xgrids([
8790 * {value: 1, text: "Label 1"},
8791 * {value: 4, text: "Label 4"}
8792 * ]);
8793 * // --> Returns: [{value: 1, text: "Label 1"}, {value: 4, text: "Label 4"}]
8794 */
8795function xgrids(grids) {
8796 var $$ = this.internal,
8797 config = $$.config;
8798 return grids ? (config.grid_x_lines = grids, $$.redrawWithoutRescale(), config.grid_x_lines) : config.grid_x_lines;
8799}
8800
8801extend(xgrids, {
8802 /**
8803 * Add x grid lines.<br>
8804 * This API adds new x grid lines instead of replacing like xgrids.
8805 * @function xgrids․add
8806 * @instance
8807 * @memberof Chart
8808 * @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.
8809 * @returns {object}
8810 * @example
8811 * // Add a new x grid line
8812 * chart.xgrids.add(
8813 * {value: 4, text: "Label 4"}
8814 * );
8815 *
8816 * // Add new x grid lines
8817 * chart.xgrids.add([
8818 * {value: 2, text: "Label 2"},
8819 * {value: 4, text: "Label 4"}
8820 * ]);
8821 */
8822 add: function add(grids) {
8823 return this.xgrids(this.internal.config.grid_x_lines.concat(grids || []));
8824 },
8825
8826 /**
8827 * Remove x grid lines.<br>
8828 * This API removes x grid lines.
8829 * @function xgrids․remove
8830 * @instance
8831 * @memberof Chart
8832 * @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.
8833 * @example
8834 * // x grid line on x = 2 will be removed
8835 * chart.xgrids.remove({value: 2});
8836 *
8837 * // x grid lines that have 'grid-A' will be removed
8838 * chart.xgrids.remove({
8839 * class: "grid-A"
8840 * });
8841 *
8842 * // all of x grid lines will be removed
8843 * chart.xgrids.remove();
8844 */
8845 remove: function remove(params) {
8846 // TODO: multiple
8847 this.internal.removeGridLines(params, !0);
8848 }
8849});
8850/* harmony default export */ var grid_x = ({
8851 xgrids: xgrids
8852});
8853;// CONCATENATED MODULE: ./src/Chart/api/grid.y.ts
8854/**
8855 * Copyright (c) 2017 ~ present NAVER Corp.
8856 * billboard.js project is licensed under the MIT license
8857 */
8858
8859/**
8860 * Update y grid lines.
8861 * @function ygrids
8862 * @instance
8863 * @memberof Chart
8864 * @param {Array} grids Y grid lines will be replaced with this argument. The format of this argument is the same as grid.y.lines.
8865 * @returns {object}
8866 * @example
8867 * // Show 2 y grid lines
8868 * chart.ygrids([
8869 * {value: 100, text: "Label 1"},
8870 * {value: 400, text: "Label 4"}
8871 * ]);
8872 * // --> Returns: [{value: 100, text: "Label 1"}, {value: 400, text: "Label 4"}]
8873 */
8874
8875function ygrids(grids) {
8876 var $$ = this.internal,
8877 config = $$.config;
8878 return grids ? (config.grid_y_lines = grids, $$.redrawWithoutRescale(), config.grid_y_lines) : config.grid_y_lines;
8879}
8880
8881extend(ygrids, {
8882 /**
8883 * Add y grid lines.<br>
8884 * This API adds new y grid lines instead of replacing like ygrids.
8885 * @function ygrids․add
8886 * @instance
8887 * @memberof Chart
8888 * @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.
8889 * @returns {object}
8890 * @example
8891 * // Add a new x grid line
8892 * chart.ygrids.add(
8893 * {value: 400, text: "Label 4"}
8894 * );
8895 *
8896 * // Add new x grid lines
8897 * chart.ygrids.add([
8898 * {value: 200, text: "Label 2"},
8899 * {value: 400, text: "Label 4"}
8900 * ]);
8901 */
8902 add: function add(grids) {
8903 return this.ygrids(this.internal.config.grid_y_lines.concat(grids || []));
8904 },
8905
8906 /**
8907 * Remove y grid lines.<br>
8908 * This API removes x grid lines.
8909 * @function ygrids․remove
8910 * @instance
8911 * @memberof Chart
8912 * @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.
8913 * @param {number} [params.value] target value
8914 * @param {string} [params.class] target class
8915 * @example
8916 * // y grid line on y = 200 will be removed
8917 * chart.ygrids.remove({value: 200});
8918 *
8919 * // y grid lines that have 'grid-A' will be removed
8920 * chart.ygrids.remove({
8921 * class: "grid-A"
8922 * });
8923 *
8924 * // all of y grid lines will be removed
8925 * chart.ygrids.remove();
8926 */
8927 remove: function remove(params) {
8928 // TODO: multiple
8929 this.internal.removeGridLines(params, !1);
8930 }
8931});
8932/* harmony default export */ var grid_y = ({
8933 ygrids: ygrids
8934});
8935;// CONCATENATED MODULE: ./src/Chart/api/group.ts
8936/**
8937 * Copyright (c) 2017 ~ present NAVER Corp.
8938 * billboard.js project is licensed under the MIT license
8939 */
8940
8941/* harmony default export */ var group = ({
8942 /**
8943 * Update groups for the targets.
8944 * @function groups
8945 * @instance
8946 * @memberof Chart
8947 * @param {Array} groups This argument needs to be an Array that includes one or more Array that includes target ids to be grouped.
8948 * @returns {Array} Grouped data names array
8949 * @example
8950 * // data1 and data2 will be a new group.
8951 * chart.groups([
8952 * ["data1", "data2"]
8953 * ]);
8954 */
8955 groups: function groups(_groups) {
8956 var $$ = this.internal,
8957 config = $$.config;
8958 return isUndefined(_groups) ? config.data_groups : (config.data_groups = _groups, $$.redraw(), config.data_groups);
8959 }
8960});
8961;// CONCATENATED MODULE: ./src/Chart/api/regions.ts
8962/**
8963 * Copyright (c) 2017 ~ present NAVER Corp.
8964 * billboard.js project is licensed under the MIT license
8965 */
8966
8967
8968
8969/**
8970 * Update regions.
8971 * @function regions
8972 * @instance
8973 * @memberof Chart
8974 * @param {Array} regions Regions will be replaced with this argument. The format of this argument is the same as regions.
8975 * @returns {Array} regions
8976 * @example
8977 * // Show 2 regions
8978 * chart.regions([
8979 * {axis: "x", start: 5, class: "regionX"},
8980 * {axis: "y", end: 50, class: "regionY"}
8981 * ]);
8982 */
8983function regions(regions) {
8984 var $$ = this.internal,
8985 config = $$.config;
8986 return regions ? (config.regions = regions, $$.redrawWithoutRescale(), regions) : config.regions;
8987}
8988
8989extend(regions, {
8990 /**
8991 * Add new region.<br><br>
8992 * This API adds new region instead of replacing like regions.
8993 * @function regions․add
8994 * @instance
8995 * @memberof Chart
8996 * @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.
8997 * @returns {Array} regions
8998 * @example
8999 * // Add a new region
9000 * chart.regions.add(
9001 * {axis: "x", start: 5, class: "regionX"}
9002 * );
9003 *
9004 * // Add new regions
9005 * chart.regions.add([
9006 * {axis: "x", start: 5, class: "regionX"},
9007 * {axis: "y", end: 50, class: "regionY"}
9008 *]);
9009 */
9010 add: function add(regions) {
9011 var $$ = this.internal,
9012 config = $$.config;
9013 return regions ? (config.regions = config.regions.concat(regions), $$.redrawWithoutRescale(), config.regions) : config.regions;
9014 },
9015
9016 /**
9017 * Remove regions.<br><br>
9018 * This API removes regions.
9019 * @function regions․remove
9020 * @instance
9021 * @memberof Chart
9022 * @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.
9023 * @returns {Array} regions Removed regions
9024 * @example
9025 * // regions that have 'region-A' or 'region-B' will be removed.
9026 * chart.regions.remove({
9027 * classes: [
9028 * "region-A", "region-B"
9029 * ]
9030 * });
9031 *
9032 * // all of regions will be removed.
9033 * chart.regions.remove();
9034 */
9035 remove: function remove(optionsValue) {
9036 var $$ = this.internal,
9037 config = $$.config,
9038 options = optionsValue || {},
9039 duration = getOption(options, "duration", config.transition_duration),
9040 classes = getOption(options, "classes", [config_classes.region]),
9041 regions = $$.$el.main.select("." + config_classes.regions).selectAll(classes.map(function (c) {
9042 return "." + c;
9043 }));
9044 return (duration ? regions.transition().duration(duration) : regions).style("opacity", "0").remove(), regions = config.regions, Object.keys(options).length ? (regions = regions.filter(function (region) {
9045 var found = !1;
9046 return !region.class || (region.class.split(" ").forEach(function (c) {
9047 classes.indexOf(c) >= 0 && (found = !0);
9048 }), !found);
9049 }), config.regions = regions) : config.regions = [], regions;
9050 }
9051});
9052/* harmony default export */ var api_regions = ({
9053 regions: regions
9054});
9055;// CONCATENATED MODULE: ./src/Chart/api/x.ts
9056/**
9057 * Copyright (c) 2017 ~ present NAVER Corp.
9058 * billboard.js project is licensed under the MIT license
9059 */
9060
9061/* harmony default export */ var x = ({
9062 /**
9063 * Get and set x values for the chart.
9064 * @function x
9065 * @instance
9066 * @memberof Chart
9067 * @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.
9068 * @returns {object} xs
9069 * @example
9070 * // Get current x values
9071 * chart.x();
9072 *
9073 * // Update x values for all targets
9074 * chart.x([100, 200, 300, 400, ...]);
9075 */
9076 x: function x(_x) {
9077 var $$ = this.internal,
9078 axis = $$.axis,
9079 data = $$.data,
9080 isCategorized = axis.isCustomX() && axis.isCategorized();
9081 return isArray(_x) && (isCategorized ? this.categories(_x) : ($$.updateTargetX(data.targets, _x), $$.redraw({
9082 withUpdateOrgXDomain: !0,
9083 withUpdateXDomain: !0
9084 }))), isCategorized ? this.categories() : data.xs;
9085 },
9086
9087 /**
9088 * Get and set x values for the chart.
9089 * @function xs
9090 * @instance
9091 * @memberof Chart
9092 * @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.
9093 * @returns {object} xs
9094 * @example
9095 * // Get current x values
9096 * chart.xs();
9097 *
9098 * // Update x values for all targets
9099 * chart.xs({
9100 * data1: [10, 20, 30, 40, ...],
9101 * data2: [100, 200, 300, 400, ...]
9102 * });
9103 */
9104 xs: function xs(_xs) {
9105 var $$ = this.internal;
9106 return isObject(_xs) && ($$.updateTargetXs($$.data.targets, _xs), $$.redraw({
9107 withUpdateOrgXDomain: !0,
9108 withUpdateXDomain: !0
9109 })), $$.data.xs;
9110 }
9111});
9112;// CONCATENATED MODULE: ./src/Chart/api/flow.ts
9113/**
9114 * Copyright (c) 2017 ~ present NAVER Corp.
9115 * billboard.js project is licensed under the MIT license
9116 */
9117
9118/* harmony default export */ var flow = ({
9119 /**
9120 * Flow data to the chart.<br><br>
9121 * By this API, you can append new data points to the chart.
9122 * @function flow
9123 * @instance
9124 * @memberof Chart
9125 * @param {object} args The object can consist with following members:<br>
9126 *
9127 * | Key | Type | Description |
9128 * | --- | --- | --- |
9129 * | json | Object | Data as JSON format (@see [data․json](Options.html#.data%25E2%2580%25A4json)) |
9130 * | rows | Array | Data in array as row format (@see [data․rows](Options.html#.data%25E2%2580%25A4json)) |
9131 * | columns | Array | Data in array as column format (@see [data․columns](Options.html#.data%25E2%2580%25A4columns)) |
9132 * | 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 |
9133 * | length | Number | The lower x edge will move by the number of this argument |
9134 * | duration | Number | The duration of the transition will be specified value. If not given, transition.duration will be used as default |
9135 * | done | Function | The specified function will be called when flow ends |
9136 *
9137 * - **NOTE:**
9138 * - If json, rows and columns given, the data will be loaded.
9139 * - If data that has the same target id is given, the chart will be appended.
9140 * - Otherwise, new target will be added. One of these is required when calling.
9141 * - If json specified, keys is required as well as data.json.
9142 * - If tab isn't visible(by evaluating `document.hidden`), will not be executed to prevent unnecessary work.
9143 * @example
9144 * // 2 data points will be apprended to the tail and popped from the head.
9145 * // After that, 4 data points will be appended and no data points will be poppoed.
9146 * chart.flow({
9147 * columns: [
9148 * ["x", "2018-01-11", "2018-01-21"],
9149 * ["data1", 500, 200],
9150 * ["data2", 100, 300],
9151 * ["data3", 200, 120]
9152 * ],
9153 * to: "2013-01-11",
9154 * done: function () {
9155 * chart.flow({
9156 * columns: [
9157 * ["x", "2018-02-11", "2018-02-12", "2018-02-13", "2018-02-14"],
9158 * ["data1", 200, 300, 100, 250],
9159 * ["data2", 100, 90, 40, 120],
9160 * ["data3", 100, 100, 300, 500]
9161 * ],
9162 * length: 2,
9163 * duration: 1500
9164 * });
9165 * }
9166 * });
9167 */
9168 flow: function flow(args) {
9169 var data,
9170 domain,
9171 diff,
9172 to,
9173 $$ = this.internal,
9174 length = 0,
9175 tail = 0;
9176
9177 if ((args.json || args.rows || args.columns) && (data = $$.convertData(args)), data && isTabVisible()) {
9178 var notfoundIds = [],
9179 orgDataCount = $$.getMaxDataCount(),
9180 targets = $$.convertDataToTargets(data, !0),
9181 isTimeSeries = $$.axis.isTimeSeries();
9182 $$.data.targets.forEach(function (t) {
9183 for (var found = !1, i = 0; i < targets.length; i++) if (t.id === targets[i].id) {
9184 found = !0, t.values[t.values.length - 1] && (tail = t.values[t.values.length - 1].index + 1), length = targets[i].values.length;
9185
9186 for (var _j3 = 0; _j3 < length; _j3++) targets[i].values[_j3].index = tail + _j3, isTimeSeries || (targets[i].values[_j3].x = tail + _j3);
9187
9188 t.values = t.values.concat(targets[i].values), targets.splice(i, 1);
9189 break;
9190 }
9191
9192 found || notfoundIds.push(t.id);
9193 }), $$.data.targets.forEach(function (t) {
9194 for (var _i = 0; _i < notfoundIds.length; _i++) if (t.id === notfoundIds[_i]) {
9195 tail = t.values[t.values.length - 1].index + 1;
9196
9197 for (var _j4 = 0; _j4 < length; _j4++) t.values.push({
9198 id: t.id,
9199 index: tail + _j4,
9200 x: isTimeSeries ? $$.getOtherTargetX(tail + _j4) : tail + _j4,
9201 value: null
9202 });
9203 }
9204 }), $$.data.targets.length && targets.forEach(function (t) {
9205 for (var missing = [], i = $$.data.targets[0].values[0].index; i < tail; i++) missing.push({
9206 id: t.id,
9207 index: i,
9208 x: isTimeSeries ? $$.getOtherTargetX(i) : i,
9209 value: null
9210 });
9211
9212 t.values.forEach(function (v) {
9213 v.index += tail, isTimeSeries || (v.x += tail);
9214 }), t.values = missing.concat(t.values);
9215 }), $$.data.targets = $$.data.targets.concat(targets);
9216 // add remained
9217 // check data count because behavior needs to change when it"s only one
9218 // const dataCount = $$.getMaxDataCount();
9219 var baseTarget = $$.data.targets[0],
9220 baseValue = baseTarget.values[0];
9221 isDefined(args.to) ? (length = 0, to = isTimeSeries ? parseDate.call($$, args.to) : args.to, baseTarget.values.forEach(function (v) {
9222 v.x < to && length++;
9223 })) : isDefined(args.length) && (length = args.length), orgDataCount ? orgDataCount === 1 && isTimeSeries && (diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2, domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)]) : (diff = isTimeSeries ? baseTarget.values.length > 1 ? baseTarget.values[baseTarget.values.length - 1].x - baseValue.x : baseValue.x - $$.getXDomain($$.data.targets)[0] : 1, domain = [baseValue.x - diff, baseValue.x]), domain && $$.updateXDomain(null, !0, !0, !1, domain), $$.updateTargets($$.data.targets), $$.redraw({
9224 flow: {
9225 index: baseValue.index,
9226 length: length,
9227 duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
9228 done: args.done,
9229 orgDataCount: orgDataCount
9230 },
9231 withLegend: !0,
9232 withTransition: orgDataCount > 1,
9233 withTrimXDomain: !1,
9234 withUpdateXAxis: !0
9235 });
9236 }
9237 }
9238});
9239// EXTERNAL MODULE: external {"commonjs":"d3-axis","commonjs2":"d3-axis","amd":"d3-axis","root":"d3"}
9240var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack_require__(10);
9241;// CONCATENATED MODULE: ./src/ChartInternal/Axis/AxisRendererHelper.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
9250var AxisRendererHelper = /*#__PURE__*/function () {
9251 function AxisRendererHelper(owner) {
9252 this.owner = void 0, this.config = void 0, this.scale = void 0;
9253 var scale = getScale(),
9254 config = owner.config,
9255 params = owner.params;
9256 this.owner = owner, this.config = config, this.scale = scale, (config.noTransition || !params.config.transition_duration) && (config.withoutTransition = !0), config.range = this.scaleExtent((params.orgXScale || scale).range());
9257 }
9258 /**
9259 * Compute a character dimension
9260 * @param {d3.selection} node <g class=tick> node
9261 * @returns {{w: number, h: number}}
9262 * @private
9263 */
9264
9265
9266 AxisRendererHelper.getSizeFor1Char = function getSizeFor1Char(node) {
9267 // default size for one character
9268 var size = {
9269 w: 5.5,
9270 h: 11.5
9271 };
9272 return node.empty() || node.select("text").text("0").call(function (el) {
9273 try {
9274 var _el$node$getBBox = el.node().getBBox(),
9275 width = _el$node$getBBox.width,
9276 height = _el$node$getBBox.height;
9277
9278 width && height && (size.w = width, size.h = height);
9279 } catch (e) {} finally {
9280 el.text("");
9281 }
9282 }), this.getSizeFor1Char = function () {
9283 return size;
9284 }, size;
9285 }
9286 /**
9287 * Get tick transform setter function
9288 * @param {string} id Axis id
9289 * @returns {Function} transfrom setter function
9290 * @private
9291 */
9292 ;
9293
9294 var _proto = AxisRendererHelper.prototype;
9295 return _proto.getTickTransformSetter = function getTickTransformSetter(id) {
9296 var config = this.config,
9297 fn = id === "x" ? function (value) {
9298 return "translate(" + (value + config.tickOffset) + ",0)";
9299 } : function (value) {
9300 return "translate(0," + value + ")";
9301 };
9302 return function (selection, scale) {
9303 selection.attr("transform", function (d) {
9304 return fn(Math.ceil(scale(d)));
9305 });
9306 };
9307 }, _proto.scaleExtent = function scaleExtent(domain) {
9308 var start = domain[0],
9309 stop = domain[domain.length - 1];
9310 return start < stop ? [start, stop] : [stop, start];
9311 }, _proto.generateTicks = function generateTicks(scale, isYAxes) {
9312 var tickStepSize = this.owner.params.tickStepSize,
9313 _scale$domain = scale.domain(),
9314 start = _scale$domain[0],
9315 end = _scale$domain[1],
9316 ticks = [];
9317
9318 // When 'axis[y|y2].tick.stepSize' option is set
9319 if (isYAxes && tickStepSize) for (var interval = start; interval <= end;) ticks.push(interval), interval += tickStepSize;else if (scale.ticks) {
9320 var tickArguments = this.config.tickArguments; // adjust excessive tick count show
9321
9322 if (scale.type === "log" && !tickArguments) {
9323 // nicer symlog ticks didn't implemented yet: https://github.com/d3/d3-scale/issues/162
9324 // get ticks values from logScale
9325 var s = getScale("_log").domain([start > 0 ? start : 1, end]).range(scale.range());
9326 ticks = s.ticks();
9327
9328 for (var cnt = end.toFixed().length; ticks.length > 15; cnt--) ticks = s.ticks(cnt);
9329
9330 ticks.splice(0, 1, start), ticks.splice(ticks.length - 1, 1, end);
9331 } else ticks = scale.ticks.apply(scale, this.config.tickArguments || []);
9332
9333 ticks = ticks.map(function (v) {
9334 // round the tick value if is number
9335 var r = isString(v) && isNumber(v) && !isNaN(v) && Math.round(v * 10) / 10 || v;
9336 return r;
9337 });
9338 } else {
9339 for (var i = Math.ceil(start); i < end; i++) ticks.push(i);
9340
9341 ticks.length > 0 && ticks[0] > 0 && ticks.unshift(ticks[0] - (ticks[1] - ticks[0]));
9342 }
9343 return ticks;
9344 }, _proto.copyScale = function copyScale() {
9345 var newScale = this.scale.copy();
9346 return newScale.domain().length || newScale.domain(this.scale.domain()), newScale.type = this.scale.type, newScale;
9347 }, _proto.textFormatted = function textFormatted(v) {
9348 var tickFormat = this.config.tickFormat,
9349 value = /\d+\.\d+0{5,}\d$/.test(v) ? +(v + "").replace(/0+\d$/, "") : v,
9350 formatted = tickFormat ? tickFormat(value) : value; // to round float numbers from 'binary floating point'
9351 // https://en.wikipedia.org/wiki/Double-precision_floating-point_format
9352 // https://stackoverflow.com/questions/17849101/laymans-explanation-for-why-javascript-has-weird-floating-math-ieee-754-stand
9353
9354 return isDefined(formatted) ? formatted : "";
9355 }, _proto.transitionise = function transitionise(selection) {
9356 var config = this.config;
9357 return config.withoutTransition ? selection.interrupt() : selection.transition(config.transition);
9358 }, AxisRendererHelper;
9359}();
9360
9361
9362;// CONCATENATED MODULE: ./src/ChartInternal/Axis/AxisRenderer.ts
9363/**
9364 * Copyright (c) 2017 ~ present NAVER Corp.
9365 * billboard.js project is licensed under the MIT license
9366 * @ignore
9367 */
9368
9369
9370
9371
9372var AxisRenderer = /*#__PURE__*/function () {
9373 function AxisRenderer(params) {
9374 params === void 0 && (params = {}), this.helper = void 0, this.config = void 0, this.params = void 0, this.g = void 0;
9375 var config = {
9376 innerTickSize: 6,
9377 outerTickSize: params.outerTick ? 6 : 0,
9378 orient: "bottom",
9379 range: [],
9380 tickArguments: null,
9381 tickCentered: null,
9382 tickCulling: !0,
9383 tickFormat: null,
9384 tickLength: 9,
9385 tickOffset: 0,
9386 tickPadding: 3,
9387 tickValues: null,
9388 transition: null,
9389 noTransition: params.noTransition
9390 };
9391 config.tickLength = Math.max(config.innerTickSize, 0) + config.tickPadding, this.config = config, this.params = params, this.helper = new AxisRendererHelper(this);
9392 }
9393 /**
9394 * Create axis element
9395 * @param {d3.selection} g Axis selection
9396 * @private
9397 */
9398
9399
9400 var _proto = AxisRenderer.prototype;
9401 return _proto.create = function create(g) {
9402 var ctx = this,
9403 config = this.config,
9404 helper = this.helper,
9405 params = this.params,
9406 scale = helper.scale,
9407 orient = config.orient,
9408 splitTickText = this.splitTickText.bind(this),
9409 isLeftRight = /^(left|right)$/.test(orient),
9410 isTopBottom = /^(top|bottom)$/.test(orient),
9411 tickTransform = helper.getTickTransformSetter(isTopBottom ? "x" : "y"),
9412 axisPx = tickTransform === helper.axisX ? "y" : "x",
9413 sign = /^(top|left)$/.test(orient) ? -1 : 1,
9414 rotate = params.tickTextRotate;
9415 this.config.range = scale.rangeExtent ? scale.rangeExtent() : helper.scaleExtent((params.orgXScale || scale).range());
9416 var $g,
9417 _config2 = config,
9418 innerTickSize = _config2.innerTickSize,
9419 tickLength = _config2.tickLength,
9420 range = _config2.range,
9421 id = params.id,
9422 tickTextPos = id && /^(x|y|y2)$/.test(id) ? params.config["axis_" + id + "_tick_text_position"] : {
9423 x: 0,
9424 y: 0
9425 },
9426 prefix = id === "subX" ? "subchart_axis_x" : "axis_" + id,
9427 axisShow = params.config[prefix + "_show"],
9428 tickShow = {
9429 tick: !!axisShow && params.config[prefix + "_tick_show"],
9430 text: !!axisShow && params.config[prefix + "_tick_text_show"]
9431 }; // // get the axis' tick position configuration
9432
9433 g.each(function () {
9434 var g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
9435 scale0 = this.__chart__ || scale,
9436 scale1 = helper.copyScale();
9437 $g = g, this.__chart__ = scale1, config.tickOffset = params.isCategory ? Math.ceil((scale1(1) - scale1(0)) / 2) : 0;
9438 // update selection - data join
9439 var path = g.selectAll(".domain").data([0]); // enter + update selection
9440
9441 if (path.enter().append("path").attr("class", "domain") // https://observablehq.com/@d3/d3-selection-2-0
9442 .merge(helper.transitionise(path).selection()).attr("d", function () {
9443 var outerTickSized = config.outerTickSize * sign;
9444 return isTopBottom ? "M" + range[0] + "," + outerTickSized + "V0H" + range[1] + "V" + outerTickSized : "M" + outerTickSized + "," + range[0] + "H0V" + range[1] + "H" + outerTickSized;
9445 }), tickShow.tick || tickShow.text) {
9446 // count of tick data in array
9447 var ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight),
9448 tick = g.selectAll(".tick").data(ticks, scale1),
9449 tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", "1"),
9450 tickExit = tick.exit().remove(); // update selection
9451
9452 tick = tickEnter.merge(tick), tickShow.tick && tickEnter.append("line"), tickShow.text && tickEnter.append("text");
9453 var sizeFor1Char = AxisRendererHelper.getSizeFor1Char(tick),
9454 counts = [],
9455 tspan = tick.select("text").selectAll("tspan").data(function (d, index) {
9456 var split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
9457 return counts[index] = split.length, split.map(function (splitted) {
9458 return {
9459 index: index,
9460 splitted: splitted
9461 };
9462 });
9463 });
9464 tspan.exit().remove(), tspan = tspan.enter().append("tspan").merge(tspan).text(function (d) {
9465 return d.splitted;
9466 }), tspan.attr("x", isTopBottom ? 0 : tickLength * sign).attr("dx", function () {
9467 var dx = 0;
9468 return /(top|bottom)/.test(orient) && rotate && (dx = 8 * Math.sin(Math.PI * (rotate / 180)) * (orient === "top" ? -1 : 1)), dx + (tickTextPos.x || 0);
9469 }()).attr("dy", function (d, i) {
9470 var dy = 0;
9471 return orient !== "top" && (dy = sizeFor1Char.h, i === 0 && (dy = isLeftRight ? -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3) : tickTextPos.y === 0 ? ".71em" : 0)), isNumber(dy) && tickTextPos.y ? dy + tickTextPos.y : dy || ".71em";
9472 });
9473 var lineUpdate = tick.select("line"),
9474 textUpdate = tick.select("text");
9475
9476 // Append <title> for tooltip display
9477 if (tickEnter.select("line").attr(axisPx + "2", innerTickSize * sign), tickEnter.select("text").attr(axisPx, tickLength * sign), ctx.setTickLineTextPosition(lineUpdate, textUpdate), params.tickTitle) {
9478 var title = textUpdate.select("title");
9479 (title.empty() ? textUpdate.append("title") : title).text(function (index) {
9480 return params.tickTitle[index];
9481 });
9482 }
9483
9484 if (scale1.bandwidth) {
9485 var x = scale1,
9486 dx = x.bandwidth() / 2;
9487 scale0 = function (d) {
9488 return x(d) + dx;
9489 }, scale1 = scale0;
9490 } else scale0.bandwidth ? scale0 = scale1 : tickTransform(tickExit, scale1);
9491
9492 tickTransform(tickEnter, scale0), tickTransform(helper.transitionise(tick).style("opacity", "1"), scale1);
9493 }
9494 }), this.g = $g;
9495 }
9496 /**
9497 * Get tick x/y coordinate
9498 * @returns {{x: number, y: number}}
9499 * @private
9500 */
9501 , _proto.getTickXY = function getTickXY() {
9502 var config = this.config,
9503 pos = {
9504 x: 0,
9505 y: 0
9506 };
9507 return this.params.isCategory && (pos.x = config.tickCentered ? 0 : config.tickOffset, pos.y = config.tickCentered ? config.tickOffset : 0), pos;
9508 }
9509 /**
9510 * Get tick size
9511 * @param {object} d data object
9512 * @returns {number}
9513 * @private
9514 */
9515 , _proto.getTickSize = function getTickSize(d) {
9516 var scale = this.helper.scale,
9517 config = this.config,
9518 _config3 = config,
9519 innerTickSize = _config3.innerTickSize,
9520 range = _config3.range,
9521 tickPosition = scale(d) + (config.tickCentered ? 0 : config.tickOffset);
9522 return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0;
9523 }
9524 /**
9525 * Set tick's line & text position
9526 * @param {d3.selection} lineUpdate Line selection
9527 * @param {d3.selection} textUpdate Text selection
9528 * @private
9529 */
9530 , _proto.setTickLineTextPosition = function setTickLineTextPosition(lineUpdate, textUpdate) {
9531 var tickPos = this.getTickXY(),
9532 _this$config = this.config,
9533 innerTickSize = _this$config.innerTickSize,
9534 orient = _this$config.orient,
9535 tickLength = _this$config.tickLength,
9536 tickOffset = _this$config.tickOffset,
9537 rotate = this.params.tickTextRotate,
9538 textAnchorForText = function (r) {
9539 var value = ["start", "end"];
9540 return orient === "top" && value.reverse(), r ? r > 0 ? value[0] : value[1] : "middle";
9541 },
9542 textTransform = function (r) {
9543 return r ? "rotate(" + r + ")" : null;
9544 },
9545 yForText = function (r) {
9546 var r2 = r / (orient === "bottom" ? 15 : 23);
9547 return r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
9548 };
9549
9550 orient === "bottom" ? (lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", this.getTickSize.bind(this)), textUpdate.attr("x", 0).attr("y", yForText(rotate)).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate))) : orient === "top" ? (lineUpdate.attr("x2", 0).attr("y2", -innerTickSize), textUpdate.attr("x", 0).attr("y", -yForText(rotate) * 2).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate))) : orient === "left" ? (lineUpdate.attr("x2", -innerTickSize).attr("y1", tickPos.y).attr("y2", tickPos.y), textUpdate.attr("x", -tickLength).attr("y", tickOffset).style("text-anchor", "end")) : orient === "right" ? (lineUpdate.attr("x2", innerTickSize).attr("y2", 0), textUpdate.attr("x", tickLength).attr("y", 0).style("text-anchor", "start")) : void 0;
9551 } // this should be called only when category axis
9552 , _proto.splitTickText = function splitTickText(d, scale, ticks, isLeftRight, charWidth) {
9553 // split given text by tick width size
9554 // eslint-disable-next-line
9555 function split(splitted, text) {
9556 for (var subtext, spaceIndex, textWidth, i = 1; i < text.length; i++) // if text width gets over tick width, split by space index or current index
9557 if (text.charAt(i) === " " && (spaceIndex = i), subtext = text.substr(0, i + 1), textWidth = charWidth * subtext.length, tickWidth < textWidth) return split(splitted.concat(text.substr(0, spaceIndex || i)), text.slice(spaceIndex ? spaceIndex + 1 : i));
9558
9559 return splitted.concat(text);
9560 }
9561
9562 var params = this.params,
9563 tickText = this.helper.textFormatted(d),
9564 splitted = isString(tickText) && tickText.indexOf("\n") > -1 ? tickText.split("\n") : [];
9565 if (splitted.length) return splitted;
9566 if (isArray(tickText)) return tickText;
9567 var tickWidth = params.tickWidth;
9568 return (!tickWidth || tickWidth <= 0) && (tickWidth = isLeftRight ? 95 : params.isCategory ? Math.ceil(scale(ticks[1]) - scale(ticks[0])) - 12 : 110), split(splitted, tickText + "");
9569 }, _proto.scale = function scale(x) {
9570 return arguments.length ? (this.helper.scale = x, this) : this.helper.scale;
9571 }, _proto.orient = function orient(x) {
9572 return arguments.length ? (this.config.orient = x in {
9573 top: 1,
9574 right: 1,
9575 bottom: 1,
9576 left: 1
9577 } ? x + "" : "bottom", this) : this.config.orient;
9578 }, _proto.tickFormat = function tickFormat(format) {
9579 var config = this.config;
9580 return arguments.length ? (config.tickFormat = format, this) : config.tickFormat;
9581 }, _proto.tickCentered = function tickCentered(isCentered) {
9582 var config = this.config;
9583 return arguments.length ? (config.tickCentered = isCentered, this) : config.tickCentered;
9584 }
9585 /**
9586 * Return tick's offset value.
9587 * The value will be set for 'category' axis type.
9588 * @returns {number}
9589 * @private
9590 */
9591 , _proto.tickOffset = function tickOffset() {
9592 return this.config.tickOffset;
9593 }
9594 /**
9595 * Get tick interval count
9596 * @private
9597 * @param {number} size Total data size
9598 * @returns {number}
9599 */
9600 , _proto.tickInterval = function tickInterval(size) {
9601 var interval,
9602 _this = this;
9603
9604 if (this.params.isCategory) interval = this.config.tickOffset * 2;else {
9605 var length = this.g.select("path.domain").node().getTotalLength() - this.config.outerTickSize * 2;
9606 interval = length / (size || this.g.selectAll("line").size());
9607 // get the interval by its values
9608 var intervalByValue = this.config.tickValues.map(function (v, i, arr) {
9609 var next = i + 1;
9610 return next < arr.length ? _this.helper.scale(arr[next]) - _this.helper.scale(v) : null;
9611 }).filter(Boolean);
9612 interval = Math.min.apply(Math, intervalByValue.concat([interval]));
9613 }
9614 return interval === Infinity ? 0 : interval;
9615 }, _proto.ticks = function ticks() {
9616 for (var config = this.config, _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
9617
9618 return args.length ? (config.tickArguments = toArray(args), this) : config.tickArguments;
9619 }, _proto.tickCulling = function tickCulling(culling) {
9620 var config = this.config;
9621 return arguments.length ? (config.tickCulling = culling, this) : config.tickCulling;
9622 }, _proto.tickValues = function tickValues(x) {
9623 var _this2 = this,
9624 config = this.config;
9625
9626 if (isFunction(x)) config.tickValues = function () {
9627 return x(_this2.helper.scale.domain());
9628 };else {
9629 if (!arguments.length) return config.tickValues;
9630 config.tickValues = x;
9631 }
9632 return this;
9633 }, _proto.setTransition = function setTransition(t) {
9634 return this.config.transition = t, this;
9635 }, AxisRenderer;
9636}();
9637
9638
9639;// CONCATENATED MODULE: ./src/ChartInternal/Axis/Axis.ts
9640/**
9641 * Copyright (c) 2017 ~ present NAVER Corp.
9642 * billboard.js project is licensed under the MIT license
9643 */
9644
9645
9646
9647
9648
9649/* harmony default export */ var Axis = ({
9650 getAxisInstance: function getAxisInstance() {
9651 return this.axis || new Axis_Axis(this);
9652 }
9653});
9654
9655var Axis_Axis = /*#__PURE__*/function () {
9656 function Axis(owner) {
9657 this.owner = void 0, this.x = void 0, this.subX = void 0, this.y = void 0, this.y2 = void 0, this.axesList = {}, this.tick = {
9658 x: null,
9659 y: null,
9660 y2: null
9661 }, this.xs = [], this.orient = {
9662 x: "bottom",
9663 y: "left",
9664 y2: "right",
9665 subX: "bottom"
9666 }, this.owner = owner, this.setOrient();
9667 }
9668
9669 var _proto = Axis.prototype;
9670 return _proto.getAxisClassName = function getAxisClassName(id) {
9671 return config_classes.axis + " " + config_classes["axis" + capitalize(id)];
9672 }, _proto.isHorizontal = function isHorizontal($$, forHorizontal) {
9673 var isRotated = $$.config.axis_rotated;
9674 return forHorizontal ? isRotated : !isRotated;
9675 }, _proto.isCategorized = function isCategorized() {
9676 var _this$owner = this.owner,
9677 config = _this$owner.config,
9678 state = _this$owner.state;
9679 return config.axis_x_type.indexOf("category") >= 0 || state.hasRadar;
9680 }, _proto.isCustomX = function isCustomX() {
9681 var config = this.owner.config;
9682 return !this.isTimeSeries() && (config.data_x || notEmpty(config.data_xs));
9683 }, _proto.isTimeSeries = function isTimeSeries(id) {
9684 return id === void 0 && (id = "x"), this.owner.config["axis_" + id + "_type"] === "timeseries";
9685 }, _proto.isLog = function isLog(id) {
9686 return id === void 0 && (id = "x"), this.owner.config["axis_" + id + "_type"] === "log";
9687 }, _proto.isTimeSeriesY = function isTimeSeriesY() {
9688 return this.isTimeSeries("y");
9689 }, _proto.getAxisType = function getAxisType(id) {
9690 id === void 0 && (id = "x");
9691 var type = "linear";
9692 return this.isTimeSeries(id) ? type = "time" : this.isLog(id) && (type = "log"), type;
9693 }, _proto.init = function init() {
9694 var _this = this,
9695 $$ = this.owner,
9696 config = $$.config,
9697 _$$$$el = $$.$el,
9698 main = _$$$$el.main,
9699 axis = _$$$$el.axis,
9700 clip = $$.state.clip,
9701 isRotated = config.axis_rotated,
9702 target = ["x", "y"];
9703
9704 config.axis_y2_show && target.push("y2"), target.forEach(function (v) {
9705 var classAxis = _this.getAxisClassName(v),
9706 classLabel = config_classes["axis" + v.toUpperCase() + "Label"];
9707
9708 axis[v] = main.append("g").attr("class", classAxis).attr("clip-path", function () {
9709 var res = null;
9710 return v === "x" ? res = clip.pathXAxis : v === "y" && (res = clip.pathYAxis), res;
9711 }).attr("transform", $$.getTranslate(v)).style("visibility", config["axis_" + v + "_show"] ? "visible" : "hidden"), axis[v].append("text").attr("class", classLabel).attr("transform", ["rotate(-90)", null][v === "x" ? +!isRotated : +isRotated]).style("text-anchor", function () {
9712 return _this.textAnchorForAxisLabel(v);
9713 }), _this.generateAxes(v);
9714 });
9715 }
9716 /**
9717 * Set axis orient according option value
9718 * @private
9719 */
9720 , _proto.setOrient = function setOrient() {
9721 var $$ = this.owner,
9722 _$$$config = $$.config,
9723 isRotated = _$$$config.axis_rotated,
9724 yInner = _$$$config.axis_y_inner,
9725 y2Inner = _$$$config.axis_y2_inner;
9726 this.orient = {
9727 x: isRotated ? "left" : "bottom",
9728 y: isRotated ? yInner ? "top" : "bottom" : yInner ? "right" : "left",
9729 y2: isRotated ? y2Inner ? "bottom" : "top" : y2Inner ? "left" : "right",
9730 subX: isRotated ? "left" : "bottom"
9731 };
9732 }
9733 /**
9734 * Generate axes
9735 * It's used when axis' axes option is set
9736 * @param {string} id Axis id
9737 * @private
9738 */
9739 , _proto.generateAxes = function generateAxes(id) {
9740 var d3Axis,
9741 $$ = this.owner,
9742 config = $$.config,
9743 axes = [],
9744 axesConfig = config["axis_" + id + "_axes"],
9745 isRotated = config.axis_rotated;
9746 id === "x" ? 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 : id === "y" ? 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 : id === "y2" && (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), axesConfig.length && axesConfig.forEach(function (v) {
9747 var tick = v.tick || {},
9748 scale = $$.scale[id].copy();
9749 v.domain && scale.domain(v.domain), axes.push(d3Axis(scale).ticks(tick.count).tickFormat(isFunction(tick.format) ? tick.format.bind($$.api) : function (x) {
9750 return x;
9751 }).tickValues(tick.values).tickSizeOuter(tick.outer === !1 ? 0 : 6));
9752 }), this.axesList[id] = axes;
9753 }
9754 /**
9755 * Update axes nodes
9756 * @private
9757 */
9758 , _proto.updateAxes = function updateAxes() {
9759 var _this2 = this,
9760 $$ = this.owner,
9761 config = $$.config,
9762 main = $$.$el.main;
9763
9764 Object.keys(this.axesList).forEach(function (id) {
9765 var axesConfig = config["axis_" + id + "_axes"],
9766 scale = $$.scale[id].copy(),
9767 range = scale.range();
9768
9769 _this2.axesList[id].forEach(function (v, i) {
9770 var axisRange = v.scale().range(); // adjust range value with the current
9771 // https://github.com/naver/billboard.js/issues/859
9772
9773 range.every(function (v, i) {
9774 return v === axisRange[i];
9775 }) || v.scale().range(range);
9776 var className = _this2.getAxisClassName(id) + "-" + (i + 1),
9777 g = main.select("." + className.replace(/\s/, "."));
9778 g.empty() ? g = main.append("g").attr("class", className).style("visibility", config["axis_" + id + "_show"] ? "visible" : "hidden").call(v) : (axesConfig[i].domain && scale.domain(axesConfig[i].domain), _this2.x.helper.transitionise(g).call(v.scale(scale))), g.attr("transform", $$.getTranslate(id, i + 1));
9779 });
9780 });
9781 }
9782 /**
9783 * Set Axis & tick values
9784 * called from: updateScales()
9785 * @param {string} id Axis id string
9786 * @param {d3Scale} scale Scale
9787 * @param {boolean} outerTick If show outer tick
9788 * @param {boolean} noTransition If with no transition
9789 * @private
9790 */
9791 , _proto.setAxis = function setAxis(id, scale, outerTick, noTransition) {
9792 var $$ = this.owner;
9793 id !== "subX" && (this.tick[id] = this.getTickValues(id)), this[id] = this.getAxis(id, scale, outerTick, // do not transit x Axis on zoom and resizing
9794 // https://github.com/naver/billboard.js/issues/1949
9795 !!(id === "x" && ($$.scale.zoom || $$.config.subchart_show || $$.state.resizing)) || noTransition);
9796 } // called from : getMaxTickWidth()
9797 , _proto.getAxis = function getAxis(id, scale, outerTick, noTransition, noTickTextRotate) {
9798 var tickFormat,
9799 $$ = this.owner,
9800 config = $$.config,
9801 isX = /^(x|subX)$/.test(id),
9802 type = isX ? "x" : id,
9803 isCategory = isX && this.isCategorized(),
9804 orient = this.orient[id],
9805 tickTextRotate = noTickTextRotate ? 0 : $$.getAxisTickRotate(type);
9806 if (isX) tickFormat = $$.format.xAxisTick;else {
9807 var fn = config["axis_" + id + "_tick_format"];
9808 isFunction(fn) && (tickFormat = fn.bind($$.api));
9809 }
9810 var tickValues = this.tick[type],
9811 axisParams = mergeObj({
9812 outerTick: outerTick,
9813 noTransition: noTransition,
9814 config: config,
9815 id: id,
9816 tickTextRotate: tickTextRotate
9817 }, isX && {
9818 isCategory: isCategory,
9819 tickMultiline: config.axis_x_tick_multiline,
9820 tickWidth: config.axis_x_tick_width,
9821 tickTitle: isCategory && config.axis_x_tick_tooltip && $$.api.categories(),
9822 orgXScale: $$.scale.x
9823 });
9824 isX || (axisParams.tickStepSize = config["axis_" + type + "_tick_stepSize"]);
9825 var axis = new AxisRenderer(axisParams).scale(isX && $$.scale.zoom || scale).orient(orient);
9826
9827 if (isX && this.isTimeSeries() && tickValues && !isFunction(tickValues)) {
9828 var _fn = parseDate.bind($$);
9829
9830 tickValues = tickValues.map(function (v) {
9831 return _fn(v);
9832 });
9833 } else !isX && this.isTimeSeriesY() && ( // https://github.com/d3/d3/blob/master/CHANGES.md#time-intervals-d3-time
9834 axis.ticks(config.axis_y_tick_time_value), tickValues = null);
9835
9836 tickValues && axis.tickValues(tickValues), axis.tickFormat(tickFormat || !isX && $$.isStackNormalized() && function (x) {
9837 return x + "%";
9838 }), isCategory && (axis.tickCentered(config.axis_x_tick_centered), isEmpty(config.axis_x_tick_culling) && (config.axis_x_tick_culling = !1));
9839 var tickCount = config["axis_" + type + "_tick_count"];
9840 return tickCount && axis.ticks(tickCount), axis;
9841 }, _proto.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) {
9842 var values,
9843 $$ = this.owner,
9844 config = $$.config,
9845 fit = config.axis_x_tick_fit,
9846 count = config.axis_x_tick_count;
9847 return (fit || count && fit) && (values = $$.mapTargetsToUniqueXs(targets), this.isCategorized() && count > values.length && (count = values.length), values = this.generateTickValues(values, count, this.isTimeSeries())), axis ? axis.tickValues(values) : this.x && (this.x.tickValues(values), this.subX && this.subX.tickValues(values)), values;
9848 }, _proto.getId = function getId(id) {
9849 var _this$owner2 = this.owner,
9850 config = _this$owner2.config,
9851 scale = _this$owner2.scale,
9852 axis = config.data_axes[id];
9853 return axis && scale[axis] || (axis = "y"), axis;
9854 }, _proto.getXAxisTickFormat = function getXAxisTickFormat() {
9855 var currFormat,
9856 $$ = this.owner,
9857 config = $$.config,
9858 format = $$.format,
9859 tickFormat = config.axis_x_tick_format,
9860 isTimeSeries = this.isTimeSeries(),
9861 isCategorized = this.isCategorized();
9862 return tickFormat ? isFunction(tickFormat) ? currFormat = tickFormat.bind($$.api) : isTimeSeries && (currFormat = function (date) {
9863 return date ? format.axisTime(tickFormat)(date) : "";
9864 }) : currFormat = isTimeSeries ? format.defaultAxisTime : isCategorized ? $$.categoryName : function (v) {
9865 return v < 0 ? v.toFixed(0) : v;
9866 }, isFunction(currFormat) ? function (v) {
9867 return currFormat.apply($$, isCategorized ? [v, $$.categoryName(v)] : [v]);
9868 } : currFormat;
9869 }, _proto.getTickValues = function getTickValues(id) {
9870 var $$ = this.owner,
9871 tickValues = $$.config["axis_" + id + "_tick_values"],
9872 axis = $$[id + "Axis"];
9873 return (isFunction(tickValues) ? tickValues.call($$.api) : tickValues) || (axis ? axis.tickValues() : undefined);
9874 }, _proto.getLabelOptionByAxisId = function getLabelOptionByAxisId(id) {
9875 return this.owner.config["axis_" + id + "_label"];
9876 }, _proto.getLabelText = function getLabelText(id) {
9877 var option = this.getLabelOptionByAxisId(id);
9878 return isString(option) ? option : option ? option.text : null;
9879 }, _proto.setLabelText = function setLabelText(id, text) {
9880 var $$ = this.owner,
9881 config = $$.config,
9882 option = this.getLabelOptionByAxisId(id);
9883 isString(option) ? config["axis_" + id + "_label"] = text : option && (option.text = text);
9884 }, _proto.getLabelPosition = function getLabelPosition(id, defaultPosition) {
9885 var isRotated = this.owner.config.axis_rotated,
9886 option = this.getLabelOptionByAxisId(id),
9887 position = isObjectType(option) && option.position ? option.position : defaultPosition[+!isRotated],
9888 has = function (v) {
9889 return !!~position.indexOf(v);
9890 };
9891
9892 return {
9893 isInner: has("inner"),
9894 isOuter: has("outer"),
9895 isLeft: has("left"),
9896 isCenter: has("center"),
9897 isRight: has("right"),
9898 isTop: has("top"),
9899 isMiddle: has("middle"),
9900 isBottom: has("bottom")
9901 };
9902 }, _proto.getAxisLabelPosition = function getAxisLabelPosition(id) {
9903 return this.getLabelPosition(id, id === "x" ? ["inner-top", "inner-right"] : ["inner-right", "inner-top"]);
9904 }, _proto.getLabelPositionById = function getLabelPositionById(id) {
9905 return this.getAxisLabelPosition(id);
9906 }, _proto.xForAxisLabel = function xForAxisLabel(id) {
9907 var $$ = this.owner,
9908 _$$$state = $$.state,
9909 width = _$$$state.width,
9910 height = _$$$state.height,
9911 position = this.getAxisLabelPosition(id),
9912 x = position.isMiddle ? -height / 2 : 0;
9913 return this.isHorizontal($$, id !== "x") ? x = position.isLeft ? 0 : position.isCenter ? width / 2 : width : position.isBottom && (x = -height), x;
9914 }, _proto.dxForAxisLabel = function dxForAxisLabel(id) {
9915 var $$ = this.owner,
9916 position = this.getAxisLabelPosition(id),
9917 dx = position.isBottom ? "0.5em" : "0";
9918 return this.isHorizontal($$, id !== "x") ? dx = position.isLeft ? "0.5em" : position.isRight ? "-0.5em" : "0" : position.isTop && (dx = "-0.5em"), dx;
9919 }, _proto.textAnchorForAxisLabel = function textAnchorForAxisLabel(id) {
9920 var $$ = this.owner,
9921 position = this.getAxisLabelPosition(id),
9922 anchor = position.isMiddle ? "middle" : "end";
9923 return this.isHorizontal($$, id !== "x") ? anchor = position.isLeft ? "start" : position.isCenter ? "middle" : "end" : position.isBottom && (anchor = "start"), anchor;
9924 }, _proto.dyForAxisLabel = function dyForAxisLabel(id) {
9925 var dy,
9926 $$ = this.owner,
9927 config = $$.config,
9928 isRotated = config.axis_rotated,
9929 isInner = this.getAxisLabelPosition(id).isInner,
9930 tickRotate = config["axis_" + id + "_tick_rotate"] ? $$.getHorizontalAxisHeight(id) : 0,
9931 maxTickWidth = this.getMaxTickWidth(id);
9932
9933 if (id === "x") {
9934 var xHeight = config.axis_x_height;
9935 dy = isRotated ? isInner ? "1.2em" : -25 - maxTickWidth : isInner ? "-0.5em" : xHeight ? xHeight - 10 : tickRotate ? tickRotate - 10 : "3em";
9936 } else dy = {
9937 y: ["-0.5em", 10, "3em", "1.2em", 10],
9938 y2: ["1.2em", -20, "-2.2em", "-0.5em", 15]
9939 }[id], dy = isRotated ? isInner ? dy[0] : tickRotate ? tickRotate * (id === "y2" ? -1 : 1) - dy[1] : dy[2] : isInner ? dy[3] : (dy[4] + (config["axis_" + id + "_inner"] ? 0 : maxTickWidth + dy[4])) * (id === "y" ? -1 : 1);
9940
9941 return dy;
9942 }, _proto.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) {
9943 var $$ = this.owner,
9944 config = $$.config,
9945 current = $$.state.current,
9946 _$$$$el2 = $$.$el,
9947 svg = _$$$$el2.svg,
9948 chart = _$$$$el2.chart,
9949 currentTickMax = current.maxTickWidths[id],
9950 maxWidth = 0;
9951 if (withoutRecompute || !config["axis_" + id + "_show"] || $$.filterTargetsToShow().length === 0) return currentTickMax.size;
9952
9953 if (svg) {
9954 var isYAxis = /^y2?$/.test(id),
9955 targetsToShow = $$.filterTargetsToShow($$.data.targets),
9956 scale = $$.scale[id].copy().domain($$["get" + (isYAxis ? "Y" : "X") + "Domain"](targetsToShow, id)),
9957 domain = scale.domain(),
9958 isDomainSame = domain[0] === domain[1] && domain.every(function (v) {
9959 return v > 0;
9960 }),
9961 isCurrentMaxTickDomainSame = isArray(currentTickMax.domain) && currentTickMax.domain[0] === currentTickMax.domain[1] && currentTickMax.domain.every(function (v) {
9962 return v > 0;
9963 });
9964 // do not compute if domain or currentMaxTickDomain is same
9965 if (isDomainSame || isCurrentMaxTickDomainSame) return currentTickMax.size; // reset old max state value to prevent from new data loading
9966
9967 currentTickMax.domain = domain, isYAxis || currentTickMax.ticks.splice(0);
9968 var axis = this.getAxis(id, scale, !1, !1, !0),
9969 tickCount = config["axis_" + id + "_tick_count"],
9970 tickValues = config["axis_" + id + "_tick_values"];
9971 !tickValues && tickCount && axis.tickValues(this.generateTickValues(domain, tickCount, isYAxis ? this.isTimeSeriesY() : this.isTimeSeries())), isYAxis || this.updateXAxisTickValues(targetsToShow, axis);
9972 var dummy = chart.append("svg").style("visibility", "hidden").style("position", "fixed").style("top", "0px").style("left", "0px");
9973 axis.create(dummy), dummy.selectAll("text").each(function (d, i) {
9974 var currentTextWidth = this.getBoundingClientRect().width;
9975 maxWidth = Math.max(maxWidth, currentTextWidth), isYAxis || (currentTickMax.ticks[i] = currentTextWidth);
9976 }), dummy.remove();
9977 }
9978
9979 return maxWidth > 0 && (currentTickMax.size = maxWidth), currentTickMax.size;
9980 }, _proto.getXAxisTickTextY2Overflow = function getXAxisTickTextY2Overflow(defaultPadding) {
9981 var $$ = this.owner,
9982 axis = $$.axis,
9983 config = $$.config,
9984 state = $$.state,
9985 xAxisTickRotate = $$.getAxisTickRotate("x");
9986
9987 if ((axis.isCategorized() || axis.isTimeSeries()) && config.axis_x_tick_fit && !config.axis_x_tick_culling && !config.axis_x_tick_multiline && xAxisTickRotate > 0 && xAxisTickRotate < 90) {
9988 var widthWithoutCurrentPaddingLeft = state.current.width - $$.getCurrentPaddingLeft(),
9989 maxOverflow = this.getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft - defaultPadding),
9990 xAxisTickTextY2Overflow = Math.max(0, maxOverflow) + defaultPadding;
9991 // for display inconsistencies between browsers
9992 return Math.min(xAxisTickTextY2Overflow, widthWithoutCurrentPaddingLeft / 2);
9993 }
9994
9995 return 0;
9996 }, _proto.getXAxisTickMaxOverflow = function getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft) {
9997 for (var $$ = this.owner, axis = $$.axis, config = $$.config, state = $$.state, isTimeSeries = axis.isTimeSeries(), tickTextWidths = state.current.maxTickWidths.x.ticks, tickCount = tickTextWidths.length, _state$axis$x$padding = state.axis.x.padding, left = _state$axis$x$padding.left, right = _state$axis$x$padding.right, maxOverflow = 0, remaining = tickCount - (isTimeSeries && config.axis_x_tick_fit ? .5 : 0), i = 0; i < tickCount; i++) {
9998 var tickIndex = i + 1,
9999 rotatedTickTextWidth = Math.cos(Math.PI * xAxisTickRotate / 180) * tickTextWidths[i],
10000 ticksBeforeTickText = tickIndex - (isTimeSeries ? 1 : .5) + left;
10001
10002 // Skip ticks if there are no ticks before them
10003 if (!(ticksBeforeTickText <= 0)) {
10004 var tickLength = (widthWithoutCurrentPaddingLeft - rotatedTickTextWidth) / ticksBeforeTickText;
10005 maxOverflow = Math.max(maxOverflow, rotatedTickTextWidth - tickLength / 2 - ((remaining - tickIndex) * tickLength + right * tickLength));
10006 }
10007 }
10008
10009 var filteredTargets = $$.filterTargetsToShow($$.data.targets),
10010 tickOffset = 0;
10011
10012 if (!isTimeSeries && config.axis_x_tick_count <= filteredTargets.length && filteredTargets[0].values.length) {
10013 var scale = getScale($$.axis.getAxisType("x"), 0, widthWithoutCurrentPaddingLeft - maxOverflow).domain([left * -1, $$.getXDomainMax($$.data.targets) + 1 + right]);
10014 tickOffset = Math.ceil((scale(1) - scale(0)) / 2);
10015 }
10016
10017 return maxOverflow + tickOffset;
10018 }
10019 /**
10020 * Get x Axis padding
10021 * @param {number} tickCount Tick count
10022 * @returns {object} Padding object values with 'left' & 'right' key
10023 * @private
10024 */
10025 , _proto.getXAxisPadding = function getXAxisPadding(tickCount) {
10026 var $$ = this.owner,
10027 padding = $$.config.axis_x_padding;
10028
10029 if (isEmpty(padding) ? padding = {
10030 left: 0,
10031 right: 0
10032 } : (padding.left = padding.left || 0, padding.right = padding.right || 0), $$.axis.isTimeSeries()) {
10033 var firstX = +$$.getXDomainMin($$.data.targets),
10034 lastX = +$$.getXDomainMax($$.data.targets),
10035 timeDiff = lastX - firstX,
10036 range = timeDiff + padding.left + padding.right,
10037 left = 0,
10038 _right = 0;
10039
10040 if (tickCount && range) {
10041 var relativeTickWidth = timeDiff / tickCount / range;
10042 left = padding.left / range / relativeTickWidth, _right = padding.right / range / relativeTickWidth;
10043 }
10044
10045 padding = {
10046 left: left,
10047 right: _right
10048 };
10049 }
10050
10051 return padding;
10052 }, _proto.updateLabels = function updateLabels(withTransition) {
10053 var _this3 = this,
10054 $$ = this.owner,
10055 main = $$.$el.main,
10056 labels = {
10057 x: main.select("." + config_classes.axisX + " ." + config_classes.axisXLabel),
10058 y: main.select("." + config_classes.axisY + " ." + config_classes.axisYLabel),
10059 y2: main.select("." + config_classes.axisY2 + " ." + config_classes.axisY2Label)
10060 };
10061
10062 Object.keys(labels).filter(function (id) {
10063 return !labels[id].empty();
10064 }).forEach(function (v) {
10065 var node = labels[v];
10066 (withTransition ? node.transition() : node).attr("x", function () {
10067 return _this3.xForAxisLabel(v);
10068 }).attr("dx", function () {
10069 return _this3.dxForAxisLabel(v);
10070 }).attr("dy", function () {
10071 return _this3.dyForAxisLabel(v);
10072 }).text(function () {
10073 return _this3.getLabelText(v);
10074 });
10075 });
10076 }, _proto.getPadding = function getPadding(padding, key, defaultValue, domainLength) {
10077 var p = isNumber(padding) ? padding : padding[key];
10078 return isValue(p) ? this.convertPixelsToAxisPadding(p, domainLength) : defaultValue;
10079 }, _proto.convertPixelsToAxisPadding = function convertPixelsToAxisPadding(pixels, domainLength) {
10080 var $$ = this.owner,
10081 config = $$.config,
10082 _$$$state2 = $$.state,
10083 width = _$$$state2.width,
10084 height = _$$$state2.height,
10085 length = config.axis_rotated ? width : height;
10086 return domainLength * (pixels / length);
10087 }, _proto.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) {
10088 var tickValues = values;
10089
10090 if (tickCount) {
10091 var targetCount = isFunction(tickCount) ? tickCount() : tickCount; // compute ticks according to tickCount
10092
10093 if (targetCount === 1) tickValues = [values[0]];else if (targetCount === 2) tickValues = [values[0], values[values.length - 1]];else if (targetCount > 2) {
10094 var tickValue,
10095 isCategorized = this.isCategorized(),
10096 count = targetCount - 2,
10097 start = values[0],
10098 end = values[values.length - 1];
10099 tickValues = [start];
10100
10101 for (var i = 0; i < count; i++) tickValue = +start + (end - start) / (count + 1) * (i + 1), tickValues.push(forTimeSeries ? new Date(tickValue) : isCategorized ? Math.round(tickValue) : tickValue);
10102
10103 tickValues.push(end);
10104 }
10105 }
10106
10107 return forTimeSeries || (tickValues = tickValues.sort(function (a, b) {
10108 return a - b;
10109 })), tickValues;
10110 }, _proto.generateTransitions = function generateTransitions(duration) {
10111 var $$ = this.owner,
10112 axis = $$.$el.axis,
10113 _map = ["x", "y", "y2", "subX"].map(function (v) {
10114 var ax = axis[v];
10115 return ax && duration && (ax = ax.transition().duration(duration)), ax;
10116 }),
10117 axisX = _map[0],
10118 axisY = _map[1],
10119 axisY2 = _map[2],
10120 axisSubX = _map[3];
10121
10122 return {
10123 axisX: axisX,
10124 axisY: axisY,
10125 axisY2: axisY2,
10126 axisSubX: axisSubX
10127 };
10128 }, _proto.redraw = function redraw(transitions, isHidden, isInit) {
10129 var _this4 = this,
10130 $$ = this.owner,
10131 config = $$.config,
10132 $el = $$.$el,
10133 opacity = isHidden ? "0" : "1";
10134
10135 ["x", "y", "y2", "subX"].forEach(function (id) {
10136 var axis = _this4[id],
10137 $axis = $el.axis[id];
10138 axis && $axis && (!isInit && !config.transition_duration && (axis.config.withoutTransition = !0), $axis.style("opacity", opacity), axis.create(transitions["axis" + capitalize(id)]));
10139 }), this.updateAxes();
10140 }
10141 /**
10142 * Redraw axis
10143 * @param {Array} targetsToShow targets data to be shown
10144 * @param {object} wth option object
10145 * @param {d3.Transition} transitions Transition object
10146 * @param {object} flow flow object
10147 * @param {boolean} isInit called from initialization
10148 * @private
10149 */
10150 , _proto.redrawAxis = function redrawAxis(targetsToShow, wth, transitions, flow, isInit) {
10151 var xDomainForZoom,
10152 _this5 = this,
10153 $$ = this.owner,
10154 config = $$.config,
10155 scale = $$.scale,
10156 $el = $$.$el,
10157 hasZoom = !!scale.zoom;
10158
10159 !hasZoom && this.isCategorized() && targetsToShow.length === 0 && scale.x.domain([0, $el.axis.x.selectAll(".tick").size()]), scale.x && targetsToShow.length ? (!hasZoom && $$.updateXDomain(targetsToShow, wth.UpdateXDomain, wth.UpdateOrgXDomain, wth.TrimXDomain), !config.axis_x_tick_values && this.updateXAxisTickValues(targetsToShow)) : this.x && (this.x.tickValues([]), this.subX && this.subX.tickValues([])), config.zoom_rescale && !flow && (xDomainForZoom = scale.x.orgDomain()), ["y", "y2"].forEach(function (key) {
10160 var axisScale = scale[key];
10161
10162 if (axisScale) {
10163 var tickValues = config["axis_" + key + "_tick_values"],
10164 tickCount = config["axis_" + key + "_tick_count"];
10165
10166 if (axisScale.domain($$.getYDomain(targetsToShow, key, xDomainForZoom)), !tickValues && tickCount) {
10167 var _axis = $$.axis[key],
10168 domain = axisScale.domain();
10169
10170 _axis.tickValues(_this5.generateTickValues(domain, domain.every(function (v) {
10171 return v === 0;
10172 }) ? 1 : tickCount, _this5.isTimeSeriesY()));
10173 }
10174 }
10175 }), this.redraw(transitions, $$.hasArcType(), isInit), this.updateLabels(wth.Transition), (wth.UpdateXDomain || wth.UpdateXAxis || wth.Y) && targetsToShow.length && this.setCulling(), wth.Y && (scale.subY && scale.subY.domain($$.getYDomain(targetsToShow, "y")), scale.subY2 && scale.subY2.domain($$.getYDomain(targetsToShow, "y2")));
10176 }
10177 /**
10178 * Set manual culling
10179 * @private
10180 */
10181 , _proto.setCulling = function setCulling() {
10182 var $$ = this.owner,
10183 config = $$.config,
10184 _$$$state3 = $$.state,
10185 clip = _$$$state3.clip,
10186 current = _$$$state3.current,
10187 $el = $$.$el;
10188 ["subX", "x", "y", "y2"].forEach(function (type) {
10189 var axis = $el.axis[type],
10190 id = type === "subX" ? "x" : type,
10191 toCull = config["axis_" + id + "_tick_culling"]; // subchart x axis should be aligned with x axis culling
10192
10193 if (axis && toCull) {
10194 var intervalForCulling,
10195 tickText = axis.selectAll(".tick text"),
10196 tickValues = sortValue(tickText.data()),
10197 tickSize = tickValues.length,
10198 cullingMax = config["axis_" + id + "_tick_culling_max"];
10199
10200 if (tickSize) {
10201 for (var i = 1; i < tickSize; i++) if (tickSize / i < cullingMax) {
10202 intervalForCulling = i;
10203 break;
10204 }
10205
10206 tickText.each(function (d) {
10207 this.style.display = tickValues.indexOf(d) % intervalForCulling ? "none" : "block";
10208 });
10209 } else tickText.style("display", "block"); // set/unset x_axis_tick_clippath
10210
10211
10212 if (type === "x") {
10213 var clipPath = current.maxTickWidths.x.clipPath ? clip.pathXAxisTickTexts : null;
10214 $el.svg.selectAll("." + config_classes.axisX + " .tick text").attr("clip-path", clipPath);
10215 }
10216 }
10217 });
10218 }, Axis;
10219}();
10220;// CONCATENATED MODULE: ./src/ChartInternal/interactions/eventrect.ts
10221/**
10222 * Copyright (c) 2017 ~ present NAVER Corp.
10223 * billboard.js project is licensed under the MIT license
10224 */
10225
10226
10227/* harmony default export */ var eventrect = ({
10228 /**
10229 * Initialize the area that detects the event.
10230 * Add a container for the zone that detects the event.
10231 * @private
10232 */
10233 initEventRect: function initEventRect() {
10234 var $$ = this;
10235 $$.$el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.eventRects).style("fill-opacity", "0");
10236 },
10237
10238 /**
10239 * Redraws the area that detects the event.
10240 * @private
10241 */
10242 redrawEventRect: function redrawEventRect() {
10243 var $$ = this,
10244 config = $$.config,
10245 state = $$.state,
10246 $el = $$.$el,
10247 isMultipleX = $$.isMultipleX();
10248 if ($el.eventRect) $$.updateEventRect($el.eventRect, !0);else {
10249 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),
10250 eventRectUpdate = eventRects.selectAll("." + config_classes.eventRect).data([0]).enter().append("rect"); // append event <rect>
10251
10252 // bind event to <rect> element
10253 // bind draggable selection
10254 $$.updateEventRect(eventRectUpdate), isMultipleX ? $$.generateEventRectsForMultipleXs(eventRectUpdate) : $$.generateEventRectsForSingleX(eventRectUpdate), eventRectUpdate.call($$.getDraggableSelection()), $el.eventRect = eventRectUpdate, $$.state.inputType !== "touch" || $el.svg.on("touchstart.eventRect") || $$.hasArcType() || $$.bindTouchOnEventRect(isMultipleX);
10255 }
10256
10257 if (!isMultipleX) {
10258 // Set data and update eventReceiver.data
10259 var xAxisTickValues = $$.getMaxDataCountTarget(); // update data's index value to be alinged with the x Axis
10260
10261 $$.updateDataIndexByX(xAxisTickValues), $$.updateXs(xAxisTickValues), $$.updatePointClass && $$.updatePointClass(!0), state.eventReceiver.data = xAxisTickValues;
10262 }
10263
10264 $$.updateEventRectData();
10265 },
10266 bindTouchOnEventRect: function bindTouchOnEventRect(isMultipleX) {
10267 var startPx,
10268 $$ = this,
10269 config = $$.config,
10270 state = $$.state,
10271 _$$$$el = $$.$el,
10272 eventRect = _$$$$el.eventRect,
10273 svg = _$$$$el.svg,
10274 selectRect = function (context) {
10275 if (isMultipleX) $$.selectRectForMultipleXs(context);else {
10276 var index = $$.getDataIndexFromEvent(state.event);
10277 $$.callOverOutForTouch(index), index === -1 ? $$.unselectRect() : $$.selectRectForSingle(context, eventRect, index);
10278 }
10279 },
10280 unselectRect = function () {
10281 $$.unselectRect(), $$.callOverOutForTouch();
10282 },
10283 preventDefault = config.interaction_inputType_touch.preventDefault,
10284 isPrevented = isboolean(preventDefault) && preventDefault || !1,
10285 preventThreshold = !isNaN(preventDefault) && preventDefault || null,
10286 preventEvent = function (event) {
10287 var eventType = event.type,
10288 touch = event.changedTouches[0],
10289 currentXY = touch["client" + (config.axis_rotated ? "Y" : "X")];
10290 eventType === "touchstart" ? isPrevented ? event.preventDefault() : preventThreshold !== null && (startPx = currentXY) : eventType === "touchmove" && (isPrevented || startPx === !0 || preventThreshold !== null && Math.abs(startPx - currentXY) >= preventThreshold) && (startPx = !0, event.preventDefault());
10291 };
10292
10293 // bind touch events
10294 eventRect.on("touchstart", function (event) {
10295 state.event = event, $$.updateEventRect();
10296 }).on("touchstart.eventRect touchmove.eventRect", function (event) {
10297 if (state.event = event, !eventRect.empty() && eventRect.classed(config_classes.eventRect)) {
10298 // if touch points are > 1, means doing zooming interaction. In this case do not execute tooltip codes.
10299 if (state.dragging || state.flowing || $$.hasArcType() || event.touches.length > 1) return;
10300 preventEvent(event), selectRect(eventRect.node());
10301 } else unselectRect();
10302 }, !0).on("touchend.eventRect", function (event) {
10303 state.event = event, !eventRect.empty() && eventRect.classed(config_classes.eventRect) && ($$.hasArcType() || !$$.toggleShape || state.cancelClick) && state.cancelClick && (state.cancelClick = !1);
10304 }, !0), svg.on("touchstart", function (event) {
10305 state.event = event;
10306 var target = event.target;
10307 target && target !== eventRect.node() && unselectRect();
10308 });
10309 },
10310
10311 /**
10312 * Update event rect size
10313 * @param {d3Selection} eventRect Event <rect> element
10314 * @param {boolean} force Force to update
10315 * @private
10316 */
10317 updateEventRect: function updateEventRect(eventRect, force) {
10318 force === void 0 && (force = !1);
10319 var $$ = this,
10320 state = $$.state,
10321 $el = $$.$el,
10322 _state = state,
10323 eventReceiver = _state.eventReceiver,
10324 width = _state.width,
10325 height = _state.height,
10326 rendered = _state.rendered,
10327 resizing = _state.resizing,
10328 rectElement = eventRect || $el.eventRect;
10329 (!rendered || resizing || force) && (rectElement.attr("x", 0).attr("y", 0).attr("width", width).attr("height", height), !rendered && rectElement.attr("class", config_classes.eventRect)), function updateClientRect() {
10330 eventReceiver && (eventReceiver.rect = rectElement.node().getBoundingClientRect());
10331 }();
10332 },
10333
10334 /**
10335 * Updates the location and size of the eventRect.
10336 * @private
10337 */
10338 updateEventRectData: function updateEventRectData() {
10339 var x,
10340 y,
10341 w,
10342 h,
10343 $$ = this,
10344 config = $$.config,
10345 scale = $$.scale,
10346 state = $$.state,
10347 xScale = scale.zoom || scale.x,
10348 isRotated = config.axis_rotated;
10349 if ($$.isMultipleX()) // TODO: rotated not supported yet
10350 x = 0, y = 0, w = state.width, h = state.height;else {
10351 var rectW, rectX;
10352 if ($$.axis.isCategorized()) rectW = $$.getEventRectWidth(), rectX = function (d) {
10353 return xScale(d.x) - rectW / 2;
10354 };else {
10355 var getPrevNextX = function (_ref) {
10356 var index = _ref.index;
10357 return {
10358 prev: $$.getPrevX(index),
10359 next: $$.getNextX(index)
10360 };
10361 };
10362
10363 rectW = function (d) {
10364 var x = getPrevNextX(d); // if there this is a single data point make the eventRect full width (or height)
10365
10366 return x.prev === null && x.next === null ? isRotated ? state.height : state.width : (x.prev === null && (x.prev = xScale.domain()[0]), x.next === null && (x.next = xScale.domain()[1]), Math.max(0, (xScale(x.next) - xScale(x.prev)) / 2));
10367 }, rectX = function (d) {
10368 var x = getPrevNextX(d),
10369 thisX = d.x;
10370 // if there this is a single data point position the eventRect at 0
10371 return x.prev === null && x.next === null ? 0 : (x.prev === null && (x.prev = xScale.domain()[0]), (xScale(thisX) + xScale(x.prev)) / 2);
10372 };
10373 }
10374 x = isRotated ? 0 : rectX, y = isRotated ? rectX : 0, w = isRotated ? state.width : rectW, h = isRotated ? rectW : state.height;
10375 }
10376
10377 var eventReceiver = state.eventReceiver,
10378 call = function (fn, v) {
10379 return isFunction(fn) ? fn(v) : fn;
10380 };
10381
10382 // reset for possible remains coords data before the data loading
10383 eventReceiver.coords.splice(eventReceiver.data.length), eventReceiver.data.forEach(function (d, i) {
10384 eventReceiver.coords[i] = {
10385 x: call(x, d),
10386 y: call(y, d),
10387 w: call(w, d),
10388 h: call(h, d)
10389 };
10390 });
10391 },
10392 selectRectForMultipleXs: function selectRectForMultipleXs(context) {
10393 var $$ = this,
10394 config = $$.config,
10395 state = $$.state,
10396 targetsToShow = $$.filterTargetsToShow($$.data.targets);
10397
10398 // do nothing when dragging
10399 if (!(state.dragging || $$.hasArcType(targetsToShow))) {
10400 var mouse = getPointer(state.event, context),
10401 closest = $$.findClosestFromTargets(targetsToShow, mouse);
10402 if (state.mouseover && (!closest || closest.id !== state.mouseover.id) && (config.data_onout.call($$.api, state.mouseover), state.mouseover = undefined), !closest) return void $$.unselectRect();
10403 var sameXData = $$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped ? [closest] : $$.filterByX(targetsToShow, closest.x),
10404 selectedData = sameXData.map(function (d) {
10405 return $$.addName(d);
10406 }); // show tooltip when cursor is close to some point
10407
10408 $$.showTooltip(selectedData, context), $$.expandCirclesBars(closest.index, closest.id, !0), $$.showGridFocus(selectedData), ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) && ($$.$el.svg.select("." + config_classes.eventRect).style("cursor", "pointer"), !state.mouseover && (config.data_onover.call($$.api, closest), state.mouseover = closest));
10409 }
10410 },
10411
10412 /**
10413 * Unselect EventRect.
10414 * @private
10415 */
10416 unselectRect: function unselectRect() {
10417 var $$ = this,
10418 config = $$.config,
10419 _$$$$el2 = $$.$el,
10420 bar = _$$$$el2.bar,
10421 circle = _$$$$el2.circle,
10422 tooltip = _$$$$el2.tooltip;
10423 $$.$el.svg.select("." + config_classes.eventRect).style("cursor", null), $$.hideGridFocus(), tooltip && ($$.hideTooltip(), $$._handleLinkedCharts(!1)), circle && !config.point_focus_only && $$.unexpandCircles(), bar && $$.unexpandBars();
10424 },
10425
10426 /**
10427 * Create eventRect for each data on the x-axis.
10428 * Register touch and drag events.
10429 * @param {object} eventRectEnter d3.select(CLASS.eventRects) object.
10430 * @returns {object} d3.select(CLASS.eventRects) object.
10431 * @private
10432 */
10433 generateEventRectsForSingleX: function generateEventRectsForSingleX(eventRectEnter) {
10434 var $$ = this,
10435 config = $$.config,
10436 state = $$.state,
10437 eventReceiver = state.eventReceiver,
10438 rect = eventRectEnter.style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null).on("click", function (event) {
10439 state.event = event;
10440 var _eventReceiver = eventReceiver,
10441 currentIdx = _eventReceiver.currentIdx,
10442 data = _eventReceiver.data,
10443 d = data[currentIdx === -1 ? $$.getDataIndexFromEvent(event) : currentIdx];
10444 $$.clickHandlerForSingleX.bind(this)(d, $$);
10445 });
10446
10447 if (state.inputType === "mouse") {
10448 var getData = function (event) {
10449 var index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
10450 return index > -1 ? eventReceiver.data[index] : null;
10451 };
10452
10453 rect.on("mouseover", function (event) {
10454 state.event = event, $$.updateEventRect();
10455 }).on("mousemove", function (event) {
10456 var d = getData(event);
10457
10458 // do nothing while dragging/flowing
10459 if (state.event = event, !(state.dragging || state.flowing || $$.hasArcType() || !d || config.tooltip_grouped && d && d.index === eventReceiver.currentIdx)) {
10460 var index = d.index;
10461 $$.isStepType(d) && config.line_step_type === "step-after" && getPointer(event, this)[0] < $$.scale.x($$.getXValue(d.id, index)) && (index -= 1), index !== eventReceiver.currentIdx && ($$.setOverOut(!1, eventReceiver.currentIdx), eventReceiver.currentIdx = index), index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, rect, index), $$.setOverOut(index !== -1, index);
10462 }
10463 }).on("mouseout", function (event) {
10464 state.event = event;
10465 // chart is destroyed
10466 !config || $$.hasArcType() || eventReceiver.currentIdx === -1 || ( // reset the event current index
10467 $$.unselectRect(), $$.setOverOut(!1, eventReceiver.currentIdx), eventReceiver.currentIdx = -1);
10468 });
10469 }
10470
10471 return rect;
10472 },
10473 clickHandlerForSingleX: function clickHandlerForSingleX(d, ctx) {
10474 var $$ = ctx,
10475 config = $$.config,
10476 state = $$.state,
10477 main = $$.$el.main;
10478 if (!d || $$.hasArcType() || state.cancelClick) return void (state.cancelClick && (state.cancelClick = !1));
10479 var index = d.index;
10480 main.selectAll("." + config_classes.shape + "-" + index).each(function (d2) {
10481 (config.data_selection_grouped || $$.isWithinShape(this, d2)) && ($$.toggleShape && $$.toggleShape(this, d2, index), config.data_onclick.bind($$.api)(d2, this));
10482 });
10483 },
10484
10485 /**
10486 * Create an eventRect,
10487 * Register touch and drag events.
10488 * @param {object} eventRectEnter d3.select(CLASS.eventRects) object.
10489 * @private
10490 */
10491 generateEventRectsForMultipleXs: function generateEventRectsForMultipleXs(eventRectEnter) {
10492 var $$ = this,
10493 state = $$.state;
10494 eventRectEnter.on("click", function (event) {
10495 state.event = event, $$.clickHandlerForMultipleXS.bind(this)($$);
10496 }), state.inputType === "mouse" && eventRectEnter.on("mouseover mousemove", function (event) {
10497 state.event = event, $$.selectRectForMultipleXs(this);
10498 }).on("mouseout", function (event) {
10499 state.event = event;
10500 // chart is destroyed
10501 !$$.config || $$.hasArcType() || $$.unselectRect();
10502 });
10503 },
10504 clickHandlerForMultipleXS: function clickHandlerForMultipleXS(ctx) {
10505 var $$ = ctx,
10506 config = $$.config,
10507 state = $$.state,
10508 targetsToShow = $$.filterTargetsToShow($$.data.targets);
10509
10510 if (!$$.hasArcType(targetsToShow)) {
10511 var mouse = getPointer(state.event, this),
10512 closest = $$.findClosestFromTargets(targetsToShow, mouse);
10513 !closest || ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) && $$.$el.main.selectAll("." + config_classes.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll("." + config_classes.shape + "-" + closest.index).each(function () {
10514 (config.data_selection_grouped || $$.isWithinShape(this, closest)) && ($$.toggleShape && $$.toggleShape(this, closest, closest.index), config.data_onclick.bind($$.api)(closest, this));
10515 });
10516 } // select if selection enabled
10517
10518 }
10519});
10520// EXTERNAL MODULE: external {"commonjs":"d3-ease","commonjs2":"d3-ease","amd":"d3-ease","root":"d3"}
10521var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack_require__(11);
10522;// CONCATENATED MODULE: ./src/ChartInternal/interactions/flow.ts
10523/**
10524 * Copyright (c) 2017 ~ present NAVER Corp.
10525 * billboard.js project is licensed under the MIT license
10526 */
10527
10528
10529
10530
10531/* harmony default export */ var interactions_flow = ({
10532 /**
10533 * Generate flow
10534 * @param {object} args option object
10535 * @returns {Function}
10536 * @private
10537 */
10538 generateFlow: function generateFlow(args) {
10539 var $$ = this,
10540 data = $$.data,
10541 state = $$.state,
10542 $el = $$.$el;
10543 return function () {
10544 var flowLength = args.flow.length; // set flag
10545
10546 state.flowing = !0, data.targets.forEach(function (d) {
10547 d.values.splice(0, flowLength);
10548 }), $$.updateXGrid && $$.updateXGrid(!0);
10549 // target elements
10550 var elements = {};
10551 ["axis.x", "grid.x", "gridLines.x", "region.list", "text", "bar", "line", "area", "circle"].forEach(function (v) {
10552 var name = v.split("."),
10553 node = $el[name[0]];
10554 node && name.length > 1 && (node = node[name[1]]), node && node.size() && (elements[v] = node);
10555 }), $$.hideGridFocus(), $$.setFlowList(elements, args);
10556 };
10557 },
10558
10559 /**
10560 * Set flow list
10561 * @param {object} elements Target elements
10562 * @param {object} args option object
10563 * @private
10564 */
10565 setFlowList: function setFlowList(elements, args) {
10566 var n,
10567 $$ = this,
10568 flow = args.flow,
10569 targets = args.targets,
10570 _flow = flow,
10571 _flow$duration = _flow.duration,
10572 duration = _flow$duration === void 0 ? args.duration : _flow$duration,
10573 flowIndex = _flow.index,
10574 flowLength = _flow.length,
10575 orgDataCount = _flow.orgDataCount,
10576 transform = $$.getFlowTransform(targets, orgDataCount, flowIndex, flowLength),
10577 wait = generateWait();
10578 wait.add(Object.keys(elements).map(function (v) {
10579 return n = elements[v].transition().ease(external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_.easeLinear).duration(duration), n = v === "axis.x" ? n.call(function (g) {
10580 $$.axis.x.setTransition(g).create(g);
10581 }) : v === "region.list" ? n.filter($$.isRegionOnX).attr("transform", transform) : n.attr("transform", transform), n;
10582 })), n.call(wait, function () {
10583 $$.cleanUpFlow(elements, args);
10584 });
10585 },
10586
10587 /**
10588 * Clean up flow
10589 * @param {object} elements Target elements
10590 * @param {object} args option object
10591 * @private
10592 */
10593 cleanUpFlow: function cleanUpFlow(elements, args) {
10594 var $$ = this,
10595 config = $$.config,
10596 state = $$.state,
10597 svg = $$.$el.svg,
10598 isRotated = config.axis_rotated,
10599 flow = args.flow,
10600 shape = args.shape,
10601 xv = args.xv,
10602 _shape$pos = shape.pos,
10603 cx = _shape$pos.cx,
10604 cy = _shape$pos.cy,
10605 xForText = _shape$pos.xForText,
10606 yForText = _shape$pos.yForText,
10607 _flow2 = flow,
10608 _flow2$done = _flow2.done,
10609 done = _flow2$done === void 0 ? function () {} : _flow2$done,
10610 flowLength = _flow2.length;
10611 // draw again for removing flowed elements and reverting attr
10612 // callback for end of flow
10613 flowLength && (["circle", "text", "shape", "eventRect"].forEach(function (v) {
10614 var target = [];
10615
10616 for (var i = 0; i < flowLength; i++) target.push("." + config_classes[v] + "-" + i);
10617
10618 svg.selectAll("." + config_classes[v + "s"]) // circles, shapes, texts, eventRects
10619 .selectAll(target).remove();
10620 }), svg.select("." + config_classes.xgrid).remove()), Object.keys(elements).forEach(function (v) {
10621 var n = elements[v];
10622 if (v !== "axis.x" && n.attr("transform", null), v === "grid.x") n.attr(state.xgridAttr);else if (v === "gridLines.x") n.attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);else if (v === "gridLines.x") n.select("line").attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv), n.select("text").attr("x", isRotated ? state.width : 0).attr("y", xv);else if (/^(area|bar|line)$/.test(v)) n.attr("d", shape.type[v]);else if (v === "text") n.attr("x", xForText).attr("y", yForText).style("fill-opacity", $$.opacityForText.bind($$));else if (v !== "circle") v === "region.list" && n.select("rect").filter($$.isRegionOnX).attr("x", $$.regionX.bind($$)).attr("width", $$.regionWidth.bind($$));else if ($$.isCirclePoint()) n.attr("cx", cx).attr("cy", cy);else {
10623 var xFunc = function (d) {
10624 return cx(d) - config.point_r;
10625 },
10626 yFunc = function (d) {
10627 return cy(d) - config.point_r;
10628 };
10629
10630 n.attr("x", xFunc).attr("y", yFunc).attr("cx", cx) // when pattern is used, it possibly contain 'circle' also.
10631 .attr("cy", cy);
10632 }
10633 }), config.interaction_enabled && $$.redrawEventRect(), done.call($$.api), state.flowing = !1;
10634 },
10635
10636 /**
10637 * Get flow transform value
10638 * @param {object} targets target
10639 * @param {number} orgDataCount original data count
10640 * @param {number} flowIndex flow index
10641 * @param {number} flowLength flow length
10642 * @returns {string}
10643 * @private
10644 */
10645 getFlowTransform: function getFlowTransform(targets, orgDataCount, flowIndex, flowLength) {
10646 var translateX,
10647 $$ = this,
10648 data = $$.data,
10649 x = $$.scale.x,
10650 dataValues = data.targets[0].values,
10651 flowStart = $$.getValueOnIndex(dataValues, flowIndex),
10652 flowEnd = $$.getValueOnIndex(dataValues, flowIndex + flowLength),
10653 orgDomain = x.domain(),
10654 domain = $$.updateXDomain(targets, !0, !0);
10655 orgDataCount ? orgDataCount === 1 || (flowStart && flowStart.x) === (flowEnd && flowEnd.x) ? translateX = x(orgDomain[0]) - x(domain[0]) : translateX = $$.axis.isTimeSeries() ? x(orgDomain[0]) - x(domain[0]) : x(flowStart.x) - x(flowEnd.x) : dataValues.length === 1 ? $$.axis.isTimeSeries() ? (flowStart = $$.getValueOnIndex(dataValues, 0), flowEnd = $$.getValueOnIndex(dataValues, dataValues.length - 1), translateX = x(flowStart.x) - x(flowEnd.x)) : translateX = diffDomain(domain) / 2 : translateX = x(orgDomain[0]) - x(domain[0]);
10656 var scaleX = diffDomain(orgDomain) / diffDomain(domain);
10657 return "translate(" + translateX + ",0) scale(" + scaleX + ",1)";
10658 }
10659});
10660;// CONCATENATED MODULE: ./src/ChartInternal/internals/clip.ts
10661/**
10662 * Copyright (c) 2017 ~ present NAVER Corp.
10663 * billboard.js project is licensed under the MIT license
10664 */
10665
10666/* harmony default export */ var clip = ({
10667 initClip: function initClip() {
10668 var $$ = this,
10669 clip = $$.state.clip;
10670 // MEMO: clipId needs to be unique because it conflicts when multiple charts exist
10671 // Define 'clip-path' attribute values
10672 clip.id = $$.state.datetimeId + "-clip", clip.idXAxis = clip.id + "-xaxis", clip.idYAxis = clip.id + "-yaxis", clip.idGrid = clip.id + "-grid", clip.path = $$.getClipPath(clip.id), clip.pathXAxis = $$.getClipPath(clip.idXAxis), clip.pathYAxis = $$.getClipPath(clip.idYAxis), clip.pathGrid = $$.getClipPath(clip.idGrid);
10673 },
10674 getClipPath: function getClipPath(id) {
10675 var $$ = this,
10676 config = $$.config;
10677 if (!config.clipPath && /-clip$/.test(id) || !config.axis_x_clipPath && /-clip-xaxis$/.test(id) || !config.axis_y_clipPath && /-clip-yaxis$/.test(id)) return null;
10678 var isIE9 = !!win.navigator && win.navigator.appVersion.toLowerCase().indexOf("msie 9.") >= 0;
10679 return "url(" + (isIE9 ? "" : browser_doc.URL.split("#")[0]) + "#" + id + ")";
10680 },
10681 appendClip: function appendClip(parent, id) {
10682 id && parent.append("clipPath").attr("id", id).append("rect");
10683 },
10684
10685 /**
10686 * Set x Axis clipPath dimension
10687 * @param {d3Selecton} node clipPath <rect> selection
10688 * @private
10689 */
10690 setXAxisClipPath: function setXAxisClipPath(node) {
10691 var $$ = this,
10692 config = $$.config,
10693 _$$$state = $$.state,
10694 margin = _$$$state.margin,
10695 width = _$$$state.width,
10696 height = _$$$state.height,
10697 isRotated = config.axis_rotated,
10698 left = Math.max(30, margin.left) - (isRotated ? 0 : 20),
10699 x = isRotated ? -(1 + left) : -(left - 1),
10700 y = -Math.max(15, margin.top),
10701 w = isRotated ? margin.left + 20 : width + 10 + left,
10702 h = (isRotated ? margin.top + height + 10 : margin.bottom) + 20;
10703 node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
10704 },
10705
10706 /**
10707 * Set y Axis clipPath dimension
10708 * @param {d3Selecton} node clipPath <rect> selection
10709 * @private
10710 */
10711 setYAxisClipPath: function setYAxisClipPath(node) {
10712 var $$ = this,
10713 config = $$.config,
10714 _$$$state2 = $$.state,
10715 margin = _$$$state2.margin,
10716 width = _$$$state2.width,
10717 height = _$$$state2.height,
10718 isRotated = config.axis_rotated,
10719 left = Math.max(30, margin.left) - (isRotated ? 20 : 0),
10720 isInner = config.axis_y_inner,
10721 x = isInner ? -1 : isRotated ? -(1 + left) : -(left - 1),
10722 y = -(isRotated ? 20 : margin.top),
10723 w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0),
10724 h = (isRotated ? margin.bottom : margin.top + height) + 10;
10725 node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
10726 },
10727 updateXAxisTickClip: function updateXAxisTickClip() {
10728 var $$ = this,
10729 config = $$.config,
10730 _$$$state3 = $$.state,
10731 clip = _$$$state3.clip,
10732 xAxisHeight = _$$$state3.xAxisHeight,
10733 defs = $$.$el.defs,
10734 newXAxisHeight = $$.getHorizontalAxisHeight("x");
10735
10736 if (defs && !clip.idXAxisTickTexts) {
10737 var clipId = clip.id + "-xaxisticktexts";
10738 $$.appendClip(defs, clipId), clip.pathXAxisTickTexts = $$.getClipPath(clip.idXAxisTickTexts), clip.idXAxisTickTexts = clipId;
10739 }
10740
10741 !config.axis_x_tick_multiline && $$.getAxisTickRotate("x") && newXAxisHeight !== xAxisHeight && ($$.setXAxisTickClipWidth(), $$.setXAxisTickTextClipPathWidth()), $$.state.xAxisHeight = newXAxisHeight;
10742 },
10743 setXAxisTickClipWidth: function setXAxisTickClipWidth() {
10744 var $$ = this,
10745 config = $$.config,
10746 maxTickWidths = $$.state.current.maxTickWidths,
10747 xAxisTickRotate = $$.getAxisTickRotate("x");
10748
10749 if (!config.axis_x_tick_multiline && xAxisTickRotate) {
10750 var sinRotation = Math.sin(Math.PI / 180 * Math.abs(xAxisTickRotate));
10751 maxTickWidths.x.clipPath = ($$.getHorizontalAxisHeight("x") - 20) / sinRotation;
10752 } else maxTickWidths.x.clipPath = null;
10753 },
10754 setXAxisTickTextClipPathWidth: function setXAxisTickTextClipPathWidth() {
10755 var $$ = this,
10756 _$$$state4 = $$.state,
10757 clip = _$$$state4.clip,
10758 current = _$$$state4.current,
10759 svg = $$.$el.svg;
10760 svg && svg.select("#" + clip.idXAxisTickTexts + " rect").attr("width", current.maxTickWidths.x.clipPath).attr("height", 30);
10761 }
10762});
10763;// CONCATENATED MODULE: ./src/ChartInternal/internals/grid.ts
10764/**
10765 * Copyright (c) 2017 ~ present NAVER Corp.
10766 * billboard.js project is licensed under the MIT license
10767 */
10768
10769
10770 // Grid position and text anchor helpers
10771
10772var getGridTextAnchor = function (d) {
10773 return isValue(d.position) || "end";
10774},
10775 getGridTextDx = function (d) {
10776 return d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
10777};
10778
10779/**
10780 * Get grid text x value getter function
10781 * @param {boolean} isX Is x Axis
10782 * @param {number} width Width value
10783 * @param {number} height Height value
10784 * @returns {Function}
10785 * @private
10786 */
10787function getGridTextX(isX, width, height) {
10788 return function (d) {
10789 var x = isX ? 0 : width;
10790 return d.position === "start" ? x = isX ? -height : 0 : d.position === "middle" && (x = (isX ? -height : width) / 2), x;
10791 };
10792}
10793/**
10794 * Update coordinate attributes value
10795 * @param {d3.selection} el Target node
10796 * @param {string} type Type
10797 * @private
10798 */
10799
10800
10801function smoothLines(el, type) {
10802 type === "grid" && el.each(function () {
10803 var g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
10804 ["x1", "x2", "y1", "y2"].forEach(function (v) {
10805 return g.attr(v, Math.ceil(+g.attr(v)));
10806 });
10807 });
10808}
10809
10810/* harmony default export */ var grid = ({
10811 hasGrid: function hasGrid() {
10812 var config = this.config;
10813 return ["x", "y"].some(function (v) {
10814 return config["grid_" + v + "_show"] || config["grid_" + v + "_lines"].length;
10815 });
10816 },
10817 initGrid: function initGrid() {
10818 var $$ = this;
10819 $$.hasGrid() && $$.initGridLines(), $$.initFocusGrid();
10820 },
10821 initGridLines: function initGridLines() {
10822 var $$ = this,
10823 config = $$.config,
10824 clip = $$.state.clip,
10825 $el = $$.$el;
10826 (config.grid_x_lines.length || config.grid_y_lines.length) && ($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), $el.gridLines.main.append("g").attr("class", config_classes.xgridLines), $el.gridLines.main.append("g").attr("class", config_classes.ygridLines), $el.gridLines.x = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([]));
10827 },
10828 updateXGrid: function updateXGrid(withoutUpdate) {
10829 var $$ = this,
10830 config = $$.config,
10831 scale = $$.scale,
10832 state = $$.state,
10833 _$$$$el = $$.$el,
10834 main = _$$$$el.main,
10835 grid = _$$$$el.grid,
10836 isRotated = config.axis_rotated,
10837 xgridData = $$.generateGridData(config.grid_x_type, scale.x),
10838 tickOffset = $$.axis.isCategorized() ? $$.axis.x.tickOffset() : 0,
10839 pos = function (d) {
10840 return (scale.zoom || scale.x)(d) + tickOffset * (isRotated ? -1 : 1);
10841 };
10842
10843 state.xgridAttr = isRotated ? {
10844 "x1": 0,
10845 "x2": state.width,
10846 "y1": pos,
10847 "y2": pos
10848 } : {
10849 "x1": pos,
10850 "x2": pos,
10851 "y1": 0,
10852 "y2": state.height
10853 }, grid.x = main.select("." + config_classes.xgrids).selectAll("." + config_classes.xgrid).data(xgridData), grid.x.exit().remove(), grid.x = grid.x.enter().append("line").attr("class", config_classes.xgrid).merge(grid.x), withoutUpdate || grid.x.each(function () {
10854 var grid = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
10855 Object.keys(state.xgridAttr).forEach(function (id) {
10856 grid.attr(id, state.xgridAttr[id]).style("opacity", function () {
10857 return grid.attr(isRotated ? "y1" : "x1") === (isRotated ? state.height : 0) ? "0" : "1";
10858 });
10859 });
10860 });
10861 },
10862 updateYGrid: function updateYGrid() {
10863 var $$ = this,
10864 config = $$.config,
10865 state = $$.state,
10866 _$$$$el2 = $$.$el,
10867 grid = _$$$$el2.grid,
10868 main = _$$$$el2.main,
10869 isRotated = config.axis_rotated,
10870 gridValues = $$.axis.y.tickValues() || $$.scale.y.ticks(config.grid_y_ticks),
10871 pos = function (d) {
10872 return Math.ceil($$.scale.y(d));
10873 };
10874
10875 grid.y = main.select("." + config_classes.ygrids).selectAll("." + config_classes.ygrid).data(gridValues), grid.y.exit().remove(), grid.y = grid.y.enter().append("line").attr("class", config_classes.ygrid).merge(grid.y), grid.y.attr("x1", isRotated ? pos : 0).attr("x2", isRotated ? pos : state.width).attr("y1", isRotated ? 0 : pos).attr("y2", isRotated ? state.height : pos), smoothLines(grid.y, "grid");
10876 },
10877 updateGrid: function updateGrid(duration) {
10878 var $$ = this,
10879 _$$$$el3 = $$.$el,
10880 grid = _$$$$el3.grid,
10881 gridLines = _$$$$el3.gridLines;
10882 // hide if arc type
10883 gridLines.main || $$.initGridLines(), grid.main.style("visibility", $$.hasArcType() ? "hidden" : "visible"), $$.hideGridFocus(), $$.updateXGridLines(duration), $$.updateYGridLines(duration);
10884 },
10885
10886 /**
10887 * Update X Grid lines
10888 * @param {number} duration Dration value
10889 * @private
10890 */
10891 updateXGridLines: function updateXGridLines(duration) {
10892 var $$ = this,
10893 config = $$.config,
10894 _$$$$el4 = $$.$el,
10895 gridLines = _$$$$el4.gridLines,
10896 main = _$$$$el4.main,
10897 isRotated = config.axis_rotated;
10898 config.grid_x_show && $$.updateXGrid();
10899 var xLines = main.select("." + config_classes.xgridLines).selectAll("." + config_classes.xgridLine).data(config.grid_x_lines); // exit
10900
10901 xLines.exit().transition().duration(duration).style("opacity", "0").remove();
10902 // enter
10903 var xgridLine = xLines.enter().append("g");
10904 xgridLine.append("line").style("opacity", "0"), xgridLine.append("text").attr("transform", isRotated ? "" : "rotate(-90)").attr("dy", -5).style("opacity", "0"), xLines = xgridLine.merge(xLines), xLines.attr("class", function (d) {
10905 return (config_classes.xgridLine + " " + (d.class || "")).trim();
10906 }).select("text").attr("text-anchor", getGridTextAnchor).attr("dx", getGridTextDx).transition().duration(duration).text(function (d) {
10907 return d.text;
10908 }).transition().style("opacity", "1"), gridLines.x = xLines;
10909 },
10910
10911 /**
10912 * Update Y Grid lines
10913 * @param {number} duration Duration value
10914 * @private
10915 */
10916 updateYGridLines: function updateYGridLines(duration) {
10917 var $$ = this,
10918 config = $$.config,
10919 _$$$state = $$.state,
10920 width = _$$$state.width,
10921 height = _$$$state.height,
10922 $el = $$.$el,
10923 isRotated = config.axis_rotated;
10924 config.grid_y_show && $$.updateYGrid();
10925 var ygridLines = $el.main.select("." + config_classes.ygridLines).selectAll("." + config_classes.ygridLine).data(config.grid_y_lines); // exit
10926
10927 ygridLines.exit().transition().duration(duration).style("opacity", "0").remove();
10928 // enter
10929 var ygridLine = ygridLines.enter().append("g");
10930 ygridLine.append("line").style("opacity", "0"), ygridLine.append("text").attr("transform", isRotated ? "rotate(-90)" : "").style("opacity", "0"), ygridLines = ygridLine.merge(ygridLines);
10931 // update
10932 var yv = $$.yv.bind($$);
10933 ygridLines.attr("class", function (d) {
10934 return (config_classes.ygridLine + " " + (d.class || "")).trim();
10935 }).select("line").transition().duration(duration).attr("x1", isRotated ? yv : 0).attr("x2", isRotated ? yv : width).attr("y1", isRotated ? 0 : yv).attr("y2", isRotated ? height : yv).transition().style("opacity", "1"), ygridLines.select("text").attr("text-anchor", getGridTextAnchor).attr("dx", getGridTextDx).transition().duration(duration).attr("dy", -5).attr("x", getGridTextX(isRotated, width, height)).attr("y", yv).text(function (d) {
10936 return d.text;
10937 }).transition().style("opacity", "1"), $el.gridLines.y = ygridLines;
10938 },
10939 redrawGrid: function redrawGrid(withTransition) {
10940 var $$ = this,
10941 isRotated = $$.config.axis_rotated,
10942 _$$$state2 = $$.state,
10943 width = _$$$state2.width,
10944 height = _$$$state2.height,
10945 gridLines = $$.$el.gridLines,
10946 xv = $$.xv.bind($$),
10947 lines = gridLines.x.select("line"),
10948 texts = gridLines.x.select("text");
10949 return lines = (withTransition ? lines.transition() : lines).attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? width : xv).attr("y1", isRotated ? xv : 0).attr("y2", isRotated ? xv : height), texts = (withTransition ? texts.transition() : texts).attr("x", getGridTextX(!isRotated, width, height)).attr("y", xv).text(function (d) {
10950 return d.text;
10951 }), [lines.style("opacity", "1"), texts.style("opacity", "1")];
10952 },
10953 initFocusGrid: function initFocusGrid() {
10954 var $$ = this,
10955 config = $$.config,
10956 clip = $$.state.clip,
10957 $el = $$.$el,
10958 isFront = config.grid_front,
10959 className = "." + config_classes[isFront && $el.gridLines.main ? "gridLines" : "chart"] + (isFront ? " + *" : ""),
10960 grid = $el.main.insert("g", className).attr("clip-path", clip.pathGrid).attr("class", config_classes.grid);
10961 $el.grid.main = grid, config.grid_x_show && grid.append("g").attr("class", config_classes.xgrids), config.grid_y_show && grid.append("g").attr("class", config_classes.ygrids), config.interaction_enabled && config.grid_focus_show && (grid.append("g").attr("class", config_classes.xgridFocus).append("line").attr("class", config_classes.xgridFocus), config.grid_focus_y && !config.tooltip_grouped && grid.append("g").attr("class", config_classes.ygridFocus).append("line").attr("class", config_classes.ygridFocus));
10962 },
10963
10964 /**
10965 * Show grid focus line
10966 * @param {Array} data Selected data
10967 * @private
10968 */
10969 showGridFocus: function showGridFocus(data) {
10970 var $$ = this,
10971 config = $$.config,
10972 _$$$state3 = $$.state,
10973 width = _$$$state3.width,
10974 height = _$$$state3.height,
10975 isRotated = config.axis_rotated,
10976 focusEl = $$.$el.main.selectAll("line." + config_classes.xgridFocus + ", line." + config_classes.ygridFocus),
10977 dataToShow = (data || [focusEl.datum()]).filter(function (d) {
10978 return d && isValue($$.getBaseValue(d));
10979 });
10980
10981 // Hide when bubble/scatter/stanford plot exists
10982 if (!(!config.tooltip_show || dataToShow.length === 0 || $$.hasType("bubble") || $$.hasArcType())) {
10983 var isEdge = config.grid_focus_edge && !config.tooltip_grouped,
10984 xx = $$.xx.bind($$);
10985 focusEl.style("visibility", "visible").data(dataToShow.concat(dataToShow)).each(function (d) {
10986 var xy,
10987 el = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
10988 pos = {
10989 x: xx(d),
10990 y: $$.getYScaleById(d.id)(d.value)
10991 };
10992 if (el.classed(config_classes.xgridFocus)) xy = isRotated ? [null, // x1
10993 pos.x, // y1
10994 isEdge ? pos.y : width, // x2
10995 pos.x // y2
10996 ] : [pos.x, isEdge ? pos.y : null, pos.x, height];else {
10997 var isY2 = $$.axis.getId(d.id) === "y2";
10998 xy = isRotated ? [pos.y, // x1
10999 isEdge && !isY2 ? pos.x : null, // y1
11000 pos.y, // x2
11001 isEdge && isY2 ? pos.x : height // y2
11002 ] : [isEdge && isY2 ? pos.x : null, pos.y, isEdge && !isY2 ? pos.x : width, pos.y];
11003 }
11004 ["x1", "y1", "x2", "y2"].forEach(function (v, i) {
11005 return el.attr(v, xy[i]);
11006 });
11007 }), smoothLines(focusEl, "grid"), $$.showCircleFocus && $$.showCircleFocus(data);
11008 }
11009 },
11010 hideGridFocus: function hideGridFocus() {
11011 var $$ = this,
11012 _$$$state4 = $$.state,
11013 inputType = _$$$state4.inputType,
11014 resizing = _$$$state4.resizing,
11015 main = $$.$el.main;
11016 inputType !== "mouse" && resizing || (main.selectAll("line." + config_classes.xgridFocus + ", line." + config_classes.ygridFocus).style("visibility", "hidden"), $$.hideCircleFocus && $$.hideCircleFocus());
11017 },
11018 updateGridFocus: function updateGridFocus() {
11019 var $$ = this,
11020 _$$$state5 = $$.state,
11021 inputType = _$$$state5.inputType,
11022 width = _$$$state5.width,
11023 height = _$$$state5.height,
11024 resizing = _$$$state5.resizing,
11025 grid = $$.$el.grid,
11026 xgridFocus = grid.main.select("line." + config_classes.xgridFocus);
11027 if (inputType === "touch") xgridFocus.empty() ? resizing && $$.showCircleFocus() : $$.showGridFocus();else {
11028 var _isRotated = $$.config.axis_rotated;
11029 xgridFocus.attr("x1", _isRotated ? 0 : -10).attr("x2", _isRotated ? width : -10).attr("y1", _isRotated ? -10 : 0).attr("y2", _isRotated ? -10 : height);
11030 } // need to return 'true' as of being pushed to the redraw list
11031 // ref: getRedrawList()
11032
11033 return !0;
11034 },
11035 generateGridData: function generateGridData(type, scale) {
11036 var $$ = this,
11037 tickNum = $$.$el.main.select("." + config_classes.axisX).selectAll(".tick").size(),
11038 gridData = [];
11039
11040 if (type === "year") {
11041 var xDomain = $$.getXDomain(),
11042 firstYear = xDomain[0].getFullYear(),
11043 lastYear = xDomain[1].getFullYear();
11044
11045 for (var i = firstYear; i <= lastYear; i++) gridData.push(new Date(i + "-01-01 00:00:00"));
11046 } else gridData = scale.ticks(10), gridData.length > tickNum && (gridData = gridData.filter(function (d) {
11047 return (d + "").indexOf(".") < 0;
11048 }));
11049
11050 return gridData;
11051 },
11052 getGridFilterToRemove: function getGridFilterToRemove(params) {
11053 return params ? function (line) {
11054 var found = !1;
11055 return (isArray(params) ? params.concat() : [params]).forEach(function (param) {
11056 ("value" in param && line.value === param.value || "class" in param && line.class === param.class) && (found = !0);
11057 }), found;
11058 } : function () {
11059 return !0;
11060 };
11061 },
11062 removeGridLines: function removeGridLines(params, forX) {
11063 var $$ = this,
11064 config = $$.config,
11065 toRemove = $$.getGridFilterToRemove(params),
11066 classLines = forX ? config_classes.xgridLines : config_classes.ygridLines,
11067 classLine = forX ? config_classes.xgridLine : config_classes.ygridLine;
11068 $$.$el.main.select("." + classLines).selectAll("." + classLine).filter(toRemove).transition().duration(config.transition_duration).style("opacity", "0").remove();
11069 var gridLines = "grid_" + (forX ? "x" : "y") + "_lines";
11070 config[gridLines] = config[gridLines].filter(function toShow(line) {
11071 return !toRemove(line);
11072 });
11073 }
11074});
11075;// CONCATENATED MODULE: ./src/ChartInternal/internals/region.ts
11076/**
11077 * Copyright (c) 2017 ~ present NAVER Corp.
11078 * billboard.js project is licensed under the MIT license
11079 */
11080 // selection
11081
11082
11083
11084/* harmony default export */ var region = ({
11085 initRegion: function initRegion() {
11086 var $$ = this,
11087 $el = $$.$el;
11088 $el.region.main = $el.main.append("g").attr("clip-path", $$.state.clip.path).attr("class", config_classes.regions);
11089 },
11090 updateRegion: function updateRegion(duration) {
11091 var $$ = this,
11092 config = $$.config,
11093 $el = $$.$el;
11094 $el.region.main || $$.initRegion(), $el.region.main.style("visibility", $$.hasArcType() ? "hidden" : "visible");
11095 // select <g> element
11096 var list = $el.main.select("." + config_classes.regions).selectAll("." + config_classes.region).data(config.regions);
11097 list.exit().transition().duration(duration).style("opacity", "0").remove(), list = list.enter().append("g").merge(list).attr("class", $$.classRegion.bind($$)), list.append("rect").style("fill-opacity", "0"), $el.region.list = list;
11098 },
11099 redrawRegion: function redrawRegion(withTransition) {
11100 var $$ = this,
11101 regions = $$.$el.region.list.select("rect");
11102 return regions = (withTransition ? regions.transition() : regions).attr("x", $$.regionX.bind($$)).attr("y", $$.regionY.bind($$)).attr("width", $$.regionWidth.bind($$)).attr("height", $$.regionHeight.bind($$)), [(withTransition ? regions.transition() : regions).style("fill-opacity", function (d) {
11103 return isValue(d.opacity) ? d.opacity : "0.1";
11104 }).on("end", function () {
11105 (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode).selectAll("rect:not([x])").remove();
11106 })];
11107 },
11108 getRegionXY: function getRegionXY(type, d) {
11109 var currScale,
11110 $$ = this,
11111 config = $$.config,
11112 scale = $$.scale,
11113 isRotated = config.axis_rotated,
11114 isX = type === "x",
11115 key = "start",
11116 pos = 0;
11117 return d.axis === "y" || d.axis === "y2" ? (!isX && (key = "end"), (isX ? isRotated : !isRotated) && key in d && (currScale = scale[d.axis], pos = currScale(d[key]))) : (isX ? !isRotated : isRotated) && key in d && (currScale = scale.zoom || scale.x, pos = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key])), pos;
11118 },
11119 regionX: function regionX(d) {
11120 return this.getRegionXY("x", d);
11121 },
11122 regionY: function regionY(d) {
11123 return this.getRegionXY("y", d);
11124 },
11125 getRegionSize: function getRegionSize(type, d) {
11126 var currScale,
11127 $$ = this,
11128 config = $$.config,
11129 scale = $$.scale,
11130 state = $$.state,
11131 isRotated = config.axis_rotated,
11132 isWidth = type === "width",
11133 start = $$[isWidth ? "regionX" : "regionY"](d),
11134 key = "end",
11135 end = state[type];
11136 return d.axis === "y" || d.axis === "y2" ? (!isWidth && (key = "start"), (isWidth ? isRotated : !isRotated) && key in d && (currScale = scale[d.axis], end = currScale(d[key]))) : (isWidth ? !isRotated : isRotated) && key in d && (currScale = scale.zoom || scale.x, end = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key])), end < start ? 0 : end - start;
11137 },
11138 regionWidth: function regionWidth(d) {
11139 return this.getRegionSize("width", d);
11140 },
11141 regionHeight: function regionHeight(d) {
11142 return this.getRegionSize("height", d);
11143 },
11144 isRegionOnX: function isRegionOnX(d) {
11145 return !d.axis || d.axis === "x";
11146 }
11147});
11148;// CONCATENATED MODULE: ./src/ChartInternal/internals/size.axis.ts
11149/**
11150 * Copyright (c) 2017 ~ present NAVER Corp.
11151 * billboard.js project is licensed under the MIT license
11152 */
11153/* harmony default export */ var size_axis = ({
11154 /**
11155 * Get Axis size according its position
11156 * @param {string} id Axis id value - x, y or y2
11157 * @returns {number} size Axis size value
11158 * @private
11159 */
11160 getAxisSize: function getAxisSize(id) {
11161 var $$ = this,
11162 isRotated = $$.config.axis_rotated;
11163 return isRotated && id === "x" || !isRotated && /y2?/.test(id) ? $$.getAxisWidthByAxisId(id, !0) : $$.getHorizontalAxisHeight(id);
11164 },
11165 getAxisWidthByAxisId: function getAxisWidthByAxisId(id, withoutRecompute) {
11166 var $$ = this;
11167
11168 if ($$.axis) {
11169 var position = $$.axis && $$.axis.getLabelPositionById(id);
11170 return $$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40);
11171 }
11172
11173 return 40;
11174 },
11175 getHorizontalAxisHeight: function getHorizontalAxisHeight(id) {
11176 var $$ = this,
11177 config = $$.config,
11178 state = $$.state,
11179 _state = state,
11180 current = _state.current,
11181 rotatedPadding = _state.rotatedPadding,
11182 isLegendRight = _state.isLegendRight,
11183 isLegendInset = _state.isLegendInset,
11184 isRotated = config.axis_rotated,
11185 h = 30;
11186 if (id === "x" && !config.axis_x_show) return 8;
11187 if (id === "x" && config.axis_x_height) return config.axis_x_height;
11188 if (id === "y" && !config.axis_y_show) return !config.legend_show || isLegendRight || isLegendInset ? 1 : 10;
11189 if (id === "y2" && !config.axis_y2_show) return rotatedPadding.top;
11190 var rotate = $$.getAxisTickRotate(id); // Calculate x/y axis height when tick rotated
11191
11192 return (id === "x" && !isRotated || /y2?/.test(id) && isRotated) && rotate && (h = 30 + $$.axis.getMaxTickWidth(id) * Math.cos(Math.PI * (90 - Math.abs(rotate)) / 180), !config.axis_x_tick_multiline && current.height && h > current.height / 2 && (h = current.height / 2)), h + ($$.axis.getLabelPositionById(id).isInner ? 0 : 10) + (id !== "y2" || isRotated ? 0 : -10);
11193 },
11194 getEventRectWidth: function getEventRectWidth() {
11195 return Math.max(0, this.axis.x.tickInterval());
11196 },
11197
11198 /**
11199 * Get axis tick test rotate value
11200 * @param {string} id Axis id
11201 * @returns {number} rotate value
11202 * @private
11203 */
11204 getAxisTickRotate: function getAxisTickRotate(id) {
11205 var $$ = this,
11206 axis = $$.axis,
11207 config = $$.config,
11208 state = $$.state,
11209 $el = $$.$el,
11210 rotate = config["axis_" + id + "_tick_rotate"];
11211
11212 if (id === "x") {
11213 var allowedXAxisTypes = axis.isCategorized() || axis.isTimeSeries();
11214
11215 if (config.axis_x_tick_fit && allowedXAxisTypes) {
11216 var xTickCount = config.axis_x_tick_count,
11217 currentXTicksLength = state.current.maxTickWidths.x.ticks.length,
11218 tickCount = 0;
11219 xTickCount ? tickCount = xTickCount > currentXTicksLength ? currentXTicksLength : xTickCount : currentXTicksLength && (tickCount = currentXTicksLength), tickCount !== state.axis.x.tickCount && (state.axis.x.padding = $$.axis.getXAxisPadding(tickCount)), state.axis.x.tickCount = tickCount;
11220 }
11221
11222 $el.svg && config.axis_x_tick_fit && !config.axis_x_tick_multiline && !config.axis_x_tick_culling && config.axis_x_tick_autorotate && allowedXAxisTypes && (rotate = $$.needToRotateXAxisTickTexts() ? config.axis_x_tick_rotate : 0);
11223 }
11224
11225 return rotate;
11226 },
11227
11228 /**
11229 * Check weather axis tick text needs to be rotated
11230 * @returns {boolean}
11231 * @private
11232 */
11233 needToRotateXAxisTickTexts: function needToRotateXAxisTickTexts() {
11234 var $$ = this,
11235 _$$$state = $$.state,
11236 axis = _$$$state.axis,
11237 current = _$$$state.current,
11238 xAxisLength = current.width - $$.getCurrentPaddingLeft(!1) - $$.getCurrentPaddingRight(),
11239 tickCountWithPadding = axis.x.tickCount + axis.x.padding.left + axis.x.padding.right,
11240 maxTickWidth = $$.axis.getMaxTickWidth("x"),
11241 tickLength = tickCountWithPadding ? xAxisLength / tickCountWithPadding : 0;
11242 return maxTickWidth > tickLength;
11243 }
11244});
11245;// CONCATENATED MODULE: ./src/config/Options/data/axis.ts
11246/**
11247 * Copyright (c) 2017 ~ present NAVER Corp.
11248 * billboard.js project is licensed under the MIT license
11249 */
11250
11251/**
11252 * Axis based chart data config options
11253 */
11254/* harmony default export */ var data_axis = ({
11255 /**
11256 * Specify the keys of the x values for each data.<br><br>
11257 * This option can be used if we want to show the data that has different x values.
11258 * @name data․xs
11259 * @memberof Options
11260 * @type {object}
11261 * @default {}
11262 * @example
11263 * data: {
11264 * xs: {
11265 * data1: "x1",
11266 * data2: "x2"
11267 * }
11268 * }
11269 */
11270 data_xs: {},
11271
11272 /**
11273 * Set a format specifier to parse string specifed as x.
11274 * @name data․xFormat
11275 * @memberof Options
11276 * @type {string}
11277 * @default %Y-%m-%d
11278 * @example
11279 * data: {
11280 * x: "x",
11281 * columns: [
11282 * ["x", "01012019", "02012019", "03012019"],
11283 * ["data1", 30, 200, 100]
11284 * ],
11285 * // Format specifier to parse as datetime for given 'x' string value
11286 * xFormat: "%m%d%Y"
11287 * },
11288 * axis: {
11289 * x: {
11290 * type: "timeseries"
11291 * }
11292 * }
11293 * @see [D3's time specifier](https://github.com/d3/d3-time-format#locale_format)
11294 */
11295 data_xFormat: "%Y-%m-%d",
11296
11297 /**
11298 * Set localtime format to parse x axis.
11299 * @name data․xLocaltime
11300 * @memberof Options
11301 * @type {boolean}
11302 * @default true
11303 * @example
11304 * data: {
11305 * xLocaltime: false
11306 * }
11307 */
11308 data_xLocaltime: !0,
11309
11310 /**
11311 * Sort on x axis.
11312 * @name data․xSort
11313 * @memberof Options
11314 * @type {boolean}
11315 * @default true
11316 * @example
11317 * data: {
11318 * xSort: false
11319 * }
11320 */
11321 data_xSort: !0,
11322
11323 /**
11324 * Set y axis the data related to. y and y2 can be used.
11325 * - **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
11326 * @name data․axes
11327 * @memberof Options
11328 * @type {object}
11329 * @default {}
11330 * @example
11331 * data: {
11332 * axes: {
11333 * data1: "y",
11334 * data2: "y2"
11335 * }
11336 * }
11337 */
11338 data_axes: {},
11339
11340 /**
11341 * Define regions for each data.<br>
11342 * The values must be an array for each data and it should include an object that has `start`, `end` and `style`.
11343 * - The object type should be as:
11344 * - start {number}: Start data point number. If not set, the start will be the first data point.
11345 * - [end] {number}: End data point number. If not set, the end will be the last data point.
11346 * - [style.dasharray="2 2"] {object}: The first number specifies a distance for the filled area, and the second a distance for the unfilled area.
11347 * - **NOTE:** Currently this option supports only line chart and dashed style. If this option specified, the line will be dashed only in the regions.
11348 * @name data․regions
11349 * @memberof Options
11350 * @type {object}
11351 * @default {}
11352 * @example
11353 * data: {
11354 * regions: {
11355 * data1: [{
11356 * start: 1,
11357 * end: 2,
11358 * style: {
11359 * dasharray: "5 2"
11360 * }
11361 * }, {
11362 * start: 3
11363 * }],
11364 * ...
11365 * }
11366 * }
11367 */
11368 data_regions: {},
11369
11370 /**
11371 * Set the stacking to be normalized
11372 * - **NOTE:**
11373 * - For stacking, '[data.groups](#.data%25E2%2580%25A4groups)' option should be set
11374 * - y Axis will be set in percentage value (0 ~ 100%)
11375 * - Must have postive values
11376 * @name data․stack․normalize
11377 * @memberof Options
11378 * @type {boolean}
11379 * @default false
11380 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
11381 * @example
11382 * data: {
11383 * stack: {
11384 * normalize: true
11385 * }
11386 * }
11387 */
11388 data_stack_normalize: !1
11389});
11390;// CONCATENATED MODULE: ./src/config/Options/axis/x.ts
11391/**
11392 * Copyright (c) 2017 ~ present NAVER Corp.
11393 * billboard.js project is licensed under the MIT license
11394 */
11395
11396/**
11397 * x Axis config options
11398 */
11399/* harmony default export */ var axis_x = ({
11400 /**
11401 * Set clip-path attribute for x axis element
11402 * @name axis․x․clipPath
11403 * @memberof Options
11404 * @type {boolean}
11405 * @default true
11406 * @see [Demo]()
11407 * @example
11408 * // don't set 'clip-path' attribute
11409 * clipPath: false
11410 */
11411 axis_x_clipPath: !0,
11412
11413 /**
11414 * Show or hide x axis.
11415 * @name axis․x․show
11416 * @memberof Options
11417 * @type {boolean}
11418 * @default true
11419 * @example
11420 * axis: {
11421 * x: {
11422 * show: false
11423 * }
11424 * }
11425 */
11426 axis_x_show: !0,
11427
11428 /**
11429 * Set type of x axis.<br><br>
11430 * **Available Values:**
11431 * - category
11432 * - indexed
11433 * - log
11434 * - timeseries
11435 *
11436 * **NOTE:**<br>
11437 * - **log** type:
11438 * - the x values specified by [`data.x`](#.data%25E2%2580%25A4x)(or by any equivalent option), must be exclusively-positive.
11439 * - x axis min value should be >= 0.
11440 *
11441 * @name axis․x․type
11442 * @memberof Options
11443 * @type {string}
11444 * @default indexed
11445 * @see [Demo: indexed](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
11446 * @see [Demo: timeseries](https://naver.github.io/billboard.js/demo/#Chart.TimeseriesChart)
11447 * @see [Demo: category](https://naver.github.io/billboard.js/demo/#Data.CategoryData)
11448 * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
11449 * @example
11450 * axis: {
11451 * x: {
11452 * type: "timeseries"
11453 * }
11454 * }
11455 */
11456 axis_x_type: "indexed",
11457
11458 /**
11459 * Set how to treat the timezone of x values.<br>
11460 * If true, treat x value as localtime. If false, convert to UTC internally.
11461 * @name axis․x․localtime
11462 * @memberof Options
11463 * @type {boolean}
11464 * @default true
11465 * @example
11466 * axis: {
11467 * x: {
11468 * localtime: false
11469 * }
11470 * }
11471 */
11472 axis_x_localtime: !0,
11473
11474 /**
11475 * Set category names on category axis.
11476 * 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.
11477 * @name axis․x․categories
11478 * @memberof Options
11479 * @type {Array}
11480 * @default []
11481 * @example
11482 * axis: {
11483 * x: {
11484 * categories: ["Category 1", "Category 2", ...]
11485 * }
11486 * }
11487 */
11488 axis_x_categories: [],
11489
11490 /**
11491 * centerize ticks on category axis.
11492 * @name axis․x․tick․centered
11493 * @memberof Options
11494 * @type {boolean}
11495 * @default false
11496 * @example
11497 * axis: {
11498 * x: {
11499 * tick: {
11500 * centered: true
11501 * }
11502 * }
11503 * }
11504 */
11505 axis_x_tick_centered: !1,
11506
11507 /**
11508 * A function to format tick value. Format string is also available for timeseries data.
11509 * @name axis․x․tick․format
11510 * @memberof Options
11511 * @type {Function|string}
11512 * @default undefined
11513 * @see [D3's time specifier](https://github.com/d3/d3-time-format#locale_format)
11514 * @example
11515 * axis: {
11516 * x: {
11517 * tick: {
11518 * // for timeseries, a 'datetime' object is given as parameter
11519 * format: function(x) {
11520 * return x.getFullYear();
11521 * }
11522 *
11523 * // for category, index(Number) and categoryName(String) are given as parameter
11524 * format: function(index, categoryName) {
11525 * return categoryName.substr(0, 10);
11526 * },
11527 *
11528 * // for timeseries format specifier
11529 * format: "%Y-%m-%d %H:%M:%S"
11530 * }
11531 * }
11532 * }
11533 */
11534 axis_x_tick_format: undefined,
11535
11536 /**
11537 * Setting for culling ticks.<br><br>
11538 * 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>
11539 * We can change the number of ticks to be shown by axis.x.tick.culling.max.
11540 * @name axis․x․tick․culling
11541 * @memberof Options
11542 * @type {boolean}
11543 * @default
11544 * - true for indexed axis and timeseries axis
11545 * - false for category axis
11546 * @example
11547 * axis: {
11548 * x: {
11549 * tick: {
11550 * culling: false
11551 * }
11552 * }
11553 * }
11554 */
11555 axis_x_tick_culling: {},
11556
11557 /**
11558 * The number of tick texts will be adjusted to less than this value.
11559 * @name axis․x․tick․culling․max
11560 * @memberof Options
11561 * @type {number}
11562 * @default 10
11563 * @example
11564 * axis: {
11565 * x: {
11566 * tick: {
11567 * culling: {
11568 * max: 5
11569 * }
11570 * }
11571 * }
11572 * }
11573 */
11574 axis_x_tick_culling_max: 10,
11575
11576 /**
11577 * The number of x axis ticks to show.<br><br>
11578 * 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).
11579 * @name axis․x․tick․count
11580 * @memberof Options
11581 * @type {number}
11582 * @default undefined
11583 * @example
11584 * axis: {
11585 * x: {
11586 * tick: {
11587 * count: 5
11588 * }
11589 * }
11590 * }
11591 */
11592 axis_x_tick_count: undefined,
11593
11594 /**
11595 * Show or hide x axis tick line.
11596 * @name axis․x․tick․show
11597 * @memberof Options
11598 * @type {boolean}
11599 * @default true
11600 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
11601 * @example
11602 * axis: {
11603 * x: {
11604 * tick: {
11605 * show: false
11606 * }
11607 * }
11608 * }
11609 */
11610 axis_x_tick_show: !0,
11611
11612 /**
11613 * Show or hide x axis tick text.
11614 * @name axis․x․tick․text․show
11615 * @memberof Options
11616 * @type {boolean}
11617 * @default true
11618 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
11619 * @example
11620 * axis: {
11621 * x: {
11622 * tick: {
11623 * text: {
11624 * show: false
11625 * }
11626 * }
11627 * }
11628 * }
11629 */
11630 axis_x_tick_text_show: !0,
11631
11632 /**
11633 * Set the x Axis tick text's position relatively its original position
11634 * @name axis․x․tick․text․position
11635 * @memberof Options
11636 * @type {object}
11637 * @default {x: 0, y:0}
11638 * @example
11639 * axis: {
11640 * x: {
11641 * tick: {
11642 * text: {
11643 * position: {
11644 * x: 10,
11645 * y: 10
11646 * }
11647 * }
11648 * }
11649 * }
11650 * }
11651 */
11652 axis_x_tick_text_position: {
11653 x: 0,
11654 y: 0
11655 },
11656
11657 /**
11658 * Fit x axis ticks.
11659 * - **true**: ticks will be positioned nicely to have same intervals.
11660 * - **false**: ticks will be positioned according to x value of the data points.
11661 * @name axis․x․tick․fit
11662 * @memberof Options
11663 * @type {boolean}
11664 * @default true
11665 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickFitting)
11666 * @see [Demo: for timeseries zoom](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickTimeseries)
11667 * @example
11668 * axis: {
11669 * x: {
11670 * tick: {
11671 * fit: false
11672 * }
11673 * }
11674 * }
11675 */
11676 axis_x_tick_fit: !0,
11677
11678 /**
11679 * Set the x values of ticks manually.<br><br>
11680 * If this option is provided, the position of the ticks will be determined based on those values.<br>
11681 * This option works with `timeseries` data and the x values will be parsed accoding to the type of the value and data.xFormat option.
11682 * @name axis․x․tick․values
11683 * @memberof Options
11684 * @type {Array|Function}
11685 * @default null
11686 * @example
11687 * axis: {
11688 * x: {
11689 * tick: {
11690 * values: [1, 2, 4, 8, 16, 32, ...],
11691 *
11692 * // an Array value should be returned
11693 * values: function() {
11694 * return [ ... ];
11695 * }
11696 * }
11697 * }
11698 * }
11699 */
11700 axis_x_tick_values: null,
11701
11702 /**
11703 * Rotate x axis tick text if there is not enough space for 'category' and 'timeseries' type axis.
11704 * - **NOTE:** The conditions where `autorotate` is enabled are:
11705 * - axis.x.type='category' or 'timeseries
11706 * - axis.x.tick.multiline=false
11707 * - axis.x.tick.culling=false
11708 * - axis.x.tick.fit=true
11709 * - **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
11710 * @name axis․x․tick․autorotate
11711 * @memberof Options
11712 * @type {boolean}
11713 * @default false
11714 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickAutorotate)
11715 * @example
11716 * axis: {
11717 * x: {
11718 * tick: {
11719 * rotate: 15,
11720 * autorotate: true,
11721 * multiline: false,
11722 * culling: false,
11723 * fit: true
11724 * },
11725 * clipPath: false
11726 * }
11727 * }
11728 */
11729 axis_x_tick_autorotate: !1,
11730
11731 /**
11732 * Rotate x axis tick text.
11733 * - If you set negative value, it will rotate to opposite direction.
11734 * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `false`.
11735 * - 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.
11736 * @name axis․x․tick․rotate
11737 * @memberof Options
11738 * @type {number}
11739 * @default 0
11740 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.RotateXAxisTickText)
11741 * @example
11742 * axis: {
11743 * x: {
11744 * tick: {
11745 * rotate: 60
11746 * }
11747 * }
11748 * }
11749 */
11750 axis_x_tick_rotate: 0,
11751
11752 /**
11753 * Show x axis outer tick.
11754 * @name axis․x․tick․outer
11755 * @memberof Options
11756 * @type {boolean}
11757 * @default true
11758 * @example
11759 * axis: {
11760 * x: {
11761 * tick: {
11762 * outer: false
11763 * }
11764 * }
11765 * }
11766 */
11767 axis_x_tick_outer: !0,
11768
11769 /**
11770 * Set tick text to be multiline
11771 * - **NOTE:**
11772 * > When x tick text contains `\n`, it's used as line break and 'axis.x.tick.width' option is ignored.
11773 * @name axis․x․tick․multiline
11774 * @memberof Options
11775 * @type {boolean}
11776 * @default true
11777 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickMultiline)
11778 * @example
11779 * axis: {
11780 * x: {
11781 * tick: {
11782 * multiline: false
11783 * }
11784 * }
11785 * }
11786 * @example
11787 * // example of line break with '\n'
11788 * // In this case, 'axis.x.tick.width' is ignored
11789 * data: {
11790 * x: "x",
11791 * columns: [
11792 * ["x", "long\ntext", "Another\nLong\nText"],
11793 * ...
11794 * ],
11795 * }
11796 */
11797 axis_x_tick_multiline: !0,
11798
11799 /**
11800 * Set tick width
11801 * - **NOTE:**
11802 * > When x tick text contains `\n`, this option is ignored.
11803 * @name axis․x․tick․width
11804 * @memberof Options
11805 * @type {number}
11806 * @default null
11807 * @example
11808 * axis: {
11809 * x: {
11810 * tick: {
11811 * width: 50
11812 * }
11813 * }
11814 * }
11815 */
11816 axis_x_tick_width: null,
11817
11818 /**
11819 * Set to display system tooltip(via 'title' attribute) for tick text
11820 * - **NOTE:** Only available for category axis type (`axis.x.type='category'`)
11821 * @name axis․x․tick․tooltip
11822 * @memberof Options
11823 * @type {boolean}
11824 * @default false
11825 * @example
11826 * axis: {
11827 * x: {
11828 * tick: {
11829 * tooltip: true
11830 * }
11831 * }
11832 * }
11833 */
11834 axis_x_tick_tooltip: !1,
11835
11836 /**
11837 * Set max value of x axis range.
11838 * @name axis․x․max
11839 * @memberof Options
11840 * @property {number} max Set the max value
11841 * @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.
11842 * - **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`.
11843 * @property {number} [max.value] Set the max value
11844 * @example
11845 * axis: {
11846 * x: {
11847 * max: 100,
11848 *
11849 * max: {
11850 * // 'fit=true' will make x axis max to be limited as the bound data value max when 'max.value' is greater.
11851 * // - when bound data max is '10' and max.value: '100' ==> x axis max will be '10'
11852 * // - when bound data max is '1000' and max.value: '100' ==> x axis max will be '100'
11853 * fit: true,
11854 * value: 100
11855 * }
11856 * }
11857 * }
11858 */
11859 axis_x_max: undefined,
11860
11861 /**
11862 * Set min value of x axis range.
11863 * @name axis․x․min
11864 * @memberof Options
11865 * @property {number} min Set the min value
11866 * @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.
11867 * - **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`.
11868 * @property {number} [min.value] Set the min value
11869 * @example
11870 * axis: {
11871 * x: {
11872 * min: -100,
11873 *
11874 * min: {
11875 * // 'fit=true' will make x axis min to be limited as the bound data value min when 'min.value' is lower.
11876 * // - when bound data min is '-10' and min.value: '-100' ==> x axis min will be '-10'
11877 * // - when bound data min is '-1000' and min.value: '-100' ==> x axis min will be '-100'
11878 * fit: true,
11879 * value: -100
11880 * }
11881 * }
11882 * }
11883 */
11884 axis_x_min: undefined,
11885
11886 /**
11887 * Set padding for x axis.<br><br>
11888 * If this option is set, the range of x axis will increase/decrease according to the values.
11889 * If no padding is needed in the rage of x axis, 0 should be set.
11890 * - **NOTE:**
11891 * The padding values aren't based on pixels. It differs according axis types<br>
11892 * - **category:** The unit of tick value
11893 * ex. the given value `1`, is same as the width of 1 tick width
11894 * - **timeseries:** Numeric time value
11895 * 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
11896 * @name axis․x․padding
11897 * @memberof Options
11898 * @type {object|number}
11899 * @default {}
11900 * @example
11901 * axis: {
11902 * x: {
11903 * padding: {
11904 * // when axis type is 'category'
11905 * left: 1, // set left padding width of equivalent value of a tick's width
11906 * right: 0.5 // set right padding width as half of equivalent value of tick's width
11907 *
11908 * // when axis type is 'timeseries'
11909 * left: 1000*60*60*24, // set left padding width of equivalent value of a day tick's width
11910 * right: 1000*60*60*12 // set right padding width as half of equivalent value of a day tick's width
11911 * },
11912 *
11913 * // or set both values at once.
11914 * padding: 10
11915 * }
11916 * }
11917 */
11918 axis_x_padding: {},
11919
11920 /**
11921 * Set height of x axis.<br><br>
11922 * 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.
11923 * @name axis․x․height
11924 * @memberof Options
11925 * @type {number}
11926 * @default undefined
11927 * @example
11928 * axis: {
11929 * x: {
11930 * height: 20
11931 * }
11932 * }
11933 */
11934 axis_x_height: undefined,
11935
11936 /**
11937 * Set default extent for subchart and zoom. This can be an array or function that returns an array.
11938 * @name axis․x․extent
11939 * @memberof Options
11940 * @type {Array|Function}
11941 * @default undefined
11942 * @example
11943 * axis: {
11944 * x: {
11945 * // extent range as a pixel value
11946 * extent: [0, 200],
11947 *
11948 * // when axis is 'timeseries', parsable datetime string
11949 * extent: ["2019-03-01", "2019-03-05"],
11950 *
11951 * // return extent value
11952 * extent: function(domain, scale) {
11953 * var extent = domain.map(function(v) {
11954 * return scale(v);
11955 * });
11956 *
11957 * // it should return a format of array
11958 * // ex) [0, 584]
11959 * return extent;
11960 * }
11961 * }
11962 * }
11963 */
11964 axis_x_extent: undefined,
11965
11966 /**
11967 * Set label on x axis.<br><br>
11968 * You can set x axis label and change its position by this option.
11969 * `string` and `object` can be passed and we can change the poisiton by passing object that has position key.<br>
11970 * Available position differs according to the axis direction (vertical or horizontal).
11971 * If string set, the position will be the default.
11972 *
11973 * - **If it's horizontal axis:**
11974 * - inner-right [default]
11975 * - inner-center
11976 * - inner-left
11977 * - outer-right
11978 * - outer-center
11979 * - outer-left
11980 * - **If it's vertical axis:**
11981 * - inner-top [default]
11982 * - inner-middle
11983 * - inner-bottom
11984 * - outer-top
11985 * - outer-middle
11986 * - outer-bottom
11987 * @name axis․x․label
11988 * @memberof Options
11989 * @type {string|object}
11990 * @default undefined
11991 * @example
11992 * axis: {
11993 * x: {
11994 * label: "Your X Axis"
11995 * }
11996 * }
11997 *
11998 * axis: {
11999 * x: {
12000 * label: {
12001 * text: "Your X Axis",
12002 * position: "outer-center"
12003 * }
12004 * }
12005 * }
12006 */
12007 axis_x_label: {},
12008
12009 /**
12010 * Set additional axes for x Axis.
12011 * - **NOTE:** Axis' scale is based on x Axis value if domain option isn't set.
12012 *
12013 * Each axis object should consist with following options:
12014 *
12015 * | Name | Type | Default | Description |
12016 * | --- | --- | --- | --- |
12017 * | domain | Array | - | Set the domain value |
12018 * | tick.outer | boolean | true | Show outer tick |
12019 * | tick.format | Function | - | Set formatter for tick text |
12020 * | tick.count | Number | - | Set the number of y axis ticks |
12021 * | tick.values | Array | - | Set tick values manually |
12022 * @name axis․x․axes
12023 * @memberof Options
12024 * @type {Array}
12025 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
12026 * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
12027 * @example
12028 * x: {
12029 * axes: [
12030 * {
12031 * // if set, will not be correlated with the main x Axis domain value
12032 * domain: [0, 1000],
12033 * tick: {
12034 * outer: false,
12035 * format: function(x) {
12036 * return x + "%";
12037 * },
12038 * count: 2,
12039 * values: [10, 20, 30]
12040 * }
12041 * },
12042 * ...
12043 * ]
12044 * }
12045 */
12046 axis_x_axes: []
12047});
12048;// CONCATENATED MODULE: ./src/config/Options/axis/y.ts
12049/**
12050 * Copyright (c) 2017 ~ present NAVER Corp.
12051 * billboard.js project is licensed under the MIT license
12052 */
12053
12054/**
12055 * y Axis config options
12056 */
12057/* harmony default export */ var y = ({
12058 /**
12059 * Set clip-path attribute for y axis element
12060 * - **NOTE**: `clip-path` attribute for y Axis is set only when `axis.y.inner` option is true.
12061 * @name axis․y․clipPath
12062 * @memberof Options
12063 * @type {boolean}
12064 * @default true
12065 * @example
12066 * // don't set 'clip-path' attribute
12067 * clipPath: false
12068 */
12069 axis_y_clipPath: !0,
12070
12071 /**
12072 * Show or hide y axis.
12073 * @name axis․y․show
12074 * @memberof Options
12075 * @type {boolean}
12076 * @default true
12077 * @example
12078 * axis: {
12079 * y: {
12080 * show: false
12081 * }
12082 * }
12083 */
12084 axis_y_show: !0,
12085
12086 /**
12087 * Set type of y axis.<br><br>
12088 * **Available Values:**
12089 * - indexed
12090 * - log
12091 * - timeseries
12092 *
12093 * **NOTE:**<br>
12094 * - **log** type:
12095 * - the bound data values must be exclusively-positive.
12096 * - y axis min value should be >= 0.
12097 * - [`data.groups`](#.data%25E2%2580%25A4groups)(stacked data) option aren't supported.
12098 *
12099 * @name axis․y․type
12100 * @memberof Options
12101 * @type {string}
12102 * @default "indexed"
12103 * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
12104 * @example
12105 * axis: {
12106 * y: {
12107 * type: "log"
12108 * }
12109 * }
12110 */
12111 axis_y_type: "indexed",
12112
12113 /**
12114 * Set max value of y axis.
12115 * - **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).
12116 * @name axis․y․max
12117 * @memberof Options
12118 * @type {number}
12119 * @default undefined
12120 * @example
12121 * axis: {
12122 * y: {
12123 * max: 1000
12124 * }
12125 * }
12126 */
12127 axis_y_max: undefined,
12128
12129 /**
12130 * Set min value of y axis.
12131 * - **NOTE:**
12132 * 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).
12133 * @name axis․y․min
12134 * @memberof Options
12135 * @type {number}
12136 * @default undefined
12137 * @example
12138 * axis: {
12139 * y: {
12140 * min: 1000
12141 * }
12142 * }
12143 */
12144 axis_y_min: undefined,
12145
12146 /**
12147 * Change the direction of y axis.<br><br>
12148 * If true set, the direction will be from the top to the bottom.
12149 * @name axis․y․inverted
12150 * @memberof Options
12151 * @type {boolean}
12152 * @default false
12153 * @example
12154 * axis: {
12155 * y: {
12156 * inverted: true
12157 * }
12158 * }
12159 */
12160 axis_y_inverted: !1,
12161
12162 /**
12163 * Set center value of y axis.
12164 * @name axis․y․center
12165 * @memberof Options
12166 * @type {number}
12167 * @default undefined
12168 * @example
12169 * axis: {
12170 * y: {
12171 * center: 0
12172 * }
12173 * }
12174 */
12175 axis_y_center: undefined,
12176
12177 /**
12178 * Show y axis inside of the chart.
12179 * @name axis․y․inner
12180 * @memberof Options
12181 * @type {boolean}
12182 * @default false
12183 * @example
12184 * axis: {
12185 * y: {
12186 * inner: true
12187 * }
12188 * }
12189 */
12190 axis_y_inner: !1,
12191
12192 /**
12193 * Set label on y axis.<br><br>
12194 * 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).
12195 * @name axis․y․label
12196 * @memberof Options
12197 * @type {string|object}
12198 * @default {}
12199 * @see [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label) for position string value.
12200 * @example
12201 * axis: {
12202 * y: {
12203 * label: "Your Y Axis"
12204 * }
12205 * }
12206 *
12207 * axis: {
12208 * y: {
12209 * label: {
12210 * text: "Your Y Axis",
12211 * position: "outer-middle"
12212 * }
12213 * }
12214 * }
12215 */
12216 axis_y_label: {},
12217
12218 /**
12219 * Set formatter for y axis tick text.<br><br>
12220 * This option accepts d3.format object as well as a function you define.
12221 * @name axis․y․tick․format
12222 * @memberof Options
12223 * @type {Function}
12224 * @default undefined
12225 * @example
12226 * axis: {
12227 * y: {
12228 * tick: {
12229 * format: function(x) {
12230 * return x.getFullYear();
12231 * }
12232 * }
12233 * }
12234 * }
12235 */
12236 axis_y_tick_format: undefined,
12237
12238 /**
12239 * Setting for culling ticks.<br><br>
12240 * 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>
12241 * We can change the number of ticks to be shown by axis.y.tick.culling.max.
12242 * @name axis․y․tick․culling
12243 * @memberof Options
12244 * @type {boolean}
12245 * @default false
12246 * @example
12247 * axis: {
12248 * y: {
12249 * tick: {
12250 * culling: false
12251 * }
12252 * }
12253 * }
12254 */
12255 axis_y_tick_culling: !1,
12256
12257 /**
12258 * The number of tick texts will be adjusted to less than this value.
12259 * @name axis․y․tick․culling․max
12260 * @memberof Options
12261 * @type {number}
12262 * @default 5
12263 * @example
12264 * axis: {
12265 * y: {
12266 * tick: {
12267 * culling: {
12268 * max: 5
12269 * }
12270 * }
12271 * }
12272 * }
12273 */
12274 axis_y_tick_culling_max: 5,
12275
12276 /**
12277 * Show y axis outer tick.
12278 * @name axis․y․tick․outer
12279 * @memberof Options
12280 * @type {boolean}
12281 * @default true
12282 * @example
12283 * axis: {
12284 * y: {
12285 * tick: {
12286 * outer: false
12287 * }
12288 * }
12289 * }
12290 */
12291 axis_y_tick_outer: !0,
12292
12293 /**
12294 * Set y axis tick values manually.
12295 * @name axis․y․tick․values
12296 * @memberof Options
12297 * @type {Array|Function}
12298 * @default null
12299 * @example
12300 * axis: {
12301 * y: {
12302 * tick: {
12303 * values: [100, 1000, 10000],
12304 *
12305 * // an Array value should be returned
12306 * values: function() {
12307 * return [ ... ];
12308 * }
12309 * }
12310 * }
12311 * }
12312 */
12313 axis_y_tick_values: null,
12314
12315 /**
12316 * Rotate y axis tick text.
12317 * - If you set negative value, it will rotate to opposite direction.
12318 * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `true`.
12319 * @name axis․y․tick․rotate
12320 * @memberof Options
12321 * @type {number}
12322 * @default 0
12323 * @example
12324 * axis: {
12325 * y: {
12326 * tick: {
12327 * rotate: 60
12328 * }
12329 * }
12330 * }
12331 */
12332 axis_y_tick_rotate: 0,
12333
12334 /**
12335 * Set the number of y axis ticks.<br><br>
12336 * - **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.
12337 * @name axis․y․tick․count
12338 * @memberof Options
12339 * @type {number}
12340 * @default undefined
12341 * @example
12342 * axis: {
12343 * y: {
12344 * tick: {
12345 * count: 5
12346 * }
12347 * }
12348 * }
12349 */
12350 axis_y_tick_count: undefined,
12351
12352 /**
12353 * Show or hide y axis tick line.
12354 * @name axis․y․tick․show
12355 * @memberof Options
12356 * @type {boolean}
12357 * @default true
12358 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
12359 * @example
12360 * axis: {
12361 * y: {
12362 * tick: {
12363 * show: false
12364 * }
12365 * }
12366 * }
12367 */
12368 axis_y_tick_show: !0,
12369
12370 /**
12371 * Set axis tick step(interval) size.
12372 * - **NOTE:** Will be ignored if `axis.y.tick.count` or `axis.y.tick.values` options are set.
12373 * @name axis․y․tick․stepSize
12374 * @memberof Options
12375 * @type {number}
12376 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.StepSizeForYAxis)
12377 * @example
12378 * axis: {
12379 * y: {
12380 * tick: {
12381 * // tick value will step as indicated interval value.
12382 * // ex) 'stepSize=15' ==> [0, 15, 30, 45, 60]
12383 * stepSize: 15
12384 * }
12385 * }
12386 * }
12387 */
12388 axis_y_tick_stepSize: null,
12389
12390 /**
12391 * Show or hide y axis tick text.
12392 * @name axis․y․tick․text․show
12393 * @memberof Options
12394 * @type {boolean}
12395 * @default true
12396 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
12397 * @example
12398 * axis: {
12399 * y: {
12400 * tick: {
12401 * text: {
12402 * show: false
12403 * }
12404 * }
12405 * }
12406 * }
12407 */
12408 axis_y_tick_text_show: !0,
12409
12410 /**
12411 * Set the y Axis tick text's position relatively its original position
12412 * @name axis․y․tick․text․position
12413 * @memberof Options
12414 * @type {object}
12415 * @default {x: 0, y:0}
12416 * @example
12417 * axis: {
12418 * y: {
12419 * tick: {
12420 * text: {
12421 * position: {
12422 * x: 10,
12423 * y: 10
12424 * }
12425 * }
12426 * }
12427 * }
12428 * }
12429 */
12430 axis_y_tick_text_position: {
12431 x: 0,
12432 y: 0
12433 },
12434
12435 /**
12436 * Set the number of y axis ticks.<br><br>
12437 * - **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.
12438 * @name axis․y․tick․time
12439 * @memberof Options
12440 * @private
12441 * @type {object}
12442 * @property {object} time time object
12443 * @property {Function} [time.value] D3's time interval function (https://github.com/d3/d3-time#intervals)
12444 * @example
12445 * axis: {
12446 * y: {
12447 * tick: {
12448 * time: {
12449 * // ticks at 15-minute intervals
12450 * // https://github.com/d3/d3-scale/blob/master/README.md#time_ticks
12451 * value: d3.timeMinute.every(15)
12452 * }
12453 * }
12454 * }
12455 * }
12456 */
12457 // @TODO: not fully implemented yet
12458 axis_y_tick_time_value: undefined,
12459
12460 /**
12461 * Set padding for y axis.<br><br>
12462 * You can set padding for y axis to create more space on the edge of the axis.
12463 * This option accepts object and it can include top and bottom. top, bottom will be treated as pixels.
12464 *
12465 * - **NOTE:**
12466 * - Given values are translated relative to the y Axis domain value for padding
12467 * - For area and bar type charts, [area.zerobased](#.area) or [bar.zerobased](#.bar) options should be set to 'false` to get padded bottom.
12468 * @name axis․y․padding
12469 * @memberof Options
12470 * @type {object|number}
12471 * @default {}
12472 * @example
12473 * axis: {
12474 * y: {
12475 * padding: {
12476 * top: 0,
12477 * bottom: 0
12478 * },
12479 *
12480 * // or set both values at once.
12481 * padding: 10
12482 * }
12483 * }
12484 */
12485 axis_y_padding: {},
12486
12487 /**
12488 * Set default range of y axis.<br><br>
12489 * This option set the default value for y axis when there is no data on init.
12490 * @name axis․y․default
12491 * @memberof Options
12492 * @type {Array}
12493 * @default undefined
12494 * @example
12495 * axis: {
12496 * y: {
12497 * default: [0, 1000]
12498 * }
12499 * }
12500 */
12501 axis_y_default: undefined,
12502
12503 /**
12504 * Set additional axes for y Axis.
12505 * - **NOTE:** Axis' scale is based on y Axis value if domain option isn't set.
12506 *
12507 * Each axis object should consist with following options:
12508 *
12509 * | Name | Type | Default | Description |
12510 * | --- | --- | --- | --- |
12511 * | domain | Array | - | Set the domain value |
12512 * | tick.outer | boolean | true | Show outer tick |
12513 * | tick.format | Function | - | Set formatter for tick text |
12514 * | tick.count | Number | - | Set the number of y axis ticks |
12515 * | tick.values | Array | - | Set tick values manually |
12516 * @name axis․y․axes
12517 * @memberof Options
12518 * @type {Array}
12519 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
12520 * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
12521 * @example
12522 * y: {
12523 * axes: [
12524 * {
12525 * // if set, will not be correlated with the main y Axis domain value
12526 * domain: [0, 1000],
12527 * tick: {
12528 * outer: false,
12529 * format: function(x) {
12530 * return x + "%";
12531 * },
12532 * count: 2,
12533 * values: [10, 20, 30]
12534 * }
12535 * },
12536 * ...
12537 * ]
12538 * }
12539 */
12540 axis_y_axes: []
12541});
12542;// CONCATENATED MODULE: ./src/config/Options/axis/y2.ts
12543/**
12544 * Copyright (c) 2017 ~ present NAVER Corp.
12545 * billboard.js project is licensed under the MIT license
12546 */
12547
12548/**
12549 * y2 Axis config options
12550 */
12551/* harmony default export */ var y2 = ({
12552 /**
12553 * Show or hide y2 axis.
12554 * - **NOTE**:
12555 * - When set to `false` will not generate y2 axis node. In this case, all 'y2' axis related functionality won't work properly.
12556 * - If need to use 'y2' related options while y2 isn't visible, set the value `true` and control visibility by css display property.
12557 * @name axis․y2․show
12558 * @memberof Options
12559 * @type {boolean}
12560 * @default false
12561 * @example
12562 * axis: {
12563 * y2: {
12564 * show: true
12565 * }
12566 * }
12567 */
12568 axis_y2_show: !1,
12569
12570 /**
12571 * Set type of y2 axis.<br><br>
12572 * **Available Values:**
12573 * - indexed
12574 * - log
12575 * - timeseries
12576 *
12577 * **NOTE:**<br>
12578 * - **log** type:
12579 * - the bound data values must be exclusively-positive.
12580 * - y2 axis min value should be >= 0.
12581 * - [`data.groups`](#.data%25E2%2580%25A4groups)(stacked data) option aren't supported.
12582 *
12583 * @name axis․y2․type
12584 * @memberof Options
12585 * @type {string}
12586 * @default "indexed"
12587 * @see [Demo: log](https://naver.github.io/billboard.js/demo/#Axis.LogScales)
12588 * @example
12589 * axis: {
12590 * y2: {
12591 * type: "indexed"
12592 * }
12593 * }
12594 */
12595 axis_y2_type: "indexed",
12596
12597 /**
12598 * Set max value of y2 axis.
12599 * @name axis․y2․max
12600 * @memberof Options
12601 * @type {number}
12602 * @default undefined
12603 * @example
12604 * axis: {
12605 * y2: {
12606 * max: 1000
12607 * }
12608 * }
12609 */
12610 axis_y2_max: undefined,
12611
12612 /**
12613 * Set min value of y2 axis.
12614 * @name axis․y2․min
12615 * @memberof Options
12616 * @type {number}
12617 * @default undefined
12618 * @example
12619 * axis: {
12620 * y2: {
12621 * min: -1000
12622 * }
12623 * }
12624 */
12625 axis_y2_min: undefined,
12626
12627 /**
12628 * Change the direction of y2 axis.<br><br>
12629 * If true set, the direction will be from the top to the bottom.
12630 * @name axis․y2․inverted
12631 * @memberof Options
12632 * @type {boolean}
12633 * @default false
12634 * @example
12635 * axis: {
12636 * y2: {
12637 * inverted: true
12638 * }
12639 * }
12640 */
12641 axis_y2_inverted: !1,
12642
12643 /**
12644 * Set center value of y2 axis.
12645 * @name axis․y2․center
12646 * @memberof Options
12647 * @type {number}
12648 * @default undefined
12649 * @example
12650 * axis: {
12651 * y2: {
12652 * center: 0
12653 * }
12654 * }
12655 */
12656 axis_y2_center: undefined,
12657
12658 /**
12659 * Show y2 axis inside of the chart.
12660 * @name axis․y2․inner
12661 * @memberof Options
12662 * @type {boolean}
12663 * @default false
12664 * @example
12665 * axis: {
12666 * y2: {
12667 * inner: true
12668 * }
12669 * }
12670 */
12671 axis_y2_inner: !1,
12672
12673 /**
12674 * Set label on y2 axis.<br><br>
12675 * 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).
12676 * @name axis․y2․label
12677 * @memberof Options
12678 * @type {string|object}
12679 * @default {}
12680 * @see [axis.x.label](#.axis%25E2%2580%25A4x%25E2%2580%25A4label) for position string value.
12681 * @example
12682 * axis: {
12683 * y2: {
12684 * label: "Your Y2 Axis"
12685 * }
12686 * }
12687 *
12688 * axis: {
12689 * y2: {
12690 * label: {
12691 * text: "Your Y2 Axis",
12692 * position: "outer-middle"
12693 * }
12694 * }
12695 * }
12696 */
12697 axis_y2_label: {},
12698
12699 /**
12700 * Set formatter for y2 axis tick text.<br><br>
12701 * This option works in the same way as axis.y.format.
12702 * @name axis․y2․tick․format
12703 * @memberof Options
12704 * @type {Function}
12705 * @default undefined
12706 * @example
12707 * axis: {
12708 * y2: {
12709 * tick: {
12710 * format: d3.format("$,")
12711 * //or format: function(d) { return "$" + d; }
12712 * }
12713 * }
12714 * }
12715 */
12716 axis_y2_tick_format: undefined,
12717
12718 /**
12719 * Setting for culling ticks.<br><br>
12720 * 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>
12721 * We can change the number of ticks to be shown by axis.y.tick.culling.max.
12722 * @name axis․y2․tick․culling
12723 * @memberof Options
12724 * @type {boolean}
12725 * @default false
12726 * @example
12727 * axis: {
12728 * y2: {
12729 * tick: {
12730 * culling: false
12731 * }
12732 * }
12733 * }
12734 */
12735 axis_y2_tick_culling: !1,
12736
12737 /**
12738 * The number of tick texts will be adjusted to less than this value.
12739 * @name axis․y2․tick․culling․max
12740 * @memberof Options
12741 * @type {number}
12742 * @default 5
12743 * @example
12744 * axis: {
12745 * y2: {
12746 * tick: {
12747 * culling: {
12748 * max: 5
12749 * }
12750 * }
12751 * }
12752 * }
12753 */
12754 axis_y2_tick_culling_max: 5,
12755
12756 /**
12757 * Show or hide y2 axis outer tick.
12758 * @name axis․y2․tick․outer
12759 * @memberof Options
12760 * @type {boolean}
12761 * @default true
12762 * @example
12763 * axis: {
12764 * y2: {
12765 * tick: {
12766 * outer: false
12767 * }
12768 * }
12769 * }
12770 */
12771 axis_y2_tick_outer: !0,
12772
12773 /**
12774 * Set y2 axis tick values manually.
12775 * @name axis․y2․tick․values
12776 * @memberof Options
12777 * @type {Array|Function}
12778 * @default null
12779 * @example
12780 * axis: {
12781 * y2: {
12782 * tick: {
12783 * values: [100, 1000, 10000],
12784 *
12785 * // an Array value should be returned
12786 * values: function() {
12787 * return [ ... ];
12788 * }
12789 * }
12790 * }
12791 * }
12792 */
12793 axis_y2_tick_values: null,
12794
12795 /**
12796 * Rotate y2 axis tick text.
12797 * - If you set negative value, it will rotate to opposite direction.
12798 * - Applied when [`axis.rotated`](#.axis%25E2%2580%25A4rotated) option is `true`.
12799 * @name axis․y2․tick․rotate
12800 * @memberof Options
12801 * @type {number}
12802 * @default 0
12803 * @example
12804 * axis: {
12805 * y2: {
12806 * tick: {
12807 * rotate: 60
12808 * }
12809 * }
12810 * }
12811 */
12812 axis_y2_tick_rotate: 0,
12813
12814 /**
12815 * Set the number of y2 axis ticks.
12816 * - **NOTE:** This works in the same way as axis.y.tick.count.
12817 * @name axis․y2․tick․count
12818 * @memberof Options
12819 * @type {number}
12820 * @default undefined
12821 * @example
12822 * axis: {
12823 * y2: {
12824 * tick: {
12825 * count: 5
12826 * }
12827 * }
12828 * }
12829 */
12830 axis_y2_tick_count: undefined,
12831
12832 /**
12833 * Show or hide y2 axis tick line.
12834 * @name axis․y2․tick․show
12835 * @memberof Options
12836 * @type {boolean}
12837 * @default true
12838 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
12839 * @example
12840 * axis: {
12841 * y2: {
12842 * tick: {
12843 * show: false
12844 * }
12845 * }
12846 * }
12847 */
12848 axis_y2_tick_show: !0,
12849
12850 /**
12851 * Set axis tick step(interval) size.
12852 * - **NOTE:** Will be ignored if `axis.y2.tick.count` or `axis.y2.tick.values` options are set.
12853 * @name axis․y2․tick․stepSize
12854 * @memberof Options
12855 * @type {number}
12856 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.StepSizeForYAxis)
12857 * @example
12858 * axis: {
12859 * y2: {
12860 * tick: {
12861 * // tick value will step as indicated interval value.
12862 * // ex) 'stepSize=15' ==> [0, 15, 30, 45, 60]
12863 * stepSize: 15
12864 * }
12865 * }
12866 * }
12867 */
12868 axis_y2_tick_stepSize: null,
12869
12870 /**
12871 * Show or hide y2 axis tick text.
12872 * @name axis․y2․tick․text․show
12873 * @memberof Options
12874 * @type {boolean}
12875 * @default true
12876 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.HideTickLineText)
12877 * @example
12878 * axis: {
12879 * y2: {
12880 * tick: {
12881 * text: {
12882 * show: false
12883 * }
12884 * }
12885 * }
12886 * }
12887 */
12888 axis_y2_tick_text_show: !0,
12889
12890 /**
12891 * Set the y2 Axis tick text's position relatively its original position
12892 * @name axis․y2․tick․text․position
12893 * @memberof Options
12894 * @type {object}
12895 * @default {x: 0, y:0}
12896 * @example
12897 * axis: {
12898 * y2: {
12899 * tick: {
12900 * text: {
12901 * position: {
12902 * x: 10,
12903 * y: 10
12904 * }
12905 * }
12906 * }
12907 * }
12908 * }
12909 */
12910 axis_y2_tick_text_position: {
12911 x: 0,
12912 y: 0
12913 },
12914
12915 /**
12916 * Set padding for y2 axis.<br><br>
12917 * You can set padding for y2 axis to create more space on the edge of the axis.
12918 * This option accepts object and it can include top and bottom. top, bottom will be treated as pixels.
12919 *
12920 * - **NOTE:**
12921 * - Given values are translated relative to the y2 Axis domain value for padding
12922 * - For area and bar type charts, [area.zerobased](#.area) or [bar.zerobased](#.bar) options should be set to 'false` to get padded bottom.
12923 * @name axis․y2․padding
12924 * @memberof Options
12925 * @type {object|number}
12926 * @default {}
12927 * @example
12928 * axis: {
12929 * y2: {
12930 * padding: {
12931 * top: 100,
12932 * bottom: 100
12933 * }
12934 *
12935 * // or set both values at once.
12936 * padding: 10
12937 * }
12938 */
12939 axis_y2_padding: {},
12940
12941 /**
12942 * Set default range of y2 axis.<br><br>
12943 * This option set the default value for y2 axis when there is no data on init.
12944 * @name axis․y2․default
12945 * @memberof Options
12946 * @type {Array}
12947 * @default undefined
12948 * @example
12949 * axis: {
12950 * y2: {
12951 * default: [0, 1000]
12952 * }
12953 * }
12954 */
12955 axis_y2_default: undefined,
12956
12957 /**
12958 * Set additional axes for y2 Axis.
12959 * - **NOTE:** Axis' scale is based on y2 Axis value if domain option isn't set.
12960 *
12961 * Each axis object should consist with following options:
12962 *
12963 * | Name | Type | Default | Description |
12964 * | --- | --- | --- | --- |
12965 * | domain | Array | - | Set the domain value |
12966 * | tick.outer | boolean | true | Show outer tick |
12967 * | tick.format | Function | - | Set formatter for tick text |
12968 * | tick.count | Number | - | Set the number of y axis ticks |
12969 * | tick.values | Array | - | Set tick values manually |
12970 * @name axis․y2․axes
12971 * @memberof Options
12972 * @type {Array}
12973 * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.MultiAxes)
12974 * @see [Demo: Domain](https://naver.github.io/billboard.js/demo/#Axis.MultiAxesDomain)
12975 * @example
12976 * y2: {
12977 * axes: [
12978 * {
12979 * // if set, will not be correlated with the main y2 Axis domain value
12980 * domain: [0, 1000],
12981 * tick: {
12982 * outer: false,
12983 * format: function(x) {
12984 * return x + "%";
12985 * },
12986 * count: 2,
12987 * values: [10, 20, 30]
12988 * }
12989 * },
12990 * ...
12991 * ]
12992 * }
12993 */
12994 axis_y2_axes: []
12995});
12996;// CONCATENATED MODULE: ./src/config/Options/axis/axis.ts
12997
12998
12999function axis_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13000
13001function axis_objectSpread(target) { for (var source, i = 1; i < arguments.length; i++) source = arguments[i] == null ? {} : arguments[i], i % 2 ? axis_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : axis_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); return target; }
13002
13003/**
13004 * Copyright (c) 2017 ~ present NAVER Corp.
13005 * billboard.js project is licensed under the MIT license
13006 */
13007
13008
13009
13010/**
13011 * y Axis config options
13012 */
13013
13014/* harmony default export */ var axis_axis = (axis_objectSpread(axis_objectSpread(axis_objectSpread({
13015 /**
13016 * Switch x and y axis position.
13017 * @name axis․rotated
13018 * @memberof Options
13019 * @type {boolean}
13020 * @default false
13021 * @example
13022 * axis: {
13023 * rotated: true
13024 * }
13025 */
13026 axis_rotated: !1
13027}, axis_x), y), y2));
13028;// CONCATENATED MODULE: ./src/config/Options/common/grid.ts
13029/**
13030 * Copyright (c) 2017 ~ present NAVER Corp.
13031 * billboard.js project is licensed under the MIT license
13032 */
13033
13034/**
13035 * grid config options
13036 */
13037/* harmony default export */ var common_grid = ({
13038 /**
13039 * Set related options
13040 * @name grid
13041 * @memberof Options
13042 * @type {object}
13043 * @property {boolean} [front=false] Set 'grid & focus lines' to be positioned over grid lines and chart elements.
13044 * @property {object} x Grid x object
13045 * @property {boolean} [x.show=false] Show grids along x axis.
13046 * @property {Array} [x.lines=[]] Show additional grid lines along x axis.<br>
13047 * 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.
13048 * 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.
13049 * @property {object} y Grid y object
13050 * @property {boolean} [y.show=false] Show grids along x axis.
13051 * @property {Array} [y.lines=[]] Show additional grid lines along y axis.<br>
13052 * This option accepts array including object that has value, text, position and class.
13053 * @property {number} [y.ticks=10] Number of y grids to be shown.
13054 * @property {object} focus Grid focus object
13055 * @property {boolean} [focus.edge=false] Show edged focus grid line.<br>**NOTE:** Available when [`tooltip.grouped=false`](#.tooltip) option is set.
13056 * @property {boolean} [focus.show=true] Show grid line when focus.
13057 * @property {boolean} [focus.y=false] Show y coordinate focus grid line.<br>**NOTE:** Available when [`tooltip.grouped=false`](#.tooltip) option is set.
13058 * @property {object} lines Grid lines object
13059 * @property {boolean} [lines.front=true] Set grid lines to be positioned over chart elements.
13060 * @default undefined
13061 * @see [Demo](https://naver.github.io/billboard.js/demo/#Grid.GridLines)
13062 * @see [Demo: X Grid Lines](https://naver.github.io/billboard.js/demo/#Grid.OptionalXGridLines)
13063 * @see [Demo: Y Grid Lines](https://naver.github.io/billboard.js/demo/#Grid.OptionalYGridLines)
13064 * @example
13065 * grid: {
13066 * x: {
13067 * show: true,
13068 * lines: [
13069 * {value: 2, text: "Label on 2"},
13070 * {value: 5, text: "Label on 5", class: "label-5"},
13071 * {value: 6, text: "Label on 6", position: "start"}
13072 * ]
13073 * },
13074 * y: {
13075 * show: true,
13076 * lines: [
13077 * {value: 100, text: "Label on 100"},
13078 * {value: 200, text: "Label on 200", class: "label-200"},
13079 * {value: 300, text: "Label on 300", position: 'middle'}
13080 * ],
13081 * ticks: 5
13082 * },
13083 * front: true,
13084 * focus: {
13085 * show: false,
13086 *
13087 * // Below options are available when 'tooltip.grouped=false' option is set
13088 * edge: true,
13089 * y: true
13090 * },
13091 * lines: {
13092 * front: false
13093 * }
13094 * }
13095 */
13096 grid_x_show: !1,
13097 grid_x_type: "tick",
13098 grid_x_lines: [],
13099 grid_y_show: !1,
13100 grid_y_lines: [],
13101 grid_y_ticks: 10,
13102 grid_focus_edge: !1,
13103 grid_focus_show: !0,
13104 grid_focus_y: !1,
13105 grid_front: !1,
13106 grid_lines_front: !0
13107});
13108;// CONCATENATED MODULE: ./src/config/resolver/axis.ts
13109/**
13110 * Copyright (c) 2017 ~ present NAVER Corp.
13111 * billboard.js project is licensed under the MIT license
13112 */
13113
13114/**
13115 * Modules exports for Axis based chart
13116 */
13117// Chart
13118
13119
13120
13121
13122
13123
13124
13125 // ChartInternal
13126
13127
13128
13129
13130
13131
13132
13133 // Axis based options
13134
13135
13136
13137
13138var api = [api_axis, api_category, grid_x, grid_y, flow, group, api_regions, x];
13139var internal = [Axis, clip, eventrect, interactions_flow, grid, region, size_axis];
13140var options = [data_axis, axis_axis, common_grid];
13141// EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
13142var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(12);
13143;// CONCATENATED MODULE: ./src/ChartInternal/shape/arc.ts
13144/**
13145 * Copyright (c) 2017 ~ present NAVER Corp.
13146 * billboard.js project is licensed under the MIT license
13147 */
13148
13149
13150
13151
13152
13153
13154/* harmony default export */ var arc = ({
13155 initPie: function initPie() {
13156 var $$ = this,
13157 config = $$.config,
13158 dataType = config.data_type,
13159 padding = config.pie_padding,
13160 startingAngle = config[dataType + "_startingAngle"] || 0,
13161 padAngle = ($$.hasType("pie") && padding ? padding * .01 : config[dataType + "_padAngle"]) || 0;
13162 $$.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) {
13163 return d.values.reduce(function (a, b) {
13164 return a + b.value;
13165 }, 0);
13166 }).sort($$.getSortCompareFn.bind($$)(!0));
13167 },
13168 updateRadius: function updateRadius() {
13169 var $$ = this,
13170 config = $$.config,
13171 state = $$.state,
13172 padding = config.pie_padding,
13173 w = config.gauge_width || config.donut_width,
13174 gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length * config.gauge_arcs_minWidth;
13175 state.radiusExpanded = Math.min(state.arcWidth, state.arcHeight) / 2 * ($$.hasMultiArcGauge() ? .85 : 1), state.radius = state.radiusExpanded * .95, state.innerRadiusRatio = w ? (state.radius - w) / state.radius : .6, state.gaugeArcWidth = w || (gaugeArcWidth <= state.radius - state.innerRadius ? state.radius - state.innerRadius : gaugeArcWidth <= state.radius ? gaugeArcWidth : state.radius);
13176 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
13177
13178 state.outerRadius = config.pie_outerRadius, state.innerRadius = $$.hasType("donut") || $$.hasType("gauge") ? state.radius * state.innerRadiusRatio : innerRadius;
13179 },
13180
13181 /**
13182 * Get pie's inner & outer radius value
13183 * @param {object|undefined} d Data object
13184 * @returns {object}
13185 * @private
13186 */
13187 getRadius: function getRadius(d) {
13188 var $$ = this,
13189 data = d && d.data,
13190 _$$$state = $$.state,
13191 innerRadius = _$$$state.innerRadius,
13192 outerRadius = _$$$state.outerRadius;
13193 return !isNumber(innerRadius) && data && (innerRadius = innerRadius[data.id] || 0), isObject(outerRadius) && data && data.id in outerRadius ? outerRadius = outerRadius[data.id] : !isNumber(outerRadius) && (outerRadius = $$.state.radius), {
13194 innerRadius: innerRadius,
13195 outerRadius: outerRadius
13196 };
13197 },
13198 updateArc: function updateArc() {
13199 var $$ = this;
13200 $$.updateRadius(), $$.svgArc = $$.getSvgArc(), $$.svgArcExpanded = $$.getSvgArcExpanded();
13201 },
13202 getArcLength: function getArcLength() {
13203 var $$ = this,
13204 config = $$.config,
13205 arcLengthInPercent = config.gauge_arcLength * 3.6,
13206 len = 2 * (arcLengthInPercent / 360);
13207 return arcLengthInPercent < -360 ? len = -2 : arcLengthInPercent > 360 && (len = 2), len * Math.PI;
13208 },
13209 getStartAngle: function getStartAngle() {
13210 var $$ = this,
13211 config = $$.config,
13212 isFullCircle = config.gauge_fullCircle,
13213 defaultStartAngle = -1 * Math.PI / 2,
13214 defaultEndAngle = Math.PI / 2,
13215 startAngle = config.gauge_startingAngle;
13216 return !isFullCircle && startAngle <= defaultStartAngle ? startAngle = defaultStartAngle : !isFullCircle && startAngle >= defaultEndAngle ? startAngle = defaultEndAngle : (startAngle > Math.PI || startAngle < -1 * Math.PI) && (startAngle = Math.PI), startAngle;
13217 },
13218 updateAngle: function updateAngle(dValue) {
13219 var $$ = this,
13220 config = $$.config,
13221 state = $$.state,
13222 pie = $$.pie,
13223 d = dValue,
13224 found = !1;
13225 if (!config) return null;
13226 var gStart = $$.getStartAngle(),
13227 radius = config.gauge_fullCircle ? $$.getArcLength() : gStart * -2;
13228
13229 if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
13230 // to prevent excluding total data sum during the init(when data.hide option is used), use $$.rendered state value
13231 var totalSum = $$.getTotalDataSum(state.rendered),
13232 gEnd = radius * (totalSum / (config.gauge_max - config.gauge_min));
13233 pie = pie.startAngle(gStart).endAngle(gEnd + gStart);
13234 }
13235
13236 if (pie($$.filterTargetsToShow()).forEach(function (t, i) {
13237 found || t.data.id !== d.data.id || (found = !0, d = t, d.index = i);
13238 }), isNaN(d.startAngle) && (d.startAngle = 0), isNaN(d.endAngle) && (d.endAngle = d.startAngle), d.data && $$.hasMultiArcGauge()) {
13239 var gMin = config.gauge_min,
13240 gMax = config.gauge_max,
13241 gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : gMax - gMin;
13242 d.startAngle = gStart, d.endAngle = gStart + radius / (gMax - gMin) * gValue;
13243 }
13244
13245 return found ? d : null;
13246 },
13247 getSvgArc: function getSvgArc() {
13248 var $$ = this,
13249 state = $$.state,
13250 singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
13251 hasMultiArcGauge = $$.hasMultiArcGauge(),
13252 arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
13253 var _$$$getRadius = $$.getRadius(d),
13254 innerRadius = _$$$getRadius.innerRadius;
13255
13256 return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : isNumber(innerRadius) ? innerRadius : 0;
13257 }).outerRadius(function (d) {
13258 var _$$$getRadius2 = $$.getRadius(d),
13259 outerRadius = _$$$getRadius2.outerRadius;
13260
13261 return hasMultiArcGauge ? state.radius - singleArcWidth * d.index : outerRadius;
13262 }),
13263 newArc = function (d, withoutUpdate) {
13264 var path = "M 0 0";
13265
13266 if (d.value || d.data) {
13267 var updated = !withoutUpdate && $$.updateAngle(d);
13268 withoutUpdate ? path = arc(d) : updated && (path = arc(updated));
13269 }
13270
13271 return path;
13272 };
13273
13274 return newArc.centroid = arc.centroid, newArc;
13275 },
13276 getSvgArcExpanded: function getSvgArcExpanded(rate) {
13277 var $$ = this,
13278 state = $$.state,
13279 newRate = rate || 1,
13280 singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
13281 hasMultiArcGauge = $$.hasMultiArcGauge(),
13282 expandWidth = Math.min(state.radiusExpanded * newRate - state.radius, singleArcWidth * .8 - (1 - newRate) * 100),
13283 arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
13284 return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : $$.getRadius(d).innerRadius;
13285 }).outerRadius(function (d) {
13286 var radius;
13287 if (hasMultiArcGauge) radius = state.radius - singleArcWidth * d.index + expandWidth;else {
13288 var _$$$getRadius3 = $$.getRadius(d),
13289 outerRadius = _$$$getRadius3.outerRadius,
13290 radiusExpanded = state.radiusExpanded;
13291
13292 state.radius !== outerRadius && (radiusExpanded -= Math.abs(state.radius - outerRadius)), radius = radiusExpanded * newRate;
13293 }
13294 return radius;
13295 });
13296 return function (d) {
13297 var updated = $$.updateAngle(d);
13298 return updated ? arc(updated) : "M 0 0";
13299 };
13300 },
13301 getArc: function getArc(d, withoutUpdate, force) {
13302 return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0";
13303 },
13304 transformForArcLabel: function transformForArcLabel(d) {
13305 var $$ = this,
13306 config = $$.config,
13307 radiusExpanded = $$.state.radiusExpanded,
13308 updated = $$.updateAngle(d),
13309 translate = "";
13310 if (updated) if ($$.hasMultiArcGauge()) {
13311 var y1 = Math.sin(updated.endAngle - Math.PI / 2),
13312 x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + 25),
13313 y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
13314 translate = "translate(" + x + "," + y + ")";
13315 } else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
13316 var _$$$getRadius4 = $$.getRadius(d),
13317 outerRadius = _$$$getRadius4.outerRadius,
13318 c = this.svgArc.centroid(updated),
13319 x = isNaN(c[0]) ? 0 : c[0],
13320 y = isNaN(c[1]) ? 0 : c[1],
13321 h = Math.sqrt(x * x + y * y),
13322 ratio = $$.hasType("donut") && config.donut_label_ratio || $$.hasType("pie") && config.pie_label_ratio;
13323
13324 ratio = ratio ? isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio : outerRadius && (h ? (36 / outerRadius > .375 ? 1.175 - 36 / outerRadius : .8) * outerRadius / h : 0), translate = "translate(" + x * ratio + "," + y * ratio + ")";
13325 }
13326 return translate;
13327 },
13328 convertToArcData: function convertToArcData(d) {
13329 return this.addName({
13330 id: d.data ? d.data.id : d.id,
13331 value: d.value,
13332 ratio: this.getRatio("arc", d),
13333 index: d.index
13334 });
13335 },
13336 textForArcLabel: function textForArcLabel(selection) {
13337 var $$ = this,
13338 hasGauge = $$.hasType("gauge");
13339 $$.shouldShowArcLabel() && selection.style("fill", $$.updateTextColor.bind($$)).each(function (d) {
13340 var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
13341 updated = $$.updateAngle(d),
13342 ratio = $$.getRatio("arc", updated),
13343 isUnderThreshold = $$.meetsLabelThreshold(ratio, $$.hasType("donut") && "donut" || $$.hasType("gauge") && "gauge" || $$.hasType("pie") && "pie");
13344
13345 if (isUnderThreshold) {
13346 var value = (updated || d).value,
13347 text = ($$.getArcLabelFormat() || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
13348 setTextValue(node, text, [-1, 1], hasGauge);
13349 } else node.text("");
13350 });
13351 },
13352 expandArc: function expandArc(targetIds) {
13353 var $$ = this,
13354 transiting = $$.state.transiting,
13355 $el = $$.$el;
13356
13357 // MEMO: avoid to cancel transition
13358 if (transiting) {
13359 var interval = setInterval(function () {
13360 transiting || (clearInterval(interval), $el.legend.selectAll("." + config_classes.legendItemFocused).size() > 0 && $$.expandArc(targetIds));
13361 }, 10);
13362 return;
13363 }
13364
13365 var newTargetIds = $$.mapToTargetIds(targetIds);
13366 $el.svg.selectAll($$.selectorTargets(newTargetIds, "." + config_classes.chartArc)).each(function (d) {
13367 if ($$.shouldExpand(d.data.id)) {
13368 var expandDuration = $$.getExpandConfig(d.data.id, "duration"),
13369 svgArcExpandedSub = $$.getSvgArcExpanded($$.getExpandConfig(d.data.id, "rate"));
13370 (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);
13371 }
13372 });
13373 },
13374 unexpandArc: function unexpandArc(targetIds) {
13375 var $$ = this,
13376 transiting = $$.state.transiting,
13377 svg = $$.$el.svg;
13378
13379 if (!transiting) {
13380 var newTargetIds = $$.mapToTargetIds(targetIds);
13381 svg.selectAll($$.selectorTargets(newTargetIds, "." + config_classes.chartArc)).selectAll("path").transition().duration(function (d) {
13382 return $$.getExpandConfig(d.data.id, "duration");
13383 }).attr("d", $$.svgArc), svg.selectAll("" + config_classes.arc).style("opacity", "1");
13384 }
13385 },
13386
13387 /**
13388 * Get expand config value
13389 * @param {string} id data ID
13390 * @param {string} key config key: 'duration | rate'
13391 * @returns {number}
13392 * @private
13393 */
13394 getExpandConfig: function getExpandConfig(id, key) {
13395 var type,
13396 $$ = this,
13397 config = $$.config;
13398 return $$.isDonutType(id) ? type = "donut" : $$.isGaugeType(id) ? type = "gauge" : $$.isPieType(id) && (type = "pie"), type ? config[type + "_expand_" + key] : {
13399 duration: 50,
13400 rate: .98
13401 }[key];
13402 },
13403 shouldExpand: function shouldExpand(id) {
13404 var $$ = this,
13405 config = $$.config;
13406 return $$.isDonutType(id) && config.donut_expand || $$.isGaugeType(id) && config.gauge_expand || $$.isPieType(id) && config.pie_expand;
13407 },
13408 shouldShowArcLabel: function shouldShowArcLabel() {
13409 var $$ = this,
13410 config = $$.config;
13411 return ["pie", "donut", "gauge"].some(function (v) {
13412 return $$.hasType(v) && config[v + "_label_show"];
13413 });
13414 },
13415 getArcLabelFormat: function getArcLabelFormat() {
13416 var $$ = this,
13417 config = $$.config,
13418 format = config.pie_label_format;
13419 return $$.hasType("gauge") ? format = config.gauge_label_format : $$.hasType("donut") && (format = config.donut_label_format), isFunction(format) ? format.bind($$.api) : format;
13420 },
13421 getArcTitle: function getArcTitle() {
13422 var $$ = this,
13423 type = $$.hasType("donut") && "donut" || $$.hasType("gauge") && "gauge";
13424 return type ? $$.config[type + "_title"] : "";
13425 },
13426 updateTargetsForArc: function updateTargetsForArc(targets) {
13427 var $$ = this,
13428 $el = $$.$el,
13429 hasGauge = $$.hasType("gauge"),
13430 classChartArc = $$.getChartClass("Arc"),
13431 classArcs = $$.getClass("arcs", !0),
13432 classFocus = $$.classFocus.bind($$),
13433 chartArcs = $el.main.select("." + config_classes.chartArcs),
13434 mainPieUpdate = chartArcs.selectAll("." + config_classes.chartArc).data($$.pie(targets)).attr("class", function (d) {
13435 return classChartArc(d) + classFocus(d.data);
13436 }),
13437 mainPieEnter = mainPieUpdate.enter().append("g").attr("class", classChartArc);
13438 mainPieEnter.append("g").attr("class", classArcs).merge(mainPieUpdate), mainPieEnter.append("text").attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" : ".35em").style("opacity", "0").style("text-anchor", "middle").style("pointer-events", "none"), $el.text = chartArcs.selectAll("." + config_classes.target + " text");
13439 },
13440 initArc: function initArc() {
13441 var $$ = this,
13442 $el = $$.$el;
13443 $el.arcs = $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartArcs).attr("transform", $$.getTranslate("arc")), $$.setArcTitle();
13444 },
13445
13446 /**
13447 * Set arc title text
13448 * @private
13449 */
13450 setArcTitle: function setArcTitle() {
13451 var $$ = this,
13452 title = $$.getArcTitle(),
13453 hasGauge = $$.hasType("gauge");
13454
13455 if (title) {
13456 var text = $$.$el.arcs.append("text").attr("class", config_classes[hasGauge ? "chartArcsGaugeTitle" : "chartArcsTitle"]).style("text-anchor", "middle");
13457 hasGauge && text.attr("dy", "-0.3em").style("font-size", "27px"), setTextValue(text, title, hasGauge ? undefined : [-.6, 1.35], !0);
13458 }
13459 },
13460 redrawArc: function redrawArc(duration, durationForExit, withTransform) {
13461 var $$ = this,
13462 config = $$.config,
13463 state = $$.state,
13464 main = $$.$el.main,
13465 hasInteraction = config.interaction_enabled,
13466 isSelectable = hasInteraction && config.data_selection_isselectable,
13467 mainArc = main.selectAll("." + config_classes.arcs).selectAll("." + config_classes.arc).data($$.arcData.bind($$));
13468 // bind arc events
13469 mainArc.exit().transition().duration(durationForExit).style("opacity", "0").remove(), mainArc = mainArc.enter().append("path").attr("class", $$.getClass("arc", !0)).style("fill", function (d) {
13470 return $$.color(d.data);
13471 }).style("cursor", function (d) {
13472 return isSelectable && isSelectable.bind($$.api)(d) ? "pointer" : null;
13473 }).style("opacity", "0").each(function (d) {
13474 $$.isGaugeType(d.data) && (d.startAngle = config.gauge_startingAngle, d.endAngle = config.gauge_startingAngle), this._current = d;
13475 }).merge(mainArc), $$.hasType("gauge") && ($$.updateGaugeMax(), $$.hasMultiArcGauge() && $$.redrawMultiArcGauge()), mainArc.attr("transform", function (d) {
13476 return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : "";
13477 }).style("opacity", function (d) {
13478 return d === this._current ? "0" : "1";
13479 }).each(function () {
13480 state.transiting = !0;
13481 }).transition().duration(duration).attrTween("d", function (d) {
13482 var updated = $$.updateAngle(d);
13483 if (!updated) return function () {
13484 return "M 0 0";
13485 };
13486 isNaN(this._current.startAngle) && (this._current.startAngle = 0), isNaN(this._current.endAngle) && (this._current.endAngle = this._current.startAngle);
13487 var interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(this._current, updated);
13488 return this._current = interpolate(0), function (t) {
13489 var interpolated = interpolate(t);
13490 // data.id will be updated by interporator
13491 return interpolated.data = d.data, $$.getArc(interpolated, !0);
13492 };
13493 }).attr("transform", withTransform ? "scale(1)" : "").style("fill", function (d) {
13494 var color;
13495 return $$.levelColor ? (color = $$.levelColor(d.data.values[0].value), config.data_colors[d.data.id] = color) : color = $$.color(d.data), color;
13496 }) // Where gauge reading color would receive customization.
13497 .style("opacity", "1").call(endall, function () {
13498 if ($$.levelColor) {
13499 var path = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
13500 d = path.datum();
13501 $$.updateLegendItemColor(d.data.id, path.style("fill"));
13502 }
13503
13504 state.transiting = !1, callFn(config.onrendered, $$.api);
13505 }), hasInteraction && $$.bindArcEvent(mainArc), $$.hasType("gauge") && $$.redrawBackgroundArcs(), $$.redrawArcText(duration);
13506 },
13507 redrawBackgroundArcs: function redrawBackgroundArcs() {
13508 var $$ = this,
13509 config = $$.config,
13510 state = $$.state,
13511 hasMultiArcGauge = $$.hasMultiArcGauge(),
13512 isFullCircle = config.gauge_fullCircle,
13513 startAngle = $$.getStartAngle(),
13514 endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1,
13515 backgroundArc = $$.$el.arcs.select((hasMultiArcGauge ? "g" : "") + "." + config_classes.chartArcsBackground);
13516
13517 if (hasMultiArcGauge) {
13518 var index = 0;
13519 backgroundArc = backgroundArc.selectAll("path." + config_classes.chartArcsBackground).data($$.data.targets), backgroundArc.enter().append("path").attr("class", function (d, i) {
13520 return config_classes.chartArcsBackground + " " + config_classes.chartArcsBackground + "-" + i;
13521 }).merge(backgroundArc).style("fill", config.gauge_background || null).attr("d", function (_ref2) {
13522 var id = _ref2.id;
13523 if (state.hiddenTargetIds.indexOf(id) >= 0) return "M 0 0";
13524 var d = {
13525 data: [{
13526 value: config.gauge_max
13527 }],
13528 startAngle: startAngle,
13529 endAngle: endAngle,
13530 index: index++
13531 };
13532 return $$.getArc(d, !0, !0);
13533 }), backgroundArc.exit().remove();
13534 } else backgroundArc.attr("d", function () {
13535 var d = {
13536 data: [{
13537 value: config.gauge_max
13538 }],
13539 startAngle: startAngle,
13540 endAngle: endAngle
13541 };
13542 return $$.getArc(d, !0, !0);
13543 });
13544 },
13545 bindArcEvent: function bindArcEvent(arc) {
13546 // eslint-disable-next-line
13547 function selectArc(_this, arcData, id) {
13548 $$.expandArc(id), $$.api.focus(id), $$.toggleFocusLegend(id, !0), $$.showTooltip([arcData], _this);
13549 } // eslint-disable-next-line
13550
13551
13552 function unselectArc(arcData) {
13553 var id = arcData && arcData.id || undefined;
13554 $$.unexpandArc(id), $$.api.revert(), $$.revertLegend(), $$.hideTooltip();
13555 }
13556
13557 var $$ = this,
13558 config = $$.config,
13559 state = $$.state,
13560 isTouch = state.inputType === "touch",
13561 isMouse = state.inputType === "mouse";
13562
13563 // touch events
13564 if (arc.on("click", function (event, d, i) {
13565 var arcData,
13566 updated = $$.updateAngle(d);
13567 updated && (arcData = $$.convertToArcData(updated), $$.toggleShape && $$.toggleShape(this, arcData, i), config.data_onclick.bind($$.api)(arcData, this));
13568 }), isMouse && arc.on("mouseover", function (event, d) {
13569 if (!state.transiting) // skip while transiting
13570 {
13571 state.event = event;
13572 var updated = $$.updateAngle(d),
13573 arcData = updated ? $$.convertToArcData(updated) : null,
13574 id = arcData && arcData.id || undefined;
13575 selectArc(this, arcData, id), $$.setOverOut(!0, arcData);
13576 }
13577 }).on("mouseout", function (event, d) {
13578 if (!state.transiting) // skip while transiting
13579 {
13580 state.event = event;
13581 var updated = $$.updateAngle(d),
13582 arcData = updated ? $$.convertToArcData(updated) : null;
13583 unselectArc(), $$.setOverOut(!1, arcData);
13584 }
13585 }).on("mousemove", function (event, d) {
13586 var updated = $$.updateAngle(d),
13587 arcData = updated ? $$.convertToArcData(updated) : null;
13588 state.event = event, $$.showTooltip([arcData], this);
13589 }), isTouch && $$.hasArcType() && !$$.radars) {
13590 var getEventArc = function (event) {
13591 var touch = event.changedTouches[0],
13592 eventArc = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.elementFromPoint(touch.clientX, touch.clientY));
13593 return eventArc;
13594 };
13595
13596 $$.$el.svg.on("touchstart touchmove", function (event) {
13597 if (!state.transiting) // skip while transiting
13598 {
13599 var eventArc = getEventArc(event),
13600 datum = eventArc.datum(),
13601 updated = datum && datum.data && datum.data.id ? $$.updateAngle(datum) : null,
13602 arcData = updated ? $$.convertToArcData(updated) : null,
13603 id = arcData && arcData.id || undefined;
13604 $$.callOverOutForTouch(arcData), isUndefined(id) ? unselectArc() : selectArc(this, arcData, id);
13605 }
13606 });
13607 }
13608 },
13609 redrawArcText: function redrawArcText(duration) {
13610 var text,
13611 $$ = this,
13612 config = $$.config,
13613 state = $$.state,
13614 _$$$$el = $$.$el,
13615 main = _$$$$el.main,
13616 arcs = _$$$$el.arcs,
13617 hasGauge = $$.hasType("gauge"),
13618 hasMultiArcGauge = $$.hasMultiArcGauge();
13619
13620 if (hasGauge && $$.data.targets.length === 1 && config.gauge_title || (text = main.selectAll("." + config_classes.chartArc).select("text").style("opacity", "0").attr("class", function (d) {
13621 return $$.isGaugeType(d.data) ? config_classes.gaugeValue : null;
13622 }).call($$.textForArcLabel.bind($$)).attr("transform", $$.transformForArcLabel.bind($$)).style("font-size", function (d) {
13623 return $$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ? Math.round(state.radius / 5) + "px" : null;
13624 }).transition().duration(duration).style("opacity", function (d) {
13625 return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? "1" : "0";
13626 }), hasMultiArcGauge && text.attr("dy", "-.1em")), main.select("." + config_classes.chartArcsTitle).style("opacity", $$.hasType("donut") || hasGauge ? "1" : "0"), hasGauge) {
13627 var isFullCircle = config.gauge_fullCircle;
13628 isFullCircle && text && text.attr("dy", "" + (hasMultiArcGauge ? 0 : Math.round(state.radius / 14))), config.gauge_label_show && (arcs.select("." + config_classes.chartArcsGaugeUnit).attr("dy", (isFullCircle ? 1.5 : .75) + "em").text(config.gauge_units), 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)), !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)));
13629 }
13630 }
13631});
13632;// CONCATENATED MODULE: ./src/ChartInternal/shape/area.ts
13633/**
13634 * Copyright (c) 2017 ~ present NAVER Corp.
13635 * billboard.js project is licensed under the MIT license
13636 */
13637
13638
13639
13640
13641/* harmony default export */ var shape_area = ({
13642 initArea: function initArea(mainLine) {
13643 var $$ = this,
13644 config = $$.config;
13645 mainLine.insert("g", "." + config_classes[config.area_front ? "circles" : "lines"]).attr("class", $$.getClass("areas", !0));
13646 },
13647 updateAreaGradient: function updateAreaGradient() {
13648 var $$ = this,
13649 config = $$.config,
13650 datetimeId = $$.state.datetimeId,
13651 defs = $$.$el.defs;
13652 $$.data.targets.forEach(function (d) {
13653 var id = datetimeId + "-areaGradient" + $$.getTargetSelectorSuffix(d.id);
13654
13655 if ($$.isAreaType(d) && defs.select("#" + id).empty()) {
13656 var color = $$.color(d),
13657 _config$area_linearGr = config.area_linearGradient,
13658 _config$area_linearGr2 = _config$area_linearGr.x,
13659 x = _config$area_linearGr2 === void 0 ? [0, 0] : _config$area_linearGr2,
13660 _config$area_linearGr3 = _config$area_linearGr.y,
13661 y = _config$area_linearGr3 === void 0 ? [0, 1] : _config$area_linearGr3,
13662 _config$area_linearGr4 = _config$area_linearGr.stops,
13663 stops = _config$area_linearGr4 === void 0 ? [[0, color, 1], [1, color, 0]] : _config$area_linearGr4,
13664 linearGradient = defs.append("linearGradient").attr("id", "" + id).attr("x1", x[0]).attr("x2", x[1]).attr("y1", y[0]).attr("y2", y[1]);
13665 stops.forEach(function (v) {
13666 var stopColor = isFunction(v[1]) ? v[1].bind($$.api)(d.id) : v[1];
13667 linearGradient.append("stop").attr("offset", v[0]).attr("stop-color", stopColor || color).attr("stop-opacity", v[2]);
13668 });
13669 }
13670 });
13671 },
13672 updateAreaColor: function updateAreaColor(d) {
13673 var $$ = this;
13674 return $$.config.area_linearGradient ? "url(#" + $$.state.datetimeId + "-areaGradient" + $$.getTargetSelectorSuffix(d.id) + ")" : $$.color(d);
13675 },
13676
13677 /**
13678 * Generate/Update elements
13679 * @param {number} durationForExit Transition duration for exit elements
13680 * @param {boolean} isSub Subchart draw
13681 * @private
13682 */
13683 updateArea: function updateArea(durationForExit, isSub) {
13684 isSub === void 0 && (isSub = !1);
13685 var $$ = this,
13686 config = $$.config,
13687 state = $$.state,
13688 $el = $$.$el,
13689 $root = isSub ? $el.subchart : $el;
13690 config.area_linearGradient && $$.updateAreaGradient();
13691 var area = $root.main.selectAll("." + config_classes.areas).selectAll("." + config_classes.area).data($$.lineData.bind($$));
13692 area.exit().transition().duration(durationForExit).style("opacity", "0").remove(), $root.area = area.enter().append("path").attr("class", $$.getClass("area", !0)).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function () {
13693 return state.orgAreaOpacity = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).style("opacity"), "0";
13694 }).merge(area), area.style("opacity", state.orgAreaOpacity);
13695 },
13696
13697 /**
13698 * Redraw function
13699 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
13700 * @param {boolean} withTransition With or without transition
13701 * @param {boolean} isSub Subchart draw
13702 * @returns {Array}
13703 */
13704 redrawArea: function redrawArea(drawFn, withTransition, isSub) {
13705 isSub === void 0 && (isSub = !1);
13706
13707 var $$ = this,
13708 _ref = isSub ? this.$el.subchart : this.$el,
13709 area = _ref.area,
13710 orgAreaOpacity = $$.state.orgAreaOpacity;
13711
13712 return [(withTransition ? area.transition(getRandom()) : area).attr("d", drawFn).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function (d) {
13713 return ($$.isAreaRangeType(d) ? orgAreaOpacity / 1.75 : orgAreaOpacity) + "";
13714 })];
13715 },
13716
13717 /**
13718 * Generate area path data
13719 * @param {object} areaIndices Indices
13720 * @param {boolean} isSub Weather is sub axis
13721 * @returns {Function}
13722 * @private
13723 */
13724 generateDrawArea: function generateDrawArea(areaIndices, isSub) {
13725 var $$ = this,
13726 config = $$.config,
13727 lineConnectNull = config.line_connectNull,
13728 isRotated = config.axis_rotated,
13729 getPoints = $$.generateGetAreaPoints(areaIndices, isSub),
13730 yScale = $$.getYScaleById.bind($$),
13731 xValue = function (d) {
13732 return (isSub ? $$.subxx : $$.xx).call($$, d);
13733 },
13734 value0 = function (d, i) {
13735 return $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : $$.getShapeYMin(d.id));
13736 },
13737 value1 = function (d, i) {
13738 return $$.isGrouped(d.id) ? getPoints(d, i)[1][1] : yScale(d.id, isSub)($$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : d.value);
13739 };
13740
13741 return function (d) {
13742 var path,
13743 values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
13744 x0 = 0,
13745 y0 = 0;
13746
13747 if ($$.isAreaType(d)) {
13748 var area = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.area)();
13749 area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue) // @ts-ignore
13750 .y0(config.area_above ? 0 : value0).y1(value1), lineConnectNull || (area = area.defined(function (d) {
13751 return $$.getBaseValue(d) !== null;
13752 })), $$.isStepType(d) && (values = $$.convertValuesToStep(values)), path = area.curve($$.getCurve(d))(values);
13753 } else values[0] && (x0 = $$.scale.x(values[0].x), y0 = $$.getYScaleById(d.id)(values[0].value)), path = isRotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
13754
13755 return path || "M 0 0";
13756 };
13757 },
13758 generateGetAreaPoints: function generateGetAreaPoints(areaIndices, isSub) {
13759 // partial duplication of generateGetBarPoints
13760 var $$ = this,
13761 config = $$.config,
13762 x = $$.getShapeX(0, areaIndices, isSub),
13763 y = $$.getShapeY(!!isSub),
13764 areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, isSub),
13765 yScale = $$.getYScaleById.bind($$);
13766 return function (d, i) {
13767 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
13768 offset = areaOffset(d, i) || y0,
13769 posX = x(d),
13770 posY = y(d);
13771 // 1 point that marks the area position
13772 return config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY) && (posY = y0), [[posX, offset], [posX, posY - (y0 - offset)], [posX, posY - (y0 - offset)], // needed for compatibility
13773 [posX, offset] // needed for compatibility
13774 ];
13775 };
13776 }
13777});
13778;// CONCATENATED MODULE: ./src/ChartInternal/shape/bar.ts
13779/**
13780 * Copyright (c) 2017 ~ present NAVER Corp.
13781 * billboard.js project is licensed under the MIT license
13782 */
13783
13784
13785/* harmony default export */ var bar = ({
13786 initBar: function initBar() {
13787 var $el = this.$el;
13788 $el.bar = $el.main.select("." + config_classes.chart) // should positioned at the beginning of the shape node to not overlap others
13789 .insert("g", ":first-child").attr("class", config_classes.chartBars);
13790 },
13791 updateTargetsForBar: function updateTargetsForBar(targets) {
13792 var $$ = this,
13793 config = $$.config,
13794 $el = $$.$el,
13795 classChartBar = $$.getChartClass("Bar"),
13796 classBars = $$.getClass("bars", !0),
13797 classFocus = $$.classFocus.bind($$),
13798 isSelectable = config.interaction_enabled && config.data_selection_isselectable;
13799 $el.bar || $$.initBar();
13800 var mainBarUpdate = $$.$el.main.select("." + config_classes.chartBars).selectAll("." + config_classes.chartBar).data(targets).attr("class", function (d) {
13801 return classChartBar(d) + classFocus(d);
13802 }),
13803 mainBarEnter = mainBarUpdate.enter().append("g").attr("class", classChartBar).style("opacity", "0").style("pointer-events", "none");
13804 // Bars for each data
13805 mainBarEnter.append("g").attr("class", classBars).style("cursor", function (d) {
13806 return isSelectable && isSelectable.bind($$.api)(d) ? "pointer" : null;
13807 });
13808 },
13809
13810 /**
13811 * Generate/Update elements
13812 * @param {number} durationForExit Transition duration for exit elements
13813 * @param {boolean} isSub Subchart draw
13814 * @private
13815 */
13816 updateBar: function updateBar(durationForExit, isSub) {
13817 isSub === void 0 && (isSub = !1);
13818 var $$ = this,
13819 $root = isSub ? $$.$el.subchart : $$.$el,
13820 classBar = $$.getClass("bar", !0),
13821 initialOpacity = $$.initialOpacity.bind($$),
13822 bar = $root.main.selectAll("." + config_classes.bars).selectAll("." + config_classes.bar).data($$.labelishData.bind($$));
13823 bar.exit().transition().duration(durationForExit).style("opacity", "0").remove(), $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.color).merge(bar).style("opacity", initialOpacity);
13824 },
13825
13826 /**
13827 * Redraw function
13828 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
13829 * @param {boolean} withTransition With or without transition
13830 * @param {boolean} isSub Subchart draw
13831 * @returns {Array}
13832 */
13833 redrawBar: function redrawBar(drawFn, withTransition, isSub) {
13834 isSub === void 0 && (isSub = !1);
13835
13836 var _ref = isSub ? this.$el.subchart : this.$el,
13837 bar = _ref.bar;
13838
13839 return [(withTransition ? bar.transition(getRandom()) : bar).attr("d", drawFn).style("fill", this.color).style("opacity", "1")];
13840 },
13841 getBars: function getBars(i, id) {
13842 var $$ = this,
13843 main = $$.$el.main,
13844 suffix = isValue(i) ? "-" + i : "";
13845 return (id ? main.selectAll("." + config_classes.bars + $$.getTargetSelectorSuffix(id)) : main).selectAll("." + config_classes.bar + suffix);
13846 },
13847 expandBars: function expandBars(i, id, reset) {
13848 var $$ = this;
13849 reset && $$.unexpandBars(), $$.getBars(i, id).classed(config_classes.EXPANDED, !0);
13850 },
13851 unexpandBars: function unexpandBars(i) {
13852 this.getBars(i).classed(config_classes.EXPANDED, !1);
13853 },
13854 generateDrawBar: function generateDrawBar(barIndices, isSub) {
13855 var $$ = this,
13856 config = $$.config,
13857 getPoints = $$.generateGetBarPoints(barIndices, isSub),
13858 isRotated = config.axis_rotated,
13859 isGrouped = config.data_groups.length,
13860 barRadius = config.bar_radius,
13861 barRadiusRatio = config.bar_radius_ratio,
13862 getRadius = isNumber(barRadius) && barRadius > 0 ? function () {
13863 return barRadius;
13864 } : isNumber(barRadiusRatio) ? function (w) {
13865 return w * barRadiusRatio;
13866 } : null;
13867 return function (d, i) {
13868 // 4 points that make a bar
13869 var points = getPoints(d, i),
13870 indexX = +isRotated,
13871 indexY = +!indexX,
13872 isNegative = d.value < 0,
13873 pathRadius = ["", ""],
13874 radius = 0; // switch points if axis is rotated, not applicable for sub chart
13875
13876 if (getRadius && !isGrouped) {
13877 var index = isRotated ? indexY : indexX,
13878 barW = points[2][index] - points[0][index];
13879 radius = getRadius(barW);
13880 var arc = "a" + radius + "," + radius + " " + (isNegative ? "1 0 0" : "0 0 1") + " ";
13881 pathRadius[+!isRotated] = "" + arc + radius + "," + radius, pathRadius[+isRotated] = "" + arc + [-radius, radius][isRotated ? "sort" : "reverse"](), isNegative && pathRadius.reverse();
13882 } // path string data shouldn't be containing new line chars
13883 // https://github.com/naver/billboard.js/issues/530
13884
13885
13886 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];
13887 return "M" + points[0][indexX] + "," + points[0][indexY] + path + "z";
13888 };
13889 },
13890 generateGetBarPoints: function generateGetBarPoints(barIndices, isSub) {
13891 var $$ = this,
13892 config = $$.config,
13893 axis = isSub ? $$.axis.subX : $$.axis.x,
13894 barTargetsNum = $$.getIndicesMax(barIndices) + 1,
13895 barW = $$.getBarW("bar", axis, barTargetsNum),
13896 barX = $$.getShapeX(barW, barIndices, !!isSub),
13897 barY = $$.getShapeY(!!isSub),
13898 barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub),
13899 yScale = $$.getYScaleById.bind($$);
13900 return function (d, i) {
13901 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
13902 offset = barOffset(d, i) || y0,
13903 width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
13904 posX = barX(d),
13905 posY = barY(d);
13906 config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY) && (posY = y0), posY -= y0 - offset;
13907 var startPosX = posX + width; // 4 points that make a bar
13908
13909 return [[posX, offset], [posX, posY], [startPosX, posY], [startPosX, offset]];
13910 };
13911 },
13912 isWithinBar: function isWithinBar(that) {
13913 var mouse = getPointer(this.state.event, that),
13914 list = getRectSegList(that),
13915 _list = list,
13916 seg0 = _list[0],
13917 seg1 = _list[1],
13918 x = Math.min(seg0.x, seg1.x),
13919 y = Math.min(seg0.y, seg1.y),
13920 offset = this.config.bar_sensitivity,
13921 _that$getBBox = that.getBBox(),
13922 width = _that$getBBox.width,
13923 height = _that$getBBox.height,
13924 isWithin = x - offset < mouse[0] && mouse[0] < x + width + offset && y - offset < mouse[1] && mouse[1] < y + height + offset;
13925
13926 return isWithin;
13927 }
13928});
13929;// CONCATENATED MODULE: ./src/ChartInternal/shape/candlestick.ts
13930
13931
13932function candlestick_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13933
13934function candlestick_objectSpread(target) { for (var source, i = 1; i < arguments.length; i++) source = arguments[i] == null ? {} : arguments[i], i % 2 ? candlestick_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : candlestick_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); return target; }
13935
13936/**
13937 * Copyright (c) 2017 ~ present NAVER Corp.
13938 * billboard.js project is licensed under the MIT license
13939 */
13940
13941
13942
13943/* harmony default export */ var candlestick = ({
13944 initCandlestick: function initCandlestick() {
13945 var $el = this.$el;
13946 $el.candlestick = $el.main.select("." + config_classes.chart) // should positioned at the beginning of the shape node to not overlap others
13947 .append("g").attr("class", config_classes.chartCandlesticks);
13948 },
13949
13950 /**
13951 * Update targets by its data
13952 * called from: ChartInternal.updateTargets()
13953 * @param {Array} targets Filtered target by type
13954 * @private
13955 */
13956 updateTargetsForCandlestick: function updateTargetsForCandlestick(targets) {
13957 var $$ = this,
13958 $el = $$.$el,
13959 classChart = $$.getChartClass("Candlestick"),
13960 classFocus = $$.classFocus.bind($$);
13961 $el.candlestick || $$.initCandlestick();
13962 var mainUpdate = $$.$el.main.select("." + config_classes.chartCandlesticks).selectAll("." + config_classes.chartCandlestick).data(targets).attr("class", function (d) {
13963 return classChart(d) + classFocus(d);
13964 });
13965 mainUpdate.enter().append("g").attr("class", classChart).style("pointer-events", "none");
13966 },
13967
13968 /**
13969 * Generate/Update elements
13970 * @param {number} durationForExit Transition duration for exit elements
13971 * @param {boolean} isSub Subchart draw
13972 * @private
13973 */
13974 updateCandlestick: function updateCandlestick(durationForExit, isSub) {
13975 isSub === void 0 && (isSub = !1);
13976 var $$ = this,
13977 $el = $$.$el,
13978 $root = isSub ? $el.subchart : $el,
13979 classSetter = $$.getClass("candlestick", !0),
13980 initialOpacity = $$.initialOpacity.bind($$),
13981 candlestick = $root.main.selectAll("." + config_classes.chartCandlestick).selectAll("." + config_classes.candlestick).data($$.labelishData.bind($$));
13982 candlestick.exit().transition().duration(durationForExit).style("opacity", "0").remove();
13983 var candlestickEnter = candlestick.enter().filter(function (d) {
13984 return d.value;
13985 }).append("g").attr("class", classSetter);
13986 candlestickEnter.append("line"), candlestickEnter.append("path"), $root.candlestick || ($root.candlestick = {}), $root.candlestick = candlestick.merge(candlestickEnter).style("opacity", initialOpacity);
13987 },
13988
13989 /**
13990 * Get draw function
13991 * @param {object} indices Indice data
13992 * @param {boolean} isSub Subchart draw
13993 * @returns {Function}
13994 * @private
13995 */
13996 generateDrawCandlestick: function generateDrawCandlestick(indices, isSub) {
13997 var $$ = this,
13998 config = $$.config,
13999 getPoints = $$.generateGetCandlestickPoints(indices, isSub),
14000 isRotated = config.axis_rotated,
14001 downColor = config.candlestick_color_down;
14002 return function (d, i, g) {
14003 var _value,
14004 points = getPoints(d, i),
14005 value = $$.getCandlestickData(d),
14006 isUp = (_value = value) == null ? void 0 : _value._isUp,
14007 indexX = +isRotated;
14008
14009 g.classed && g.classed(config_classes[isUp ? "valueUp" : "valueDown"], !0);
14010 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];
14011 g.select("path").attr("d", "M" + points[0][indexX] + "," + points[0][+!indexX] + path + "z").style("fill", function (d) {
14012 var color = isUp ? $$.color(d) : isObject(downColor) ? downColor[d.id] : downColor;
14013 return color || $$.color(d);
14014 });
14015 // set line position
14016 var line = g.select("line"),
14017 pos = isRotated ? {
14018 x1: points[2][1],
14019 x2: points[2][2],
14020 y1: points[2][0],
14021 y2: points[2][0]
14022 } : {
14023 x1: points[2][0],
14024 x2: points[2][0],
14025 y1: points[2][1],
14026 y2: points[2][2]
14027 };
14028
14029 for (var x in pos) line.attr(x, pos[x]);
14030 };
14031 },
14032
14033 /**
14034 * Generate shape drawing points
14035 * @param {object} indices Indice data
14036 * @param {boolean} isSub Subchart draw
14037 * @returns {Function}
14038 */
14039 generateGetCandlestickPoints: function generateGetCandlestickPoints(indices, isSub) {
14040 isSub === void 0 && (isSub = !1);
14041 var $$ = this,
14042 config = $$.config,
14043 axis = isSub ? $$.axis.subX : $$.axis.x,
14044 targetsNum = $$.getIndicesMax(indices) + 1,
14045 barW = $$.getBarW("candlestick", axis, targetsNum),
14046 x = $$.getShapeX(barW, indices, !!isSub),
14047 y = $$.getShapeY(!!isSub),
14048 shapeOffset = $$.getShapeOffset($$.isBarType, indices, !!isSub),
14049 yScale = $$.getYScaleById.bind($$);
14050 return function (d, i) {
14051 var points,
14052 y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
14053 offset = shapeOffset(d, i) || y0,
14054 width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
14055 value = $$.getCandlestickData(d);
14056
14057 if (value) {
14058 var posX = {
14059 start: x(d),
14060 end: 0
14061 };
14062 posX.end = posX.start + width;
14063 var posY = {
14064 start: y(value.open),
14065 end: y(value.close)
14066 },
14067 posLine = {
14068 x: posX.start + width / 2,
14069 high: y(value.high),
14070 low: y(value.low)
14071 };
14072 config.axis_rotated && (d.value > 0 && posY.start < y0 || d.value < 0 && y0 < posY.start) && (posY.start = y0), posY.start -= y0 - offset, points = [[posX.start, posY.start], [posX.end, posY.end], [posLine.x, posLine.low, posLine.high]];
14073 } else points = [[0, 0], [0, 0], [0, 0, 0]];
14074
14075 return points;
14076 };
14077 },
14078
14079 /**
14080 * Redraw function
14081 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
14082 * @param {boolean} withTransition With or without transition
14083 * @param {boolean} isSub Subchart draw
14084 * @returns {Array}
14085 */
14086 redrawCandlestick: function redrawCandlestick(drawFn, withTransition, isSub) {
14087 isSub === void 0 && (isSub = !1);
14088
14089 var _ref = isSub ? this.$el.subchart : this.$el,
14090 candlestick = _ref.candlestick,
14091 rand = getRandom(!0);
14092
14093 return [candlestick.each(function (d, i) {
14094 var g = withTransition ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).transition(rand) : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
14095 drawFn(d, i, g);
14096 }).style("opacity", "1")];
14097 },
14098
14099 /**
14100 * Get candlestick data as object
14101 * @param {object} param Data object
14102 * @param {Array|object} param.value Data value
14103 * @returns {object|null} Converted data object
14104 * @private
14105 */
14106 getCandlestickData: function getCandlestickData(_ref2) {
14107 var d,
14108 value = _ref2.value;
14109
14110 if (isArray(value)) {
14111 var open = value[0],
14112 high = value[1],
14113 low = value[2],
14114 close = value[3],
14115 _value$ = value[4],
14116 volume = _value$ !== void 0 && _value$;
14117 d = {
14118 open: open,
14119 high: high,
14120 low: low,
14121 close: close
14122 }, volume !== !1 && (d.volume = volume);
14123 } else isObject(value) && (d = candlestick_objectSpread({}, value));
14124
14125 return d && (d._isUp = d.close >= d.open), d || null;
14126 }
14127});
14128;// CONCATENATED MODULE: ./src/ChartInternal/shape/gauge.ts
14129/**
14130 * Copyright (c) 2017 ~ present NAVER Corp.
14131 * billboard.js project is licensed under the MIT license
14132 */
14133
14134
14135
14136/* harmony default export */ var gauge = ({
14137 initGauge: function initGauge() {
14138 var $$ = this,
14139 config = $$.config,
14140 arcs = $$.$el.arcs,
14141 appendText = function (className) {
14142 arcs.append("text").attr("class", className).style("text-anchor", "middle").style("pointer-events", "none");
14143 };
14144
14145 if ($$.hasType("gauge")) {
14146 var hasMulti = $$.hasMultiArcGauge();
14147 arcs.append(hasMulti ? "g" : "path").attr("class", config_classes.chartArcsBackground).style("fill", !hasMulti && config.gauge_background || null), config.gauge_units && appendText(config_classes.chartArcsGaugeUnit), config.gauge_label_show && (appendText(config_classes.chartArcsGaugeMin), !config.gauge_fullCircle && appendText(config_classes.chartArcsGaugeMax));
14148 }
14149 },
14150 updateGaugeMax: function updateGaugeMax() {
14151 var $$ = this,
14152 config = $$.config,
14153 state = $$.state,
14154 hasMultiGauge = $$.hasMultiArcGauge(),
14155 max = hasMultiGauge ? $$.getMinMaxData().max[0].value : $$.getTotalDataSum(state.rendered);
14156 max > config.gauge_max && (config.gauge_max = max);
14157 },
14158 redrawMultiArcGauge: function redrawMultiArcGauge() {
14159 var $$ = this,
14160 config = $$.config,
14161 state = $$.state,
14162 $el = $$.$el,
14163 hiddenTargetIds = $$.state.hiddenTargetIds,
14164 arcLabelLines = $el.main.selectAll("." + config_classes.arcs).selectAll("." + config_classes.arcLabelLine).data($$.arcData.bind($$)),
14165 mainArcLabelLine = arcLabelLines.enter().append("rect").attr("class", function (d) {
14166 return config_classes.arcLabelLine + " " + config_classes.target + " " + config_classes.target + "-" + d.data.id;
14167 }).merge(arcLabelLines);
14168 mainArcLabelLine.style("fill", function (d) {
14169 return $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data);
14170 }).style("display", config.gauge_label_show ? "" : "none").each(function (d) {
14171 var lineLength = 0,
14172 lineThickness = 2,
14173 x = 0,
14174 y = 0,
14175 transform = "";
14176
14177 if (hiddenTargetIds.indexOf(d.data.id) < 0) {
14178 var updated = $$.updateAngle(d),
14179 innerLineLength = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length * (updated.index + 1),
14180 lineAngle = updated.endAngle - Math.PI / 2,
14181 arcInnerRadius = state.radius - innerLineLength,
14182 linePositioningAngle = lineAngle - (arcInnerRadius === 0 ? 0 : 1 / arcInnerRadius);
14183 lineLength = state.radiusExpanded - state.radius + innerLineLength, x = Math.cos(linePositioningAngle) * arcInnerRadius, y = Math.sin(linePositioningAngle) * arcInnerRadius, transform = "rotate(" + lineAngle * 180 / Math.PI + ", " + x + ", " + y + ")";
14184 }
14185
14186 (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");
14187 });
14188 },
14189 textForGaugeMinMax: function textForGaugeMinMax(value, isMax) {
14190 var $$ = this,
14191 config = $$.config,
14192 format = config.gauge_label_extents;
14193 return isFunction(format) ? format.bind($$.api)(value, isMax) : value;
14194 },
14195 getGaugeLabelHeight: function getGaugeLabelHeight() {
14196 var config = this.config;
14197 return this.config.gauge_label_show && !config.gauge_fullCircle ? 20 : 0;
14198 },
14199 getPaddingBottomForGauge: function getPaddingBottomForGauge() {
14200 var $$ = this;
14201 return $$.getGaugeLabelHeight() * ($$.config.gauge_label_show ? 2 : 2.5);
14202 }
14203});
14204;// CONCATENATED MODULE: ./src/ChartInternal/shape/bubble.ts
14205/**
14206 * Copyright (c) 2017 ~ present NAVER Corp.
14207 * billboard.js project is licensed under the MIT license
14208 */
14209
14210
14211/* harmony default export */ var bubble = ({
14212 /**
14213 * Initializer
14214 * @private
14215 */
14216 initBubble: function initBubble() {
14217 var $$ = this,
14218 config = $$.config;
14219 $$.hasType("bubble") && (config.point_show = !0, config.point_type = "circle", config.point_sensitivity = 25);
14220 },
14221
14222 /**
14223 * Get user agent's computed value
14224 * @returns {number}
14225 * @private
14226 */
14227 getBaseLength: function getBaseLength() {
14228 var $$ = this,
14229 _$$$state = $$.state,
14230 width = _$$$state.width,
14231 height = _$$$state.height,
14232 cacheKey = KEY.bubbleBaseLength,
14233 baseLength = $$.cache.get(cacheKey);
14234 return baseLength || $$.cache.add(cacheKey, baseLength = getMinMax("min", [width, height])), baseLength;
14235 },
14236
14237 /**
14238 * Get the radius value for bubble circle
14239 * @param {object} d Data object
14240 * @returns {number}
14241 * @private
14242 */
14243 getBubbleR: function getBubbleR(d) {
14244 var $$ = this,
14245 maxR = $$.config.bubble_maxR;
14246 isFunction(maxR) ? maxR = maxR.bind($$.api)(d) : !isNumber(maxR) && (maxR = $$.getBaseLength() / ($$.getMaxDataCount() * 2) + 12);
14247 var max = getMinMax("max", $$.getMinMaxData().max.map(function (d) {
14248 return $$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "y") : isObject(d.value) ? d.value.mid : d.value;
14249 })),
14250 maxArea = maxR * maxR * Math.PI,
14251 area = ($$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "z") : d.value) * (maxArea / max);
14252 return Math.sqrt(area / Math.PI);
14253 },
14254
14255 /**
14256 * Get bubble dimension data
14257 * @param {object|Array} d data value
14258 * @param {string} type - y or z
14259 * @returns {number}
14260 * @private
14261 */
14262 getBubbleZData: function getBubbleZData(d, type) {
14263 return isObject(d) ? d[type] : d[type === "y" ? 0 : 1];
14264 }
14265});
14266;// CONCATENATED MODULE: ./src/ChartInternal/shape/line.ts
14267/**
14268 * Copyright (c) 2017 ~ present NAVER Corp.
14269 * billboard.js project is licensed under the MIT license
14270 */
14271
14272
14273
14274
14275/* harmony default export */ var line = ({
14276 initLine: function initLine() {
14277 var $el = this.$el;
14278 $el.line = $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartLines);
14279 },
14280 updateTargetsForLine: function updateTargetsForLine(t) {
14281 var $$ = this,
14282 _$$$$el = $$.$el,
14283 area = _$$$$el.area,
14284 line = _$$$$el.line,
14285 main = _$$$$el.main,
14286 classChartLine = $$.getChartClass("Line"),
14287 classLines = $$.getClass("lines", !0),
14288 classFocus = $$.classFocus.bind($$);
14289 line || $$.initLine();
14290 var targets = t.filter(function (d) {
14291 return !($$.isScatterType(d) || $$.isBubbleType(d));
14292 }),
14293 mainLineUpdate = main.select("." + config_classes.chartLines).selectAll("." + config_classes.chartLine).data(targets).attr("class", function (d) {
14294 return classChartLine(d) + classFocus(d);
14295 }),
14296 mainLineEnter = mainLineUpdate.enter().append("g").attr("class", classChartLine).style("opacity", "0").style("pointer-events", "none");
14297 // Lines for each data
14298 mainLineEnter.append("g").attr("class", classLines), $$.hasTypeOf("Area") && $$.initArea(!area && mainLineEnter.empty() ? mainLineUpdate : mainLineEnter), $$.updateTargetForCircle(targets, mainLineEnter);
14299 },
14300
14301 /**
14302 * Generate/Update elements
14303 * @param {number} durationForExit Transition duration for exit elements
14304 * @param {boolean} isSub Subchart draw
14305 * @private
14306 */
14307 updateLine: function updateLine(durationForExit, isSub) {
14308 isSub === void 0 && (isSub = !1);
14309 var $$ = this,
14310 extraLineClasses = $$.format.extraLineClasses,
14311 $el = $$.$el,
14312 $root = isSub ? $el.subchart : $el,
14313 line = $root.main.selectAll("." + config_classes.lines).selectAll("." + config_classes.line).data($$.lineData.bind($$));
14314 line.exit().transition().duration(durationForExit).style("opacity", "0").remove(), $root.line = line.enter().append("path").attr("class", function (d) {
14315 return $$.getClass("line", !0)(d) + " " + (extraLineClasses(d) || "");
14316 }).style("stroke", $$.color).merge(line).style("opacity", $$.initialOpacity.bind($$)).style("shape-rendering", function (d) {
14317 return $$.isStepType(d) ? "crispEdges" : "";
14318 }).attr("transform", null);
14319 },
14320
14321 /**
14322 * Redraw function
14323 * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
14324 * @param {boolean} withTransition With or without transition
14325 * @param {boolean} isSub Subchart draw
14326 * @returns {Array}
14327 */
14328 redrawLine: function redrawLine(drawFn, withTransition, isSub) {
14329 isSub === void 0 && (isSub = !1);
14330
14331 var _ref = isSub ? this.$el.subchart : this.$el,
14332 line = _ref.line;
14333
14334 return [(withTransition ? line.transition(getRandom()) : line).attr("d", drawFn).style("stroke", this.color).style("opacity", "1")];
14335 },
14336
14337 /**
14338 * Get the curve interpolate
14339 * @param {Array} d Data object
14340 * @returns {Function}
14341 * @private
14342 */
14343 getCurve: function getCurve(d) {
14344 var $$ = this,
14345 isRotatedStepType = $$.config.axis_rotated && $$.isStepType(d);
14346 // when is step & rotated, should be computed in different way
14347 // https://github.com/naver/billboard.js/issues/471
14348 return isRotatedStepType ? function (context) {
14349 var step = $$.getInterpolate(d)(context); // keep the original method
14350
14351 return step.orgPoint = step.point, step.pointRotated = function (x, y) {
14352 this._point === 1 && (this._point = 2);
14353 var y1 = this._y * (1 - this._t) + y * this._t;
14354 this._context.lineTo(this._x, y1), this._context.lineTo(x, y1), this._x = x, this._y = y;
14355 }, step.point = function (x, y) {
14356 this._point === 0 ? this.orgPoint(x, y) : this.pointRotated(x, y);
14357 }, step;
14358 } : $$.getInterpolate(d);
14359 },
14360 generateDrawLine: function generateDrawLine(lineIndices, isSub) {
14361 var $$ = this,
14362 config = $$.config,
14363 scale = $$.scale,
14364 lineConnectNull = config.line_connectNull,
14365 isRotated = config.axis_rotated,
14366 getPoints = $$.generateGetLinePoints(lineIndices, isSub),
14367 yScale = $$.getYScaleById.bind($$),
14368 xValue = function (d) {
14369 return (isSub ? $$.subxx : $$.xx).call($$, d);
14370 },
14371 yValue = function (d, i) {
14372 return $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.getBaseValue(d));
14373 },
14374 line = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.line)();
14375
14376 line = isRotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue), lineConnectNull || (line = line.defined(function (d) {
14377 return $$.getBaseValue(d) !== null;
14378 }));
14379 var x = isSub ? scale.subX : scale.x;
14380 return function (d) {
14381 var path,
14382 y = yScale(d.id, isSub),
14383 values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
14384 x0 = 0,
14385 y0 = 0;
14386
14387 if ($$.isLineType(d)) {
14388 var regions = config.data_regions[d.id];
14389 regions ? path = $$.lineWithRegions(values, x, y, regions) : ($$.isStepType(d) && (values = $$.convertValuesToStep(values)), path = line.curve($$.getCurve(d))(values));
14390 } else values[0] && (x0 = x(values[0].x), y0 = y(values[0].value)), path = isRotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
14391
14392 return path || "M 0 0";
14393 };
14394 },
14395 lineWithRegions: function lineWithRegions(d, x, y, _regions) {
14396 var xp,
14397 yp,
14398 diff,
14399 diffx2,
14400 $$ = this,
14401 config = $$.config,
14402 isRotated = config.axis_rotated,
14403 isTimeSeries = $$.axis.isTimeSeries(),
14404 xOffset = $$.axis.isCategorized() ? .5 : 0,
14405 regions = [],
14406 dasharray = "2 2",
14407 isWithinRegions = function (withinX, withinRegions) {
14408 for (var reg, i = 0; reg = withinRegions[i]; i++) if (reg.start < withinX && withinX <= reg.end) return reg.style;
14409
14410 return !1;
14411 };
14412
14413 // Check start/end of regions
14414 if (isDefined(_regions)) {
14415 var getValue = function (v, def) {
14416 return isUndefined(v) ? def : isTimeSeries ? parseDate.call($$, v) : v;
14417 };
14418
14419 for (var reg, i = 0; reg = _regions[i]; i++) {
14420 var start = getValue(reg.start, d[0].x),
14421 end = getValue(reg.end, d[d.length - 1].x),
14422 style = reg.style || {
14423 dasharray: dasharray
14424 };
14425 regions[i] = {
14426 start: start,
14427 end: end,
14428 style: style
14429 };
14430 }
14431 } // Set scales
14432
14433
14434 var xValue = isRotated ? function (dt) {
14435 return y(dt.value);
14436 } : function (dt) {
14437 return x(dt.x);
14438 },
14439 yValue = isRotated ? function (dt) {
14440 return x(dt.x);
14441 } : function (dt) {
14442 return y(dt.value);
14443 },
14444 generateM = function (points) {
14445 return "M" + points[0][0] + "," + points[0][1] + "L" + points[1][0] + "," + points[1][1];
14446 },
14447 sWithRegion = isTimeSeries ? function (d0, d1, k, timeseriesDiff) {
14448 var x0 = d0.x.getTime(),
14449 xDiff = d1.x - d0.x,
14450 xv0 = new Date(x0 + xDiff * k),
14451 xv1 = new Date(x0 + xDiff * (k + timeseriesDiff)),
14452 points = isRotated ? [[y(yp(k)), x(xv0)], [y(yp(k + diff)), x(xv1)]] : [[x(xv0), y(yp(k))], [x(xv1), y(yp(k + diff))]];
14453 return generateM(points);
14454 } : function (d0, d1, k, otherDiff) {
14455 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))]];
14456 return generateM(points);
14457 },
14458 axisType = {
14459 x: $$.axis.getAxisType("x"),
14460 y: $$.axis.getAxisType("y")
14461 },
14462 path = "";
14463
14464 for (var data, _i = 0; data = d[_i]; _i++) {
14465 var prevData = d[_i - 1],
14466 hasPrevData = prevData && isValue(prevData.value),
14467 style = isWithinRegions(data.x, regions);
14468 // https://github.com/naver/billboard.js/issues/1172
14469 if (isValue(data.value)) // Draw as normal
14470 if (isUndefined(regions) || !style || !hasPrevData) path += "" + (_i && hasPrevData ? "L" : "M") + xValue(data) + "," + yValue(data);else if (hasPrevData) {
14471 try {
14472 style = style.dasharray.split(" ");
14473 } catch (e) {
14474 style = dasharray.split(" ");
14475 } // Draw with region // TODO: Fix for horizotal charts
14476
14477
14478 xp = getScale(axisType.x, prevData.x + xOffset, data.x + xOffset), yp = getScale(axisType.y, prevData.value, data.value);
14479 var dx = x(data.x) - x(prevData.x),
14480 dy = y(data.value) - y(prevData.value),
14481 dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
14482 diff = style[0] / dd, diffx2 = diff * style[1];
14483
14484 for (var _j = diff; _j <= 1; _j += diffx2) path += sWithRegion(prevData, data, _j, diff), _j + diffx2 >= 1 && (path += sWithRegion(prevData, data, 1, 0));
14485 }
14486 }
14487
14488 return path;
14489 },
14490 isWithinStep: function isWithinStep(that, y) {
14491 return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
14492 },
14493 shouldDrawPointsForLine: function shouldDrawPointsForLine(d) {
14494 var linePoint = this.config.line_point;
14495 return linePoint === !0 || isArray(linePoint) && linePoint.indexOf(d.id) !== -1;
14496 }
14497});
14498;// CONCATENATED MODULE: ./src/ChartInternal/shape/point.ts
14499/**
14500 * Copyright (c) 2017 ~ present NAVER Corp.
14501 * billboard.js project is licensed under the MIT license
14502 */
14503
14504
14505
14506
14507
14508var getTransitionName = function () {
14509 return getRandom();
14510};
14511
14512/* harmony default export */ var point = ({
14513 hasValidPointType: function hasValidPointType(type) {
14514 return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
14515 },
14516 hasValidPointDrawMethods: function hasValidPointDrawMethods(type) {
14517 var pointType = type || this.config.point_type;
14518 return isObjectType(pointType) && isFunction(pointType.create) && isFunction(pointType.update);
14519 },
14520 initialOpacityForCircle: function initialOpacityForCircle(d) {
14521 var config = this.config,
14522 withoutFadeIn = this.state.withoutFadeIn,
14523 opacity = config.point_opacity;
14524 return isUndefined(opacity) && (opacity = this.getBaseValue(d) !== null && withoutFadeIn[d.id] ? this.opacityForCircle(d) : "0"), opacity;
14525 },
14526 opacityForCircle: function opacityForCircle(d) {
14527 var config = this.config,
14528 opacity = config.point_opacity;
14529 return isUndefined(opacity) && (opacity = config.point_show && !config.point_focus_only ? "1" : "0", opacity = isValue(this.getBaseValue(d)) ? this.isBubbleType(d) || this.isScatterType(d) ? "0.5" : opacity : "0"), opacity;
14530 },
14531 initCircle: function initCircle() {
14532 var $$ = this,
14533 main = $$.$el.main;
14534 $$.point = $$.generatePoint(), ($$.hasType("bubble") || $$.hasType("scatter")) && main.select("." + config_classes.chartCircles).empty() && main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartCircles);
14535 },
14536 updateTargetForCircle: function updateTargetForCircle(targetsValue, enterNodeValue) {
14537 var _this = this,
14538 $$ = this,
14539 config = $$.config,
14540 data = $$.data,
14541 $el = $$.$el,
14542 selectionEnabled = config.interaction_enabled && config.data_selection_enabled,
14543 isSelectable = selectionEnabled && config.data_selection_isselectable,
14544 classCircles = $$.getClass("circles", !0);
14545
14546 if (config.point_show) {
14547 $el.circle || $$.initCircle();
14548 var targets = targetsValue,
14549 enterNode = enterNodeValue;
14550
14551 // only for scatter & bubble type should generate seprate <g> node
14552 if (!targets) {
14553 targets = data.targets.filter(function (d) {
14554 return _this.isScatterType(d) || _this.isBubbleType(d);
14555 });
14556 var mainCircle = $el.main.select("." + config_classes.chartCircles).style("pointer-events", "none").selectAll("." + config_classes.circles).data(targets).attr("class", classCircles);
14557 mainCircle.exit().remove(), enterNode = mainCircle.enter();
14558 } // Circles for each data point on lines
14559
14560
14561 selectionEnabled && enterNode.append("g").attr("class", function (d) {
14562 return $$.generateClass(config_classes.selectedCircles, d.id);
14563 }), enterNode.append("g").attr("class", classCircles).style("cursor", function (d) {
14564 return isSelectable && isSelectable(d) ? "pointer" : null;
14565 }), selectionEnabled && targets.forEach(function (t) {
14566 $el.main.selectAll("." + config_classes.selectedCircles + $$.getTargetSelectorSuffix(t.id)).selectAll("" + config_classes.selectedCircle).each(function (d) {
14567 d.value = t.values[d.index].value;
14568 });
14569 });
14570 }
14571 },
14572 updateCircle: function updateCircle(isSub) {
14573 isSub === void 0 && (isSub = !1);
14574 var $$ = this,
14575 config = $$.config,
14576 state = $$.state,
14577 $el = $$.$el,
14578 focusOnly = config.point_focus_only,
14579 $root = isSub ? $el.subchart : $el;
14580
14581 if (config.point_show && !state.toggling) {
14582 var circles = $root.main.selectAll("." + config_classes.circles).selectAll("." + config_classes.circle).data(function (d) {
14583 return $$.isLineType(d) && $$.shouldDrawPointsForLine(d) || $$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ? focusOnly ? [d.values[0]] : d.values : [];
14584 });
14585 circles.exit().remove(), circles.enter().filter(Boolean).append($$.point("create", this, $$.pointR.bind($$), $$.color)), $root.circle = $root.main.selectAll("." + config_classes.circles + " ." + config_classes.circle).style("stroke", $$.color).style("opacity", $$.initialOpacityForCircle.bind($$));
14586 }
14587 },
14588 redrawCircle: function redrawCircle(cx, cy, withTransition, flow, isSub) {
14589 isSub === void 0 && (isSub = !1);
14590 var $$ = this,
14591 rendered = $$.state.rendered,
14592 $el = $$.$el,
14593 $root = isSub ? $el.subchart : $el,
14594 selectedCircles = $root.main.selectAll("." + config_classes.selectedCircle);
14595 if (!$$.config.point_show) return [];
14596 var fn = $$.point("update", $$, cx, cy, $$.color, withTransition, flow, selectedCircles),
14597 posAttr = $$.isCirclePoint() ? "c" : "",
14598 t = getRandom(),
14599 opacityStyleFn = $$.opacityForCircle.bind($$),
14600 mainCircles = [];
14601 return $root.circle.each(function (d) {
14602 var result = fn.bind(this)(d);
14603 result = (withTransition || !rendered ? result.transition(t) : result).style("opacity", opacityStyleFn), mainCircles.push(result);
14604 }), [mainCircles, (withTransition ? selectedCircles.transition() : selectedCircles).attr(posAttr + "x", cx).attr(posAttr + "y", cy)];
14605 },
14606
14607 /**
14608 * Show focused data point circle
14609 * @param {object} d Selected data
14610 * @private
14611 */
14612 showCircleFocus: function showCircleFocus(d) {
14613 var $$ = this,
14614 config = $$.config,
14615 _$$$state = $$.state,
14616 hasRadar = _$$$state.hasRadar,
14617 resizing = _$$$state.resizing,
14618 toggling = _$$$state.toggling,
14619 transiting = _$$$state.transiting,
14620 $el = $$.$el,
14621 circle = $el.circle;
14622
14623 if (transiting === !1 && config.point_focus_only && circle) {
14624 var cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$),
14625 cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$),
14626 withTransition = toggling || isUndefined(d),
14627 fn = $$.point("update", $$, cx, cy, $$.color, !resizing && withTransition);
14628 d && (circle = circle.filter(function (t) {
14629 var data = d.filter(function (v) {
14630 return v.id === t.id;
14631 });
14632 return !!data.length && (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).datum(data[0]);
14633 })), circle.attr("class", this.updatePointClass.bind(this)).style("opacity", "1").each(function (d) {
14634 var id = d.id,
14635 index = d.index,
14636 value = d.value,
14637 visibility = "hidden";
14638 isValue(value) && (fn.bind(this)(d), $$.expandCircles(index, id), visibility = ""), this.style.visibility = visibility;
14639 });
14640 }
14641 },
14642
14643 /**
14644 * Hide focused data point circle
14645 * @private
14646 */
14647 hideCircleFocus: function hideCircleFocus() {
14648 var $$ = this,
14649 config = $$.config,
14650 circle = $$.$el.circle;
14651 config.point_focus_only && circle && ($$.unexpandCircles(), circle.style("visibility", "hidden"));
14652 },
14653 circleX: function circleX(d) {
14654 return this.xx(d);
14655 },
14656 updateCircleY: function updateCircleY(isSub) {
14657 isSub === void 0 && (isSub = !1);
14658 var $$ = this,
14659 getPoints = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType), isSub);
14660 return function (d, i) {
14661 var id = d.id;
14662 return $$.isGrouped(id) ? getPoints(d, i)[0][1] : $$.getYScaleById(id, isSub)($$.getBaseValue(d));
14663 };
14664 },
14665 getCircles: function getCircles(i, id) {
14666 var $$ = this,
14667 suffix = isValue(i) ? "-" + i : "";
14668 return (id ? $$.$el.main.selectAll("." + config_classes.circles + $$.getTargetSelectorSuffix(id)) : $$.$el.main).selectAll("." + config_classes.circle + suffix);
14669 },
14670 expandCircles: function expandCircles(i, id, reset) {
14671 var $$ = this,
14672 r = $$.pointExpandedR.bind($$);
14673 reset && $$.unexpandCircles();
14674 var circles = $$.getCircles(i, id).classed(config_classes.EXPANDED, !0),
14675 scale = r(circles) / $$.config.point_r,
14676 ratio = 1 - scale;
14677 $$.isCirclePoint() ? circles.attr("r", r) : circles.each(function () {
14678 var point = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
14679 if (this.tagName === "circle") point.attr("r", r);else {
14680 var _this$getBBox = this.getBBox(),
14681 width = _this$getBBox.width,
14682 height = _this$getBBox.height,
14683 x = ratio * (+point.attr("x") + width / 2),
14684 y = ratio * (+point.attr("y") + height / 2);
14685
14686 point.attr("transform", "translate(" + x + " " + y + ") scale(" + scale + ")");
14687 }
14688 });
14689 },
14690 unexpandCircles: function unexpandCircles(i) {
14691 var $$ = this,
14692 r = $$.pointR.bind($$),
14693 circles = $$.getCircles(i).filter(function () {
14694 return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.EXPANDED);
14695 }).classed(config_classes.EXPANDED, !1);
14696 circles.attr("r", r), $$.isCirclePoint() || circles.attr("transform", "scale(" + r(circles) / $$.config.point_r + ")");
14697 },
14698 pointR: function (d) {
14699 var $$ = this,
14700 config = $$.config,
14701 pointR = config.point_r,
14702 r = pointR;
14703 return $$.isBubbleType(d) ? r = $$.getBubbleR(d) : isFunction(pointR) && (r = pointR.bind($$.api)(d)), r;
14704 },
14705 pointExpandedR: function pointExpandedR(d) {
14706 var $$ = this,
14707 config = $$.config,
14708 scale = $$.isBubbleType(d) ? 1.15 : 1.75;
14709 return config.point_focus_expand_enabled ? config.point_focus_expand_r || $$.pointR(d) * scale : $$.pointR(d);
14710 },
14711 pointSelectR: function pointSelectR(d) {
14712 var $$ = this,
14713 selectR = $$.config.point_select_r;
14714 return isFunction(selectR) ? selectR(d) : selectR || $$.pointR(d) * 4;
14715 },
14716 isWithinCircle: function isWithinCircle(node, r) {
14717 var mouse = getPointer(this.state.event, node),
14718 element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(node),
14719 prefix = this.isCirclePoint(node) ? "c" : "",
14720 cx = +element.attr(prefix + "x"),
14721 cy = +element.attr(prefix + "y");
14722
14723 // if node don't have cx/y or x/y attribute value
14724 if (!(cx || cy) && node.nodeType === 1) {
14725 var _getBoundingRect = getBoundingRect(node),
14726 x = _getBoundingRect.x,
14727 y = _getBoundingRect.y;
14728
14729 cx = x, cy = y;
14730 }
14731
14732 return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < (r || this.config.point_sensitivity);
14733 },
14734 insertPointInfoDefs: function insertPointInfoDefs(point, id) {
14735 var $$ = this,
14736 copyAttr = function (from, target) {
14737 for (var name, attribs = from.attributes, i = 0; name = attribs[i]; i++) name = name.name, target.setAttribute(name, from.getAttribute(name));
14738 },
14739 doc = new DOMParser().parseFromString(point, "image/svg+xml"),
14740 node = doc.documentElement,
14741 clone = browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, node.nodeName.toLowerCase());
14742
14743 if (clone.id = id, clone.style.fill = "inherit", clone.style.stroke = "inherit", copyAttr(node, clone), node.childNodes && node.childNodes.length) {
14744 var parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(clone);
14745 "innerHTML" in clone ? parent.html(node.innerHTML) : toArray(node.childNodes).forEach(function (v) {
14746 copyAttr(v, parent.append(v.tagName).node());
14747 });
14748 }
14749
14750 $$.$el.defs.node().appendChild(clone);
14751 },
14752 pointFromDefs: function pointFromDefs(id) {
14753 return this.$el.defs.select("#" + id);
14754 },
14755 updatePointClass: function updatePointClass(d) {
14756 var $$ = this,
14757 circle = $$.$el.circle,
14758 pointClass = !1;
14759 return (isObject(d) || circle) && (pointClass = d === !0 ? circle.each(function (d) {
14760 var className = $$.getClass("circle", !0)(d);
14761 this.getAttribute("class").indexOf(config_classes.EXPANDED) > -1 && (className += " " + config_classes.EXPANDED), this.setAttribute("class", className);
14762 }) : $$.getClass("circle", !0)(d)), pointClass;
14763 },
14764 generateGetLinePoints: function generateGetLinePoints(lineIndices, isSub) {
14765 // partial duplication of generateGetBarPoints
14766 var $$ = this,
14767 config = $$.config,
14768 x = $$.getShapeX(0, lineIndices, isSub),
14769 y = $$.getShapeY(isSub),
14770 lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, isSub),
14771 yScale = $$.getYScaleById.bind($$);
14772 return function (d, i) {
14773 var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
14774 offset = lineOffset(d, i) || y0,
14775 posX = x(d),
14776 posY = y(d);
14777 config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY) && (posY = y0);
14778 // 1 point that marks the line position
14779 var point = [posX, posY - (y0 - offset)];
14780 return [point, point, // from here and below, needed for compatibility
14781 point, point];
14782 };
14783 },
14784 generatePoint: function generatePoint() {
14785 var $$ = this,
14786 config = $$.config,
14787 datetimeId = $$.state.datetimeId,
14788 ids = [],
14789 pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
14790 return function (method, context) {
14791 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
14792
14793 return function (d) {
14794 var id = $$.getTargetSelectorSuffix(d.id || d.data && d.data.id || d),
14795 element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
14796 ids.indexOf(id) < 0 && ids.push(id);
14797 var point = pattern[ids.indexOf(id) % pattern.length];
14798 if ($$.hasValidPointType(point)) point = $$[point];else if (!$$.hasValidPointDrawMethods(point)) {
14799 var pointId = datetimeId + "-point" + id,
14800 pointFromDefs = $$.pointFromDefs(pointId);
14801 if (pointFromDefs.size() < 1 && $$.insertPointInfoDefs(point, pointId), method === "create") return $$.custom.create.bind(context).apply(void 0, [element, pointId].concat(args));
14802 if (method === "update") return $$.custom.update.bind(context).apply(void 0, [element].concat(args));
14803 }
14804 return point[method].bind(context).apply(void 0, [element].concat(args));
14805 };
14806 };
14807 },
14808 custom: {
14809 create: function create(element, id, sizeFn, fillStyleFn) {
14810 return element.append("use").attr("xlink:href", "#" + id).attr("class", this.updatePointClass.bind(this)).style("fill", fillStyleFn).node();
14811 },
14812 update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
14813 var _element$node$getBBox = element.node().getBBox(),
14814 width = _element$node$getBBox.width,
14815 height = _element$node$getBBox.height,
14816 xPosFn2 = function (d) {
14817 return xPosFn(d) - width / 2;
14818 },
14819 mainCircles = element;
14820
14821 if (withTransition) {
14822 var transitionName = getTransitionName();
14823 flow && mainCircles.attr("x", xPosFn2), mainCircles = mainCircles.transition(transitionName), selectedCircles && selectedCircles.transition(getTransitionName());
14824 }
14825
14826 return mainCircles.attr("x", xPosFn2).attr("y", function yPosFn2(d) {
14827 return yPosFn(d) - height / 2;
14828 }).style("fill", fillStyleFn);
14829 }
14830 },
14831 // 'circle' data point
14832 circle: {
14833 create: function create(element, sizeFn, fillStyleFn) {
14834 return element.append("circle").attr("class", this.updatePointClass.bind(this)).attr("r", sizeFn).style("fill", fillStyleFn).node();
14835 },
14836 update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
14837 var $$ = this,
14838 mainCircles = element;
14839
14840 if ($$.hasType("bubble") && mainCircles.attr("r", $$.pointR.bind($$)), withTransition) {
14841 var transitionName = getTransitionName();
14842 flow && mainCircles.attr("cx", xPosFn), mainCircles.attr("cx") && (mainCircles = mainCircles.transition(transitionName)), selectedCircles && selectedCircles.transition(getTransitionName());
14843 }
14844
14845 return mainCircles.attr("cx", xPosFn).attr("cy", yPosFn).style("fill", fillStyleFn);
14846 }
14847 },
14848 // 'rectangle' data point
14849 rectangle: {
14850 create: function create(element, sizeFn, fillStyleFn) {
14851 var rectSizeFn = function (d) {
14852 return sizeFn(d) * 2;
14853 };
14854
14855 return element.append("rect").attr("class", this.updatePointClass.bind(this)).attr("width", rectSizeFn).attr("height", rectSizeFn).style("fill", fillStyleFn).node();
14856 },
14857 update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
14858 var $$ = this,
14859 r = $$.config.point_r,
14860 rectXPosFn = function (d) {
14861 return xPosFn(d) - r;
14862 },
14863 mainCircles = element;
14864
14865 if (withTransition) {
14866 var transitionName = getTransitionName();
14867 flow && mainCircles.attr("x", rectXPosFn), mainCircles = mainCircles.transition(transitionName), selectedCircles && selectedCircles.transition(getTransitionName());
14868 }
14869
14870 return mainCircles.attr("x", rectXPosFn).attr("y", function rectYPosFn(d) {
14871 return yPosFn(d) - r;
14872 }).style("fill", fillStyleFn);
14873 }
14874 }
14875});
14876;// CONCATENATED MODULE: ./src/ChartInternal/shape/radar.ts
14877/**
14878 * Copyright (c) 2017 ~ present NAVER Corp.
14879 * billboard.js project is licensed under the MIT license
14880 */
14881
14882
14883
14884
14885/**
14886 * Get the position value
14887 * @param {boolean} isClockwise If the direction is clockwise
14888 * @param {string} type Coordinate type 'x' or 'y'
14889 * @param {number} edge Number of edge
14890 * @param {number} pos The indexed position
14891 * @param {number} range Range value
14892 * @param {number} ratio Ratio value
14893 * @returns {number}
14894 * @private
14895 */
14896
14897function getPosition(isClockwise, type, edge, pos, range, ratio) {
14898 var index = isClockwise && pos > 0 ? edge - pos : pos,
14899 r = 2 * Math.PI,
14900 func = type === "x" ? Math.sin : Math.cos;
14901 return range * (1 - ratio * func(index * r / edge));
14902} // cache key
14903
14904
14905var cacheKey = KEY.radarPoints;
14906/* harmony default export */ var radar = ({
14907 initRadar: function initRadar() {
14908 var $$ = this,
14909 config = $$.config,
14910 current = $$.state.current,
14911 $el = $$.$el;
14912 $$.hasType("radar") && ($el.radar = $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartRadars), $el.radar.levels = $el.radar.append("g").attr("class", config_classes.levels), $el.radar.axes = $el.radar.append("g").attr("class", config_classes.axis), $el.radar.shapes = $el.radar.append("g").attr("class", config_classes.shapes), current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value);
14913 },
14914 getRadarSize: function getRadarSize() {
14915 var $$ = this,
14916 config = $$.config,
14917 _$$$state = $$.state,
14918 arcWidth = _$$$state.arcWidth,
14919 arcHeight = _$$$state.arcHeight,
14920 padding = config.axis_x_categories.length < 4 ? -20 : 10,
14921 size = (Math.min(arcWidth, arcHeight) - padding) / 2;
14922 return [size, size];
14923 },
14924 updateTargetsForRadar: function updateTargetsForRadar(targets) {
14925 var $$ = this,
14926 config = $$.config;
14927 isEmpty(config.axis_x_categories) && (config.axis_x_categories = getRange(0, getMinMax("max", targets.map(function (v) {
14928 return v.values.length;
14929 })))), $$.generateRadarPoints();
14930 },
14931 getRadarPosition: function getRadarPosition(type, index, range, ratio) {
14932 var $$ = this,
14933 config = $$.config,
14934 _$$$getRadarSize = $$.getRadarSize(),
14935 width = _$$$getRadarSize[0],
14936 height = _$$$getRadarSize[1],
14937 edge = config.axis_x_categories.length,
14938 isClockwise = config.radar_direction_clockwise,
14939 pos = toArray(type).map(function (v) {
14940 return getPosition(isClockwise, v, edge, index, isDefined(range) ? range : type === "x" ? width : height, isNumber(ratio) ? ratio : config.radar_size_ratio);
14941 });
14942
14943 return pos.length === 1 ? pos[0] : pos;
14944 },
14945
14946 /**
14947 * Generate data points
14948 * @private
14949 */
14950 generateRadarPoints: function generateRadarPoints() {
14951 var $$ = this,
14952 targets = $$.data.targets,
14953 _$$$getRadarSize2 = $$.getRadarSize(),
14954 width = _$$$getRadarSize2[0],
14955 height = _$$$getRadarSize2[1],
14956 points = $$.cache.get(cacheKey) || {},
14957 size = points._size;
14958
14959 size && (size.width === width || size.height === height) || (targets.forEach(function (d) {
14960 points[d.id] = d.values.map(function (v, i) {
14961 return $$.getRadarPosition(["x", "y"], i, undefined, $$.getRatio("radar", v));
14962 });
14963 }), points._size = {
14964 width: width,
14965 height: height
14966 }, $$.cache.add(cacheKey, points));
14967 },
14968 redrawRadar: function redrawRadar(durationForExit) {
14969 var $$ = this,
14970 _$$$$el = $$.$el,
14971 radar = _$$$$el.radar,
14972 main = _$$$$el.main,
14973 translate = $$.getTranslate("radar");
14974 translate && (radar.attr("transform", translate), main.select("." + config_classes.chartTexts).attr("transform", translate), $$.generateRadarPoints(), $$.updateRadarLevel(), $$.updateRadarAxes(), $$.updateRadarShape(durationForExit));
14975 },
14976 generateGetRadarPoints: function generateGetRadarPoints() {
14977 var points = this.cache.get(cacheKey);
14978 return function (d, i) {
14979 var point = points[d.id][i];
14980 return [point, point, point, point];
14981 };
14982 },
14983 updateRadarLevel: function updateRadarLevel() {
14984 var $$ = this,
14985 config = $$.config,
14986 state = $$.state,
14987 radar = $$.$el.radar,
14988 _$$$getRadarSize3 = $$.getRadarSize(),
14989 width = _$$$getRadarSize3[0],
14990 height = _$$$getRadarSize3[1],
14991 depth = config.radar_level_depth,
14992 edge = config.axis_x_categories.length,
14993 showText = config.radar_level_text_show,
14994 radarLevels = radar.levels,
14995 levelData = getRange(0, depth),
14996 radius = config.radar_size_ratio * Math.min(width, height),
14997 levelRatio = levelData.map(function (l) {
14998 return radius * ((l + 1) / depth);
14999 }),
15000 levelTextFormat = (config.radar_level_text_format || function () {}).bind($$.api),
15001 points = levelData.map(function (v) {
15002 var range = levelRatio[v],
15003 pos = getRange(0, edge).map(function (i) {
15004 return $$.getRadarPosition(["x", "y"], i, range, 1).join(",");
15005 });
15006 return pos.join(" ");
15007 }),
15008 level = radarLevels.selectAll("." + config_classes.level).data(levelData);
15009
15010 level.exit().remove();
15011 var levelEnter = level.enter().append("g").attr("class", function (d, i) {
15012 return config_classes.level + " " + config_classes.level + "-" + i;
15013 });
15014 levelEnter.append("polygon").style("visibility", config.radar_level_show ? null : "hidden"), showText && (radarLevels.select("text").empty() && radarLevels.append("text").attr("dx", "-.5em").attr("dy", "-.7em").style("text-anchor", "end").text(function () {
15015 return levelTextFormat(0);
15016 }), levelEnter.append("text").attr("dx", "-.5em").style("text-anchor", "end").text(function (d) {
15017 return levelTextFormat(state.current.dataMax / levelData.length * (d + 1));
15018 })), levelEnter.merge(level).attr("transform", function (d) {
15019 return "translate(" + (width - levelRatio[d]) + ", " + (height - levelRatio[d]) + ")";
15020 }).selectAll("polygon").attr("points", function (d) {
15021 return points[d];
15022 }), showText && radarLevels.selectAll("text").attr("x", function (d) {
15023 return isUndefined(d) ? width : points[d].split(",")[0];
15024 }).attr("y", function (d) {
15025 return isUndefined(d) ? height : 0;
15026 });
15027 },
15028 updateRadarAxes: function updateRadarAxes() {
15029 var $$ = this,
15030 config = $$.config,
15031 radar = $$.$el.radar,
15032 _$$$getRadarSize4 = $$.getRadarSize(),
15033 width = _$$$getRadarSize4[0],
15034 height = _$$$getRadarSize4[1],
15035 categories = config.axis_x_categories,
15036 axis = radar.axes.selectAll("g").data(categories);
15037
15038 axis.exit().remove();
15039 var axisEnter = axis.enter().append("g").attr("class", function (d, i) {
15040 return config_classes.axis + "-" + i;
15041 });
15042
15043 // axis text
15044 if (config.radar_axis_line_show && axisEnter.append("line"), config.radar_axis_text_show && axisEnter.append("text"), axis = axisEnter.merge(axis), config.radar_axis_line_show && axis.select("line").attr("x1", width).attr("y1", height).attr("x2", function (d, i) {
15045 return $$.getRadarPosition("x", i);
15046 }).attr("y2", function (d, i) {
15047 return $$.getRadarPosition("y", i);
15048 }), config.radar_axis_text_show) {
15049 var _config$radar_axis_te = config.radar_axis_text_position,
15050 _config$radar_axis_te2 = _config$radar_axis_te.x,
15051 x = _config$radar_axis_te2 === void 0 ? 0 : _config$radar_axis_te2,
15052 _config$radar_axis_te3 = _config$radar_axis_te.y,
15053 y = _config$radar_axis_te3 === void 0 ? 0 : _config$radar_axis_te3;
15054 axis.select("text").style("text-anchor", "middle").attr("dy", ".5em").call(function (selection) {
15055 selection.each(function (d) {
15056 setTextValue((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), d + "", [-.6, 1.2]);
15057 });
15058 }).datum(function (d, i) {
15059 return {
15060 index: i
15061 };
15062 }).attr("transform", function (d) {
15063 isUndefined(this.width) && (this.width = this.getBoundingClientRect().width / 2);
15064 var posX = $$.getRadarPosition("x", d.index, undefined, 1),
15065 posY = Math.round($$.getRadarPosition("y", d.index, undefined, 1));
15066 return posX > width ? posX += this.width + x : Math.round(posX) < width && (posX -= this.width + x), posY > height ? (posY / 2 === height && this.firstChild.tagName === "tspan" && this.firstChild.setAttribute("dy", "0em"), posY += y) : posY < height && (posY -= y), "translate(" + posX + " " + posY + ")";
15067 });
15068 }
15069
15070 $$.bindEvent();
15071 },
15072 bindEvent: function bindEvent() {
15073 var $$ = this,
15074 config = $$.config,
15075 state = $$.state,
15076 _$$$$el2 = $$.$el,
15077 radar = _$$$$el2.radar,
15078 svg = _$$$$el2.svg,
15079 focusOnly = config.point_focus_only,
15080 _state = state,
15081 inputType = _state.inputType,
15082 transiting = _state.transiting;
15083
15084 if (config.interaction_enabled) {
15085 var isMouse = inputType === "mouse",
15086 getIndex = function (event) {
15087 var target = event.target; // in case of multilined axis text
15088
15089 /tspan/i.test(target.tagName) && (target = target.parentNode);
15090 var d = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
15091 return d && Object.keys(d).length === 1 ? d.index : undefined;
15092 },
15093 hide = function (event) {
15094 var index = getIndex(event),
15095 noIndex = isUndefined(index);
15096 (isMouse || noIndex) && ($$.hideTooltip(), focusOnly ? $$.hideCircleFocus() : $$.unexpandCircles(), isMouse ? $$.setOverOut(!1, index) : noIndex && $$.callOverOutForTouch());
15097 };
15098
15099 radar.axes.selectAll("text").on(isMouse ? "mouseover " : "touchstart", function (event) {
15100 if (!transiting) // skip while transiting
15101 {
15102 state.event = event;
15103 var index = getIndex(event);
15104 $$.selectRectForSingle(svg.node(), null, index), isMouse ? $$.setOverOut(!0, index) : $$.callOverOutForTouch(index);
15105 }
15106 }).on("mouseout", isMouse ? hide : null), isMouse || svg.on("touchstart", hide);
15107 }
15108 },
15109 updateRadarShape: function updateRadarShape(durationForExit) {
15110 var $$ = this,
15111 targets = $$.data.targets.filter(function (d) {
15112 return $$.isRadarType(d);
15113 }),
15114 points = $$.cache.get(cacheKey),
15115 areas = $$.$el.radar.shapes.selectAll("polygon").data(targets),
15116 areasEnter = areas.enter().append("g").attr("class", $$.getChartClass("Radar"));
15117 areas.exit().transition().duration(durationForExit).remove(), areasEnter.append("polygon").merge(areas).style("fill", $$.color).style("stroke", $$.color).attr("points", function (d) {
15118 return points[d.id].join(" ");
15119 }), $$.updateTargetForCircle(targets, areasEnter);
15120 },
15121
15122 /**
15123 * Get data point x coordinate
15124 * @param {object} d Data object
15125 * @returns {number}
15126 * @private
15127 */
15128 radarCircleX: function radarCircleX(d) {
15129 return this.cache.get(cacheKey)[d.id][d.index][0];
15130 },
15131
15132 /**
15133 * Get data point y coordinate
15134 * @param {object} d Data object
15135 * @returns {number}
15136 * @private
15137 */
15138 radarCircleY: function radarCircleY(d) {
15139 return this.cache.get(cacheKey)[d.id][d.index][1];
15140 }
15141});
15142;// CONCATENATED MODULE: ./src/config/Options/common/point.ts
15143/**
15144 * Copyright (c) 2017 ~ present NAVER Corp.
15145 * billboard.js project is licensed under the MIT license
15146 */
15147
15148/**
15149 * point config options
15150 */
15151/* harmony default export */ var common_point = ({
15152 /**
15153 * Set point options
15154 * @name point
15155 * @memberof Options
15156 * @type {object}
15157 * @property {object} point Point object
15158 * @property {boolean} [point.show=true] Whether to show each point in line.
15159 * @property {number|Function} [point.r=2.5] The radius size of each point.
15160 * - **NOTE:** Disabled for 'bubble' type
15161 * @property {boolean} [point.focus.expand.enabled=true] Whether to expand each point on focus.
15162 * @property {number} [point.focus.expand.r=point.r*1.75] The radius size of each point on focus.
15163 * - **NOTE:** For 'bubble' type, the default is `bubbleSize*1.15`
15164 * @property {boolean} [point.focus.only=false] Show point only when is focused.
15165 * @property {number|null} [point.opacity=undefined] Set point opacity value.
15166 * - **NOTE:**
15167 * - `null` will make to not set inline 'opacity' css prop.
15168 * - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
15169 * @property {number} [point.sensitivity=10] The senstivity value for interaction boundary.
15170 * @property {number} [point.select.r=point.r*4] The radius size of each point on selected.
15171 * @property {string} [point.type="circle"] The type of point to be drawn
15172 * - **NOTE:**
15173 * - If chart has 'bubble' type, only circle can be used.
15174 * - For IE, non circle point expansions are not supported due to lack of transform support.
15175 * - **Available Values:**
15176 * - circle
15177 * - rectangle
15178 * @property {Array} [point.pattern=[]] The type of point or svg shape as string, to be drawn for each line
15179 * - **NOTE:**
15180 * - This is an `experimental` feature and can have some unexpected behaviors.
15181 * - If chart has 'bubble' type, only circle can be used.
15182 * - For IE, non circle point expansions are not supported due to lack of transform support.
15183 * - **Available Values:**
15184 * - circle
15185 * - rectangle
15186 * - svg shape tag interpreted as string<br>
15187 * (ex. `<polygon points='2.5 0 0 5 5 5'></polygon>`)
15188 * @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
15189 * @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
15190 * @example
15191 * point: {
15192 * show: false,
15193 * r: 5,
15194 *
15195 * // or customize the radius
15196 * r: function(d) {
15197 * ...
15198 * return r;
15199 * },
15200 *
15201 * focus: {
15202 * expand: {
15203 * enabled: true,
15204 * r: 1
15205 * },
15206 * only: true
15207 * },
15208 *
15209 * // do not set inline 'opacity' css prop setting
15210 * opacity: null,
15211 *
15212 * // set every data point's opacity value
15213 * opacity: 0.7,
15214 *
15215 * select: {
15216 * r: 3
15217 * },
15218 *
15219 * // having lower value, means how closer to be for interaction
15220 * sensitivity: 3,
15221 *
15222 * // valid values are "circle" or "rectangle"
15223 * type: "rectangle",
15224 *
15225 * // or indicate as pattern
15226 * pattern: [
15227 * "circle",
15228 * "rectangle",
15229 * "<polygon points='0 6 4 0 -4 0'></polygon>"
15230 * ],
15231 * }
15232 */
15233 point_show: !0,
15234 point_r: 2.5,
15235 point_sensitivity: 10,
15236 point_focus_expand_enabled: !0,
15237 point_focus_expand_r: undefined,
15238 point_focus_only: !1,
15239 point_opacity: undefined,
15240 point_pattern: [],
15241 point_select_r: undefined,
15242 point_type: "circle"
15243});
15244;// CONCATENATED MODULE: ./src/config/Options/shape/area.ts
15245/**
15246 * Copyright (c) 2017 ~ present NAVER Corp.
15247 * billboard.js project is licensed under the MIT license
15248 */
15249
15250/**
15251 * area config options
15252 */
15253/* harmony default export */ var Options_shape_area = ({
15254 /**
15255 * Set area options
15256 * @name area
15257 * @memberof Options
15258 * @type {object}
15259 * @property {object} area Area object
15260 * @property {boolean} [area.above=false] Set background area above the data chart line.
15261 * @property {boolean} [area.front=true] Set area node to be positioned over line node.
15262 * @property {boolean|object} [area.linearGradient=false] Set the linear gradient on area.<br><br>
15263 * Or customize by giving below object value:
15264 * - x {Array}: `x1`, `x2` value
15265 * - y {Array}: `y1`, `y2` value
15266 * - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
15267 * @property {boolean} [area.zerobased=true] Set if min or max value will be 0 on area chart.
15268 * @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)
15269 * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
15270 * @see [Demo: above](https://naver.github.io/billboard.js/demo/#AreaChartOptions.Above)
15271 * @see [Demo: linearGradient](https://naver.github.io/billboard.js/demo/#AreaChartOptions.LinearGradient)
15272 * @example
15273 * area: {
15274 * above: true,
15275 * zerobased: false,
15276 *
15277 * // <g class='bb-areas'> will be positioned behind the line <g class='bb-lines'> in stacking order
15278 * front: false,
15279 *
15280 * // will generate follwing linearGradient:
15281 * // <linearGradient x1="0" x2="0" y1="0" y2="1">
15282 * // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
15283 * // <stop offset="1" stop-color="$DATA_COLOR" stop-opacity="0"></stop>
15284 * // </linearGradient>
15285 * linearGradient: true,
15286 *
15287 * // Or customized gradient
15288 * linearGradient: {
15289 * x: [0, 0], // x1, x2 attributes
15290 * y: [0, 0], // y1, y2 attributes
15291 * stops: [
15292 * // offset, stop-color, stop-opacity
15293 * [0, "#7cb5ec", 1],
15294 *
15295 * // setting 'null' for stop-color, will set its original data color
15296 * [0.5, null, 0],
15297 *
15298 * // setting 'function' for stop-color, will pass data id as argument.
15299 * // It should return color string or null value
15300 * [1, function(id) { return id === "data1" ? "red" : "blue"; }, 0],
15301 * ]
15302 * }
15303 * }
15304 */
15305 area_above: !1,
15306 area_front: !0,
15307 area_linearGradient: !1,
15308 area_zerobased: !0
15309});
15310;// CONCATENATED MODULE: ./src/config/Options/shape/bar.ts
15311/**
15312 * Copyright (c) 2017 ~ present NAVER Corp.
15313 * billboard.js project is licensed under the MIT license
15314 */
15315
15316/**
15317 * bar config options
15318 */
15319/* harmony default export */ var shape_bar = ({
15320 /**
15321 * Set bar options
15322 * @name bar
15323 * @memberof Options
15324 * @type {object}
15325 * @property {object} bar Bar object
15326 * @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
15327 * @property {number} [bar.padding=0] The padding pixel value between each bar.
15328 * @property {number} [bar.radius] Set the radius of bar edge in pixel.
15329 * - **NOTE:** Works only for non-stacked bar
15330 * @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
15331 * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
15332 * @property {number} [bar.width] Change the width of bar chart.
15333 * @property {number} [bar.width.ratio=0.6] Change the width of bar chart by ratio.
15334 * @property {number} [bar.width.max] The maximum width value for ratio.
15335 * @property {number} [bar.width.dataname] Change the width of bar for indicated dataset only.
15336 * - **NOTE:**
15337 * - Works only for non-stacked bar
15338 * - Bars are centered accoding its total width value
15339 * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
15340 * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
15341 * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
15342 * @see [Demo: bar padding](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarPadding)
15343 * @see [Demo: bar radius](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarRadius)
15344 * @see [Demo: bar width](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidth)
15345 * @see [Demo: bar width variant](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidthVariant)
15346 * @example
15347 * bar: {
15348 * padding: 1,
15349 *
15350 * // the 'radius' option can be used only for non-stacking bars
15351 * radius: 10,
15352 * // or
15353 * radius: {
15354 * ratio: 0.5
15355 * }
15356 *
15357 * label: {
15358 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the y Axis domain range value.
15359 * // if data value is below than 0.1, text label will be hidden.
15360 * threshold: 0.1,
15361 * },
15362 *
15363 * // will not have offset between each bar elements for interaction
15364 * sensitivity: 0,
15365 *
15366 * width: 10,
15367 *
15368 * // or
15369 * width: {
15370 * ratio: 0.2,
15371 * max: 20
15372 * },
15373 *
15374 * // or specify width per dataset
15375 * width: {
15376 * data1: 20,
15377 * data2: {
15378 * ratio: 0.2,
15379 * max: 20
15380 * }
15381 * },
15382 *
15383 * zerobased: false
15384 * }
15385 */
15386 bar_label_threshold: 0,
15387 bar_padding: 0,
15388 bar_radius: undefined,
15389 bar_radius_ratio: undefined,
15390 bar_sensitivity: 2,
15391 bar_width: undefined,
15392 bar_width_ratio: .6,
15393 bar_width_max: undefined,
15394 bar_zerobased: !0
15395});
15396;// CONCATENATED MODULE: ./src/config/Options/shape/bubble.ts
15397/**
15398 * Copyright (c) 2017 ~ present NAVER Corp.
15399 * billboard.js project is licensed under the MIT license
15400 */
15401
15402/**
15403 * bubble config options
15404 */
15405/* harmony default export */ var shape_bubble = ({
15406 /**
15407 * Set bubble options
15408 * @name bubble
15409 * @memberof Options
15410 * @type {object}
15411 * @property {object} bubble bubble object
15412 * @property {number|Function} [bubble.maxR=35] Set the max bubble radius value
15413 * @property {boolean} [bubble.zerobased=false] Set if min or max value will be 0 on bubble chart.
15414 * @example
15415 * bubble: {
15416 * // ex) If 100 is the highest value among data bound, the representation bubble of 100 will have radius of 50.
15417 * // And the lesser will have radius relatively from tha max value.
15418 * maxR: 50,
15419 *
15420 * // or set radius callback
15421 * maxR: function(d) {
15422 * // ex. of d param - {x: Fri Oct 06 2017 00:00:00 GMT+0900, value: 80, id: "data2", index: 5}
15423 * ...
15424 * return Math.sqrt(d.value * 2);
15425 * },
15426 * zerobased: false
15427 * }
15428 */
15429 bubble_maxR: 35,
15430 bubble_zerobased: !1
15431});
15432;// CONCATENATED MODULE: ./src/config/Options/shape/candlestick.ts
15433/**
15434 * Copyright (c) 2017 ~ present NAVER Corp.
15435 * billboard.js project is licensed under the MIT license
15436 */
15437
15438/**
15439 * candlestick config options
15440 */
15441/* harmony default export */ var shape_candlestick = ({
15442 /**
15443 * Set candlestick options
15444 * @name candlestick
15445 * @memberof Options
15446 * @type {object}
15447 * @property {object} candlestick Candlestick object
15448 * @property {number} [candlestick.width] Change the width.
15449 * @property {number} [candlestick.width.ratio=0.6] Change the width by ratio.
15450 * @property {number} [candlestick.width.max] The maximum width value for ratio.
15451 * @property {number} [candlestick.width.dataname] Change the width for indicated dataset only.
15452 * @property {number} [candlestick.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
15453 * @property {number} [candlestick.width.dataname.max] The maximum width value for ratio.
15454 * @property {object} [candlestick.color] Color setting.
15455 * @property {string|object} [candlestick.color.down] Change down(bearish) value color.
15456 * @property {string} [candlestick.color.down.dataname] Change down value color for indicated dataset only.
15457 *
15458 * @see [Demo](https://naver.github.io/billboard.js/demo/##Chart.CandlestickChart)
15459 * @example
15460 * candlestick: {
15461 * width: 10,
15462 *
15463 * // or
15464 * width: {
15465 * ratio: 0.2,
15466 * max: 20
15467 * },
15468 *
15469 * // or specify width per dataset
15470 * width: {
15471 * data1: 20,
15472 * data2: {
15473 * ratio: 0.2,
15474 * max: 20
15475 * }
15476 * },
15477 * color: {
15478 * // spcify bearish color
15479 * down: "red",
15480 *
15481 * // or specify color per dataset
15482 * down: {
15483 * data1: "red",
15484 * data2: "blue",
15485 * }
15486 * }
15487 * }
15488 */
15489 candlestick_width: undefined,
15490 candlestick_width_ratio: .6,
15491 candlestick_width_max: undefined,
15492 candlestick_color_down: "red"
15493});
15494;// CONCATENATED MODULE: ./src/config/Options/shape/line.ts
15495/**
15496 * Copyright (c) 2017 ~ present NAVER Corp.
15497 * billboard.js project is licensed under the MIT license
15498 */
15499
15500/**
15501 * line config options
15502 */
15503/* harmony default export */ var shape_line = ({
15504 /**
15505 * Set line options
15506 * @name line
15507 * @memberof Options
15508 * @type {object}
15509 * @property {object} line Line object
15510 * @property {boolean} [line.connectNull=false] Set if null data point will be connected or not.<br>
15511 * 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.
15512 * @property {Array} [line.classes=undefined] If set, used to set a css class on each line.
15513 * @property {boolean} [line.step.type=step] Change step type for step chart.<br>
15514 * **Available values:**
15515 * - step
15516 * - step-before
15517 * - step-after
15518 * @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.
15519 * @property {boolean} [line.zerobased=false] Set if min or max value will be 0 on line chart.
15520 * @example
15521 * line: {
15522 * connectNull: true,
15523 * classes: [
15524 * "line-class1",
15525 * "line-class2"
15526 * ],
15527 * step: {
15528 * type: "step-after"
15529 * },
15530 *
15531 * // hide all data points ('point.show=false' also has similar effect)
15532 * point: false,
15533 *
15534 * // show data points for only indicated datas
15535 * point: [
15536 * "data1", "data3"
15537 * ],
15538 *
15539 * zerobased: false
15540 * }
15541 */
15542 line_connectNull: !1,
15543 line_step_type: "step",
15544 line_zerobased: !1,
15545 line_classes: undefined,
15546 line_point: !0
15547});
15548;// CONCATENATED MODULE: ./src/config/Options/shape/scatter.ts
15549/**
15550 * Copyright (c) 2017 ~ present NAVER Corp.
15551 * billboard.js project is licensed under the MIT license
15552 */
15553
15554/**
15555 * scatter config options
15556 */
15557/* harmony default export */ var scatter = ({
15558 /**
15559 * Set scatter options
15560 * @name scatter
15561 * @memberof Options
15562 * @type {object}
15563 * @property {object} [scatter] scatter object
15564 * @property {boolean} [scatter.zerobased=false] Set if min or max value will be 0 on scatter chart.
15565 * @example
15566 * scatter: {
15567 * connectNull: true,
15568 * step: {
15569 * type: "step-after"
15570 * },
15571 *
15572 * // hide all data points ('point.show=false' also has similar effect)
15573 * point: false,
15574 *
15575 * // show data points for only indicated datas
15576 * point: [
15577 * "data1", "data3"
15578 * ],
15579 *
15580 * zerobased: false
15581 * }
15582 */
15583 scatter_zerobased: !1
15584});
15585;// CONCATENATED MODULE: ./src/config/Options/shape/spline.ts
15586/**
15587 * Copyright (c) 2017 ~ present NAVER Corp.
15588 * billboard.js project is licensed under the MIT license
15589 */
15590
15591/**
15592 * x Axis config options
15593 */
15594/* harmony default export */ var spline = ({
15595 /**
15596 * Set spline options
15597 * - **Available interpolation type values:**
15598 * - basis (d3.curveBasis)
15599 * - basis-closed (d3.curveBasisClosed)
15600 * - basis-open (d3.curveBasisOpen)
15601 * - bundle (d3.curveBundle)
15602 * - cardinal (d3.curveCardinal)
15603 * - cardinal-closed (d3.curveCardinalClosed)
15604 * - cardinal-open (d3.curveCardinalOpen)
15605 * - catmull-rom (d3.curveCatmullRom)
15606 * - catmull-rom-closed (d3.curveCatmullRomClosed)
15607 * - catmull-rom-open (d3.curveCatmullRomOpen)
15608 * - monotone-x (d3.curveMonotoneX)
15609 * - monotone-y (d3.curveMonotoneY)
15610 * - natural (d3.curveNatural)
15611 * - linear-closed (d3.curveLinearClosed)
15612 * - linear (d3.curveLinear)
15613 * - step (d3.curveStep)
15614 * - step-after (d3.curveStepAfter)
15615 * - step-before (d3.curveStepBefore)
15616 * @name spline
15617 * @memberof Options
15618 * @type {object}
15619 * @property {object} spline Spline object
15620 * @property {object} spline.interpolation Spline interpolation object
15621 * @property {string} [spline.interpolation.type="cardinal"] Interpolation type
15622 * @see [Interpolation (d3 v4)](http://bl.ocks.org/emmasaunders/c25a147970def2b02d8c7c2719dc7502)
15623 * @example
15624 * spline: {
15625 * interpolation: {
15626 * type: "cardinal"
15627 * }
15628 * }
15629 */
15630 spline_interpolation_type: "cardinal"
15631});
15632;// CONCATENATED MODULE: ./src/config/Options/shape/donut.ts
15633/**
15634 * Copyright (c) 2017 ~ present NAVER Corp.
15635 * billboard.js project is licensed under the MIT license
15636 */
15637
15638/**
15639 * donut config options
15640 */
15641/* harmony default export */ var donut = ({
15642 /**
15643 * Set donut options
15644 * @name donut
15645 * @memberof Options
15646 * @type {object}
15647 * @property {object} donut Donut object
15648 * @property {boolean} [donut.label.show=true] Show or hide label on each donut piece.
15649 * @property {Function} [donut.label.format] Set formatter for the label on each donut piece.
15650 * @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
15651 * @property {number|Function} [donut.label.ratio=undefined] Set ratio of labels position.
15652 * @property {boolean} [donut.expand=true] Enable or disable expanding donut pieces.
15653 * @property {number} [donut.expand.rate=0.98] Set expand rate.
15654 * @property {number} [donut.expand.duration=50] Set expand transition time in ms.
15655 * @property {number} [donut.width] Set width of donut chart.
15656 * @property {string} [donut.title=""] Set title of donut chart. Use `\n` character for line break.
15657 * @property {number} [donut.padAngle=0] Set padding between data.
15658 * @property {number} [donut.startingAngle=0] Set starting angle where data draws.
15659 * @example
15660 * donut: {
15661 * label: {
15662 * show: false,
15663 * format: function(value, ratio, id) {
15664 * return d3.format("$")(value);
15665 *
15666 * // to multiline, return with '\n' character
15667 * // return value +"%\nLine1\n2Line2";
15668 * },
15669 *
15670 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
15671 * // if data value is below than 0.1, text label will be hidden.
15672 * threshold: 0.1,
15673 *
15674 * // set ratio callback. Should return ratio value
15675 * ratio: function(d, radius, h) {
15676 * ...
15677 * return ratio;
15678 * },
15679 * // or set ratio number
15680 * ratio: 0.5
15681 * },
15682 *
15683 * // disable expand transition for interaction
15684 * expand: false,
15685 *
15686 * expand: {
15687 * // set duration of expand transition to 500ms.
15688 * duration: 500,
15689 *
15690 * // set expand area rate
15691 * rate: 1
15692 * },
15693 *
15694 * width: 10,
15695 * padAngle: 0.2,
15696 * startingAngle: 1,
15697 * title: "Donut Title"
15698 *
15699 * // title with line break
15700 * title: "Title1\nTitle2"
15701 * }
15702 */
15703 donut_label_show: !0,
15704 donut_label_format: undefined,
15705 donut_label_threshold: .05,
15706 donut_label_ratio: undefined,
15707 donut_width: undefined,
15708 donut_title: "",
15709 donut_expand: {},
15710 donut_expand_rate: .98,
15711 donut_expand_duration: 50,
15712 donut_padAngle: 0,
15713 donut_startingAngle: 0
15714});
15715;// CONCATENATED MODULE: ./src/config/Options/shape/gauge.ts
15716/**
15717 * Copyright (c) 2017 ~ present NAVER Corp.
15718 * billboard.js project is licensed under the MIT license
15719 */
15720
15721/**
15722 * gauge config options
15723 */
15724/* harmony default export */ var shape_gauge = ({
15725 /**
15726 * Set gauge options
15727 * @name gauge
15728 * @memberof Options
15729 * @type {object}
15730 * @property {object} gauge Gauge object
15731 * @property {boolean} [gauge.background=""] Set background color. (The `.bb-chart-arcs-background` element)
15732 * @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.
15733 * @property {boolean} [gauge.label.show=true] Show or hide label on gauge.
15734 * @property {Function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.
15735 * @property {Function} [gauge.label.extents] Set customized min/max label text.
15736 * @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
15737 * @property {boolean} [gauge.expand=true] Enable or disable expanding gauge.
15738 * @property {number} [gauge.expand.rate=0.98] Set expand rate.
15739 * @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
15740 * @property {number} [gauge.min=0] Set min value of the gauge.
15741 * @property {number} [gauge.max=100] Set max value of the gauge.
15742 * @property {number} [gauge.startingAngle=-1 * Math.PI / 2] Set starting angle where data draws.
15743 *
15744 * **Limitations:**
15745 * - when `gauge.fullCircle=false`:
15746 * - -1 * Math.PI / 2 <= startingAngle <= Math.PI / 2
15747 * - `startingAngle <= -1 * Math.PI / 2` defaults to `-1 * Math.PI / 2`
15748 * - `startingAngle >= Math.PI / 2` defaults to `Math.PI / 2`
15749 * - when `gauge.fullCircle=true`:
15750 * - -1 * Math.PI < startingAngle < Math.PI
15751 * - `startingAngle < -1 * Math.PI` defaults to `Math.PI`
15752 * - `startingAngle > Math.PI` defaults to `Math.PI`
15753 * @property {number} [gauge.arcLength=100] Set the length of the arc to be drawn in percent from -100 to 100.<br>
15754 * Negative value will draw the arc **counterclockwise**.
15755 *
15756 * **Limitations:**
15757 * - -100 <= arcLength (in percent) <= 100
15758 * - 'arcLength < -100' defaults to -100
15759 * - 'arcLength > 100' defaults to 100
15760 * @property {string} [gauge.title=""] Set title of gauge chart. Use `\n` character for line break.
15761 * @property {string} [gauge.units] Set units of the gauge.
15762 * @property {number} [gauge.width] Set width of gauge chart.
15763 * @property {string} [gauge.type="single"] Set type of gauge to be displayed.<br><br>
15764 * **Available Values:**
15765 * - single
15766 * - multi
15767 * @property {string} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
15768 * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
15769 * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
15770 * @example
15771 * gauge: {
15772 * background: "#eee", // will set 'fill' css prop for '.bb-chart-arcs-background' classed element.
15773 * fullCircle: false,
15774 * label: {
15775 * show: false,
15776 * format: function(value, ratio) {
15777 * return value;
15778 *
15779 * // to multiline, return with '\n' character
15780 * // return value +"%\nLine1\n2Line2";
15781 * },
15782 *
15783 * extents: function(value, isMax) {
15784 * return (isMax ? "Max:" : "Min:") + value;
15785 * },
15786 *
15787 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
15788 * // if data value is below than 0.1, text label will be hidden.
15789 * threshold: 0.1,
15790 * },
15791 *
15792 * // disable expand transition for interaction
15793 * expand: false,
15794 *
15795 * expand: {
15796 * // set duration of expand transition to 500ms.
15797 * duration: 500,
15798 *
15799 * // set expand area rate
15800 * rate: 1
15801 * },
15802 *
15803 * min: -100,
15804 * max: 200,
15805 * type: "single" // or 'multi'
15806 * title: "Title Text",
15807 * units: "%",
15808 * width: 10,
15809 * startingAngle: -1 * Math.PI / 2,
15810 * arcLength: 100,
15811 * arcs: {
15812 * minWidth: 5
15813 * }
15814 * }
15815 */
15816 gauge_background: "",
15817 gauge_fullCircle: !1,
15818 gauge_label_show: !0,
15819 gauge_label_format: undefined,
15820 gauge_label_extents: undefined,
15821 gauge_label_threshold: 0,
15822 gauge_min: 0,
15823 gauge_max: 100,
15824 gauge_type: "single",
15825 gauge_startingAngle: -1 * Math.PI / 2,
15826 gauge_arcLength: 100,
15827 gauge_title: "",
15828 gauge_units: undefined,
15829 gauge_width: undefined,
15830 gauge_arcs_minWidth: 5,
15831 gauge_expand: {},
15832 gauge_expand_rate: .98,
15833 gauge_expand_duration: 50
15834});
15835;// CONCATENATED MODULE: ./src/config/Options/shape/pie.ts
15836/**
15837 * Copyright (c) 2017 ~ present NAVER Corp.
15838 * billboard.js project is licensed under the MIT license
15839 */
15840
15841/**
15842 * x Axis config options
15843 */
15844/* harmony default export */ var pie = ({
15845 /**
15846 * Set pie options
15847 * @name pie
15848 * @memberof Options
15849 * @type {object}
15850 * @property {object} pie Pie object
15851 * @property {boolean} [pie.label.show=true] Show or hide label on each pie piece.
15852 * @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
15853 * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
15854 * @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
15855 * @property {boolean|object} [pie.expand=true] Enable or disable expanding pie pieces.
15856 * @property {number} [pie.expand.rate=0.98] Set expand rate.
15857 * @property {number} [pie.expand.duration=50] Set expand transition time in ms.
15858 * @property {number|object} [pie.innerRadius=0] Sets the inner radius of pie arc.
15859 * @property {number|object|undefined} [pie.outerRadius=undefined] Sets the outer radius of pie arc.
15860 * @property {number} [pie.padAngle=0] Set padding between data.
15861 * @property {number} [pie.padding=0] Sets the gap between pie arcs.
15862 * @property {number} [pie.startingAngle=0] Set starting angle where data draws.
15863 * @see [Demo: expand.rate](https://naver.github.io/billboard.js/demo/#PieChartOptions.ExpandRate)
15864 * @see [Demo: innerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.InnerRadius)
15865 * @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
15866 * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
15867 * @example
15868 * pie: {
15869 * label: {
15870 * show: false,
15871 * format: function(value, ratio, id) {
15872 * return d3.format("$")(value);
15873 *
15874 * // to multiline, return with '\n' character
15875 * // return value +"%\nLine1\n2Line2";
15876 * },
15877 *
15878 * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
15879 * // if data value is below than 0.1, text label will be hidden.
15880 * threshold: 0.1,
15881 *
15882 * // set ratio callback. Should return ratio value
15883 * ratio: function(d, radius, h) {
15884 * ...
15885 * return ratio;
15886 * },
15887 * // or set ratio number
15888 * ratio: 0.5
15889 * },
15890 *
15891 * // disable expand transition for interaction
15892 * expand: false,
15893 *
15894 * expand: {
15895 * // set duration of expand transition to 500ms.
15896 * duration: 500,
15897 *
15898 * // set expand area rate
15899 * rate: 1
15900 * },
15901 *
15902 * innerRadius: 0,
15903 *
15904 * // set different innerRadius for each data
15905 * innerRadius: {
15906 * data1: 10,
15907 * data2: 0
15908 * },
15909 *
15910 * outerRadius: 100,
15911 *
15912 * // set different outerRadius for each data
15913 * outerRadius: {
15914 * data1: 50,
15915 * data2: 100
15916 * }
15917 *
15918 * padAngle: 0.1,
15919 * padding: 0,
15920 * startingAngle: 1
15921 * }
15922 */
15923 pie_label_show: !0,
15924 pie_label_format: undefined,
15925 pie_label_threshold: .05,
15926 pie_label_ratio: undefined,
15927 pie_expand: {},
15928 pie_expand_rate: .98,
15929 pie_expand_duration: 50,
15930 pie_innerRadius: 0,
15931 pie_outerRadius: undefined,
15932 pie_padAngle: 0,
15933 pie_padding: 0,
15934 pie_startingAngle: 0
15935});
15936;// CONCATENATED MODULE: ./src/config/Options/shape/radar.ts
15937/**
15938 * Copyright (c) 2017 ~ present NAVER Corp.
15939 * billboard.js project is licensed under the MIT license
15940 */
15941
15942/**
15943 * x Axis config options
15944 */
15945/* harmony default export */ var shape_radar = ({
15946 /**
15947 * Set radar options
15948 * - **NOTE:**
15949 * > When x tick text contains `\n`, it's used as line break.
15950 * @name radar
15951 * @memberof Options
15952 * @type {object}
15953 * @property {object} radar Radar object
15954 * @property {number} [radar.axis.max=undefined] The max value of axis. If not given, it'll take the max value from the given data.
15955 * @property {boolean} [radar.axis.line.show=true] Show or hide axis line.
15956 * @property {number} [radar.axis.text.position.x=0] x coordinate position, relative the original.
15957 * @property {number} [radar.axis.text.position.y=0] y coordinate position, relative the original.
15958 * @property {boolean} [radar.axis.text.show=true] Show or hide axis text.
15959 * @property {boolean} [radar.direction.clockwise=false] Set the direction to be drawn.
15960 * @property {number} [radar.level.depth=3] Set the level depth.
15961 * @property {boolean} [radar.level.show=true] Show or hide level.
15962 * @property {Function} [radar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
15963 * @property {boolean} [radar.level.text.show=true] Show or hide level text.
15964 * @property {number} [radar.size.ratio=0.87] Set size ratio.
15965 * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.RadarChart)
15966 * @see [Demo: radar axis](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarAxis)
15967 * @see [Demo: radar level](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarLevel)
15968 * @see [Demo: radar size](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarSize)
15969 * @see [Demo: radar axis multiline](https://naver.github.io/billboard.js/demo/#RadarChartOptions.RadarAxisMultiline)
15970 * @example
15971 * radar: {
15972 * axis: {
15973 * max: 50,
15974 * line: {
15975 * show: false
15976 * },
15977 * text: {
15978 * position: {
15979 * x: 0,
15980 * y: 0
15981 * },
15982 * show: false
15983 * }
15984 * },
15985 * direction: {
15986 * clockwise: true
15987 * },
15988 * level: {
15989 * show: false,
15990 * text: {
15991 * format: function(x) {
15992 * return x + "%";
15993 * },
15994 * show: true
15995 * }
15996 * },
15997 * size: {
15998 * ratio: 0.7
15999 * }
16000 * }
16001 */
16002 radar_axis_max: undefined,
16003 radar_axis_line_show: !0,
16004 radar_axis_text_show: !0,
16005 radar_axis_text_position: {},
16006 radar_level_depth: 3,
16007 radar_level_show: !0,
16008 radar_level_text_format: function radar_level_text_format(x) {
16009 return x % 1 === 0 ? x : x.toFixed(2);
16010 },
16011 radar_level_text_show: !0,
16012 radar_size_ratio: .87,
16013 radar_direction_clockwise: !1
16014});
16015;// CONCATENATED MODULE: ./src/config/resolver/shape.ts
16016/**
16017 * Copyright (c) 2017 ~ present NAVER Corp.
16018 * billboard.js project is licensed under the MIT license
16019 */
16020
16021
16022
16023
16024 // Axis
16025
16026 // Shape
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036 // Options
16037
16038
16039
16040
16041
16042
16043
16044
16045 // Non-Axis based
16046
16047
16048
16049
16050
16051
16052/**
16053 * Extend Axis
16054 * @param {Array} module Module to be extended
16055 * @param {Array} option Option object to be extended
16056 * @private
16057 */
16058
16059function extendAxis(module, option) {
16060 extend(ChartInternal.prototype, internal.concat(module)), extend(Chart.prototype, api), Options.setOptions(options.concat(option || []));
16061}
16062/**
16063 * Extend Line type modules
16064 * @param {object} module Module to be extended
16065 * @param {Array} option Option object to be extended
16066 * @private
16067 */
16068
16069
16070function extendLine(module, option) {
16071 extendAxis([point, line].concat(module || [])), Options.setOptions([common_point, shape_line].concat(option || []));
16072}
16073/**
16074 * Extend Arc type modules
16075 * @param {Array} module Module to be extended
16076 * @param {Array} option Option object to be extended
16077 * @private
16078 */
16079
16080
16081function extendArc(module, option) {
16082 extend(ChartInternal.prototype, [arc].concat(module || [])), Options.setOptions(option);
16083} // Area types
16084
16085
16086var _area = function area() {
16087 return extendLine(shape_area, [Options_shape_area]), (_area = function area() {
16088 return TYPE.AREA;
16089 })();
16090},
16091 areaLineRange = function () {
16092 return extendLine(shape_area, [Options_shape_area]), (areaLineRange = function () {
16093 return TYPE.AREA_LINE_RANGE;
16094 })();
16095},
16096 areaSpline = function () {
16097 return extendLine(shape_area, [Options_shape_area, spline]), (areaSpline = function () {
16098 return TYPE.AREA_SPLINE;
16099 })();
16100},
16101 areaSplineRange = function () {
16102 return extendLine(shape_area, [Options_shape_area, spline]), (areaSplineRange = function () {
16103 return TYPE.AREA_SPLINE_RANGE;
16104 })();
16105},
16106 areaStep = function () {
16107 return extendLine(shape_area, [Options_shape_area]), (areaStep = function () {
16108 return TYPE.AREA_STEP;
16109 })();
16110},
16111 resolver_shape_line = function () {
16112 return extendLine(), (resolver_shape_line = function () {
16113 return TYPE.LINE;
16114 })();
16115},
16116 shape_spline = function () {
16117 return extendLine(undefined, [spline]), (shape_spline = function () {
16118 return TYPE.SPLINE;
16119 })();
16120},
16121 step = function () {
16122 return extendLine(), (step = function () {
16123 return TYPE.STEP;
16124 })();
16125},
16126 shape_donut = function () {
16127 return extendArc(undefined, [donut]), (shape_donut = function () {
16128 return TYPE.DONUT;
16129 })();
16130},
16131 resolver_shape_gauge = function () {
16132 return extendArc([gauge], [shape_gauge]), (resolver_shape_gauge = function () {
16133 return TYPE.GAUGE;
16134 })();
16135},
16136 shape_pie = function () {
16137 return extendArc(undefined, [pie]), (shape_pie = function () {
16138 return TYPE.PIE;
16139 })();
16140},
16141 resolver_shape_radar = function () {
16142 return extendArc([point, radar], [common_point, shape_radar]), (resolver_shape_radar = function () {
16143 return TYPE.RADAR;
16144 })();
16145},
16146 resolver_shape_bar = function () {
16147 return extendAxis([bar], shape_bar), (resolver_shape_bar = function () {
16148 return TYPE.BAR;
16149 })();
16150},
16151 resolver_shape_bubble = function () {
16152 return extendAxis([point, bubble], [shape_bubble, common_point]), (resolver_shape_bubble = function () {
16153 return TYPE.BUBBLE;
16154 })();
16155},
16156 resolver_shape_candlestick = function () {
16157 return extendAxis([candlestick], [shape_candlestick]), (resolver_shape_candlestick = function () {
16158 return TYPE.CANDLESTICK;
16159 })();
16160},
16161 shape_scatter = function () {
16162 return extendAxis([point], [common_point, scatter]), (shape_scatter = function () {
16163 return TYPE.SCATTER;
16164 })();
16165};
16166;// CONCATENATED MODULE: ./src/Chart/api/selection.ts
16167/**
16168 * Copyright (c) 2017 ~ present NAVER Corp.
16169 * billboard.js project is licensed under the MIT license
16170 */
16171
16172
16173
16174/* harmony default export */ var selection = ({
16175 /**
16176 * Get selected data points.<br><br>
16177 * By this API, you can get selected data points information. To use this API, data.selection.enabled needs to be set true.
16178 * @function selected
16179 * @instance
16180 * @memberof Chart
16181 * @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.
16182 * @returns {Array} dataPoint Array of the data points.<br>ex.) `[{x: 1, value: 200, id: "data1", index: 1, name: "data1"}, ...]`
16183 * @example
16184 * // all selected data points will be returned.
16185 * chart.selected();
16186 * // --> ex.) [{x: 1, value: 200, id: "data1", index: 1, name: "data1"}, ... ]
16187 *
16188 * // all selected data points of data1 will be returned.
16189 * chart.selected("data1");
16190 */
16191 selected: function selected(targetId) {
16192 var $$ = this.internal,
16193 dataPoint = [];
16194 return $$.$el.main.selectAll("." + (config_classes.shapes + $$.getTargetSelectorSuffix(targetId))).selectAll("." + config_classes.shape).filter(function () {
16195 return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.SELECTED);
16196 }).each(function (d) {
16197 return dataPoint.push(d);
16198 }), dataPoint;
16199 },
16200
16201 /**
16202 * 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)
16203 * @function select
16204 * @instance
16205 * @memberof Chart
16206 * @param {string|Array} [ids] id value to get selected.
16207 * @param {Array} [indices] The index array of data points. If falsy value given, will select all data points.
16208 * @param {boolean} [resetOther] Unselect already selected.
16209 * @example
16210 * // select all data points
16211 * chart.select();
16212 *
16213 * // select all from 'data2'
16214 * chart.select("data2");
16215 *
16216 * // select all from 'data1' and 'data2'
16217 * chart.select(["data1", "data2"]);
16218 *
16219 * // select from 'data1', indices 2 and unselect others selected
16220 * chart.select("data1", [2], true);
16221 *
16222 * // select from 'data1', indices 0, 3 and 5
16223 * chart.select("data1", [0, 3, 5]);
16224 */
16225 select: function select(ids, indices, resetOther) {
16226 var $$ = this.internal,
16227 config = $$.config,
16228 $el = $$.$el;
16229 config.data_selection_enabled && $el.main.selectAll("." + config_classes.shapes).selectAll("." + config_classes.shape).each(function (d, i) {
16230 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
16231 id = d.data ? d.data.id : d.id,
16232 toggle = $$.getToggle(this, d).bind($$),
16233 isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
16234 isTargetIndex = !indices || indices.indexOf(i) >= 0,
16235 isSelected = shape.classed(config_classes.SELECTED);
16236 // line/area selection not supported yet
16237 shape.classed(config_classes.line) || shape.classed(config_classes.area) || (isTargetId && isTargetIndex ? config.data_selection_isselectable.bind($$.api)(d) && !isSelected && toggle(!0, shape.classed(config_classes.SELECTED, !0), d, i) : isDefined(resetOther) && resetOther && isSelected && toggle(!1, shape.classed(config_classes.SELECTED, !1), d, i));
16238 });
16239 },
16240
16241 /**
16242 * Set data points to be un-selected.
16243 * @function unselect
16244 * @instance
16245 * @memberof Chart
16246 * @param {string|Array} [ids] id value to be unselected.
16247 * @param {Array} [indices] The index array of data points. If falsy value given, will select all data points.
16248 * @example
16249 * // unselect all data points
16250 * chart.unselect();
16251 *
16252 * // unselect all from 'data1'
16253 * chart.unselect("data1");
16254 *
16255 * // unselect from 'data1', indices 2
16256 * chart.unselect("data1", [2]);
16257 */
16258 unselect: function unselect(ids, indices) {
16259 var $$ = this.internal,
16260 config = $$.config,
16261 $el = $$.$el;
16262 config.data_selection_enabled && $el.main.selectAll("." + config_classes.shapes).selectAll("." + config_classes.shape).each(function (d, i) {
16263 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
16264 id = d.data ? d.data.id : d.id,
16265 toggle = $$.getToggle(this, d).bind($$),
16266 isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
16267 isTargetIndex = !indices || indices.indexOf(i) >= 0,
16268 isSelected = shape.classed(config_classes.SELECTED);
16269 // line/area selection not supported yet
16270 shape.classed(config_classes.line) || shape.classed(config_classes.area) || isTargetId && isTargetIndex && config.data_selection_isselectable.bind($$.api)(d) && isSelected && toggle(!1, shape.classed(config_classes.SELECTED, !1), d, i);
16271 });
16272 }
16273});
16274;// CONCATENATED MODULE: ./src/Chart/api/subchart.ts
16275/**
16276 * Copyright (c) 2017 ~ present NAVER Corp.
16277 * billboard.js project is licensed under the MIT license
16278 */
16279
16280/* harmony default export */ var subchart = ({
16281 subchart: {
16282 /**
16283 * Show subchart
16284 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
16285 * @function subchart․show
16286 * @instance
16287 * @memberof Chart
16288 * @example
16289 * // for ESM imports, needs to import 'subchart' and must be instantiated first to enable subchart's API.
16290 * import {subchart} from "billboard.js";
16291 *
16292 * const chart = bb.generate({
16293 * ...
16294 * subchart: {
16295 * // need to be instantiated by calling 'subchart()'
16296 * enabled: subchart()
16297 *
16298 * // in case don't want subchart to be shown at initialization, instantiate with '!subchart()'
16299 * enabled: !subchart()
16300 * }
16301 * });
16302 *
16303 * chart.subchart.show();
16304 */
16305 show: function () {
16306 var $$ = this.internal,
16307 subchart = $$.$el.subchart,
16308 config = $$.config,
16309 show = config.subchart_show;
16310
16311 if (!show) {
16312 config.subchart_show = !show, subchart.main || $$.initSubchart();
16313 var $target = subchart.main.selectAll("." + config_classes.target); // need to cover when new data has been loaded
16314
16315 $$.data.targets.length !== $target.size() && ($$.updateSizes(), $$.updateTargetsForSubchart($$.data.targets), $target = subchart.main.selectAll("." + config_classes.target)), $target.style("opacity", "1"), subchart.main.style("display", null), this.flush();
16316 }
16317 },
16318
16319 /**
16320 * Hide generated subchart
16321 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
16322 * @function subchart․hide
16323 * @instance
16324 * @memberof Chart
16325 * @example
16326 * chart.subchart.hide();
16327 */
16328 hide: function hide() {
16329 var $$ = this.internal,
16330 subchart = $$.$el.subchart,
16331 config = $$.config;
16332 config.subchart_show && subchart.main.style("display") !== "none" && (config.subchart_show = !1, subchart.main.style("display", "none"), this.flush());
16333 },
16334
16335 /**
16336 * Toggle the visiblity of subchart
16337 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
16338 * @function subchart․toggle
16339 * @instance
16340 * @memberof Chart
16341 * @example
16342 * // When subchart is hidden, will be shown
16343 * // When subchart is shown, will be hidden
16344 * chart.subchart.toggle();
16345 */
16346 toggle: function toggle() {
16347 var $$ = this.internal,
16348 config = $$.config;
16349 this.subchart[config.subchart_show ? "hide" : "show"]();
16350 }
16351 }
16352});
16353// EXTERNAL MODULE: external {"commonjs":"d3-zoom","commonjs2":"d3-zoom","amd":"d3-zoom","root":"d3"}
16354var external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_ = __webpack_require__(14);
16355;// CONCATENATED MODULE: ./src/Chart/api/zoom.ts
16356/**
16357 * Copyright (c) 2017 ~ present NAVER Corp.
16358 * billboard.js project is licensed under the MIT license
16359 */
16360
16361
16362
16363/**
16364 * Check if the given domain is within zoom range
16365 * @param {Array} domain domain value
16366 * @param {Array} range zoom range value
16367 * @returns {boolean}
16368 * @private
16369 */
16370
16371function withinRange(domain, range) {
16372 var min = range[0],
16373 max = range[1];
16374 return domain.every(function (v, i) {
16375 return i === 0 ? v >= min : v <= max;
16376 });
16377}
16378/**
16379 * Zoom by giving x domain.
16380 * - **NOTE:**
16381 * - For `wheel` type zoom, the minimum zoom range will be set as the given domain. To get the initial state, [.unzoom()](#unzoom) should be called.
16382 * - To be used [zoom.enabled](Options.html#.zoom) option should be set as `truthy`.
16383 * @function zoom
16384 * @instance
16385 * @memberof Chart
16386 * @param {Array} domainValue If domain is given, the chart will be zoomed to the given domain. If no argument is given, the current zoomed domain will be returned.
16387 * @returns {Array} domain value in array
16388 * @example
16389 * // Zoom to specified domain
16390 * chart.zoom([10, 20]);
16391 *
16392 * // Get the current zoomed domain
16393 * chart.zoom();
16394 */
16395
16396
16397var zoom = function (domainValue) {
16398 var resultDomain,
16399 $$ = this.internal,
16400 config = $$.config,
16401 scale = $$.scale,
16402 domain = domainValue;
16403 if (!(config.zoom_enabled && domain)) resultDomain = scale.zoom ? scale.zoom.domain() : scale.x.orgDomain();else if ($$.axis.isTimeSeries() && (domain = domain.map(function (x) {
16404 return parseDate.bind($$)(x);
16405 })), withinRange(domain, $$.getZoomDomain())) {
16406 if ($$.api.tooltip.hide(), config.subchart_show) {
16407 var xScale = scale.zoom || scale.x;
16408 $$.brush.getSelection().call($$.brush.move, [xScale(domain[0]), xScale(domain[1])]), resultDomain = domain;
16409 } else scale.x.domain(domain), scale.zoom = scale.x, $$.axis.x.scale(scale.zoom), resultDomain = scale.zoom.orgDomain();
16410
16411 $$.redraw({
16412 withTransition: !0,
16413 withY: config.zoom_rescale,
16414 withDimension: !1
16415 }), $$.setZoomResetButton(), callFn(config.zoom_onzoom, $$.api, resultDomain);
16416 }
16417 return resultDomain;
16418};
16419
16420extend(zoom, {
16421 /**
16422 * Enable and disable zooming.
16423 * @function zoom․enable
16424 * @instance
16425 * @memberof Chart
16426 * @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.
16427 * @example
16428 * // Enable zooming using the mouse wheel
16429 * chart.zoom.enable(true);
16430 * // Or
16431 * chart.zoom.enable("wheel");
16432 *
16433 * // Enable zooming by dragging
16434 * chart.zoom.enable("drag");
16435 *
16436 * // Disable zooming
16437 * chart.zoom.enable(false);
16438 */
16439 enable: function enable(enabled) {
16440 var $$ = this.internal,
16441 config = $$.config;
16442 /^(drag|wheel)$/.test(enabled) && (config.zoom_type = enabled), config.zoom_enabled = !!enabled, $$.zoom ? enabled === !1 && $$.bindZoomEvent(!1) : ($$.initZoom(), $$.bindZoomEvent()), $$.updateAndRedraw();
16443 },
16444
16445 /**
16446 * Set or get x Axis maximum zoom range value
16447 * @function zoom․max
16448 * @instance
16449 * @memberof Chart
16450 * @param {number} [max] maximum value to set for zoom
16451 * @returns {number} zoom max value
16452 * @example
16453 * // Set maximum range value
16454 * chart.zoom.max(20);
16455 */
16456 max: function max(_max) {
16457 var $$ = this.internal,
16458 config = $$.config,
16459 xDomain = $$.org.xDomain;
16460 return (_max === 0 || _max) && (config.zoom_x_max = getMinMax("max", [xDomain[1], _max])), config.zoom_x_max;
16461 },
16462
16463 /**
16464 * Set or get x Axis minimum zoom range value
16465 * @function zoom․min
16466 * @instance
16467 * @memberof Chart
16468 * @param {number} [min] minimum value to set for zoom
16469 * @returns {number} zoom min value
16470 * @example
16471 * // Set minimum range value
16472 * chart.zoom.min(-1);
16473 */
16474 min: function min(_min) {
16475 var $$ = this.internal,
16476 config = $$.config,
16477 xDomain = $$.org.xDomain;
16478 return (_min === 0 || _min) && (config.zoom_x_min = getMinMax("min", [xDomain[0], _min])), config.zoom_x_min;
16479 },
16480
16481 /**
16482 * Set zoom range
16483 * @function zoom․range
16484 * @instance
16485 * @memberof Chart
16486 * @param {object} [range] zoom range
16487 * @returns {object} zoom range value
16488 * {
16489 * min: 0,
16490 * max: 100
16491 * }
16492 * @example
16493 * chart.zoom.range({
16494 * min: 10,
16495 * max: 100
16496 * });
16497 */
16498 range: function range(_range) {
16499 var zoom = this.zoom;
16500
16501 if (isObject(_range)) {
16502 var min = _range.min,
16503 max = _range.max;
16504 isDefined(min) && zoom.min(min), isDefined(max) && zoom.max(max);
16505 }
16506
16507 return {
16508 min: zoom.min(),
16509 max: zoom.max()
16510 };
16511 }
16512});
16513/* harmony default export */ var api_zoom = ({
16514 zoom: zoom,
16515
16516 /**
16517 * Unzoom zoomed area
16518 * @function unzoom
16519 * @instance
16520 * @memberof Chart
16521 * @example
16522 * chart.unzoom();
16523 */
16524 unzoom: function unzoom() {
16525 var $$ = this.internal,
16526 config = $$.config;
16527
16528 if ($$.scale.zoom) {
16529 config.subchart_show ? $$.brush.getSelection().call($$.brush.move, null) : $$.zoom.updateTransformScale(external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity), $$.updateZoom(!0), $$.zoom.resetBtn && $$.zoom.resetBtn.style("display", "none");
16530 // reset transform
16531 var eventRects = $$.$el.main.select("." + config_classes.eventRects);
16532 (0,external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomTransform)(eventRects.node()) !== external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity && $$.zoom.transform(eventRects, external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity), $$.redraw({
16533 withTransition: !0,
16534 withUpdateXDomain: !0,
16535 withUpdateOrgXDomain: !0,
16536 withY: config.zoom_rescale
16537 });
16538 }
16539 }
16540});
16541// EXTERNAL MODULE: external {"commonjs":"d3-color","commonjs2":"d3-color","amd":"d3-color","root":"d3"}
16542var external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_ = __webpack_require__(13);
16543;// CONCATENATED MODULE: ./src/ChartInternal/interactions/drag.ts
16544/**
16545 * Copyright (c) 2017 ~ present NAVER Corp.
16546 * billboard.js project is licensed under the MIT license
16547 */
16548
16549
16550
16551/**
16552 * Module used for data.selection.draggable option
16553 */
16554
16555/* harmony default export */ var drag = ({
16556 /**
16557 * Called when dragging.
16558 * Data points can be selected.
16559 * @private
16560 * @param {object} mouse Object
16561 */
16562 drag: function drag(mouse) {
16563 var $$ = this,
16564 config = $$.config,
16565 state = $$.state,
16566 main = $$.$el.main,
16567 isSelectionGrouped = config.data_selection_grouped,
16568 isSelectable = config.interaction_enabled && config.data_selection_isselectable;
16569
16570 if (!$$.hasArcType() && config.data_selection_enabled && ( // do nothing if not selectable
16571 !config.zoom_enabled || $$.zoom.altDomain) && config.data_selection_multiple // skip when single selection because drag is used for multiple selection
16572 ) {
16573 var _ref = state.dragStart || [0, 0],
16574 sx = _ref[0],
16575 sy = _ref[1],
16576 mx = mouse[0],
16577 my = mouse[1],
16578 minX = Math.min(sx, mx),
16579 maxX = Math.max(sx, mx),
16580 minY = isSelectionGrouped ? state.margin.top : Math.min(sy, my),
16581 maxY = isSelectionGrouped ? state.height : Math.max(sy, my);
16582
16583 main.select("." + config_classes.dragarea).attr("x", minX).attr("y", minY).attr("width", maxX - minX).attr("height", maxY - minY), main.selectAll("." + config_classes.shapes).selectAll("." + config_classes.shape).filter(function (d) {
16584 return isSelectable && isSelectable.bind($$.api)(d);
16585 }).each(function (d, i) {
16586 var toggle,
16587 shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
16588 isSelected = shape.classed(config_classes.SELECTED),
16589 isIncluded = shape.classed(config_classes.INCLUDED),
16590 isWithin = !1;
16591
16592 if (shape.classed(config_classes.circle)) {
16593 var x = +shape.attr("cx") * 1,
16594 y = +shape.attr("cy") * 1;
16595 toggle = $$.togglePoint, isWithin = minX < x && x < maxX && minY < y && y < maxY;
16596 } else if (shape.classed(config_classes.bar)) {
16597 var _getPathBox = getPathBox(this),
16598 _x = _getPathBox.x,
16599 y = _getPathBox.y,
16600 width = _getPathBox.width,
16601 height = _getPathBox.height;
16602
16603 toggle = $$.togglePath, isWithin = !(maxX < _x || _x + width < minX) && !(maxY < y || y + height < minY);
16604 } else // line/area selection not supported yet
16605 return; // @ts-ignore
16606
16607
16608 isWithin ^ isIncluded && (shape.classed(config_classes.INCLUDED, !isIncluded), shape.classed(config_classes.SELECTED, !isSelected), toggle.call($$, !isSelected, shape, d, i));
16609 });
16610 }
16611 },
16612
16613 /**
16614 * Called when the drag starts.
16615 * Adds and Shows the drag area.
16616 * @private
16617 * @param {object} mouse Object
16618 */
16619 dragstart: function dragstart(mouse) {
16620 var $$ = this,
16621 config = $$.config,
16622 state = $$.state,
16623 main = $$.$el.main;
16624 $$.hasArcType() || !config.data_selection_enabled || (state.dragStart = mouse, main.select("." + config_classes.chart).append("rect").attr("class", config_classes.dragarea).style("opacity", "0.1"), $$.setDragStatus(!0));
16625 },
16626
16627 /**
16628 * Called when the drag finishes.
16629 * Removes the drag area.
16630 * @private
16631 */
16632 dragend: function dragend() {
16633 var $$ = this,
16634 config = $$.config,
16635 main = $$.$el.main;
16636 $$.hasArcType() || !config.data_selection_enabled || (main.select("." + config_classes.dragarea).transition().duration(100).style("opacity", "0").remove(), main.selectAll("." + config_classes.shape).classed(config_classes.INCLUDED, !1), $$.setDragStatus(!1));
16637 }
16638});
16639;// CONCATENATED MODULE: ./src/ChartInternal/internals/selection.ts
16640
16641
16642function selection_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16643
16644function selection_objectSpread(target) { for (var source, i = 1; i < arguments.length; i++) source = arguments[i] == null ? {} : arguments[i], i % 2 ? selection_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : selection_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); return target; }
16645
16646/**
16647 * Copyright (c) 2017 ~ present NAVER Corp.
16648 * billboard.js project is licensed under the MIT license
16649 */
16650
16651
16652
16653
16654
16655/* harmony default export */ var internals_selection = (selection_objectSpread(selection_objectSpread({}, drag), {}, {
16656 /**
16657 * Select a point
16658 * @param {object} target Target point
16659 * @param {object} d Data object
16660 * @param {number} i Index number
16661 * @private
16662 */
16663 selectPoint: function selectPoint(target, d, i) {
16664 var $$ = this,
16665 config = $$.config,
16666 main = $$.$el.main,
16667 isRotated = config.axis_rotated,
16668 cx = (isRotated ? $$.circleY : $$.circleX).bind($$),
16669 cy = (isRotated ? $$.circleX : $$.circleY).bind($$),
16670 r = $$.pointSelectR.bind($$);
16671 // add selected-circle on low layer g
16672 callFn(config.data_onselected, $$.api, d, target.node()), main.select("." + config_classes.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll("." + config_classes.selectedCircle + "-" + i).data([d]).enter().append("circle").attr("class", function () {
16673 return $$.generateClass(config_classes.selectedCircle, i);
16674 }).attr("cx", cx).attr("cy", cy).attr("stroke", $$.color).attr("r", function (d2) {
16675 return $$.pointSelectR(d2) * 1.4;
16676 }).transition().duration(100).attr("r", r);
16677 },
16678
16679 /**
16680 * Unelect a point
16681 * @param {object} target Target point
16682 * @param {object} d Data object
16683 * @param {number} i Index number
16684 * @private
16685 */
16686 unselectPoint: function unselectPoint(target, d, i) {
16687 var $$ = this,
16688 config = $$.config,
16689 $el = $$.$el;
16690 // remove selected-circle from low layer g
16691 callFn(config.data_onunselected, $$.api, d, target.node()), $el.main.select("." + config_classes.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll("." + config_classes.selectedCircle + "-" + i).transition().duration(100).attr("r", 0).remove();
16692 },
16693
16694 /**
16695 * Toggles the selection of points
16696 * @param {boolean} selected whether or not to select.
16697 * @param {object} target Target object
16698 * @param {object} d Data object
16699 * @param {number} i Index number
16700 * @private
16701 */
16702 togglePoint: function togglePoint(selected, target, d, i) {
16703 var method = (selected ? "" : "un") + "selectPoint";
16704 this[method](target, d, i);
16705 },
16706
16707 /**
16708 * Select a path
16709 * @param {object} target Target path
16710 * @param {object} d Data object
16711 * @private
16712 */
16713 selectPath: function selectPath(target, d) {
16714 var $$ = this,
16715 config = $$.config;
16716 callFn(config.data_onselected, $$.api, d, target.node()), config.interaction_brighten && target.transition().duration(100).style("fill", function () {
16717 return (0,external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_.rgb)($$.color(d)).brighter(.75);
16718 });
16719 },
16720
16721 /**
16722 * Unelect a path
16723 * @private
16724 * @param {object} target Target path
16725 * @param {object} d Data object
16726 */
16727 unselectPath: function unselectPath(target, d) {
16728 var $$ = this,
16729 config = $$.config;
16730 callFn(config.data_onunselected, $$.api, d, target.node()), config.interaction_brighten && target.transition().duration(100).style("fill", function () {
16731 return $$.color(d);
16732 });
16733 },
16734
16735 /**
16736 * Toggles the selection of lines
16737 * @param {boolean} selected whether or not to select.
16738 * @param {object} target Target object
16739 * @param {object} d Data object
16740 * @param {number} i Index number
16741 * @private
16742 */
16743 togglePath: function togglePath(selected, target, d, i) {
16744 this[(selected ? "" : "un") + "selectPath"](target, d, i);
16745 },
16746
16747 /**
16748 * Returns the toggle method of the target
16749 * @param {object} that shape
16750 * @param {object} d Data object
16751 * @returns {Function} toggle method
16752 * @private
16753 */
16754 getToggle: function getToggle(that, d) {
16755 var $$ = this;
16756 return that.nodeName === "path" ? $$.togglePath : $$.isStepType(d) ? function () {} : // circle is hidden in step chart, so treat as within the click area
16757 $$.togglePoint;
16758 },
16759
16760 /**
16761 * Toggles the selection of shapes
16762 * @param {object} that shape
16763 * @param {object} d Data object
16764 * @param {number} i Index number
16765 * @private
16766 */
16767 toggleShape: function toggleShape(that, d, i) {
16768 var toggledShape,
16769 $$ = this,
16770 config = $$.config,
16771 main = $$.$el.main,
16772 shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that),
16773 isSelected = shape.classed(config_classes.SELECTED),
16774 toggle = $$.getToggle(that, d).bind($$);
16775
16776 if (config.data_selection_enabled && config.data_selection_isselectable.bind($$.api)(d)) {
16777 if (!config.data_selection_multiple) {
16778 var selector = "." + config_classes.shapes;
16779 config.data_selection_grouped && (selector += $$.getTargetSelectorSuffix(d.id)), main.selectAll(selector).selectAll("." + config_classes.shape).each(function (d, i) {
16780 var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
16781 shape.classed(config_classes.SELECTED) && (toggledShape = shape, toggle(!1, shape.classed(config_classes.SELECTED, !1), d, i));
16782 });
16783 }
16784
16785 toggledShape && toggledShape.node() === shape.node() || (shape.classed(config_classes.SELECTED, !isSelected), toggle(!isSelected, shape, d, i));
16786 }
16787 }
16788}));
16789;// CONCATENATED MODULE: ./src/ChartInternal/interactions/subchart.ts
16790/**
16791 * Copyright (c) 2017 ~ present NAVER Corp.
16792 * billboard.js project is licensed under the MIT license
16793 */
16794
16795
16796
16797
16798/* harmony default export */ var interactions_subchart = ({
16799 /**
16800 * Initialize the brush.
16801 * @private
16802 */
16803 initBrush: function initBrush() {
16804 var $$ = this,
16805 config = $$.config,
16806 scale = $$.scale,
16807 subchart = $$.$el.subchart,
16808 isRotated = config.axis_rotated;
16809 $$.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)();
16810
16811 // set "brush" event
16812 var lastDomain,
16813 timeout,
16814 brushHandler = function () {
16815 $$.redrawForBrush();
16816 },
16817 getBrushSize = function () {
16818 var brush = $$.$el.svg.select("." + config_classes.brush + " .overlay"),
16819 brushSize = {
16820 width: 0,
16821 height: 0
16822 };
16823 return brush.size() && (brushSize.width = +brush.attr("width"), brushSize.height = +brush.attr("height")), brushSize[isRotated ? "width" : "height"];
16824 };
16825
16826 // set the brush extent
16827 $$.brush.on("start", function () {
16828 $$.state.inputType === "touch" && $$.hideTooltip(), brushHandler();
16829 }).on("brush", brushHandler).on("end", function () {
16830 lastDomain = scale.x.orgDomain();
16831 }), $$.brush.updateResize = function () {
16832 var _this = this;
16833
16834 timeout && clearTimeout(timeout), timeout = setTimeout(function () {
16835 var selection = _this.getSelection();
16836
16837 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()));
16838 }, 0);
16839 }, $$.brush.update = function () {
16840 var extent = this.extent()();
16841 return extent[1].filter(function (v) {
16842 return isNaN(v);
16843 }).length === 0 && subchart.main && subchart.main.select("." + config_classes.brush).call(this), this;
16844 }, $$.brush.scale = function (scale) {
16845 var h = config.subchart_size_height || getBrushSize(),
16846 extent = $$.getExtent();
16847 // [[x0, y0], [x1, y1]], where [x0, y0] is the top-left corner and [x1, y1] is the bottom-right corner
16848 // when extent updates, brush selection also be re-applied
16849 // https://github.com/d3/d3/issues/2918
16850 !extent && scale.range ? extent = [[0, 0], [scale.range()[1], h]] : isArray(extent) && (extent = extent.map(function (v, i) {
16851 return [v, i > 0 ? h : i];
16852 })), isRotated && extent[1].reverse(), this.extent(extent), this.update();
16853 }, $$.brush.getSelection = function () {
16854 return (// @ts-ignore
16855 subchart.main ? subchart.main.select("." + config_classes.brush) : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)([])
16856 );
16857 };
16858 },
16859
16860 /**
16861 * Initialize the subchart.
16862 * @private
16863 */
16864 initSubchart: function initSubchart() {
16865 var $$ = this,
16866 config = $$.config,
16867 _$$$state = $$.state,
16868 clip = _$$$state.clip,
16869 hasAxis = _$$$state.hasAxis,
16870 _$$$$el = $$.$el,
16871 defs = _$$$$el.defs,
16872 svg = _$$$$el.svg,
16873 subchart = _$$$$el.subchart,
16874 axis = _$$$$el.axis;
16875
16876 if (hasAxis) {
16877 var visibility = config.subchart_show ? "visible" : "hidden",
16878 clipId = clip.id + "-subchart",
16879 clipPath = $$.getClipPath(clipId);
16880 clip.idSubchart = clipId, $$.appendClip(defs, clipId), $$.initBrush(), subchart.main = svg.append("g").classed(config_classes.subchart, !0).attr("transform", $$.getTranslate("context"));
16881 var main = subchart.main;
16882 main.style("visibility", visibility), main.append("g").attr("clip-path", clipPath).attr("class", config_classes.chart), ["bar", "line", "bubble", "candlestick", "scatter"].forEach(function (v) {
16883 var type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
16884
16885 if ($$.hasType(v) || $$.hasTypeOf(type)) {
16886 var chart = main.select("." + config_classes.chart),
16887 chartClassName = config_classes["chart" + type + "s"];
16888 chart.select("." + chartClassName).empty() && chart.append("g").attr("class", chartClassName);
16889 }
16890 }), main.append("g").attr("clip-path", clipPath).attr("class", config_classes.brush).call($$.brush), 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");
16891 }
16892 },
16893
16894 /**
16895 * Update sub chart
16896 * @param {object} targets $$.data.targets
16897 * @private
16898 */
16899 updateTargetsForSubchart: function updateTargetsForSubchart(targets) {
16900 var $$ = this,
16901 config = $$.config,
16902 state = $$.state,
16903 main = $$.$el.subchart.main;
16904 config.subchart_show && (["bar", "line", "bubble", "candlestick", "scatter"].filter(function (v) {
16905 return $$.hasType(v) || $$.hasTypeOf(capitalize(v));
16906 }).forEach(function (v) {
16907 var isPointType = /^(bubble|scatter)$/.test(v),
16908 name = capitalize(isPointType ? "circle" : v),
16909 chartClass = $$.getChartClass(name, !0),
16910 shapeClass = $$.getClass(isPointType ? "circles" : v + "s", !0),
16911 shapeChart = main.select("." + config_classes["chart" + (name + "s")]);
16912
16913 if (isPointType) {
16914 var circle = shapeChart.selectAll("." + config_classes.circles).data(targets.filter($$["is" + capitalize(v) + "Type"].bind($$))).attr("class", shapeClass);
16915 circle.exit().remove(), circle.enter().append("g").attr("class", shapeClass);
16916 } else {
16917 var shapeUpdate = shapeChart.selectAll("." + config_classes["chart" + name]).attr("class", chartClass).data(targets.filter($$["is" + name + "Type"].bind($$))),
16918 shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
16919 // Area
16920 shapeUpdate.exit().remove(), v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", !0));
16921 }
16922 }), main.selectAll("." + config_classes.brush + " rect").attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? state.width2 : state.height2));
16923 },
16924
16925 /**
16926 * Redraw subchart.
16927 * @private
16928 * @param {boolean} withSubchart whether or not to show subchart
16929 * @param {number} duration duration
16930 * @param {object} shape Shape's info
16931 */
16932 redrawSubchart: function redrawSubchart(withSubchart, duration, shape) {
16933 var $$ = this,
16934 config = $$.config,
16935 main = $$.$el.subchart.main,
16936 state = $$.state,
16937 withTransition = !!duration;
16938
16939 // subchart
16940 if (main.style("visibility", config.subchart_show ? "visible" : "hidden"), config.subchart_show && (state.event && state.event.type === "zoom" && $$.brush.update(), withSubchart && (brushEmpty($$) || $$.brush.update(), Object.keys(shape.type).forEach(function (v) {
16941 var name = capitalize(v),
16942 drawFn = $$["generateDraw" + name](shape.indices[v], !0);
16943 $$["update" + name](duration, !0), $$["redraw" + name](drawFn, withTransition, !0);
16944 }), $$.hasType("bubble") || $$.hasType("scatter")))) // update subchart elements if needed
16945 {
16946 var cx = shape.pos.cx,
16947 cy = $$.updateCircleY(!0);
16948 $$.updateCircle(!0), $$.redrawCircle(cx, cy, withTransition, undefined, !0);
16949 }
16950 },
16951
16952 /**
16953 * Redraw the brush.
16954 * @private
16955 */
16956 redrawForBrush: function redrawForBrush() {
16957 var $$ = this,
16958 _$$$config = $$.config,
16959 onBrush = _$$$config.subchart_onbrush,
16960 withY = _$$$config.zoom_rescale,
16961 scale = $$.scale;
16962 $$.redraw({
16963 withTransition: !1,
16964 withY: withY,
16965 withSubchart: !1,
16966 withUpdateXDomain: !0,
16967 withDimension: !1
16968 }), onBrush.bind($$.api)(scale.x.orgDomain());
16969 },
16970
16971 /**
16972 * Transform context
16973 * @param {boolean} withTransition indicates transition is enabled
16974 * @param {object} transitions The return value of the generateTransitions method of Axis.
16975 * @private
16976 */
16977 transformContext: function transformContext(withTransition, transitions) {
16978 var subXAxis,
16979 $$ = this,
16980 main = $$.$el.subchart.main;
16981 transitions && transitions.axisSubX ? subXAxis = transitions.axisSubX : (subXAxis = main.select("." + config_classes.axisX), withTransition && (subXAxis = subXAxis.transition())), main.attr("transform", $$.getTranslate("context")), subXAxis.attr("transform", $$.getTranslate("subX"));
16982 },
16983
16984 /**
16985 * Get extent value
16986 * @returns {Array} default extent
16987 * @private
16988 */
16989 getExtent: function getExtent() {
16990 var $$ = this,
16991 config = $$.config,
16992 scale = $$.scale,
16993 extent = config.axis_x_extent;
16994 if (extent) if (isFunction(extent)) extent = extent.bind($$.api)($$.getXDomain($$.data.targets), scale.subX);else if ($$.axis.isTimeSeries() && extent.every(isNaN)) {
16995 var fn = parseDate.bind($$);
16996 extent = extent.map(function (v) {
16997 return scale.subX(fn(v));
16998 });
16999 }
17000 return extent;
17001 }
17002});
17003;// CONCATENATED MODULE: ./src/ChartInternal/interactions/zoom.ts
17004/**
17005 * Copyright (c) 2017 ~ present NAVER Corp.
17006 * billboard.js project is licensed under the MIT license
17007 */
17008
17009
17010
17011
17012
17013
17014/* harmony default export */ var interactions_zoom = ({
17015 /**
17016 * Initialize zoom.
17017 * @private
17018 */
17019 initZoom: function initZoom() {
17020 var $$ = this;
17021 $$.scale.zoom = null, $$.generateZoom(), $$.initZoomBehaviour();
17022 },
17023
17024 /**
17025 * Bind zoom event
17026 * @param {boolean} bind Weather bind or unbound
17027 * @private
17028 */
17029 bindZoomEvent: function bindZoomEvent(bind) {
17030 bind === void 0 && (bind = !0);
17031 var $$ = this,
17032 config = $$.config,
17033 main = $$.$el.main,
17034 zoomEnabled = config.zoom_enabled,
17035 eventRects = main.select("." + config_classes.eventRects);
17036 zoomEnabled && bind ? !config.subchart_show && $$.bindZoomOnEventRect(eventRects, config.zoom_type) : bind === !1 && ($$.api.unzoom(), eventRects.on(".zoom", null).on(".drag", null));
17037 },
17038
17039 /**
17040 * Generate zoom
17041 * @private
17042 */
17043 generateZoom: function generateZoom() {
17044 var $$ = this,
17045 config = $$.config,
17046 org = $$.org,
17047 scale = $$.scale,
17048 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($$));
17049 // get zoom extent
17050 // @ts-ignore
17051 // @ts-ignore
17052
17053 /**
17054 * Update scale according zoom transform value
17055 * @param {object} transform transform object
17056 * @private
17057 */
17058 // @ts-ignore
17059 zoom.orgScaleExtent = function () {
17060 var extent = config.zoom_extent || [1, 10];
17061 return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])];
17062 }, zoom.updateScaleExtent = function () {
17063 var ratio = diffDomain($$.scale.x.orgDomain()) / diffDomain($$.getZoomDomain()),
17064 extent = this.orgScaleExtent();
17065 return this.scaleExtent([extent[0] * ratio, extent[1] * ratio]), this;
17066 }, zoom.updateTransformScale = function (transform) {
17067 org.xScale && org.xScale.range(scale.x.range());
17068 // rescale from the original scale
17069 var newScale = transform[config.axis_rotated ? "rescaleY" : "rescaleX"](org.xScale || scale.x),
17070 domain = $$.trimXDomain(newScale.domain()),
17071 rescale = config.zoom_rescale;
17072 newScale.domain(domain, org.xDomain), scale.zoom = $$.getCustomizedScale(newScale), $$.axis.x.scale(scale.zoom), rescale && (!org.xScale && (org.xScale = scale.x.copy()), scale.x.domain(domain));
17073 }, $$.zoom = zoom;
17074 },
17075
17076 /**
17077 * 'start' event listener
17078 * @param {object} event Event object
17079 * @private
17080 */
17081 onZoomStart: function onZoomStart(event) {
17082 var $$ = this,
17083 sourceEvent = event.sourceEvent;
17084 sourceEvent && ($$.zoom.startEvent = sourceEvent, $$.state.zooming = !0, callFn($$.config.zoom_onzoomstart, $$.api, event));
17085 },
17086
17087 /**
17088 * 'zoom' event listener
17089 * @param {object} event Event object
17090 * @private
17091 */
17092 onZoom: function onZoom(event) {
17093 var $$ = this,
17094 config = $$.config,
17095 scale = $$.scale,
17096 org = $$.org,
17097 sourceEvent = event.sourceEvent;
17098
17099 if (config.zoom_enabled && event.sourceEvent && $$.filterTargetsToShow($$.data.targets).length !== 0 && (scale.zoom || !(sourceEvent.type.indexOf("touch") > -1) || sourceEvent.touches.length !== 1)) {
17100 var isMousemove = sourceEvent.type === "mousemove",
17101 isZoomOut = sourceEvent.wheelDelta < 0,
17102 transform = event.transform;
17103 !isMousemove && isZoomOut && scale.x.domain().every(function (v, i) {
17104 return v !== org.xDomain[i];
17105 }) && scale.x.domain(org.xDomain), $$.zoom.updateTransformScale(transform), $$.axis.isCategorized() && scale.x.orgDomain()[0] === org.xDomain[0] && scale.x.domain([org.xDomain[0] - 1e-10, scale.x.orgDomain()[1]]), $$.redraw({
17106 withTransition: !1,
17107 withY: config.zoom_rescale,
17108 withSubchart: !1,
17109 withEventRect: !1,
17110 withDimension: !1
17111 }), $$.state.cancelClick = isMousemove, callFn(config.zoom_onzoom, $$.api, scale.zoom.domain());
17112 }
17113 },
17114
17115 /**
17116 * 'end' event listener
17117 * @param {object} event Event object
17118 * @private
17119 */
17120 onZoomEnd: function onZoomEnd(event) {
17121 var $$ = this,
17122 config = $$.config,
17123 scale = $$.scale,
17124 startEvent = $$.zoom.startEvent,
17125 e = event && event.sourceEvent;
17126 startEvent && startEvent.type.indexOf("touch") > -1 && (startEvent = startEvent.changedTouches[0], e = e.changedTouches[0]);
17127 // if click, do nothing. otherwise, click interaction will be canceled.
17128 !startEvent || e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY || ($$.redrawEventRect(), $$.updateZoom(), $$.state.zooming = !1, callFn(config.zoom_onzoomend, $$.api, scale[scale.zoom ? "zoom" : "subX"].domain()));
17129 },
17130
17131 /**
17132 * Get zoom domain
17133 * @returns {Array} zoom domain
17134 * @private
17135 */
17136 getZoomDomain: function getZoomDomain() {
17137 var $$ = this,
17138 config = $$.config,
17139 org = $$.org,
17140 _org$xDomain = org.xDomain,
17141 min = _org$xDomain[0],
17142 max = _org$xDomain[1];
17143 return isDefined(config.zoom_x_min) && (min = getMinMax("min", [min, config.zoom_x_min])), isDefined(config.zoom_x_max) && (max = getMinMax("max", [max, config.zoom_x_max])), [min, max];
17144 },
17145
17146 /**
17147 * Update zoom
17148 * @param {boolean} force Force unzoom
17149 * @private
17150 */
17151 updateZoom: function updateZoom(force) {
17152 var $$ = this,
17153 _$$$scale = $$.scale,
17154 subX = _$$$scale.subX,
17155 x = _$$$scale.x,
17156 zoom = _$$$scale.zoom;
17157
17158 if (zoom) {
17159 var zoomDomain = zoom.domain(),
17160 xDomain = subX.domain(),
17161 delta = .015,
17162 isfullyShown = (zoomDomain[0] <= xDomain[0] || zoomDomain[0] - delta <= xDomain[0]) && (xDomain[1] <= zoomDomain[1] || xDomain[1] <= zoomDomain[1] - delta);
17163 (force || isfullyShown) && ($$.axis.x.scale(subX), x.domain(subX.orgDomain()), $$.scale.zoom = null);
17164 }
17165 },
17166
17167 /**
17168 * Attach zoom event on <rect>
17169 * @param {d3.selection} eventRects evemt <rect> element
17170 * @param {string} type zoom type
17171 * @private
17172 */
17173 bindZoomOnEventRect: function bindZoomOnEventRect(eventRects, type) {
17174 var $$ = this,
17175 behaviour = type === "drag" ? $$.zoomBehaviour : $$.zoom;
17176 // Since Chrome 89, wheel zoom not works properly
17177 // Applying the workaround: https://github.com/d3/d3-zoom/issues/231#issuecomment-802305692
17178 $$.$el.svg.on("wheel", function () {}), eventRects.call(behaviour).on("dblclick.zoom", null);
17179 },
17180
17181 /**
17182 * Initialize the drag behaviour used for zooming.
17183 * @private
17184 */
17185 initZoomBehaviour: function initZoomBehaviour() {
17186 var zoomRect,
17187 $$ = this,
17188 config = $$.config,
17189 state = $$.state,
17190 isRotated = config.axis_rotated,
17191 start = 0,
17192 end = 0,
17193 prop = {
17194 axis: isRotated ? "y" : "x",
17195 attr: isRotated ? "height" : "width",
17196 index: isRotated ? 1 : 0
17197 };
17198 $$.zoomBehaviour = (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().clickDistance(4).on("start", function (event) {
17199 state.event = event, $$.setDragStatus(!0), $$.unselectRect(), zoomRect || (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)), start = getPointer(event, this)[prop.index], end = start, zoomRect.attr(prop.axis, start).attr(prop.attr, 0), $$.onZoomStart(event);
17200 }).on("drag", function (event) {
17201 end = getPointer(event, this)[prop.index], zoomRect.attr(prop.axis, Math.min(start, end)).attr(prop.attr, Math.abs(end - start));
17202 }).on("end", function (event) {
17203 var _ref,
17204 scale = $$.scale.zoom || $$.scale.x;
17205
17206 if (state.event = event, $$.setDragStatus(!1), zoomRect.attr(prop.axis, 0).attr(prop.attr, 0), start > end && (_ref = [end, start], start = _ref[0], end = _ref[1], _ref), start < 0 && (end += Math.abs(start), start = 0), start !== end) $$.api.zoom([start, end].map(function (v) {
17207 return scale.invert(v);
17208 })), $$.onZoomEnd(event);else if ($$.isMultipleX()) $$.clickHandlerForMultipleXS.bind(this)($$);else {
17209 var _getPointer = getPointer(event),
17210 x = _getPointer[0],
17211 y = _getPointer[1],
17212 target = browser_doc.elementFromPoint(x, y);
17213
17214 $$.clickHandlerForSingleX.bind(target)((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum(), $$);
17215 }
17216 });
17217 },
17218 setZoomResetButton: function setZoomResetButton() {
17219 var $$ = this,
17220 config = $$.config,
17221 resetButton = config.zoom_resetButton;
17222 resetButton && config.zoom_type === "drag" && ($$.zoom.resetBtn ? $$.zoom.resetBtn.style("display", null) : $$.zoom.resetBtn = $$.$el.chart.append("div").classed(config_classes.button, !0).append("span").on("click", function () {
17223 isFunction(resetButton.onclick) && resetButton.onclick.bind($$.api)(this), $$.api.unzoom();
17224 }).classed(config_classes.buttonZoomReset, !0).text(resetButton.text || "Reset Zoom"));
17225 }
17226});
17227;// CONCATENATED MODULE: ./src/config/Options/data/selection.ts
17228/**
17229 * Copyright (c) 2017 ~ present NAVER Corp.
17230 * billboard.js project is licensed under the MIT license
17231 */
17232
17233/**
17234 * data.selection config options
17235 */
17236/* harmony default export */ var data_selection = ({
17237 /**
17238 * Set data selection enabled<br><br>
17239 * 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).
17240 * - **NOTE:** for ESM imports, needs to import 'selection' exports and instantiate it by calling `selection()`.
17241 * - `enabled: selection()`
17242 * @name data․selection․enabled
17243 * @memberof Options
17244 * @type {boolean}
17245 * @default false
17246 * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataSelection)
17247 * @example
17248 * data: {
17249 * selection: {
17250 * enabled: true
17251 * }
17252 * }
17253 * @example
17254 * // importing ESM
17255 * import bb, {selection} from "billboard.js";
17256 *
17257 * data: {
17258 * selection: {
17259 * enabled: selection(),
17260 * ...
17261 * }
17262 * }
17263 */
17264 data_selection_enabled: !1,
17265
17266 /**
17267 * Set grouped selection enabled.<br><br>
17268 * If this option set true, multiple data points that have same x value will be selected by one selection.
17269 * @name data․selection․grouped
17270 * @memberof Options
17271 * @type {boolean}
17272 * @default false
17273 * @example
17274 * data: {
17275 * selection: {
17276 * grouped: true
17277 * }
17278 * }
17279 */
17280 data_selection_grouped: !1,
17281
17282 /**
17283 * Set a callback for each data point to determine if it's selectable or not.<br><br>
17284 * The callback will receive d as an argument and it has some parameters like id, value, index. This callback should return boolean.
17285 * @name data․selection․isselectable
17286 * @memberof Options
17287 * @type {Function}
17288 * @default function() { return true; }
17289 * @example
17290 * data: {
17291 * selection: {
17292 * isselectable: function(d) { ... }
17293 * }
17294 * }
17295 */
17296 data_selection_isselectable: function data_selection_isselectable() {
17297 return !0;
17298 },
17299
17300 /**
17301 * Set multiple data points selection enabled.<br><br>
17302 * 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.
17303 * @name data․selection․multiple
17304 * @memberof Options
17305 * @type {boolean}
17306 * @default true
17307 * @example
17308 * data: {
17309 * selection: {
17310 * multiple: false
17311 * }
17312 * }
17313 */
17314 data_selection_multiple: !0,
17315
17316 /**
17317 * Enable to select data points by dragging.
17318 * If this option set true, data points can be selected by dragging.
17319 * - **NOTE:** If this option set true, scrolling on the chart will be disabled because dragging event will handle the event.
17320 * @name data․selection․draggable
17321 * @memberof Options
17322 * @type {boolean}
17323 * @default false
17324 * @example
17325 * data: {
17326 * selection: {
17327 * draggable: true
17328 * }
17329 * }
17330 */
17331 data_selection_draggable: !1,
17332
17333 /**
17334 * Set a callback for on data selection.
17335 * @name data․onselected
17336 * @memberof Options
17337 * @type {Function}
17338 * @default function() {}
17339 * @example
17340 * data: {
17341 * onselected: function(d, element) {
17342 * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
17343 * // element - <circle>
17344 * ...
17345 * }
17346 * }
17347 */
17348 data_onselected: function data_onselected() {},
17349
17350 /**
17351 * Set a callback for on data un-selection.
17352 * @name data․onunselected
17353 * @memberof Options
17354 * @type {Function}
17355 * @default function() {}
17356 * @example
17357 * data: {
17358 * onunselected: function(d, element) {
17359 * // d - ex) {x: 4, value: 150, id: "data1", index: 4, name: "data1"}
17360 * // element - <circle>
17361 * ...
17362 * }
17363 * }
17364 */
17365 data_onunselected: function data_onunselected() {}
17366});
17367;// CONCATENATED MODULE: ./src/config/Options/interaction/subchart.ts
17368/**
17369 * Copyright (c) 2017 ~ present NAVER Corp.
17370 * billboard.js project is licensed under the MIT license
17371 */
17372
17373/**
17374 * x Axis config options
17375 */
17376/* harmony default export */ var interaction_subchart = ({
17377 /**
17378 * Set subchart options.
17379 * - **NOTE:** Not supported for `bubble`, `scatter` and non-Axis based(pie, donut, gauge, radar) types.
17380 * @name subchart
17381 * @memberof Options
17382 * @type {object}
17383 * @property {object} subchart Subchart object
17384 * @property {boolean} [subchart.show=false] Show sub chart on the bottom of the chart.
17385 * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
17386 * - `show: subchart()`
17387 * @property {boolean} [subchart.axis.x.show=true] Show or hide x axis.
17388 * @property {boolean} [subchart.axis.x.tick.show=true] Show or hide x axis tick line.
17389 * @property {boolean} [subchart.axis.x.tick.text.show=true] Show or hide x axis tick text.
17390 * @property {number} [subchart.size.height] Change the height of the subchart.
17391 * @property {Function} [subchart.onbrush] Set callback for brush event.<br>
17392 * Specified function receives the current zoomed x domain.
17393 * @see [Demo](https://naver.github.io/billboard.js/demo/#Interaction.SubChart)
17394 * @example
17395 * subchart: {
17396 * show: true,
17397 * size: {
17398 * height: 20
17399 * },
17400 * axis: {
17401 * x: {
17402 * show: true,
17403 * tick: {
17404 * show: true,
17405 * text: {
17406 * show: false
17407 * }
17408 * }
17409 * }
17410 * },
17411 * onbrush: function(domain) { ... }
17412 * }
17413 * @example
17414 * // importing ESM
17415 * import bb, {subchart} from "billboard.js";
17416 *
17417 * subchart: {
17418 * show: subchart(),
17419 * ...
17420 * }
17421 */
17422 subchart_show: !1,
17423 subchart_size_height: 60,
17424 subchart_axis_x_show: !0,
17425 subchart_axis_x_tick_show: !0,
17426 subchart_axis_x_tick_text_show: !0,
17427 subchart_onbrush: function subchart_onbrush() {}
17428});
17429;// CONCATENATED MODULE: ./src/config/Options/interaction/zoom.ts
17430/**
17431 * Copyright (c) 2017 ~ present NAVER Corp.
17432 * billboard.js project is licensed under the MIT license
17433 */
17434
17435/**
17436 * zoom config options
17437 */
17438/* harmony default export */ var interaction_zoom = ({
17439 /**
17440 * Set zoom options
17441 * @name zoom
17442 * @memberof Options
17443 * @type {object}
17444 * @property {object} zoom Zoom object
17445 * @property {boolean} [zoom.enabled=false] Enable zooming.
17446 * - **NOTE:** for ESM imports, needs to import 'zoom' exports and instantiate it by calling `zoom()`.
17447 * - `enabled: zoom()`
17448 * @property {string} [zoom.type='wheel'] Set zoom interaction type.
17449 * - **Available types:**
17450 * - wheel
17451 * - drag
17452 * @property {boolean} [zoom.rescale=false] Enable to rescale after zooming.<br>
17453 * If true set, y domain will be updated according to the zoomed region.
17454 * @property {Array} [zoom.extent=[1, 10]] Change zoom extent.
17455 * @property {number|Date} [zoom.x.min] Set x Axis minimum zoom range
17456 * @property {number|Date} [zoom.x.max] Set x Axis maximum zoom range
17457 * @property {Function} [zoom.onzoomstart=undefined] Set callback that is called when zooming starts.<br>
17458 * Specified function receives the zoom event.
17459 * @property {Function} [zoom.onzoom=undefined] Set callback that is called when the chart is zooming.<br>
17460 * Specified function receives the zoomed domain.
17461 * @property {Function} [zoom.onzoomend=undefined] Set callback that is called when zooming ends.<br>
17462 * Specified function receives the zoomed domain.
17463 * @property {boolean|object} [zoom.resetButton=true] Set to display zoom reset button for 'drag' type zoom
17464 * @property {Function} [zoom.resetButton.onclick] Set callback when clicks the reset button. The callback will receive reset button element reference as argument.
17465 * @property {string} [zoom.resetButton.text='Reset Zoom'] Text value for zoom reset button.
17466 * @see [Demo:zoom](https://naver.github.io/billboard.js/demo/#Interaction.Zoom)
17467 * @see [Demo:drag zoom](https://naver.github.io/billboard.js/demo/#Interaction.DragZoom)
17468 * @example
17469 * zoom: {
17470 * enabled: true,
17471 * type: "drag",
17472 * rescale: true,
17473 * extent: [1, 100] // enable more zooming
17474 * x: {
17475 * min: -1, // set min range
17476 * max: 10 // set max range
17477 * },
17478 * onzoomstart: function(event) { ... },
17479 * onzoom: function(domain) { ... },
17480 * onzoomend: function(domain) { ... },
17481 *
17482 * // show reset button when is zoomed-in
17483 * resetButton: true,
17484 *
17485 * resetButton: {
17486 * // onclick callback when reset button is clicked
17487 * onclick: function(button) {
17488 * button; // Reset button element reference
17489 * ...
17490 * },
17491 *
17492 * // customized text value for reset zoom button
17493 * text: "Unzoom"
17494 * }
17495 * }
17496 * @example
17497 * // importing ESM
17498 * import bb, {zoom} from "billboard.js";
17499 *
17500 * zoom: {
17501 * enabled: zoom(),
17502 * ...
17503 * }
17504 */
17505 zoom_enabled: !1,
17506 zoom_type: "wheel",
17507 zoom_extent: undefined,
17508 zoom_privileged: !1,
17509 zoom_rescale: !1,
17510 zoom_onzoom: undefined,
17511 zoom_onzoomstart: undefined,
17512 zoom_onzoomend: undefined,
17513 zoom_resetButton: !0,
17514 zoom_x_min: undefined,
17515 zoom_x_max: undefined
17516});
17517;// CONCATENATED MODULE: ./src/config/resolver/interaction.ts
17518/**
17519 * Copyright (c) 2017 ~ present NAVER Corp.
17520 * billboard.js project is licensed under the MIT license
17521 */
17522
17523
17524
17525 // Chart
17526
17527
17528
17529 // ChartInternal
17530
17531
17532
17533 // Axis based options
17534
17535
17536
17537
17538
17539
17540var _selectionModule = function selectionModule() {
17541 return extend(ChartInternal.prototype, internals_selection), extend(Chart.prototype, selection), Options.setOptions([data_selection]), (_selectionModule = function selectionModule() {
17542 return !0;
17543 })();
17544},
17545 subchartModule = function () {
17546 return extend(ChartInternal.prototype, interactions_subchart), extend(Chart.prototype, subchart), Options.setOptions([interaction_subchart]), (subchartModule = function () {
17547 return !0;
17548 })();
17549},
17550 zoomModule = function () {
17551 return extend(ChartInternal.prototype, interactions_zoom), extend(Chart.prototype, api_zoom), Options.setOptions([interaction_zoom]), (zoomModule = function () {
17552 return !0;
17553 })();
17554};
17555;// CONCATENATED MODULE: ./src/core.ts
17556/**
17557 * Copyright (c) 2017 ~ present NAVER Corp.
17558 * billboard project is licensed under the MIT license
17559 */
17560
17561 // eslint-disable-next-line no-use-before-define
17562
17563
17564var _defaults = {},
17565 bb = {
17566 /**
17567 * Version information
17568 * @property {string} version version
17569 * @example
17570 * bb.version; // "1.0.0"
17571 * @memberof bb
17572 */
17573 version: "3.0.1",
17574
17575 /**
17576 * Generate chart
17577 * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
17578 * - Unused option value is given.
17579 * - ex) For `data.type="pie"` option, setting 'axis' option can cause unexpected generation error.
17580 * - Insufficient value is given for certain option used.
17581 * - ex) `data: { x: "x", columns: [["x"], ["data1", 30, 200, 100]] }`
17582 * @param {Options} config chart options
17583 * @memberof bb
17584 * @returns {Chart}
17585 * @see {@link Options} for different generation options
17586 * @see {@link Chart} for different methods API
17587 * @example
17588 * <!-- chart holder -->
17589 * <div id="LineChart"></div>
17590 * @example
17591 * // Generate chart with options
17592 * var chart = bb.generate({
17593 * "bindto": "#LineChart"
17594 * "data": {
17595 * "columns": [
17596 * ["data1", 30, 200, 100, 400, 150, 250],
17597 * ["data2", 50, 20, 10, 40, 15, 25]
17598 * ],
17599 * "type": "line"
17600 * }
17601 * });
17602 *
17603 * // call some API
17604 * // ex) get the data of 'data1'
17605 * chart.data("data1");
17606 * @example
17607 * // Generate chart by importing ESM
17608 * // Import types to be used only, where this will make smaller bundle size.
17609 * import bb, {
17610 * area,
17611 * areaLineRange,
17612 * areaSpline,
17613 * areaSplineRange,
17614 * areaStep,
17615 * bar,
17616 * bubble,
17617 * donut,
17618 * gauge,
17619 * line,
17620 * pie,
17621 * radar,
17622 * scatter,
17623 * spline,
17624 * step
17625 * }
17626 *
17627 * bb.generate({
17628 * "bindto": "#LineChart"
17629 * "data": {
17630 * "columns": [
17631 * ["data1", 30, 200, 100, 400, 150, 250],
17632 * ["data2", 50, 20, 10, 40, 15, 25]
17633 * ]
17634 * },
17635 * type: line(),
17636 *
17637 * // or
17638 * types: {
17639 * data1: bar(),
17640 * data2: step()
17641 * }
17642 * });
17643 */
17644 generate: function generate(config) {
17645 var options = mergeObj({}, _defaults, config),
17646 inst = new Chart(options);
17647 return inst.internal.charts = this.instance, this.instance.push(inst), inst;
17648 },
17649
17650 /**
17651 * Set or get global default options.
17652 * - **NOTE:**
17653 * - The options values settings are valid within page context only.
17654 * - If is called multiple times, will override the last value.
17655 * @param {Options} options chart options
17656 * @memberof bb
17657 * @returns {Options}
17658 * @see {@link Options}
17659 * @example
17660 * // Set same option value as for `.generate()`
17661 * bb.defaults({
17662 * data: {
17663 * type: "bar"
17664 * }
17665 * });
17666 *
17667 * bb.defaults(); // {data:{type: "bar"}}
17668 *
17669 * // data.type defaults to 'bar'
17670 * var chart = bb.generate({ ... });
17671 */
17672 defaults: function defaults(options) {
17673 return isObject(options) && (_defaults = options), _defaults;
17674 },
17675
17676 /**
17677 * An array containing instance created
17678 * @property {Array} instance instance array
17679 * @example
17680 * // generate charts
17681 * var chart1 = bb.generate(...);
17682 * var chart2 = bb.generate(...);
17683 *
17684 * bb.instance; // [ chart1, chart2, ... ]
17685 * @memberof bb
17686 */
17687 instance: [],
17688
17689 /**
17690 * Namespace for plugins
17691 * @property {object} plugin plugin namespace
17692 * @example
17693 * // Stanford diagram plugin
17694 * bb.plugin.stanford;
17695 * @memberof bb
17696 */
17697 plugin: {}
17698};
17699/**
17700 * @namespace bb
17701 * @version 3.0.1
17702 */
17703;// CONCATENATED MODULE: ./src/index.ts
17704/**
17705 * Copyright (c) 2017 ~ present NAVER Corp.
17706 * billboard project is licensed under the MIT license
17707 */
17708
17709 // extends shape modules
17710
17711Object.keys(resolver_shape_namespaceObject).forEach(function (v) {
17712 return resolver_shape_namespaceObject[v]();
17713}), Object.keys(resolver_interaction_namespaceObject).forEach(function (v) {
17714 return resolver_interaction_namespaceObject[v]();
17715});
17716
17717}();
17718/******/ return __webpack_exports__;
17719/******/ })()
17720;
17721});
\No newline at end of file