UNPKG

67.2 kBJavaScriptView Raw
1/*!
2 * Copyright (c) 2017 ~ present NAVER Corp.
3 * billboard.js project is licensed under the MIT license
4 *
5 * billboard.js, JavaScript chart library
6 * https://naver.github.io/billboard.js/
7 *
8 * @version 3.6.3
9 * @requires billboard.js
10 * @summary billboard.js plugin
11 */
12(function webpackUniversalModuleDefinition(root, factory) {
13 if(typeof exports === 'object' && typeof module === 'object')
14 module.exports = factory(require("d3-interpolate"), require("d3-color"), require("d3-scale"), require("d3-selection"), require("d3-brush"), require("d3-axis"), require("d3-format"));
15 else if(typeof define === 'function' && define.amd)
16 define("bb", ["d3-interpolate", "d3-color", "d3-scale", "d3-selection", "d3-brush", "d3-axis", "d3-format"], factory);
17 else if(typeof exports === 'object')
18 exports["bb"] = factory(require("d3-interpolate"), require("d3-color"), require("d3-scale"), require("d3-selection"), require("d3-brush"), require("d3-axis"), require("d3-format"));
19 else
20 root["bb"] = root["bb"] || {}, root["bb"]["plugin"] = root["bb"]["plugin"] || {}, root["bb"]["plugin"]["stanford"] = factory(root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"]);
21})(this, function(__WEBPACK_EXTERNAL_MODULE__5__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__8__, __WEBPACK_EXTERNAL_MODULE__9__) {
22return /******/ (function() { // webpackBootstrap
23/******/ "use strict";
24/******/ var __webpack_modules__ = ([
25/* 0 */,
26/* 1 */
27/***/ (function(module) {
28
29module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
30
31/***/ }),
32/* 2 */,
33/* 3 */
34/***/ (function(module) {
35
36module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
37
38/***/ }),
39/* 4 */,
40/* 5 */
41/***/ (function(module) {
42
43module.exports = __WEBPACK_EXTERNAL_MODULE__5__;
44
45/***/ }),
46/* 6 */
47/***/ (function(module) {
48
49module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
50
51/***/ }),
52/* 7 */
53/***/ (function(module) {
54
55module.exports = __WEBPACK_EXTERNAL_MODULE__7__;
56
57/***/ }),
58/* 8 */
59/***/ (function(module) {
60
61module.exports = __WEBPACK_EXTERNAL_MODULE__8__;
62
63/***/ }),
64/* 9 */
65/***/ (function(module) {
66
67module.exports = __WEBPACK_EXTERNAL_MODULE__9__;
68
69/***/ })
70/******/ ]);
71/************************************************************************/
72/******/ // The module cache
73/******/ var __webpack_module_cache__ = {};
74/******/
75/******/ // The require function
76/******/ function __webpack_require__(moduleId) {
77/******/ // Check if module is in cache
78/******/ var cachedModule = __webpack_module_cache__[moduleId];
79/******/ if (cachedModule !== undefined) {
80/******/ return cachedModule.exports;
81/******/ }
82/******/ // Create a new module (and put it into the cache)
83/******/ var module = __webpack_module_cache__[moduleId] = {
84/******/ // no module.id needed
85/******/ // no module.loaded needed
86/******/ exports: {}
87/******/ };
88/******/
89/******/ // Execute the module function
90/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
91/******/
92/******/ // Return the exports of the module
93/******/ return module.exports;
94/******/ }
95/******/
96/************************************************************************/
97/******/ /* webpack/runtime/define property getters */
98/******/ !function() {
99/******/ // define getter functions for harmony exports
100/******/ __webpack_require__.d = function(exports, definition) {
101/******/ for(var key in definition) {
102/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
103/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
104/******/ }
105/******/ }
106/******/ };
107/******/ }();
108/******/
109/******/ /* webpack/runtime/hasOwnProperty shorthand */
110/******/ !function() {
111/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
112/******/ }();
113/******/
114/************************************************************************/
115var __webpack_exports__ = {};
116// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
117!function() {
118
119// EXPORTS
120__webpack_require__.d(__webpack_exports__, {
121 "default": function() { return /* binding */ Stanford; }
122});
123
124;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/newArrowCheck.js
125function _newArrowCheck(innerThis, boundThis) {
126 if (innerThis !== boundThis) {
127 throw new TypeError("Cannot instantiate an arrow function");
128 }
129}
130;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
131function _assertThisInitialized(self) {
132 if (self === void 0) {
133 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
134 }
135 return self;
136}
137;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
138function _setPrototypeOf(o, p) {
139 _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
140 o.__proto__ = p;
141 return o;
142 };
143 return _setPrototypeOf(o, p);
144}
145;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js
146
147function _inheritsLoose(subClass, superClass) {
148 subClass.prototype = Object.create(superClass.prototype);
149 subClass.prototype.constructor = subClass;
150 _setPrototypeOf(subClass, superClass);
151}
152// EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
153var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(5);
154// EXTERNAL MODULE: external {"commonjs":"d3-color","commonjs2":"d3-color","amd":"d3-color","root":"d3"}
155var external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_ = __webpack_require__(6);
156// EXTERNAL MODULE: external {"commonjs":"d3-scale","commonjs2":"d3-scale","amd":"d3-scale","root":"d3"}
157var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webpack_require__(7);
158;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
159function _defineProperty(obj, key, value) {
160 if (key in obj) {
161 Object.defineProperty(obj, key, {
162 value: value,
163 enumerable: true,
164 configurable: true,
165 writable: true
166 });
167 } else {
168 obj[key] = value;
169 }
170 return obj;
171}
172;// CONCATENATED MODULE: ./src/config/classes.ts
173
174function 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; }
175function _objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
176/**
177 * Copyright (c) 2017 ~ present NAVER Corp.
178 * billboard.js project is licensed under the MIT license
179 */
180/**
181 * CSS class names definition
182 * @private
183 */
184var $COMMON = {
185 button: "bb-button",
186 chart: "bb-chart",
187 empty: "bb-empty",
188 main: "bb-main",
189 target: "bb-target",
190 EXPANDED: "_expanded_"
191};
192var $ARC = {
193 arc: "bb-arc",
194 arcLabelLine: "bb-arc-label-line",
195 arcs: "bb-arcs",
196 chartArc: "bb-chart-arc",
197 chartArcs: "bb-chart-arcs",
198 chartArcsBackground: "bb-chart-arcs-background",
199 chartArcsTitle: "bb-chart-arcs-title"
200};
201var $AREA = {
202 area: "bb-area",
203 areas: "bb-areas"
204};
205var $AXIS = {
206 axis: "bb-axis",
207 axisX: "bb-axis-x",
208 axisXLabel: "bb-axis-x-label",
209 axisY: "bb-axis-y",
210 axisY2: "bb-axis-y2",
211 axisY2Label: "bb-axis-y2-label",
212 axisYLabel: "bb-axis-y-label"
213};
214var $BAR = {
215 bar: "bb-bar",
216 bars: "bb-bars",
217 chartBar: "bb-chart-bar",
218 chartBars: "bb-chart-bars"
219};
220var $CANDLESTICK = {
221 candlestick: "bb-candlestick",
222 candlesticks: "bb-candlesticks",
223 chartCandlestick: "bb-chart-candlestick",
224 chartCandlesticks: "bb-chart-candlesticks",
225 valueDown: "bb-value-down",
226 valueUp: "bb-value-up"
227};
228var $CIRCLE = {
229 chartCircles: "bb-chart-circles",
230 circle: "bb-circle",
231 circles: "bb-circles"
232};
233var $COLOR = {
234 colorPattern: "bb-color-pattern",
235 colorScale: "bb-colorscale"
236};
237var $DRAG = {
238 dragarea: "bb-dragarea",
239 INCLUDED: "_included_"
240};
241var $GAUGE = {
242 chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
243 chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
244 chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
245 chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
246 gaugeValue: "bb-gauge-value"
247};
248var $LEGEND = {
249 legend: "bb-legend",
250 legendBackground: "bb-legend-background",
251 legendItem: "bb-legend-item",
252 legendItemEvent: "bb-legend-item-event",
253 legendItemHidden: "bb-legend-item-hidden",
254 legendItemPoint: "bb-legend-item-point",
255 legendItemTile: "bb-legend-item-tile"
256};
257var $LINE = {
258 chartLine: "bb-chart-line",
259 chartLines: "bb-chart-lines",
260 line: "bb-line",
261 lines: "bb-lines"
262};
263var $EVENT = {
264 eventRect: "bb-event-rect",
265 eventRects: "bb-event-rects",
266 eventRectsMultiple: "bb-event-rects-multiple",
267 eventRectsSingle: "bb-event-rects-single"
268};
269var $FOCUS = {
270 focused: "bb-focused",
271 defocused: "bb-defocused",
272 legendItemFocused: "bb-legend-item-focused",
273 xgridFocus: "bb-xgrid-focus",
274 ygridFocus: "bb-ygrid-focus"
275};
276var $GRID = {
277 grid: "bb-grid",
278 gridLines: "bb-grid-lines",
279 xgrid: "bb-xgrid",
280 xgridLine: "bb-xgrid-line",
281 xgridLines: "bb-xgrid-lines",
282 xgrids: "bb-xgrids",
283 ygrid: "bb-ygrid",
284 ygridLine: "bb-ygrid-line",
285 ygridLines: "bb-ygrid-lines",
286 ygrids: "bb-ygrids"
287};
288var $LEVEL = {
289 level: "bb-level",
290 levels: "bb-levels"
291};
292var $RADAR = {
293 chartRadar: "bb-chart-radar",
294 chartRadars: "bb-chart-radars"
295};
296var $REGION = {
297 region: "bb-region",
298 regions: "bb-regions"
299};
300var $SELECT = {
301 selectedCircle: "bb-selected-circle",
302 selectedCircles: "bb-selected-circles",
303 SELECTED: "_selected_"
304};
305var $SHAPE = {
306 shape: "bb-shape",
307 shapes: "bb-shapes"
308};
309var $SUBCHART = {
310 brush: "bb-brush",
311 subchart: "bb-subchart"
312};
313var $TEXT = {
314 chartText: "bb-chart-text",
315 chartTexts: "bb-chart-texts",
316 text: "bb-text",
317 texts: "bb-texts",
318 title: "bb-title",
319 TextOverlapping: "text-overlapping"
320};
321var $TOOLTIP = {
322 tooltip: "bb-tooltip",
323 tooltipContainer: "bb-tooltip-container",
324 tooltipName: "bb-tooltip-name"
325};
326var $ZOOM = {
327 buttonZoomReset: "bb-zoom-reset",
328 zoomBrush: "bb-zoom-brush"
329};
330/* harmony default export */ var classes = (_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, $COMMON), $ARC), $AREA), $AXIS), $BAR), $CANDLESTICK), $CIRCLE), $COLOR), $DRAG), $GAUGE), $LEGEND), $LINE), $EVENT), $FOCUS), $GRID), $RADAR), $REGION), $SELECT), $SHAPE), $SUBCHART), $TEXT), $TOOLTIP), $ZOOM));
331// EXTERNAL MODULE: external {"commonjs":"d3-selection","commonjs2":"d3-selection","amd":"d3-selection","root":"d3"}
332var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(1);
333// EXTERNAL MODULE: external {"commonjs":"d3-brush","commonjs2":"d3-brush","amd":"d3-brush","root":"d3"}
334var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(3);
335;// CONCATENATED MODULE: ./src/module/browser.ts
336
337var _this = undefined;
338/**
339 * Copyright (c) 2017 ~ present NAVER Corp.
340 * billboard.js project is licensed under the MIT license
341 */
342/**
343 * Window object
344 * @private
345 */
346/* eslint-disable no-new-func, no-undef */
347
348var win = function () {
349 _newArrowCheck(this, _this);
350 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;
351 return root || Function("return this")();
352}.bind(undefined)();
353/* eslint-enable no-new-func, no-undef */
354
355// fallback for non-supported environments
356win.requestIdleCallback = win.requestIdleCallback || function (cb) {
357 _newArrowCheck(this, _this);
358 return setTimeout(cb, 1);
359}.bind(undefined);
360// win.cancelIdleCallback = win.cancelIdleCallback || (id => clearTimeout(id));
361win.requestAnimationFrame = win.requestAnimationFrame || function (cb) {
362 _newArrowCheck(this, _this);
363 return setTimeout(cb, 1);
364}.bind(undefined);
365var doc = win == null ? void 0 : win.document;
366;// CONCATENATED MODULE: ./src/module/util.ts
367
368
369var util_this = undefined;
370function util_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; }
371function util_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? util_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : util_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
372/**
373 * Copyright (c) 2017 ~ present NAVER Corp.
374 * billboard.js project is licensed under the MIT license
375 * @ignore
376 */
377
378
379
380
381var isValue = function (v) {
382 _newArrowCheck(this, util_this);
383 return v || v === 0;
384 }.bind(undefined),
385 isFunction = function (v) {
386 _newArrowCheck(this, util_this);
387 return typeof v === "function";
388 }.bind(undefined),
389 isString = function (v) {
390 _newArrowCheck(this, util_this);
391 return typeof v === "string";
392 }.bind(undefined),
393 isNumber = function (v) {
394 _newArrowCheck(this, util_this);
395 return typeof v === "number";
396 }.bind(undefined),
397 isUndefined = function (v) {
398 _newArrowCheck(this, util_this);
399 return typeof v === "undefined";
400 }.bind(undefined),
401 isDefined = function (v) {
402 _newArrowCheck(this, util_this);
403 return typeof v !== "undefined";
404 }.bind(undefined),
405 isboolean = function (v) {
406 _newArrowCheck(this, util_this);
407 return typeof v === "boolean";
408 }.bind(undefined),
409 ceil10 = function (v) {
410 _newArrowCheck(this, util_this);
411 return Math.ceil(v / 10) * 10;
412 }.bind(undefined),
413 asHalfPixel = function (n) {
414 _newArrowCheck(this, util_this);
415 return Math.ceil(n) + .5;
416 }.bind(undefined),
417 diffDomain = function (d) {
418 _newArrowCheck(this, util_this);
419 return d[1] - d[0];
420 }.bind(undefined),
421 isObjectType = function (v) {
422 _newArrowCheck(this, util_this);
423 return typeof v === "object";
424 }.bind(undefined),
425 isEmpty = function (o) {
426 _newArrowCheck(this, util_this);
427 return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
428 }.bind(undefined),
429 notEmpty = function (o) {
430 _newArrowCheck(this, util_this);
431 return !isEmpty(o);
432 }.bind(undefined),
433 isArray = function (arr) {
434 _newArrowCheck(this, util_this);
435 return Array.isArray(arr);
436 }.bind(undefined),
437 isObject = function (obj) {
438 _newArrowCheck(this, util_this);
439 return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
440 }.bind(undefined);
441/**
442 * Get specified key value from object
443 * If default value is given, will return if given key value not found
444 * @param {object} options Source object
445 * @param {string} key Key value
446 * @param {*} defaultValue Default value
447 * @returns {*}
448 * @private
449 */
450function getOption(options, key, defaultValue) {
451 return isDefined(options[key]) ? options[key] : defaultValue;
452}
453
454/**
455 * Check if value exist in the given object
456 * @param {object} dict Target object to be checked
457 * @param {*} value Value to be checked
458 * @returns {boolean}
459 * @private
460 */
461function hasValue(dict, value) {
462 var _this2 = this,
463 found = !1;
464 Object.keys(dict).forEach(function (key) {
465 _newArrowCheck(this, _this2);
466 return dict[key] === value && (found = !0);
467 }.bind(this));
468 return found;
469}
470
471/**
472 * Call function with arguments
473 * @param {Function} fn Function to be called
474 * @param {*} thisArg "this" value for fn
475 * @param {*} args Arguments for fn
476 * @returns {boolean} true: fn is function, false: fn is not function
477 * @private
478 */
479function callFn(fn, thisArg) {
480 for (var isFn = isFunction(fn), _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
481 args[_key - 2] = arguments[_key];
482 }
483 isFn && fn.call.apply(fn, [thisArg].concat(args));
484 return isFn;
485}
486
487/**
488 * Call function after all transitions ends
489 * @param {d3.transition} transition Transition
490 * @param {Fucntion} cb Callback function
491 * @private
492 */
493function endall(transition, cb) {
494 var _this3 = this,
495 n = 0,
496 end = function () {
497 for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
498 args[_key2] = arguments[_key2];
499 }
500 --n || cb.apply.apply(cb, [this].concat(args));
501 };
502 // if is transition selection
503 if ("duration" in transition) {
504 transition.each(function () {
505 _newArrowCheck(this, _this3);
506 return ++n;
507 }.bind(this)).on("end", end);
508 } else {
509 ++n;
510 transition.call(end);
511 }
512}
513
514/**
515 * Replace tag sign to html entity
516 * @param {string} str Target string value
517 * @returns {string}
518 * @private
519 */
520function sanitise(str) {
521 return isString(str) ? str.replace(/</g, "&lt;").replace(/>/g, "&gt;") : str;
522}
523
524/**
525 * Set text value. If there's multiline add nodes.
526 * @param {d3Selection} node Text node
527 * @param {string} text Text value string
528 * @param {Array} dy dy value for multilined text
529 * @param {boolean} toMiddle To be alingned vertically middle
530 * @private
531 */
532function setTextValue(node, text, dy, toMiddle) {
533 var _this4 = this;
534 if (dy === void 0) {
535 dy = [-1, 1];
536 }
537 if (toMiddle === void 0) {
538 toMiddle = !1;
539 }
540 if (!node || !isString(text)) {
541 return;
542 }
543 if (text.indexOf("\n") === -1) {
544 node.text(text);
545 } else {
546 var diff = [node.text(), text].map(function (v) {
547 _newArrowCheck(this, _this4);
548 return v.replace(/[\s\n]/g, "");
549 }.bind(this));
550 if (diff[0] !== diff[1]) {
551 var multiline = text.split("\n"),
552 len = toMiddle ? multiline.length - 1 : 1;
553 // reset possible text
554 node.html("");
555 multiline.forEach(function (v, i) {
556 _newArrowCheck(this, _this4);
557 node.append("tspan").attr("x", 0).attr("dy", (i === 0 ? dy[0] * len : dy[1]) + "em").text(v);
558 }.bind(this));
559 }
560 }
561}
562
563/**
564 * Substitution of SVGPathSeg API polyfill
565 * @param {SVGGraphicsElement} path Target svg element
566 * @returns {Array}
567 * @private
568 */
569function getRectSegList(path) {
570 /*
571 * seg1 ---------- seg2
572 * | |
573 * | |
574 * | |
575 * seg0 ---------- seg3
576 * */
577 var _path$getBBox = path.getBBox(),
578 x = _path$getBBox.x,
579 y = _path$getBBox.y,
580 width = _path$getBBox.width,
581 height = _path$getBBox.height;
582 return [{
583 x: x,
584 y: y + height
585 },
586 // seg0
587 {
588 x: x,
589 y: y
590 },
591 // seg1
592 {
593 x: x + width,
594 y: y
595 },
596 // seg2
597 {
598 x: x + width,
599 y: y + height
600 } // seg3
601 ];
602}
603
604/**
605 * Get svg bounding path box dimension
606 * @param {SVGGraphicsElement} path Target svg element
607 * @returns {object}
608 * @private
609 */
610function getPathBox(path) {
611 var _path$getBoundingClie = path.getBoundingClientRect(),
612 width = _path$getBoundingClie.width,
613 height = _path$getBoundingClie.height,
614 items = getRectSegList(path),
615 x = items[0].x,
616 y = Math.min(items[0].y, items[1].y);
617 return {
618 x: x,
619 y: y,
620 width: width,
621 height: height
622 };
623}
624
625/**
626 * Get event's current position coordinates
627 * @param {object} event Event object
628 * @param {SVGElement|HTMLElement} element Target element
629 * @returns {Array} [x, y] Coordinates x, y array
630 * @private
631 */
632function getPointer(event, element) {
633 var _ref,
634 touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]),
635 pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element),
636 _this5 = this;
637 return pointer.map(function (v) {
638 _newArrowCheck(this, _this5);
639 return isNaN(v) ? 0 : v;
640 }.bind(this));
641}
642
643/**
644 * Return brush selection array
645 * @param {object} ctx Current instance
646 * @returns {d3.brushSelection}
647 * @private
648 */
649function getBrushSelection(ctx) {
650 var event = ctx.event,
651 $el = ctx.$el,
652 main = $el.subchart.main || $el.main,
653 selection;
654 // check from event
655 if (event && event.type === "brush") {
656 selection = event.selection;
657 // check from brush area selection
658 } else if (main && (selection = main.select(".bb-brush").node())) {
659 selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection);
660 }
661 return selection;
662}
663
664/**
665 * Get boundingClientRect.
666 * Cache the evaluated value once it was called.
667 * @param {HTMLElement} node Target element
668 * @returns {object}
669 * @private
670 */
671function getBoundingRect(node) {
672 var needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
673 return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
674}
675
676/**
677 * Retrun random number
678 * @param {boolean} asStr Convert returned value as string
679 * @param {number} min Minimum value
680 * @param {number} max Maximum value
681 * @returns {number|string}
682 * @private
683 */
684function getRandom(asStr, min, max) {
685 if (asStr === void 0) {
686 asStr = !0;
687 }
688 if (min === void 0) {
689 min = 0;
690 }
691 if (max === void 0) {
692 max = 1e4;
693 }
694 var rand = Math.floor(Math.random() * (max - min) + min);
695 return asStr ? rand + "" : rand;
696}
697
698/**
699 * Find index based on binary search
700 * @param {Array} arr Data array
701 * @param {number} v Target number to find
702 * @param {number} start Start index of data array
703 * @param {number} end End index of data arr
704 * @param {boolean} isRotated Weather is roted axis
705 * @returns {number} Index number
706 * @private
707 */
708function findIndex(arr, v, start, end, isRotated) {
709 if (start > end) {
710 return -1;
711 }
712 var mid = Math.floor((start + end) / 2),
713 _arr$mid = arr[mid],
714 x = _arr$mid.x,
715 _arr$mid$w = _arr$mid.w,
716 w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
717 if (isRotated) {
718 x = arr[mid].y;
719 w = arr[mid].h;
720 }
721 if (v >= x && v <= x + w) {
722 return mid;
723 }
724 return v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
725}
726
727/**
728 * Check if brush is empty
729 * @param {object} ctx Bursh context
730 * @returns {boolean}
731 * @private
732 */
733function brushEmpty(ctx) {
734 var selection = getBrushSelection(ctx);
735 if (selection) {
736 // brush selected area
737 // two-dimensional: [[x0, y0], [x1, y1]]
738 // one-dimensional: [x0, x1] or [y0, y1]
739 return selection[0] === selection[1];
740 }
741 return !0;
742}
743
744/**
745 * Deep copy object
746 * @param {object} objectN Source object
747 * @returns {object} Cloned object
748 * @private
749 */
750function deepClone() {
751 for (var _this6 = this, clone = function (v) {
752 _newArrowCheck(this, _this6);
753 if (isObject(v) && v.constructor) {
754 var r = new v.constructor();
755 for (var k in v) {
756 r[k] = clone(v[k]);
757 }
758 return r;
759 }
760 return v;
761 }.bind(this), _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
762 objectN[_key3] = arguments[_key3];
763 }
764 return objectN.map(function (v) {
765 _newArrowCheck(this, _this6);
766 return clone(v);
767 }.bind(this)).reduce(function (a, c) {
768 _newArrowCheck(this, _this6);
769 return util_objectSpread(util_objectSpread({}, a), c);
770 }.bind(this));
771}
772
773/**
774 * Extend target from source object
775 * @param {object} target Target object
776 * @param {object|Array} source Source object
777 * @returns {object}
778 * @private
779 */
780function extend(target, source) {
781 var _this7 = this;
782 if (target === void 0) {
783 target = {};
784 }
785 if (isArray(source)) {
786 source.forEach(function (v) {
787 _newArrowCheck(this, _this7);
788 return extend(target, v);
789 }.bind(this));
790 }
791
792 // exclude name with only numbers
793 for (var p in source) {
794 if (/^\d+$/.test(p) || p in target) {
795 continue;
796 }
797 target[p] = source[p];
798 }
799 return target;
800}
801
802/**
803 * Return first letter capitalized
804 * @param {string} str Target string
805 * @returns {string} capitalized string
806 * @private
807 */
808var capitalize = function (str) {
809 _newArrowCheck(this, util_this);
810 return str.charAt(0).toUpperCase() + str.slice(1);
811}.bind(undefined);
812
813/**
814 * Camelize from kebob style string
815 * @param {string} str Target string
816 * @param {string} separator Separator string
817 * @returns {string} camelized string
818 * @private
819 */
820function camelize(str, separator) {
821 var _this8 = this;
822 if (separator === void 0) {
823 separator = "-";
824 }
825 return str.split(separator).map(function (v, i) {
826 _newArrowCheck(this, _this8);
827 return i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase();
828 }.bind(this)).join("");
829}
830
831/**
832 * Convert to array
833 * @param {object} v Target to be converted
834 * @returns {Array}
835 * @private
836 */
837var toArray = function (v) {
838 _newArrowCheck(this, util_this);
839 return [].slice.call(v);
840}.bind(undefined);
841
842/**
843 * Add CSS rules
844 * @param {object} style Style object
845 * @param {string} selector Selector string
846 * @param {Array} prop Prps arrary
847 * @returns {number} Newely added rule index
848 * @private
849 */
850function addCssRules(style, selector, prop) {
851 var _this9 = this,
852 rootSelctor = style.rootSelctor,
853 sheet = style.sheet,
854 getSelector = function (s) {
855 _newArrowCheck(this, _this9);
856 return s.replace(/\s?(bb-)/g, ".$1").replace(/\.+/g, ".");
857 }.bind(this),
858 rule = rootSelctor + " " + getSelector(selector) + " {" + prop.join(";") + "}";
859 return sheet[sheet.insertRule ? "insertRule" : "addRule"](rule, sheet.cssRules.length);
860}
861
862/**
863 * Get css rules for specified stylesheets
864 * @param {Array} styleSheets The stylesheets to get the rules from
865 * @returns {Array}
866 * @private
867 */
868function getCssRules(styleSheets) {
869 var _this10 = this,
870 rules = [];
871 styleSheets.forEach(function (sheet) {
872 _newArrowCheck(this, _this10);
873 try {
874 if (sheet.cssRules && sheet.cssRules.length) {
875 rules = rules.concat(toArray(sheet.cssRules));
876 }
877 } catch (e) {
878 console.error("Error while reading rules from " + sheet.href + ": " + e.toString());
879 }
880 }.bind(this));
881 return rules;
882}
883
884/**
885 * Gets the SVGMatrix of an SVGGElement
886 * @param {SVGElement} node Node element
887 * @returns {SVGMatrix} matrix
888 * @private
889 */
890function getTranslation(node) {
891 var transform = node ? node.transform : null,
892 baseVal = transform && transform.baseVal;
893 return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
894 a: 0,
895 b: 0,
896 c: 0,
897 d: 0,
898 e: 0,
899 f: 0
900 };
901}
902
903/**
904 * Get unique value from array
905 * @param {Array} data Source data
906 * @returns {Array} Unique array value
907 * @private
908 */
909function getUnique(data) {
910 var _this11 = this,
911 isDate = data[0] instanceof Date,
912 d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
913 _newArrowCheck(this, _this11);
914 return self.indexOf(v) === i;
915 }.bind(this));
916 return isDate ? d.map(function (v) {
917 _newArrowCheck(this, _this11);
918 return new Date(v);
919 }.bind(this)) : d;
920}
921
922/**
923 * Merge array
924 * @param {Array} arr Source array
925 * @returns {Array}
926 * @private
927 */
928function mergeArray(arr) {
929 var _this12 = this;
930 return arr && arr.length ? arr.reduce(function (p, c) {
931 _newArrowCheck(this, _this12);
932 return p.concat(c);
933 }.bind(this)) : [];
934}
935
936/**
937 * Merge object returning new object
938 * @param {object} target Target object
939 * @param {object} objectN Source object
940 * @returns {object} merged target object
941 * @private
942 */
943function mergeObj(target) {
944 for (var _this13 = this, _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
945 objectN[_key4 - 1] = arguments[_key4];
946 }
947 if (!objectN.length || objectN.length === 1 && !objectN[0]) {
948 return target;
949 }
950 var source = objectN.shift();
951 if (isObject(target) && isObject(source)) {
952 Object.keys(source).forEach(function (key) {
953 _newArrowCheck(this, _this13);
954 var value = source[key];
955 if (isObject(value)) {
956 target[key] || (target[key] = {});
957 target[key] = mergeObj(target[key], value);
958 } else {
959 target[key] = isArray(value) ? value.concat() : value;
960 }
961 }.bind(this));
962 }
963 return mergeObj.apply(void 0, [target].concat(objectN));
964}
965
966/**
967 * Sort value
968 * @param {Array} data value to be sorted
969 * @param {boolean} isAsc true: asc, false: desc
970 * @returns {number|string|Date} sorted date
971 * @private
972 */
973function sortValue(data, isAsc) {
974 var _this14 = this;
975 if (isAsc === void 0) {
976 isAsc = !0;
977 }
978 var fn;
979 if (data[0] instanceof Date) {
980 fn = isAsc ? function (a, b) {
981 _newArrowCheck(this, _this14);
982 return a - b;
983 }.bind(this) : function (a, b) {
984 _newArrowCheck(this, _this14);
985 return b - a;
986 }.bind(this);
987 } else {
988 if (isAsc && !data.every(isNaN)) {
989 fn = function (a, b) {
990 _newArrowCheck(this, _this14);
991 return a - b;
992 }.bind(this);
993 } else if (!isAsc) {
994 fn = function (a, b) {
995 _newArrowCheck(this, _this14);
996 return a > b && -1 || a < b && 1 || a === b && 0;
997 }.bind(this);
998 }
999 }
1000 return data.concat().sort(fn);
1001}
1002
1003/**
1004 * Get min/max value
1005 * @param {string} type 'min' or 'max'
1006 * @param {Array} data Array data value
1007 * @returns {number|Date|undefined}
1008 * @private
1009 */
1010function getMinMax(type, data) {
1011 var _this15 = this,
1012 res = data.filter(function (v) {
1013 _newArrowCheck(this, _this15);
1014 return notEmpty(v);
1015 }.bind(this));
1016 if (res.length) {
1017 if (isNumber(res[0])) {
1018 res = Math[type].apply(Math, res);
1019 } else if (res[0] instanceof Date) {
1020 res = sortValue(res, type === "min")[0];
1021 }
1022 } else {
1023 res = undefined;
1024 }
1025 return res;
1026}
1027
1028/**
1029 * Get range
1030 * @param {number} start Start number
1031 * @param {number} end End number
1032 * @param {number} step Step number
1033 * @returns {Array}
1034 * @private
1035 */
1036var getRange = function (start, end, step) {
1037 if (step === void 0) {
1038 step = 1;
1039 }
1040 _newArrowCheck(this, util_this);
1041 var res = [],
1042 n = Math.max(0, Math.ceil((end - start) / step)) | 0;
1043 for (var i = start; i < n; i++) {
1044 res.push(start + i * step);
1045 }
1046 return res;
1047 }.bind(undefined),
1048 emulateEvent = {
1049 mouse: function () {
1050 var _this16 = this;
1051 _newArrowCheck(this, util_this);
1052 var getParams = function () {
1053 _newArrowCheck(this, _this16);
1054 return {
1055 bubbles: !1,
1056 cancelable: !1,
1057 screenX: 0,
1058 screenY: 0,
1059 clientX: 0,
1060 clientY: 0
1061 };
1062 }.bind(this);
1063 try {
1064 // eslint-disable-next-line no-new
1065 new MouseEvent("t");
1066 return function (el, eventType, params) {
1067 if (params === void 0) {
1068 params = getParams();
1069 }
1070 _newArrowCheck(this, _this16);
1071 el.dispatchEvent(new MouseEvent(eventType, params));
1072 }.bind(this);
1073 } catch (e) {
1074 // Polyfills DOM4 MouseEvent
1075 return function (el, eventType, params) {
1076 if (params === void 0) {
1077 params = getParams();
1078 }
1079 _newArrowCheck(this, _this16);
1080 var mouseEvent = doc.createEvent("MouseEvent");
1081
1082 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
1083 mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0,
1084 // the event's mouse click count
1085 params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null);
1086 el.dispatchEvent(mouseEvent);
1087 }.bind(this);
1088 }
1089 }.bind(undefined)(),
1090 touch: function touch(el, eventType, params) {
1091 _newArrowCheck(this, util_this);
1092 var touchObj = new Touch(mergeObj({
1093 identifier: Date.now(),
1094 target: el,
1095 radiusX: 2.5,
1096 radiusY: 2.5,
1097 rotationAngle: 10,
1098 force: .5
1099 }, params));
1100 el.dispatchEvent(new TouchEvent(eventType, {
1101 cancelable: !0,
1102 bubbles: !0,
1103 shiftKey: !0,
1104 touches: [touchObj],
1105 targetTouches: [],
1106 changedTouches: [touchObj]
1107 }));
1108 }.bind(undefined)
1109 }; // emulate event
1110/**
1111 * Process the template & return bound string
1112 * @param {string} tpl Template string
1113 * @param {object} data Data value to be replaced
1114 * @returns {string}
1115 * @private
1116 */
1117function tplProcess(tpl, data) {
1118 var res = tpl;
1119 for (var x in data) {
1120 res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
1121 }
1122 return res;
1123}
1124
1125/**
1126 * Get parsed date value
1127 * (It must be called in 'ChartInternal' context)
1128 * @param {Date|string|number} date Value of date to be parsed
1129 * @returns {Date}
1130 * @private
1131 */
1132function parseDate(date) {
1133 var parsedDate;
1134 if (date instanceof Date) {
1135 parsedDate = date;
1136 } else if (isString(date)) {
1137 var _format$dataTime,
1138 config = this.config,
1139 format = this.format;
1140 // if fails to parse, try by new Date()
1141 // https://github.com/naver/billboard.js/issues/1714
1142 parsedDate = (_format$dataTime = format.dataTime(config.data_xFormat)(date)) != null ? _format$dataTime : new Date(date);
1143 } else if (isNumber(date) && !isNaN(date)) {
1144 parsedDate = new Date(+date);
1145 }
1146 if (!parsedDate || isNaN(+parsedDate)) {
1147 console && console.error && console.error("Failed to parse x '" + date + "' to Date object");
1148 }
1149 return parsedDate;
1150}
1151
1152/**
1153 * Return if the current doc is visible or not
1154 * @returns {boolean}
1155 * @private
1156 */
1157function isTabVisible() {
1158 return (doc == null ? void 0 : doc.hidden) === !1 || (doc == null ? void 0 : doc.visibilityState) === "visible";
1159}
1160
1161/**
1162 * Get the current input type
1163 * @param {boolean} mouse Config value: interaction.inputType.mouse
1164 * @param {boolean} touch Config value: interaction.inputType.touch
1165 * @returns {string} "mouse" | "touch" | null
1166 * @private
1167 */
1168function convertInputType(mouse, touch) {
1169 var _this17 = this,
1170 DocumentTouch = win.DocumentTouch,
1171 matchMedia = win.matchMedia,
1172 navigator = win.navigator,
1173 hasTouch = !1;
1174 if (touch) {
1175 // Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
1176 if (navigator && "maxTouchPoints" in navigator) {
1177 hasTouch = navigator.maxTouchPoints > 0;
1178
1179 // Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
1180 // On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
1181 } else if ("ontouchmove" in win || DocumentTouch && doc instanceof DocumentTouch) {
1182 hasTouch = !0;
1183 } else {
1184 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#avoiding_user_agent_detection
1185 if (matchMedia != null && matchMedia("(pointer:coarse)").matches) {
1186 hasTouch = !0;
1187 } else {
1188 // Only as a last resort, fall back to user agent sniffing
1189 var UA = navigator.userAgent;
1190 hasTouch = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
1191 }
1192 }
1193 }
1194
1195 // Check if agent has mouse using any-hover, touch devices (e.g iPad) with external mouse will return true as long as mouse is connected
1196 // https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-testing-the-capabilities-of-all-inputs
1197 // Demo: https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/
1198 var hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some(function (v) {
1199 _newArrowCheck(this, _this17);
1200 return matchMedia == null ? void 0 : matchMedia("(" + v + ")").matches;
1201 }.bind(this));
1202
1203 // fallback to 'mouse' if no input type is detected.
1204 return hasMouse && "mouse" || hasTouch && "touch" || "mouse";
1205}
1206
1207/**
1208 * Run function until given condition function return true
1209 * @param {Function} fn Function to be executed when condition is true
1210 * @param {Function} conditionFn Condition function to check if condition is true
1211 * @private
1212 */
1213function runUntil(fn, conditionFn) {
1214 var _this18 = this;
1215 if (conditionFn() === !1) {
1216 win.requestAnimationFrame(function () {
1217 _newArrowCheck(this, _this18);
1218 return runUntil(fn, conditionFn);
1219 }.bind(this));
1220 } else {
1221 fn();
1222 }
1223}
1224;// CONCATENATED MODULE: ./src/config/config.ts
1225
1226/**
1227 * Copyright (c) 2017 ~ present NAVER Corp.
1228 * billboard.js project is licensed under the MIT license
1229 */
1230
1231/**
1232 * Load configuration option
1233 * @param {object} config User's generation config value
1234 * @private
1235 */
1236function loadConfig(config) {
1237 var _this = this,
1238 thisConfig = this.config,
1239 target,
1240 keys,
1241 read,
1242 find = function () {
1243 _newArrowCheck(this, _this);
1244 var key = keys.shift();
1245 if (key && target && isObjectType(target) && key in target) {
1246 target = target[key];
1247 return find();
1248 } else if (!key) {
1249 return target;
1250 }
1251 return undefined;
1252 }.bind(this);
1253 Object.keys(thisConfig).forEach(function (key) {
1254 _newArrowCheck(this, _this);
1255 target = config;
1256 keys = key.split("_");
1257 read = find();
1258 if (isDefined(read)) {
1259 thisConfig[key] = read;
1260 }
1261 }.bind(this));
1262
1263 // only should run in the ChartInternal context
1264 if (this.api) {
1265 this.state.orgConfig = config;
1266 }
1267}
1268;// CONCATENATED MODULE: ./src/Plugin/Plugin.ts
1269
1270/**
1271 * Copyright (c) 2017 ~ present NAVER Corp.
1272 * billboard.js project is licensed under the MIT license
1273 */
1274/**
1275 * Base class to generate billboard.js plugin
1276 * @class Plugin
1277 */
1278/**
1279 * Version info string for plugin
1280 * @name version
1281 * @static
1282 * @memberof Plugin
1283 * @type {string}
1284 * @example
1285 * bb.plugin.stanford.version; // ex) 1.9.0
1286 */
1287var Plugin = /*#__PURE__*/function () {
1288 /**
1289 * Constructor
1290 * @param {Any} options config option object
1291 * @private
1292 */
1293 function Plugin(options) {
1294 if (options === void 0) {
1295 options = {};
1296 }
1297 this.$$ = void 0;
1298 this.options = void 0;
1299 this.options = options;
1300 }
1301
1302 /**
1303 * Lifecycle hook for 'beforeInit' phase.
1304 * @private
1305 */
1306 var _proto = Plugin.prototype;
1307 _proto.$beforeInit = function $beforeInit() {}
1308
1309 /**
1310 * Lifecycle hook for 'init' phase.
1311 * @private
1312 */;
1313 _proto.$init = function $init() {}
1314
1315 /**
1316 * Lifecycle hook for 'afterInit' phase.
1317 * @private
1318 */;
1319 _proto.$afterInit = function $afterInit() {}
1320
1321 /**
1322 * Lifecycle hook for 'redraw' phase.
1323 * @private
1324 */;
1325 _proto.$redraw = function $redraw() {}
1326
1327 /**
1328 * Lifecycle hook for 'willDestroy' phase.
1329 * @private
1330 */;
1331 _proto.$willDestroy = function $willDestroy() {
1332 var _this = this;
1333 Object.keys(this).forEach(function (key) {
1334 _newArrowCheck(this, _this);
1335 this[key] = null;
1336 delete this[key];
1337 }.bind(this));
1338 };
1339 return Plugin;
1340}();
1341Plugin.version = "3.6.3";
1342
1343;// CONCATENATED MODULE: ./src/Plugin/stanford/Options.ts
1344/**
1345 * Copyright (c) 2017 ~ present NAVER Corp.
1346 * billboard.js project is licensed under the MIT license
1347 */
1348/**
1349 * Stanford diagram plugin option class
1350 * @class StanfordOptions
1351 * @param {Options} options Stanford plugin options
1352 * @augments Plugin
1353 * @returns {StanfordOptions}
1354 * @private
1355 */
1356var Options = function () {
1357 return {
1358 /**
1359 * Set the color of the color scale. This function receives a value between 0 and 1, and should return a color.
1360 * @name colors
1361 * @memberof plugin-stanford
1362 * @type {Function}
1363 * @default undefined
1364 * @example
1365 * colors: d3.interpolateHslLong(
1366 * d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)
1367 * )
1368 */
1369 colors: undefined,
1370 /**
1371 * Specify the key of epochs values in the data.
1372 * @name epochs
1373 * @memberof plugin-stanford
1374 * @type {Array}
1375 * @default []
1376 * @example
1377 * epochs: [ 1, 1, 2, 2, ... ]
1378 */
1379 epochs: [],
1380 /**
1381 * Show additional lines anywhere on the chart.
1382 * - Each line object should consist with following options:
1383 *
1384 * | Key | Type | Description |
1385 * | --- | --- | --- |
1386 * | x1 | Number | Starting position on the x axis |
1387 * | y1 | Number | Starting position on the y axis |
1388 * | x2 | Number | Ending position on the x axis |
1389 * | y2 | Number | Ending position on the y axis |
1390 * | class | String | Optional value. Set a custom css class to this line. |
1391 * @type {Array}
1392 * @memberof plugin-stanford
1393 * @default []
1394 * @example
1395 * lines: [
1396 * { x1: 0, y1: 0, x2: 65, y2: 65, class: "line1" },
1397 * { x1: 0, x2: 65, y1: 40, y2: 40, class: "line2" }
1398 * ]
1399 */
1400 lines: [],
1401 /**
1402 * Set scale values
1403 * @name scale
1404 * @memberof plugin-stanford
1405 * @type {object}
1406 * @property {object} [scale] scale object
1407 * @property {number} [scale.min=undefined] Minimum value of the color scale. Default: lowest value in epochs
1408 * @property {number} [scale.max=undefined] Maximum value of the color scale. Default: highest value in epochs
1409 * @property {number} [scale.width=20] Width of the color scale
1410 * @property {string|Function} [scale.format=undefined] Format of the axis of the color scale. Use 'pow10' to format as powers of 10 or a custom function. Example: d3.format("d")
1411 * @example
1412 * scale: {
1413 * max: 10000,
1414 * min: 1,
1415 * width: 500,
1416 *
1417 * // specify 'pow10' to format as powers of 10
1418 * format: "pow10",
1419 *
1420 * // or specify a format function
1421 * format: function(x) {
1422 * return x +"%";
1423 * }
1424 * },
1425 */
1426 scale_min: undefined,
1427 scale_max: undefined,
1428 scale_width: 20,
1429 scale_format: undefined,
1430 /**
1431 * The padding for color scale element
1432 * @name padding
1433 * @memberof plugin-stanford
1434 * @type {object}
1435 * @property {object} [padding] padding object
1436 * @property {number} [padding.top=0] Top padding value.
1437 * @property {number} [padding.right=0] Right padding value.
1438 * @property {number} [padding.bottom=0] Bottom padding value.
1439 * @property {number} [padding.left=0] Left padding value.
1440 * @example
1441 * padding: {
1442 * top: 15,
1443 * right: 0,
1444 * bottom: 0,
1445 * left: 0
1446 * },
1447 */
1448 padding_top: 0,
1449 padding_right: 0,
1450 padding_bottom: 0,
1451 padding_left: 0,
1452 /**
1453 * Show additional regions anywhere on the chart.
1454 * - Each region object should consist with following options:
1455 *
1456 * | Key | Type | Default | Attributes | Description |
1457 * | --- | --- | --- | --- | --- |
1458 * | points | Array | | | Accepts a group of objects that has x and y.<br>These points should be added in a counter-clockwise fashion to make a closed polygon. |
1459 * | opacity | Number | `0.2` | &lt;optional> | Sets the opacity of the region as value between 0 and 1 |
1460 * | text | Function | | &lt;optional> | This function receives a value and percentage of the number of epochs in this region.<br>Return a string to place text in the middle of the region. |
1461 * | class | String | | &lt;optional> | Se a custom css class to this region, use the fill property in css to set a background color. |
1462 * @name regions
1463 * @memberof plugin-stanford
1464 * @type {Array}
1465 * @default []
1466 * @example
1467 * regions: [
1468 * {
1469 * points: [ // add points counter-clockwise
1470 * { x: 0, y: 0 },
1471 * { x: 40, y: 40 },
1472 * { x: 0, y: 40 },
1473 * ],
1474 * text: function (value, percentage) {
1475 * return `Normal Operations: ${value} (${percentage}%)`;
1476 * },
1477 * opacity: 0.2, // 0 to 1
1478 * class: "test-polygon1"
1479 * },
1480 * ...
1481 * ]
1482 */
1483 regions: []
1484 };
1485};
1486
1487;// CONCATENATED MODULE: ./src/Plugin/stanford/classes.ts
1488/**
1489 * Copyright (c) 2017 ~ present NAVER Corp.
1490 * billboard.js project is licensed under the MIT license
1491 */
1492/**
1493 * CSS class names definition
1494 * @private
1495 */
1496/* harmony default export */ var stanford_classes = ({
1497 colorScale: "bb-colorscale",
1498 stanfordElements: "bb-stanford-elements",
1499 stanfordLine: "bb-stanford-line",
1500 stanfordLines: "bb-stanford-lines",
1501 stanfordRegion: "bb-stanford-region",
1502 stanfordRegions: "bb-stanford-regions"
1503});
1504;// CONCATENATED MODULE: ./src/Plugin/stanford/util.ts
1505/**
1506 * Copyright (c) 2017 ~ present NAVER Corp.
1507 * billboard.js project is licensed under the MIT license
1508 * @ignore
1509 */
1510
1511
1512/**
1513 * Check if point is in region
1514 * @param {object} point Point
1515 * @param {Array} region Region
1516 * @returns {boolean}
1517 * @private
1518 */
1519function pointInRegion(point, region) {
1520 // thanks to: http://bl.ocks.org/bycoffe/5575904
1521 // ray-casting algorithm based on
1522 // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
1523 var x = point.x,
1524 y = point.value,
1525 inside = !1;
1526 for (var i = 0, j = region.length - 1; i < region.length; j = i++) {
1527 var xi = region[i].x,
1528 yi = region[i].y,
1529 xj = region[j].x,
1530 yj = region[j].y,
1531 intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
1532 if (intersect) {
1533 inside = !inside;
1534 }
1535 }
1536 return inside;
1537}
1538
1539/**
1540 * Compare epochs
1541 * @param {object} a Target
1542 * @param {object} b Source
1543 * @returns {number}
1544 * @private
1545 */
1546function compareEpochs(a, b) {
1547 if (a.epochs < b.epochs) {
1548 return -1;
1549 }
1550 if (a.epochs > b.epochs) {
1551 return 1;
1552 }
1553 return 0;
1554}
1555
1556/**
1557 * Get region area
1558 * @param {Array} points Points
1559 * @returns {number}
1560 * @private
1561 */
1562function getRegionArea(points) {
1563 // thanks to: https://stackoverflow.com/questions/16282330/find-centerpoint-of-polygon-in-javascript
1564 var area = 0,
1565 point1,
1566 point2;
1567 for (var i = 0, l = points.length, j = l - 1; i < l; j = i, i++) {
1568 point1 = points[i];
1569 point2 = points[j];
1570 area += point1.x * point2.y;
1571 area -= point1.y * point2.x;
1572 }
1573 area /= 2;
1574 return area;
1575}
1576
1577/**
1578 * Get centroid
1579 * @param {Array} points Points
1580 * @returns {object}
1581 * @private
1582 */
1583function getCentroid(points) {
1584 var area = getRegionArea(points),
1585 x = 0,
1586 y = 0,
1587 f;
1588 for (var i = 0, l = points.length, j = l - 1; i < l; j = i, i++) {
1589 var point1 = points[i],
1590 point2 = points[j];
1591 f = point1.x * point2.y - point2.x * point1.y;
1592 x += (point1.x + point2.x) * f;
1593 y += (point1.y + point2.y) * f;
1594 }
1595 f = area * 6;
1596 return {
1597 x: x / f,
1598 y: y / f
1599 };
1600}
1601
1602;// CONCATENATED MODULE: ./src/Plugin/stanford/Elements.ts
1603
1604/**
1605 * Copyright (c) 2017 ~ present NAVER Corp.
1606 * billboard.js project is licensed under the MIT license
1607 */
1608// @ts-nocheck
1609
1610
1611
1612/**
1613 * Stanford diagram plugin element class
1614 * @class ColorScale
1615 * @param {Stanford} owner Stanford instance
1616 * @private
1617 */
1618var Elements = /*#__PURE__*/function () {
1619 function Elements(owner) {
1620 this.owner = void 0;
1621 this.owner = owner;
1622
1623 // MEMO: Avoid blocking eventRect
1624 var elements = owner.$$.$el.main.select(".bb-chart").append("g").attr("class", stanford_classes.stanfordElements);
1625 elements.append("g").attr("class", stanford_classes.stanfordLines);
1626 elements.append("g").attr("class", stanford_classes.stanfordRegions);
1627 }
1628 var _proto = Elements.prototype;
1629 _proto.updateStanfordLines = function updateStanfordLines(duration) {
1630 var _this = this,
1631 $$ = this.owner.$$,
1632 config = $$.config,
1633 main = $$.$el.main,
1634 isRotated = config.axis_rotated,
1635 xvCustom = this.xvCustom.bind($$),
1636 yvCustom = this.yvCustom.bind($$),
1637 stanfordLine = main.select("." + stanford_classes.stanfordLines).style("shape-rendering", "geometricprecision").selectAll("." + stanford_classes.stanfordLine).data(this.owner.config.lines);
1638 // exit
1639 stanfordLine.exit().transition().duration(duration).style("opacity", "0").remove();
1640
1641 // enter
1642 var stanfordLineEnter = stanfordLine.enter().append("g");
1643 stanfordLineEnter.append("line").style("opacity", "0");
1644 stanfordLineEnter.merge(stanfordLine).attr("class", function (d) {
1645 _newArrowCheck(this, _this);
1646 return stanford_classes.stanfordLine + (d.class ? " " + d.class : "");
1647 }.bind(this)).select("line").transition().duration(duration).attr("x1", function (d) {
1648 _newArrowCheck(this, _this);
1649 return isRotated ? yvCustom(d, "y1") : xvCustom(d, "x1");
1650 }.bind(this)).attr("x2", function (d) {
1651 _newArrowCheck(this, _this);
1652 return isRotated ? yvCustom(d, "y2") : xvCustom(d, "x2");
1653 }.bind(this)).attr("y1", function (d) {
1654 _newArrowCheck(this, _this);
1655 return isRotated ? xvCustom(d, "x1") : yvCustom(d, "y1");
1656 }.bind(this)).attr("y2", function (d) {
1657 _newArrowCheck(this, _this);
1658 return isRotated ? xvCustom(d, "x2") : yvCustom(d, "y2");
1659 }.bind(this)).transition().style("opacity", null);
1660 };
1661 _proto.updateStanfordRegions = function updateStanfordRegions(duration) {
1662 var _this2 = this,
1663 $$ = this.owner.$$,
1664 config = $$.config,
1665 main = $$.$el.main,
1666 isRotated = config.axis_rotated,
1667 xvCustom = this.xvCustom.bind($$),
1668 yvCustom = this.yvCustom.bind($$),
1669 countPointsInRegion = this.owner.countEpochsInRegion.bind($$),
1670 stanfordRegion = main.select("." + stanford_classes.stanfordRegions).selectAll("." + stanford_classes.stanfordRegion).data(this.owner.config.regions);
1671 // exit
1672 stanfordRegion.exit().transition().duration(duration).style("opacity", "0").remove();
1673
1674 // enter
1675 var stanfordRegionEnter = stanfordRegion.enter().append("g");
1676 stanfordRegionEnter.append("polygon").style("opacity", "0");
1677 stanfordRegionEnter.append("text").attr("transform", isRotated ? "rotate(-90)" : "").style("opacity", "0");
1678 stanfordRegion = stanfordRegionEnter.merge(stanfordRegion);
1679
1680 // update
1681 stanfordRegion.attr("class", function (d) {
1682 _newArrowCheck(this, _this2);
1683 return stanford_classes.stanfordRegion + (d.class ? " " + d.class : "");
1684 }.bind(this)).select("polygon").transition().duration(duration).attr("points", function (d) {
1685 var _this3 = this;
1686 _newArrowCheck(this, _this2);
1687 return d.points.map(function (value) {
1688 _newArrowCheck(this, _this3);
1689 return [isRotated ? yvCustom(value, "y") : xvCustom(value, "x"), isRotated ? xvCustom(value, "x") : yvCustom(value, "y")].join(",");
1690 }.bind(this)).join(" ");
1691 }.bind(this)).transition().style("opacity", function (d) {
1692 _newArrowCheck(this, _this2);
1693 return (d.opacity ? d.opacity : .2) + "";
1694 }.bind(this));
1695 stanfordRegion.select("text").transition().duration(duration).attr("x", function (d) {
1696 _newArrowCheck(this, _this2);
1697 return isRotated ? yvCustom(getCentroid(d.points), "y") : xvCustom(getCentroid(d.points), "x");
1698 }.bind(this)).attr("y", function (d) {
1699 _newArrowCheck(this, _this2);
1700 return isRotated ? xvCustom(getCentroid(d.points), "x") : yvCustom(getCentroid(d.points), "y");
1701 }.bind(this)).text(function (d) {
1702 _newArrowCheck(this, _this2);
1703 if (d.text) {
1704 var _countPointsInRegion = countPointsInRegion(d.points),
1705 value = _countPointsInRegion.value,
1706 percentage = _countPointsInRegion.percentage;
1707 return d.text(value, percentage);
1708 }
1709 return "";
1710 }.bind(this)).attr("text-anchor", "middle").attr("dominant-baseline", "middle").transition().style("opacity", null);
1711 };
1712 _proto.updateStanfordElements = function updateStanfordElements(duration) {
1713 if (duration === void 0) {
1714 duration = 0;
1715 }
1716 this.updateStanfordLines(duration);
1717 this.updateStanfordRegions(duration);
1718 };
1719 _proto.xvCustom = function xvCustom(d, xyValue) {
1720 var $$ = this,
1721 axis = $$.axis,
1722 config = $$.config,
1723 value = xyValue ? d[xyValue] : $$.getBaseValue(d);
1724 if (axis.isTimeSeries()) {
1725 value = parseDate.call($$, value);
1726 } else if (axis.isCategorized() && isString(value)) {
1727 value = config.axis_x_categories.indexOf(d.value);
1728 }
1729 return Math.ceil($$.scale.x(value));
1730 };
1731 _proto.yvCustom = function yvCustom(d, xyValue) {
1732 var $$ = this,
1733 yScale = d.axis && d.axis === "y2" ? $$.scale.y2 : $$.scale.y,
1734 value = xyValue ? d[xyValue] : $$.getBaseValue(d);
1735 return Math.ceil(yScale(value));
1736 };
1737 return Elements;
1738}();
1739
1740// EXTERNAL MODULE: external {"commonjs":"d3-axis","commonjs2":"d3-axis","amd":"d3-axis","root":"d3"}
1741var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack_require__(8);
1742// EXTERNAL MODULE: external {"commonjs":"d3-format","commonjs2":"d3-format","amd":"d3-format","root":"d3"}
1743var external_commonjs_d3_format_commonjs2_d3_format_amd_d3_format_root_d3_ = __webpack_require__(9);
1744;// CONCATENATED MODULE: ./src/Plugin/stanford/ColorScale.ts
1745
1746/**
1747 * Copyright (c) 2017 ~ present NAVER Corp.
1748 * billboard.js project is licensed under the MIT license
1749 */
1750
1751
1752
1753
1754
1755
1756/**
1757 * Stanford diagram plugin color scale class
1758 * @class ColorScale
1759 * @param {Stanford} owner Stanford instance
1760 * @private
1761 */
1762var ColorScale = /*#__PURE__*/function () {
1763 function ColorScale(owner) {
1764 this.owner = void 0;
1765 this.colorScale = void 0;
1766 this.owner = owner;
1767 }
1768 var _proto = ColorScale.prototype;
1769 _proto.drawColorScale = function drawColorScale() {
1770 var _this = this,
1771 _this$owner = this.owner,
1772 $$ = _this$owner.$$,
1773 config = _this$owner.config,
1774 target = $$.data.targets[0],
1775 height = $$.state.height - config.padding_bottom - config.padding_top,
1776 barWidth = config.scale_width,
1777 points = getRange(config.padding_bottom, height, 5),
1778 inverseScale = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSequential)(target.colors).domain([points[points.length - 1], points[0]]);
1779 if (this.colorScale) {
1780 this.colorScale.remove();
1781 }
1782 this.colorScale = $$.$el.svg.append("g").attr("width", 50).attr("height", height).attr("class", stanford_classes.colorScale);
1783 this.colorScale.append("g").attr("transform", "translate(0, " + config.padding_top + ")").selectAll("bars").data(points).enter().append("rect").attr("y", function (d, i) {
1784 _newArrowCheck(this, _this);
1785 return i * 5;
1786 }.bind(this)).attr("x", 0).attr("width", barWidth).attr("height", 5).attr("fill", function (d) {
1787 _newArrowCheck(this, _this);
1788 return inverseScale(d);
1789 }.bind(this));
1790
1791 // Legend Axis
1792 var axisScale = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLog)().domain([target.minEpochs, target.maxEpochs]).range([points[0] + config.padding_top + points[points.length - 1] + 5 - 1, points[0] + config.padding_top]),
1793 legendAxis = (0,external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisRight)(axisScale),
1794 scaleFormat = config.scale_format;
1795 if (scaleFormat === "pow10") {
1796 legendAxis.tickValues([1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7]);
1797 } else if (isFunction(scaleFormat)) {
1798 legendAxis.tickFormat(scaleFormat);
1799 } else {
1800 legendAxis.tickFormat((0,external_commonjs_d3_format_commonjs2_d3_format_amd_d3_format_root_d3_.format)("d"));
1801 }
1802
1803 // Draw Axis
1804 var axis = this.colorScale.append("g").attr("class", "legend axis").attr("transform", "translate(" + barWidth + ",0)").call(legendAxis);
1805 if (scaleFormat === "pow10") {
1806 axis.selectAll(".tick text").text(null).filter(function (d) {
1807 _newArrowCheck(this, _this);
1808 return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1;
1809 }.bind(this)) // Power of Ten
1810 .text(10).append("tspan").attr("dy", "-.7em") // https://bl.ocks.org/mbostock/6738229
1811 .text(function (d) {
1812 _newArrowCheck(this, _this);
1813 return Math.round(Math.log(d) / Math.LN10);
1814 }.bind(this));
1815 }
1816 this.colorScale.attr("transform", "translate(" + ($$.state.current.width - this.xForColorScale()) + ", 0)");
1817 };
1818 _proto.xForColorScale = function xForColorScale() {
1819 return this.owner.config.padding_right + this.colorScale.node().getBBox().width;
1820 };
1821 _proto.getColorScalePadding = function getColorScalePadding() {
1822 return this.xForColorScale() + this.owner.config.padding_left + 20;
1823 };
1824 return ColorScale;
1825}();
1826
1827;// CONCATENATED MODULE: ./src/Plugin/stanford/index.ts
1828
1829
1830
1831/**
1832 * Copyright (c) 2017 ~ present NAVER Corp.
1833 * billboard.js project is licensed under the MIT license
1834 */
1835// @ts-nocheck
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847/**
1848 * Stanford diagram plugin
1849 * - **NOTE:**
1850 * - Plugins aren't built-in. Need to be loaded or imported to be used.
1851 * - Non required modules from billboard.js core, need to be installed separately.
1852 * - Is preferable use `scatter` as data.type
1853 * - **Required modules:**
1854 * - [d3-selection](https://github.com/d3/d3-selection)
1855 * - [d3-interpolate](https://github.com/d3/d3-interpolate)
1856 * - [d3-color](https://github.com/d3/d3-color)
1857 * - [d3-scale](https://github.com/d3/d3-scale)
1858 * - [d3-brush](https://github.com/d3/d3-brush)
1859 * - [d3-axis](https://github.com/d3/d3-axis)
1860 * - [d3-format](https://github.com/d3/d3-format)
1861 * @class plugin-stanford
1862 * @requires d3-selection
1863 * @requires d3-interpolate
1864 * @requires d3-color
1865 * @requires d3-scale
1866 * @requires d3-brush
1867 * @requires d3-axis
1868 * @requires d3-format
1869 * @param {object} options Stanford plugin options
1870 * @augments Plugin
1871 * @returns {Stanford}
1872 * @example
1873 * // Plugin must be loaded before the use.
1874 * <script src="$YOUR_PATH/plugin/billboardjs-plugin-stanford.js"></script>
1875 *
1876 * var chart = bb.generate({
1877 * data: {
1878 * columns: [ ... ],
1879 * type: "scatter"
1880 * }
1881 * ...
1882 * plugins: [
1883 * new bb.plugin.stanford({
1884 * colors: d3.interpolateHslLong(
1885 * d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)
1886 * ),
1887 * epochs: [ 1, 1, 2, 2, ... ],
1888 * lines: [
1889 * { x1: 0, y1: 0, x2: 65, y2: 65, class: "line1" },
1890 * { x1: 0, x2: 65, y1: 40, y2: 40, class: "line2" }
1891 * ],
1892 * scale: {
1893 * max: 10000,
1894 * min: 1,
1895 * width: 500,
1896 * format: 'pow10',
1897 * },
1898 * padding: {
1899 * top: 15,
1900 * right: 0,
1901 * bottom: 0,
1902 * left: 0
1903 * },
1904 * regions: [
1905 * {
1906 * points: [ // add points counter-clockwise
1907 * { x: 0, y: 0 },
1908 * { x: 40, y: 40 },
1909 * { x: 0, y: 40 }
1910 * ],
1911 * text: function (value, percentage) {
1912 * return `Normal Operations: ${value} (${percentage}%)`;
1913 * },
1914 * opacity: 0.2, // 0 to 1
1915 * class: "test-polygon1"
1916 * },
1917 * ...
1918 * ]
1919 * }
1920 * ]
1921 * });
1922 * @example
1923 * import {bb} from "billboard.js";
1924 * import Stanford from "billboard.js/dist/billboardjs-plugin-stanford";
1925 *
1926 * bb.generate({
1927 * plugins: [
1928 * new Stanford({ ... })
1929 * ]
1930 * })
1931 */
1932var Stanford = /*#__PURE__*/function (_Plugin) {
1933 _inheritsLoose(Stanford, _Plugin);
1934 function Stanford(options) {
1935 var _this = _Plugin.call(this, options) || this;
1936 _this.config = void 0;
1937 _this.colorScale = void 0;
1938 _this.elements = void 0;
1939 _this.config = new Options();
1940 return _assertThisInitialized(_this) || _assertThisInitialized(_this);
1941 }
1942 var _proto = Stanford.prototype;
1943 _proto.$beforeInit = function $beforeInit() {
1944 var _this2 = this,
1945 $$ = this.$$;
1946 // override on config values & methods
1947 $$.config.data_xSort = !1;
1948 $$.isMultipleX = function () {
1949 _newArrowCheck(this, _this2);
1950 return !0;
1951 }.bind(this);
1952 $$.showGridFocus = function () {
1953 _newArrowCheck(this, _this2);
1954 }.bind(this);
1955 $$.labelishData = function (d) {
1956 _newArrowCheck(this, _this2);
1957 return d.values;
1958 }.bind(this);
1959 $$.opacityForCircle = function () {
1960 _newArrowCheck(this, _this2);
1961 return 1;
1962 }.bind(this);
1963 var getCurrentPaddingRight = $$.getCurrentPaddingRight.bind($$);
1964 $$.getCurrentPaddingRight = function () {
1965 _newArrowCheck(this, _this2);
1966 return getCurrentPaddingRight() + (this.colorScale ? this.colorScale.getColorScalePadding() : 0);
1967 }.bind(this);
1968 };
1969 _proto.$init = function $init() {
1970 var $$ = this.$$;
1971 loadConfig.call(this, this.options);
1972 $$.color = this.getStanfordPointColor.bind($$);
1973 this.colorScale = new ColorScale(this);
1974 this.elements = new Elements(this);
1975 this.convertData();
1976 this.initStanfordData();
1977 this.setStanfordTooltip();
1978 this.colorScale.drawColorScale();
1979 this.$redraw();
1980 };
1981 _proto.$redraw = function $redraw(duration) {
1982 var _this$colorScale, _this$elements;
1983 (_this$colorScale = this.colorScale) == null ? void 0 : _this$colorScale.drawColorScale();
1984 (_this$elements = this.elements) == null ? void 0 : _this$elements.updateStanfordElements(duration);
1985 };
1986 _proto.getOptions = function getOptions() {
1987 return new Options();
1988 };
1989 _proto.convertData = function convertData() {
1990 var _this3 = this,
1991 data = this.$$.data.targets,
1992 epochs = this.options.epochs;
1993 data.forEach(function (d) {
1994 var _this4 = this;
1995 _newArrowCheck(this, _this3);
1996 d.values.forEach(function (v, i) {
1997 _newArrowCheck(this, _this4);
1998 v.epochs = epochs[i];
1999 }.bind(this));
2000 d.minEpochs = undefined;
2001 d.maxEpochs = undefined;
2002 d.colors = undefined;
2003 d.colorscale = undefined;
2004 }.bind(this));
2005 };
2006 _proto.xvCustom = function xvCustom(d, xyValue) {
2007 var $$ = this,
2008 axis = $$.axis,
2009 config = $$.config,
2010 value = xyValue ? d[xyValue] : $$.getBaseValue(d);
2011 if (axis.isTimeSeries()) {
2012 value = parseDate.call($$, value);
2013 } else if (axis.isCategorized() && isString(value)) {
2014 value = config.axis_x_categories.indexOf(d.value);
2015 }
2016 return Math.ceil($$.scale.x(value));
2017 };
2018 _proto.yvCustom = function yvCustom(d, xyValue) {
2019 var $$ = this,
2020 scale = $$.scale,
2021 yScale = d.axis && d.axis === "y2" ? scale.y2 : scale.y,
2022 value = xyValue ? d[xyValue] : $$.getBaseValue(d);
2023 return Math.ceil(yScale(value));
2024 };
2025 _proto.initStanfordData = function initStanfordData() {
2026 var _this5 = this,
2027 config = this.config,
2028 target = this.$$.data.targets[0];
2029 // TODO STANFORD see if (data.js -> orderTargets)+ can be used instead
2030 // Make larger values appear on top
2031 target.values.sort(compareEpochs);
2032
2033 // Get array of epochs
2034 var epochs = target.values.map(function (a) {
2035 _newArrowCheck(this, _this5);
2036 return a.epochs;
2037 }.bind(this));
2038 target.minEpochs = !isNaN(config.scale_min) ? config.scale_min : Math.min.apply(Math, epochs);
2039 target.maxEpochs = !isNaN(config.scale_max) ? config.scale_max : Math.max.apply(Math, epochs);
2040 target.colors = isFunction(config.colors) ? config.colors : (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolateHslLong)((0,external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_.hsl)(250, 1, .5), (0,external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_.hsl)(0, 1, .5));
2041 target.colorscale = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSequentialLog)(target.colors).domain([target.minEpochs, target.maxEpochs]);
2042 };
2043 _proto.getStanfordPointColor = function getStanfordPointColor(d) {
2044 var target = this.data.targets[0];
2045 return target.colorscale(d.epochs);
2046 };
2047 _proto.setStanfordTooltip = function setStanfordTooltip() {
2048 var config = this.$$.config;
2049 if (isEmpty(config.tooltip_contents)) {
2050 config.tooltip_contents = function (d, defaultTitleFormat, defaultValueFormat, color) {
2051 var _this6 = this,
2052 data_x = config.data_x,
2053 html = "<table class=\"" + $TOOLTIP.tooltip + "\"><tbody>";
2054 d.forEach(function (v) {
2055 _newArrowCheck(this, _this6);
2056 var _v$id = v.id,
2057 id = _v$id === void 0 ? "" : _v$id,
2058 _v$value = v.value,
2059 value = _v$value === void 0 ? 0 : _v$value,
2060 _v$epochs = v.epochs,
2061 epochs = _v$epochs === void 0 ? 0 : _v$epochs,
2062 _v$x = v.x,
2063 x = _v$x === void 0 ? "" : _v$x;
2064 html += "<tr>\n\t\t\t\t\t\t\t<th>" + (data_x || "") + "</th>\n\t\t\t\t\t\t\t<th class=\"value\">" + defaultTitleFormat(x) + "</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>" + v.id + "</th>\n\t\t\t\t\t\t\t<th class=\"value\">" + defaultValueFormat(value) + "</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class=\"" + $TOOLTIP.tooltipName + "-" + id + "\">\n\t\t\t\t\t\t\t<td class=\"name\"><span style=\"background-color:" + color(v) + "\"></span>Epochs</td>\n\t\t\t\t\t\t\t<td class=\"value\">" + defaultValueFormat(epochs) + "</td>\n\t\t\t\t\t\t</tr>";
2065 }.bind(this));
2066 return html + "</tbody></table>";
2067 };
2068 }
2069 };
2070 _proto.countEpochsInRegion = function countEpochsInRegion(region) {
2071 var _this7 = this,
2072 $$ = this,
2073 target = $$.data.targets[0],
2074 total = target.values.reduce(function (accumulator, currentValue) {
2075 _newArrowCheck(this, _this7);
2076 return accumulator + +currentValue.epochs;
2077 }.bind(this), 0),
2078 value = target.values.reduce(function (accumulator, currentValue) {
2079 _newArrowCheck(this, _this7);
2080 if (pointInRegion(currentValue, region)) {
2081 return accumulator + +currentValue.epochs;
2082 }
2083 return accumulator;
2084 }.bind(this), 0);
2085 return {
2086 value: value,
2087 percentage: value !== 0 ? +(value / total * 100).toFixed(1) : 0
2088 };
2089 };
2090 return Stanford;
2091}(Plugin);
2092
2093}();
2094__webpack_exports__ = __webpack_exports__["default"];
2095/******/ return __webpack_exports__;
2096/******/ })()
2097;
2098});
\No newline at end of file