UNPKG

55 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 * http://naver.github.io/billboard.js/
7 *
8 * @version 1.12.1
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-selection"), require("d3-array"), require("d3-interpolate"), require("d3-color"), require("d3-scale"), require("d3-brush"), require("d3-axis"), require("d3-format"));
15 else if(typeof define === 'function' && define.amd)
16 define("stanford", ["d3-selection", "d3-array", "d3-interpolate", "d3-color", "d3-scale", "d3-brush", "d3-axis", "d3-format"], factory);
17 else if(typeof exports === 'object')
18 exports["stanford"] = factory(require("d3-selection"), require("d3-array"), require("d3-interpolate"), require("d3-color"), require("d3-scale"), 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"], root["d3"]);
21})(this, function(__WEBPACK_EXTERNAL_MODULE__8__, __WEBPACK_EXTERNAL_MODULE__10__, __WEBPACK_EXTERNAL_MODULE__11__, __WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__13__, __WEBPACK_EXTERNAL_MODULE__14__, __WEBPACK_EXTERNAL_MODULE__15__, __WEBPACK_EXTERNAL_MODULE__16__) {
22return /******/ (function(modules) { // webpackBootstrap
23/******/ // The module cache
24/******/ var installedModules = {};
25/******/
26/******/ // The require function
27/******/ function __webpack_require__(moduleId) {
28/******/
29/******/ // Check if module is in cache
30/******/ if(installedModules[moduleId]) {
31/******/ return installedModules[moduleId].exports;
32/******/ }
33/******/ // Create a new module (and put it into the cache)
34/******/ var module = installedModules[moduleId] = {
35/******/ i: moduleId,
36/******/ l: false,
37/******/ exports: {}
38/******/ };
39/******/
40/******/ // Execute the module function
41/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
42/******/
43/******/ // Flag the module as loaded
44/******/ module.l = true;
45/******/
46/******/ // Return the exports of the module
47/******/ return module.exports;
48/******/ }
49/******/
50/******/
51/******/ // expose the modules object (__webpack_modules__)
52/******/ __webpack_require__.m = modules;
53/******/
54/******/ // expose the module cache
55/******/ __webpack_require__.c = installedModules;
56/******/
57/******/ // define getter function for harmony exports
58/******/ __webpack_require__.d = function(exports, name, getter) {
59/******/ if(!__webpack_require__.o(exports, name)) {
60/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
61/******/ }
62/******/ };
63/******/
64/******/ // define __esModule on exports
65/******/ __webpack_require__.r = function(exports) {
66/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
67/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
68/******/ }
69/******/ Object.defineProperty(exports, '__esModule', { value: true });
70/******/ };
71/******/
72/******/ // create a fake namespace object
73/******/ // mode & 1: value is a module id, require it
74/******/ // mode & 2: merge all properties of value into the ns
75/******/ // mode & 4: return value when already ns object
76/******/ // mode & 8|1: behave like require
77/******/ __webpack_require__.t = function(value, mode) {
78/******/ if(mode & 1) value = __webpack_require__(value);
79/******/ if(mode & 8) return value;
80/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
81/******/ var ns = Object.create(null);
82/******/ __webpack_require__.r(ns);
83/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
84/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
85/******/ return ns;
86/******/ };
87/******/
88/******/ // getDefaultExport function for compatibility with non-harmony modules
89/******/ __webpack_require__.n = function(module) {
90/******/ var getter = module && module.__esModule ?
91/******/ function getDefault() { return module['default']; } :
92/******/ function getModuleExports() { return module; };
93/******/ __webpack_require__.d(getter, 'a', getter);
94/******/ return getter;
95/******/ };
96/******/
97/******/ // Object.prototype.hasOwnProperty.call
98/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
99/******/
100/******/ // __webpack_public_path__
101/******/ __webpack_require__.p = "";
102/******/
103/******/
104/******/ // Load entry module and return exports
105/******/ return __webpack_require__(__webpack_require__.s = 19);
106/******/ })
107/************************************************************************/
108/******/ ([
109/* 0 */,
110/* 1 */
111/***/ (function(module, __webpack_exports__, __webpack_require__) {
112
113"use strict";
114/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
115function _classCallCheck(instance, Constructor) {
116 if (!(instance instanceof Constructor)) {
117 throw new TypeError("Cannot call a class as a function");
118 }
119}
120
121/***/ }),
122/* 2 */
123/***/ (function(module, __webpack_exports__, __webpack_require__) {
124
125"use strict";
126/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
127function _defineProperties(target, props) {
128 for (var i = 0; i < props.length; i++) {
129 var descriptor = props[i];
130 descriptor.enumerable = descriptor.enumerable || false;
131 descriptor.configurable = true;
132 if ("value" in descriptor) descriptor.writable = true;
133 Object.defineProperty(target, descriptor.key, descriptor);
134 }
135}
136
137function _createClass(Constructor, protoProps, staticProps) {
138 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
139 if (staticProps) _defineProperties(Constructor, staticProps);
140 return Constructor;
141}
142
143/***/ }),
144/* 3 */
145/***/ (function(module, __webpack_exports__, __webpack_require__) {
146
147"use strict";
148/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
149/* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
150/* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
151
152
153function _possibleConstructorReturn(self, call) {
154 if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) {
155 return call;
156 }
157
158 return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
159}
160
161/***/ }),
162/* 4 */
163/***/ (function(module, __webpack_exports__, __webpack_require__) {
164
165"use strict";
166/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
167function _typeof(obj) {
168 "@babel/helpers - typeof";
169
170 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
171 _typeof = function _typeof(obj) {
172 return typeof obj;
173 };
174 } else {
175 _typeof = function _typeof(obj) {
176 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
177 };
178 }
179
180 return _typeof(obj);
181}
182
183/***/ }),
184/* 5 */
185/***/ (function(module, __webpack_exports__, __webpack_require__) {
186
187"use strict";
188/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
189function _assertThisInitialized(self) {
190 if (self === void 0) {
191 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
192 }
193
194 return self;
195}
196
197/***/ }),
198/* 6 */
199/***/ (function(module, __webpack_exports__, __webpack_require__) {
200
201"use strict";
202/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
203function _getPrototypeOf(o) {
204 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
205 return o.__proto__ || Object.getPrototypeOf(o);
206 };
207 return _getPrototypeOf(o);
208}
209
210/***/ }),
211/* 7 */
212/***/ (function(module, __webpack_exports__, __webpack_require__) {
213
214"use strict";
215/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
216function _defineProperty(obj, key, value) {
217 if (key in obj) {
218 Object.defineProperty(obj, key, {
219 value: value,
220 enumerable: true,
221 configurable: true,
222 writable: true
223 });
224 } else {
225 obj[key] = value;
226 }
227
228 return obj;
229}
230
231/***/ }),
232/* 8 */
233/***/ (function(module, exports) {
234
235module.exports = __WEBPACK_EXTERNAL_MODULE__8__;
236
237/***/ }),
238/* 9 */
239/***/ (function(module, __webpack_exports__, __webpack_require__) {
240
241"use strict";
242/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Plugin; });
243/* harmony import */ var _babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
244/* harmony import */ var _babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
245/* harmony import */ var _babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
246
247
248
249
250/**
251 * Copyright (c) 2017 ~ present NAVER Corp.
252 * billboard.js project is licensed under the MIT license
253 */
254
255/**
256 * Base class to generate billboard.js plugin
257 * @class Plugin
258 */
259var Plugin = /*#__PURE__*/function () {
260 /**
261 * Version info string for plugin
262 * @name version
263 * @static
264 * @memberof Plugin
265 * @type {String}
266 * @example
267 * bb.plugin.stanford.version; // ex) 1.9.0
268 */
269
270 /**
271 * Constructor
272 * @param {Any} config config option object
273 * @private
274 */
275 function Plugin() {
276 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
277 Object(_babel_runtime_helpers_esm_classCallCheck__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(this, Plugin), this.options = options;
278 }
279 /**
280 * Lifecycle hook for 'beforeInit' phase.
281 * @private
282 */
283
284
285 return Object(_babel_runtime_helpers_esm_createClass__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(Plugin, [{
286 key: "$beforeInit",
287 value: function $beforeInit() {}
288 /**
289 * Lifecycle hook for 'init' phase.
290 * @private
291 */
292
293 }, {
294 key: "$init",
295 value: function $init() {}
296 /**
297 * Lifecycle hook for 'afterInit' phase.
298 * @private
299 */
300
301 }, {
302 key: "$afterInit",
303 value: function $afterInit() {}
304 /**
305 * Lifecycle hook for 'redraw' phase.
306 * @private
307 */
308
309 }, {
310 key: "$redraw",
311 value: function $redraw() {}
312 /**
313 * Lifecycle hook for 'willDestroy' phase.
314 * @private
315 */
316
317 }, {
318 key: "$willDestroy",
319 value: function $willDestroy() {
320 var _this = this;
321
322 Object.keys(this).forEach(function (key) {
323 _this[key] = null, delete _this[key];
324 });
325 }
326 }]), Plugin;
327}();
328
329Object(_babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"])(Plugin, "version", "1.12.1");
330
331
332
333/***/ }),
334/* 10 */
335/***/ (function(module, exports) {
336
337module.exports = __WEBPACK_EXTERNAL_MODULE__10__;
338
339/***/ }),
340/* 11 */
341/***/ (function(module, exports) {
342
343module.exports = __WEBPACK_EXTERNAL_MODULE__11__;
344
345/***/ }),
346/* 12 */
347/***/ (function(module, exports) {
348
349module.exports = __WEBPACK_EXTERNAL_MODULE__12__;
350
351/***/ }),
352/* 13 */
353/***/ (function(module, exports) {
354
355module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
356
357/***/ }),
358/* 14 */
359/***/ (function(module, exports) {
360
361module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
362
363/***/ }),
364/* 15 */
365/***/ (function(module, exports) {
366
367module.exports = __WEBPACK_EXTERNAL_MODULE__15__;
368
369/***/ }),
370/* 16 */
371/***/ (function(module, exports) {
372
373module.exports = __WEBPACK_EXTERNAL_MODULE__16__;
374
375/***/ }),
376/* 17 */,
377/* 18 */,
378/* 19 */
379/***/ (function(module, __webpack_exports__, __webpack_require__) {
380
381"use strict";
382// ESM COMPAT FLAG
383__webpack_require__.r(__webpack_exports__);
384
385// EXPORTS
386__webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ stanford_Stanford; });
387
388// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
389var classCallCheck = __webpack_require__(1);
390
391// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
392var createClass = __webpack_require__(2);
393
394// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
395var possibleConstructorReturn = __webpack_require__(3);
396
397// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
398var getPrototypeOf = __webpack_require__(6);
399
400// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
401var assertThisInitialized = __webpack_require__(5);
402
403// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules
404var inherits = __webpack_require__(22);
405
406// EXTERNAL MODULE: external {"commonjs":"d3-array","commonjs2":"d3-array","amd":"d3-array","root":"d3"}
407var external_commonjs_d3_array_commonjs2_d3_array_amd_d3_array_root_d3_ = __webpack_require__(10);
408
409// EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
410var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(11);
411
412// EXTERNAL MODULE: external {"commonjs":"d3-color","commonjs2":"d3-color","amd":"d3-color","root":"d3"}
413var external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_ = __webpack_require__(12);
414
415// EXTERNAL MODULE: external {"commonjs":"d3-scale","commonjs2":"d3-scale","amd":"d3-scale","root":"d3"}
416var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webpack_require__(13);
417
418// CONCATENATED MODULE: ./src/config/classes.js
419/**
420 * Copyright (c) 2017 ~ present NAVER Corp.
421 * billboard.js project is licensed under the MIT license
422 */
423
424/**
425 * CSS class names definition
426 * @private
427 */
428/* harmony default export */ var classes = ({
429 arc: "bb-arc",
430 arcLabelLine: "bb-arc-label-line",
431 arcs: "bb-arcs",
432 area: "bb-area",
433 areas: "bb-areas",
434 axis: "bb-axis",
435 axisX: "bb-axis-x",
436 axisXLabel: "bb-axis-x-label",
437 axisY: "bb-axis-y",
438 axisY2: "bb-axis-y2",
439 axisY2Label: "bb-axis-y2-label",
440 axisYLabel: "bb-axis-y-label",
441 bar: "bb-bar",
442 bars: "bb-bars",
443 brush: "bb-brush",
444 button: "bb-button",
445 buttonZoomReset: "bb-zoom-reset",
446 chart: "bb-chart",
447 chartArc: "bb-chart-arc",
448 chartArcs: "bb-chart-arcs",
449 chartArcsBackground: "bb-chart-arcs-background",
450 chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
451 chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
452 chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
453 chartArcsTitle: "bb-chart-arcs-title",
454 chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
455 chartBar: "bb-chart-bar",
456 chartBars: "bb-chart-bars",
457 chartLine: "bb-chart-line",
458 chartLines: "bb-chart-lines",
459 chartRadar: "bb-chart-radar",
460 chartRadars: "bb-chart-radars",
461 chartText: "bb-chart-text",
462 chartTexts: "bb-chart-texts",
463 circle: "bb-circle",
464 circles: "bb-circles",
465 colorPattern: "bb-color-pattern",
466 colorScale: "bb-colorscale",
467 defocused: "bb-defocused",
468 dragarea: "bb-dragarea",
469 empty: "bb-empty",
470 eventRect: "bb-event-rect",
471 eventRects: "bb-event-rects",
472 eventRectsMultiple: "bb-event-rects-multiple",
473 eventRectsSingle: "bb-event-rects-single",
474 focused: "bb-focused",
475 gaugeValue: "bb-gauge-value",
476 grid: "bb-grid",
477 gridLines: "bb-grid-lines",
478 legendBackground: "bb-legend-background",
479 legendItem: "bb-legend-item",
480 legendItemEvent: "bb-legend-item-event",
481 legendItemFocused: "bb-legend-item-focused",
482 legendItemHidden: "bb-legend-item-hidden",
483 legendItemPoint: "bb-legend-item-point",
484 legendItemTile: "bb-legend-item-tile",
485 level: "bb-level",
486 levels: "bb-levels",
487 line: "bb-line",
488 lines: "bb-lines",
489 region: "bb-region",
490 regions: "bb-regions",
491 selectedCircle: "bb-selected-circle",
492 selectedCircles: "bb-selected-circles",
493 shape: "bb-shape",
494 shapes: "bb-shapes",
495 stanfordElements: "bb-stanford-elements",
496 stanfordLine: "bb-stanford-line",
497 stanfordLines: "bb-stanford-lines",
498 stanfordRegion: "bb-stanford-region",
499 stanfordRegions: "bb-stanford-regions",
500 target: "bb-target",
501 text: "bb-text",
502 texts: "bb-texts",
503 title: "bb-title",
504 tooltip: "bb-tooltip",
505 tooltipContainer: "bb-tooltip-container",
506 tooltipName: "bb-tooltip-name",
507 xgrid: "bb-xgrid",
508 xgridFocus: "bb-xgrid-focus",
509 xgridLine: "bb-xgrid-line",
510 xgridLines: "bb-xgrid-lines",
511 xgrids: "bb-xgrids",
512 ygrid: "bb-ygrid",
513 ygridFocus: "bb-ygrid-focus",
514 ygridLine: "bb-ygrid-line",
515 ygridLines: "bb-ygrid-lines",
516 ygrids: "bb-ygrids",
517 zoomBrush: "bb-zoom-brush",
518 zoomRect: "bb-zoom-rect",
519 EXPANDED: "_expanded_",
520 SELECTED: "_selected_",
521 INCLUDED: "_included_",
522 TextOverlapping: "text-overlapping"
523});
524// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
525function _arrayWithoutHoles(arr) {
526 if (Array.isArray(arr)) {
527 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
528 arr2[i] = arr[i];
529 }
530
531 return arr2;
532 }
533}
534// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
535function _iterableToArray(iter) {
536 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
537}
538// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
539function _nonIterableSpread() {
540 throw new TypeError("Invalid attempt to spread non-iterable instance");
541}
542// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
543
544
545
546function _toConsumableArray(arr) {
547 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
548}
549// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
550var esm_typeof = __webpack_require__(4);
551
552// EXTERNAL MODULE: external {"commonjs":"d3-selection","commonjs2":"d3-selection","amd":"d3-selection","root":"d3"}
553var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(8);
554
555// EXTERNAL MODULE: external {"commonjs":"d3-brush","commonjs2":"d3-brush","amd":"d3-brush","root":"d3"}
556var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(14);
557
558// CONCATENATED MODULE: ./src/internals/browser.js
559/**
560 * Copyright (c) 2017 ~ present NAVER Corp.
561 * billboard.js project is licensed under the MIT license
562 */
563
564/**
565 * Window object
566 * @module
567 * @ignore
568 */
569
570/* eslint-disable no-new-func, no-undef */
571var win = function () {
572 var def = function (o) {
573 return typeof o !== "undefined" && o;
574 };
575
576 return def(self) || def(window) || def(global) || def(globalThis) || Function("return this")();
577}(),
578 doc = win && win.document;
579/* eslint-enable no-new-func, no-undef */
580
581
582
583// CONCATENATED MODULE: ./src/internals/util.js
584
585
586
587/**
588 * Copyright (c) 2017 ~ present NAVER Corp.
589 * billboard.js project is licensed under the MIT license
590 * @ignore
591 */
592
593
594
595
596
597var isValue = function (v) {
598 return v || v === 0;
599},
600 isFunction = function (v) {
601 return typeof v === "function";
602},
603 isString = function (v) {
604 return typeof v === "string";
605},
606 isNumber = function (v) {
607 return typeof v === "number";
608},
609 isUndefined = function (v) {
610 return typeof v === "undefined";
611},
612 isDefined = function (v) {
613 return typeof v !== "undefined";
614},
615 isBoolean = function (v) {
616 return typeof v === "boolean";
617},
618 ceil10 = function (v) {
619 return Math.ceil(v / 10) * 10;
620},
621 asHalfPixel = function (n) {
622 return Math.ceil(n) + .5;
623},
624 diffDomain = function (d) {
625 return d[1] - d[0];
626},
627 isObjectType = function (v) {
628 return Object(esm_typeof["a" /* default */])(v) === "object";
629},
630 isEmpty = function (o) {
631 return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
632},
633 notEmpty = function (o) {
634 return !isEmpty(o);
635},
636 isArray = function (arr) {
637 return arr && arr.constructor === Array;
638},
639 isObject = function (obj) {
640 return obj && !obj.nodeType && isObjectType(obj) && !isArray(obj);
641},
642 getOption = function (options, key, defaultValue) {
643 return isDefined(options[key]) ? options[key] : defaultValue;
644},
645 hasValue = function (dict, value) {
646 var found = !1;
647 return Object.keys(dict).forEach(function (key) {
648 return dict[key] === value && (found = !0);
649 }), found;
650},
651 callFn = function (fn) {
652 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];
653
654 return isFn && fn.call.apply(fn, args), isFn;
655},
656 sanitise = function (str) {
657 return isString(str) ? str.replace(/</g, "&lt;").replace(/>/g, "&gt;") : str;
658},
659 setTextValue = function (node, text) {
660 var dy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [-1, 1],
661 toMiddle = !!(arguments.length > 3 && arguments[3] !== undefined) && arguments[3];
662 if (node && isString(text)) if (text.indexOf("\n") === -1) node.text(text);else {
663 var diff = [node.text(), text].map(function (v) {
664 return v.replace(/[\s\n]/g, "");
665 });
666
667 if (diff[0] !== diff[1]) {
668 var multiline = text.split("\n"),
669 len = toMiddle ? multiline.length - 1 : 1;
670 node.html(""), multiline.forEach(function (v, i) {
671 node.append("tspan").attr("x", 0).attr("dy", "".concat(i === 0 ? dy[0] * len : dy[1], "em")).text(v);
672 });
673 }
674 }
675},
676 getRectSegList = function (path) {
677 /*
678 * seg1 ---------- seg2
679 * | |
680 * | |
681 * | |
682 * seg0 ---------- seg3
683 * */
684 var _path$getBBox = path.getBBox(),
685 x = _path$getBBox.x,
686 y = _path$getBBox.y,
687 width = _path$getBBox.width,
688 height = _path$getBBox.height;
689
690 return [{
691 x: x,
692 y: y + height
693 }, // seg0
694 {
695 x: x,
696 y: y
697 }, // seg1
698 {
699 x: x + width,
700 y: y
701 }, // seg2
702 {
703 x: x + width,
704 y: y + height
705 } // seg3
706 ];
707},
708 getPathBox = function (path) {
709 var _path$getBoundingClie = path.getBoundingClientRect(),
710 width = _path$getBoundingClie.width,
711 height = _path$getBoundingClie.height,
712 items = getRectSegList(path),
713 x = items[0].x,
714 y = Math.min(items[0].y, items[1].y);
715
716 return {
717 x: x,
718 y: y,
719 width: width,
720 height: height
721 };
722},
723 getBrushSelection = function (ctx) {
724 var selection = null,
725 event = external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_["event"],
726 main = ctx.context || ctx.main;
727 return event && event.constructor.name === "BrushEvent" ? selection = event.selection : main && (selection = main.select(".".concat(classes.brush)).node()) && (selection = Object(external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_["brushSelection"])(selection)), selection;
728},
729 getBoundingRect = function (node) {
730 return node.rect || (node.rect = node.getBoundingClientRect());
731},
732 getRandom = function () {
733 var asStr = !(arguments.length > 0 && arguments[0] !== undefined) || arguments[0];
734 return Math.random() + (asStr ? "" : 0);
735},
736 brushEmpty = function (ctx) {
737 var selection = getBrushSelection(ctx);
738 return !selection || selection[0] === selection[1];
739},
740 extend = function () {
741 var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
742 source = arguments.length > 1 ? arguments[1] : undefined;
743
744 for (var p in source) target[p] = source[p];
745
746 return target;
747},
748 capitalize = function (str) {
749 return str.charAt(0).toUpperCase() + str.slice(1);
750},
751 toArray = function (v) {
752 return [].slice.call(v);
753},
754 getCssRules = function (styleSheets) {
755 var rules = [];
756 return styleSheets.forEach(function (sheet) {
757 try {
758 sheet.cssRules && sheet.cssRules.length && (rules = rules.concat(toArray(sheet.cssRules)));
759 } catch (e) {
760 console.error("Error while reading rules from ".concat(sheet.href, ": ").concat(e.toString()));
761 }
762 }), rules;
763},
764 getTranslation = function (node) {
765 var transform = node ? node.transform : null,
766 baseVal = transform ? transform.baseVal : [];
767 return baseVal.length ? baseVal.getItem(0).matrix : {
768 a: 0,
769 b: 0,
770 c: 0,
771 d: 0,
772 e: 0,
773 f: 0
774 };
775},
776 getUnique = function (data) {
777 var isDate = data[0] instanceof Date,
778 d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
779 return self.indexOf(v) === i;
780 });
781 return isDate ? d.map(function (v) {
782 return new Date(v);
783 }) : d;
784},
785 mergeArray = function (arr) {
786 return arr && arr.length ? arr.reduce(function (p, c) {
787 return p.concat(c);
788 }) : [];
789},
790 mergeObj = function (_mergeObj) {
791 function mergeObj() {
792 return _mergeObj.apply(this, arguments);
793 }
794
795 return mergeObj.toString = function () {
796 return _mergeObj.toString();
797 }, mergeObj;
798}(function (target) {
799 for (var _len2 = arguments.length, objectN = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) objectN[_key2 - 1] = arguments[_key2];
800
801 if (!objectN.length || objectN.length === 1 && !objectN[0]) return target;
802 var source = objectN.shift();
803 return isObject(target) && isObject(source) && Object.keys(source).forEach(function (key) {
804 var value = source[key];
805 isObject(value) ? (!target[key] && (target[key] = {}), target[key] = mergeObj(target[key], value)) : target[key] = isArray(value) ? value.concat() : value;
806 }), mergeObj.apply(void 0, [target].concat(objectN));
807}),
808 sortValue = function (data) {
809 var fn,
810 isAsc = !(arguments.length > 1 && arguments[1] !== undefined) || arguments[1];
811 return data[0] instanceof Date ? fn = isAsc ? function (a, b) {
812 return a - b;
813 } : function (a, b) {
814 return b - a;
815 } : isAsc && !data.every(isNaN) ? fn = function (a, b) {
816 return a - b;
817 } : !isAsc && (fn = function (a, b) {
818 return a > b && -1 || a < b && 1 || a === b && 0;
819 }), data.concat().sort(fn);
820},
821 getMinMax = function (type, data) {
822 var res = data.filter(function (v) {
823 return notEmpty(v);
824 });
825 return res.length ? isNumber(res[0]) ? res = Math[type].apply(Math, _toConsumableArray(res)) : res[0] instanceof Date && (res = sortValue(res, type === "min")[0]) : res = undefined, res;
826},
827 getRange = function (start, end) {
828 var res = [];
829
830 for (var i = start; i < end; i++) res.push(i);
831
832 return res;
833},
834 emulateEvent = {
835 mouse: function () {
836 var getParams = function () {
837 return {
838 bubbles: !1,
839 cancelable: !1,
840 screenX: 0,
841 screenY: 0,
842 clientX: 0,
843 clientY: 0
844 };
845 };
846
847 try {
848 return new MouseEvent("t"), function (el, eventType) {
849 var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getParams();
850 el.dispatchEvent(new MouseEvent(eventType, params));
851 };
852 } catch (e) {
853 // Polyfills DOM4 MouseEvent
854 return function (el, eventType) {
855 var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getParams(),
856 mouseEvent = doc.createEvent("MouseEvent");
857 mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0, // the event's mouse click count
858 params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null), el.dispatchEvent(mouseEvent);
859 };
860 }
861 }(),
862 touch: function touch(el, eventType, params) {
863 var touchObj = new Touch(mergeObj({
864 identifier: Date.now(),
865 target: el,
866 radiusX: 2.5,
867 radiusY: 2.5,
868 rotationAngle: 10,
869 force: .5
870 }, params));
871 el.dispatchEvent(new TouchEvent(eventType, {
872 cancelable: !0,
873 bubbles: !0,
874 shiftKey: !0,
875 touches: [touchObj],
876 targetTouches: [],
877 changedTouches: [touchObj]
878 }));
879 }
880},
881 tplProcess = function (tpl, data) {
882 var res = tpl;
883
884 for (var x in data) res = res.replace(new RegExp("{=".concat(x, "}"), "g"), data[x]);
885
886 return res;
887};
888
889
890// EXTERNAL MODULE: ./src/plugin/Plugin.js
891var Plugin = __webpack_require__(9);
892
893// CONCATENATED MODULE: ./src/plugin/stanford/Options.js
894
895
896/**
897 * Copyright (c) 2017 ~ present NAVER Corp.
898 * billboard.js project is licensed under the MIT license
899 */
900
901/**
902 * Stanford diagram plugin option class
903 * @class StanfordOptions
904 * @param {Options} options Stanford plugin options
905 * @extends Plugin
906 * @return {StanfordOptions}
907 * @private
908 */
909var Options_Options = function Options() {
910 return Object(classCallCheck["a" /* default */])(this, Options), {
911 /**
912 * Set the color of the color scale. This function receives a value between 0 and 1, and should return a color.
913 * @name colors
914 * @memberof plugin-stanford
915 * @type {Function}
916 * @default undefined
917 * @example
918 * colors: d3.interpolateHslLong(
919 * d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)
920 * )
921 */
922 colors: undefined,
923
924 /**
925 * Specify the key of epochs values in the data.
926 * @name epochs
927 * @memberof plugin-stanford
928 * @type {Array}
929 * @default []
930 * @example
931 * epochs: [ 1, 1, 2, 2, ... ]
932 */
933 epochs: [],
934
935 /**
936 * Show additional lines anywhere on the chart.
937 * - Each line object should consist with following options:
938 *
939 * | Key | Type | Description |
940 * | --- | --- | --- |
941 * | x1 | Number | Starting position on the x axis |
942 * | y1 | Number | Starting position on the y axis |
943 * | x2 | Number | Ending position on the x axis |
944 * | y2 | Number | Ending position on the y axis |
945 * | class | String | Optional value. Set a custom css class to this line. |
946 * @type {Array}
947 * @memberof plugin-stanford
948 * @default []
949 * @example
950 * lines: [
951 * { x1: 0, y1: 0, x2: 65, y2: 65, class: "line1" },
952 * { x1: 0, x2: 65, y1: 40, y2: 40, class: "line2" }
953 * ]
954 */
955 lines: [],
956
957 /**
958 * Set scale values
959 * @name scale
960 * @memberof plugin-stanford
961 * @type {Object}
962 * @property {Number} [scale.min=undefined] Minimum value of the color scale. Default: lowest value in epochs
963 * @property {Number} [scale.max=undefined] Maximum value of the color scale. Default: highest value in epochs
964 * @property {Number} [scale.width=20] Width of the color scale
965 * @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")
966 * @example
967 * scale: {
968 * max: 10000,
969 * min: 1,
970 * width: 500,
971 *
972 * // specify 'pow10' to format as powers of 10
973 * format: "pow10",
974 *
975 * // or specify a format function
976 * format: function(x) {
977 * return x +"%";
978 * }
979 * },
980 */
981 scale_min: undefined,
982 scale_max: undefined,
983 scale_width: 20,
984 scale_format: undefined,
985
986 /**
987 * The padding for color scale element
988 * @name padding
989 * @memberof plugin-stanford
990 * @type {Object}
991 * @property {Number} [padding.top=0] Top padding value.
992 * @property {Number} [padding.right=0] Right padding value.
993 * @property {Number} [padding.bottom=0] Bottom padding value.
994 * @property {Number} [padding.left=0] Left padding value.
995 * @example
996 * padding: {
997 * top: 15,
998 * right: 0,
999 * bottom: 0,
1000 * left: 0
1001 * },
1002 */
1003 padding_top: 0,
1004 padding_right: 0,
1005 padding_bottom: 0,
1006 padding_left: 0,
1007
1008 /**
1009 * Show additional regions anywhere on the chart.
1010 * - Each region object should consist with following options:
1011 *
1012 * | Key | Type | Default | Attributes | Description |
1013 * | --- | --- | --- | --- | --- |
1014 * | 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. |
1015 * | opacity | Number | `0.2` | &lt;optional> | Sets the opacity of the region as value between 0 and 1 |
1016 * | 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. |
1017 * | class | String | | &lt;optional> | Se a custom css class to this region, use the fill property in css to set a background color. |
1018 * @name regions
1019 * @memberof plugin-stanford
1020 * @type {Array}
1021 * @default []
1022 * @example
1023 * regions: [
1024 * {
1025 * points: [ // add points counter-clockwise
1026 * { x: 0, y: 0 },
1027 * { x: 40, y: 40 },
1028 * { x: 0, y: 40 },
1029 * ],
1030 * text: function (value, percentage) {
1031 * return `Normal Operations: ${value} (${percentage}%)`;
1032 * },
1033 * opacity: 0.2, // 0 to 1
1034 * class: "test-polygon1"
1035 * },
1036 * ...
1037 * ]
1038 */
1039 regions: []
1040 };
1041};
1042
1043
1044// CONCATENATED MODULE: ./src/plugin/stanford/classes.js
1045/**
1046 * Copyright (c) 2017 ~ present NAVER Corp.
1047 * billboard.js project is licensed under the MIT license
1048 */
1049
1050/**
1051 * CSS class names definition
1052 * @private
1053 */
1054/* harmony default export */ var stanford_classes = ({
1055 colorScale: "bb-colorscale",
1056 stanfordElements: "bb-stanford-elements",
1057 stanfordLine: "bb-stanford-line",
1058 stanfordLines: "bb-stanford-lines",
1059 stanfordRegion: "bb-stanford-region",
1060 stanfordRegions: "bb-stanford-regions"
1061});
1062// CONCATENATED MODULE: ./src/plugin/stanford/util.js
1063/**
1064 * Copyright (c) 2017 ~ present NAVER Corp.
1065 * billboard.js project is licensed under the MIT license
1066 * @ignore
1067 */
1068function pointInRegion(point, region) {
1069 // thanks to: http://bl.ocks.org/bycoffe/5575904
1070 // ray-casting algorithm based on
1071 // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
1072 var x = point.x,
1073 y = point.value,
1074 inside = !1;
1075
1076 for (var i = 0, j = region.length - 1; i < region.length; j = i++) {
1077 var xi = region[i].x,
1078 yi = region[i].y,
1079 xj = region[j].x,
1080 yj = region[j].y;
1081 yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi && (inside = !inside);
1082 }
1083
1084 return inside;
1085}
1086
1087function compareEpochs(a, b) {
1088 return a.epochs < b.epochs ? -1 : a.epochs > b.epochs ? 1 : 0;
1089}
1090
1091function getRegionArea(points) {
1092 // thanks to: https://stackoverflow.com/questions/16282330/find-centerpoint-of-polygon-in-javascript
1093 for (var point1, point2, area = 0, i = 0, l = points.length, j = l - 1; i < l; j = i, i++) point1 = points[i], point2 = points[j], area += point1.x * point2.y, area -= point1.y * point2.x;
1094
1095 return area /= 2, area;
1096}
1097
1098function getCentroid(points) {
1099 for (var f, area = getRegionArea(points), x = 0, y = 0, i = 0, l = points.length, j = l - 1; i < l; j = i, i++) {
1100 var _point = points[i],
1101 _point2 = points[j];
1102 f = _point.x * _point2.y - _point2.x * _point.y, x += (_point.x + _point2.x) * f, y += (_point.y + _point2.y) * f;
1103 }
1104
1105 return f = area * 6, {
1106 x: x / f,
1107 y: y / f
1108 };
1109}
1110
1111
1112// CONCATENATED MODULE: ./src/plugin/stanford/Elements.js
1113
1114
1115
1116/**
1117 * Copyright (c) 2017 ~ present NAVER Corp.
1118 * billboard.js project is licensed under the MIT license
1119 */
1120
1121
1122
1123/**
1124 * Stanford diagram plugin element class
1125 * @class ColorScale
1126 * @param {Stanford} owner Stanford instance
1127 * @private
1128 */
1129
1130var Elements_Elements = /*#__PURE__*/function () {
1131 function Elements(owner) {
1132 Object(classCallCheck["a" /* default */])(this, Elements), this.owner = owner;
1133 // MEMO: Avoid blocking eventRect
1134 var elements = owner.$$.main.select(".bb-chart").append("g").attr("class", stanford_classes.stanfordElements);
1135 elements.append("g").attr("class", stanford_classes.stanfordLines), elements.append("g").attr("class", stanford_classes.stanfordRegions);
1136 }
1137
1138 return Object(createClass["a" /* default */])(Elements, [{
1139 key: "updateStanfordLines",
1140 value: function updateStanfordLines(duration) {
1141 var $$ = this.owner.$$,
1142 main = $$.main,
1143 config = $$.config,
1144 isRotated = config.axis_rotated,
1145 xvCustom = this.xvCustom.bind($$),
1146 yvCustom = this.yvCustom.bind($$),
1147 stanfordLine = main.select(".".concat(stanford_classes.stanfordLines)).style("shape-rendering", "geometricprecision").selectAll(".".concat(stanford_classes.stanfordLine)).data(this.owner.config.lines);
1148 stanfordLine.exit().transition().duration(duration).style("opacity", "0").remove();
1149 // enter
1150 var stanfordLineEnter = stanfordLine.enter().append("g");
1151 stanfordLineEnter.append("line").style("opacity", "0"), stanfordLineEnter.merge(stanfordLine).attr("class", function (d) {
1152 return stanford_classes.stanfordLine + (d["class"] ? " ".concat(d["class"]) : "");
1153 }).select("line").transition().duration(duration).attr("x1", function (d) {
1154 return isRotated ? yvCustom(d, "y1") : xvCustom(d, "x1");
1155 }).attr("x2", function (d) {
1156 return isRotated ? yvCustom(d, "y2") : xvCustom(d, "x2");
1157 }).attr("y1", function (d) {
1158 return isRotated ? xvCustom(d, "x1") : yvCustom(d, "y1");
1159 }).attr("y2", function (d) {
1160 return isRotated ? xvCustom(d, "x2") : yvCustom(d, "y2");
1161 }).transition().style("opacity", "1");
1162 }
1163 }, {
1164 key: "updateStanfordRegions",
1165 value: function updateStanfordRegions(duration) {
1166 var $$ = this.owner.$$,
1167 main = $$.main,
1168 config = $$.config,
1169 isRotated = config.axis_rotated,
1170 xvCustom = this.xvCustom.bind($$),
1171 yvCustom = this.yvCustom.bind($$),
1172 countPointsInRegion = this.owner.countEpochsInRegion.bind($$),
1173 stanfordRegion = main.select(".".concat(stanford_classes.stanfordRegions)).selectAll(".".concat(stanford_classes.stanfordRegion)).data(this.owner.config.regions);
1174 stanfordRegion.exit().transition().duration(duration).style("opacity", "0").remove();
1175 // enter
1176 var stanfordRegionEnter = stanfordRegion.enter().append("g");
1177 stanfordRegionEnter.append("polygon").style("opacity", "0"), stanfordRegionEnter.append("text").attr("transform", isRotated ? "rotate(-90)" : "").style("opacity", "0"), stanfordRegion = stanfordRegionEnter.merge(stanfordRegion), stanfordRegion.attr("class", function (d) {
1178 return stanford_classes.stanfordRegion + (d["class"] ? " ".concat(d["class"]) : "");
1179 }).select("polygon").transition().duration(duration).attr("points", function (d) {
1180 return d.points.map(function (value) {
1181 return [isRotated ? yvCustom(value, "y") : xvCustom(value, "x"), isRotated ? xvCustom(value, "x") : yvCustom(value, "y")].join(",");
1182 }).join(" ");
1183 }).transition().style("opacity", function (d) {
1184 return (d.opacity ? d.opacity : .2) + "";
1185 }), stanfordRegion.select("text").transition().duration(duration).attr("x", function (d) {
1186 return isRotated ? yvCustom(getCentroid(d.points), "y") : xvCustom(getCentroid(d.points), "x");
1187 }).attr("y", function (d) {
1188 return isRotated ? xvCustom(getCentroid(d.points), "x") : yvCustom(getCentroid(d.points), "y");
1189 }).text(function (d) {
1190 if (d.text) {
1191 var _countPointsInRegion = countPointsInRegion(d.points),
1192 value = _countPointsInRegion.value,
1193 percentage = _countPointsInRegion.percentage;
1194
1195 return d.text(value, percentage);
1196 }
1197
1198 return "";
1199 }).attr("text-anchor", "middle").attr("dominant-baseline", "middle").transition().style("opacity", "1");
1200 }
1201 }, {
1202 key: "updateStanfordElements",
1203 value: function updateStanfordElements() {
1204 var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1205 this.updateStanfordLines(duration), this.updateStanfordRegions(duration);
1206 }
1207 }, {
1208 key: "xvCustom",
1209 value: function xvCustom(d, xyValue) {
1210 var $$ = this,
1211 value = xyValue ? d[xyValue] : $$.getBaseValue(d);
1212 return $$.isTimeSeries() ? value = $$.parseDate(value) : $$.isCategorized() && isString(value) && (value = $$.config.axis_x_categories.indexOf(d.value)), Math.ceil($$.x(value));
1213 }
1214 }, {
1215 key: "yvCustom",
1216 value: function yvCustom(d, xyValue) {
1217 var $$ = this,
1218 yScale = d.axis && d.axis === "y2" ? $$.y2 : $$.y,
1219 value = xyValue ? d[xyValue] : $$.getBaseValue(d);
1220 return Math.ceil(yScale(value));
1221 }
1222 }]), Elements;
1223}();
1224
1225
1226// EXTERNAL MODULE: external {"commonjs":"d3-axis","commonjs2":"d3-axis","amd":"d3-axis","root":"d3"}
1227var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack_require__(15);
1228
1229// EXTERNAL MODULE: external {"commonjs":"d3-format","commonjs2":"d3-format","amd":"d3-format","root":"d3"}
1230var external_commonjs_d3_format_commonjs2_d3_format_amd_d3_format_root_d3_ = __webpack_require__(16);
1231
1232// CONCATENATED MODULE: ./src/plugin/stanford/ColorScale.js
1233
1234
1235
1236/**
1237 * Copyright (c) 2017 ~ present NAVER Corp.
1238 * billboard.js project is licensed under the MIT license
1239 */
1240
1241
1242
1243
1244
1245
1246/**
1247 * Stanford diagram plugin color scale class
1248 * @class ColorScale
1249 * @param {Stanford} owner Stanford instance
1250 * @private
1251 */
1252
1253var ColorScale_ColorScale = /*#__PURE__*/function () {
1254 function ColorScale(owner) {
1255 Object(classCallCheck["a" /* default */])(this, ColorScale), this.owner = owner;
1256 }
1257
1258 return Object(createClass["a" /* default */])(ColorScale, [{
1259 key: "drawColorScale",
1260 value: function drawColorScale() {
1261 var $$ = this.owner.$$,
1262 config = this.owner.config,
1263 target = $$.data.targets[0],
1264 height = $$.height - config.padding_bottom - config.padding_top,
1265 barWidth = config.scale_width,
1266 barHeight = 5,
1267 points = Object(external_commonjs_d3_array_commonjs2_d3_array_amd_d3_array_root_d3_["range"])(config.padding_bottom, height, barHeight),
1268 inverseScale = Object(external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_["scaleSequential"])(target.colors).domain([points[points.length - 1], points[0]]);
1269 this.colorScale && this.colorScale.remove(), this.colorScale = $$.svg.append("g").attr("width", 50).attr("height", height).attr("class", stanford_classes.colorScale), this.colorScale.append("g").attr("transform", "translate(0, ".concat(config.padding_top, ")")).selectAll("bars").data(points).enter().append("rect").attr("y", function (d, i) {
1270 return i * barHeight;
1271 }).attr("x", 0).attr("width", barWidth).attr("height", barHeight).attr("fill", function (d) {
1272 return inverseScale(d);
1273 });
1274 // Legend Axis
1275 var axisScale = Object(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] + barHeight - 1, points[0] + config.padding_top]),
1276 legendAxis = Object(external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_["axisRight"])(axisScale),
1277 scaleFormat = config.scale_format;
1278 scaleFormat === "pow10" ? legendAxis.tickValues([1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7]) : isFunction(scaleFormat) ? legendAxis.tickFormat(scaleFormat) : legendAxis.tickFormat(Object(external_commonjs_d3_format_commonjs2_d3_format_amd_d3_format_root_d3_["format"])("d"));
1279 // Draw Axis
1280 var axis = this.colorScale.append("g").attr("class", "legend axis").attr("transform", "translate(".concat(barWidth, ",0)")).call(legendAxis);
1281 scaleFormat === "pow10" && axis.selectAll(".tick text").text(null).filter(function (d) {
1282 return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1;
1283 }) // Power of Ten
1284 .text(10).append("tspan").attr("dy", "-.7em") // https://bl.ocks.org/mbostock/6738229
1285 .text(function (d) {
1286 return Math.round(Math.log(d) / Math.LN10);
1287 }), this.colorScale.attr("transform", "translate(".concat($$.currentWidth - this.xForColorScale(), ", 0)"));
1288 }
1289 }, {
1290 key: "xForColorScale",
1291 value: function xForColorScale() {
1292 return this.owner.config.padding_right + this.colorScale.node().getBBox().width;
1293 }
1294 }, {
1295 key: "getColorScalePadding",
1296 value: function getColorScalePadding() {
1297 return this.xForColorScale() + this.owner.config.padding_left + 20;
1298 }
1299 }]), ColorScale;
1300}();
1301
1302
1303// CONCATENATED MODULE: ./src/plugin/stanford/index.js
1304
1305
1306
1307
1308
1309
1310
1311/**
1312 * Copyright (c) 2017 ~ present NAVER Corp.
1313 * billboard.js project is licensed under the MIT license
1314 */
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326/**
1327 * Stanford diagram plugin
1328 * - **NOTE:**
1329 * - Plugins aren't built-in. Need to be loaded or imported to be used.
1330 * - Non required modules from billboard.js core, need to be installed separately.
1331 * - Is preferable use `scatter` as data.type
1332 * - **Required modules:**
1333 * - [d3-selection](https://github.com/d3/d3-selection)
1334 * - [d3-array](https://github.com/d3/d3-array)
1335 * - [d3-interpolate](https://github.com/d3/d3-interpolate)
1336 * - [d3-color](https://github.com/d3/d3-color)
1337 * - [d3-scale](https://github.com/d3/d3-scale)
1338 * - [d3-brush](https://github.com/d3/d3-brush)
1339 * - [d3-axis](https://github.com/d3/d3-axis)
1340 * - [d3-format](https://github.com/d3/d3-format)
1341 * @class plugin-stanford
1342 * @requires d3-selection
1343 * @requires d3-array
1344 * @requires d3-interpolate
1345 * @requires d3-color
1346 * @requires d3-scale
1347 * @requires d3-brush
1348 * @requires d3-axis
1349 * @requires d3-format
1350 * @param {Object} options Stanford plugin options
1351 * @extends Plugin
1352 * @return {Stanford}
1353 * @example
1354 * var chart = bb.generate({
1355 * data: {
1356 * columns: [ ... ],
1357 * type: "scatter"
1358 * }
1359 * ...
1360 * plugins: [
1361 * new bb.plugin.stanford({
1362 * colors: d3.interpolateHslLong(
1363 * d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)
1364 * ),
1365 * epochs: [ 1, 1, 2, 2, ... ],
1366 * lines: [
1367 * { x1: 0, y1: 0, x2: 65, y2: 65, class: "line1" },
1368 * { x1: 0, x2: 65, y1: 40, y2: 40, class: "line2" }
1369 * ],
1370 * scale: {
1371 * max: 10000,
1372 * min: 1,
1373 * width: 500,
1374 * format: 'pow10',
1375 * },
1376 * padding: {
1377 * top: 15,
1378 * right: 0,
1379 * bottom: 0,
1380 * left: 0
1381 * },
1382 * regions: [
1383 * {
1384 * points: [ // add points counter-clockwise
1385 * { x: 0, y: 0 },
1386 * { x: 40, y: 40 },
1387 * { x: 0, y: 40 }
1388 * ],
1389 * text: function (value, percentage) {
1390 * return `Normal Operations: ${value} (${percentage}%)`;
1391 * },
1392 * opacity: 0.2, // 0 to 1
1393 * class: "test-polygon1"
1394 * },
1395 * ...
1396 * ]
1397 * }
1398 * ]
1399 * });
1400 * @example
1401 * import {bb} from "billboard.js";
1402 * import Stanford from "billboard.js/dist/billboardjs-plugin-stanford";
1403 *
1404 * bb.generate({
1405 * plugins: [
1406 * new Stanford({ ... })
1407 * ]
1408 * })
1409 */
1410
1411var stanford_Stanford = /*#__PURE__*/function (_Plugin) {
1412 function Stanford(options) {
1413 var _this;
1414
1415 return Object(classCallCheck["a" /* default */])(this, Stanford), _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(Stanford).call(this, options)), _this.config = new Options_Options(), Object(possibleConstructorReturn["a" /* default */])(_this, Object(assertThisInitialized["a" /* default */])(_this));
1416 }
1417
1418 return Object(inherits["a" /* default */])(Stanford, _Plugin), Object(createClass["a" /* default */])(Stanford, [{
1419 key: "$beforeInit",
1420 value: function $beforeInit() {
1421 var _this2 = this,
1422 $$ = this.$$;
1423
1424 $$.config.data_xSort = !1, $$.isMultipleX = function () {
1425 return !0;
1426 }, $$.showGridFocus = function () {}, $$.labelishData = function (d) {
1427 return d.values;
1428 }, $$.opacityForCircle = function () {
1429 return 1;
1430 };
1431 var getCurrentPaddingRight = $$.getCurrentPaddingRight.bind($$);
1432
1433 $$.getCurrentPaddingRight = function () {
1434 return getCurrentPaddingRight() + (_this2.colorScale ? _this2.colorScale.getColorScalePadding() : 0);
1435 };
1436 }
1437 }, {
1438 key: "$init",
1439 value: function $init() {
1440 var $$ = this.$$;
1441 $$.loadConfig.bind(this)(this.options), $$.color = this.getStanfordPointColor.bind($$), this.colorScale = new ColorScale_ColorScale(this), this.elements = new Elements_Elements(this), this.convertData(), this.initStanfordData(), this.setStanfordTooltip(), this.colorScale.drawColorScale(), this.$redraw();
1442 }
1443 }, {
1444 key: "$redraw",
1445 value: function $redraw(duration) {
1446 this.colorScale && this.colorScale.drawColorScale(), this.elements && this.elements.updateStanfordElements(duration);
1447 }
1448 }, {
1449 key: "getOptions",
1450 value: function getOptions() {
1451 return new Options_Options();
1452 }
1453 }, {
1454 key: "convertData",
1455 value: function convertData() {
1456 var data = this.$$.data.targets,
1457 epochs = this.options.epochs;
1458 data.forEach(function (d) {
1459 d.values.forEach(function (v, i) {
1460 v.epochs = epochs[i];
1461 }), d.minEpochs = undefined, d.maxEpochs = undefined, d.colors = undefined, d.colorscale = undefined;
1462 });
1463 }
1464 }, {
1465 key: "xvCustom",
1466 value: function xvCustom(d, xyValue) {
1467 var $$ = this,
1468 value = xyValue ? d[xyValue] : $$.getBaseValue(d);
1469 return $$.isTimeSeries() ? value = $$.parseDate(value) : $$.isCategorized() && isString(value) && (value = $$.config.axis_x_categories.indexOf(d.value)), Math.ceil($$.x(value));
1470 }
1471 }, {
1472 key: "yvCustom",
1473 value: function yvCustom(d, xyValue) {
1474 var $$ = this,
1475 yScale = d.axis && d.axis === "y2" ? $$.y2 : $$.y,
1476 value = xyValue ? d[xyValue] : $$.getBaseValue(d);
1477 return Math.ceil(yScale(value));
1478 }
1479 }, {
1480 key: "initStanfordData",
1481 value: function initStanfordData() {
1482 var config = this.config,
1483 target = this.$$.data.targets[0];
1484 target.values.sort(compareEpochs);
1485 // Get array of epochs
1486 var epochs = target.values.map(function (a) {
1487 return a.epochs;
1488 });
1489 target.minEpochs = isNaN(config.scale_min) ? Object(external_commonjs_d3_array_commonjs2_d3_array_amd_d3_array_root_d3_["min"])(epochs) : config.scale_min, target.maxEpochs = isNaN(config.scale_max) ? Object(external_commonjs_d3_array_commonjs2_d3_array_amd_d3_array_root_d3_["max"])(epochs) : config.scale_max, target.colors = isFunction(config.colors) ? config.colors : Object(external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_["interpolateHslLong"])(Object(external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_["hsl"])(250, 1, .5), Object(external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_["hsl"])(0, 1, .5)), target.colorscale = Object(external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_["scaleSequentialLog"])(target.colors).domain([target.minEpochs, target.maxEpochs]);
1490 }
1491 }, {
1492 key: "getStanfordPointColor",
1493 value: function getStanfordPointColor(d) {
1494 var target = this.data.targets[0];
1495 return target.colorscale(d.epochs);
1496 }
1497 }, {
1498 key: "setStanfordTooltip",
1499 value: function setStanfordTooltip() {
1500 var config = this.$$.config;
1501 isEmpty(config.tooltip_contents) && (config.tooltip_contents = function (d, defaultTitleFormat, defaultValueFormat, color) {
1502 var _this3 = this,
1503 html = "<table class=\"".concat(classes.tooltip, "\"><tbody>");
1504
1505 return d.forEach(function (v) {
1506 html += "<tr>\n\t\t\t\t\t\t\t<th>".concat(defaultTitleFormat(_this3.config.data_x), "</th>\n\t\t\t\t\t\t\t<th class=\"value\">").concat(defaultValueFormat(v.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>").concat(defaultTitleFormat(v.id), "</th>\n\t\t\t\t\t\t\t<th class=\"value\">").concat(defaultValueFormat(v.value), "</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class=\"").concat(classes.tooltipName, "-").concat(v.id, "\">\n\t\t\t\t\t\t\t<td class=\"name\"><span style=\"background-color:").concat(color(v), "\"></span>").concat(defaultTitleFormat("Epochs"), "</td>\n\t\t\t\t\t\t\t<td class=\"value\">").concat(defaultValueFormat(v.epochs), "</td>\n\t\t\t\t\t\t</tr>");
1507 }), "".concat(html, "</tbody></table>");
1508 });
1509 }
1510 }, {
1511 key: "countEpochsInRegion",
1512 value: function countEpochsInRegion(region) {
1513 var $$ = this,
1514 target = $$.data.targets[0],
1515 total = target.values.reduce(function (accumulator, currentValue) {
1516 return accumulator + +currentValue.epochs;
1517 }, 0),
1518 value = target.values.reduce(function (accumulator, currentValue) {
1519 return pointInRegion(currentValue, region) ? accumulator + +currentValue.epochs : accumulator;
1520 }, 0);
1521 return {
1522 value: value,
1523 percentage: value === 0 ? 0 : +(value / total * 100).toFixed(1)
1524 };
1525 }
1526 }]), Stanford;
1527}(Plugin["a" /* default */]);
1528
1529
1530
1531/***/ }),
1532/* 20 */,
1533/* 21 */,
1534/* 22 */
1535/***/ (function(module, __webpack_exports__, __webpack_require__) {
1536
1537"use strict";
1538
1539// EXPORTS
1540__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _inherits; });
1541
1542// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
1543function _setPrototypeOf(o, p) {
1544 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
1545 o.__proto__ = p;
1546 return o;
1547 };
1548
1549 return _setPrototypeOf(o, p);
1550}
1551// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
1552
1553function _inherits(subClass, superClass) {
1554 if (typeof superClass !== "function" && superClass !== null) {
1555 throw new TypeError("Super expression must either be null or a function");
1556 }
1557
1558 subClass.prototype = Object.create(superClass && superClass.prototype, {
1559 constructor: {
1560 value: subClass,
1561 writable: true,
1562 configurable: true
1563 }
1564 });
1565 if (superClass) _setPrototypeOf(subClass, superClass);
1566}
1567
1568/***/ })
1569/******/ ])["default"];
1570});
\No newline at end of file