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-interpolate"), require("d3-color"), require("d3-scale"), require("d3-selection"), require("d3-brush"), require("d3-axis"), require("d3-format"));
|
15 | else if(typeof define === 'function' && define.amd)
|
16 | define("bb", ["d3-interpolate", "d3-color", "d3-scale", "d3-selection", "d3-brush", "d3-axis", "d3-format"], factory);
|
17 | else if(typeof exports === 'object')
|
18 | exports["bb"] = factory(require("d3-interpolate"), require("d3-color"), require("d3-scale"), require("d3-selection"), require("d3-brush"), require("d3-axis"), require("d3-format"));
|
19 | else
|
20 | root["bb"] = root["bb"] || {}, root["bb"]["plugin"] = root["bb"]["plugin"] || {}, root["bb"]["plugin"]["stanford"] = factory(root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"]);
|
21 | })(this, function(__WEBPACK_EXTERNAL_MODULE__5__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__8__, __WEBPACK_EXTERNAL_MODULE__9__) {
|
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 | (function(module) {
|
42 |
|
43 | module.exports = __WEBPACK_EXTERNAL_MODULE__5__;
|
44 |
|
45 | }),
|
46 |
|
47 | (function(module) {
|
48 |
|
49 | module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
|
50 |
|
51 | }),
|
52 |
|
53 | (function(module) {
|
54 |
|
55 | module.exports = __WEBPACK_EXTERNAL_MODULE__7__;
|
56 |
|
57 | }),
|
58 |
|
59 | (function(module) {
|
60 |
|
61 | module.exports = __WEBPACK_EXTERNAL_MODULE__8__;
|
62 |
|
63 | }),
|
64 |
|
65 | (function(module) {
|
66 |
|
67 | module.exports = __WEBPACK_EXTERNAL_MODULE__9__;
|
68 |
|
69 | })
|
70 | ]);
|
71 |
|
72 |
|
73 | var __webpack_module_cache__ = {};
|
74 |
|
75 |
|
76 | function __webpack_require__(moduleId) {
|
77 |
|
78 | var cachedModule = __webpack_module_cache__[moduleId];
|
79 | if (cachedModule !== undefined) {
|
80 | return cachedModule.exports;
|
81 | }
|
82 |
|
83 | var module = __webpack_module_cache__[moduleId] = {
|
84 |
|
85 |
|
86 | exports: {}
|
87 | };
|
88 |
|
89 |
|
90 | __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
91 |
|
92 |
|
93 | return module.exports;
|
94 | }
|
95 |
|
96 |
|
97 |
|
98 | !function() {
|
99 |
|
100 | __webpack_require__.d = function(exports, definition) {
|
101 | for(var key in definition) {
|
102 | if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
103 | Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
104 | }
|
105 | }
|
106 | };
|
107 | }();
|
108 |
|
109 |
|
110 | !function() {
|
111 | __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
112 | }();
|
113 |
|
114 |
|
115 | var __webpack_exports__ = {};
|
116 |
|
117 | !function() {
|
118 |
|
119 |
|
120 | __webpack_require__.d(__webpack_exports__, {
|
121 | "default": function() { return Stanford; }
|
122 | });
|
123 |
|
124 | ;
|
125 | function _assertThisInitialized(self) {
|
126 | if (self === void 0) {
|
127 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
128 | }
|
129 |
|
130 | return self;
|
131 | }
|
132 | ;
|
133 | function _setPrototypeOf(o, p) {
|
134 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
135 | o.__proto__ = p;
|
136 | return o;
|
137 | };
|
138 |
|
139 | return _setPrototypeOf(o, p);
|
140 | }
|
141 | ;
|
142 |
|
143 | function _inheritsLoose(subClass, superClass) {
|
144 | subClass.prototype = Object.create(superClass.prototype);
|
145 | subClass.prototype.constructor = subClass;
|
146 | _setPrototypeOf(subClass, superClass);
|
147 | }
|
148 |
|
149 | var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(5);
|
150 |
|
151 | var external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_ = __webpack_require__(6);
|
152 |
|
153 | var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webpack_require__(7);
|
154 | ;
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 | var classes = ({
|
165 | arc: "bb-arc",
|
166 | arcLabelLine: "bb-arc-label-line",
|
167 | arcs: "bb-arcs",
|
168 | area: "bb-area",
|
169 | areas: "bb-areas",
|
170 | axis: "bb-axis",
|
171 | axisX: "bb-axis-x",
|
172 | axisXLabel: "bb-axis-x-label",
|
173 | axisY: "bb-axis-y",
|
174 | axisY2: "bb-axis-y2",
|
175 | axisY2Label: "bb-axis-y2-label",
|
176 | axisYLabel: "bb-axis-y-label",
|
177 | bar: "bb-bar",
|
178 | bars: "bb-bars",
|
179 | brush: "bb-brush",
|
180 | button: "bb-button",
|
181 | buttonZoomReset: "bb-zoom-reset",
|
182 | candlestick: "bb-candlestick",
|
183 | candlesticks: "bb-candlesticks",
|
184 | chart: "bb-chart",
|
185 | chartArc: "bb-chart-arc",
|
186 | chartArcs: "bb-chart-arcs",
|
187 | chartArcsBackground: "bb-chart-arcs-background",
|
188 | chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
|
189 | chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
|
190 | chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
|
191 | chartArcsTitle: "bb-chart-arcs-title",
|
192 | chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
|
193 | chartBar: "bb-chart-bar",
|
194 | chartBars: "bb-chart-bars",
|
195 | chartCandlestick: "bb-chart-candlestick",
|
196 | chartCandlesticks: "bb-chart-candlesticks",
|
197 | chartCircles: "bb-chart-circles",
|
198 | chartLine: "bb-chart-line",
|
199 | chartLines: "bb-chart-lines",
|
200 | chartRadar: "bb-chart-radar",
|
201 | chartRadars: "bb-chart-radars",
|
202 | chartText: "bb-chart-text",
|
203 | chartTexts: "bb-chart-texts",
|
204 | circle: "bb-circle",
|
205 | circles: "bb-circles",
|
206 | colorPattern: "bb-color-pattern",
|
207 | colorScale: "bb-colorscale",
|
208 | defocused: "bb-defocused",
|
209 | dragarea: "bb-dragarea",
|
210 | empty: "bb-empty",
|
211 | eventRect: "bb-event-rect",
|
212 | eventRects: "bb-event-rects",
|
213 | eventRectsMultiple: "bb-event-rects-multiple",
|
214 | eventRectsSingle: "bb-event-rects-single",
|
215 | focused: "bb-focused",
|
216 | gaugeValue: "bb-gauge-value",
|
217 | grid: "bb-grid",
|
218 | gridLines: "bb-grid-lines",
|
219 | legend: "bb-legend",
|
220 | legendBackground: "bb-legend-background",
|
221 | legendItem: "bb-legend-item",
|
222 | legendItemEvent: "bb-legend-item-event",
|
223 | legendItemFocused: "bb-legend-item-focused",
|
224 | legendItemHidden: "bb-legend-item-hidden",
|
225 | legendItemPoint: "bb-legend-item-point",
|
226 | legendItemTile: "bb-legend-item-tile",
|
227 | level: "bb-level",
|
228 | levels: "bb-levels",
|
229 | line: "bb-line",
|
230 | lines: "bb-lines",
|
231 | main: "bb-main",
|
232 | region: "bb-region",
|
233 | regions: "bb-regions",
|
234 | selectedCircle: "bb-selected-circle",
|
235 | selectedCircles: "bb-selected-circles",
|
236 | shape: "bb-shape",
|
237 | shapes: "bb-shapes",
|
238 | stanfordElements: "bb-stanford-elements",
|
239 | stanfordLine: "bb-stanford-line",
|
240 | stanfordLines: "bb-stanford-lines",
|
241 | stanfordRegion: "bb-stanford-region",
|
242 | stanfordRegions: "bb-stanford-regions",
|
243 | subchart: "bb-subchart",
|
244 | target: "bb-target",
|
245 | text: "bb-text",
|
246 | texts: "bb-texts",
|
247 | title: "bb-title",
|
248 | tooltip: "bb-tooltip",
|
249 | tooltipContainer: "bb-tooltip-container",
|
250 | tooltipName: "bb-tooltip-name",
|
251 | valueDown: "bb-value-down",
|
252 | valueUp: "bb-value-up",
|
253 | xgrid: "bb-xgrid",
|
254 | xgridFocus: "bb-xgrid-focus",
|
255 | xgridLine: "bb-xgrid-line",
|
256 | xgridLines: "bb-xgrid-lines",
|
257 | xgrids: "bb-xgrids",
|
258 | ygrid: "bb-ygrid",
|
259 | ygridFocus: "bb-ygrid-focus",
|
260 | ygridLine: "bb-ygrid-line",
|
261 | ygridLines: "bb-ygrid-lines",
|
262 | ygrids: "bb-ygrids",
|
263 | zoomBrush: "bb-zoom-brush",
|
264 | EXPANDED: "_expanded_",
|
265 | SELECTED: "_selected_",
|
266 | INCLUDED: "_included_",
|
267 | TextOverlapping: "text-overlapping"
|
268 | });
|
269 | ;
|
270 | function _defineProperty(obj, key, value) {
|
271 | if (key in obj) {
|
272 | Object.defineProperty(obj, key, {
|
273 | value: value,
|
274 | enumerable: true,
|
275 | configurable: true,
|
276 | writable: true
|
277 | });
|
278 | } else {
|
279 | obj[key] = value;
|
280 | }
|
281 |
|
282 | return obj;
|
283 | }
|
284 |
|
285 | var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(1);
|
286 |
|
287 | var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(3);
|
288 | ;
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 | var win = function () {
|
303 | 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;
|
304 | return root || Function("return this")();
|
305 | }();
|
306 |
|
307 |
|
308 |
|
309 |
|
310 | win.requestIdleCallback = win.requestIdleCallback || function (cb) {
|
311 | return setTimeout(cb, 1);
|
312 | };
|
313 |
|
314 | win.cancelIdleCallback = win.cancelIdleCallback || function (id) {
|
315 | return clearTimeout(id);
|
316 | };
|
317 |
|
318 | var doc = win == null ? void 0 : win.document;
|
319 | ;
|
320 |
|
321 |
|
322 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
323 |
|
324 | function _objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 | var isValue = function (v) {
|
338 | return v || v === 0;
|
339 | },
|
340 | isFunction = function (v) {
|
341 | return typeof v === "function";
|
342 | },
|
343 | isString = function (v) {
|
344 | return typeof v === "string";
|
345 | },
|
346 | isNumber = function (v) {
|
347 | return typeof v === "number";
|
348 | },
|
349 | isUndefined = function (v) {
|
350 | return typeof v === "undefined";
|
351 | },
|
352 | isDefined = function (v) {
|
353 | return typeof v !== "undefined";
|
354 | },
|
355 | isboolean = function (v) {
|
356 | return typeof v === "boolean";
|
357 | },
|
358 | ceil10 = function (v) {
|
359 | return Math.ceil(v / 10) * 10;
|
360 | },
|
361 | asHalfPixel = function (n) {
|
362 | return Math.ceil(n) + .5;
|
363 | },
|
364 | diffDomain = function (d) {
|
365 | return d[1] - d[0];
|
366 | },
|
367 | isObjectType = function (v) {
|
368 | return typeof v === "object";
|
369 | },
|
370 | isEmpty = function (o) {
|
371 | return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
|
372 | },
|
373 | notEmpty = function (o) {
|
374 | return !isEmpty(o);
|
375 | },
|
376 | isArray = function (arr) {
|
377 | return Array.isArray(arr);
|
378 | },
|
379 | isObject = function (obj) {
|
380 | return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
|
381 | };
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 | function getOption(options, key, defaultValue) {
|
393 | return isDefined(options[key]) ? options[key] : defaultValue;
|
394 | }
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 | function hasValue(dict, value) {
|
405 | var found = !1;
|
406 | Object.keys(dict).forEach(function (key) {
|
407 | return dict[key] === value && (found = !0);
|
408 | });
|
409 | return found;
|
410 | }
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 | function callFn(fn) {
|
421 | for (var isFn = isFunction(fn), _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
422 | args[_key - 1] = arguments[_key];
|
423 | }
|
424 |
|
425 | isFn && fn.call.apply(fn, args);
|
426 | return isFn;
|
427 | }
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 | function endall(transition, cb) {
|
437 | var n = 0,
|
438 | end = function () {
|
439 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
440 | args[_key2] = arguments[_key2];
|
441 | }
|
442 |
|
443 | --n || cb.apply.apply(cb, [this].concat(args));
|
444 | };
|
445 |
|
446 |
|
447 | if ("duration" in transition) {
|
448 | transition.each(function () {
|
449 | return ++n;
|
450 | }).on("end", end);
|
451 | } else {
|
452 | ++n;
|
453 | transition.call(end);
|
454 | }
|
455 | }
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 | function sanitise(str) {
|
465 | return isString(str) ? str.replace(/</g, "<").replace(/>/g, ">") : str;
|
466 | }
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 | function setTextValue(node, text, dy, toMiddle) {
|
478 | if (dy === void 0) {
|
479 | dy = [-1, 1];
|
480 | }
|
481 |
|
482 | if (toMiddle === void 0) {
|
483 | toMiddle = !1;
|
484 | }
|
485 |
|
486 | if (!node || !isString(text)) {
|
487 | return;
|
488 | }
|
489 |
|
490 | if (text.indexOf("\n") === -1) {
|
491 | node.text(text);
|
492 | } else {
|
493 | var diff = [node.text(), text].map(function (v) {
|
494 | return v.replace(/[\s\n]/g, "");
|
495 | });
|
496 |
|
497 | if (diff[0] !== diff[1]) {
|
498 | var multiline = text.split("\n"),
|
499 | len = toMiddle ? multiline.length - 1 : 1;
|
500 |
|
501 | node.html("");
|
502 | multiline.forEach(function (v, i) {
|
503 | node.append("tspan").attr("x", 0).attr("dy", (i === 0 ? dy[0] * len : dy[1]) + "em").text(v);
|
504 | });
|
505 | }
|
506 | }
|
507 | }
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 | function getRectSegList(path) {
|
517 | |
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 | var _path$getBBox = path.getBBox(),
|
525 | x = _path$getBBox.x,
|
526 | y = _path$getBBox.y,
|
527 | width = _path$getBBox.width,
|
528 | height = _path$getBBox.height;
|
529 |
|
530 | return [{
|
531 | x: x,
|
532 | y: y + height
|
533 | },
|
534 | {
|
535 | x: x,
|
536 | y: y
|
537 | },
|
538 | {
|
539 | x: x + width,
|
540 | y: y
|
541 | },
|
542 | {
|
543 | x: x + width,
|
544 | y: y + height
|
545 | }
|
546 | ];
|
547 | }
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 | function getPathBox(path) {
|
557 | var _path$getBoundingClie = path.getBoundingClientRect(),
|
558 | width = _path$getBoundingClie.width,
|
559 | height = _path$getBoundingClie.height,
|
560 | items = getRectSegList(path),
|
561 | x = items[0].x,
|
562 | y = Math.min(items[0].y, items[1].y);
|
563 |
|
564 | return {
|
565 | x: x,
|
566 | y: y,
|
567 | width: width,
|
568 | height: height
|
569 | };
|
570 | }
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 | function getPointer(event, element) {
|
581 | var _ref,
|
582 | touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]),
|
583 | pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element);
|
584 |
|
585 | return pointer.map(function (v) {
|
586 | return isNaN(v) ? 0 : v;
|
587 | });
|
588 | }
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 | function getBrushSelection(ctx) {
|
598 | var event = ctx.event,
|
599 | $el = ctx.$el,
|
600 | main = $el.subchart.main || $el.main,
|
601 | selection;
|
602 |
|
603 |
|
604 | if (event && event.type === "brush") {
|
605 | selection = event.selection;
|
606 | } else if (main && (selection = main.select("." + classes.brush).node())) {
|
607 | selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection);
|
608 | }
|
609 |
|
610 | return selection;
|
611 | }
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 | function getBoundingRect(node) {
|
622 | var needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
|
623 | return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
|
624 | }
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 | function getRandom(asStr) {
|
634 | if (asStr === void 0) {
|
635 | asStr = !0;
|
636 | }
|
637 |
|
638 | var rand = Math.random();
|
639 | return asStr ? rand + "" : rand;
|
640 | }
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 | function findIndex(arr, v, start, end, isRotated) {
|
654 | if (start > end) {
|
655 | return -1;
|
656 | }
|
657 |
|
658 | var mid = Math.floor((start + end) / 2),
|
659 | _arr$mid = arr[mid],
|
660 | x = _arr$mid.x,
|
661 | _arr$mid$w = _arr$mid.w,
|
662 | w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
|
663 |
|
664 | if (isRotated) {
|
665 | x = arr[mid].y;
|
666 | w = arr[mid].h;
|
667 | }
|
668 |
|
669 | if (v >= x && v <= x + w) {
|
670 | return mid;
|
671 | }
|
672 |
|
673 | return v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
|
674 | }
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 | function brushEmpty(ctx) {
|
684 | var selection = getBrushSelection(ctx);
|
685 |
|
686 | if (selection) {
|
687 |
|
688 |
|
689 |
|
690 | return selection[0] === selection[1];
|
691 | }
|
692 |
|
693 | return !0;
|
694 | }
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 | function deepClone() {
|
704 | for (var clone = function (v) {
|
705 | if (isObject(v) && v.constructor) {
|
706 | var r = new v.constructor();
|
707 |
|
708 | for (var k in v) {
|
709 | r[k] = clone(v[k]);
|
710 | }
|
711 |
|
712 | return r;
|
713 | }
|
714 |
|
715 | return v;
|
716 | }, _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
717 | objectN[_key3] = arguments[_key3];
|
718 | }
|
719 |
|
720 | return objectN.map(function (v) {
|
721 | return clone(v);
|
722 | }).reduce(function (a, c) {
|
723 | return _objectSpread(_objectSpread({}, a), c);
|
724 | });
|
725 | }
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 | function extend(target, source) {
|
736 | if (target === void 0) {
|
737 | target = {};
|
738 | }
|
739 |
|
740 | if (isArray(source)) {
|
741 | source.forEach(function (v) {
|
742 | return extend(target, v);
|
743 | });
|
744 | }
|
745 |
|
746 |
|
747 | for (var p in source) {
|
748 | if (/^\d+$/.test(p) || p in target) {
|
749 | continue;
|
750 | }
|
751 |
|
752 | target[p] = source[p];
|
753 | }
|
754 |
|
755 | return target;
|
756 | }
|
757 |
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 | var capitalize = function (str) {
|
766 | return str.charAt(0).toUpperCase() + str.slice(1);
|
767 | };
|
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 | function camelize(str, separator) {
|
778 | if (separator === void 0) {
|
779 | separator = "-";
|
780 | }
|
781 |
|
782 | return str.split(separator).map(function (v, i) {
|
783 | return i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase();
|
784 | }).join("");
|
785 | }
|
786 |
|
787 |
|
788 |
|
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 | var toArray = function (v) {
|
795 | return [].slice.call(v);
|
796 | };
|
797 |
|
798 |
|
799 |
|
800 |
|
801 |
|
802 |
|
803 |
|
804 |
|
805 | function getCssRules(styleSheets) {
|
806 | var rules = [];
|
807 | styleSheets.forEach(function (sheet) {
|
808 | try {
|
809 | if (sheet.cssRules && sheet.cssRules.length) {
|
810 | rules = rules.concat(toArray(sheet.cssRules));
|
811 | }
|
812 | } catch (e) {
|
813 | console.error("Error while reading rules from " + sheet.href + ": " + e.toString());
|
814 | }
|
815 | });
|
816 | return rules;
|
817 | }
|
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 |
|
824 |
|
825 |
|
826 | function getTranslation(node) {
|
827 | var transform = node ? node.transform : null,
|
828 | baseVal = transform && transform.baseVal;
|
829 | return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
|
830 | a: 0,
|
831 | b: 0,
|
832 | c: 0,
|
833 | d: 0,
|
834 | e: 0,
|
835 | f: 0
|
836 | };
|
837 | }
|
838 |
|
839 |
|
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 | function getUnique(data) {
|
847 | var isDate = data[0] instanceof Date,
|
848 | d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
|
849 | return self.indexOf(v) === i;
|
850 | });
|
851 | return isDate ? d.map(function (v) {
|
852 | return new Date(v);
|
853 | }) : d;
|
854 | }
|
855 |
|
856 |
|
857 |
|
858 |
|
859 |
|
860 |
|
861 |
|
862 |
|
863 | function mergeArray(arr) {
|
864 | return arr && arr.length ? arr.reduce(function (p, c) {
|
865 | return p.concat(c);
|
866 | }) : [];
|
867 | }
|
868 |
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 | function mergeObj(target) {
|
878 | for (var _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
879 | objectN[_key4 - 1] = arguments[_key4];
|
880 | }
|
881 |
|
882 | if (!objectN.length || objectN.length === 1 && !objectN[0]) {
|
883 | return target;
|
884 | }
|
885 |
|
886 | var source = objectN.shift();
|
887 |
|
888 | if (isObject(target) && isObject(source)) {
|
889 | Object.keys(source).forEach(function (key) {
|
890 | var value = source[key];
|
891 |
|
892 | if (isObject(value)) {
|
893 | target[key] || (target[key] = {});
|
894 | target[key] = mergeObj(target[key], value);
|
895 | } else {
|
896 | target[key] = isArray(value) ? value.concat() : value;
|
897 | }
|
898 | });
|
899 | }
|
900 |
|
901 | return mergeObj.apply(void 0, [target].concat(objectN));
|
902 | }
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 | function sortValue(data, isAsc) {
|
913 | if (isAsc === void 0) {
|
914 | isAsc = !0;
|
915 | }
|
916 |
|
917 | var fn;
|
918 |
|
919 | if (data[0] instanceof Date) {
|
920 | fn = isAsc ? function (a, b) {
|
921 | return a - b;
|
922 | } : function (a, b) {
|
923 | return b - a;
|
924 | };
|
925 | } else {
|
926 | if (isAsc && !data.every(isNaN)) {
|
927 | fn = function (a, b) {
|
928 | return a - b;
|
929 | };
|
930 | } else if (!isAsc) {
|
931 | fn = function (a, b) {
|
932 | return a > b && -1 || a < b && 1 || a === b && 0;
|
933 | };
|
934 | }
|
935 | }
|
936 |
|
937 | return data.concat().sort(fn);
|
938 | }
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 |
|
948 | function getMinMax(type, data) {
|
949 | var res = data.filter(function (v) {
|
950 | return notEmpty(v);
|
951 | });
|
952 |
|
953 | if (res.length) {
|
954 | if (isNumber(res[0])) {
|
955 | res = Math[type].apply(Math, res);
|
956 | } else if (res[0] instanceof Date) {
|
957 | res = sortValue(res, type === "min")[0];
|
958 | }
|
959 | } else {
|
960 | res = undefined;
|
961 | }
|
962 |
|
963 | return res;
|
964 | }
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 | var getRange = function (start, end, step) {
|
976 | if (step === void 0) {
|
977 | step = 1;
|
978 | }
|
979 |
|
980 | var res = [],
|
981 | n = Math.max(0, Math.ceil((end - start) / step)) | 0;
|
982 |
|
983 | for (var i = start; i < n; i++) {
|
984 | res.push(start + i * step);
|
985 | }
|
986 |
|
987 | return res;
|
988 | },
|
989 | emulateEvent = {
|
990 | mouse: function () {
|
991 | var getParams = function () {
|
992 | return {
|
993 | bubbles: !1,
|
994 | cancelable: !1,
|
995 | screenX: 0,
|
996 | screenY: 0,
|
997 | clientX: 0,
|
998 | clientY: 0
|
999 | };
|
1000 | };
|
1001 |
|
1002 | try {
|
1003 |
|
1004 | new MouseEvent("t");
|
1005 | return function (el, eventType, params) {
|
1006 | if (params === void 0) {
|
1007 | params = getParams();
|
1008 | }
|
1009 |
|
1010 | el.dispatchEvent(new MouseEvent(eventType, params));
|
1011 | };
|
1012 | } catch (e) {
|
1013 |
|
1014 | return function (el, eventType, params) {
|
1015 | if (params === void 0) {
|
1016 | params = getParams();
|
1017 | }
|
1018 |
|
1019 | var mouseEvent = doc.createEvent("MouseEvent");
|
1020 |
|
1021 | mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0,
|
1022 | params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null);
|
1023 | el.dispatchEvent(mouseEvent);
|
1024 | };
|
1025 | }
|
1026 | }(),
|
1027 | touch: function touch(el, eventType, params) {
|
1028 | var touchObj = new Touch(mergeObj({
|
1029 | identifier: Date.now(),
|
1030 | target: el,
|
1031 | radiusX: 2.5,
|
1032 | radiusY: 2.5,
|
1033 | rotationAngle: 10,
|
1034 | force: .5
|
1035 | }, params));
|
1036 | el.dispatchEvent(new TouchEvent(eventType, {
|
1037 | cancelable: !0,
|
1038 | bubbles: !0,
|
1039 | shiftKey: !0,
|
1040 | touches: [touchObj],
|
1041 | targetTouches: [],
|
1042 | changedTouches: [touchObj]
|
1043 | }));
|
1044 | }
|
1045 | };
|
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 | function tplProcess(tpl, data) {
|
1056 | var res = tpl;
|
1057 |
|
1058 | for (var x in data) {
|
1059 | res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
|
1060 | }
|
1061 |
|
1062 | return res;
|
1063 | }
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 | function parseDate(date) {
|
1074 | var parsedDate;
|
1075 |
|
1076 | if (date instanceof Date) {
|
1077 | parsedDate = date;
|
1078 | } else if (isString(date)) {
|
1079 | var config = this.config,
|
1080 | format = this.format;
|
1081 | parsedDate = format.dataTime(config.data_xFormat)(date);
|
1082 | } else if (isNumber(date) && !isNaN(date)) {
|
1083 | parsedDate = new Date(+date);
|
1084 | }
|
1085 |
|
1086 | if (!parsedDate || isNaN(+parsedDate)) {
|
1087 | console && console.error && console.error("Failed to parse x '" + date + "' to Date object");
|
1088 | }
|
1089 |
|
1090 | return parsedDate;
|
1091 | }
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 | function isTabVisible() {
|
1100 | return !doc.hidden;
|
1101 | }
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 | function convertInputType(mouse, touch) {
|
1112 | var isMobile = !1;
|
1113 |
|
1114 | if (/Mobi/.test(win.navigator.userAgent) && touch) {
|
1115 |
|
1116 | var hasTouchPoints = win.navigator && "maxTouchPoints" in win.navigator && win.navigator.maxTouchPoints > 0,
|
1117 | hasTouch = "ontouchmove" in win || win.DocumentTouch && doc instanceof win.DocumentTouch;
|
1118 |
|
1119 |
|
1120 | isMobile = hasTouchPoints || hasTouch;
|
1121 | }
|
1122 |
|
1123 | var hasMouse = mouse && !isMobile ? "onmouseover" in win : !1;
|
1124 | return hasMouse && "mouse" || isMobile && "touch" || null;
|
1125 | }
|
1126 | ;
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 | function loadConfig(config) {
|
1139 | var thisConfig = this.config,
|
1140 | target,
|
1141 | keys,
|
1142 | read,
|
1143 | find = function () {
|
1144 | var key = keys.shift();
|
1145 |
|
1146 | if (key && target && isObjectType(target) && key in target) {
|
1147 | target = target[key];
|
1148 | return find();
|
1149 | } else if (!key) {
|
1150 | return target;
|
1151 | }
|
1152 |
|
1153 | return undefined;
|
1154 | };
|
1155 |
|
1156 | Object.keys(thisConfig).forEach(function (key) {
|
1157 | target = config;
|
1158 | keys = key.split("_");
|
1159 | read = find();
|
1160 |
|
1161 | if (isDefined(read)) {
|
1162 | thisConfig[key] = read;
|
1163 | }
|
1164 | });
|
1165 | }
|
1166 | ;
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 | var Plugin = function () {
|
1187 | |
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 | function Plugin(options) {
|
1193 | if (options === void 0) {
|
1194 | options = {};
|
1195 | }
|
1196 |
|
1197 | this.$$ = void 0;
|
1198 | this.options = void 0;
|
1199 | this.options = options;
|
1200 | }
|
1201 | |
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 | var _proto = Plugin.prototype;
|
1208 |
|
1209 | _proto.$beforeInit = function $beforeInit() {}
|
1210 | |
1211 |
|
1212 |
|
1213 |
|
1214 | ;
|
1215 |
|
1216 | _proto.$init = function $init() {}
|
1217 | |
1218 |
|
1219 |
|
1220 |
|
1221 | ;
|
1222 |
|
1223 | _proto.$afterInit = function $afterInit() {}
|
1224 | |
1225 |
|
1226 |
|
1227 |
|
1228 | ;
|
1229 |
|
1230 | _proto.$redraw = function $redraw() {}
|
1231 | |
1232 |
|
1233 |
|
1234 |
|
1235 | ;
|
1236 |
|
1237 | _proto.$willDestroy = function $willDestroy() {
|
1238 | var _this = this;
|
1239 |
|
1240 | Object.keys(this).forEach(function (key) {
|
1241 | _this[key] = null;
|
1242 | delete _this[key];
|
1243 | });
|
1244 | };
|
1245 |
|
1246 | return Plugin;
|
1247 | }();
|
1248 |
|
1249 | Plugin.version = "3.2.1";
|
1250 |
|
1251 | ;
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 | var Options = function () {
|
1266 | return {
|
1267 | |
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 | colors: undefined,
|
1279 |
|
1280 | |
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 | epochs: [],
|
1290 |
|
1291 | |
1292 |
|
1293 |
|
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 | lines: [],
|
1312 |
|
1313 | |
1314 |
|
1315 |
|
1316 |
|
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 | scale_min: undefined,
|
1339 | scale_max: undefined,
|
1340 | scale_width: 20,
|
1341 | scale_format: undefined,
|
1342 |
|
1343 | |
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 | padding_top: 0,
|
1362 | padding_right: 0,
|
1363 | padding_bottom: 0,
|
1364 | padding_left: 0,
|
1365 |
|
1366 | |
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 | regions: []
|
1398 | };
|
1399 | };
|
1400 |
|
1401 |
|
1402 | ;
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 | var stanford_classes = ({
|
1413 | colorScale: "bb-colorscale",
|
1414 | stanfordElements: "bb-stanford-elements",
|
1415 | stanfordLine: "bb-stanford-line",
|
1416 | stanfordLines: "bb-stanford-lines",
|
1417 | stanfordRegion: "bb-stanford-region",
|
1418 | stanfordRegions: "bb-stanford-regions"
|
1419 | });
|
1420 | ;
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 | function pointInRegion(point, region) {
|
1436 |
|
1437 |
|
1438 |
|
1439 | var x = point.x,
|
1440 | y = point.value,
|
1441 | inside = !1;
|
1442 |
|
1443 | for (var i = 0, j = region.length - 1; i < region.length; j = i++) {
|
1444 | var xi = region[i].x,
|
1445 | yi = region[i].y,
|
1446 | xj = region[j].x,
|
1447 | yj = region[j].y;
|
1448 |
|
1449 | if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) {
|
1450 | inside = !inside;
|
1451 | }
|
1452 | }
|
1453 |
|
1454 | return inside;
|
1455 | }
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 | function compareEpochs(a, b) {
|
1466 | if (a.epochs < b.epochs) {
|
1467 | return -1;
|
1468 | }
|
1469 |
|
1470 | if (a.epochs > b.epochs) {
|
1471 | return 1;
|
1472 | }
|
1473 |
|
1474 | return 0;
|
1475 | }
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 | function getRegionArea(points) {
|
1485 |
|
1486 | var area = 0,
|
1487 | point1,
|
1488 | point2;
|
1489 |
|
1490 | for (var i = 0, l = points.length, j = l - 1; i < l; j = i, i++) {
|
1491 | point1 = points[i];
|
1492 | point2 = points[j];
|
1493 | area += point1.x * point2.y;
|
1494 | area -= point1.y * point2.x;
|
1495 | }
|
1496 |
|
1497 | area /= 2;
|
1498 | return area;
|
1499 | }
|
1500 |
|
1501 |
|
1502 |
|
1503 |
|
1504 |
|
1505 |
|
1506 |
|
1507 |
|
1508 | function getCentroid(points) {
|
1509 | var area = getRegionArea(points),
|
1510 | x = 0,
|
1511 | y = 0,
|
1512 | f;
|
1513 |
|
1514 | for (var i = 0, l = points.length, j = l - 1; i < l; j = i, i++) {
|
1515 | var point1 = points[i],
|
1516 | point2 = points[j];
|
1517 | f = point1.x * point2.y - point2.x * point1.y;
|
1518 | x += (point1.x + point2.x) * f;
|
1519 | y += (point1.y + point2.y) * f;
|
1520 | }
|
1521 |
|
1522 | f = area * 6;
|
1523 | return {
|
1524 | x: x / f,
|
1525 | y: y / f
|
1526 | };
|
1527 | }
|
1528 |
|
1529 |
|
1530 | ;
|
1531 |
|
1532 |
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 |
|
1541 |
|
1542 |
|
1543 |
|
1544 |
|
1545 | var Elements = function () {
|
1546 | function Elements(owner) {
|
1547 | this.owner = void 0;
|
1548 | this.owner = owner;
|
1549 |
|
1550 | var elements = owner.$$.$el.main.select(".bb-chart").append("g").attr("class", stanford_classes.stanfordElements);
|
1551 | elements.append("g").attr("class", stanford_classes.stanfordLines);
|
1552 | elements.append("g").attr("class", stanford_classes.stanfordRegions);
|
1553 | }
|
1554 |
|
1555 | var _proto = Elements.prototype;
|
1556 |
|
1557 | _proto.updateStanfordLines = function updateStanfordLines(duration) {
|
1558 | var $$ = this.owner.$$,
|
1559 | config = $$.config,
|
1560 | main = $$.$el.main,
|
1561 | isRotated = config.axis_rotated,
|
1562 | xvCustom = this.xvCustom.bind($$),
|
1563 | yvCustom = this.yvCustom.bind($$),
|
1564 | stanfordLine = main.select("." + stanford_classes.stanfordLines).style("shape-rendering", "geometricprecision").selectAll("." + stanford_classes.stanfordLine).data(this.owner.config.lines);
|
1565 |
|
1566 | stanfordLine.exit().transition().duration(duration).style("opacity", "0").remove();
|
1567 |
|
1568 | var stanfordLineEnter = stanfordLine.enter().append("g");
|
1569 | stanfordLineEnter.append("line").style("opacity", "0");
|
1570 | stanfordLineEnter.merge(stanfordLine).attr("class", function (d) {
|
1571 | return stanford_classes.stanfordLine + (d.class ? " " + d.class : "");
|
1572 | }).select("line").transition().duration(duration).attr("x1", function (d) {
|
1573 | return isRotated ? yvCustom(d, "y1") : xvCustom(d, "x1");
|
1574 | }).attr("x2", function (d) {
|
1575 | return isRotated ? yvCustom(d, "y2") : xvCustom(d, "x2");
|
1576 | }).attr("y1", function (d) {
|
1577 | return isRotated ? xvCustom(d, "x1") : yvCustom(d, "y1");
|
1578 | }).attr("y2", function (d) {
|
1579 | return isRotated ? xvCustom(d, "x2") : yvCustom(d, "y2");
|
1580 | }).transition().style("opacity", null);
|
1581 | };
|
1582 |
|
1583 | _proto.updateStanfordRegions = function updateStanfordRegions(duration) {
|
1584 | var $$ = this.owner.$$,
|
1585 | config = $$.config,
|
1586 | main = $$.$el.main,
|
1587 | isRotated = config.axis_rotated,
|
1588 | xvCustom = this.xvCustom.bind($$),
|
1589 | yvCustom = this.yvCustom.bind($$),
|
1590 | countPointsInRegion = this.owner.countEpochsInRegion.bind($$),
|
1591 | stanfordRegion = main.select("." + stanford_classes.stanfordRegions).selectAll("." + stanford_classes.stanfordRegion).data(this.owner.config.regions);
|
1592 |
|
1593 | stanfordRegion.exit().transition().duration(duration).style("opacity", "0").remove();
|
1594 |
|
1595 | var stanfordRegionEnter = stanfordRegion.enter().append("g");
|
1596 | stanfordRegionEnter.append("polygon").style("opacity", "0");
|
1597 | stanfordRegionEnter.append("text").attr("transform", isRotated ? "rotate(-90)" : "").style("opacity", "0");
|
1598 | stanfordRegion = stanfordRegionEnter.merge(stanfordRegion);
|
1599 |
|
1600 | stanfordRegion.attr("class", function (d) {
|
1601 | return stanford_classes.stanfordRegion + (d.class ? " " + d.class : "");
|
1602 | }).select("polygon").transition().duration(duration).attr("points", function (d) {
|
1603 | return d.points.map(function (value) {
|
1604 | return [isRotated ? yvCustom(value, "y") : xvCustom(value, "x"), isRotated ? xvCustom(value, "x") : yvCustom(value, "y")].join(",");
|
1605 | }).join(" ");
|
1606 | }).transition().style("opacity", function (d) {
|
1607 | return (d.opacity ? d.opacity : .2) + "";
|
1608 | });
|
1609 | stanfordRegion.select("text").transition().duration(duration).attr("x", function (d) {
|
1610 | return isRotated ? yvCustom(getCentroid(d.points), "y") : xvCustom(getCentroid(d.points), "x");
|
1611 | }).attr("y", function (d) {
|
1612 | return isRotated ? xvCustom(getCentroid(d.points), "x") : yvCustom(getCentroid(d.points), "y");
|
1613 | }).text(function (d) {
|
1614 | if (d.text) {
|
1615 | var _countPointsInRegion = countPointsInRegion(d.points),
|
1616 | value = _countPointsInRegion.value,
|
1617 | percentage = _countPointsInRegion.percentage;
|
1618 |
|
1619 | return d.text(value, percentage);
|
1620 | }
|
1621 |
|
1622 | return "";
|
1623 | }).attr("text-anchor", "middle").attr("dominant-baseline", "middle").transition().style("opacity", null);
|
1624 | };
|
1625 |
|
1626 | _proto.updateStanfordElements = function updateStanfordElements(duration) {
|
1627 | if (duration === void 0) {
|
1628 | duration = 0;
|
1629 | }
|
1630 |
|
1631 | this.updateStanfordLines(duration);
|
1632 | this.updateStanfordRegions(duration);
|
1633 | };
|
1634 |
|
1635 | _proto.xvCustom = function xvCustom(d, xyValue) {
|
1636 | var $$ = this,
|
1637 | axis = $$.axis,
|
1638 | config = $$.config,
|
1639 | value = xyValue ? d[xyValue] : $$.getBaseValue(d);
|
1640 |
|
1641 | if (axis.isTimeSeries()) {
|
1642 | value = parseDate.call($$, value);
|
1643 | } else if (axis.isCategorized() && isString(value)) {
|
1644 | value = config.axis_x_categories.indexOf(d.value);
|
1645 | }
|
1646 |
|
1647 | return Math.ceil($$.scale.x(value));
|
1648 | };
|
1649 |
|
1650 | _proto.yvCustom = function yvCustom(d, xyValue) {
|
1651 | var $$ = this,
|
1652 | yScale = d.axis && d.axis === "y2" ? $$.scale.y2 : $$.scale.y,
|
1653 | value = xyValue ? d[xyValue] : $$.getBaseValue(d);
|
1654 | return Math.ceil(yScale(value));
|
1655 | };
|
1656 |
|
1657 | return Elements;
|
1658 | }();
|
1659 |
|
1660 |
|
1661 |
|
1662 | var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack_require__(8);
|
1663 |
|
1664 | var external_commonjs_d3_format_commonjs2_d3_format_amd_d3_format_root_d3_ = __webpack_require__(9);
|
1665 | ;
|
1666 |
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 |
|
1682 | var ColorScale = function () {
|
1683 | function ColorScale(owner) {
|
1684 | this.owner = void 0;
|
1685 | this.colorScale = void 0;
|
1686 | this.owner = owner;
|
1687 | }
|
1688 |
|
1689 | var _proto = ColorScale.prototype;
|
1690 |
|
1691 | _proto.drawColorScale = function drawColorScale() {
|
1692 | var _this$owner = this.owner,
|
1693 | $$ = _this$owner.$$,
|
1694 | config = _this$owner.config,
|
1695 | target = $$.data.targets[0],
|
1696 | height = $$.state.height - config.padding_bottom - config.padding_top,
|
1697 | barWidth = config.scale_width,
|
1698 | barHeight = 5,
|
1699 | points = getRange(config.padding_bottom, height, barHeight),
|
1700 | inverseScale = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSequential)(target.colors).domain([points[points.length - 1], points[0]]);
|
1701 |
|
1702 | if (this.colorScale) {
|
1703 | this.colorScale.remove();
|
1704 | }
|
1705 |
|
1706 | this.colorScale = $$.$el.svg.append("g").attr("width", 50).attr("height", height).attr("class", stanford_classes.colorScale);
|
1707 | this.colorScale.append("g").attr("transform", "translate(0, " + config.padding_top + ")").selectAll("bars").data(points).enter().append("rect").attr("y", function (d, i) {
|
1708 | return i * barHeight;
|
1709 | }).attr("x", 0).attr("width", barWidth).attr("height", barHeight).attr("fill", function (d) {
|
1710 | return inverseScale(d);
|
1711 | });
|
1712 |
|
1713 | var axisScale = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLog)().domain([target.minEpochs, target.maxEpochs]).range([points[0] + config.padding_top + points[points.length - 1] + barHeight - 1, points[0] + config.padding_top]),
|
1714 | legendAxis = (0,external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisRight)(axisScale),
|
1715 | scaleFormat = config.scale_format;
|
1716 |
|
1717 | if (scaleFormat === "pow10") {
|
1718 | legendAxis.tickValues([1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7]);
|
1719 | } else if (isFunction(scaleFormat)) {
|
1720 | legendAxis.tickFormat(scaleFormat);
|
1721 | } else {
|
1722 | legendAxis.tickFormat((0,external_commonjs_d3_format_commonjs2_d3_format_amd_d3_format_root_d3_.format)("d"));
|
1723 | }
|
1724 |
|
1725 |
|
1726 | var axis = this.colorScale.append("g").attr("class", "legend axis").attr("transform", "translate(" + barWidth + ",0)").call(legendAxis);
|
1727 |
|
1728 | if (scaleFormat === "pow10") {
|
1729 | axis.selectAll(".tick text").text(null).filter(function (d) {
|
1730 | return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1;
|
1731 | })
|
1732 | .text(10).append("tspan").attr("dy", "-.7em")
|
1733 | .text(function (d) {
|
1734 | return Math.round(Math.log(d) / Math.LN10);
|
1735 | });
|
1736 | }
|
1737 |
|
1738 | this.colorScale.attr("transform", "translate(" + ($$.state.current.width - this.xForColorScale()) + ", 0)");
|
1739 | };
|
1740 |
|
1741 | _proto.xForColorScale = function xForColorScale() {
|
1742 | return this.owner.config.padding_right + this.colorScale.node().getBBox().width;
|
1743 | };
|
1744 |
|
1745 | _proto.getColorScalePadding = function getColorScalePadding() {
|
1746 | return this.xForColorScale() + this.owner.config.padding_left + 20;
|
1747 | };
|
1748 |
|
1749 | return ColorScale;
|
1750 | }();
|
1751 |
|
1752 |
|
1753 | ;
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 |
|
1762 |
|
1763 |
|
1764 |
|
1765 |
|
1766 |
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 |
|
1777 |
|
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 |
|
1786 |
|
1787 |
|
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 |
|
1800 |
|
1801 |
|
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 |
|
1807 |
|
1808 |
|
1809 |
|
1810 |
|
1811 |
|
1812 |
|
1813 |
|
1814 |
|
1815 |
|
1816 |
|
1817 |
|
1818 |
|
1819 |
|
1820 |
|
1821 |
|
1822 |
|
1823 |
|
1824 |
|
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 |
|
1830 |
|
1831 |
|
1832 |
|
1833 |
|
1834 |
|
1835 |
|
1836 |
|
1837 |
|
1838 |
|
1839 |
|
1840 |
|
1841 |
|
1842 |
|
1843 |
|
1844 |
|
1845 |
|
1846 |
|
1847 |
|
1848 |
|
1849 |
|
1850 |
|
1851 |
|
1852 |
|
1853 |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 | var Stanford = function (_Plugin) {
|
1859 | _inheritsLoose(Stanford, _Plugin);
|
1860 |
|
1861 | function Stanford(options) {
|
1862 | var _this = _Plugin.call(this, options) || this;
|
1863 |
|
1864 | _this.config = void 0;
|
1865 | _this.colorScale = void 0;
|
1866 | _this.elements = void 0;
|
1867 | _this.config = new Options();
|
1868 | return _assertThisInitialized(_this) || _assertThisInitialized(_this);
|
1869 | }
|
1870 |
|
1871 | var _proto = Stanford.prototype;
|
1872 |
|
1873 | _proto.$beforeInit = function $beforeInit() {
|
1874 | var _this2 = this,
|
1875 | $$ = this.$$;
|
1876 |
|
1877 |
|
1878 | $$.config.data_xSort = !1;
|
1879 |
|
1880 | $$.isMultipleX = function () {
|
1881 | return !0;
|
1882 | };
|
1883 |
|
1884 | $$.showGridFocus = function () {};
|
1885 |
|
1886 | $$.labelishData = function (d) {
|
1887 | return d.values;
|
1888 | };
|
1889 |
|
1890 | $$.opacityForCircle = function () {
|
1891 | return 1;
|
1892 | };
|
1893 |
|
1894 | var getCurrentPaddingRight = $$.getCurrentPaddingRight.bind($$);
|
1895 |
|
1896 | $$.getCurrentPaddingRight = function () {
|
1897 | return getCurrentPaddingRight() + (_this2.colorScale ? _this2.colorScale.getColorScalePadding() : 0);
|
1898 | };
|
1899 | };
|
1900 |
|
1901 | _proto.$init = function $init() {
|
1902 | var $$ = this.$$;
|
1903 | loadConfig.call(this, this.options);
|
1904 | $$.color = this.getStanfordPointColor.bind($$);
|
1905 | this.colorScale = new ColorScale(this);
|
1906 | this.elements = new Elements(this);
|
1907 | this.convertData();
|
1908 | this.initStanfordData();
|
1909 | this.setStanfordTooltip();
|
1910 | this.colorScale.drawColorScale();
|
1911 | this.$redraw();
|
1912 | };
|
1913 |
|
1914 | _proto.$redraw = function $redraw(duration) {
|
1915 | var _this$colorScale, _this$elements;
|
1916 |
|
1917 | (_this$colorScale = this.colorScale) == null ? void 0 : _this$colorScale.drawColorScale();
|
1918 | (_this$elements = this.elements) == null ? void 0 : _this$elements.updateStanfordElements(duration);
|
1919 | };
|
1920 |
|
1921 | _proto.getOptions = function getOptions() {
|
1922 | return new Options();
|
1923 | };
|
1924 |
|
1925 | _proto.convertData = function convertData() {
|
1926 | var data = this.$$.data.targets,
|
1927 | epochs = this.options.epochs;
|
1928 | data.forEach(function (d) {
|
1929 | d.values.forEach(function (v, i) {
|
1930 | v.epochs = epochs[i];
|
1931 | });
|
1932 | d.minEpochs = undefined;
|
1933 | d.maxEpochs = undefined;
|
1934 | d.colors = undefined;
|
1935 | d.colorscale = undefined;
|
1936 | });
|
1937 | };
|
1938 |
|
1939 | _proto.xvCustom = function xvCustom(d, xyValue) {
|
1940 | var $$ = this,
|
1941 | axis = $$.axis,
|
1942 | config = $$.config,
|
1943 | value = xyValue ? d[xyValue] : $$.getBaseValue(d);
|
1944 |
|
1945 | if (axis.isTimeSeries()) {
|
1946 | value = parseDate.call($$, value);
|
1947 | } else if (axis.isCategorized() && isString(value)) {
|
1948 | value = config.axis_x_categories.indexOf(d.value);
|
1949 | }
|
1950 |
|
1951 | return Math.ceil($$.scale.x(value));
|
1952 | };
|
1953 |
|
1954 | _proto.yvCustom = function yvCustom(d, xyValue) {
|
1955 | var $$ = this,
|
1956 | scale = $$.scale,
|
1957 | yScale = d.axis && d.axis === "y2" ? scale.y2 : scale.y,
|
1958 | value = xyValue ? d[xyValue] : $$.getBaseValue(d);
|
1959 | return Math.ceil(yScale(value));
|
1960 | };
|
1961 |
|
1962 | _proto.initStanfordData = function initStanfordData() {
|
1963 | var config = this.config,
|
1964 | target = this.$$.data.targets[0];
|
1965 |
|
1966 |
|
1967 | target.values.sort(compareEpochs);
|
1968 |
|
1969 | var epochs = target.values.map(function (a) {
|
1970 | return a.epochs;
|
1971 | });
|
1972 | target.minEpochs = !isNaN(config.scale_min) ? config.scale_min : Math.min.apply(Math, epochs);
|
1973 | target.maxEpochs = !isNaN(config.scale_max) ? config.scale_max : Math.max.apply(Math, epochs);
|
1974 | target.colors = isFunction(config.colors) ? config.colors : (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolateHslLong)((0,external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_.hsl)(250, 1, .5), (0,external_commonjs_d3_color_commonjs2_d3_color_amd_d3_color_root_d3_.hsl)(0, 1, .5));
|
1975 | target.colorscale = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSequentialLog)(target.colors).domain([target.minEpochs, target.maxEpochs]);
|
1976 | };
|
1977 |
|
1978 | _proto.getStanfordPointColor = function getStanfordPointColor(d) {
|
1979 | var target = this.data.targets[0];
|
1980 | return target.colorscale(d.epochs);
|
1981 | };
|
1982 |
|
1983 | _proto.setStanfordTooltip = function setStanfordTooltip() {
|
1984 | var config = this.$$.config;
|
1985 |
|
1986 | if (isEmpty(config.tooltip_contents)) {
|
1987 | config.tooltip_contents = function (d, defaultTitleFormat, defaultValueFormat, color) {
|
1988 | var html = "<table class=\"" + classes.tooltip + "\"><tbody>";
|
1989 | d.forEach(function (v) {
|
1990 | html += "<tr>\n\t\t\t\t\t\t\t<th>" + defaultTitleFormat(config.data_x) + "</th>\n\t\t\t\t\t\t\t<th class=\"value\">" + 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>" + defaultTitleFormat(v.id) + "</th>\n\t\t\t\t\t\t\t<th class=\"value\">" + defaultValueFormat(v.value) + "</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr class=\"" + classes.tooltipName + "-" + v.id + "\">\n\t\t\t\t\t\t\t<td class=\"name\"><span style=\"background-color:" + color(v) + "\"></span>" + defaultTitleFormat("Epochs") + "</td>\n\t\t\t\t\t\t\t<td class=\"value\">" + defaultValueFormat(v.epochs) + "</td>\n\t\t\t\t\t\t</tr>";
|
1991 | });
|
1992 | return html + "</tbody></table>";
|
1993 | };
|
1994 | }
|
1995 | };
|
1996 |
|
1997 | _proto.countEpochsInRegion = function countEpochsInRegion(region) {
|
1998 | var $$ = this,
|
1999 | target = $$.data.targets[0],
|
2000 | total = target.values.reduce(function (accumulator, currentValue) {
|
2001 | return accumulator + +currentValue.epochs;
|
2002 | }, 0),
|
2003 | value = target.values.reduce(function (accumulator, currentValue) {
|
2004 | if (pointInRegion(currentValue, region)) {
|
2005 | return accumulator + +currentValue.epochs;
|
2006 | }
|
2007 |
|
2008 | return accumulator;
|
2009 | }, 0);
|
2010 | return {
|
2011 | value: value,
|
2012 | percentage: value !== 0 ? +(value / total * 100).toFixed(1) : 0
|
2013 | };
|
2014 | };
|
2015 |
|
2016 | return Stanford;
|
2017 | }(Plugin);
|
2018 |
|
2019 |
|
2020 | }();
|
2021 | __webpack_exports__ = __webpack_exports__["default"];
|
2022 | return __webpack_exports__;
|
2023 | })()
|
2024 | ;
|
2025 | }); |
\ | No newline at end of file |