1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | (function webpackUniversalModuleDefinition(root, factory) {
|
13 | if(typeof exports === 'object' && typeof module === 'object')
|
14 | module.exports = factory(require("d3-selection"), require("d3-brush"));
|
15 | else if(typeof define === 'function' && define.amd)
|
16 | define("bb", ["d3-selection", "d3-brush"], factory);
|
17 | else if(typeof exports === 'object')
|
18 | exports["bb"] = factory(require("d3-selection"), require("d3-brush"));
|
19 | else
|
20 | root["bb"] = root["bb"] || {}, root["bb"]["plugin"] = root["bb"]["plugin"] || {}, root["bb"]["plugin"]["tableview"] = factory(root["d3"], root["d3"]);
|
21 | })(this, function(__WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__3__) {
|
22 | return (function() {
|
23 | "use strict";
|
24 | var __webpack_modules__ = ([
|
25 | ,
|
26 |
|
27 | (function(module) {
|
28 |
|
29 | module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
|
30 |
|
31 | }),
|
32 | ,
|
33 |
|
34 | (function(module) {
|
35 |
|
36 | module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
|
37 |
|
38 | })
|
39 | ]);
|
40 |
|
41 |
|
42 | var __webpack_module_cache__ = {};
|
43 |
|
44 |
|
45 | function __webpack_require__(moduleId) {
|
46 |
|
47 | var cachedModule = __webpack_module_cache__[moduleId];
|
48 | if (cachedModule !== undefined) {
|
49 | return cachedModule.exports;
|
50 | }
|
51 |
|
52 | var module = __webpack_module_cache__[moduleId] = {
|
53 |
|
54 |
|
55 | exports: {}
|
56 | };
|
57 |
|
58 |
|
59 | __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
60 |
|
61 |
|
62 | return module.exports;
|
63 | }
|
64 |
|
65 |
|
66 |
|
67 | !function() {
|
68 |
|
69 | __webpack_require__.d = function(exports, definition) {
|
70 | for(var key in definition) {
|
71 | if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
72 | Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
73 | }
|
74 | }
|
75 | };
|
76 | }();
|
77 |
|
78 |
|
79 | !function() {
|
80 | __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
81 | }();
|
82 |
|
83 |
|
84 | var __webpack_exports__ = {};
|
85 |
|
86 | !function() {
|
87 |
|
88 |
|
89 | __webpack_require__.d(__webpack_exports__, {
|
90 | "default": function() { return TableView; }
|
91 | });
|
92 |
|
93 | ;
|
94 | function _defineProperty(obj, key, value) {
|
95 | if (key in obj) {
|
96 | Object.defineProperty(obj, key, {
|
97 | value: value,
|
98 | enumerable: true,
|
99 | configurable: true,
|
100 | writable: true
|
101 | });
|
102 | } else {
|
103 | obj[key] = value;
|
104 | }
|
105 | return obj;
|
106 | }
|
107 | ;
|
108 | function _newArrowCheck(innerThis, boundThis) {
|
109 | if (innerThis !== boundThis) {
|
110 | throw new TypeError("Cannot instantiate an arrow function");
|
111 | }
|
112 | }
|
113 | ;
|
114 | function _assertThisInitialized(self) {
|
115 | if (self === void 0) {
|
116 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
117 | }
|
118 | return self;
|
119 | }
|
120 | ;
|
121 | function _setPrototypeOf(o, p) {
|
122 | _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
123 | o.__proto__ = p;
|
124 | return o;
|
125 | };
|
126 | return _setPrototypeOf(o, p);
|
127 | }
|
128 | ;
|
129 |
|
130 | function _inheritsLoose(subClass, superClass) {
|
131 | subClass.prototype = Object.create(superClass.prototype);
|
132 | subClass.prototype.constructor = subClass;
|
133 | _setPrototypeOf(subClass, superClass);
|
134 | }
|
135 | ;
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 | var Plugin = function () {
|
155 | |
156 |
|
157 |
|
158 |
|
159 |
|
160 | function Plugin(options) {
|
161 | if (options === void 0) {
|
162 | options = {};
|
163 | }
|
164 | this.$$ = void 0;
|
165 | this.options = void 0;
|
166 | this.options = options;
|
167 | }
|
168 |
|
169 | |
170 |
|
171 |
|
172 |
|
173 | var _proto = Plugin.prototype;
|
174 | _proto.$beforeInit = function $beforeInit() {}
|
175 |
|
176 | |
177 |
|
178 |
|
179 | ;
|
180 | _proto.$init = function $init() {}
|
181 |
|
182 | |
183 |
|
184 |
|
185 | ;
|
186 | _proto.$afterInit = function $afterInit() {}
|
187 |
|
188 | |
189 |
|
190 |
|
191 | ;
|
192 | _proto.$redraw = function $redraw() {}
|
193 |
|
194 | |
195 |
|
196 |
|
197 | ;
|
198 | _proto.$willDestroy = function $willDestroy() {
|
199 | var _this = this;
|
200 | Object.keys(this).forEach(function (key) {
|
201 | _newArrowCheck(this, _this);
|
202 | this[key] = null;
|
203 | delete this[key];
|
204 | }.bind(this));
|
205 | };
|
206 | return Plugin;
|
207 | }();
|
208 | Plugin.version = "3.6.3";
|
209 |
|
210 | ;
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 | var Options = function () {
|
224 | return {
|
225 | |
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 | selector: undefined,
|
236 | |
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 | categoryTitle: "Category",
|
246 | |
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 | categoryFormat: function categoryFormat(v) {
|
257 | var category = v;
|
258 | if (this.$$.axis.isCategorized()) {
|
259 | category = this.$$.categoryName(v);
|
260 | } else if (this.$$.axis.isTimeSeries()) {
|
261 | category = v.toLocaleDateString();
|
262 | }
|
263 | return category;
|
264 | },
|
265 | |
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 | class: undefined,
|
275 | |
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 | style: !0,
|
285 | |
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 | title: undefined,
|
296 | |
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 | updateOnToggle: !0
|
306 | };
|
307 | };
|
308 |
|
309 | ;
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 | var defaultStyle = {
|
320 | id: "__tableview-style__",
|
321 | class: "bb-tableview",
|
322 | rule: ".bb-tableview {\n\t\tborder-collapse:collapse;\n\t\tborder-spacing:0;\n\t\tbackground:#fff;\n\t\tmin-width:100%;\n\t\tmargin-top:10px;\n\t\tfont-family:sans-serif;\n\t\tfont-size:.9em;\n\t}\n\t.bb-tableview tr:hover {\n\t\tbackground:#eef7ff;\n\t}\n\t.bb-tableview thead tr {\n\t\tbackground:#f8f8f8;\n\t}\n\t.bb-tableview caption,.bb-tableview td,.bb-tableview th {\n\t\ttext-align: center;\n\t\tborder:1px solid silver;\n\t\tpadding:.5em;\n\t}\n\t.bb-tableview caption {\n\t\tfont-size:1.1em;\n\t\tfont-weight:700;\n\t\tmargin-bottom: -1px;\n\t}"
|
323 | },
|
324 | tpl = {
|
325 | body: "<caption>{=title}</caption>\n\t\t<thead><tr>{=thead}</tr></thead>\n\t\t<tbody>{=tbody}</tbody>",
|
326 | thead: "<th scope=\"col\">{=title}</th>",
|
327 | tbodyHeader: "<th scope=\"row\">{=value}</th>",
|
328 | tbody: "<td>{=value}</td>"
|
329 | };
|
330 |
|
331 | var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(1);
|
332 |
|
333 | var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(3);
|
334 | ;
|
335 |
|
336 | var _this = undefined;
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 | var win = function () {
|
348 | _newArrowCheck(this, _this);
|
349 | 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;
|
350 | return root || Function("return this")();
|
351 | }.bind(undefined)();
|
352 |
|
353 |
|
354 |
|
355 | win.requestIdleCallback = win.requestIdleCallback || function (cb) {
|
356 | _newArrowCheck(this, _this);
|
357 | return setTimeout(cb, 1);
|
358 | }.bind(undefined);
|
359 |
|
360 | win.requestAnimationFrame = win.requestAnimationFrame || function (cb) {
|
361 | _newArrowCheck(this, _this);
|
362 | return setTimeout(cb, 1);
|
363 | }.bind(undefined);
|
364 | var doc = win == null ? void 0 : win.document;
|
365 | ;
|
366 |
|
367 |
|
368 | var util_this = undefined;
|
369 | function 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; }
|
370 | function _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; }
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 | var isValue = function (v) {
|
381 | _newArrowCheck(this, util_this);
|
382 | return v || v === 0;
|
383 | }.bind(undefined),
|
384 | isFunction = function (v) {
|
385 | _newArrowCheck(this, util_this);
|
386 | return typeof v === "function";
|
387 | }.bind(undefined),
|
388 | isString = function (v) {
|
389 | _newArrowCheck(this, util_this);
|
390 | return typeof v === "string";
|
391 | }.bind(undefined),
|
392 | isNumber = function (v) {
|
393 | _newArrowCheck(this, util_this);
|
394 | return typeof v === "number";
|
395 | }.bind(undefined),
|
396 | isUndefined = function (v) {
|
397 | _newArrowCheck(this, util_this);
|
398 | return typeof v === "undefined";
|
399 | }.bind(undefined),
|
400 | isDefined = function (v) {
|
401 | _newArrowCheck(this, util_this);
|
402 | return typeof v !== "undefined";
|
403 | }.bind(undefined),
|
404 | isboolean = function (v) {
|
405 | _newArrowCheck(this, util_this);
|
406 | return typeof v === "boolean";
|
407 | }.bind(undefined),
|
408 | ceil10 = function (v) {
|
409 | _newArrowCheck(this, util_this);
|
410 | return Math.ceil(v / 10) * 10;
|
411 | }.bind(undefined),
|
412 | asHalfPixel = function (n) {
|
413 | _newArrowCheck(this, util_this);
|
414 | return Math.ceil(n) + .5;
|
415 | }.bind(undefined),
|
416 | diffDomain = function (d) {
|
417 | _newArrowCheck(this, util_this);
|
418 | return d[1] - d[0];
|
419 | }.bind(undefined),
|
420 | isObjectType = function (v) {
|
421 | _newArrowCheck(this, util_this);
|
422 | return typeof v === "object";
|
423 | }.bind(undefined),
|
424 | isEmpty = function (o) {
|
425 | _newArrowCheck(this, util_this);
|
426 | return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
|
427 | }.bind(undefined),
|
428 | notEmpty = function (o) {
|
429 | _newArrowCheck(this, util_this);
|
430 | return !isEmpty(o);
|
431 | }.bind(undefined),
|
432 | isArray = function (arr) {
|
433 | _newArrowCheck(this, util_this);
|
434 | return Array.isArray(arr);
|
435 | }.bind(undefined),
|
436 | isObject = function (obj) {
|
437 | _newArrowCheck(this, util_this);
|
438 | return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
|
439 | }.bind(undefined);
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 | function getOption(options, key, defaultValue) {
|
450 | return isDefined(options[key]) ? options[key] : defaultValue;
|
451 | }
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 | function hasValue(dict, value) {
|
461 | var _this2 = this,
|
462 | found = !1;
|
463 | Object.keys(dict).forEach(function (key) {
|
464 | _newArrowCheck(this, _this2);
|
465 | return dict[key] === value && (found = !0);
|
466 | }.bind(this));
|
467 | return found;
|
468 | }
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 | function callFn(fn, thisArg) {
|
479 | for (var isFn = isFunction(fn), _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
480 | args[_key - 2] = arguments[_key];
|
481 | }
|
482 | isFn && fn.call.apply(fn, [thisArg].concat(args));
|
483 | return isFn;
|
484 | }
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 | function endall(transition, cb) {
|
493 | var _this3 = this,
|
494 | n = 0,
|
495 | end = function () {
|
496 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
497 | args[_key2] = arguments[_key2];
|
498 | }
|
499 | --n || cb.apply.apply(cb, [this].concat(args));
|
500 | };
|
501 |
|
502 | if ("duration" in transition) {
|
503 | transition.each(function () {
|
504 | _newArrowCheck(this, _this3);
|
505 | return ++n;
|
506 | }.bind(this)).on("end", end);
|
507 | } else {
|
508 | ++n;
|
509 | transition.call(end);
|
510 | }
|
511 | }
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 | function sanitise(str) {
|
520 | return isString(str) ? str.replace(/</g, "<").replace(/>/g, ">") : str;
|
521 | }
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 | function setTextValue(node, text, dy, toMiddle) {
|
532 | var _this4 = this;
|
533 | if (dy === void 0) {
|
534 | dy = [-1, 1];
|
535 | }
|
536 | if (toMiddle === void 0) {
|
537 | toMiddle = !1;
|
538 | }
|
539 | if (!node || !isString(text)) {
|
540 | return;
|
541 | }
|
542 | if (text.indexOf("\n") === -1) {
|
543 | node.text(text);
|
544 | } else {
|
545 | var diff = [node.text(), text].map(function (v) {
|
546 | _newArrowCheck(this, _this4);
|
547 | return v.replace(/[\s\n]/g, "");
|
548 | }.bind(this));
|
549 | if (diff[0] !== diff[1]) {
|
550 | var multiline = text.split("\n"),
|
551 | len = toMiddle ? multiline.length - 1 : 1;
|
552 |
|
553 | node.html("");
|
554 | multiline.forEach(function (v, i) {
|
555 | _newArrowCheck(this, _this4);
|
556 | node.append("tspan").attr("x", 0).attr("dy", (i === 0 ? dy[0] * len : dy[1]) + "em").text(v);
|
557 | }.bind(this));
|
558 | }
|
559 | }
|
560 | }
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 | function getRectSegList(path) {
|
569 | |
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 | var _path$getBBox = path.getBBox(),
|
577 | x = _path$getBBox.x,
|
578 | y = _path$getBBox.y,
|
579 | width = _path$getBBox.width,
|
580 | height = _path$getBBox.height;
|
581 | return [{
|
582 | x: x,
|
583 | y: y + height
|
584 | },
|
585 |
|
586 | {
|
587 | x: x,
|
588 | y: y
|
589 | },
|
590 |
|
591 | {
|
592 | x: x + width,
|
593 | y: y
|
594 | },
|
595 |
|
596 | {
|
597 | x: x + width,
|
598 | y: y + height
|
599 | }
|
600 | ];
|
601 | }
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 | function getPathBox(path) {
|
610 | var _path$getBoundingClie = path.getBoundingClientRect(),
|
611 | width = _path$getBoundingClie.width,
|
612 | height = _path$getBoundingClie.height,
|
613 | items = getRectSegList(path),
|
614 | x = items[0].x,
|
615 | y = Math.min(items[0].y, items[1].y);
|
616 | return {
|
617 | x: x,
|
618 | y: y,
|
619 | width: width,
|
620 | height: height
|
621 | };
|
622 | }
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 | function getPointer(event, element) {
|
632 | var _ref,
|
633 | touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]),
|
634 | pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element),
|
635 | _this5 = this;
|
636 | return pointer.map(function (v) {
|
637 | _newArrowCheck(this, _this5);
|
638 | return isNaN(v) ? 0 : v;
|
639 | }.bind(this));
|
640 | }
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 | function getBrushSelection(ctx) {
|
649 | var event = ctx.event,
|
650 | $el = ctx.$el,
|
651 | main = $el.subchart.main || $el.main,
|
652 | selection;
|
653 |
|
654 | if (event && event.type === "brush") {
|
655 | selection = event.selection;
|
656 |
|
657 | } else if (main && (selection = main.select(".bb-brush").node())) {
|
658 | selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection);
|
659 | }
|
660 | return selection;
|
661 | }
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 | function getBoundingRect(node) {
|
671 | var needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
|
672 | return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
|
673 | }
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 | function getRandom(asStr, min, max) {
|
684 | if (asStr === void 0) {
|
685 | asStr = !0;
|
686 | }
|
687 | if (min === void 0) {
|
688 | min = 0;
|
689 | }
|
690 | if (max === void 0) {
|
691 | max = 1e4;
|
692 | }
|
693 | var rand = Math.floor(Math.random() * (max - min) + min);
|
694 | return asStr ? rand + "" : rand;
|
695 | }
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 | function findIndex(arr, v, start, end, isRotated) {
|
708 | if (start > end) {
|
709 | return -1;
|
710 | }
|
711 | var mid = Math.floor((start + end) / 2),
|
712 | _arr$mid = arr[mid],
|
713 | x = _arr$mid.x,
|
714 | _arr$mid$w = _arr$mid.w,
|
715 | w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
|
716 | if (isRotated) {
|
717 | x = arr[mid].y;
|
718 | w = arr[mid].h;
|
719 | }
|
720 | if (v >= x && v <= x + w) {
|
721 | return mid;
|
722 | }
|
723 | return v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
|
724 | }
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 | function brushEmpty(ctx) {
|
733 | var selection = getBrushSelection(ctx);
|
734 | if (selection) {
|
735 |
|
736 |
|
737 |
|
738 | return selection[0] === selection[1];
|
739 | }
|
740 | return !0;
|
741 | }
|
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 | function deepClone() {
|
750 | for (var _this6 = this, clone = function (v) {
|
751 | _newArrowCheck(this, _this6);
|
752 | if (isObject(v) && v.constructor) {
|
753 | var r = new v.constructor();
|
754 | for (var k in v) {
|
755 | r[k] = clone(v[k]);
|
756 | }
|
757 | return r;
|
758 | }
|
759 | return v;
|
760 | }.bind(this), _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
761 | objectN[_key3] = arguments[_key3];
|
762 | }
|
763 | return objectN.map(function (v) {
|
764 | _newArrowCheck(this, _this6);
|
765 | return clone(v);
|
766 | }.bind(this)).reduce(function (a, c) {
|
767 | _newArrowCheck(this, _this6);
|
768 | return _objectSpread(_objectSpread({}, a), c);
|
769 | }.bind(this));
|
770 | }
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 | function extend(target, source) {
|
780 | var _this7 = this;
|
781 | if (target === void 0) {
|
782 | target = {};
|
783 | }
|
784 | if (isArray(source)) {
|
785 | source.forEach(function (v) {
|
786 | _newArrowCheck(this, _this7);
|
787 | return extend(target, v);
|
788 | }.bind(this));
|
789 | }
|
790 |
|
791 |
|
792 | for (var p in source) {
|
793 | if (/^\d+$/.test(p) || p in target) {
|
794 | continue;
|
795 | }
|
796 | target[p] = source[p];
|
797 | }
|
798 | return target;
|
799 | }
|
800 |
|
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 |
|
807 | var capitalize = function (str) {
|
808 | _newArrowCheck(this, util_this);
|
809 | return str.charAt(0).toUpperCase() + str.slice(1);
|
810 | }.bind(undefined);
|
811 |
|
812 |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 |
|
818 |
|
819 | function camelize(str, separator) {
|
820 | var _this8 = this;
|
821 | if (separator === void 0) {
|
822 | separator = "-";
|
823 | }
|
824 | return str.split(separator).map(function (v, i) {
|
825 | _newArrowCheck(this, _this8);
|
826 | return i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase();
|
827 | }.bind(this)).join("");
|
828 | }
|
829 |
|
830 |
|
831 |
|
832 |
|
833 |
|
834 |
|
835 |
|
836 | var toArray = function (v) {
|
837 | _newArrowCheck(this, util_this);
|
838 | return [].slice.call(v);
|
839 | }.bind(undefined);
|
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 | function addCssRules(style, selector, prop) {
|
850 | var _this9 = this,
|
851 | rootSelctor = style.rootSelctor,
|
852 | sheet = style.sheet,
|
853 | getSelector = function (s) {
|
854 | _newArrowCheck(this, _this9);
|
855 | return s.replace(/\s?(bb-)/g, ".$1").replace(/\.+/g, ".");
|
856 | }.bind(this),
|
857 | rule = rootSelctor + " " + getSelector(selector) + " {" + prop.join(";") + "}";
|
858 | return sheet[sheet.insertRule ? "insertRule" : "addRule"](rule, sheet.cssRules.length);
|
859 | }
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 | function getCssRules(styleSheets) {
|
868 | var _this10 = this,
|
869 | rules = [];
|
870 | styleSheets.forEach(function (sheet) {
|
871 | _newArrowCheck(this, _this10);
|
872 | try {
|
873 | if (sheet.cssRules && sheet.cssRules.length) {
|
874 | rules = rules.concat(toArray(sheet.cssRules));
|
875 | }
|
876 | } catch (e) {
|
877 | console.error("Error while reading rules from " + sheet.href + ": " + e.toString());
|
878 | }
|
879 | }.bind(this));
|
880 | return rules;
|
881 | }
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 |
|
888 |
|
889 | function getTranslation(node) {
|
890 | var transform = node ? node.transform : null,
|
891 | baseVal = transform && transform.baseVal;
|
892 | return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
|
893 | a: 0,
|
894 | b: 0,
|
895 | c: 0,
|
896 | d: 0,
|
897 | e: 0,
|
898 | f: 0
|
899 | };
|
900 | }
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 | function getUnique(data) {
|
909 | var _this11 = this,
|
910 | isDate = data[0] instanceof Date,
|
911 | d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
|
912 | _newArrowCheck(this, _this11);
|
913 | return self.indexOf(v) === i;
|
914 | }.bind(this));
|
915 | return isDate ? d.map(function (v) {
|
916 | _newArrowCheck(this, _this11);
|
917 | return new Date(v);
|
918 | }.bind(this)) : d;
|
919 | }
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 | function mergeArray(arr) {
|
928 | var _this12 = this;
|
929 | return arr && arr.length ? arr.reduce(function (p, c) {
|
930 | _newArrowCheck(this, _this12);
|
931 | return p.concat(c);
|
932 | }.bind(this)) : [];
|
933 | }
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 | function mergeObj(target) {
|
943 | for (var _this13 = this, _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
944 | objectN[_key4 - 1] = arguments[_key4];
|
945 | }
|
946 | if (!objectN.length || objectN.length === 1 && !objectN[0]) {
|
947 | return target;
|
948 | }
|
949 | var source = objectN.shift();
|
950 | if (isObject(target) && isObject(source)) {
|
951 | Object.keys(source).forEach(function (key) {
|
952 | _newArrowCheck(this, _this13);
|
953 | var value = source[key];
|
954 | if (isObject(value)) {
|
955 | target[key] || (target[key] = {});
|
956 | target[key] = mergeObj(target[key], value);
|
957 | } else {
|
958 | target[key] = isArray(value) ? value.concat() : value;
|
959 | }
|
960 | }.bind(this));
|
961 | }
|
962 | return mergeObj.apply(void 0, [target].concat(objectN));
|
963 | }
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 | function sortValue(data, isAsc) {
|
973 | var _this14 = this;
|
974 | if (isAsc === void 0) {
|
975 | isAsc = !0;
|
976 | }
|
977 | var fn;
|
978 | if (data[0] instanceof Date) {
|
979 | fn = isAsc ? function (a, b) {
|
980 | _newArrowCheck(this, _this14);
|
981 | return a - b;
|
982 | }.bind(this) : function (a, b) {
|
983 | _newArrowCheck(this, _this14);
|
984 | return b - a;
|
985 | }.bind(this);
|
986 | } else {
|
987 | if (isAsc && !data.every(isNaN)) {
|
988 | fn = function (a, b) {
|
989 | _newArrowCheck(this, _this14);
|
990 | return a - b;
|
991 | }.bind(this);
|
992 | } else if (!isAsc) {
|
993 | fn = function (a, b) {
|
994 | _newArrowCheck(this, _this14);
|
995 | return a > b && -1 || a < b && 1 || a === b && 0;
|
996 | }.bind(this);
|
997 | }
|
998 | }
|
999 | return data.concat().sort(fn);
|
1000 | }
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 | function getMinMax(type, data) {
|
1010 | var _this15 = this,
|
1011 | res = data.filter(function (v) {
|
1012 | _newArrowCheck(this, _this15);
|
1013 | return notEmpty(v);
|
1014 | }.bind(this));
|
1015 | if (res.length) {
|
1016 | if (isNumber(res[0])) {
|
1017 | res = Math[type].apply(Math, res);
|
1018 | } else if (res[0] instanceof Date) {
|
1019 | res = sortValue(res, type === "min")[0];
|
1020 | }
|
1021 | } else {
|
1022 | res = undefined;
|
1023 | }
|
1024 | return res;
|
1025 | }
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 | var getRange = function (start, end, step) {
|
1036 | if (step === void 0) {
|
1037 | step = 1;
|
1038 | }
|
1039 | _newArrowCheck(this, util_this);
|
1040 | var res = [],
|
1041 | n = Math.max(0, Math.ceil((end - start) / step)) | 0;
|
1042 | for (var i = start; i < n; i++) {
|
1043 | res.push(start + i * step);
|
1044 | }
|
1045 | return res;
|
1046 | }.bind(undefined),
|
1047 | emulateEvent = {
|
1048 | mouse: function () {
|
1049 | var _this16 = this;
|
1050 | _newArrowCheck(this, util_this);
|
1051 | var getParams = function () {
|
1052 | _newArrowCheck(this, _this16);
|
1053 | return {
|
1054 | bubbles: !1,
|
1055 | cancelable: !1,
|
1056 | screenX: 0,
|
1057 | screenY: 0,
|
1058 | clientX: 0,
|
1059 | clientY: 0
|
1060 | };
|
1061 | }.bind(this);
|
1062 | try {
|
1063 |
|
1064 | new MouseEvent("t");
|
1065 | return function (el, eventType, params) {
|
1066 | if (params === void 0) {
|
1067 | params = getParams();
|
1068 | }
|
1069 | _newArrowCheck(this, _this16);
|
1070 | el.dispatchEvent(new MouseEvent(eventType, params));
|
1071 | }.bind(this);
|
1072 | } catch (e) {
|
1073 |
|
1074 | return function (el, eventType, params) {
|
1075 | if (params === void 0) {
|
1076 | params = getParams();
|
1077 | }
|
1078 | _newArrowCheck(this, _this16);
|
1079 | var mouseEvent = doc.createEvent("MouseEvent");
|
1080 |
|
1081 |
|
1082 | mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0,
|
1083 |
|
1084 | params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null);
|
1085 | el.dispatchEvent(mouseEvent);
|
1086 | }.bind(this);
|
1087 | }
|
1088 | }.bind(undefined)(),
|
1089 | touch: function touch(el, eventType, params) {
|
1090 | _newArrowCheck(this, util_this);
|
1091 | var touchObj = new Touch(mergeObj({
|
1092 | identifier: Date.now(),
|
1093 | target: el,
|
1094 | radiusX: 2.5,
|
1095 | radiusY: 2.5,
|
1096 | rotationAngle: 10,
|
1097 | force: .5
|
1098 | }, params));
|
1099 | el.dispatchEvent(new TouchEvent(eventType, {
|
1100 | cancelable: !0,
|
1101 | bubbles: !0,
|
1102 | shiftKey: !0,
|
1103 | touches: [touchObj],
|
1104 | targetTouches: [],
|
1105 | changedTouches: [touchObj]
|
1106 | }));
|
1107 | }.bind(undefined)
|
1108 | };
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 | function tplProcess(tpl, data) {
|
1117 | var res = tpl;
|
1118 | for (var x in data) {
|
1119 | res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
|
1120 | }
|
1121 | return res;
|
1122 | }
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 | function parseDate(date) {
|
1132 | var parsedDate;
|
1133 | if (date instanceof Date) {
|
1134 | parsedDate = date;
|
1135 | } else if (isString(date)) {
|
1136 | var _format$dataTime,
|
1137 | config = this.config,
|
1138 | format = this.format;
|
1139 |
|
1140 |
|
1141 | parsedDate = (_format$dataTime = format.dataTime(config.data_xFormat)(date)) != null ? _format$dataTime : new Date(date);
|
1142 | } else if (isNumber(date) && !isNaN(date)) {
|
1143 | parsedDate = new Date(+date);
|
1144 | }
|
1145 | if (!parsedDate || isNaN(+parsedDate)) {
|
1146 | console && console.error && console.error("Failed to parse x '" + date + "' to Date object");
|
1147 | }
|
1148 | return parsedDate;
|
1149 | }
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 | function isTabVisible() {
|
1157 | return (doc == null ? void 0 : doc.hidden) === !1 || (doc == null ? void 0 : doc.visibilityState) === "visible";
|
1158 | }
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 | function convertInputType(mouse, touch) {
|
1168 | var _this17 = this,
|
1169 | DocumentTouch = win.DocumentTouch,
|
1170 | matchMedia = win.matchMedia,
|
1171 | navigator = win.navigator,
|
1172 | hasTouch = !1;
|
1173 | if (touch) {
|
1174 |
|
1175 | if (navigator && "maxTouchPoints" in navigator) {
|
1176 | hasTouch = navigator.maxTouchPoints > 0;
|
1177 |
|
1178 |
|
1179 |
|
1180 | } else if ("ontouchmove" in win || DocumentTouch && doc instanceof DocumentTouch) {
|
1181 | hasTouch = !0;
|
1182 | } else {
|
1183 |
|
1184 | if (matchMedia != null && matchMedia("(pointer:coarse)").matches) {
|
1185 | hasTouch = !0;
|
1186 | } else {
|
1187 |
|
1188 | var UA = navigator.userAgent;
|
1189 | hasTouch = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
|
1190 | }
|
1191 | }
|
1192 | }
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 | var hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some(function (v) {
|
1198 | _newArrowCheck(this, _this17);
|
1199 | return matchMedia == null ? void 0 : matchMedia("(" + v + ")").matches;
|
1200 | }.bind(this));
|
1201 |
|
1202 |
|
1203 | return hasMouse && "mouse" || hasTouch && "touch" || "mouse";
|
1204 | }
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 | function runUntil(fn, conditionFn) {
|
1213 | var _this18 = this;
|
1214 | if (conditionFn() === !1) {
|
1215 | win.requestAnimationFrame(function () {
|
1216 | _newArrowCheck(this, _this18);
|
1217 | return runUntil(fn, conditionFn);
|
1218 | }.bind(this));
|
1219 | } else {
|
1220 | fn();
|
1221 | }
|
1222 | }
|
1223 | ;
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 | function loadConfig(config) {
|
1236 | var _this = this,
|
1237 | thisConfig = this.config,
|
1238 | target,
|
1239 | keys,
|
1240 | read,
|
1241 | find = function () {
|
1242 | _newArrowCheck(this, _this);
|
1243 | var key = keys.shift();
|
1244 | if (key && target && isObjectType(target) && key in target) {
|
1245 | target = target[key];
|
1246 | return find();
|
1247 | } else if (!key) {
|
1248 | return target;
|
1249 | }
|
1250 | return undefined;
|
1251 | }.bind(this);
|
1252 | Object.keys(thisConfig).forEach(function (key) {
|
1253 | _newArrowCheck(this, _this);
|
1254 | target = config;
|
1255 | keys = key.split("_");
|
1256 | read = find();
|
1257 | if (isDefined(read)) {
|
1258 | thisConfig[key] = read;
|
1259 | }
|
1260 | }.bind(this));
|
1261 |
|
1262 |
|
1263 | if (this.api) {
|
1264 | this.state.orgConfig = config;
|
1265 | }
|
1266 | }
|
1267 | ;
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 | function tableview_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; }
|
1273 | function tableview_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = null != arguments[i] ? arguments[i] : {}; i % 2 ? tableview_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : tableview_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 |
|
1293 |
|
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 | var TableView = function (_Plugin) {
|
1328 | _inheritsLoose(TableView, _Plugin);
|
1329 | function TableView(options) {
|
1330 | var _this = _Plugin.call(this, options) || this;
|
1331 | _this.config = void 0;
|
1332 | _this.element = void 0;
|
1333 | _this.config = new Options();
|
1334 | return _assertThisInitialized(_this) || _assertThisInitialized(_this);
|
1335 | }
|
1336 | var _proto = TableView.prototype;
|
1337 | _proto.$beforeInit = function $beforeInit() {
|
1338 | loadConfig.call(this, this.options);
|
1339 | };
|
1340 | _proto.$init = function $init() {
|
1341 | var _element$classList,
|
1342 | _this$config = this.config,
|
1343 | className = _this$config.class,
|
1344 | selector = _this$config.selector,
|
1345 | style = _this$config.style,
|
1346 | element = document.querySelector(selector || "." + (className || defaultStyle["class"]));
|
1347 | if (!element) {
|
1348 | var chart = this.$$.$el.chart.node();
|
1349 | element = document.createElement("table");
|
1350 | chart.parentNode.insertBefore(element, chart.nextSibling);
|
1351 | }
|
1352 | if (element.tagName !== "TABLE") {
|
1353 | var table = document.createElement("table");
|
1354 | element.appendChild(table);
|
1355 | element = table;
|
1356 | }
|
1357 |
|
1358 |
|
1359 | if (style && !document.getElementById(defaultStyle.id)) {
|
1360 | var s = document.createElement("style");
|
1361 | s.id = defaultStyle.id;
|
1362 | s.innerHTML = defaultStyle.rule;
|
1363 | (document.head || document.getElementsByTagName("head")[0]).appendChild(s);
|
1364 | }
|
1365 | (_element$classList = element.classList).add.apply(_element$classList, [style && defaultStyle["class"], className].filter(Boolean));
|
1366 | this.element = element;
|
1367 | }
|
1368 |
|
1369 | |
1370 |
|
1371 |
|
1372 | ;
|
1373 | _proto.generateTable = function generateTable() {
|
1374 | var _this2 = this,
|
1375 | $$ = this.$$,
|
1376 | config = this.config,
|
1377 | element = this.element,
|
1378 | dataToShow = $$.filterTargetsToShow($$.data.targets),
|
1379 | thead = tplProcess(tpl.thead, {
|
1380 | title: dataToShow.length ? this.config.categoryTitle : ""
|
1381 | }),
|
1382 | tbody = "",
|
1383 | rows = [];
|
1384 | dataToShow.forEach(function (v) {
|
1385 | var _this3 = this;
|
1386 | _newArrowCheck(this, _this2);
|
1387 | thead += tplProcess(tpl.thead, {
|
1388 | title: v.id
|
1389 | });
|
1390 |
|
1391 |
|
1392 | v.values.forEach(function (d, i) {
|
1393 | _newArrowCheck(this, _this3);
|
1394 | if (!rows[i]) {
|
1395 | rows[i] = [d.x];
|
1396 | }
|
1397 | rows[i].push(d.value);
|
1398 | }.bind(this));
|
1399 | }.bind(this));
|
1400 | rows.forEach(function (v) {
|
1401 | var _this4 = this;
|
1402 | _newArrowCheck(this, _this2);
|
1403 | tbody += "<tr>" + v.map(function (d, i) {
|
1404 | _newArrowCheck(this, _this4);
|
1405 | return tplProcess(i ? tpl.tbody : tpl.tbodyHeader, {
|
1406 | value: i === 0 ? config.categoryFormat.bind(this)(d) : isNumber(d) ? d.toLocaleString() : ""
|
1407 | });
|
1408 | }.bind(this)).join("") + "</tr>";
|
1409 | }.bind(this));
|
1410 | var r = tplProcess(tpl.body, tableview_objectSpread(tableview_objectSpread({}, config), {}, {
|
1411 | title: config.title || $$.config.title_text || "",
|
1412 | thead: thead,
|
1413 | tbody: tbody
|
1414 | })).replace(/<[^>]+><\/[^>]+>/g, "");
|
1415 | element.innerHTML = r;
|
1416 | };
|
1417 | _proto.$redraw = function $redraw() {
|
1418 | var state = this.$$.state,
|
1419 | doNotUpdate = state.resizing || !this.config.updateOnToggle && state.toggling;
|
1420 | doNotUpdate || this.generateTable();
|
1421 | };
|
1422 | _proto.$willDestroy = function $willDestroy() {
|
1423 | this.element.parentNode.removeChild(this.element);
|
1424 |
|
1425 |
|
1426 | if (this.$$.charts.length === 1) {
|
1427 | var _s$parentNode,
|
1428 | s = document.getElementById(defaultStyle.id);
|
1429 | s == null ? void 0 : (_s$parentNode = s.parentNode) == null ? void 0 : _s$parentNode.removeChild(s);
|
1430 | }
|
1431 | };
|
1432 | return TableView;
|
1433 | }(Plugin);
|
1434 |
|
1435 | }();
|
1436 | __webpack_exports__ = __webpack_exports__["default"];
|
1437 | return __webpack_exports__;
|
1438 | })()
|
1439 | ;
|
1440 | }); |
\ | No newline at end of file |