1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | (function webpackUniversalModuleDefinition(root, factory) {
|
11 | if(typeof exports === 'object' && typeof module === 'object')
|
12 | module.exports = factory(require("d3-axis"), require("d3-brush"), require("d3-drag"), require("d3-dsv"), require("d3-ease"), require("d3-hierarchy"), require("d3-interpolate"), require("d3-scale"), require("d3-selection"), require("d3-shape"), require("d3-time-format"), require("d3-transition"), require("d3-zoom"));
|
13 | else if(typeof define === 'function' && define.amd)
|
14 | define(["d3-axis", "d3-brush", "d3-drag", "d3-dsv", "d3-ease", "d3-hierarchy", "d3-interpolate", "d3-scale", "d3-selection", "d3-shape", "d3-time-format", "d3-transition", "d3-zoom"], factory);
|
15 | else {
|
16 | var a = typeof exports === 'object' ? factory(require("d3-axis"), require("d3-brush"), require("d3-drag"), require("d3-dsv"), require("d3-ease"), require("d3-hierarchy"), require("d3-interpolate"), require("d3-scale"), require("d3-selection"), require("d3-shape"), require("d3-time-format"), require("d3-transition"), require("d3-zoom")) : factory(root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"]);
|
17 | for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
18 | }
|
19 | })(this, function(__WEBPACK_EXTERNAL_MODULE__11__, __WEBPACK_EXTERNAL_MODULE__4__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__5__, __WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__14__, __WEBPACK_EXTERNAL_MODULE__13__, __WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__2__, __WEBPACK_EXTERNAL_MODULE__9__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__8__, __WEBPACK_EXTERNAL_MODULE__10__) {
|
20 | return (function() {
|
21 | "use strict";
|
22 | var __webpack_modules__ = ([
|
23 | ,
|
24 | ,
|
25 |
|
26 | (function(module) {
|
27 |
|
28 | module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
|
29 |
|
30 | }),
|
31 |
|
32 | (function(module) {
|
33 |
|
34 | module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
|
35 |
|
36 | }),
|
37 |
|
38 | (function(module) {
|
39 |
|
40 | module.exports = __WEBPACK_EXTERNAL_MODULE__4__;
|
41 |
|
42 | }),
|
43 |
|
44 | (function(module) {
|
45 |
|
46 | module.exports = __WEBPACK_EXTERNAL_MODULE__5__;
|
47 |
|
48 | }),
|
49 |
|
50 | (function(module) {
|
51 |
|
52 | module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
|
53 |
|
54 | }),
|
55 |
|
56 | (function(module) {
|
57 |
|
58 | module.exports = __WEBPACK_EXTERNAL_MODULE__7__;
|
59 |
|
60 | }),
|
61 |
|
62 | (function(module) {
|
63 |
|
64 | module.exports = __WEBPACK_EXTERNAL_MODULE__8__;
|
65 |
|
66 | }),
|
67 |
|
68 | (function(module) {
|
69 |
|
70 | module.exports = __WEBPACK_EXTERNAL_MODULE__9__;
|
71 |
|
72 | }),
|
73 |
|
74 | (function(module) {
|
75 |
|
76 | module.exports = __WEBPACK_EXTERNAL_MODULE__10__;
|
77 |
|
78 | }),
|
79 |
|
80 | (function(module) {
|
81 |
|
82 | module.exports = __WEBPACK_EXTERNAL_MODULE__11__;
|
83 |
|
84 | }),
|
85 |
|
86 | (function(module) {
|
87 |
|
88 | module.exports = __WEBPACK_EXTERNAL_MODULE__12__;
|
89 |
|
90 | }),
|
91 |
|
92 | (function(module) {
|
93 |
|
94 | module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
|
95 |
|
96 | }),
|
97 |
|
98 | (function(module) {
|
99 |
|
100 | module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
|
101 |
|
102 | })
|
103 | ]);
|
104 |
|
105 |
|
106 | var __webpack_module_cache__ = {};
|
107 |
|
108 |
|
109 | function __webpack_require__(moduleId) {
|
110 |
|
111 | var cachedModule = __webpack_module_cache__[moduleId];
|
112 | if (cachedModule !== undefined) {
|
113 | return cachedModule.exports;
|
114 | }
|
115 |
|
116 | var module = __webpack_module_cache__[moduleId] = {
|
117 |
|
118 |
|
119 | exports: {}
|
120 | };
|
121 |
|
122 |
|
123 | __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
124 |
|
125 |
|
126 | return module.exports;
|
127 | }
|
128 |
|
129 |
|
130 |
|
131 | !function() {
|
132 |
|
133 | __webpack_require__.d = function(exports, definition) {
|
134 | for(var key in definition) {
|
135 | if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
136 | Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
137 | }
|
138 | }
|
139 | };
|
140 | }();
|
141 |
|
142 |
|
143 | !function() {
|
144 | __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
145 | }();
|
146 |
|
147 |
|
148 | !function() {
|
149 |
|
150 | __webpack_require__.r = function(exports) {
|
151 | if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
152 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
153 | }
|
154 | Object.defineProperty(exports, '__esModule', { value: true });
|
155 | };
|
156 | }();
|
157 |
|
158 |
|
159 | var __webpack_exports__ = {};
|
160 |
|
161 | !function() {
|
162 |
|
163 |
|
164 | }();
|
165 |
|
166 | !function() {
|
167 |
|
168 | __webpack_require__.r(__webpack_exports__);
|
169 |
|
170 |
|
171 | __webpack_require__.d(__webpack_exports__, {
|
172 | bb: function() { return bb; },
|
173 | "default": function() { return bb; }
|
174 | });
|
175 |
|
176 |
|
177 | var resolver_interaction_namespaceObject = {};
|
178 | __webpack_require__.r(resolver_interaction_namespaceObject);
|
179 | __webpack_require__.d(resolver_interaction_namespaceObject, {
|
180 | selection: function() { return selectionModule; },
|
181 | subchart: function() { return subchartModule; },
|
182 | zoom: function() { return zoomModule; }
|
183 | });
|
184 |
|
185 |
|
186 | var resolver_shape_namespaceObject = {};
|
187 | __webpack_require__.r(resolver_shape_namespaceObject);
|
188 | __webpack_require__.d(resolver_shape_namespaceObject, {
|
189 | area: function() { return resolver_shape_area; },
|
190 | areaLineRange: function() { return areaLineRange; },
|
191 | areaSpline: function() { return areaSpline; },
|
192 | areaSplineRange: function() { return areaSplineRange; },
|
193 | areaStep: function() { return areaStep; },
|
194 | areaStepRange: function() { return areaStepRange; },
|
195 | bar: function() { return resolver_shape_bar; },
|
196 | bubble: function() { return resolver_shape_bubble; },
|
197 | candlestick: function() { return resolver_shape_candlestick; },
|
198 | donut: function() { return shape_donut; },
|
199 | funnel: function() { return resolver_shape_funnel; },
|
200 | gauge: function() { return resolver_shape_gauge; },
|
201 | line: function() { return resolver_shape_line; },
|
202 | pie: function() { return shape_pie; },
|
203 | polar: function() { return resolver_shape_polar; },
|
204 | radar: function() { return resolver_shape_radar; },
|
205 | scatter: function() { return shape_scatter; },
|
206 | spline: function() { return shape_spline; },
|
207 | step: function() { return step; },
|
208 | treemap: function() { return resolver_shape_treemap; }
|
209 | });
|
210 |
|
211 |
|
212 | var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(2);
|
213 |
|
214 | var external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_ = __webpack_require__(3);
|
215 | ;
|
216 | var __defProp = Object.defineProperty;
|
217 | var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
218 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
219 | var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
220 | var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
221 | var __spreadValues = (a, b) => {
|
222 | for (var prop in b || (b = {}))
|
223 | if (__hasOwnProp.call(b, prop))
|
224 | __defNormalProp(a, prop, b[prop]);
|
225 | if (__getOwnPropSymbols)
|
226 | for (var prop of __getOwnPropSymbols(b)) {
|
227 | if (__propIsEnum.call(b, prop))
|
228 | __defNormalProp(a, prop, b[prop]);
|
229 | }
|
230 | return a;
|
231 | };
|
232 | const $COMMON = {
|
233 | button: "bb-button",
|
234 | chart: "bb-chart",
|
235 | empty: "bb-empty",
|
236 | main: "bb-main",
|
237 | target: "bb-target",
|
238 | EXPANDED: "_expanded_"
|
239 | };
|
240 | const $ARC = {
|
241 | arc: "bb-arc",
|
242 | arcLabelLine: "bb-arc-label-line",
|
243 | arcRange: "bb-arc-range",
|
244 | arcs: "bb-arcs",
|
245 | chartArc: "bb-chart-arc",
|
246 | chartArcs: "bb-chart-arcs",
|
247 | chartArcsBackground: "bb-chart-arcs-background",
|
248 | chartArcsTitle: "bb-chart-arcs-title",
|
249 | needle: "bb-needle"
|
250 | };
|
251 | const $AREA = {
|
252 | area: "bb-area",
|
253 | areas: "bb-areas"
|
254 | };
|
255 | const $AXIS = {
|
256 | axis: "bb-axis",
|
257 | axisX: "bb-axis-x",
|
258 | axisXLabel: "bb-axis-x-label",
|
259 | axisY: "bb-axis-y",
|
260 | axisY2: "bb-axis-y2",
|
261 | axisY2Label: "bb-axis-y2-label",
|
262 | axisYLabel: "bb-axis-y-label",
|
263 | axisXTooltip: "bb-axis-x-tooltip",
|
264 | axisYTooltip: "bb-axis-y-tooltip",
|
265 | axisY2Tooltip: "bb-axis-y2-tooltip"
|
266 | };
|
267 | const $BAR = {
|
268 | bar: "bb-bar",
|
269 | bars: "bb-bars",
|
270 | chartBar: "bb-chart-bar",
|
271 | chartBars: "bb-chart-bars"
|
272 | };
|
273 | const $CANDLESTICK = {
|
274 | candlestick: "bb-candlestick",
|
275 | candlesticks: "bb-candlesticks",
|
276 | chartCandlestick: "bb-chart-candlestick",
|
277 | chartCandlesticks: "bb-chart-candlesticks",
|
278 | valueDown: "bb-value-down",
|
279 | valueUp: "bb-value-up"
|
280 | };
|
281 | const $CIRCLE = {
|
282 | chartCircles: "bb-chart-circles",
|
283 | circle: "bb-circle",
|
284 | circles: "bb-circles"
|
285 | };
|
286 | const $COLOR = {
|
287 | colorPattern: "bb-color-pattern",
|
288 | colorScale: "bb-colorscale"
|
289 | };
|
290 | const $DRAG = {
|
291 | dragarea: "bb-dragarea",
|
292 | INCLUDED: "_included_"
|
293 | };
|
294 | const $FUNNEL = {
|
295 | funnel: "bb-funnel",
|
296 | chartFunnel: "bb-chart-funnel",
|
297 | chartFunnels: "bb-chart-funnels",
|
298 | funnelBackground: "bb-funnel-background"
|
299 | };
|
300 | const $GAUGE = {
|
301 | chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
|
302 | chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
|
303 | chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
|
304 | chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
|
305 | gaugeValue: "bb-gauge-value"
|
306 | };
|
307 | const $LEGEND = {
|
308 | legend: "bb-legend",
|
309 | legendBackground: "bb-legend-background",
|
310 | legendItem: "bb-legend-item",
|
311 | legendItemEvent: "bb-legend-item-event",
|
312 | legendItemHidden: "bb-legend-item-hidden",
|
313 | legendItemPoint: "bb-legend-item-point",
|
314 | legendItemTile: "bb-legend-item-tile"
|
315 | };
|
316 | const $LINE = {
|
317 | chartLine: "bb-chart-line",
|
318 | chartLines: "bb-chart-lines",
|
319 | line: "bb-line",
|
320 | lines: "bb-lines"
|
321 | };
|
322 | const $EVENT = {
|
323 | eventRect: "bb-event-rect",
|
324 | eventRects: "bb-event-rects",
|
325 | eventRectsMultiple: "bb-event-rects-multiple",
|
326 | eventRectsSingle: "bb-event-rects-single"
|
327 | };
|
328 | const $FOCUS = {
|
329 | focused: "bb-focused",
|
330 | defocused: "bb-defocused",
|
331 | legendItemFocused: "bb-legend-item-focused",
|
332 | xgridFocus: "bb-xgrid-focus",
|
333 | ygridFocus: "bb-ygrid-focus"
|
334 | };
|
335 | const $GRID = {
|
336 | grid: "bb-grid",
|
337 | gridLines: "bb-grid-lines",
|
338 | xgrid: "bb-xgrid",
|
339 | xgridLine: "bb-xgrid-line",
|
340 | xgridLines: "bb-xgrid-lines",
|
341 | xgrids: "bb-xgrids",
|
342 | ygrid: "bb-ygrid",
|
343 | ygridLine: "bb-ygrid-line",
|
344 | ygridLines: "bb-ygrid-lines",
|
345 | ygrids: "bb-ygrids"
|
346 | };
|
347 | const $LEVEL = {
|
348 | level: "bb-level",
|
349 | levels: "bb-levels"
|
350 | };
|
351 | const $RADAR = {
|
352 | chartRadar: "bb-chart-radar",
|
353 | chartRadars: "bb-chart-radars"
|
354 | };
|
355 | const $REGION = {
|
356 | region: "bb-region",
|
357 | regions: "bb-regions"
|
358 | };
|
359 | const $SELECT = {
|
360 | selectedCircle: "bb-selected-circle",
|
361 | selectedCircles: "bb-selected-circles",
|
362 | SELECTED: "_selected_"
|
363 | };
|
364 | const $SHAPE = {
|
365 | shape: "bb-shape",
|
366 | shapes: "bb-shapes"
|
367 | };
|
368 | const $SUBCHART = {
|
369 | brush: "bb-brush",
|
370 | subchart: "bb-subchart"
|
371 | };
|
372 | const $TEXT = {
|
373 | chartText: "bb-chart-text",
|
374 | chartTexts: "bb-chart-texts",
|
375 | text: "bb-text",
|
376 | texts: "bb-texts",
|
377 | title: "bb-title",
|
378 | TextOverlapping: "text-overlapping"
|
379 | };
|
380 | const $TOOLTIP = {
|
381 | tooltip: "bb-tooltip",
|
382 | tooltipContainer: "bb-tooltip-container",
|
383 | tooltipName: "bb-tooltip-name"
|
384 | };
|
385 | const $TREEMAP = {
|
386 | treemap: "bb-treemap",
|
387 | chartTreemap: "bb-chart-treemap",
|
388 | chartTreemaps: "bb-chart-treemaps"
|
389 | };
|
390 | const $ZOOM = {
|
391 | buttonZoomReset: "bb-zoom-reset",
|
392 | zoomBrush: "bb-zoom-brush"
|
393 | };
|
394 | var classes = (__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, $COMMON), $ARC), $AREA), $AXIS), $BAR), $CANDLESTICK), $CIRCLE), $COLOR), $DRAG), $GAUGE), $LEGEND), $LINE), $EVENT), $FOCUS), $FUNNEL), $GRID), $RADAR), $REGION), $SELECT), $SHAPE), $SUBCHART), $TEXT), $TOOLTIP), $TREEMAP), $ZOOM));
|
395 |
|
396 | ;
|
397 | var boost = ({
|
398 | |
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 | boost_useCssRule: false,
|
419 | boost_useWorker: false
|
420 | });
|
421 |
|
422 | ;
|
423 | var color = ({
|
424 | |
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 | color_pattern: [],
|
499 | color_tiles: void 0,
|
500 | color_threshold: {},
|
501 | color_onover: void 0
|
502 | });
|
503 |
|
504 | ;
|
505 | var legend = ({
|
506 | |
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 | legend_contents_bindto: void 0,
|
652 | legend_contents_template: "<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>",
|
653 | legend_equally: false,
|
654 | legend_hide: false,
|
655 | legend_inset_anchor: "top-left",
|
656 | legend_inset_x: 10,
|
657 | legend_inset_y: 0,
|
658 | legend_inset_step: void 0,
|
659 | legend_item_interaction: true,
|
660 | legend_item_dblclick: false,
|
661 | legend_item_onclick: void 0,
|
662 | legend_item_onover: void 0,
|
663 | legend_item_onout: void 0,
|
664 | legend_item_tile_width: 10,
|
665 | legend_item_tile_height: 10,
|
666 | legend_item_tile_r: 5,
|
667 | legend_item_tile_type: "rectangle",
|
668 | legend_format: void 0,
|
669 | legend_padding: 0,
|
670 | legend_position: "bottom",
|
671 | legend_show: true,
|
672 | legend_tooltip: false,
|
673 | legend_usePoint: false
|
674 | });
|
675 |
|
676 | ;
|
677 | var main = ({
|
678 | |
679 |
|
680 |
|
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 | bindto: "#chart",
|
705 | |
706 |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 |
|
721 |
|
722 |
|
723 |
|
724 | background: {},
|
725 | |
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 | clipPath: true,
|
740 | |
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 |
|
752 | svg_classname: void 0,
|
753 | |
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 |
|
769 | size_width: void 0,
|
770 | size_height: void 0,
|
771 | |
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 |
|
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 |
|
795 |
|
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 |
|
802 |
|
803 |
|
804 |
|
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 |
|
812 |
|
813 |
|
814 | padding: true,
|
815 | padding_mode: void 0,
|
816 | padding_left: void 0,
|
817 | padding_right: void 0,
|
818 | padding_top: void 0,
|
819 | padding_bottom: void 0,
|
820 | |
821 |
|
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 |
|
833 |
|
834 |
|
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 | resize_auto: true,
|
856 | resize_timer: true,
|
857 | |
858 |
|
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 | onclick: void 0,
|
871 | |
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 | onover: void 0,
|
885 | |
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 | onout: void 0,
|
899 | |
900 |
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 | onresize: void 0,
|
912 | |
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 | onresized: void 0,
|
925 | |
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 | onbeforeinit: void 0,
|
938 | |
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 | oninit: void 0,
|
951 | |
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 | onafterinit: void 0,
|
964 | |
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 | onrendered: void 0,
|
977 | |
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 | transition_duration: 250,
|
991 | |
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 | plugins: [],
|
1004 | |
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 | render: {},
|
1048 | |
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 | regions: []
|
1079 | });
|
1080 |
|
1081 | ;
|
1082 | var title = ({
|
1083 | |
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 | title_text: void 0,
|
1113 | title_padding: {
|
1114 | top: 0,
|
1115 | right: 0,
|
1116 | bottom: 0,
|
1117 | left: 0
|
1118 | },
|
1119 | title_position: "center"
|
1120 | });
|
1121 |
|
1122 | ;
|
1123 | var tooltip = ({
|
1124 | |
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 |
|
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
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 |
|
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 | tooltip_show: true,
|
1347 | tooltip_doNotHide: false,
|
1348 | tooltip_grouped: true,
|
1349 | tooltip_format_title: void 0,
|
1350 | tooltip_format_name: void 0,
|
1351 | tooltip_format_value: void 0,
|
1352 | tooltip_position: void 0,
|
1353 | tooltip_contents: {},
|
1354 | tooltip_init_show: false,
|
1355 | tooltip_init_x: 0,
|
1356 | tooltip_init_position: void 0,
|
1357 | tooltip_linked: false,
|
1358 | tooltip_linked_name: "",
|
1359 | tooltip_onshow: () => {
|
1360 | },
|
1361 | tooltip_onhide: () => {
|
1362 | },
|
1363 | tooltip_onshown: () => {
|
1364 | },
|
1365 | tooltip_onhidden: () => {
|
1366 | },
|
1367 | tooltip_order: null
|
1368 | });
|
1369 |
|
1370 | ;
|
1371 | var data = ({
|
1372 | |
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 | data_x: void 0,
|
1385 | |
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 | data_idConverter: (id) => id,
|
1405 | |
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 | data_names: {},
|
1422 | |
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 | data_classes: {},
|
1438 | |
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 |
|
1498 |
|
1499 |
|
1500 |
|
1501 |
|
1502 |
|
1503 | data_type: void 0,
|
1504 | |
1505 |
|
1506 |
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 |
|
1522 |
|
1523 |
|
1524 |
|
1525 |
|
1526 |
|
1527 |
|
1528 |
|
1529 |
|
1530 |
|
1531 |
|
1532 |
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 |
|
1541 |
|
1542 |
|
1543 |
|
1544 |
|
1545 |
|
1546 |
|
1547 |
|
1548 |
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 | data_types: {},
|
1556 | |
1557 |
|
1558 |
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 |
|
1571 |
|
1572 |
|
1573 |
|
1574 |
|
1575 |
|
1576 |
|
1577 |
|
1578 |
|
1579 |
|
1580 |
|
1581 |
|
1582 |
|
1583 |
|
1584 |
|
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 |
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 |
|
1603 |
|
1604 |
|
1605 |
|
1606 | data_order: "desc",
|
1607 | |
1608 |
|
1609 |
|
1610 |
|
1611 |
|
1612 |
|
1613 |
|
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 | data_groups: [],
|
1622 | |
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 |
|
1638 | data_groupsZeroAs: "positive",
|
1639 | |
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 |
|
1645 |
|
1646 |
|
1647 |
|
1648 |
|
1649 |
|
1650 |
|
1651 |
|
1652 | data_color: void 0,
|
1653 | |
1654 |
|
1655 |
|
1656 |
|
1657 |
|
1658 |
|
1659 |
|
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 |
|
1670 | data_colors: {},
|
1671 | |
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 |
|
1682 |
|
1683 |
|
1684 |
|
1685 |
|
1686 |
|
1687 |
|
1688 |
|
1689 |
|
1690 |
|
1691 |
|
1692 |
|
1693 |
|
1694 |
|
1695 |
|
1696 |
|
1697 |
|
1698 |
|
1699 |
|
1700 |
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 |
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 |
|
1715 |
|
1716 |
|
1717 |
|
1718 |
|
1719 |
|
1720 |
|
1721 |
|
1722 |
|
1723 |
|
1724 |
|
1725 |
|
1726 |
|
1727 |
|
1728 |
|
1729 |
|
1730 |
|
1731 |
|
1732 |
|
1733 |
|
1734 |
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
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 | data_labels: {},
|
1784 | data_labels_backgroundColors: void 0,
|
1785 | data_labels_colors: void 0,
|
1786 | data_labels_position: {},
|
1787 | |
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 |
|
1800 |
|
1801 |
|
1802 |
|
1803 | data_hide: false,
|
1804 | |
1805 |
|
1806 |
|
1807 |
|
1808 |
|
1809 |
|
1810 |
|
1811 |
|
1812 |
|
1813 |
|
1814 |
|
1815 |
|
1816 |
|
1817 |
|
1818 |
|
1819 |
|
1820 |
|
1821 |
|
1822 | data_filter: void 0,
|
1823 | |
1824 |
|
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 |
|
1830 |
|
1831 |
|
1832 |
|
1833 |
|
1834 |
|
1835 |
|
1836 |
|
1837 |
|
1838 |
|
1839 |
|
1840 |
|
1841 |
|
1842 | data_onclick: () => {
|
1843 | },
|
1844 | |
1845 |
|
1846 |
|
1847 |
|
1848 |
|
1849 |
|
1850 |
|
1851 |
|
1852 |
|
1853 |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 |
|
1859 |
|
1860 |
|
1861 |
|
1862 |
|
1863 | data_onover: () => {
|
1864 | },
|
1865 | |
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 |
|
1873 |
|
1874 |
|
1875 |
|
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 |
|
1884 | data_onout: () => {
|
1885 | },
|
1886 | |
1887 |
|
1888 |
|
1889 |
|
1890 |
|
1891 |
|
1892 |
|
1893 |
|
1894 |
|
1895 |
|
1896 |
|
1897 |
|
1898 |
|
1899 |
|
1900 |
|
1901 | data_onshown: void 0,
|
1902 | |
1903 |
|
1904 |
|
1905 |
|
1906 |
|
1907 |
|
1908 |
|
1909 |
|
1910 |
|
1911 |
|
1912 |
|
1913 |
|
1914 |
|
1915 |
|
1916 |
|
1917 | data_onhidden: void 0,
|
1918 | |
1919 |
|
1920 |
|
1921 |
|
1922 |
|
1923 |
|
1924 |
|
1925 |
|
1926 |
|
1927 |
|
1928 |
|
1929 |
|
1930 |
|
1931 |
|
1932 | data_onmin: void 0,
|
1933 | |
1934 |
|
1935 |
|
1936 |
|
1937 |
|
1938 |
|
1939 |
|
1940 |
|
1941 |
|
1942 |
|
1943 |
|
1944 |
|
1945 |
|
1946 |
|
1947 | data_onmax: void 0,
|
1948 | |
1949 |
|
1950 |
|
1951 |
|
1952 |
|
1953 |
|
1954 |
|
1955 |
|
1956 |
|
1957 |
|
1958 |
|
1959 |
|
1960 | data_url: void 0,
|
1961 | |
1962 |
|
1963 |
|
1964 |
|
1965 |
|
1966 |
|
1967 |
|
1968 |
|
1969 |
|
1970 |
|
1971 |
|
1972 |
|
1973 |
|
1974 |
|
1975 |
|
1976 |
|
1977 |
|
1978 | data_headers: void 0,
|
1979 | |
1980 |
|
1981 |
|
1982 |
|
1983 |
|
1984 |
|
1985 |
|
1986 |
|
1987 |
|
1988 |
|
1989 |
|
1990 |
|
1991 |
|
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 |
|
1997 |
|
1998 |
|
1999 |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 | data_json: void 0,
|
2006 | |
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 |
|
2012 |
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 |
|
2027 |
|
2028 |
|
2029 |
|
2030 |
|
2031 |
|
2032 |
|
2033 |
|
2034 |
|
2035 |
|
2036 |
|
2037 |
|
2038 |
|
2039 |
|
2040 |
|
2041 |
|
2042 |
|
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 |
|
2050 |
|
2051 |
|
2052 |
|
2053 |
|
2054 |
|
2055 |
|
2056 |
|
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 |
|
2066 |
|
2067 |
|
2068 |
|
2069 |
|
2070 |
|
2071 |
|
2072 |
|
2073 |
|
2074 |
|
2075 |
|
2076 |
|
2077 |
|
2078 |
|
2079 |
|
2080 |
|
2081 |
|
2082 |
|
2083 |
|
2084 |
|
2085 |
|
2086 |
|
2087 |
|
2088 |
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 |
|
2095 |
|
2096 | data_rows: void 0,
|
2097 | |
2098 |
|
2099 |
|
2100 |
|
2101 |
|
2102 |
|
2103 |
|
2104 |
|
2105 |
|
2106 |
|
2107 |
|
2108 |
|
2109 |
|
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 |
|
2117 |
|
2118 |
|
2119 |
|
2120 |
|
2121 |
|
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 |
|
2130 |
|
2131 |
|
2132 |
|
2133 |
|
2134 |
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 |
|
2140 |
|
2141 |
|
2142 |
|
2143 |
|
2144 |
|
2145 |
|
2146 |
|
2147 |
|
2148 |
|
2149 |
|
2150 |
|
2151 |
|
2152 |
|
2153 |
|
2154 |
|
2155 |
|
2156 |
|
2157 |
|
2158 |
|
2159 |
|
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 |
|
2165 | data_columns: void 0,
|
2166 | |
2167 |
|
2168 |
|
2169 |
|
2170 |
|
2171 |
|
2172 |
|
2173 |
|
2174 |
|
2175 |
|
2176 |
|
2177 |
|
2178 |
|
2179 |
|
2180 |
|
2181 | data_mimeType: "csv",
|
2182 | |
2183 |
|
2184 |
|
2185 |
|
2186 |
|
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 |
|
2194 |
|
2195 |
|
2196 |
|
2197 |
|
2198 |
|
2199 |
|
2200 |
|
2201 |
|
2202 |
|
2203 |
|
2204 |
|
2205 |
|
2206 |
|
2207 | data_keys: void 0,
|
2208 | |
2209 |
|
2210 |
|
2211 |
|
2212 |
|
2213 |
|
2214 |
|
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 |
|
2220 |
|
2221 |
|
2222 |
|
2223 |
|
2224 | data_empty_label_text: ""
|
2225 | });
|
2226 |
|
2227 | ;
|
2228 | var interaction = ({
|
2229 | |
2230 |
|
2231 |
|
2232 |
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 |
|
2241 |
|
2242 |
|
2243 |
|
2244 |
|
2245 |
|
2246 |
|
2247 |
|
2248 |
|
2249 |
|
2250 |
|
2251 |
|
2252 |
|
2253 |
|
2254 |
|
2255 |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 |
|
2264 |
|
2265 |
|
2266 | interaction_enabled: true,
|
2267 | interaction_brighten: true,
|
2268 | interaction_inputType_mouse: true,
|
2269 | interaction_inputType_touch: {},
|
2270 | interaction_onout: true
|
2271 | });
|
2272 |
|
2273 |
|
2274 | var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(4);
|
2275 | ;
|
2276 | function getGlobal() {
|
2277 | return 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 || Function("return this")();
|
2278 | }
|
2279 | function getFallback(w) {
|
2280 | const hasRAF = typeof (w == null ? void 0 : w.requestAnimationFrame) === "function" && typeof (w == null ? void 0 : w.cancelAnimationFrame) === "function";
|
2281 | const hasRIC = typeof (w == null ? void 0 : w.requestIdleCallback) === "function" && typeof (w == null ? void 0 : w.cancelIdleCallback) === "function";
|
2282 | const request = (cb) => setTimeout(cb, 1);
|
2283 | const cancel = (id) => clearTimeout(id);
|
2284 | return [
|
2285 | hasRAF ? w.requestAnimationFrame : request,
|
2286 | hasRAF ? w.cancelAnimationFrame : cancel,
|
2287 | hasRIC ? w.requestIdleCallback : request,
|
2288 | hasRIC ? w.cancelIdleCallback : cancel
|
2289 | ];
|
2290 | }
|
2291 | const win = getGlobal();
|
2292 | const browser_doc = win == null ? void 0 : win.document;
|
2293 | const [
|
2294 | requestAnimationFrame,
|
2295 | cancelAnimationFrame,
|
2296 | requestIdleCallback,
|
2297 | cancelIdleCallback
|
2298 | ] = getFallback(win);
|
2299 |
|
2300 |
|
2301 | ;
|
2302 | var util_defProp = Object.defineProperty;
|
2303 | var util_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
2304 | var util_hasOwnProp = Object.prototype.hasOwnProperty;
|
2305 | var util_propIsEnum = Object.prototype.propertyIsEnumerable;
|
2306 | var util_defNormalProp = (obj, key, value) => key in obj ? util_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2307 | var util_spreadValues = (a, b) => {
|
2308 | for (var prop in b || (b = {}))
|
2309 | if (util_hasOwnProp.call(b, prop))
|
2310 | util_defNormalProp(a, prop, b[prop]);
|
2311 | if (util_getOwnPropSymbols)
|
2312 | for (var prop of util_getOwnPropSymbols(b)) {
|
2313 | if (util_propIsEnum.call(b, prop))
|
2314 | util_defNormalProp(a, prop, b[prop]);
|
2315 | }
|
2316 | return a;
|
2317 | };
|
2318 |
|
2319 |
|
2320 |
|
2321 |
|
2322 | const isValue = (v) => v || v === 0;
|
2323 | const isFunction = (v) => typeof v === "function";
|
2324 | const isString = (v) => typeof v === "string";
|
2325 | const isNumber = (v) => typeof v === "number";
|
2326 | const isUndefined = (v) => typeof v === "undefined";
|
2327 | const isDefined = (v) => typeof v !== "undefined";
|
2328 | const isBoolean = (v) => typeof v === "boolean";
|
2329 | const ceil10 = (v) => Math.ceil(v / 10) * 10;
|
2330 | const asHalfPixel = (n) => Math.ceil(n) + 0.5;
|
2331 | const diffDomain = (d) => d[1] - d[0];
|
2332 | const isObjectType = (v) => typeof v === "object";
|
2333 | const isEmpty = (o) => isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
|
2334 | const notEmpty = (o) => !isEmpty(o);
|
2335 | const isArray = (arr) => Array.isArray(arr);
|
2336 | const isObject = (obj) => obj && !(obj == null ? void 0 : obj.nodeType) && isObjectType(obj) && !isArray(obj);
|
2337 | function getOption(options, key, defaultValue) {
|
2338 | return isDefined(options[key]) ? options[key] : defaultValue;
|
2339 | }
|
2340 | function hasValue(dict, value) {
|
2341 | let found = false;
|
2342 | Object.keys(dict).forEach((key) => dict[key] === value && (found = true));
|
2343 | return found;
|
2344 | }
|
2345 | function callFn(fn, thisArg, ...args) {
|
2346 | const isFn = isFunction(fn);
|
2347 | isFn && fn.call(thisArg, ...args);
|
2348 | return isFn;
|
2349 | }
|
2350 | function endall(transition, cb) {
|
2351 | let n = 0;
|
2352 | const end = function(...args) {
|
2353 | !--n && cb.apply(this, ...args);
|
2354 | };
|
2355 | if ("duration" in transition) {
|
2356 | transition.each(() => ++n).on("end", end);
|
2357 | } else {
|
2358 | ++n;
|
2359 | transition.call(end);
|
2360 | }
|
2361 | }
|
2362 | function sanitize(str) {
|
2363 | return isString(str) ? str.replace(/<(script|img)?/ig, "<").replace(/(script)?>/ig, ">") : str;
|
2364 | }
|
2365 | function setTextValue(node, text, dy = [-1, 1], toMiddle = false) {
|
2366 | if (!node || !isString(text)) {
|
2367 | return;
|
2368 | }
|
2369 | if (text.indexOf("\n") === -1) {
|
2370 | node.text(text);
|
2371 | } else {
|
2372 | const diff = [node.text(), text].map((v) => v.replace(/[\s\n]/g, ""));
|
2373 | if (diff[0] !== diff[1]) {
|
2374 | const multiline = text.split("\n");
|
2375 | const len = toMiddle ? multiline.length - 1 : 1;
|
2376 | node.html("");
|
2377 | multiline.forEach((v, i) => {
|
2378 | node.append("tspan").attr("x", 0).attr("dy", `${i === 0 ? dy[0] * len : dy[1]}em`).text(v);
|
2379 | });
|
2380 | }
|
2381 | }
|
2382 | }
|
2383 | function getRectSegList(path) {
|
2384 | const { x, y, width, height } = path.getBBox();
|
2385 | return [
|
2386 | { x, y: y + height },
|
2387 |
|
2388 | { x, y },
|
2389 |
|
2390 | { x: x + width, y },
|
2391 |
|
2392 | { x: x + width, y: y + height }
|
2393 |
|
2394 | ];
|
2395 | }
|
2396 | function getPathBox(path) {
|
2397 | const { width, height } = path.getBoundingClientRect();
|
2398 | const items = getRectSegList(path);
|
2399 | const x = items[0].x;
|
2400 | const y = Math.min(items[0].y, items[1].y);
|
2401 | return {
|
2402 | x,
|
2403 | y,
|
2404 | width,
|
2405 | height
|
2406 | };
|
2407 | }
|
2408 | function getPointer(event, element) {
|
2409 | var _a;
|
2410 | const touches = event && ((_a = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _a[0]);
|
2411 | let pointer = [0, 0];
|
2412 | try {
|
2413 | pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element);
|
2414 | } catch (e) {
|
2415 | }
|
2416 | return pointer.map((v) => isNaN(v) ? 0 : v);
|
2417 | }
|
2418 | function getBrushSelection(ctx) {
|
2419 | const { event, $el } = ctx;
|
2420 | const main = $el.subchart.main || $el.main;
|
2421 | let selection;
|
2422 | if (event && event.type === "brush") {
|
2423 | selection = event.selection;
|
2424 | } else if (main && (selection = main.select(".bb-brush").node())) {
|
2425 | selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection);
|
2426 | }
|
2427 | return selection;
|
2428 | }
|
2429 | function getBoundingRect(node) {
|
2430 | const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
|
2431 | return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
|
2432 | }
|
2433 | function getRandom(asStr = true, min = 0, max = 1e4) {
|
2434 | const crpt = win.crypto || win.msCrypto;
|
2435 | const rand = crpt ? min + crpt.getRandomValues(new Uint32Array(1))[0] % (max - min + 1) : Math.floor(Math.random() * (max - min) + min);
|
2436 | return asStr ? String(rand) : rand;
|
2437 | }
|
2438 | function findIndex(arr, v, start, end, isRotated) {
|
2439 | if (start > end) {
|
2440 | return -1;
|
2441 | }
|
2442 | const mid = Math.floor((start + end) / 2);
|
2443 | let { x, w = 0 } = arr[mid];
|
2444 | if (isRotated) {
|
2445 | x = arr[mid].y;
|
2446 | w = arr[mid].h;
|
2447 | }
|
2448 | if (v >= x && v <= x + w) {
|
2449 | return mid;
|
2450 | }
|
2451 | return v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
|
2452 | }
|
2453 | function brushEmpty(ctx) {
|
2454 | const selection = getBrushSelection(ctx);
|
2455 | if (selection) {
|
2456 | return selection[0] === selection[1];
|
2457 | }
|
2458 | return true;
|
2459 | }
|
2460 | function deepClone(...objectN) {
|
2461 | const clone = (v) => {
|
2462 | if (isObject(v) && v.constructor) {
|
2463 | const r = new v.constructor();
|
2464 | for (const k in v) {
|
2465 | r[k] = clone(v[k]);
|
2466 | }
|
2467 | return r;
|
2468 | }
|
2469 | return v;
|
2470 | };
|
2471 | return objectN.map((v) => clone(v)).reduce((a, c) => util_spreadValues(util_spreadValues({}, a), c));
|
2472 | }
|
2473 | function extend(target = {}, source) {
|
2474 | if (isArray(source)) {
|
2475 | source.forEach((v) => extend(target, v));
|
2476 | }
|
2477 | for (const p in source) {
|
2478 | if (/^\d+$/.test(p) || p in target) {
|
2479 | continue;
|
2480 | }
|
2481 | target[p] = source[p];
|
2482 | }
|
2483 | return target;
|
2484 | }
|
2485 | const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
2486 | function camelize(str, separator = "-") {
|
2487 | return str.split(separator).map((v, i) => i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase()).join("");
|
2488 | }
|
2489 | const toArray = (v) => [].slice.call(v);
|
2490 | function addCssRules(style, selector, prop) {
|
2491 | const { rootSelector = "", sheet } = style;
|
2492 | const getSelector = (s) => s.replace(/\s?(bb-)/g, ".$1").replace(/\.+/g, ".");
|
2493 | const rule = `${rootSelector} ${getSelector(selector)} {${prop.join(";")}}`;
|
2494 | return sheet[sheet.insertRule ? "insertRule" : "addRule"](
|
2495 | rule,
|
2496 | sheet.cssRules.length
|
2497 | );
|
2498 | }
|
2499 | function getCssRules(styleSheets) {
|
2500 | let rules = [];
|
2501 | styleSheets.forEach((sheet) => {
|
2502 | var _a;
|
2503 | try {
|
2504 | if (sheet.cssRules && sheet.cssRules.length) {
|
2505 | rules = rules.concat(toArray(sheet.cssRules));
|
2506 | }
|
2507 | } catch (e) {
|
2508 | (_a = win.console) == null ? void 0 : _a.warn(`Error while reading rules from ${sheet.href}: ${e.toString()}`);
|
2509 | }
|
2510 | });
|
2511 | return rules;
|
2512 | }
|
2513 | function getScrollPosition(node) {
|
2514 | var _a, _b, _c, _d, _e, _f;
|
2515 | return {
|
2516 | x: ((_b = (_a = win.pageXOffset) != null ? _a : win.scrollX) != null ? _b : 0) + ((_c = node.scrollLeft) != null ? _c : 0),
|
2517 | y: ((_e = (_d = win.pageYOffset) != null ? _d : win.scrollY) != null ? _e : 0) + ((_f = node.scrollTop) != null ? _f : 0)
|
2518 | };
|
2519 | }
|
2520 | function getTransformCTM(node, x = 0, y = 0, inverse = true) {
|
2521 | const point = new DOMPoint(x, y);
|
2522 | const screen = node.getScreenCTM();
|
2523 | const res = point.matrixTransform(
|
2524 | inverse ? screen == null ? void 0 : screen.inverse() : screen
|
2525 | );
|
2526 | if (inverse === false) {
|
2527 | const rect = node.getBoundingClientRect();
|
2528 | res.x -= rect.x;
|
2529 | res.y -= rect.y;
|
2530 | }
|
2531 | return res;
|
2532 | }
|
2533 | function getTranslation(node) {
|
2534 | const transform = node ? node.transform : null;
|
2535 | const baseVal = transform && transform.baseVal;
|
2536 | return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : { a: 0, b: 0, c: 0, d: 0, e: 0, f: 0 };
|
2537 | }
|
2538 | function getUnique(data) {
|
2539 | const isDate = data[0] instanceof Date;
|
2540 | const d = (isDate ? data.map(Number) : data).filter((v, i, self) => self.indexOf(v) === i);
|
2541 | return isDate ? d.map((v) => new Date(v)) : d;
|
2542 | }
|
2543 | function mergeArray(arr) {
|
2544 | return arr && arr.length ? arr.reduce((p, c) => p.concat(c)) : [];
|
2545 | }
|
2546 | function mergeObj(target, ...objectN) {
|
2547 | if (!objectN.length || objectN.length === 1 && !objectN[0]) {
|
2548 | return target;
|
2549 | }
|
2550 | const source = objectN.shift();
|
2551 | if (isObject(target) && isObject(source)) {
|
2552 | Object.keys(source).forEach((key) => {
|
2553 | const value = source[key];
|
2554 | if (isObject(value)) {
|
2555 | !target[key] && (target[key] = {});
|
2556 | target[key] = mergeObj(target[key], value);
|
2557 | } else {
|
2558 | target[key] = isArray(value) ? value.concat() : value;
|
2559 | }
|
2560 | });
|
2561 | }
|
2562 | return mergeObj(target, ...objectN);
|
2563 | }
|
2564 | function sortValue(data, isAsc = true) {
|
2565 | let fn;
|
2566 | if (data[0] instanceof Date) {
|
2567 | fn = isAsc ? (a, b) => a - b : (a, b) => b - a;
|
2568 | } else {
|
2569 | if (isAsc && !data.every(isNaN)) {
|
2570 | fn = (a, b) => a - b;
|
2571 | } else if (!isAsc) {
|
2572 | fn = (a, b) => a > b && -1 || a < b && 1 || a === b && 0;
|
2573 | }
|
2574 | }
|
2575 | return data.concat().sort(fn);
|
2576 | }
|
2577 | function getMinMax(type, data) {
|
2578 | let res = data.filter((v) => notEmpty(v));
|
2579 | if (res.length) {
|
2580 | if (isNumber(res[0])) {
|
2581 | res = Math[type](...res);
|
2582 | } else if (res[0] instanceof Date) {
|
2583 | res = sortValue(res, type === "min")[0];
|
2584 | }
|
2585 | } else {
|
2586 | res = void 0;
|
2587 | }
|
2588 | return res;
|
2589 | }
|
2590 | const getRange = (start, end, step = 1) => {
|
2591 | const res = [];
|
2592 | const n = Math.max(0, Math.ceil((end - start) / step)) | 0;
|
2593 | for (let i = start; i < n; i++) {
|
2594 | res.push(start + i * step);
|
2595 | }
|
2596 | return res;
|
2597 | };
|
2598 | const emulateEvent = {
|
2599 | mouse: (() => {
|
2600 | const getParams = () => ({
|
2601 | bubbles: false,
|
2602 | cancelable: false,
|
2603 | screenX: 0,
|
2604 | screenY: 0,
|
2605 | clientX: 0,
|
2606 | clientY: 0
|
2607 | });
|
2608 | try {
|
2609 | new MouseEvent("t");
|
2610 | return (el, eventType, params = getParams()) => {
|
2611 | el.dispatchEvent(new MouseEvent(eventType, params));
|
2612 | };
|
2613 | } catch (e) {
|
2614 | return (el, eventType, params = getParams()) => {
|
2615 | const mouseEvent = browser_doc.createEvent("MouseEvent");
|
2616 | mouseEvent.initMouseEvent(
|
2617 | eventType,
|
2618 | params.bubbles,
|
2619 | params.cancelable,
|
2620 | win,
|
2621 | 0,
|
2622 |
|
2623 | params.screenX,
|
2624 | params.screenY,
|
2625 | params.clientX,
|
2626 | params.clientY,
|
2627 | false,
|
2628 | false,
|
2629 | false,
|
2630 | false,
|
2631 | 0,
|
2632 | null
|
2633 | );
|
2634 | el.dispatchEvent(mouseEvent);
|
2635 | };
|
2636 | }
|
2637 | })(),
|
2638 | touch: (el, eventType, params) => {
|
2639 | const touchObj = new Touch(mergeObj({
|
2640 | identifier: Date.now(),
|
2641 | target: el,
|
2642 | radiusX: 2.5,
|
2643 | radiusY: 2.5,
|
2644 | rotationAngle: 10,
|
2645 | force: 0.5
|
2646 | }, params));
|
2647 | el.dispatchEvent(new TouchEvent(eventType, {
|
2648 | cancelable: true,
|
2649 | bubbles: true,
|
2650 | shiftKey: true,
|
2651 | touches: [touchObj],
|
2652 | targetTouches: [],
|
2653 | changedTouches: [touchObj]
|
2654 | }));
|
2655 | }
|
2656 | };
|
2657 | function tplProcess(tpl, data) {
|
2658 | let res = tpl;
|
2659 | for (const x in data) {
|
2660 | res = res.replace(new RegExp(`{=${x}}`, "g"), data[x]);
|
2661 | }
|
2662 | return res;
|
2663 | }
|
2664 | function parseDate(date) {
|
2665 | var _a;
|
2666 | let parsedDate;
|
2667 | if (date instanceof Date) {
|
2668 | parsedDate = date;
|
2669 | } else if (isString(date)) {
|
2670 | const { config, format } = this;
|
2671 | parsedDate = (_a = format.dataTime(config.data_xFormat)(date)) != null ? _a : new Date(date);
|
2672 | } else if (isNumber(date) && !isNaN(date)) {
|
2673 | parsedDate = new Date(+date);
|
2674 | }
|
2675 | if (!parsedDate || isNaN(+parsedDate)) {
|
2676 | console && console.error && console.error(`Failed to parse x '${date}' to Date object`);
|
2677 | }
|
2678 | return parsedDate;
|
2679 | }
|
2680 | function hasViewBox(svg) {
|
2681 | const attr = svg.attr("viewBox");
|
2682 | return attr ? /(\d+(\.\d+)?){3}/.test(attr) : false;
|
2683 | }
|
2684 | function hasStyle(node, condition, all = false) {
|
2685 | const isD3Node = !!node.node;
|
2686 | let has = false;
|
2687 | for (const [key, value] of Object.entries(condition)) {
|
2688 | has = isD3Node ? node.style(key) === value : node.style[key] === value;
|
2689 | if (all === false && has) {
|
2690 | break;
|
2691 | }
|
2692 | }
|
2693 | return has;
|
2694 | }
|
2695 | function isTabVisible() {
|
2696 | var _a, _b;
|
2697 | return ((_a = browser_doc) == null ? void 0 : _a.hidden) === false || ((_b = browser_doc) == null ? void 0 : _b.visibilityState) === "visible";
|
2698 | }
|
2699 | function convertInputType(mouse, touch) {
|
2700 | const { DocumentTouch, matchMedia, navigator } = win;
|
2701 | const hasPointerCoarse = matchMedia == null ? void 0 : matchMedia("(pointer:coarse)").matches;
|
2702 | let hasTouch = false;
|
2703 | if (touch) {
|
2704 | if (navigator && "maxTouchPoints" in navigator) {
|
2705 | hasTouch = navigator.maxTouchPoints > 0;
|
2706 | } else if ("ontouchmove" in win || DocumentTouch && browser_doc instanceof DocumentTouch) {
|
2707 | hasTouch = true;
|
2708 | } else {
|
2709 | if (hasPointerCoarse) {
|
2710 | hasTouch = true;
|
2711 | } else {
|
2712 | const UA = navigator.userAgent;
|
2713 | hasTouch = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
|
2714 | }
|
2715 | }
|
2716 | }
|
2717 | const hasMouse = mouse && !hasPointerCoarse && (matchMedia == null ? void 0 : matchMedia("(pointer:fine)").matches);
|
2718 | return hasMouse && "mouse" || hasTouch && "touch" || "mouse";
|
2719 | }
|
2720 | function runUntil(fn, conditionFn) {
|
2721 | if (conditionFn() === false) {
|
2722 | requestAnimationFrame(() => runUntil(fn, conditionFn));
|
2723 | } else {
|
2724 | fn();
|
2725 | }
|
2726 | }
|
2727 |
|
2728 | ;
|
2729 | var Options_defProp = Object.defineProperty;
|
2730 | var Options_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
2731 | var Options_hasOwnProp = Object.prototype.hasOwnProperty;
|
2732 | var Options_propIsEnum = Object.prototype.propertyIsEnumerable;
|
2733 | var Options_defNormalProp = (obj, key, value) => key in obj ? Options_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
2734 | var Options_spreadValues = (a, b) => {
|
2735 | for (var prop in b || (b = {}))
|
2736 | if (Options_hasOwnProp.call(b, prop))
|
2737 | Options_defNormalProp(a, prop, b[prop]);
|
2738 | if (Options_getOwnPropSymbols)
|
2739 | for (var prop of Options_getOwnPropSymbols(b)) {
|
2740 | if (Options_propIsEnum.call(b, prop))
|
2741 | Options_defNormalProp(a, prop, b[prop]);
|
2742 | }
|
2743 | return a;
|
2744 | };
|
2745 | var __publicField = (obj, key, value) => Options_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
2746 |
|
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 |
|
2753 |
|
2754 |
|
2755 | const _Options = class _Options {
|
2756 | static setOptions(options) {
|
2757 | this.data = options.reduce((a, c) => Options_spreadValues(Options_spreadValues({}, a), c), this.data);
|
2758 | }
|
2759 | constructor() {
|
2760 | return deepClone(
|
2761 | main,
|
2762 | boost,
|
2763 | data,
|
2764 | color,
|
2765 | interaction,
|
2766 | legend,
|
2767 | title,
|
2768 | tooltip,
|
2769 | _Options.data
|
2770 | );
|
2771 | }
|
2772 | };
|
2773 | __publicField(_Options, "data", {});
|
2774 | let Options = _Options;
|
2775 |
|
2776 |
|
2777 | ;
|
2778 | class Element {
|
2779 | constructor() {
|
2780 | const element = {
|
2781 | chart: null,
|
2782 | main: null,
|
2783 | svg: null,
|
2784 | axis: {
|
2785 |
|
2786 | x: null,
|
2787 | y: null,
|
2788 | y2: null,
|
2789 | subX: null
|
2790 | },
|
2791 | axisTooltip: {
|
2792 | x: null,
|
2793 | y: null,
|
2794 | y2: null
|
2795 | },
|
2796 | defs: null,
|
2797 | tooltip: null,
|
2798 | legend: null,
|
2799 | title: null,
|
2800 | subchart: {
|
2801 | main: null,
|
2802 |
|
2803 | bar: null,
|
2804 |
|
2805 | line: null,
|
2806 |
|
2807 | area: null
|
2808 |
|
2809 | },
|
2810 | arcs: null,
|
2811 | bar: null,
|
2812 |
|
2813 | candlestick: null,
|
2814 | line: null,
|
2815 |
|
2816 | area: null,
|
2817 |
|
2818 | circle: null,
|
2819 |
|
2820 | radar: null,
|
2821 | text: null,
|
2822 |
|
2823 | grid: {
|
2824 | main: null,
|
2825 |
|
2826 | x: null,
|
2827 |
|
2828 | y: null
|
2829 |
|
2830 | },
|
2831 | gridLines: {
|
2832 | main: null,
|
2833 |
|
2834 | x: null,
|
2835 |
|
2836 | y: null
|
2837 |
|
2838 | },
|
2839 | region: {
|
2840 | main: null,
|
2841 |
|
2842 | list: null
|
2843 |
|
2844 | },
|
2845 | eventRect: null,
|
2846 | zoomResetBtn: null
|
2847 |
|
2848 | };
|
2849 | return element;
|
2850 | }
|
2851 | }
|
2852 |
|
2853 | ;
|
2854 | class State {
|
2855 | constructor() {
|
2856 | return {
|
2857 |
|
2858 | width: 0,
|
2859 | width2: 0,
|
2860 | height: 0,
|
2861 | height2: 0,
|
2862 | margin: {
|
2863 | top: 0,
|
2864 | bottom: 0,
|
2865 | left: 0,
|
2866 | right: 0
|
2867 | },
|
2868 | margin2: {
|
2869 | top: 0,
|
2870 | bottom: 0,
|
2871 | left: 0,
|
2872 | right: 0
|
2873 | },
|
2874 | margin3: {
|
2875 | top: 0,
|
2876 | bottom: 0,
|
2877 | left: 0,
|
2878 | right: 0
|
2879 | },
|
2880 | arcWidth: 0,
|
2881 | arcHeight: 0,
|
2882 | xAxisHeight: 0,
|
2883 | hasAxis: false,
|
2884 | hasFunnel: false,
|
2885 | hasRadar: false,
|
2886 | hasTreemap: false,
|
2887 |
|
2888 | cssRule: {},
|
2889 | current: {
|
2890 |
|
2891 | domain: void 0,
|
2892 |
|
2893 | width: 0,
|
2894 | height: 0,
|
2895 | dataMax: 0,
|
2896 | maxTickSize: {
|
2897 | x: {
|
2898 | width: 0,
|
2899 | height: 0,
|
2900 | ticks: [],
|
2901 | clipPath: 0,
|
2902 | domain: ""
|
2903 | },
|
2904 | y: { width: 0, height: 0, domain: "" },
|
2905 | y2: { width: 0, height: 0, domain: "" }
|
2906 | },
|
2907 |
|
2908 | types: [],
|
2909 | needle: void 0
|
2910 |
|
2911 | },
|
2912 |
|
2913 | isLegendRight: false,
|
2914 | isLegendInset: false,
|
2915 | isLegendTop: false,
|
2916 | isLegendLeft: false,
|
2917 | legendStep: 0,
|
2918 | legendItemWidth: 0,
|
2919 | legendItemHeight: 0,
|
2920 | legendHasRendered: false,
|
2921 | eventReceiver: {
|
2922 | currentIdx: -1,
|
2923 |
|
2924 | rect: {},
|
2925 |
|
2926 | data: [],
|
2927 |
|
2928 | coords: []
|
2929 |
|
2930 | },
|
2931 | axis: {
|
2932 | x: {
|
2933 | padding: { left: 0, right: 0 },
|
2934 | tickCount: 0
|
2935 | }
|
2936 | },
|
2937 | rotatedPadding: {
|
2938 | left: 30,
|
2939 | right: 0,
|
2940 | top: 5
|
2941 | },
|
2942 | withoutFadeIn: {},
|
2943 | inputType: "",
|
2944 | datetimeId: "",
|
2945 |
|
2946 | clip: {
|
2947 | id: "",
|
2948 | idXAxis: "",
|
2949 | idYAxis: "",
|
2950 | idXAxisTickTexts: "",
|
2951 | idGrid: "",
|
2952 | idSubchart: "",
|
2953 |
|
2954 | path: "",
|
2955 | pathXAxis: "",
|
2956 | pathYAxis: "",
|
2957 | pathXAxisTickTexts: "",
|
2958 | pathGrid: ""
|
2959 | },
|
2960 |
|
2961 | event: null,
|
2962 |
|
2963 | dragStart: null,
|
2964 | dragging: false,
|
2965 | flowing: false,
|
2966 | cancelClick: false,
|
2967 | mouseover: false,
|
2968 | rendered: false,
|
2969 | transiting: false,
|
2970 | redrawing: false,
|
2971 |
|
2972 | resizing: false,
|
2973 |
|
2974 | toggling: false,
|
2975 |
|
2976 | zooming: false,
|
2977 | hasNegativeValue: false,
|
2978 | hasPositiveValue: true,
|
2979 | orgAreaOpacity: "0.2",
|
2980 | orgConfig: {},
|
2981 |
|
2982 |
|
2983 | hiddenTargetIds: [],
|
2984 | hiddenLegendIds: [],
|
2985 | focusedTargetIds: [],
|
2986 | defocusedTargetIds: [],
|
2987 |
|
2988 | radius: 0,
|
2989 | innerRadius: 0,
|
2990 | outerRadius: void 0,
|
2991 | innerRadiusRatio: 0,
|
2992 | gaugeArcWidth: 0,
|
2993 | radiusExpanded: 0,
|
2994 |
|
2995 | xgridAttr: {
|
2996 | x1: null,
|
2997 | x2: null,
|
2998 | y1: null,
|
2999 | y2: null
|
3000 | }
|
3001 | };
|
3002 | }
|
3003 | }
|
3004 |
|
3005 | ;
|
3006 |
|
3007 |
|
3008 | const Store_classes = {
|
3009 | element: Element,
|
3010 | state: State
|
3011 | };
|
3012 | class Store {
|
3013 | constructor() {
|
3014 | Object.keys(Store_classes).forEach((v) => {
|
3015 | this[v] = new Store_classes[v]();
|
3016 | });
|
3017 | }
|
3018 | getStore(name) {
|
3019 | return this[name];
|
3020 | }
|
3021 | }
|
3022 |
|
3023 | ;
|
3024 | var Cache_defProp = Object.defineProperty;
|
3025 | var Cache_defNormalProp = (obj, key, value) => key in obj ? Cache_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3026 | var Cache_publicField = (obj, key, value) => Cache_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3027 |
|
3028 | const KEY = {
|
3029 | bubbleBaseLength: "$baseLength",
|
3030 | colorPattern: "__colorPattern__",
|
3031 | dataMinMax: "$dataMinMax",
|
3032 | dataTotalSum: "$dataTotalSum",
|
3033 | dataTotalPerIndex: "$totalPerIndex",
|
3034 | legendItemTextBox: "legendItemTextBox",
|
3035 | radarPoints: "$radarPoints",
|
3036 | radarTextWidth: "$radarTextWidth",
|
3037 | setOverOut: "setOverOut",
|
3038 | callOverOutForTouch: "callOverOutForTouch",
|
3039 | textRect: "textRect"
|
3040 | };
|
3041 | class Cache {
|
3042 | constructor() {
|
3043 | Cache_publicField(this, "cache", {});
|
3044 | }
|
3045 | |
3046 |
|
3047 |
|
3048 |
|
3049 |
|
3050 |
|
3051 |
|
3052 |
|
3053 | add(key, value, isDataType = false) {
|
3054 | this.cache[key] = isDataType ? this.cloneTarget(value) : value;
|
3055 | return this.cache[key];
|
3056 | }
|
3057 | |
3058 |
|
3059 |
|
3060 |
|
3061 |
|
3062 | remove(key) {
|
3063 | (isString(key) ? [key] : key).forEach((v) => delete this.cache[v]);
|
3064 | }
|
3065 | |
3066 |
|
3067 |
|
3068 |
|
3069 |
|
3070 |
|
3071 |
|
3072 | get(key, isDataType = false) {
|
3073 | if (isDataType && Array.isArray(key)) {
|
3074 | const targets = [];
|
3075 | for (let i = 0, id; id = key[i]; i++) {
|
3076 | if (id in this.cache) {
|
3077 | targets.push(this.cloneTarget(this.cache[id]));
|
3078 | }
|
3079 | }
|
3080 | return targets;
|
3081 | } else {
|
3082 | const value = this.cache[key];
|
3083 | return isValue(value) ? value : null;
|
3084 | }
|
3085 | }
|
3086 | |
3087 |
|
3088 |
|
3089 |
|
3090 |
|
3091 | reset(all) {
|
3092 | const $$ = this;
|
3093 | for (const x in $$.cache) {
|
3094 | if (all || /^\$/.test(x)) {
|
3095 | $$.cache[x] = null;
|
3096 | }
|
3097 | }
|
3098 | }
|
3099 | |
3100 |
|
3101 |
|
3102 |
|
3103 |
|
3104 |
|
3105 | cloneTarget(target) {
|
3106 | return {
|
3107 | id: target.id,
|
3108 | id_org: target.id_org,
|
3109 | values: target.values.map((d) => ({ x: d.x, value: d.value, id: d.id }))
|
3110 | };
|
3111 | }
|
3112 | }
|
3113 |
|
3114 | ;
|
3115 | const TYPE = {
|
3116 | AREA: "area",
|
3117 | AREA_LINE_RANGE: "area-line-range",
|
3118 | AREA_SPLINE: "area-spline",
|
3119 | AREA_SPLINE_RANGE: "area-spline-range",
|
3120 | AREA_STEP: "area-step",
|
3121 | AREA_STEP_RANGE: "area-step-range",
|
3122 | BAR: "bar",
|
3123 | BUBBLE: "bubble",
|
3124 | CANDLESTICK: "candlestick",
|
3125 | DONUT: "donut",
|
3126 | FUNNEL: "funnel",
|
3127 | GAUGE: "gauge",
|
3128 | LINE: "line",
|
3129 | PIE: "pie",
|
3130 | POLAR: "polar",
|
3131 | RADAR: "radar",
|
3132 | SCATTER: "scatter",
|
3133 | SPLINE: "spline",
|
3134 | STEP: "step",
|
3135 | TREEMAP: "treemap"
|
3136 | };
|
3137 | const TYPE_METHOD_NEEDED = {
|
3138 | AREA: "initArea",
|
3139 | AREA_LINE_RANGE: "initArea",
|
3140 | AREA_SPLINE: "initArea",
|
3141 | AREA_SPLINE_RANGE: "initArea",
|
3142 | AREA_STEP: "initArea",
|
3143 | AREA_STEP_RANGE: "initArea",
|
3144 | BAR: "initBar",
|
3145 | BUBBLE: "initCircle",
|
3146 | CANDLESTICK: "initCandlestick",
|
3147 | DONUT: "initArc",
|
3148 | FUNNEL: "initFunnel",
|
3149 | GAUGE: "initArc",
|
3150 | LINE: "initLine",
|
3151 | PIE: "initArc",
|
3152 | POLAR: "initPolar",
|
3153 | RADAR: "initCircle",
|
3154 | SCATTER: "initCircle",
|
3155 | SPLINE: "initLine",
|
3156 | STEP: "initLine",
|
3157 | TREEMAP: "initTreemap"
|
3158 | };
|
3159 | const TYPE_BY_CATEGORY = {
|
3160 | Area: [
|
3161 | TYPE.AREA,
|
3162 | TYPE.AREA_SPLINE,
|
3163 | TYPE.AREA_SPLINE_RANGE,
|
3164 | TYPE.AREA_LINE_RANGE,
|
3165 | TYPE.AREA_STEP,
|
3166 | TYPE.AREA_STEP_RANGE
|
3167 | ],
|
3168 | AreaRange: [
|
3169 | TYPE.AREA_SPLINE_RANGE,
|
3170 | TYPE.AREA_LINE_RANGE,
|
3171 | TYPE.AREA_STEP_RANGE
|
3172 | ],
|
3173 | Arc: [
|
3174 | TYPE.PIE,
|
3175 | TYPE.DONUT,
|
3176 | TYPE.GAUGE,
|
3177 | TYPE.POLAR,
|
3178 | TYPE.RADAR
|
3179 | ],
|
3180 | Line: [
|
3181 | TYPE.LINE,
|
3182 | TYPE.SPLINE,
|
3183 | TYPE.AREA,
|
3184 | TYPE.AREA_SPLINE,
|
3185 | TYPE.AREA_SPLINE_RANGE,
|
3186 | TYPE.AREA_LINE_RANGE,
|
3187 | TYPE.STEP,
|
3188 | TYPE.AREA_STEP,
|
3189 | TYPE.AREA_STEP_RANGE
|
3190 | ],
|
3191 | Step: [
|
3192 | TYPE.STEP,
|
3193 | TYPE.AREA_STEP,
|
3194 | TYPE.AREA_STEP_RANGE
|
3195 | ],
|
3196 | Spline: [
|
3197 | TYPE.SPLINE,
|
3198 | TYPE.AREA_SPLINE,
|
3199 | TYPE.AREA_SPLINE_RANGE
|
3200 | ]
|
3201 | };
|
3202 |
|
3203 | ;
|
3204 |
|
3205 |
|
3206 |
|
3207 |
|
3208 | function checkModuleImport(ctx) {
|
3209 | const $$ = ctx;
|
3210 | const { config } = $$;
|
3211 | let type = "";
|
3212 | if (isEmpty(config.data_type || config.data_types) && !$$[TYPE_METHOD_NEEDED.LINE]) {
|
3213 | type = "line";
|
3214 | } else {
|
3215 | for (const x in TYPE_METHOD_NEEDED) {
|
3216 | const t = TYPE[x];
|
3217 | if ($$.hasType(t) && !$$[TYPE_METHOD_NEEDED[x]]) {
|
3218 | type = t;
|
3219 | break;
|
3220 | }
|
3221 | }
|
3222 | }
|
3223 | type && logError(
|
3224 | `Please, make sure if %c${camelize(type)}`,
|
3225 | "module has been imported and specified correctly.",
|
3226 | "https://github.com/naver/billboard.js/wiki/CHANGELOG-v2#modularization-by-its-functionality"
|
3227 | );
|
3228 | }
|
3229 | function logError(head, tail, info) {
|
3230 | var _a;
|
3231 | const prefix = "[billboard.js]";
|
3232 | const hasConsole = (_a = win.console) == null ? void 0 : _a.error;
|
3233 | if (hasConsole) {
|
3234 | const tailMsg = tail ? ["background:red;color:white;display:block;font-size:15px", tail] : [];
|
3235 | console.error(
|
3236 | `\u274C ${prefix} ${head}`,
|
3237 | "background:red;color:white;display:block;font-size:15px",
|
3238 | ...tailMsg
|
3239 | );
|
3240 | info && console.info("%c\u2139\uFE0F", "font-size:15px", info);
|
3241 | }
|
3242 | throw Error(`${prefix} ${head.replace(/\%c([a-z-]+)/i, "'$1' ")} ${tail != null ? tail : ""}`);
|
3243 | }
|
3244 |
|
3245 | ;
|
3246 |
|
3247 |
|
3248 | const { setTimeout: generator_setTimeout, clearTimeout: generator_clearTimeout } = win;
|
3249 | function generateResize(option) {
|
3250 | const fn = [];
|
3251 | let timeout;
|
3252 | const callResizeFn = function() {
|
3253 | callResizeFn.clear();
|
3254 | if (option === false) {
|
3255 | requestIdleCallback(() => {
|
3256 | fn.forEach((f) => f());
|
3257 | }, { timeout: 200 });
|
3258 | } else {
|
3259 | timeout = generator_setTimeout(() => {
|
3260 | fn.forEach((f) => f());
|
3261 | }, isNumber(option) ? option : 200);
|
3262 | }
|
3263 | };
|
3264 | callResizeFn.clear = () => {
|
3265 | if (timeout) {
|
3266 | generator_clearTimeout(timeout);
|
3267 | timeout = null;
|
3268 | }
|
3269 | };
|
3270 | callResizeFn.add = (f) => fn.push(f);
|
3271 | callResizeFn.remove = (f) => fn.splice(fn.indexOf(f), 1);
|
3272 | return callResizeFn;
|
3273 | }
|
3274 | function generateWait() {
|
3275 | let transitionsToWait = [];
|
3276 | const f = function(selection, callback) {
|
3277 | function loop() {
|
3278 | var _a;
|
3279 | let done = 0;
|
3280 | for (let i = 0, t; t = transitionsToWait[i]; i++) {
|
3281 | if (t === true || ((_a = t.empty) == null ? void 0 : _a.call(t))) {
|
3282 | done++;
|
3283 | continue;
|
3284 | }
|
3285 | if (isTabVisible() === false) {
|
3286 | done = transitionsToWait.length;
|
3287 | break;
|
3288 | }
|
3289 | try {
|
3290 | t.transition();
|
3291 | } catch (e) {
|
3292 | done++;
|
3293 | }
|
3294 | }
|
3295 | return done === transitionsToWait.length;
|
3296 | }
|
3297 | runUntil(() => {
|
3298 | callback == null ? void 0 : callback();
|
3299 | }, loop);
|
3300 | };
|
3301 | f.add = function(t) {
|
3302 | isArray(t) ? transitionsToWait = transitionsToWait.concat(t) : transitionsToWait.push(t);
|
3303 | };
|
3304 | return f;
|
3305 | }
|
3306 |
|
3307 | ;
|
3308 |
|
3309 | const blob = {};
|
3310 | function getObjectURL(fn, depsFn) {
|
3311 | var _a;
|
3312 | const fnString = fn.toString();
|
3313 | const key = fnString.replace(/(function|[\s\W\n])/g, "").substring(0, 15);
|
3314 | if (!(key in blob)) {
|
3315 | blob[key] = new win.Blob([
|
3316 | `${(_a = depsFn == null ? void 0 : depsFn.map(String).join(";")) != null ? _a : ""}
|
3317 |
|
3318 | self.onmessage=function({data}) {
|
3319 | const result = (${fnString}).apply(null, data);
|
3320 | self.postMessage(result);
|
3321 | };`
|
3322 | ], {
|
3323 | type: "text/javascript"
|
3324 | });
|
3325 | }
|
3326 | return win.URL.createObjectURL(blob[key]);
|
3327 | }
|
3328 | function getWorker(src) {
|
3329 | const worker = new win.Worker(src);
|
3330 | worker.onerror = function(e) {
|
3331 | console.error ? console.error(e) : console.log(e);
|
3332 | };
|
3333 | return worker;
|
3334 | }
|
3335 | function runWorker(useWorker = true, fn, callback, depsFn) {
|
3336 | let runFn = function(...args) {
|
3337 | const res = fn(...args);
|
3338 | callback(res);
|
3339 | };
|
3340 | if (win.Worker && useWorker) {
|
3341 | const src = getObjectURL(fn, depsFn);
|
3342 | const worker = getWorker(src);
|
3343 | runFn = function(...args) {
|
3344 | worker.postMessage(args);
|
3345 | worker.onmessage = function(e) {
|
3346 | win.URL.revokeObjectURL(src);
|
3347 | return callback(e.data);
|
3348 | };
|
3349 | };
|
3350 | }
|
3351 | return runFn;
|
3352 | }
|
3353 |
|
3354 |
|
3355 | var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_require__(5);
|
3356 | ;
|
3357 |
|
3358 |
|
3359 | function columns(columns2) {
|
3360 | const newRows = [];
|
3361 | columns2.forEach(function(col, i) {
|
3362 | const key = col[0];
|
3363 | col.forEach(function(v, j) {
|
3364 | if (j > 0) {
|
3365 | if (typeof newRows[j - 1] === "undefined") {
|
3366 | newRows[j - 1] = {};
|
3367 | }
|
3368 | if (typeof v === "undefined") {
|
3369 | throw new Error(`Source data is missing a component at (${i}, ${j})!`);
|
3370 | }
|
3371 | newRows[j - 1][key] = v;
|
3372 | }
|
3373 | });
|
3374 | });
|
3375 | return newRows;
|
3376 | }
|
3377 | function rows(rows2) {
|
3378 | const keys = rows2[0];
|
3379 | const newRows = [];
|
3380 | rows2.forEach(function(row, i) {
|
3381 | if (i > 0) {
|
3382 | const newRow = {};
|
3383 | row.forEach(function(v, j) {
|
3384 | if (typeof v === "undefined") {
|
3385 | throw new Error(`Source data is missing a component at (${i}, ${j})!`);
|
3386 | }
|
3387 | newRow[keys[j]] = v;
|
3388 | });
|
3389 | newRows.push(newRow);
|
3390 | }
|
3391 | });
|
3392 | return newRows;
|
3393 | }
|
3394 | function json(json2, keysParam) {
|
3395 | const newRows = [];
|
3396 | let targetKeys;
|
3397 | let data;
|
3398 | if (Array.isArray(json2)) {
|
3399 | const findValueInJson = function(object, path) {
|
3400 | if (object[path] !== void 0) {
|
3401 | return object[path];
|
3402 | }
|
3403 | const convertedPath = path.replace(/\[(\w+)\]/g, ".$1");
|
3404 | const pathArray = convertedPath.replace(/^\./, "").split(".");
|
3405 | let target = object;
|
3406 | pathArray.some(function(k) {
|
3407 | return !(target = target && k in target ? target[k] : void 0);
|
3408 | });
|
3409 | return target;
|
3410 | };
|
3411 | if (keysParam.x) {
|
3412 | targetKeys = keysParam.value.concat(keysParam.x);
|
3413 | } else {
|
3414 | targetKeys = keysParam.value;
|
3415 | }
|
3416 | newRows.push(targetKeys);
|
3417 | json2.forEach(function(o) {
|
3418 | const newRow = targetKeys.map(function(key) {
|
3419 | let v = findValueInJson(o, key);
|
3420 | if (typeof v === "undefined") {
|
3421 | v = null;
|
3422 | }
|
3423 | return v;
|
3424 | });
|
3425 | newRows.push(newRow);
|
3426 | });
|
3427 | data = rows(newRows);
|
3428 | } else {
|
3429 | Object.keys(json2).forEach(function(key) {
|
3430 | var _a;
|
3431 | const tmp = json2[key].concat();
|
3432 | (_a = tmp.unshift) == null ? void 0 : _a.call(tmp, key);
|
3433 | newRows.push(tmp);
|
3434 | });
|
3435 | data = columns(newRows);
|
3436 | }
|
3437 | return data;
|
3438 | }
|
3439 | function url(url2, mimeType = "csv", headers, keys, done) {
|
3440 | const req = new XMLHttpRequest();
|
3441 | const converter = { csv, tsv, json };
|
3442 | req.open("GET", url2);
|
3443 | if (headers) {
|
3444 | Object.keys(headers).forEach(function(key) {
|
3445 | req.setRequestHeader(key, headers[key]);
|
3446 | });
|
3447 | }
|
3448 | req.onreadystatechange = function() {
|
3449 | if (req.readyState === 4) {
|
3450 | if (req.status === 200) {
|
3451 | const response = req.responseText;
|
3452 | response && done.call(this, converter[mimeType](
|
3453 | mimeType === "json" ? JSON.parse(response) : response,
|
3454 | keys
|
3455 | ));
|
3456 | } else {
|
3457 | throw new Error(`${url2}: Something went wrong loading!`);
|
3458 | }
|
3459 | }
|
3460 | };
|
3461 | req.send();
|
3462 | }
|
3463 | function convertCsvTsvToData(parser, xsv) {
|
3464 | const rows2 = parser.rows(xsv);
|
3465 | let d;
|
3466 | if (rows2.length === 1) {
|
3467 | d = [{}];
|
3468 | rows2[0].forEach((id) => {
|
3469 | d[0][id] = null;
|
3470 | });
|
3471 | } else {
|
3472 | d = parser.parse(xsv);
|
3473 | }
|
3474 | return d;
|
3475 | }
|
3476 | function csv(xsv) {
|
3477 | return convertCsvTsvToData({
|
3478 | rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParseRows,
|
3479 | parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParse
|
3480 | }, xsv);
|
3481 | }
|
3482 | function tsv(tsv2) {
|
3483 | return convertCsvTsvToData({
|
3484 | rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParseRows,
|
3485 | parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParse
|
3486 | }, tsv2);
|
3487 | }
|
3488 |
|
3489 | ;
|
3490 |
|
3491 |
|
3492 |
|
3493 | function getDataKeyForJson(keysParam, config) {
|
3494 | const keys = keysParam || (config == null ? void 0 : config.data_keys);
|
3495 | if (keys == null ? void 0 : keys.x) {
|
3496 | config.data_x = keys.x;
|
3497 | }
|
3498 | return keys;
|
3499 | }
|
3500 | var convert = ({
|
3501 | |
3502 |
|
3503 |
|
3504 |
|
3505 |
|
3506 |
|
3507 | convertData(args, callback) {
|
3508 | const { config } = this;
|
3509 | const useWorker = config.boost_useWorker;
|
3510 | let data = args;
|
3511 | if (args.bindto) {
|
3512 | data = {};
|
3513 | ["url", "mimeType", "headers", "keys", "json", "keys", "rows", "columns"].forEach((v) => {
|
3514 | const key = `data_${v}`;
|
3515 | if (key in args) {
|
3516 | data[v] = args[key];
|
3517 | }
|
3518 | });
|
3519 | }
|
3520 | if (data.url && callback) {
|
3521 | url(
|
3522 | data.url,
|
3523 | data.mimeType,
|
3524 | data.headers,
|
3525 | getDataKeyForJson(data.keys, config),
|
3526 | callback
|
3527 | );
|
3528 | } else if (data.json) {
|
3529 | runWorker(useWorker, json, callback, [columns, rows])(
|
3530 | data.json,
|
3531 | getDataKeyForJson(data.keys, config)
|
3532 | );
|
3533 | } else if (data.rows) {
|
3534 | runWorker(useWorker, rows, callback)(data.rows);
|
3535 | } else if (data.columns) {
|
3536 | runWorker(useWorker, columns, callback)(data.columns);
|
3537 | } else if (args.bindto) {
|
3538 | throw Error("url or json or rows or columns is required.");
|
3539 | }
|
3540 | },
|
3541 | convertDataToTargets(data, appendXs) {
|
3542 | const $$ = this;
|
3543 | const { axis, config, state } = $$;
|
3544 | const chartType = config.data_type;
|
3545 | let isCategorized = false;
|
3546 | let isTimeSeries = false;
|
3547 | let isCustomX = false;
|
3548 | if (axis) {
|
3549 | isCategorized = axis.isCategorized();
|
3550 | isTimeSeries = axis.isTimeSeries();
|
3551 | isCustomX = axis.isCustomX();
|
3552 | }
|
3553 | const dataKeys = Object.keys(data[0] || {});
|
3554 | const ids = dataKeys.length ? dataKeys.filter($$.isNotX, $$) : [];
|
3555 | const xs = dataKeys.length ? dataKeys.filter($$.isX, $$) : [];
|
3556 | let xsData;
|
3557 | ids.forEach((id) => {
|
3558 | const xKey = this.getXKey(id);
|
3559 | if (isCustomX || isTimeSeries) {
|
3560 | if (xs.indexOf(xKey) >= 0) {
|
3561 | xsData = (appendXs && $$.data.xs[id] || []).concat(
|
3562 | data.map((d) => d[xKey]).filter(isValue).map((rawX, i) => $$.generateTargetX(rawX, id, i))
|
3563 | );
|
3564 | } else if (config.data_x) {
|
3565 | xsData = this.getOtherTargetXs();
|
3566 | } else if (notEmpty(config.data_xs)) {
|
3567 | xsData = $$.getXValuesOfXKey(xKey, $$.data.targets);
|
3568 | }
|
3569 | } else {
|
3570 | xsData = data.map((d, i) => i);
|
3571 | }
|
3572 | xsData && (this.data.xs[id] = xsData);
|
3573 | });
|
3574 | ids.forEach((id) => {
|
3575 | if (!this.data.xs[id]) {
|
3576 | throw new Error(`x is not defined for id = "${id}".`);
|
3577 | }
|
3578 | });
|
3579 | const targets = ids.map((id, index) => {
|
3580 | const convertedId = config.data_idConverter.bind($$.api)(id);
|
3581 | const xKey = $$.getXKey(id);
|
3582 | const isCategory = isCustomX && isCategorized;
|
3583 | const hasCategory = isCategory && data.map((v) => v.x).every((v) => config.axis_x_categories.indexOf(v) > -1);
|
3584 | const isDataAppend = data.__append__;
|
3585 | const xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0;
|
3586 | return {
|
3587 | id: convertedId,
|
3588 | id_org: id,
|
3589 | values: data.map((d, i) => {
|
3590 | const rawX = d[xKey];
|
3591 | let value = d[id];
|
3592 | let x;
|
3593 | value = value !== null && !isNaN(value) && !isObject(value) ? +value : isArray(value) || isObject(value) ? value : null;
|
3594 | if ((isCategory || state.hasRadar) && index === 0 && !isUndefined(rawX)) {
|
3595 | if (!hasCategory && index === 0 && i === 0 && !isDataAppend) {
|
3596 | config.axis_x_categories = [];
|
3597 | }
|
3598 | x = config.axis_x_categories.indexOf(rawX);
|
3599 | if (x === -1) {
|
3600 | x = config.axis_x_categories.length;
|
3601 | config.axis_x_categories.push(rawX);
|
3602 | }
|
3603 | } else {
|
3604 | x = $$.generateTargetX(rawX, id, xIndex + i);
|
3605 | }
|
3606 | if (isUndefined(value) || $$.data.xs[id].length <= i) {
|
3607 | x = void 0;
|
3608 | }
|
3609 | return {
|
3610 | x,
|
3611 | value,
|
3612 | id: convertedId,
|
3613 | index: -1
|
3614 | };
|
3615 | }).filter((v) => isDefined(v.x))
|
3616 | };
|
3617 | });
|
3618 | targets.forEach((t) => {
|
3619 | var _a;
|
3620 | if (config.data_xSort) {
|
3621 | t.values = t.values.sort((v1, v2) => {
|
3622 | const x1 = v1.x || v1.x === 0 ? v1.x : Infinity;
|
3623 | const x2 = v2.x || v2.x === 0 ? v2.x : Infinity;
|
3624 | return x1 - x2;
|
3625 | });
|
3626 | }
|
3627 | t.values.forEach((v, i) => v.index = i);
|
3628 | (_a = $$.data.xs[t.id]) == null ? void 0 : _a.sort((v1, v2) => v1 - v2);
|
3629 | });
|
3630 | state.hasNegativeValue = $$.hasNegativeValueInTargets(targets);
|
3631 | state.hasPositiveValue = $$.hasPositiveValueInTargets(targets);
|
3632 | if (chartType && $$.isValidChartType(chartType)) {
|
3633 | const targetIds = $$.mapToIds(targets).filter(
|
3634 | (id) => !(id in config.data_types) || !$$.isValidChartType(config.data_types[id])
|
3635 | );
|
3636 | $$.setTargetType(targetIds, chartType);
|
3637 | }
|
3638 | targets.forEach((d) => $$.cache.add(d.id_org, d, true));
|
3639 | return targets;
|
3640 | }
|
3641 | });
|
3642 |
|
3643 | ;
|
3644 |
|
3645 |
|
3646 |
|
3647 |
|
3648 | var data_data = ({
|
3649 | isX(key) {
|
3650 | const $$ = this;
|
3651 | const { config } = $$;
|
3652 | const dataKey = config.data_x && key === config.data_x;
|
3653 | const existValue = notEmpty(config.data_xs) && hasValue(config.data_xs, key);
|
3654 | return dataKey || existValue;
|
3655 | },
|
3656 | isNotX(key) {
|
3657 | return !this.isX(key);
|
3658 | },
|
3659 | isStackNormalized() {
|
3660 | const { config } = this;
|
3661 | return !!(config.data_stack_normalize && config.data_groups.length);
|
3662 | },
|
3663 | |
3664 |
|
3665 |
|
3666 |
|
3667 |
|
3668 |
|
3669 | isGrouped(id) {
|
3670 | const groups = this.config.data_groups;
|
3671 | return id ? groups.some((v) => v.indexOf(id) >= 0 && v.length > 1) : groups.length > 0;
|
3672 | },
|
3673 | getXKey(id) {
|
3674 | const $$ = this;
|
3675 | const { config } = $$;
|
3676 | return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null;
|
3677 | },
|
3678 | getXValuesOfXKey(key, targets) {
|
3679 | const $$ = this;
|
3680 | const ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : [];
|
3681 | let xValues;
|
3682 | ids.forEach((id) => {
|
3683 | if ($$.getXKey(id) === key) {
|
3684 | xValues = $$.data.xs[id];
|
3685 | }
|
3686 | });
|
3687 | return xValues;
|
3688 | },
|
3689 | |
3690 |
|
3691 |
|
3692 |
|
3693 |
|
3694 |
|
3695 |
|
3696 | getIndexByX(x, basedX) {
|
3697 | const $$ = this;
|
3698 | return basedX ? basedX.indexOf(isString(x) ? x : +x) : ($$.filterByX($$.data.targets, x)[0] || { index: null }).index;
|
3699 | },
|
3700 | getXValue(id, i) {
|
3701 | const $$ = this;
|
3702 | return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i;
|
3703 | },
|
3704 | getOtherTargetXs() {
|
3705 | const $$ = this;
|
3706 | const idsForX = Object.keys($$.data.xs);
|
3707 | return idsForX.length ? $$.data.xs[idsForX[0]] : null;
|
3708 | },
|
3709 | getOtherTargetX(index) {
|
3710 | const xs = this.getOtherTargetXs();
|
3711 | return xs && index < xs.length ? xs[index] : null;
|
3712 | },
|
3713 | addXs(xs) {
|
3714 | const $$ = this;
|
3715 | const { config } = $$;
|
3716 | Object.keys(xs).forEach((id) => {
|
3717 | config.data_xs[id] = xs[id];
|
3718 | });
|
3719 | },
|
3720 | |
3721 |
|
3722 |
|
3723 |
|
3724 |
|
3725 | isMultipleX() {
|
3726 | return !this.config.axis_x_forceAsSingle && (notEmpty(this.config.data_xs) || this.hasType("bubble") || this.hasType("scatter"));
|
3727 | },
|
3728 | addName(data) {
|
3729 | const $$ = this;
|
3730 | const { config } = $$;
|
3731 | let name;
|
3732 | if (data) {
|
3733 | name = config.data_names[data.id];
|
3734 | data.name = name !== void 0 ? name : data.id;
|
3735 | }
|
3736 | return data;
|
3737 | },
|
3738 | |
3739 |
|
3740 |
|
3741 |
|
3742 |
|
3743 |
|
3744 |
|
3745 | getAllValuesOnIndex(index, filterNull = false) {
|
3746 | const $$ = this;
|
3747 | let value = $$.filterTargetsToShow($$.data.targets).map((t) => $$.addName($$.getValueOnIndex(t.values, index)));
|
3748 | if (filterNull) {
|
3749 | value = value.filter((v) => v && "value" in v && isValue(v.value));
|
3750 | }
|
3751 | return value;
|
3752 | },
|
3753 | getValueOnIndex(values, index) {
|
3754 | const valueOnIndex = values.filter((v) => v.index === index);
|
3755 | return valueOnIndex.length ? valueOnIndex[0] : null;
|
3756 | },
|
3757 | updateTargetX(targets, x) {
|
3758 | const $$ = this;
|
3759 | targets.forEach((t) => {
|
3760 | t.values.forEach((v, i) => {
|
3761 | v.x = $$.generateTargetX(x[i], t.id, i);
|
3762 | });
|
3763 | $$.data.xs[t.id] = x;
|
3764 | });
|
3765 | },
|
3766 | updateTargetXs(targets, xs) {
|
3767 | const $$ = this;
|
3768 | targets.forEach((t) => {
|
3769 | xs[t.id] && $$.updateTargetX([t], xs[t.id]);
|
3770 | });
|
3771 | },
|
3772 | generateTargetX(rawX, id, index) {
|
3773 | const $$ = this;
|
3774 | const { axis } = $$;
|
3775 | let x = (axis == null ? void 0 : axis.isCategorized()) ? index : rawX || index;
|
3776 | if (axis == null ? void 0 : axis.isTimeSeries()) {
|
3777 | const fn = parseDate.bind($$);
|
3778 | x = rawX ? fn(rawX) : fn($$.getXValue(id, index));
|
3779 | } else if ((axis == null ? void 0 : axis.isCustomX()) && !(axis == null ? void 0 : axis.isCategorized())) {
|
3780 | x = isValue(rawX) ? +rawX : $$.getXValue(id, index);
|
3781 | }
|
3782 | return x;
|
3783 | },
|
3784 | updateXs(values) {
|
3785 | if (values.length) {
|
3786 | this.axis.xs = values.map((v) => v.x);
|
3787 | }
|
3788 | },
|
3789 | getPrevX(i) {
|
3790 | const x = this.axis.xs[i - 1];
|
3791 | return isDefined(x) ? x : null;
|
3792 | },
|
3793 | getNextX(i) {
|
3794 | const x = this.axis.xs[i + 1];
|
3795 | return isDefined(x) ? x : null;
|
3796 | },
|
3797 | |
3798 |
|
3799 |
|
3800 |
|
3801 |
|
3802 |
|
3803 | getBaseValue(data) {
|
3804 | const $$ = this;
|
3805 | const { hasAxis } = $$.state;
|
3806 | let { value } = data;
|
3807 | if (value && hasAxis) {
|
3808 | if ($$.isAreaRangeType(data)) {
|
3809 | value = $$.getRangedData(data, "mid");
|
3810 | } else if ($$.isBubbleZType(data)) {
|
3811 | value = $$.getBubbleZData(value, "y");
|
3812 | }
|
3813 | }
|
3814 | return value;
|
3815 | },
|
3816 | |
3817 |
|
3818 |
|
3819 |
|
3820 |
|
3821 |
|
3822 | getMinMaxValue(data) {
|
3823 | const getBaseValue = this.getBaseValue.bind(this);
|
3824 | let min;
|
3825 | let max;
|
3826 | (data || this.data.targets.map((t) => t.values)).forEach((v, i) => {
|
3827 | const value = v.map(getBaseValue).filter(isNumber);
|
3828 | min = Math.min(i ? min : Infinity, ...value);
|
3829 | max = Math.max(i ? max : -Infinity, ...value);
|
3830 | });
|
3831 | return { min, max };
|
3832 | },
|
3833 | |
3834 |
|
3835 |
|
3836 |
|
3837 |
|
3838 | getMinMaxData() {
|
3839 | const $$ = this;
|
3840 | const cacheKey = KEY.dataMinMax;
|
3841 | let minMaxData = $$.cache.get(cacheKey);
|
3842 | if (!minMaxData) {
|
3843 | const data = $$.data.targets.map((t) => t.values);
|
3844 | const minMax = $$.getMinMaxValue(data);
|
3845 | let min = [];
|
3846 | let max = [];
|
3847 | data.forEach((v) => {
|
3848 | const minData = $$.getFilteredDataByValue(v, minMax.min);
|
3849 | const maxData = $$.getFilteredDataByValue(v, minMax.max);
|
3850 | if (minData.length) {
|
3851 | min = min.concat(minData);
|
3852 | }
|
3853 | if (maxData.length) {
|
3854 | max = max.concat(maxData);
|
3855 | }
|
3856 | });
|
3857 | $$.cache.add(cacheKey, minMaxData = { min, max });
|
3858 | }
|
3859 | return minMaxData;
|
3860 | },
|
3861 | |
3862 |
|
3863 |
|
3864 |
|
3865 |
|
3866 | getTotalPerIndex() {
|
3867 | const $$ = this;
|
3868 | const cacheKey = KEY.dataTotalPerIndex;
|
3869 | let sum = $$.cache.get(cacheKey);
|
3870 | if (($$.config.data_groups.length || $$.isStackNormalized()) && !sum) {
|
3871 | sum = [];
|
3872 | $$.data.targets.forEach((row) => {
|
3873 | row.values.forEach((v, i) => {
|
3874 | if (!sum[i]) {
|
3875 | sum[i] = 0;
|
3876 | }
|
3877 | sum[i] += isNumber(v.value) ? v.value : 0;
|
3878 | });
|
3879 | });
|
3880 | }
|
3881 | return sum;
|
3882 | },
|
3883 | |
3884 |
|
3885 |
|
3886 |
|
3887 |
|
3888 |
|
3889 | getTotalDataSum(subtractHidden) {
|
3890 | const $$ = this;
|
3891 | const cacheKey = KEY.dataTotalSum;
|
3892 | let total = $$.cache.get(cacheKey);
|
3893 | if (!isNumber(total)) {
|
3894 | const sum = mergeArray($$.data.targets.map((t) => t.values)).map((v) => v.value);
|
3895 | total = sum.length ? sum.reduce((p, c) => p + c) : 0;
|
3896 | $$.cache.add(cacheKey, total);
|
3897 | }
|
3898 | if (subtractHidden) {
|
3899 | total -= $$.getHiddenTotalDataSum();
|
3900 | }
|
3901 | return total;
|
3902 | },
|
3903 | |
3904 |
|
3905 |
|
3906 |
|
3907 |
|
3908 | getHiddenTotalDataSum() {
|
3909 | const $$ = this;
|
3910 | const { api, state: { hiddenTargetIds } } = $$;
|
3911 | let total = 0;
|
3912 | if (hiddenTargetIds.length) {
|
3913 | total = api.data.values.bind(api)(hiddenTargetIds).reduce((p, c) => p + c);
|
3914 | }
|
3915 | return total;
|
3916 | },
|
3917 | |
3918 |
|
3919 |
|
3920 |
|
3921 |
|
3922 |
|
3923 |
|
3924 | getFilteredDataByValue(data, value) {
|
3925 | return data.filter((t) => this.getBaseValue(t) === value);
|
3926 | },
|
3927 | |
3928 |
|
3929 |
|
3930 |
|
3931 |
|
3932 | getMaxDataCount() {
|
3933 | return Math.max(...this.data.targets.map((t) => t.values.length), 0);
|
3934 | },
|
3935 | getMaxDataCountTarget() {
|
3936 | let target = this.filterTargetsToShow() || [];
|
3937 | const length = target.length;
|
3938 | const isInverted = this.config.axis_x_inverted;
|
3939 | if (length > 1) {
|
3940 | target = target.map((t) => t.values).reduce((a, b) => a.concat(b)).map((v) => v.x);
|
3941 | target = sortValue(getUnique(target)).map((x, index, array) => ({
|
3942 | x,
|
3943 | index: isInverted ? array.length - index - 1 : index
|
3944 | }));
|
3945 | } else if (length) {
|
3946 | target = target[0].values.concat();
|
3947 | }
|
3948 | return target;
|
3949 | },
|
3950 | mapToIds(targets) {
|
3951 | return targets.map((d) => d.id);
|
3952 | },
|
3953 | mapToTargetIds(ids) {
|
3954 | const $$ = this;
|
3955 | return ids ? isArray(ids) ? ids.concat() : [ids] : $$.mapToIds($$.data.targets);
|
3956 | },
|
3957 | hasTarget(targets, id) {
|
3958 | const ids = this.mapToIds(targets);
|
3959 | for (let i = 0, val; val = ids[i]; i++) {
|
3960 | if (val === id) {
|
3961 | return true;
|
3962 | }
|
3963 | }
|
3964 | return false;
|
3965 | },
|
3966 | isTargetToShow(targetId) {
|
3967 | return this.state.hiddenTargetIds.indexOf(targetId) < 0;
|
3968 | },
|
3969 | isLegendToShow(targetId) {
|
3970 | return this.state.hiddenLegendIds.indexOf(targetId) < 0;
|
3971 | },
|
3972 | filterTargetsToShow(targets) {
|
3973 | const $$ = this;
|
3974 | return (targets || $$.data.targets).filter((t) => $$.isTargetToShow(t.id));
|
3975 | },
|
3976 | mapTargetsToUniqueXs(targets) {
|
3977 | const $$ = this;
|
3978 | const { axis } = $$;
|
3979 | let xs = [];
|
3980 | if (targets == null ? void 0 : targets.length) {
|
3981 | xs = getUnique(
|
3982 | mergeArray(targets.map((t) => t.values.map((v) => +v.x)))
|
3983 | );
|
3984 | xs = (axis == null ? void 0 : axis.isTimeSeries()) ? xs.map((x) => new Date(+x)) : xs.map(Number);
|
3985 | }
|
3986 | return sortValue(xs);
|
3987 | },
|
3988 | |
3989 |
|
3990 |
|
3991 |
|
3992 |
|
3993 |
|
3994 | addTargetIds(type, targetIds) {
|
3995 | const { state } = this;
|
3996 | const ids = isArray(targetIds) ? targetIds : [targetIds];
|
3997 | ids.forEach((v) => {
|
3998 | state[type].indexOf(v) < 0 && state[type].push(v);
|
3999 | });
|
4000 | },
|
4001 | |
4002 |
|
4003 |
|
4004 |
|
4005 |
|
4006 |
|
4007 | removeTargetIds(type, targetIds) {
|
4008 | const { state } = this;
|
4009 | const ids = isArray(targetIds) ? targetIds : [targetIds];
|
4010 | ids.forEach((v) => {
|
4011 | const index = state[type].indexOf(v);
|
4012 | index >= 0 && state[type].splice(index, 1);
|
4013 | });
|
4014 | },
|
4015 | addHiddenTargetIds(targetIds) {
|
4016 | this.addTargetIds("hiddenTargetIds", targetIds);
|
4017 | },
|
4018 | removeHiddenTargetIds(targetIds) {
|
4019 | this.removeTargetIds("hiddenTargetIds", targetIds);
|
4020 | },
|
4021 | addHiddenLegendIds(targetIds) {
|
4022 | this.addTargetIds("hiddenLegendIds", targetIds);
|
4023 | },
|
4024 | removeHiddenLegendIds(targetIds) {
|
4025 | this.removeTargetIds("hiddenLegendIds", targetIds);
|
4026 | },
|
4027 | getValuesAsIdKeyed(targets) {
|
4028 | const $$ = this;
|
4029 | const { hasAxis } = $$.state;
|
4030 | const ys = {};
|
4031 | const isMultipleX = $$.isMultipleX();
|
4032 | const xs = isMultipleX ? $$.mapTargetsToUniqueXs(targets).map((v) => isString(v) ? v : +v) : null;
|
4033 | targets.forEach((t) => {
|
4034 | const data = [];
|
4035 | t.values.filter(({ value }) => isValue(value) || value === null).forEach((v) => {
|
4036 | let { value } = v;
|
4037 | if (value !== null && $$.isCandlestickType(v)) {
|
4038 | value = isArray(value) ? value.slice(0, 4) : [value.open, value.high, value.low, value.close];
|
4039 | }
|
4040 | if (isArray(value)) {
|
4041 | data.push(...value);
|
4042 | } else if (isObject(value) && "high" in value) {
|
4043 | data.push(...Object.values(value));
|
4044 | } else if ($$.isBubbleZType(v)) {
|
4045 | data.push(hasAxis && $$.getBubbleZData(value, "y"));
|
4046 | } else {
|
4047 | if (isMultipleX) {
|
4048 | data[$$.getIndexByX(v.x, xs)] = value;
|
4049 | } else {
|
4050 | data.push(value);
|
4051 | }
|
4052 | }
|
4053 | });
|
4054 | ys[t.id] = data;
|
4055 | });
|
4056 | return ys;
|
4057 | },
|
4058 | checkValueInTargets(targets, checker) {
|
4059 | const ids = Object.keys(targets);
|
4060 | let values;
|
4061 | for (let i = 0; i < ids.length; i++) {
|
4062 | values = targets[ids[i]].values;
|
4063 | for (let j = 0; j < values.length; j++) {
|
4064 | if (checker(values[j].value)) {
|
4065 | return true;
|
4066 | }
|
4067 | }
|
4068 | }
|
4069 | return false;
|
4070 | },
|
4071 | hasMultiTargets() {
|
4072 | return this.filterTargetsToShow().length > 1;
|
4073 | },
|
4074 | hasNegativeValueInTargets(targets) {
|
4075 | return this.checkValueInTargets(targets, (v) => v < 0);
|
4076 | },
|
4077 | hasPositiveValueInTargets(targets) {
|
4078 | return this.checkValueInTargets(targets, (v) => v > 0);
|
4079 | },
|
4080 | |
4081 |
|
4082 |
|
4083 |
|
4084 |
|
4085 |
|
4086 |
|
4087 | orderTargets(targetsValue) {
|
4088 | const $$ = this;
|
4089 | const targets = [...targetsValue];
|
4090 | const fn = $$.getSortCompareFn();
|
4091 | fn && targets.sort(fn);
|
4092 | return targets;
|
4093 | },
|
4094 | |
4095 |
|
4096 |
|
4097 |
|
4098 |
|
4099 |
|
4100 | getSortCompareFn(isReversed = false) {
|
4101 | const $$ = this;
|
4102 | const { config } = $$;
|
4103 | const order = config.data_order;
|
4104 | const orderAsc = /asc/i.test(order);
|
4105 | const orderDesc = /desc/i.test(order);
|
4106 | let fn;
|
4107 | if (orderAsc || orderDesc) {
|
4108 | const reducer = (p, c) => p + Math.abs(c.value);
|
4109 | const sum = (v) => isNumber(v) ? v : "values" in v ? v.values.reduce(reducer, 0) : v.value;
|
4110 | fn = (t1, t2) => {
|
4111 | const t1Sum = sum(t1);
|
4112 | const t2Sum = sum(t2);
|
4113 | return isReversed ? orderAsc ? t1Sum - t2Sum : t2Sum - t1Sum : orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum;
|
4114 | };
|
4115 | } else if (isFunction(order)) {
|
4116 | fn = order.bind($$.api);
|
4117 | }
|
4118 | return fn || null;
|
4119 | },
|
4120 | filterByX(targets, x) {
|
4121 | return mergeArray(targets.map((t) => t.values)).filter((v) => v.x - x === 0);
|
4122 | },
|
4123 | filterRemoveNull(data) {
|
4124 | return data.filter((d) => isValue(this.getBaseValue(d)));
|
4125 | },
|
4126 | filterByXDomain(targets, xDomain) {
|
4127 | return targets.map((t) => ({
|
4128 | id: t.id,
|
4129 | id_org: t.id_org,
|
4130 | values: t.values.filter((v) => xDomain[0] <= v.x && v.x <= xDomain[1])
|
4131 | }));
|
4132 | },
|
4133 | hasDataLabel() {
|
4134 | const dataLabels = this.config.data_labels;
|
4135 | return isBoolean(dataLabels) && dataLabels || isObjectType(dataLabels) && notEmpty(dataLabels);
|
4136 | },
|
4137 | |
4138 |
|
4139 |
|
4140 |
|
4141 |
|
4142 |
|
4143 | hasNullDataValue(targets) {
|
4144 | return targets.some(({ value }) => value === null);
|
4145 | },
|
4146 | |
4147 |
|
4148 |
|
4149 |
|
4150 |
|
4151 |
|
4152 | getDataIndexFromEvent(event) {
|
4153 | const $$ = this;
|
4154 | const {
|
4155 | $el,
|
4156 | config,
|
4157 | state: { hasRadar, inputType, eventReceiver: { coords, rect } }
|
4158 | } = $$;
|
4159 | let index;
|
4160 | if (hasRadar) {
|
4161 | let target = event.target;
|
4162 | if (/tspan/i.test(target.tagName)) {
|
4163 | target = target.parentNode;
|
4164 | }
|
4165 | const d = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
|
4166 | index = d && Object.keys(d).length === 1 ? d.index : void 0;
|
4167 | } else {
|
4168 | const isRotated = config.axis_rotated;
|
4169 | const scrollPos = getScrollPosition($el.chart.node());
|
4170 | const e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event;
|
4171 | let point = isRotated ? e.clientY + scrollPos.y : e.clientX + scrollPos.x;
|
4172 | if (hasViewBox($el.svg)) {
|
4173 | const pos = [point, 0];
|
4174 | isRotated && pos.reverse();
|
4175 | point = getTransformCTM($el.svg.node(), ...pos)[isRotated ? "y" : "x"];
|
4176 | } else {
|
4177 | point -= isRotated ? rect.top : rect.left;
|
4178 | }
|
4179 | index = findIndex(
|
4180 | coords,
|
4181 | point,
|
4182 | 0,
|
4183 | coords.length - 1,
|
4184 | isRotated
|
4185 | );
|
4186 | }
|
4187 | return index;
|
4188 | },
|
4189 | getDataLabelLength(min, max, key) {
|
4190 | const $$ = this;
|
4191 | const lengths = [0, 0];
|
4192 | const paddingCoef = 1.3;
|
4193 | $$.$el.chart.select("svg").selectAll(".dummy").data([min, max]).enter().append("text").text((d) => $$.dataLabelFormat(d.id)(d)).each(function(d, i) {
|
4194 | lengths[i] = this.getBoundingClientRect()[key] * paddingCoef;
|
4195 | }).remove();
|
4196 | return lengths;
|
4197 | },
|
4198 | isNoneArc(d) {
|
4199 | return this.hasTarget(this.data.targets, d.id);
|
4200 | },
|
4201 | isArc(d) {
|
4202 | return "data" in d && this.hasTarget(this.data.targets, d.data.id);
|
4203 | },
|
4204 | findSameXOfValues(values, index) {
|
4205 | const targetX = values[index].x;
|
4206 | const sames = [];
|
4207 | let i;
|
4208 | for (i = index - 1; i >= 0; i--) {
|
4209 | if (targetX !== values[i].x) {
|
4210 | break;
|
4211 | }
|
4212 | sames.push(values[i]);
|
4213 | }
|
4214 | for (i = index; i < values.length; i++) {
|
4215 | if (targetX !== values[i].x) {
|
4216 | break;
|
4217 | }
|
4218 | sames.push(values[i]);
|
4219 | }
|
4220 | return sames;
|
4221 | },
|
4222 | findClosestFromTargets(targets, pos) {
|
4223 | const $$ = this;
|
4224 | const candidates = targets.map((target) => $$.findClosest(target.values, pos));
|
4225 | return $$.findClosest(candidates, pos);
|
4226 | },
|
4227 | findClosest(values, pos) {
|
4228 | const $$ = this;
|
4229 | const { $el: { main } } = $$;
|
4230 | const data = values.filter((v) => v && isValue(v.value));
|
4231 | let minDist;
|
4232 | let closest;
|
4233 | data.filter((v) => $$.isBarType(v.id) || $$.isCandlestickType(v.id)).forEach((v) => {
|
4234 | const selector = $$.isBarType(v.id) ? `.${$BAR.chartBar}.${$COMMON.target}${$$.getTargetSelectorSuffix(v.id)} .${$BAR.bar}-${v.index}` : `.${$CANDLESTICK.chartCandlestick}.${$COMMON.target}${$$.getTargetSelectorSuffix(v.id)} .${$CANDLESTICK.candlestick}-${v.index} path`;
|
4235 | if (!closest && $$.isWithinBar(main.select(selector).node())) {
|
4236 | closest = v;
|
4237 | }
|
4238 | });
|
4239 | data.filter((v) => !$$.isBarType(v.id) && !$$.isCandlestickType(v.id)).forEach((v) => {
|
4240 | const d = $$.dist(v, pos);
|
4241 | minDist = $$.getPointSensitivity(v);
|
4242 | if (d < minDist) {
|
4243 | minDist = d;
|
4244 | closest = v;
|
4245 | }
|
4246 | });
|
4247 | return closest;
|
4248 | },
|
4249 | dist(data, pos) {
|
4250 | const $$ = this;
|
4251 | const { config: { axis_rotated: isRotated }, scale } = $$;
|
4252 | const xIndex = +isRotated;
|
4253 | const yIndex = +!isRotated;
|
4254 | const y = $$.circleY(data, data.index);
|
4255 | const x = (scale.zoom || scale.x)(data.x);
|
4256 | return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
|
4257 | },
|
4258 | |
4259 |
|
4260 |
|
4261 |
|
4262 |
|
4263 |
|
4264 | convertValuesToStep(values) {
|
4265 | const $$ = this;
|
4266 | const { axis, config } = $$;
|
4267 | const stepType = config.line_step_type;
|
4268 | const isCategorized = axis ? axis.isCategorized() : false;
|
4269 | const converted = isArray(values) ? values.concat() : [values];
|
4270 | if (!(isCategorized || /step\-(after|before)/.test(stepType))) {
|
4271 | return values;
|
4272 | }
|
4273 | if (converted.length) {
|
4274 | const head = converted[0];
|
4275 | const tail = converted[converted.length - 1];
|
4276 | const { id } = head;
|
4277 | let { x } = head;
|
4278 | converted.unshift({ x: --x, value: head.value, id });
|
4279 | isCategorized && stepType === "step-after" && converted.unshift({ x: --x, value: head.value, id });
|
4280 | x = tail.x;
|
4281 | converted.push({ x: ++x, value: tail.value, id });
|
4282 | isCategorized && stepType === "step-before" && converted.push({ x: ++x, value: tail.value, id });
|
4283 | }
|
4284 | return converted;
|
4285 | },
|
4286 | convertValuesToRange(values) {
|
4287 | const converted = isArray(values) ? values.concat() : [values];
|
4288 | const ranges = [];
|
4289 | converted.forEach((range) => {
|
4290 | const { x, id } = range;
|
4291 | ranges.push({
|
4292 | x,
|
4293 | id,
|
4294 | value: range.value[0]
|
4295 | });
|
4296 | ranges.push({
|
4297 | x,
|
4298 | id,
|
4299 | value: range.value[2]
|
4300 | });
|
4301 | });
|
4302 | return ranges;
|
4303 | },
|
4304 | updateDataAttributes(name, attrs) {
|
4305 | const $$ = this;
|
4306 | const { config } = $$;
|
4307 | const current = config[`data_${name}`];
|
4308 | if (isUndefined(attrs)) {
|
4309 | return current;
|
4310 | }
|
4311 | Object.keys(attrs).forEach((id) => {
|
4312 | current[id] = attrs[id];
|
4313 | });
|
4314 | $$.redraw({ withLegend: true });
|
4315 | return current;
|
4316 | },
|
4317 | getRangedData(d, key = "", type = "areaRange") {
|
4318 | const value = d == null ? void 0 : d.value;
|
4319 | if (isArray(value)) {
|
4320 | if (type === "bar") {
|
4321 | return value.reduce((a, c) => c - a);
|
4322 | } else {
|
4323 | const index = {
|
4324 | areaRange: ["high", "mid", "low"],
|
4325 | candlestick: ["open", "high", "low", "close", "volume"]
|
4326 | }[type].indexOf(key);
|
4327 | return index >= 0 && value ? value[index] : void 0;
|
4328 | }
|
4329 | } else if (value && key) {
|
4330 | return value[key];
|
4331 | }
|
4332 | return value;
|
4333 | },
|
4334 | |
4335 |
|
4336 |
|
4337 |
|
4338 |
|
4339 | setRatioForGroupedData(data) {
|
4340 | const $$ = this;
|
4341 | const { config } = $$;
|
4342 | if (config.data_groups.length && data.some((d) => $$.isGrouped(d.id))) {
|
4343 | const setter = (d) => $$.getRatio("index", d, true);
|
4344 | data.forEach((v) => {
|
4345 | "values" in v ? v.values.forEach(setter) : setter(v);
|
4346 | });
|
4347 | }
|
4348 | },
|
4349 | |
4350 |
|
4351 |
|
4352 |
|
4353 |
|
4354 |
|
4355 |
|
4356 |
|
4357 | getRatio(type, d, asPercent = false) {
|
4358 | const $$ = this;
|
4359 | const { config, state } = $$;
|
4360 | const api = $$.api;
|
4361 | let ratio = 0;
|
4362 | if (d && api.data.shown().length) {
|
4363 | ratio = d.ratio || d.value;
|
4364 | if (type === "arc") {
|
4365 | if ($$.pie.padAngle()()) {
|
4366 | ratio = d.value / $$.getTotalDataSum(true);
|
4367 | } else {
|
4368 | const gaugeArcLength = config.gauge_fullCircle ? $$.getArcLength() : $$.getStartingAngle() * -2;
|
4369 | const arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
|
4370 | ratio = (d.endAngle - d.startAngle) / arcLength;
|
4371 | }
|
4372 | } else if (type === "index") {
|
4373 | const dataValues = api.data.values.bind(api);
|
4374 | let total = this.getTotalPerIndex();
|
4375 | if (state.hiddenTargetIds.length) {
|
4376 | let hiddenSum = dataValues(state.hiddenTargetIds, false);
|
4377 | if (hiddenSum.length) {
|
4378 | hiddenSum = hiddenSum.reduce(
|
4379 | (acc, curr) => acc.map((v, i) => (isNumber(v) ? v : 0) + curr[i])
|
4380 | );
|
4381 | total = total.map((v, i) => v - hiddenSum[i]);
|
4382 | }
|
4383 | }
|
4384 | const divisor = total[d.index];
|
4385 | d.ratio = isNumber(d.value) && total && divisor ? d.value / divisor : 0;
|
4386 | ratio = d.ratio;
|
4387 | } else if (type === "radar") {
|
4388 | ratio = parseFloat(String(Math.max(d.value, 0))) / state.current.dataMax * config.radar_size_ratio;
|
4389 | } else if (type === "bar") {
|
4390 | const yScale = $$.getYScaleById.bind($$)(d.id);
|
4391 | const max = yScale.domain().reduce((a, c) => c - a);
|
4392 | ratio = max === 0 ? 0 : Math.abs(
|
4393 | $$.getRangedData(d, null, type) / max
|
4394 | );
|
4395 | } else if (type === "treemap") {
|
4396 | ratio /= $$.getTotalDataSum(true);
|
4397 | }
|
4398 | }
|
4399 | return asPercent && ratio ? ratio * 100 : ratio;
|
4400 | },
|
4401 | |
4402 |
|
4403 |
|
4404 |
|
4405 |
|
4406 | updateDataIndexByX(tickValues) {
|
4407 | const $$ = this;
|
4408 | const tickValueMap = tickValues.reduce((out, tick, index) => {
|
4409 | out[Number(tick.x)] = index;
|
4410 | return out;
|
4411 | }, {});
|
4412 | $$.data.targets.forEach((t) => {
|
4413 | t.values.forEach((value, valueIndex) => {
|
4414 | let index = tickValueMap[Number(value.x)];
|
4415 | if (index === void 0) {
|
4416 | index = valueIndex;
|
4417 | }
|
4418 | value.index = index;
|
4419 | });
|
4420 | });
|
4421 | },
|
4422 | |
4423 |
|
4424 |
|
4425 |
|
4426 |
|
4427 |
|
4428 | isBubbleZType(d) {
|
4429 | const $$ = this;
|
4430 | return $$.isBubbleType(d) && (isObject(d.value) && ("z" in d.value || "y" in d.value) || isArray(d.value) && d.value.length >= 2);
|
4431 | },
|
4432 | |
4433 |
|
4434 |
|
4435 |
|
4436 |
|
4437 |
|
4438 | isBarRangeType(d) {
|
4439 | const $$ = this;
|
4440 | const { value } = d;
|
4441 | return $$.isBarType(d) && isArray(value) && value.length >= 2 && value.every((v) => isNumber(v));
|
4442 | },
|
4443 | |
4444 |
|
4445 |
|
4446 |
|
4447 |
|
4448 |
|
4449 | getDataById(id) {
|
4450 | var _a;
|
4451 | const d = this.cache.get(id) || this.api.data(id);
|
4452 | return (_a = d == null ? void 0 : d[0]) != null ? _a : d;
|
4453 | }
|
4454 | });
|
4455 |
|
4456 | ;
|
4457 |
|
4458 |
|
4459 | function callDone(fn, resizeAfter = false) {
|
4460 | const $$ = this;
|
4461 | const { api } = $$;
|
4462 | resizeAfter && $$.api.flush(true);
|
4463 | fn == null ? void 0 : fn.call(api);
|
4464 | }
|
4465 | var load = ({
|
4466 | load(rawTargets, args) {
|
4467 | const $$ = this;
|
4468 | const { axis, data, org, scale } = $$;
|
4469 | const { append } = args;
|
4470 | const zoomState = {
|
4471 | domain: null,
|
4472 | currentDomain: null,
|
4473 | x: null
|
4474 | };
|
4475 | let targets = rawTargets;
|
4476 | if (targets) {
|
4477 | if (args.filter) {
|
4478 | targets = targets.filter(args.filter);
|
4479 | }
|
4480 | if (args.type || args.types) {
|
4481 | targets.forEach((t) => {
|
4482 | var _a;
|
4483 | const type = ((_a = args.types) == null ? void 0 : _a[t.id]) || args.type;
|
4484 | $$.setTargetType(t.id, type);
|
4485 | });
|
4486 | }
|
4487 | data.targets.forEach((d) => {
|
4488 | for (let i = 0; i < targets.length; i++) {
|
4489 | if (d.id === targets[i].id) {
|
4490 | d.values = append ? d.values.concat(targets[i].values) : targets[i].values;
|
4491 | targets.splice(i, 1);
|
4492 | break;
|
4493 | }
|
4494 | }
|
4495 | });
|
4496 | data.targets = data.targets.concat(targets);
|
4497 | }
|
4498 | $$.updateTargets(data.targets);
|
4499 | if (scale.zoom) {
|
4500 | zoomState.x = axis.isCategorized() ? scale.x.orgScale() : (org.xScale || scale.x).copy();
|
4501 | zoomState.domain = $$.getXDomain(data.targets);
|
4502 | zoomState.x.domain(zoomState.domain);
|
4503 | zoomState.currentDomain = $$.zoom.getDomain();
|
4504 | if (!$$.withinRange(zoomState.currentDomain, void 0, zoomState.domain)) {
|
4505 | scale.x.domain(zoomState.domain);
|
4506 | scale.zoom = null;
|
4507 | $$.$el.eventRect.property("__zoom", null);
|
4508 | }
|
4509 | }
|
4510 | $$.redraw({
|
4511 | withUpdateOrgXDomain: true,
|
4512 | withUpdateXDomain: true,
|
4513 | withLegend: true
|
4514 | });
|
4515 | if (scale.zoom) {
|
4516 | org.xDomain = zoomState.domain;
|
4517 | org.xScale = zoomState.x;
|
4518 | if (axis.isCategorized()) {
|
4519 | zoomState.currentDomain = $$.getZoomDomainValue(zoomState.currentDomain);
|
4520 | org.xDomain = $$.getZoomDomainValue(org.xDomain);
|
4521 | org.xScale = zoomState.x.domain(org.xDomain);
|
4522 | }
|
4523 | $$.updateCurrentZoomTransform(zoomState.x, zoomState.currentDomain);
|
4524 | } else if (org.xScale) {
|
4525 | org.xScale.domain(org.xDomain);
|
4526 | }
|
4527 | $$.updateTypesElements();
|
4528 | callDone.call($$, args.done, args.resizeAfter);
|
4529 | },
|
4530 | loadFromArgs(args) {
|
4531 | const $$ = this;
|
4532 | if (!$$.config) {
|
4533 | return;
|
4534 | }
|
4535 | $$.cache.reset();
|
4536 | $$.convertData(args, (d) => {
|
4537 | const data = args.data || d;
|
4538 | args.append && (data.__append__ = true);
|
4539 | data && $$.load($$.convertDataToTargets(data), args);
|
4540 | });
|
4541 | },
|
4542 | unload(rawTargetIds, customDoneCb) {
|
4543 | var _a;
|
4544 | const $$ = this;
|
4545 | const { state, $el, $T } = $$;
|
4546 | const hasLegendDefsPoint = !!((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$));
|
4547 | let done = customDoneCb;
|
4548 | let targetIds = rawTargetIds;
|
4549 | $$.cache.reset();
|
4550 | if (!done) {
|
4551 | done = () => {
|
4552 | };
|
4553 | }
|
4554 | targetIds = targetIds.filter((id) => $$.hasTarget($$.data.targets, id));
|
4555 | if (!targetIds || targetIds.length === 0) {
|
4556 | done();
|
4557 | return;
|
4558 | }
|
4559 | const targets = $el.svg.selectAll(targetIds.map((id) => $$.selectorTarget(id)));
|
4560 | $T(targets).style("opacity", "0").remove().call(endall, done);
|
4561 | targetIds.forEach((id) => {
|
4562 | var _a2;
|
4563 | const suffixId = $$.getTargetSelectorSuffix(id);
|
4564 | state.withoutFadeIn[id] = false;
|
4565 | if ($el.legend) {
|
4566 | $el.legend.selectAll(`.${$LEGEND.legendItem}${suffixId}`).remove();
|
4567 | }
|
4568 | $$.data.targets = $$.data.targets.filter((t) => t.id !== id);
|
4569 | hasLegendDefsPoint && ((_a2 = $el.defs) == null ? void 0 : _a2.select(`#${$$.getDefsPointId(suffixId)}`).remove());
|
4570 | });
|
4571 | state.hasFunnel && $$.updateFunnel($$.data.targets);
|
4572 | state.hasTreemap && $$.updateTargetsForTreemap($$.data.targets);
|
4573 | $$.updateTypesElements();
|
4574 | }
|
4575 | });
|
4576 |
|
4577 |
|
4578 | var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack_require__(6);
|
4579 | ;
|
4580 |
|
4581 |
|
4582 |
|
4583 |
|
4584 |
|
4585 | var interactions_interaction = ({
|
4586 | |
4587 |
|
4588 |
|
4589 |
|
4590 |
|
4591 |
|
4592 |
|
4593 | setExpand(index, id, reset) {
|
4594 | const $$ = this;
|
4595 | const { config, $el: { circle } } = $$;
|
4596 | circle && config.point_focus_expand_enabled && $$.expandCircles(index, id, reset);
|
4597 | $$.expandBarTypeShapes(true, index, id, reset);
|
4598 | },
|
4599 | |
4600 |
|
4601 |
|
4602 |
|
4603 |
|
4604 |
|
4605 |
|
4606 |
|
4607 | expandBarTypeShapes(expand = true, i, id, reset) {
|
4608 | const $$ = this;
|
4609 | ["bar", "candlestick"].filter((v) => $$.$el[v]).forEach((v) => {
|
4610 | reset && $$.$el[v].classed($COMMON.EXPANDED, false);
|
4611 | $$.getShapeByIndex(v, i, id).classed($COMMON.EXPANDED, expand);
|
4612 | });
|
4613 | },
|
4614 | |
4615 |
|
4616 |
|
4617 |
|
4618 |
|
4619 |
|
4620 | setOverOut(isOver, d) {
|
4621 | const $$ = this;
|
4622 | const { config, state: { hasFunnel, hasRadar, hasTreemap }, $el: { main } } = $$;
|
4623 | const isArcishData = isObject(d);
|
4624 | if (isArcishData || d !== -1) {
|
4625 | const callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
|
4626 | config.color_onover && $$.setOverColor(isOver, d, isArcishData);
|
4627 | if (isArcishData && "id") {
|
4628 | const suffix = $$.getTargetSelectorSuffix(d.id);
|
4629 | const selector = hasFunnel || hasTreemap ? `${$COMMON.target + suffix} .${$SHAPE.shape}` : $ARC.arc + suffix;
|
4630 | callback(d, main.select(`.${selector}`).node());
|
4631 | } else if (!config.tooltip_grouped) {
|
4632 | const last = $$.cache.get(KEY.setOverOut) || [];
|
4633 | const shapesAtIndex = main.selectAll(`.${$SHAPE.shape}-${d}`).filter(function(d2) {
|
4634 | return $$.isWithinShape(this, d2);
|
4635 | });
|
4636 | const shape = shapesAtIndex.filter(function() {
|
4637 | return last.every((v) => v !== this);
|
4638 | });
|
4639 | if (!isOver || shapesAtIndex.empty() || last.length === shape.size() && shape.nodes().every((v, i) => v !== last[i])) {
|
4640 | while (last.length) {
|
4641 | const target = last.pop();
|
4642 | config.data_onout.bind($$.api)((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum(), target);
|
4643 | }
|
4644 | }
|
4645 | shape.each(function() {
|
4646 | if (isOver) {
|
4647 | callback((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).datum(), this);
|
4648 | last.push(this);
|
4649 | }
|
4650 | });
|
4651 | $$.cache.add(KEY.setOverOut, last);
|
4652 | } else {
|
4653 | if (isOver) {
|
4654 | hasRadar && $$.isPointFocusOnly() ? $$.showCircleFocus($$.getAllValuesOnIndex(d, true)) : $$.setExpand(d, null, true);
|
4655 | }
|
4656 | !$$.isMultipleX() && main.selectAll(`.${$SHAPE.shape}-${d}`).each(function(d2) {
|
4657 | callback(d2, this);
|
4658 | });
|
4659 | }
|
4660 | }
|
4661 | },
|
4662 | |
4663 |
|
4664 |
|
4665 |
|
4666 |
|
4667 | callOverOutForTouch(d) {
|
4668 | const $$ = this;
|
4669 | const last = $$.cache.get(KEY.callOverOutForTouch);
|
4670 | if (isObject(d) && last ? d.id !== last.id : d !== last) {
|
4671 | (last || isNumber(last)) && $$.setOverOut(false, last);
|
4672 | (d || isNumber(d)) && $$.setOverOut(true, d);
|
4673 | $$.cache.add(KEY.callOverOutForTouch, d);
|
4674 | }
|
4675 | },
|
4676 | |
4677 |
|
4678 |
|
4679 |
|
4680 |
|
4681 | getDraggableSelection() {
|
4682 | const $$ = this;
|
4683 | const { config, state } = $$;
|
4684 | return config.interaction_enabled && config.data_selection_draggable && $$.drag ? (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().on("drag", function(event) {
|
4685 | state.event = event;
|
4686 | $$.drag(getPointer(event, this));
|
4687 | }).on("start", function(event) {
|
4688 | state.event = event;
|
4689 | $$.dragstart(getPointer(event, this));
|
4690 | }).on("end", (event) => {
|
4691 | state.event = event;
|
4692 | $$.dragend();
|
4693 | }) : () => {
|
4694 | };
|
4695 | },
|
4696 | |
4697 |
|
4698 |
|
4699 |
|
4700 |
|
4701 |
|
4702 |
|
4703 | dispatchEvent(type, index, mouse) {
|
4704 | var _a, _b;
|
4705 | const $$ = this;
|
4706 | const {
|
4707 | config,
|
4708 | state: {
|
4709 | eventReceiver,
|
4710 | hasAxis,
|
4711 | hasFunnel,
|
4712 | hasRadar,
|
4713 | hasTreemap
|
4714 | },
|
4715 | $el: { eventRect, funnel, radar, svg, treemap }
|
4716 | } = $$;
|
4717 | let element = (_b = (hasFunnel || hasTreemap) && eventReceiver.rect || hasRadar && radar.axes.select(`.${$AXIS.axis}-${index} text`) || (eventRect || ((_a = $$.getArcElementByIdOrIndex) == null ? void 0 : _a.call($$, index)))) == null ? void 0 : _b.node();
|
4718 | if (element) {
|
4719 | const isMultipleX = $$.isMultipleX();
|
4720 | const isRotated = config.axis_rotated;
|
4721 | let { width, left, top } = element.getBoundingClientRect();
|
4722 | if (hasAxis && !hasRadar && !isMultipleX) {
|
4723 | const coords = eventReceiver.coords[index];
|
4724 | if (coords) {
|
4725 | width = coords.w;
|
4726 | left += coords.x;
|
4727 | top += coords.y;
|
4728 | } else {
|
4729 | width = 0;
|
4730 | left = 0;
|
4731 | top = 0;
|
4732 | }
|
4733 | }
|
4734 | let x = left + (mouse ? mouse[0] : 0) + (isMultipleX || isRotated ? 0 : width / 2);
|
4735 | let y = top + (mouse ? mouse[1] : 0) + (isRotated ? 4 : 0);
|
4736 | if (hasViewBox(svg)) {
|
4737 | const ctm = getTransformCTM($$.$el.svg.node(), x, y, false);
|
4738 | x = ctm.x;
|
4739 | y = ctm.y;
|
4740 | }
|
4741 | const params = {
|
4742 | screenX: x,
|
4743 | screenY: y,
|
4744 | clientX: x,
|
4745 | clientY: y,
|
4746 | bubbles: hasRadar
|
4747 |
|
4748 | };
|
4749 | if (hasFunnel || hasTreemap) {
|
4750 | element = (funnel != null ? funnel : treemap).node();
|
4751 | }
|
4752 | emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](
|
4753 | element,
|
4754 | type,
|
4755 | params
|
4756 | );
|
4757 | }
|
4758 | },
|
4759 | setDragStatus(isDragging) {
|
4760 | this.state.dragging = isDragging;
|
4761 | },
|
4762 | |
4763 |
|
4764 |
|
4765 |
|
4766 | unbindZoomEvent() {
|
4767 | const $$ = this;
|
4768 | const { $el: { eventRect, zoomResetBtn } } = $$;
|
4769 | eventRect == null ? void 0 : eventRect.on(".zoom wheel.zoom .drag", null);
|
4770 | zoomResetBtn == null ? void 0 : zoomResetBtn.on("click", null).style("display", "none");
|
4771 | },
|
4772 | |
4773 |
|
4774 |
|
4775 |
|
4776 | unbindAllEvents() {
|
4777 | var _a;
|
4778 | const $$ = this;
|
4779 | const { $el: { arcs, eventRect, legend, region, svg, treemap }, brush } = $$;
|
4780 | const list = [
|
4781 | "wheel",
|
4782 | "click",
|
4783 | "mouseover",
|
4784 | "mousemove",
|
4785 | "mouseout",
|
4786 | "touchstart",
|
4787 | "touchmove",
|
4788 | "touchend",
|
4789 | "touchstart.eventRect",
|
4790 | "touchmove.eventRect",
|
4791 | "touchend.eventRect",
|
4792 | ".brush",
|
4793 | ".drag",
|
4794 | ".zoom",
|
4795 | "wheel.zoom",
|
4796 | "dblclick.zoom"
|
4797 | ].join(" ");
|
4798 | [
|
4799 | svg,
|
4800 | eventRect,
|
4801 | region == null ? void 0 : region.list,
|
4802 | brush == null ? void 0 : brush.getSelection(),
|
4803 | arcs == null ? void 0 : arcs.selectAll("path"),
|
4804 | legend == null ? void 0 : legend.selectAll("g"),
|
4805 | treemap
|
4806 | ].forEach((v) => v == null ? void 0 : v.on(list, null));
|
4807 | (_a = $$.unbindZoomEvent) == null ? void 0 : _a.call($$);
|
4808 | }
|
4809 | });
|
4810 |
|
4811 | ;
|
4812 | var category = ({
|
4813 | |
4814 |
|
4815 |
|
4816 |
|
4817 |
|
4818 |
|
4819 | categoryName(i) {
|
4820 | var _a;
|
4821 | const { axis_x_categories } = this.config;
|
4822 | return (_a = axis_x_categories == null ? void 0 : axis_x_categories[i]) != null ? _a : i;
|
4823 | }
|
4824 | });
|
4825 |
|
4826 | ;
|
4827 |
|
4828 | var internals_class = ({
|
4829 | generateClass(prefix, targetId) {
|
4830 | return ` ${prefix} ${prefix + this.getTargetSelectorSuffix(targetId)}`;
|
4831 | },
|
4832 | |
4833 |
|
4834 |
|
4835 |
|
4836 |
|
4837 |
|
4838 |
|
4839 | getClass(type, withShape) {
|
4840 | const isPlural = /s$/.test(type);
|
4841 | const useIdKey = /^(area|arc|line|funnel|treemap)s?$/.test(type);
|
4842 | const key = isPlural ? "id" : "index";
|
4843 | return (d) => {
|
4844 | const data = d.data || d;
|
4845 | const result = (withShape ? this.generateClass(classes[isPlural ? "shapes" : "shape"], data[key]) : "") + this.generateClass(classes[type], data[useIdKey ? "id" : key]);
|
4846 | return result.trim();
|
4847 | };
|
4848 | },
|
4849 | |
4850 |
|
4851 |
|
4852 |
|
4853 |
|
4854 |
|
4855 | getChartClass(type) {
|
4856 | return (d) => classes[`chart${type}`] + this.classTarget((d.data ? d.data : d).id);
|
4857 | },
|
4858 | generateExtraLineClass() {
|
4859 | const $$ = this;
|
4860 | const classes = $$.config.line_classes || [];
|
4861 | const ids = [];
|
4862 | return function(d) {
|
4863 | var _a;
|
4864 | const id = d.id || ((_a = d.data) == null ? void 0 : _a.id) || d;
|
4865 | if (ids.indexOf(id) < 0) {
|
4866 | ids.push(id);
|
4867 | }
|
4868 | return classes[ids.indexOf(id) % classes.length];
|
4869 | };
|
4870 | },
|
4871 | classRegion(d, i) {
|
4872 | return `${this.generateClass(classes.region, i)} ${"class" in d ? d.class : ""}`;
|
4873 | },
|
4874 | classTarget(id) {
|
4875 | const additionalClassSuffix = this.config.data_classes[id];
|
4876 | let additionalClass = "";
|
4877 | if (additionalClassSuffix) {
|
4878 | additionalClass = ` ${classes.target}-${additionalClassSuffix}`;
|
4879 | }
|
4880 | return this.generateClass(classes.target, id) + additionalClass;
|
4881 | },
|
4882 | classFocus(d) {
|
4883 | return this.classFocused(d) + this.classDefocused(d);
|
4884 | },
|
4885 | classFocused(d) {
|
4886 | return ` ${this.state.focusedTargetIds.indexOf(d.id) >= 0 ? classes.focused : ""}`;
|
4887 | },
|
4888 | classDefocused(d) {
|
4889 | return ` ${this.state.defocusedTargetIds.indexOf(d.id) >= 0 ? classes.defocused : ""}`;
|
4890 | },
|
4891 | getTargetSelectorSuffix(targetId) {
|
4892 | const targetStr = targetId || targetId === 0 ? `-${targetId}` : "";
|
4893 | return targetStr.replace(/[\x00-\x20\x7F-\xA0\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g, "-");
|
4894 | },
|
4895 | selectorTarget(id, prefix = "", postfix = "") {
|
4896 | const target = this.getTargetSelectorSuffix(id);
|
4897 | return `${prefix}.${classes.target + target} ${postfix}, ${prefix}.${classes.circles + target} ${postfix}`;
|
4898 | },
|
4899 | selectorTargets(idsValue, prefix) {
|
4900 | const ids = idsValue || [];
|
4901 | return ids.length ? ids.map((id) => this.selectorTarget(id, prefix)) : null;
|
4902 | },
|
4903 | selectorLegend(id) {
|
4904 | return `.${classes.legendItem + this.getTargetSelectorSuffix(id)}`;
|
4905 | },
|
4906 | selectorLegends(ids) {
|
4907 | return (ids == null ? void 0 : ids.length) ? ids.map((id) => this.selectorLegend(id)) : null;
|
4908 | }
|
4909 | });
|
4910 |
|
4911 |
|
4912 | var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webpack_require__(7);
|
4913 | ;
|
4914 |
|
4915 |
|
4916 |
|
4917 |
|
4918 |
|
4919 |
|
4920 | const colorizePattern = (pattern, color, id) => {
|
4921 | const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(true));
|
4922 | node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color);
|
4923 | return {
|
4924 | id,
|
4925 | node: node.node()
|
4926 | };
|
4927 | };
|
4928 | function getColorFromCss(element) {
|
4929 | const cacheKey = KEY.colorPattern;
|
4930 | const { body } = browser_doc;
|
4931 | let pattern = body[cacheKey];
|
4932 | if (!pattern) {
|
4933 | const delimiter = ";";
|
4934 | const content = element.classed($COLOR.colorPattern, true).style("background-image");
|
4935 | element.classed($COLOR.colorPattern, false);
|
4936 | if (content.indexOf(delimiter) > -1) {
|
4937 | pattern = content.replace(/url[^#]*|["'()]|(\s|%20)/g, "").split(delimiter).map((v) => v.trim().replace(/[\"'\s]/g, "")).filter(Boolean);
|
4938 | body[cacheKey] = pattern;
|
4939 | }
|
4940 | }
|
4941 | return pattern;
|
4942 | }
|
4943 | const schemeCategory10 = [
|
4944 | "#1f77b4",
|
4945 | "#ff7f0e",
|
4946 | "#2ca02c",
|
4947 | "#d62728",
|
4948 | "#9467bd",
|
4949 | "#8c564b",
|
4950 | "#e377c2",
|
4951 | "#7f7f7f",
|
4952 | "#bcbd22",
|
4953 | "#17becf"
|
4954 | ];
|
4955 | var internals_color = ({
|
4956 | generateColor() {
|
4957 | const $$ = this;
|
4958 | const { $el, config } = $$;
|
4959 | const colors = config.data_colors;
|
4960 | const callback = config.data_color;
|
4961 | const ids = [];
|
4962 | let pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(getColorFromCss($el.chart) || schemeCategory10).range();
|
4963 | const originalColorPattern = pattern;
|
4964 | if (isFunction(config.color_tiles)) {
|
4965 | const tiles = config.color_tiles.bind($$.api)();
|
4966 | const colorizedPatterns = pattern.map((p, index) => {
|
4967 | const color = p.replace(/[#\(\)\s,]/g, "");
|
4968 | const id = `${$$.state.datetimeId}-pattern-${color}-${index}`;
|
4969 | return colorizePattern(tiles[index % tiles.length], p, id);
|
4970 | });
|
4971 | pattern = colorizedPatterns.map((p) => `url(#${p.id})`);
|
4972 | $$.patterns = colorizedPatterns;
|
4973 | }
|
4974 | return function(d) {
|
4975 | var _a;
|
4976 | const id = d.id || ((_a = d.data) == null ? void 0 : _a.id) || d;
|
4977 | const isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id];
|
4978 | let color;
|
4979 | if (isFunction(colors[id])) {
|
4980 | color = colors[id].bind($$.api)(d);
|
4981 | } else if (colors[id]) {
|
4982 | color = colors[id];
|
4983 | } else {
|
4984 | if (ids.indexOf(id) < 0) {
|
4985 | ids.push(id);
|
4986 | }
|
4987 | color = isLine ? originalColorPattern[ids.indexOf(id) % originalColorPattern.length] : pattern[ids.indexOf(id) % pattern.length];
|
4988 | colors[id] = color;
|
4989 | }
|
4990 | return isFunction(callback) ? callback.bind($$.api)(color, d) : color;
|
4991 | };
|
4992 | },
|
4993 | generateLevelColor() {
|
4994 | const $$ = this;
|
4995 | const { config } = $$;
|
4996 | const colors = config.color_pattern;
|
4997 | const threshold = config.color_threshold;
|
4998 | const asValue = threshold.unit === "value";
|
4999 | const max = threshold.max || 100;
|
5000 | const values = threshold.values && threshold.values.length ? threshold.values : [];
|
5001 | return notEmpty(threshold) ? function(value) {
|
5002 | const v = asValue ? value : value * 100 / max;
|
5003 | let color = colors[colors.length - 1];
|
5004 | for (let i = 0, l = values.length; i < l; i++) {
|
5005 | if (v <= values[i]) {
|
5006 | color = colors[i];
|
5007 | break;
|
5008 | }
|
5009 | }
|
5010 | return color;
|
5011 | } : null;
|
5012 | },
|
5013 | |
5014 |
|
5015 |
|
5016 |
|
5017 |
|
5018 |
|
5019 | generateTextBGColorFilter(color, attr = {
|
5020 | x: 0,
|
5021 | y: 0,
|
5022 | width: 1,
|
5023 | height: 1
|
5024 | }) {
|
5025 | const $$ = this;
|
5026 | const { $el, state } = $$;
|
5027 | if (color) {
|
5028 | let ids = [];
|
5029 | if (isString(color)) {
|
5030 | ids.push("");
|
5031 | } else if (isObject(color)) {
|
5032 | ids = Object.keys(color);
|
5033 | }
|
5034 | ids.forEach((v) => {
|
5035 | const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${isString(color) ? $$.getTargetSelectorSuffix(color) : ""}`;
|
5036 | $el.defs.append("filter").attr("x", attr.x).attr("y", attr.y).attr("width", attr.width).attr("height", attr.height).attr("id", id).html(
|
5037 | `<feFlood flood-color="${v === "" ? color : color[v]}" />
|
5038 | <feComposite in="SourceGraphic" />`
|
5039 | );
|
5040 | });
|
5041 | }
|
5042 | },
|
5043 | |
5044 |
|
5045 |
|
5046 |
|
5047 |
|
5048 |
|
5049 | getGradienColortUrl(id) {
|
5050 | return `url(#${this.state.datetimeId}-gradient${this.getTargetSelectorSuffix(id)})`;
|
5051 | },
|
5052 | |
5053 |
|
5054 |
|
5055 |
|
5056 |
|
5057 |
|
5058 | updateLinearGradient() {
|
5059 | const $$ = this;
|
5060 | const { config, data: { targets }, state: { datetimeId }, $el: { defs } } = $$;
|
5061 | targets.forEach((d) => {
|
5062 | const id = `${datetimeId}-gradient${$$.getTargetSelectorSuffix(d.id)}`;
|
5063 | const radialGradient = $$.hasPointType() && config.point_radialGradient;
|
5064 | const supportedType = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar";
|
5065 | if ((radialGradient || supportedType) && defs.select(`#${id}`).empty()) {
|
5066 | const color = $$.color(d);
|
5067 | const gradient = {
|
5068 | defs: null,
|
5069 | stops: []
|
5070 | };
|
5071 | if (radialGradient) {
|
5072 | const {
|
5073 | cx = 0.3,
|
5074 | cy = 0.3,
|
5075 | r = 0.7,
|
5076 | stops = [[0.1, color, 0], [0.9, color, 1]]
|
5077 | } = radialGradient;
|
5078 | gradient.stops = stops;
|
5079 | gradient.defs = defs.append("radialGradient").attr("id", `${id}`).attr("cx", cx).attr("cy", cy).attr("r", r);
|
5080 | } else {
|
5081 | const isRotated = config.axis_rotated;
|
5082 | const {
|
5083 | x = isRotated ? [1, 0] : [0, 0],
|
5084 | y = isRotated ? [0, 0] : [0, 1],
|
5085 | stops = [[0, color, 1], [1, color, 0]]
|
5086 | } = config[`${supportedType}_linearGradient`];
|
5087 | gradient.stops = stops;
|
5088 | gradient.defs = defs.append("linearGradient").attr("id", `${id}`).attr("x1", x[0]).attr("x2", x[1]).attr("y1", y[0]).attr("y2", y[1]);
|
5089 | }
|
5090 | gradient.stops.forEach((v) => {
|
5091 | const [offset, stopColor, stopOpacity] = v;
|
5092 | const colorValue = isFunction(stopColor) ? stopColor.bind($$.api)(d.id) : stopColor;
|
5093 | gradient.defs && gradient.defs.append("stop").attr("offset", offset).attr("stop-color", colorValue || color).attr("stop-opacity", stopOpacity);
|
5094 | });
|
5095 | }
|
5096 | });
|
5097 | },
|
5098 | |
5099 |
|
5100 |
|
5101 |
|
5102 |
|
5103 |
|
5104 |
|
5105 | setOverColor(isOver, d) {
|
5106 | const $$ = this;
|
5107 | const { config, $el: { main } } = $$;
|
5108 | const onover = config.color_onover;
|
5109 | let color = isOver ? onover : $$.color;
|
5110 | if (isObject(color)) {
|
5111 | color = ({ id }) => id in onover ? onover[id] : $$.color(id);
|
5112 | } else if (isString(color)) {
|
5113 | color = () => onover;
|
5114 | } else if (isFunction(onover)) {
|
5115 | color = color.bind($$.api);
|
5116 | }
|
5117 | main.selectAll(
|
5118 | isObject(d) ? (
|
5119 |
|
5120 | `.${$ARC.arc}${$$.getTargetSelectorSuffix(d.id)}`
|
5121 | ) : `.${$SHAPE.shape}-${d}`
|
5122 | ).style("fill", color);
|
5123 | }
|
5124 | });
|
5125 |
|
5126 | ;
|
5127 |
|
5128 |
|
5129 | var domain = ({
|
5130 | getYDomainMinMax(targets, type) {
|
5131 | const $$ = this;
|
5132 | const { axis, config } = $$;
|
5133 | const isMin = type === "min";
|
5134 | const dataGroups = config.data_groups;
|
5135 | const ids = $$.mapToIds(targets);
|
5136 | const ys = $$.getValuesAsIdKeyed(targets);
|
5137 | if (dataGroups.length > 0) {
|
5138 | const hasValue = $$[`has${isMin ? "Negative" : "Positive"}ValueInTargets`](targets);
|
5139 | dataGroups.forEach((groupIds) => {
|
5140 | const idsInGroup = groupIds.filter((v) => ids.indexOf(v) >= 0);
|
5141 | if (idsInGroup.length) {
|
5142 | const baseId = idsInGroup[0];
|
5143 | const baseAxisId = axis.getId(baseId);
|
5144 | if (hasValue && ys[baseId]) {
|
5145 | ys[baseId] = ys[baseId].map((v) => (isMin ? v < 0 : v > 0) ? v : 0);
|
5146 | }
|
5147 | idsInGroup.filter((v, i) => i > 0).forEach((id) => {
|
5148 | if (ys[id]) {
|
5149 | const axisId = axis.getId(id);
|
5150 | ys[id].forEach((v, i) => {
|
5151 | const val = +v;
|
5152 | const meetCondition = isMin ? val > 0 : val < 0;
|
5153 | if (axisId === baseAxisId && !(hasValue && meetCondition)) {
|
5154 | ys[baseId][i] += val;
|
5155 | }
|
5156 | });
|
5157 | }
|
5158 | });
|
5159 | }
|
5160 | });
|
5161 | }
|
5162 | return getMinMax(type, Object.keys(ys).map((key) => getMinMax(type, ys[key])));
|
5163 | },
|
5164 | |
5165 |
|
5166 |
|
5167 |
|
5168 |
|
5169 |
|
5170 | isHiddenTargetWithYDomain(id) {
|
5171 | const $$ = this;
|
5172 | return $$.state.hiddenTargetIds.some((v) => $$.axis.getId(v) === id);
|
5173 | },
|
5174 | getYDomain(targets, axisId, xDomain) {
|
5175 | const $$ = this;
|
5176 | const { axis, config, scale } = $$;
|
5177 | const pfx = `axis_${axisId}`;
|
5178 | if ($$.isStackNormalized()) {
|
5179 | return [0, 100];
|
5180 | }
|
5181 | const isLog = (scale == null ? void 0 : scale[axisId]) && scale[axisId].type === "log";
|
5182 | const targetsByAxisId = targets.filter((t) => axis.getId(t.id) === axisId);
|
5183 | const yTargets = xDomain ? $$.filterByXDomain(targetsByAxisId, xDomain) : targetsByAxisId;
|
5184 | if (yTargets.length === 0) {
|
5185 | if ($$.isHiddenTargetWithYDomain(axisId)) {
|
5186 | return scale[axisId].domain();
|
5187 | } else {
|
5188 | return axisId === "y2" ? scale.y.domain() : (
|
5189 |
|
5190 |
|
5191 | $$.getYDomain(targets, "y2", xDomain)
|
5192 | );
|
5193 | }
|
5194 | }
|
5195 | const yMin = config[`${pfx}_min`];
|
5196 | const yMax = config[`${pfx}_max`];
|
5197 | const center = config[`${pfx}_center`];
|
5198 | const isInverted = config[`${pfx}_inverted`];
|
5199 | const showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated;
|
5200 | const showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated;
|
5201 | let yDomainMin = $$.getYDomainMinMax(yTargets, "min");
|
5202 | let yDomainMax = $$.getYDomainMinMax(yTargets, "max");
|
5203 | let isZeroBased = [TYPE.BAR, TYPE.BUBBLE, TYPE.SCATTER, ...TYPE_BY_CATEGORY.Line].some((v) => {
|
5204 | const type = v.indexOf("area") > -1 ? "area" : v;
|
5205 | return $$.hasType(v, yTargets, true) && config[`${type}_zerobased`];
|
5206 | });
|
5207 | yDomainMin = isValue(yMin) ? yMin : isValue(yMax) ? yDomainMin <= yMax ? yDomainMin : yMax - 10 : yDomainMin;
|
5208 | yDomainMax = isValue(yMax) ? yMax : isValue(yMin) ? yMin <= yDomainMax ? yDomainMax : yMin + 10 : yDomainMax;
|
5209 | if (isNaN(yDomainMin)) {
|
5210 | yDomainMin = 0;
|
5211 | }
|
5212 | if (isNaN(yDomainMax)) {
|
5213 | yDomainMax = yDomainMin;
|
5214 | }
|
5215 | if (yDomainMin === yDomainMax) {
|
5216 | yDomainMin < 0 ? yDomainMax = 0 : yDomainMin = 0;
|
5217 | }
|
5218 | const isAllPositive = yDomainMin >= 0 && yDomainMax >= 0;
|
5219 | const isAllNegative = yDomainMin <= 0 && yDomainMax <= 0;
|
5220 | if (isValue(yMin) && isAllPositive || isValue(yMax) && isAllNegative) {
|
5221 | isZeroBased = false;
|
5222 | }
|
5223 | if (isZeroBased) {
|
5224 | isAllPositive && (yDomainMin = 0);
|
5225 | isAllNegative && (yDomainMax = 0);
|
5226 | }
|
5227 | const domainLength = Math.abs(yDomainMax - yDomainMin);
|
5228 | let padding = { top: domainLength * 0.1, bottom: domainLength * 0.1 };
|
5229 | if (isDefined(center)) {
|
5230 | const yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
|
5231 | yDomainMax = center + yDomainAbs;
|
5232 | yDomainMin = center - yDomainAbs;
|
5233 | }
|
5234 | if (showHorizontalDataLabel) {
|
5235 | const diff = diffDomain(scale.y.range());
|
5236 | const ratio = $$.getDataLabelLength(yDomainMin, yDomainMax, "width").map((v) => v / diff);
|
5237 | ["bottom", "top"].forEach((v, i) => {
|
5238 | padding[v] += domainLength * (ratio[i] / (1 - ratio[0] - ratio[1]));
|
5239 | });
|
5240 | } else if (showVerticalDataLabel) {
|
5241 | const lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, "height");
|
5242 | ["bottom", "top"].forEach((v, i) => {
|
5243 | padding[v] += $$.convertPixelToScale("y", lengths[i], domainLength);
|
5244 | });
|
5245 | }
|
5246 | padding = $$.getResettedPadding(padding);
|
5247 | const p = config[`${pfx}_padding`];
|
5248 | if (notEmpty(p)) {
|
5249 | ["bottom", "top"].forEach((v) => {
|
5250 | padding[v] = axis.getPadding(p, v, padding[v], domainLength);
|
5251 | });
|
5252 | }
|
5253 | if (isZeroBased) {
|
5254 | isAllPositive && (padding.bottom = yDomainMin);
|
5255 | isAllNegative && (padding.top = -yDomainMax);
|
5256 | }
|
5257 | const domain = isLog ? [yDomainMin, yDomainMax].map((v) => v < 0 ? 0 : v) : [yDomainMin - padding.bottom, yDomainMax + padding.top];
|
5258 | return isInverted ? domain.reverse() : domain;
|
5259 | },
|
5260 | getXDomainMinMax(targets, type) {
|
5261 | var _a;
|
5262 | const $$ = this;
|
5263 | const configValue = $$.config[`axis_x_${type}`];
|
5264 | const dataValue = getMinMax(
|
5265 | type,
|
5266 | targets.map((t) => getMinMax(type, t.values.map((v) => v.x)))
|
5267 | );
|
5268 | let value = isObject(configValue) ? configValue.value : configValue;
|
5269 | value = isDefined(value) && ((_a = $$.axis) == null ? void 0 : _a.isTimeSeries()) ? parseDate.bind(this)(value) : value;
|
5270 | if (isObject(configValue) && configValue.fit && (type === "min" && value < dataValue || type === "max" && value > dataValue)) {
|
5271 | value = void 0;
|
5272 | }
|
5273 | return isDefined(value) ? value : dataValue;
|
5274 | },
|
5275 | |
5276 |
|
5277 |
|
5278 |
|
5279 |
|
5280 |
|
5281 |
|
5282 | getXDomainPadding(domain, tickCount) {
|
5283 | const $$ = this;
|
5284 | const { axis, config } = $$;
|
5285 | const padding = config.axis_x_padding;
|
5286 | const isTimeSeriesTickCount = axis.isTimeSeries() && tickCount;
|
5287 | const diff = diffDomain(domain);
|
5288 | let defaultValue;
|
5289 | if (axis.isCategorized() || isTimeSeriesTickCount) {
|
5290 | defaultValue = 0;
|
5291 | } else if ($$.hasType("bar")) {
|
5292 | const maxDataCount = $$.getMaxDataCount();
|
5293 | defaultValue = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : 0.5;
|
5294 | } else {
|
5295 | defaultValue = $$.getResettedPadding(diff * 0.01);
|
5296 | }
|
5297 | let { left = defaultValue, right = defaultValue } = isNumber(padding) ? { left: padding, right: padding } : padding;
|
5298 | if (padding.unit === "px") {
|
5299 | const domainLength = Math.abs(diff + diff * 0.2);
|
5300 | left = axis.getPadding(padding, "left", defaultValue, domainLength);
|
5301 | right = axis.getPadding(padding, "right", defaultValue, domainLength);
|
5302 | } else {
|
5303 | const range = diff + left + right;
|
5304 | if (isTimeSeriesTickCount && range) {
|
5305 | const relativeTickWidth = diff / tickCount / range;
|
5306 | left = left / range / relativeTickWidth;
|
5307 | right = right / range / relativeTickWidth;
|
5308 | }
|
5309 | }
|
5310 | return { left, right };
|
5311 | },
|
5312 | |
5313 |
|
5314 |
|
5315 |
|
5316 |
|
5317 |
|
5318 | getXDomain(targets) {
|
5319 | const $$ = this;
|
5320 | const { axis, config, scale: { x } } = $$;
|
5321 | const isInverted = config.axis_x_inverted;
|
5322 | const domain = [
|
5323 | $$.getXDomainMinMax(targets, "min"),
|
5324 | $$.getXDomainMinMax(targets, "max")
|
5325 | ];
|
5326 | let [min = 0, max = 0] = domain;
|
5327 | if (x.type !== "log") {
|
5328 | const isCategorized = axis.isCategorized();
|
5329 | const isTimeSeries = axis.isTimeSeries();
|
5330 | const padding = $$.getXDomainPadding(domain);
|
5331 | let [firstX, lastX] = domain;
|
5332 | if (firstX - lastX === 0 && !isCategorized) {
|
5333 | if (isTimeSeries) {
|
5334 | firstX = new Date(firstX.getTime() * 0.5);
|
5335 | lastX = new Date(lastX.getTime() * 1.5);
|
5336 | } else {
|
5337 | firstX = firstX === 0 ? 1 : firstX * 0.5;
|
5338 | lastX = lastX === 0 ? -1 : lastX * 1.5;
|
5339 | }
|
5340 | }
|
5341 | if (firstX || firstX === 0) {
|
5342 | min = isTimeSeries ? new Date(firstX.getTime() - padding.left) : firstX - padding.left;
|
5343 | }
|
5344 | if (lastX || lastX === 0) {
|
5345 | max = isTimeSeries ? new Date(lastX.getTime() + padding.right) : lastX + padding.right;
|
5346 | }
|
5347 | }
|
5348 | return isInverted ? [max, min] : [min, max];
|
5349 | },
|
5350 | updateXDomain(targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
|
5351 | var _a;
|
5352 | const $$ = this;
|
5353 | const { config, org, scale: { x, subX } } = $$;
|
5354 | const zoomEnabled = config.zoom_enabled;
|
5355 | if (withUpdateOrgXDomain) {
|
5356 | x.domain(domain || sortValue($$.getXDomain(targets), !config.axis_x_inverted));
|
5357 | org.xDomain = x.domain();
|
5358 | subX.domain(x.domain());
|
5359 | (_a = $$.brush) == null ? void 0 : _a.scale(subX);
|
5360 | }
|
5361 | if (withUpdateXDomain) {
|
5362 | const domainValue = domain || (!$$.brush || brushEmpty($$)) ? org.xDomain : getBrushSelection($$).map(subX.invert);
|
5363 | x.domain(domainValue);
|
5364 | }
|
5365 | if (withUpdateOrgXDomain || withUpdateXDomain) {
|
5366 | zoomEnabled && $$.zoom.updateScaleExtent();
|
5367 | }
|
5368 | withTrim && x.domain($$.trimXDomain(x.orgDomain()));
|
5369 | return x.domain();
|
5370 | },
|
5371 | |
5372 |
|
5373 |
|
5374 |
|
5375 |
|
5376 |
|
5377 | trimXDomain(domain) {
|
5378 | const $$ = this;
|
5379 | const isInverted = $$.config.axis_x_inverted;
|
5380 | const zoomDomain = $$.getZoomDomain();
|
5381 | const [min, max] = zoomDomain;
|
5382 | if (isInverted ? domain[0] >= min : domain[0] <= min) {
|
5383 | domain[1] = +domain[1] + (min - domain[0]);
|
5384 | domain[0] = min;
|
5385 | }
|
5386 | if (isInverted ? domain[1] <= max : domain[1] >= max) {
|
5387 | domain[0] = +domain[0] - (domain[1] - max);
|
5388 | domain[1] = max;
|
5389 | }
|
5390 | return domain;
|
5391 | },
|
5392 | |
5393 |
|
5394 |
|
5395 |
|
5396 |
|
5397 |
|
5398 |
|
5399 | getZoomDomain(type = "zoom", getCurrent = false) {
|
5400 | const $$ = this;
|
5401 | const { config, scale, org } = $$;
|
5402 | let [min, max] = getCurrent && scale[type] ? scale[type].domain() : org.xDomain;
|
5403 | if (type === "zoom") {
|
5404 | if (isDefined(config.zoom_x_min)) {
|
5405 | min = getMinMax("min", [min, config.zoom_x_min]);
|
5406 | }
|
5407 | if (isDefined(config.zoom_x_max)) {
|
5408 | max = getMinMax("max", [max, config.zoom_x_max]);
|
5409 | }
|
5410 | }
|
5411 | return [min, max];
|
5412 | },
|
5413 | |
5414 |
|
5415 |
|
5416 |
|
5417 |
|
5418 |
|
5419 |
|
5420 | getZoomDomainValue(domainValue) {
|
5421 | const $$ = this;
|
5422 | const { config, axis } = $$;
|
5423 | if (axis.isCategorized() && Array.isArray(domainValue)) {
|
5424 | const isInverted = config.axis_x_inverted;
|
5425 | const domain = domainValue.map(
|
5426 | (v, i) => Number(v) + (i === 0 ? +isInverted : +!isInverted)
|
5427 | );
|
5428 | return domain;
|
5429 | }
|
5430 | return domainValue;
|
5431 | },
|
5432 | |
5433 |
|
5434 |
|
5435 |
|
5436 |
|
5437 |
|
5438 |
|
5439 |
|
5440 | convertPixelToScale(type, pixels, domainLength) {
|
5441 | const $$ = this;
|
5442 | const { config, state } = $$;
|
5443 | const isRotated = config.axis_rotated;
|
5444 | let length;
|
5445 | if (type === "x") {
|
5446 | length = isRotated ? "height" : "width";
|
5447 | } else {
|
5448 | length = isRotated ? "width" : "height";
|
5449 | }
|
5450 | return domainLength * (pixels / state[length]);
|
5451 | },
|
5452 | |
5453 |
|
5454 |
|
5455 |
|
5456 |
|
5457 |
|
5458 |
|
5459 |
|
5460 | withinRange(domain, current = [0, 0], range) {
|
5461 | const $$ = this;
|
5462 | const isInverted = $$.config.axis_x_inverted;
|
5463 | const [min, max] = range;
|
5464 | if (Array.isArray(domain)) {
|
5465 | const target = [...domain];
|
5466 | isInverted && target.reverse();
|
5467 | if (target[0] < target[1]) {
|
5468 | return domain.every(
|
5469 | (v, i) => (i === 0 ? isInverted ? +v <= min : +v >= min : isInverted ? +v >= max : +v <= max) && !domain.every((v2, i2) => v2 === current[i2])
|
5470 | );
|
5471 | }
|
5472 | }
|
5473 | return false;
|
5474 | }
|
5475 | });
|
5476 |
|
5477 | ;
|
5478 |
|
5479 | function getFormat($$, typeValue, v) {
|
5480 | const { config } = $$;
|
5481 | const type = `axis_${typeValue}_tick_format`;
|
5482 | const format = config[type] ? config[type] : $$.defaultValueFormat;
|
5483 | return format.call($$.api, v);
|
5484 | }
|
5485 | var format = ({
|
5486 | yFormat(v) {
|
5487 | return getFormat(this, "y", v);
|
5488 | },
|
5489 | y2Format(v) {
|
5490 | return getFormat(this, "y2", v);
|
5491 | },
|
5492 | |
5493 |
|
5494 |
|
5495 |
|
5496 |
|
5497 | getDefaultValueFormat() {
|
5498 | const $$ = this;
|
5499 | const { defaultArcValueFormat, yFormat, y2Format } = $$;
|
5500 | const hasArc = $$.hasArcType(null, ["gauge", "polar", "radar"]);
|
5501 | return function(v, ratio, id) {
|
5502 | const format = hasArc ? defaultArcValueFormat : $$.axis && $$.axis.getId(id) === "y2" ? y2Format : yFormat;
|
5503 | return format.call($$, v, ratio);
|
5504 | };
|
5505 | },
|
5506 | defaultValueFormat(v) {
|
5507 | return isArray(v) ? v.join("~") : isValue(v) ? +v : "";
|
5508 | },
|
5509 | defaultArcValueFormat(v, ratio) {
|
5510 | return `${(ratio * 100).toFixed(1)}%`;
|
5511 | },
|
5512 | defaultPolarValueFormat(v) {
|
5513 | return `${v}`;
|
5514 | },
|
5515 | dataLabelFormat(targetId) {
|
5516 | const $$ = this;
|
5517 | const dataLabels = $$.config.data_labels;
|
5518 | const defaultFormat = (v) => {
|
5519 | const delimiter = "~";
|
5520 | let res = v;
|
5521 | if (isArray(v)) {
|
5522 | res = v.join(delimiter);
|
5523 | } else if (isObject(v)) {
|
5524 | res = Object.values(v).join(delimiter);
|
5525 | }
|
5526 | return res;
|
5527 | };
|
5528 | let format = defaultFormat;
|
5529 | if (isFunction(dataLabels.format)) {
|
5530 | format = dataLabels.format;
|
5531 | } else if (isObjectType(dataLabels.format)) {
|
5532 | if (dataLabels.format[targetId]) {
|
5533 | format = dataLabels.format[targetId] === true ? defaultFormat : dataLabels.format[targetId];
|
5534 | } else {
|
5535 | format = () => "";
|
5536 | }
|
5537 | }
|
5538 | return format.bind($$.api);
|
5539 | }
|
5540 | });
|
5541 |
|
5542 | ;
|
5543 |
|
5544 |
|
5545 |
|
5546 |
|
5547 |
|
5548 | function getLegendColor(id) {
|
5549 | const $$ = this;
|
5550 | const data = $$.getDataById(id);
|
5551 | const color = $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
|
5552 | return color;
|
5553 | }
|
5554 | function getFormattedText(id, formatted = true) {
|
5555 | var _a;
|
5556 | const { config } = this;
|
5557 | let text = (_a = config.data_names[id]) != null ? _a : id;
|
5558 | if (formatted && isFunction(config.legend_format)) {
|
5559 | text = config.legend_format(text, id !== text ? id : void 0);
|
5560 | }
|
5561 | return text;
|
5562 | }
|
5563 | var internals_legend = ({
|
5564 | |
5565 |
|
5566 |
|
5567 |
|
5568 | initLegend() {
|
5569 | const $$ = this;
|
5570 | const { config, $el } = $$;
|
5571 | $$.legendItemTextBox = {};
|
5572 | $$.state.legendHasRendered = false;
|
5573 | if (config.legend_show) {
|
5574 | if (!config.legend_contents_bindto) {
|
5575 | $el.legend = $$.$el.svg.append("g").classed($LEGEND.legend, true).attr("transform", $$.getTranslate("legend"));
|
5576 | }
|
5577 | $$.updateLegend();
|
5578 | } else {
|
5579 | $$.state.hiddenLegendIds = $$.mapToIds($$.data.targets);
|
5580 | }
|
5581 | },
|
5582 | |
5583 |
|
5584 |
|
5585 |
|
5586 |
|
5587 |
|
5588 |
|
5589 | updateLegend(targetIds, options, transitions) {
|
5590 | var _a;
|
5591 | const $$ = this;
|
5592 | const { config, state, scale, $el } = $$;
|
5593 | const optionz = options || {
|
5594 | withTransform: false,
|
5595 | withTransitionForTransform: false,
|
5596 | withTransition: false
|
5597 | };
|
5598 | optionz.withTransition = getOption(optionz, "withTransition", true);
|
5599 | optionz.withTransitionForTransform = getOption(optionz, "withTransitionForTransform", true);
|
5600 | if (config.legend_contents_bindto && config.legend_contents_template) {
|
5601 | $$.updateLegendTemplate();
|
5602 | } else if (!state.hasTreemap) {
|
5603 | $$.updateLegendElement(
|
5604 | targetIds || $$.mapToIds($$.data.targets),
|
5605 | optionz,
|
5606 | transitions
|
5607 | );
|
5608 | }
|
5609 | (_a = $el.legend) == null ? void 0 : _a.selectAll(`.${$LEGEND.legendItem}`).classed($LEGEND.legendItemHidden, function(id) {
|
5610 | const hide = !$$.isTargetToShow(id);
|
5611 | if (hide) {
|
5612 | this.style.opacity = null;
|
5613 | }
|
5614 | return hide;
|
5615 | });
|
5616 | $$.updateScales(false, !scale.zoom);
|
5617 | $$.updateSvgSize();
|
5618 | $$.transformAll(optionz.withTransitionForTransform, transitions);
|
5619 | state.legendHasRendered = true;
|
5620 | },
|
5621 | |
5622 |
|
5623 |
|
5624 |
|
5625 | updateLegendTemplate() {
|
5626 | const $$ = this;
|
5627 | const { config, $el } = $$;
|
5628 | const wrapper = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.legend_contents_bindto);
|
5629 | const template = config.legend_contents_template;
|
5630 | if (!wrapper.empty()) {
|
5631 | const targets = $$.mapToIds($$.data.targets);
|
5632 | const ids = [];
|
5633 | let html = "";
|
5634 | targets.forEach((v) => {
|
5635 | const content = isFunction(template) ? template.bind($$.api)(v, $$.color(v), $$.api.data(v)[0].values) : tplProcess(template, {
|
5636 | COLOR: $$.color(v),
|
5637 | TITLE: v
|
5638 | });
|
5639 | if (content) {
|
5640 | ids.push(v);
|
5641 | html += content;
|
5642 | }
|
5643 | });
|
5644 | const legendItem = wrapper.html(html).selectAll(function() {
|
5645 | return this.childNodes;
|
5646 | }).data(ids);
|
5647 | $$.setLegendItem(legendItem);
|
5648 | $el.legend = wrapper;
|
5649 | }
|
5650 | },
|
5651 | |
5652 |
|
5653 |
|
5654 |
|
5655 |
|
5656 | updateSizeForLegend(size) {
|
5657 | const $$ = this;
|
5658 | const {
|
5659 | config,
|
5660 | state: {
|
5661 | isLegendTop,
|
5662 | isLegendLeft,
|
5663 | isLegendRight,
|
5664 | isLegendInset,
|
5665 | current
|
5666 | }
|
5667 | } = $$;
|
5668 | const { width, height } = size;
|
5669 | const insetLegendPosition = {
|
5670 | top: isLegendTop ? $$.getCurrentPaddingByDirection("top") + config.legend_inset_y + 5.5 : current.height - height - $$.getCurrentPaddingByDirection("bottom") - config.legend_inset_y,
|
5671 | left: isLegendLeft ? $$.getCurrentPaddingByDirection("left") + config.legend_inset_x + 0.5 : current.width - width - $$.getCurrentPaddingByDirection("right") - config.legend_inset_x + 0.5
|
5672 | };
|
5673 | $$.state.margin3 = {
|
5674 | top: isLegendRight ? 0 : isLegendInset ? insetLegendPosition.top : current.height - height,
|
5675 | right: NaN,
|
5676 | bottom: 0,
|
5677 | left: isLegendRight ? current.width - width : isLegendInset ? insetLegendPosition.left : 0
|
5678 | };
|
5679 | },
|
5680 | |
5681 |
|
5682 |
|
5683 |
|
5684 |
|
5685 | transformLegend(withTransition) {
|
5686 | const $$ = this;
|
5687 | const { $el: { legend }, $T } = $$;
|
5688 | $T(legend, withTransition).attr("transform", $$.getTranslate("legend"));
|
5689 | },
|
5690 | |
5691 |
|
5692 |
|
5693 |
|
5694 |
|
5695 | updateLegendStep(step) {
|
5696 | this.state.legendStep = step;
|
5697 | },
|
5698 | |
5699 |
|
5700 |
|
5701 |
|
5702 |
|
5703 | updateLegendItemWidth(width) {
|
5704 | this.state.legendItemWidth = width;
|
5705 | },
|
5706 | |
5707 |
|
5708 |
|
5709 |
|
5710 |
|
5711 | updateLegendItemHeight(height) {
|
5712 | this.state.legendItemHeight = height;
|
5713 | },
|
5714 | |
5715 |
|
5716 |
|
5717 |
|
5718 |
|
5719 |
|
5720 | updateLegendItemColor(id, color) {
|
5721 | const { legend } = this.$el;
|
5722 | if (legend) {
|
5723 | legend.select(`.${$LEGEND.legendItem}-${id} line`).style("stroke", color);
|
5724 | }
|
5725 | },
|
5726 | |
5727 |
|
5728 |
|
5729 |
|
5730 |
|
5731 | getLegendWidth() {
|
5732 | const $$ = this;
|
5733 | const { current: { width }, isLegendRight, isLegendInset, legendItemWidth, legendStep } = $$.state;
|
5734 | return $$.config.legend_show ? isLegendRight || isLegendInset ? legendItemWidth * (legendStep + 1) : width : 0;
|
5735 | },
|
5736 | |
5737 |
|
5738 |
|
5739 |
|
5740 |
|
5741 | getLegendHeight() {
|
5742 | var _a;
|
5743 | const $$ = this;
|
5744 | const { current, isLegendRight, legendItemHeight, legendStep } = $$.state;
|
5745 | const isFitPadding = ((_a = $$.config.padding) == null ? void 0 : _a.mode) === "fit";
|
5746 | const height = $$.config.legend_show ? isLegendRight ? current.height : Math.max(isFitPadding ? 10 : 20, legendItemHeight) * (legendStep + 1) : 0;
|
5747 | return height;
|
5748 | },
|
5749 | |
5750 |
|
5751 |
|
5752 |
|
5753 |
|
5754 |
|
5755 | opacityForUnfocusedLegend(legendItem) {
|
5756 | return legendItem.classed($LEGEND.legendItemHidden) ? null : "0.3";
|
5757 | },
|
5758 | |
5759 |
|
5760 |
|
5761 |
|
5762 |
|
5763 |
|
5764 | toggleFocusLegend(targetIds, focus) {
|
5765 | const $$ = this;
|
5766 | const { $el: { legend }, $T } = $$;
|
5767 | const targetIdz = $$.mapToTargetIds(targetIds);
|
5768 | legend && $T(legend.selectAll(`.${$LEGEND.legendItem}`).filter((id) => targetIdz.indexOf(id) >= 0).classed($FOCUS.legendItemFocused, focus)).style("opacity", function() {
|
5769 | return focus ? null : $$.opacityForUnfocusedLegend.call($$, (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this));
|
5770 | });
|
5771 | },
|
5772 | |
5773 |
|
5774 |
|
5775 |
|
5776 | revertLegend() {
|
5777 | const $$ = this;
|
5778 | const { $el: { legend }, $T } = $$;
|
5779 | legend && $T(legend.selectAll(`.${$LEGEND.legendItem}`).classed($FOCUS.legendItemFocused, false)).style("opacity", null);
|
5780 | },
|
5781 | |
5782 |
|
5783 |
|
5784 |
|
5785 |
|
5786 | showLegend(targetIds) {
|
5787 | const $$ = this;
|
5788 | const { config, $el, $T } = $$;
|
5789 | if (!config.legend_show) {
|
5790 | config.legend_show = true;
|
5791 | $el.legend ? $el.legend.style("visibility", null) : $$.initLegend();
|
5792 | !$$.state.legendHasRendered && $$.updateLegend();
|
5793 | }
|
5794 | $$.removeHiddenLegendIds(targetIds);
|
5795 | $T(
|
5796 | $el.legend.selectAll($$.selectorLegends(targetIds)).style("visibility", null)
|
5797 | ).style("opacity", null);
|
5798 | },
|
5799 | |
5800 |
|
5801 |
|
5802 |
|
5803 |
|
5804 | hideLegend(targetIds) {
|
5805 | const $$ = this;
|
5806 | const { config, $el: { legend } } = $$;
|
5807 | if (config.legend_show && isEmpty(targetIds)) {
|
5808 | config.legend_show = false;
|
5809 | legend.style("visibility", "hidden");
|
5810 | }
|
5811 | $$.addHiddenLegendIds(targetIds);
|
5812 | legend.selectAll($$.selectorLegends(targetIds)).style("opacity", "0").style("visibility", "hidden");
|
5813 | },
|
5814 | |
5815 |
|
5816 |
|
5817 |
|
5818 |
|
5819 |
|
5820 |
|
5821 | getLegendItemTextBox(id, textElement) {
|
5822 | const $$ = this;
|
5823 | const { cache, state } = $$;
|
5824 | let data;
|
5825 | const cacheKey = KEY.legendItemTextBox;
|
5826 | if (id) {
|
5827 | data = !state.redrawing && cache.get(cacheKey) || {};
|
5828 | if (!data[id]) {
|
5829 | data[id] = $$.getTextRect(textElement, $LEGEND.legendItem);
|
5830 | cache.add(cacheKey, data);
|
5831 | }
|
5832 | data = data[id];
|
5833 | }
|
5834 | return data;
|
5835 | },
|
5836 | |
5837 |
|
5838 |
|
5839 |
|
5840 |
|
5841 | setLegendItem(item) {
|
5842 | const $$ = this;
|
5843 | const { $el, api, config, state } = $$;
|
5844 | const isTouch = state.inputType === "touch";
|
5845 | const hasGauge = $$.hasType("gauge");
|
5846 | const useCssRule = config.boost_useCssRule;
|
5847 | const interaction = config.legend_item_interaction;
|
5848 | item.attr("class", function(id) {
|
5849 | const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
5850 | const itemClass = !node.empty() && node.attr("class") || "";
|
5851 | return itemClass + $$.generateClass($LEGEND.legendItem, id);
|
5852 | }).style("visibility", (id) => $$.isLegendToShow(id) ? null : "hidden");
|
5853 | if (config.interaction_enabled) {
|
5854 | if (useCssRule) {
|
5855 | [
|
5856 | [`.${$LEGEND.legendItem}`, "cursor:pointer"],
|
5857 | [`.${$LEGEND.legendItem} text`, "pointer-events:none"],
|
5858 | [`.${$LEGEND.legendItemPoint} text`, "pointer-events:none"],
|
5859 | [`.${$LEGEND.legendItemTile}`, "pointer-events:none"],
|
5860 | [`.${$LEGEND.legendItemEvent}`, "fill-opacity:0"]
|
5861 | ].forEach((v) => {
|
5862 | const [selector, props] = v;
|
5863 | $$.setCssRule(false, selector, [props])($el.legend);
|
5864 | });
|
5865 | }
|
5866 | item.on(
|
5867 | interaction.dblclick ? "dblclick" : "click",
|
5868 | interaction || isFunction(config.legend_item_onclick) ? function(event, id) {
|
5869 | if (!callFn(
|
5870 | config.legend_item_onclick,
|
5871 | api,
|
5872 | id,
|
5873 | !state.hiddenTargetIds.includes(id)
|
5874 | )) {
|
5875 | const { altKey, target, type } = event;
|
5876 | if (type === "dblclick" || altKey) {
|
5877 | if (state.hiddenTargetIds.length && target.parentNode.getAttribute("class").indexOf(
|
5878 | $LEGEND.legendItemHidden
|
5879 | ) === -1) {
|
5880 | api.show();
|
5881 | } else {
|
5882 | api.hide();
|
5883 | api.show(id);
|
5884 | }
|
5885 | } else {
|
5886 | api.toggle(id);
|
5887 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused, false);
|
5888 | }
|
5889 | }
|
5890 | isTouch && $$.hideTooltip();
|
5891 | } : null
|
5892 | );
|
5893 | !isTouch && item.on("mouseout", interaction || isFunction(config.legend_item_onout) ? function(event, id) {
|
5894 | if (!callFn(
|
5895 | config.legend_item_onout,
|
5896 | api,
|
5897 | id,
|
5898 | !state.hiddenTargetIds.includes(id)
|
5899 | )) {
|
5900 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused, false);
|
5901 | if (hasGauge) {
|
5902 | $$.undoMarkOverlapped($$, `.${$GAUGE.gaugeValue}`);
|
5903 | }
|
5904 | $$.api.revert();
|
5905 | }
|
5906 | } : null).on("mouseover", interaction || isFunction(config.legend_item_onover) ? function(event, id) {
|
5907 | if (!callFn(
|
5908 | config.legend_item_onover,
|
5909 | api,
|
5910 | id,
|
5911 | !state.hiddenTargetIds.includes(id)
|
5912 | )) {
|
5913 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused, true);
|
5914 | if (hasGauge) {
|
5915 | $$.markOverlapped(id, $$, `.${$GAUGE.gaugeValue}`);
|
5916 | }
|
5917 | if (!state.transiting && $$.isTargetToShow(id)) {
|
5918 | api.focus(id);
|
5919 | }
|
5920 | }
|
5921 | } : null);
|
5922 | !item.empty() && item.on("click mouseout mouseover") && item.style("cursor", $$.getStylePropValue("pointer"));
|
5923 | }
|
5924 | },
|
5925 | |
5926 |
|
5927 |
|
5928 |
|
5929 |
|
5930 |
|
5931 | updateLegendElement(targetIds, options) {
|
5932 | const $$ = this;
|
5933 | const { config, state, $el: { legend }, $T } = $$;
|
5934 | const legendType = config.legend_item_tile_type;
|
5935 | const isRectangle = legendType !== "circle";
|
5936 | const legendItemR = config.legend_item_tile_r;
|
5937 | const itemTileSize = {
|
5938 | width: isRectangle ? config.legend_item_tile_width : legendItemR * 2,
|
5939 | height: isRectangle ? config.legend_item_tile_height : legendItemR * 2
|
5940 | };
|
5941 | const dimension = {
|
5942 | padding: {
|
5943 | top: 4,
|
5944 | right: 10
|
5945 | },
|
5946 | max: {
|
5947 | width: 0,
|
5948 | height: 0
|
5949 | },
|
5950 | posMin: 10,
|
5951 | step: 0,
|
5952 | tileWidth: itemTileSize.width + 5,
|
5953 | totalLength: 0
|
5954 | };
|
5955 | const sizes = {
|
5956 | offsets: {},
|
5957 | widths: {},
|
5958 | heights: {},
|
5959 | margins: [0],
|
5960 | steps: {}
|
5961 | };
|
5962 | let xForLegend;
|
5963 | let yForLegend;
|
5964 | let background;
|
5965 | const targetIdz = targetIds.filter((id) => !isDefined(config.data_names[id]) || config.data_names[id] !== null);
|
5966 | const withTransition = options.withTransition;
|
5967 | const updatePositions = $$.getUpdateLegendPositions(targetIdz, dimension, sizes);
|
5968 | if (state.isLegendInset) {
|
5969 | dimension.step = config.legend_inset_step ? config.legend_inset_step : targetIdz.length;
|
5970 | $$.updateLegendStep(dimension.step);
|
5971 | }
|
5972 | if (state.isLegendRight) {
|
5973 | xForLegend = (id) => dimension.max.width * sizes.steps[id];
|
5974 | yForLegend = (id) => sizes.margins[sizes.steps[id]] + sizes.offsets[id];
|
5975 | } else if (state.isLegendInset) {
|
5976 | xForLegend = (id) => dimension.max.width * sizes.steps[id] + 10;
|
5977 | yForLegend = (id) => sizes.margins[sizes.steps[id]] + sizes.offsets[id];
|
5978 | } else {
|
5979 | xForLegend = (id) => sizes.margins[sizes.steps[id]] + sizes.offsets[id];
|
5980 | yForLegend = (id) => dimension.max.height * sizes.steps[id];
|
5981 | }
|
5982 | const posFn = {
|
5983 | xText: (id, i) => xForLegend(id, i) + 4 + itemTileSize.width,
|
5984 | xRect: (id, i) => xForLegend(id, i),
|
5985 | x1Tile: (id, i) => xForLegend(id, i) - 2,
|
5986 | x2Tile: (id, i) => xForLegend(id, i) - 2 + itemTileSize.width,
|
5987 | yText: (id, i) => yForLegend(id, i) + 9,
|
5988 | yRect: (id, i) => yForLegend(id, i) - 5,
|
5989 | yTile: (id, i) => yForLegend(id, i) + 4
|
5990 | };
|
5991 | $$.generateLegendItem(targetIdz, itemTileSize, updatePositions, posFn);
|
5992 | background = legend.select(`.${$LEGEND.legendBackground} rect`);
|
5993 | if (state.isLegendInset && dimension.max.width > 0 && background.size() === 0) {
|
5994 | background = legend.insert("g", `.${$LEGEND.legendItem}`).attr("class", $LEGEND.legendBackground).append("rect");
|
5995 | }
|
5996 | if (config.legend_tooltip) {
|
5997 | legend.selectAll("title").data(targetIdz).text((id) => getFormattedText.bind($$)(id, false));
|
5998 | }
|
5999 | const texts = legend.selectAll("text").data(targetIdz).text((id) => getFormattedText.bind($$)(id)).each(function(id, i) {
|
6000 | updatePositions(this, id, i);
|
6001 | });
|
6002 | $T(texts, withTransition).attr("x", posFn.xText).attr("y", posFn.yText);
|
6003 | const rects = legend.selectAll(`rect.${$LEGEND.legendItemEvent}`).data(targetIdz);
|
6004 | $T(rects, withTransition).attr("width", (id) => sizes.widths[id]).attr("height", (id) => sizes.heights[id]).attr("x", posFn.xRect).attr("y", posFn.yRect);
|
6005 | $$.updateLegendItemPos(targetIdz, withTransition, posFn);
|
6006 | if (background) {
|
6007 | $T(background, withTransition).attr("height", $$.getLegendHeight() - 12).attr("width", dimension.max.width * (dimension.step + 1) + 10);
|
6008 | }
|
6009 | $$.updateLegendItemWidth(dimension.max.width);
|
6010 | $$.updateLegendItemHeight(dimension.max.height);
|
6011 | $$.updateLegendStep(dimension.step);
|
6012 | },
|
6013 | |
6014 |
|
6015 |
|
6016 |
|
6017 |
|
6018 |
|
6019 |
|
6020 |
|
6021 | getUpdateLegendPositions(targetIdz, dimension, sizes) {
|
6022 | const $$ = this;
|
6023 | const { config, state } = $$;
|
6024 | const isLegendRightOrInset = state.isLegendRight || state.isLegendInset;
|
6025 | return function(textElement, id, index) {
|
6026 | const reset = index === 0;
|
6027 | const isLast = index === targetIdz.length - 1;
|
6028 | const box = $$.getLegendItemTextBox(id, textElement);
|
6029 | const itemWidth = box.width + dimension.tileWidth + (isLast && !isLegendRightOrInset ? 0 : dimension.padding.right) + config.legend_padding;
|
6030 | const itemHeight = box.height + dimension.padding.top;
|
6031 | const itemLength = isLegendRightOrInset ? itemHeight : itemWidth;
|
6032 | const areaLength = isLegendRightOrInset ? $$.getLegendHeight() : $$.getLegendWidth();
|
6033 | let margin;
|
6034 | const updateValues = function(id2, withoutStep) {
|
6035 | if (!withoutStep) {
|
6036 | margin = (areaLength - dimension.totalLength - itemLength) / 2;
|
6037 | if (margin < dimension.posMin) {
|
6038 | margin = (areaLength - itemLength) / 2;
|
6039 | dimension.totalLength = 0;
|
6040 | dimension.step++;
|
6041 | }
|
6042 | }
|
6043 | sizes.steps[id2] = dimension.step;
|
6044 | sizes.margins[dimension.step] = state.isLegendInset ? 10 : margin;
|
6045 | sizes.offsets[id2] = dimension.totalLength;
|
6046 | dimension.totalLength += itemLength;
|
6047 | };
|
6048 | if (reset) {
|
6049 | dimension.totalLength = 0;
|
6050 | dimension.step = 0;
|
6051 | dimension.max.width = 0;
|
6052 | dimension.max.height = 0;
|
6053 | }
|
6054 | if (config.legend_show && !$$.isLegendToShow(id)) {
|
6055 | sizes.widths[id] = 0;
|
6056 | sizes.heights[id] = 0;
|
6057 | sizes.steps[id] = 0;
|
6058 | sizes.offsets[id] = 0;
|
6059 | return;
|
6060 | }
|
6061 | sizes.widths[id] = itemWidth;
|
6062 | sizes.heights[id] = itemHeight;
|
6063 | if (!dimension.max.width || itemWidth >= dimension.max.width) {
|
6064 | dimension.max.width = itemWidth;
|
6065 | }
|
6066 | if (!dimension.max.height || itemHeight >= dimension.max.height) {
|
6067 | dimension.max.height = itemHeight;
|
6068 | }
|
6069 | const maxLength = isLegendRightOrInset ? dimension.max.height : dimension.max.width;
|
6070 | if (config.legend_equally) {
|
6071 | Object.keys(sizes.widths).forEach((id2) => sizes.widths[id2] = dimension.max.width);
|
6072 | Object.keys(sizes.heights).forEach(
|
6073 | (id2) => sizes.heights[id2] = dimension.max.height
|
6074 | );
|
6075 | margin = (areaLength - maxLength * targetIdz.length) / 2;
|
6076 | if (margin < dimension.posMin) {
|
6077 | dimension.totalLength = 0;
|
6078 | dimension.step = 0;
|
6079 | targetIdz.forEach((id2) => updateValues(id2));
|
6080 | } else {
|
6081 | updateValues(id, true);
|
6082 | }
|
6083 | } else {
|
6084 | updateValues(id);
|
6085 | }
|
6086 | };
|
6087 | },
|
6088 | |
6089 |
|
6090 |
|
6091 |
|
6092 |
|
6093 |
|
6094 |
|
6095 |
|
6096 | generateLegendItem(targetIdz, itemTileSize, updatePositions, posFn) {
|
6097 | const $$ = this;
|
6098 | const { config, state, $el: { legend } } = $$;
|
6099 | const usePoint = config.legend_usePoint;
|
6100 | const legendItemR = config.legend_item_tile_r;
|
6101 | const legendType = config.legend_item_tile_type;
|
6102 | const isRectangle = legendType !== "circle";
|
6103 | const isLegendRightOrInset = state.isLegendRight || state.isLegendInset;
|
6104 | const pos = -200;
|
6105 | const l = legend.selectAll(`.${$LEGEND.legendItem}`).data(targetIdz).enter().append("g");
|
6106 | $$.setLegendItem(l);
|
6107 | if (config.legend_tooltip) {
|
6108 | l.append("title").text((id) => id);
|
6109 | }
|
6110 | l.append("text").text((id) => getFormattedText.bind($$)(id)).each(function(id, i) {
|
6111 | updatePositions(this, id, i);
|
6112 | }).style("pointer-events", $$.getStylePropValue("none")).attr("x", isLegendRightOrInset ? posFn.xText : pos).attr("y", isLegendRightOrInset ? pos : posFn.yText);
|
6113 | l.append("rect").attr("class", $LEGEND.legendItemEvent).style("fill-opacity", $$.getStylePropValue("0")).attr("x", isLegendRightOrInset ? posFn.xRect : pos).attr("y", isLegendRightOrInset ? pos : posFn.yRect);
|
6114 | if (usePoint) {
|
6115 | const ids = [];
|
6116 | l.append((d) => {
|
6117 | const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
|
6118 | ids.indexOf(d) === -1 && ids.push(d);
|
6119 | let point = pattern[ids.indexOf(d) % pattern.length];
|
6120 | if (point === "rectangle") {
|
6121 | point = "rect";
|
6122 | }
|
6123 | return browser_doc.createElementNS(
|
6124 | external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg,
|
6125 | "hasValidPointType" in $$ && $$.hasValidPointType(point) ? point : "use"
|
6126 | );
|
6127 | }).attr("class", $LEGEND.legendItemPoint).style("fill", getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).attr("href", (data, idx, selection) => {
|
6128 | const node = selection[idx];
|
6129 | const nodeName = node.nodeName.toLowerCase();
|
6130 | const id = $$.getTargetSelectorSuffix(data);
|
6131 | return nodeName === "use" ? `#${state.datetimeId}-point${id}` : void 0;
|
6132 | });
|
6133 | } else {
|
6134 | l.append(isRectangle ? "line" : legendType).attr("class", $LEGEND.legendItemTile).style("stroke", getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).call((selection) => {
|
6135 | if (legendType === "circle") {
|
6136 | selection.attr("r", legendItemR).style("fill", getLegendColor.bind($$)).attr("cx", isLegendRightOrInset ? posFn.x2Tile : pos).attr("cy", isLegendRightOrInset ? pos : posFn.yTile);
|
6137 | } else if (isRectangle) {
|
6138 | selection.attr("stroke-width", itemTileSize.height).attr("x1", isLegendRightOrInset ? posFn.x1Tile : pos).attr("y1", isLegendRightOrInset ? pos : posFn.yTile).attr("x2", isLegendRightOrInset ? posFn.x2Tile : pos).attr("y2", isLegendRightOrInset ? pos : posFn.yTile);
|
6139 | }
|
6140 | });
|
6141 | }
|
6142 | },
|
6143 | |
6144 |
|
6145 |
|
6146 |
|
6147 |
|
6148 |
|
6149 |
|
6150 | updateLegendItemPos(targetIdz, withTransition, posFn) {
|
6151 | const $$ = this;
|
6152 | const { config, $el: { legend }, $T } = $$;
|
6153 | const usePoint = config.legend_usePoint;
|
6154 | const legendType = config.legend_item_tile_type;
|
6155 | const isRectangle = legendType !== "circle";
|
6156 | if (usePoint) {
|
6157 | const tiles = legend.selectAll(`.${$LEGEND.legendItemPoint}`).data(targetIdz);
|
6158 | $T(tiles, withTransition).each(function() {
|
6159 | const nodeName = this.nodeName.toLowerCase();
|
6160 | const pointR = config.point_r;
|
6161 | let x = "x";
|
6162 | let y = "y";
|
6163 | let xOffset = 2;
|
6164 | let yOffset = 2.5;
|
6165 | let radius = null;
|
6166 | let width = null;
|
6167 | let height = null;
|
6168 | if (nodeName === "circle") {
|
6169 | const size = pointR * 0.2;
|
6170 | x = "cx";
|
6171 | y = "cy";
|
6172 | radius = pointR + size;
|
6173 | xOffset = pointR * 2;
|
6174 | yOffset = -size;
|
6175 | } else if (nodeName === "rect") {
|
6176 | const size = pointR * 2.5;
|
6177 | width = size;
|
6178 | height = size;
|
6179 | yOffset = 3;
|
6180 | }
|
6181 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).attr(x, (d) => posFn.x1Tile(d) + xOffset).attr(y, (d) => posFn.yTile(d) - yOffset).attr("r", radius).attr("width", width).attr("height", height);
|
6182 | });
|
6183 | } else {
|
6184 | const tiles = legend.selectAll(`.${$LEGEND.legendItemTile}`).data(targetIdz);
|
6185 | $T(tiles, withTransition).style("stroke", getLegendColor.bind($$)).call((selection) => {
|
6186 | if (legendType === "circle") {
|
6187 | selection.attr("cx", (d) => {
|
6188 | const x2 = posFn.x2Tile(d);
|
6189 | return x2 - (x2 - posFn.x1Tile(d)) / 2;
|
6190 | }).attr("cy", posFn.yTile);
|
6191 | } else if (isRectangle) {
|
6192 | selection.attr("x1", posFn.x1Tile).attr("y1", posFn.yTile).attr("x2", posFn.x2Tile).attr("y2", posFn.yTile);
|
6193 | }
|
6194 | });
|
6195 | }
|
6196 | }
|
6197 | });
|
6198 |
|
6199 |
|
6200 | var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_ = __webpack_require__(8);
|
6201 | ;
|
6202 |
|
6203 |
|
6204 |
|
6205 |
|
6206 | var redraw = ({
|
6207 | redraw(options = {}) {
|
6208 | var _a, _b, _c, _d;
|
6209 | const $$ = this;
|
6210 | const { config, state, $el } = $$;
|
6211 | const { main, treemap } = $el;
|
6212 | state.redrawing = true;
|
6213 | const targetsToShow = $$.filterTargetsToShow($$.data.targets);
|
6214 | const { flow, initializing } = options;
|
6215 | const wth = $$.getWithOption(options);
|
6216 | const duration = wth.Transition ? config.transition_duration : 0;
|
6217 | const durationForExit = wth.TransitionForExit ? duration : 0;
|
6218 | const durationForAxis = wth.TransitionForAxis ? duration : 0;
|
6219 | const transitions = (_a = $$.axis) == null ? void 0 : _a.generateTransitions(durationForAxis);
|
6220 | $$.updateSizes(initializing);
|
6221 | if (wth.Legend && config.legend_show) {
|
6222 | options.withTransition = !!duration;
|
6223 | !treemap && $$.updateLegend($$.mapToIds($$.data.targets), options, transitions);
|
6224 | } else if (wth.Dimension) {
|
6225 | $$.updateDimension(true);
|
6226 | }
|
6227 | config.data_empty_label_text && main.select(`text.${$TEXT.text}.${$COMMON.empty}`).attr("x", state.width / 2).attr("y", state.height / 2).text(config.data_empty_label_text).style("display", targetsToShow.length ? "none" : null);
|
6228 | if (state.hasAxis) {
|
6229 | $$.axis.redrawAxis(targetsToShow, wth, transitions, flow, initializing);
|
6230 | $$.hasGrid() && $$.updateGrid();
|
6231 | config.regions.length && $$.updateRegion();
|
6232 | ["bar", "candlestick", "line", "area"].forEach((v) => {
|
6233 | const name = capitalize(v);
|
6234 | if (/^(line|area)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
|
6235 | $$[`update${name}`](wth.TransitionForExit);
|
6236 | }
|
6237 | });
|
6238 | $el.text && main.selectAll(`.${$SELECT.selectedCircles}`).filter($$.isBarType.bind($$)).selectAll("circle").remove();
|
6239 | if (config.interaction_enabled && !flow && wth.EventRect) {
|
6240 | $$.redrawEventRect();
|
6241 | (_b = $$.bindZoomEvent) == null ? void 0 : _b.call($$);
|
6242 | }
|
6243 | } else {
|
6244 | $el.arcs && $$.redrawArc(duration, durationForExit, wth.Transform);
|
6245 | $el.radar && $$.redrawRadar();
|
6246 | $el.polar && $$.redrawPolar();
|
6247 | $el.funnel && $$.redrawFunnel();
|
6248 | treemap && $$.updateTreemap(durationForExit);
|
6249 | }
|
6250 | if (!state.resizing && !treemap && ($$.hasPointType() || state.hasRadar)) {
|
6251 | $$.updateCircle();
|
6252 | } else if ((_c = $$.hasLegendDefsPoint) == null ? void 0 : _c.call($$)) {
|
6253 | $$.data.targets.forEach($$.point("create", this));
|
6254 | }
|
6255 | $$.hasDataLabel() && !$$.hasArcType(null, ["radar"]) && $$.updateText();
|
6256 | (_d = $$.redrawTitle) == null ? void 0 : _d.call($$);
|
6257 | initializing && $$.updateTypesElements();
|
6258 | $$.generateRedrawList(targetsToShow, flow, duration, wth.Subchart);
|
6259 | $$.updateTooltipOnRedraw();
|
6260 | $$.callPluginHook("$redraw", options, duration);
|
6261 | },
|
6262 | |
6263 |
|
6264 |
|
6265 |
|
6266 |
|
6267 |
|
6268 |
|
6269 |
|
6270 | generateRedrawList(targets, flow, duration, withSubchart) {
|
6271 | const $$ = this;
|
6272 | const { config, state } = $$;
|
6273 | const shape = $$.getDrawShape();
|
6274 | if (state.hasAxis) {
|
6275 | config.subchart_show && $$.redrawSubchart(withSubchart, duration, shape);
|
6276 | }
|
6277 | const flowFn = flow && $$.generateFlow({
|
6278 | targets,
|
6279 | flow,
|
6280 | duration: flow.duration,
|
6281 | shape,
|
6282 | xv: $$.xv.bind($$)
|
6283 | });
|
6284 | const withTransition = (duration || flowFn) && isTabVisible();
|
6285 | const redrawList = $$.getRedrawList(shape, flow, flowFn, withTransition);
|
6286 | const afterRedraw = () => {
|
6287 | flowFn && flowFn();
|
6288 | state.redrawing = false;
|
6289 | callFn(config.onrendered, $$.api);
|
6290 | };
|
6291 | if (afterRedraw) {
|
6292 | if (withTransition && redrawList.length) {
|
6293 | const waitForDraw = generateWait();
|
6294 | (0,external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_.transition)().duration(duration).each(() => {
|
6295 | redrawList.reduce((acc, t1) => acc.concat(t1), []).forEach((t) => waitForDraw.add(t));
|
6296 | }).call(waitForDraw, afterRedraw);
|
6297 | } else if (!state.transiting) {
|
6298 | afterRedraw();
|
6299 | }
|
6300 | }
|
6301 | $$.mapToIds($$.data.targets).forEach((id) => {
|
6302 | state.withoutFadeIn[id] = true;
|
6303 | });
|
6304 | },
|
6305 | getRedrawList(shape, flow, flowFn, withTransition) {
|
6306 | const $$ = this;
|
6307 | const { config, state: { hasAxis, hasRadar, hasTreemap }, $el: { grid } } = $$;
|
6308 | const { cx, cy, xForText, yForText } = shape.pos;
|
6309 | const list = [];
|
6310 | if (hasAxis) {
|
6311 | if (config.grid_x_lines.length || config.grid_y_lines.length) {
|
6312 | list.push($$.redrawGrid(withTransition));
|
6313 | }
|
6314 | if (config.regions.length) {
|
6315 | list.push($$.redrawRegion(withTransition));
|
6316 | }
|
6317 | Object.keys(shape.type).forEach((v) => {
|
6318 | const name = capitalize(v);
|
6319 | const drawFn = shape.type[v];
|
6320 | if (/^(area|line)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
|
6321 | list.push($$[`redraw${name}`](drawFn, withTransition));
|
6322 | }
|
6323 | });
|
6324 | !flow && grid.main && list.push($$.updateGridFocus());
|
6325 | }
|
6326 | if (!$$.hasArcType() || hasRadar) {
|
6327 | notEmpty(config.data_labels) && config.data_labels !== false && list.push($$.redrawText(xForText, yForText, flow, withTransition));
|
6328 | }
|
6329 | if (($$.hasPointType() || hasRadar) && !$$.isPointFocusOnly()) {
|
6330 | $$.redrawCircle && list.push($$.redrawCircle(cx, cy, withTransition, flowFn));
|
6331 | }
|
6332 | if (hasTreemap) {
|
6333 | list.push($$.redrawTreemap(withTransition));
|
6334 | }
|
6335 | return list;
|
6336 | },
|
6337 | updateAndRedraw(options = {}) {
|
6338 | const $$ = this;
|
6339 | const { config, state } = $$;
|
6340 | let transitions;
|
6341 | options.withTransition = getOption(options, "withTransition", true);
|
6342 | options.withTransform = getOption(options, "withTransform", false);
|
6343 | options.withLegend = getOption(options, "withLegend", false);
|
6344 | options.withUpdateXDomain = true;
|
6345 | options.withUpdateOrgXDomain = true;
|
6346 | options.withTransitionForExit = false;
|
6347 | options.withTransitionForTransform = getOption(
|
6348 | options,
|
6349 | "withTransitionForTransform",
|
6350 | options.withTransition
|
6351 | );
|
6352 | if (!(options.withLegend && config.legend_show)) {
|
6353 | if (state.hasAxis) {
|
6354 | transitions = $$.axis.generateTransitions(
|
6355 | options.withTransitionForAxis ? config.transition_duration : 0
|
6356 | );
|
6357 | }
|
6358 | $$.updateScales();
|
6359 | $$.updateSvgSize();
|
6360 | $$.transformAll(options.withTransitionForTransform, transitions);
|
6361 | }
|
6362 | $$.redraw(options, transitions);
|
6363 | }
|
6364 | });
|
6365 |
|
6366 | ;
|
6367 |
|
6368 |
|
6369 | function getScale(type = "linear", min, max) {
|
6370 | const scale = {
|
6371 | linear: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear,
|
6372 | log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSymlog,
|
6373 | _log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLog,
|
6374 | time: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleTime,
|
6375 | utc: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleUtc
|
6376 | }[type]();
|
6377 | scale.type = type;
|
6378 | /_?log/.test(type) && scale.clamp(true);
|
6379 | return scale.range([min != null ? min : 0, max != null ? max : 1]);
|
6380 | }
|
6381 | var scale = ({
|
6382 | |
6383 |
|
6384 |
|
6385 |
|
6386 |
|
6387 |
|
6388 |
|
6389 |
|
6390 |
|
6391 | getXScale(min, max, domain, offset) {
|
6392 | const $$ = this;
|
6393 | const scale = $$.state.loading !== "append" && $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
|
6394 | return $$.getCustomizedXScale(
|
6395 | domain ? scale.domain(domain) : scale,
|
6396 | offset
|
6397 | );
|
6398 | },
|
6399 | |
6400 |
|
6401 |
|
6402 |
|
6403 |
|
6404 |
|
6405 |
|
6406 |
|
6407 |
|
6408 | getYScale(id, min, max, domain) {
|
6409 | const $$ = this;
|
6410 | const scale = getScale($$.axis.getAxisType(id), min, max);
|
6411 | domain && scale.domain(domain);
|
6412 | return scale;
|
6413 | },
|
6414 | |
6415 |
|
6416 |
|
6417 |
|
6418 |
|
6419 |
|
6420 |
|
6421 | getYScaleById(id, isSub = false) {
|
6422 | var _a;
|
6423 | const isY2 = ((_a = this.axis) == null ? void 0 : _a.getId(id)) === "y2";
|
6424 | const key = isSub ? isY2 ? "subY2" : "subY" : isY2 ? "y2" : "y";
|
6425 | return this.scale[key];
|
6426 | },
|
6427 | |
6428 |
|
6429 |
|
6430 |
|
6431 |
|
6432 |
|
6433 |
|
6434 | getCustomizedXScale(scaleValue, offsetValue) {
|
6435 | const $$ = this;
|
6436 | const offset = offsetValue || (() => $$.axis.x.tickOffset());
|
6437 | const isInverted = $$.config.axis_x_inverted;
|
6438 | const scale = function(d) {
|
6439 | return scaleValue(d) + offset();
|
6440 | };
|
6441 | for (const key in scaleValue) {
|
6442 | scale[key] = scaleValue[key];
|
6443 | }
|
6444 | scale.orgDomain = () => scaleValue.domain();
|
6445 | scale.orgScale = () => scaleValue;
|
6446 | if ($$.axis.isCategorized()) {
|
6447 | scale.domain = function(domainValue) {
|
6448 | let domain = domainValue;
|
6449 | if (!arguments.length) {
|
6450 | domain = this.orgDomain();
|
6451 | return isInverted ? [domain[0] + 1, domain[1]] : [domain[0], domain[1] + 1];
|
6452 | }
|
6453 | scaleValue.domain(domain);
|
6454 | return scale;
|
6455 | };
|
6456 | }
|
6457 | return scale;
|
6458 | },
|
6459 | |
6460 |
|
6461 |
|
6462 |
|
6463 |
|
6464 |
|
6465 | updateScales(isInit, updateXDomain = true) {
|
6466 | var _a, _b;
|
6467 | const $$ = this;
|
6468 | const {
|
6469 | axis,
|
6470 | config,
|
6471 | format,
|
6472 | org,
|
6473 | scale,
|
6474 | state: { current, width, height, width2, height2, hasAxis, hasTreemap }
|
6475 | } = $$;
|
6476 | if (hasAxis) {
|
6477 | const isRotated = config.axis_rotated;
|
6478 | const resettedPadding = $$.getResettedPadding(1);
|
6479 | const min = {
|
6480 | x: isRotated ? resettedPadding : 0,
|
6481 | y: isRotated ? 0 : height,
|
6482 | subX: isRotated ? 1 : 0,
|
6483 | subY: isRotated ? 0 : height2
|
6484 | };
|
6485 | const max = {
|
6486 | x: isRotated ? height : width,
|
6487 | y: isRotated ? width : resettedPadding,
|
6488 | subX: isRotated ? height : width,
|
6489 | subY: isRotated ? width2 : 1
|
6490 | };
|
6491 | const xDomain = updateXDomain && ((_a = scale.x) == null ? void 0 : _a.orgDomain());
|
6492 | const xSubDomain = updateXDomain && org.xDomain;
|
6493 | scale.x = $$.getXScale(min.x, max.x, xDomain, () => axis.x.tickOffset());
|
6494 | scale.subX = $$.getXScale(min.x, max.x, xSubDomain, (d) => {
|
6495 | var _a2;
|
6496 | return d % 1 ? 0 : ((_a2 = axis.subX) != null ? _a2 : axis.x).tickOffset();
|
6497 | });
|
6498 | format.xAxisTick = axis.getXAxisTickFormat();
|
6499 | format.subXAxisTick = axis.getXAxisTickFormat(true);
|
6500 | axis.setAxis("x", scale.x, config.axis_x_tick_outer, isInit);
|
6501 | if (config.subchart_show) {
|
6502 | axis.setAxis("subX", scale.subX, config.axis_x_tick_outer, isInit);
|
6503 | }
|
6504 | scale.y = $$.getYScale(
|
6505 | "y",
|
6506 | min.y,
|
6507 | max.y,
|
6508 | scale.y ? scale.y.domain() : config.axis_y_default
|
6509 | );
|
6510 | scale.subY = $$.getYScale(
|
6511 | "y",
|
6512 | min.subY,
|
6513 | max.subY,
|
6514 | scale.subY ? scale.subY.domain() : config.axis_y_default
|
6515 | );
|
6516 | axis.setAxis("y", scale.y, config.axis_y_tick_outer, isInit);
|
6517 | if (config.axis_y2_show) {
|
6518 | scale.y2 = $$.getYScale(
|
6519 | "y2",
|
6520 | min.y,
|
6521 | max.y,
|
6522 | scale.y2 ? scale.y2.domain() : config.axis_y2_default
|
6523 | );
|
6524 | scale.subY2 = $$.getYScale(
|
6525 | "y2",
|
6526 | min.subY,
|
6527 | max.subY,
|
6528 | scale.subY2 ? scale.subY2.domain() : config.axis_y2_default
|
6529 | );
|
6530 | axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
|
6531 | }
|
6532 | } else if (hasTreemap) {
|
6533 | const padding = $$.getCurrentPadding();
|
6534 | scale.x = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear)().rangeRound([padding.left, current.width - padding.right]);
|
6535 | scale.y = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear)().rangeRound([padding.top, current.height - padding.bottom]);
|
6536 | } else {
|
6537 | (_b = $$.updateArc) == null ? void 0 : _b.call($$);
|
6538 | }
|
6539 | },
|
6540 | |
6541 |
|
6542 |
|
6543 |
|
6544 |
|
6545 |
|
6546 | xx(d) {
|
6547 | const $$ = this;
|
6548 | const { config, scale: { x, zoom } } = $$;
|
6549 | const fn = config.zoom_enabled && zoom ? zoom : x;
|
6550 | return d ? fn(isValue(d.x) ? d.x : d) : null;
|
6551 | },
|
6552 | xv(d) {
|
6553 | const $$ = this;
|
6554 | const { axis, config, scale: { x, zoom } } = $$;
|
6555 | const fn = config.zoom_enabled && zoom ? zoom : x;
|
6556 | let value = $$.getBaseValue(d);
|
6557 | if (axis.isTimeSeries()) {
|
6558 | value = parseDate.call($$, value);
|
6559 | } else if (axis.isCategorized() && isString(value)) {
|
6560 | value = config.axis_x_categories.indexOf(value);
|
6561 | }
|
6562 | return fn(value);
|
6563 | },
|
6564 | yv(d) {
|
6565 | const $$ = this;
|
6566 | const { scale: { y, y2 } } = $$;
|
6567 | const yScale = d.axis && d.axis === "y2" ? y2 : y;
|
6568 | return yScale($$.getBaseValue(d));
|
6569 | },
|
6570 | subxx(d) {
|
6571 | return d ? this.scale.subX(d.x) : null;
|
6572 | }
|
6573 | });
|
6574 |
|
6575 | ;
|
6576 |
|
6577 |
|
6578 |
|
6579 |
|
6580 | var size = ({
|
6581 | |
6582 |
|
6583 |
|
6584 |
|
6585 | setContainerSize() {
|
6586 | const $$ = this;
|
6587 | const { state } = $$;
|
6588 | state.current.width = $$.getCurrentWidth();
|
6589 | state.current.height = $$.getCurrentHeight();
|
6590 | },
|
6591 | getCurrentWidth() {
|
6592 | const $$ = this;
|
6593 | return $$.config.size_width || $$.getParentWidth();
|
6594 | },
|
6595 | getCurrentHeight() {
|
6596 | const $$ = this;
|
6597 | const { config } = $$;
|
6598 | const h = config.size_height || $$.getParentHeight();
|
6599 | return h > 0 ? h : 320 / ($$.hasType("gauge") && !config.gauge_fullCircle ? 2 : 1);
|
6600 | },
|
6601 | |
6602 |
|
6603 |
|
6604 |
|
6605 |
|
6606 |
|
6607 | getParentRectValue(key) {
|
6608 | const offsetName = `offset${capitalize(key)}`;
|
6609 | let parent = this.$el.chart.node();
|
6610 | let v = 0;
|
6611 | while (v < 30 && parent && parent.tagName !== "BODY") {
|
6612 | try {
|
6613 | v = parent.getBoundingClientRect()[key];
|
6614 | } catch (e) {
|
6615 | if (offsetName in parent) {
|
6616 | v = parent[offsetName];
|
6617 | }
|
6618 | }
|
6619 | parent = parent.parentNode;
|
6620 | }
|
6621 | const bodySize = browser_doc.body[offsetName];
|
6622 | v > bodySize && (v = bodySize);
|
6623 | return v;
|
6624 | },
|
6625 | getParentWidth() {
|
6626 | return this.getParentRectValue("width");
|
6627 | },
|
6628 | getParentHeight() {
|
6629 | const h = this.$el.chart.style("height");
|
6630 | let height = 0;
|
6631 | if (h) {
|
6632 | height = /px$/.test(h) ? parseInt(h, 10) : this.getParentRectValue("height");
|
6633 | }
|
6634 | return height;
|
6635 | },
|
6636 | getSvgLeft(withoutRecompute) {
|
6637 | const $$ = this;
|
6638 | const { config, state: { hasAxis }, $el } = $$;
|
6639 | const isRotated = config.axis_rotated;
|
6640 | const hasLeftAxisRect = isRotated || !isRotated && !config.axis_y_inner;
|
6641 | const leftAxisClass = isRotated ? $AXIS.axisX : $AXIS.axisY;
|
6642 | const leftAxis = $el.main.select(`.${leftAxisClass}`).node();
|
6643 | const leftLabel = hasAxis && config[`axis_${isRotated ? "x" : "y"}_label`];
|
6644 | let labelWidth = 0;
|
6645 | if (hasAxis && (isString(leftLabel) || isString(leftLabel.text) || /^inner-/.test(leftLabel == null ? void 0 : leftLabel.position))) {
|
6646 | const label = $el.main.select(`.${leftAxisClass}-label`);
|
6647 | if (!label.empty()) {
|
6648 | labelWidth = label.node().getBoundingClientRect().left;
|
6649 | }
|
6650 | }
|
6651 | const svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : { right: 0 };
|
6652 | const chartRectLeft = $el.chart.node().getBoundingClientRect().left + labelWidth;
|
6653 | const hasArc = $$.hasArcType();
|
6654 | const svgLeft = svgRect.right - chartRectLeft - (hasArc ? 0 : $$.getCurrentPaddingByDirection("left", withoutRecompute));
|
6655 | return svgLeft > 0 ? svgLeft : 0;
|
6656 | },
|
6657 | updateDimension(withoutAxis) {
|
6658 | var _a;
|
6659 | const $$ = this;
|
6660 | const { config, state: { hasAxis }, $el } = $$;
|
6661 | if (hasAxis && !withoutAxis && $$.axis.x && config.axis_rotated) {
|
6662 | (_a = $$.axis.subX) == null ? void 0 : _a.create($el.axis.subX);
|
6663 | }
|
6664 | $$.updateScales(withoutAxis);
|
6665 | $$.updateSvgSize();
|
6666 | $$.transformAll(false);
|
6667 | },
|
6668 | updateSvgSize() {
|
6669 | const $$ = this;
|
6670 | const { config, state: { clip, current, hasAxis, width, height }, $el: { svg } } = $$;
|
6671 | if (config.resize_auto === "viewBox") {
|
6672 | svg.attr("viewBox", `0 0 ${current.width} ${current.height}`);
|
6673 | } else {
|
6674 | svg.attr("width", current.width).attr("height", current.height);
|
6675 | }
|
6676 | if (hasAxis) {
|
6677 | const brush = svg.select(`.${$SUBCHART.brush} .overlay`);
|
6678 | const brushSize = { width: 0, height: 0 };
|
6679 | if (brush.size()) {
|
6680 | brushSize.width = +brush.attr("width");
|
6681 | brushSize.height = +brush.attr("height");
|
6682 | }
|
6683 | svg.selectAll([`#${clip.id}`, `#${clip.idGrid}`]).select("rect").attr("width", width).attr("height", height);
|
6684 | svg.select(`#${clip.idXAxis}`).select("rect").call($$.setXAxisClipPath.bind($$));
|
6685 | svg.select(`#${clip.idYAxis}`).select("rect").call($$.setYAxisClipPath.bind($$));
|
6686 | clip.idSubchart && svg.select(`#${clip.idSubchart}`).select("rect").attr("width", width).attr("height", brushSize.height);
|
6687 | }
|
6688 | },
|
6689 | |
6690 |
|
6691 |
|
6692 |
|
6693 |
|
6694 |
|
6695 |
|
6696 |
|
6697 | getCurrentPaddingByDirection(type, withoutRecompute = false, withXAxisTickTextOverflow = false) {
|
6698 | var _a;
|
6699 | const $$ = this;
|
6700 | const { config, $el, state: { hasAxis } } = $$;
|
6701 | const isRotated = config.axis_rotated;
|
6702 | const isFitPadding = ((_a = config.padding) == null ? void 0 : _a.mode) === "fit";
|
6703 | const paddingOption = isNumber(config[`padding_${type}`]) ? config[`padding_${type}`] : void 0;
|
6704 | const axisId = hasAxis ? {
|
6705 | top: isRotated ? "y2" : null,
|
6706 | bottom: isRotated ? "y" : "x",
|
6707 | left: isRotated ? "x" : "y",
|
6708 | right: isRotated ? null : "y2"
|
6709 | }[type] : null;
|
6710 | const isLeftRight = /^(left|right)$/.test(type);
|
6711 | const isAxisInner = axisId && config[`axis_${axisId}_inner`];
|
6712 | const isAxisShow = axisId && config[`axis_${axisId}_show`];
|
6713 | const axesLen = axisId ? config[`axis_${axisId}_axes`].length : 0;
|
6714 | let axisSize = axisId ? isLeftRight ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : $$.getHorizontalAxisHeight(axisId) : 0;
|
6715 | const defaultPadding = 20;
|
6716 | let gap = 0;
|
6717 | if (!isFitPadding && isLeftRight) {
|
6718 | axisSize = ceil10(axisSize);
|
6719 | }
|
6720 | let padding = hasAxis && isLeftRight && (isAxisInner || isUndefined(paddingOption) && !isAxisShow) ? 0 : isFitPadding ? (isAxisShow ? axisSize : 0) + (paddingOption != null ? paddingOption : 0) : isUndefined(paddingOption) ? axisSize : paddingOption;
|
6721 | if (isLeftRight && hasAxis) {
|
6722 | if (axisId && (isFitPadding || isAxisInner) && config[`axis_${axisId}_label`].text) {
|
6723 | padding += $$.axis.getAxisLabelPosition(axisId).isOuter ? defaultPadding : 0;
|
6724 | }
|
6725 | if (type === "right") {
|
6726 | padding += isRotated ? !isFitPadding && isUndefined(paddingOption) ? 10 : 2 : !isAxisShow || isAxisInner ? isFitPadding ? 2 : 1 : 0;
|
6727 | padding += withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0;
|
6728 | } else if (type === "left" && isRotated && isUndefined(paddingOption)) {
|
6729 | padding = !config.axis_x_show ? 1 : isFitPadding ? axisSize : Math.max(axisSize, 40);
|
6730 | }
|
6731 | } else {
|
6732 | if (type === "top") {
|
6733 | if ($el.title && $el.title.node()) {
|
6734 | padding += $$.getTitlePadding();
|
6735 | }
|
6736 | gap = isRotated && !isAxisInner ? axesLen : 0;
|
6737 | } else if (type === "bottom" && hasAxis && isRotated && !isAxisShow) {
|
6738 | padding += 1;
|
6739 | }
|
6740 | }
|
6741 | return padding + axisSize * axesLen - gap;
|
6742 | },
|
6743 | getCurrentPadding(withXAxisTickTextOverflow = false) {
|
6744 | const $$ = this;
|
6745 | const [top, bottom, left, right] = ["top", "bottom", "left", "right"].map((v) => $$.getCurrentPaddingByDirection(v, null, withXAxisTickTextOverflow));
|
6746 | return { top, bottom, left, right };
|
6747 | },
|
6748 | |
6749 |
|
6750 |
|
6751 |
|
6752 |
|
6753 |
|
6754 |
|
6755 | getResettedPadding(v) {
|
6756 | const $$ = this;
|
6757 | const { config } = $$;
|
6758 | const isNum = isNumber(v);
|
6759 | let p = isNum ? 0 : {};
|
6760 | if (config.padding === false) {
|
6761 | !isNum && Object.keys(v).forEach((key) => {
|
6762 | p[key] = !isEmpty(config.data_labels) && config.data_labels !== false && key === "top" ? v[key] : 0;
|
6763 | });
|
6764 | } else {
|
6765 | p = v;
|
6766 | }
|
6767 | return p;
|
6768 | },
|
6769 | |
6770 |
|
6771 |
|
6772 |
|
6773 |
|
6774 | updateSizes(isInit) {
|
6775 | var _a, _b, _c, _d, _e;
|
6776 | const $$ = this;
|
6777 | const { config, state, $el: { legend } } = $$;
|
6778 | const isRotated = config.axis_rotated;
|
6779 | const isNonAxis = $$.hasArcType() || state.hasFunnel || state.hasTreemap;
|
6780 | const isFitPadding = ((_a = config.padding) == null ? void 0 : _a.mode) === "fit";
|
6781 | !isInit && $$.setContainerSize();
|
6782 | const currLegend = {
|
6783 | width: legend ? $$.getLegendWidth() : 0,
|
6784 | height: legend ? $$.getLegendHeight() : 0
|
6785 | };
|
6786 | if (!isNonAxis && config.axis_x_show && config.axis_x_tick_autorotate) {
|
6787 | $$.updateXAxisTickClip();
|
6788 | }
|
6789 | const legendSize = {
|
6790 | right: config.legend_show && state.isLegendRight ? $$.getLegendWidth() + (isFitPadding ? 0 : 20) : 0,
|
6791 | bottom: !config.legend_show || state.isLegendRight || state.isLegendInset ? 0 : currLegend.height
|
6792 | };
|
6793 | const xAxisHeight = isRotated || isNonAxis ? 0 : $$.getHorizontalAxisHeight("x");
|
6794 | const subchartXAxisHeight = config.subchart_axis_x_show && config.subchart_axis_x_tick_text_show ? xAxisHeight : 30;
|
6795 | const subchartHeight = config.subchart_show && !isNonAxis ? config.subchart_size_height + subchartXAxisHeight : 0;
|
6796 | const gaugeHeight = $$.hasType("gauge") && config.arc_needle_show && !config.gauge_fullCircle && !config.gauge_label_show ? 10 : 0;
|
6797 | const padding = $$.getCurrentPadding(true);
|
6798 | state.margin = !isNonAxis && isRotated ? {
|
6799 | top: padding.top,
|
6800 | right: isNonAxis ? 0 : padding.right + legendSize.right,
|
6801 | bottom: legendSize.bottom + padding.bottom,
|
6802 | left: subchartHeight + (isNonAxis ? 0 : padding.left)
|
6803 | } : {
|
6804 | top: (isFitPadding ? 0 : 4) + padding.top,
|
6805 |
|
6806 | right: isNonAxis ? 0 : padding.right + legendSize.right,
|
6807 | bottom: gaugeHeight + subchartHeight + legendSize.bottom + padding.bottom,
|
6808 | left: isNonAxis ? 0 : padding.left
|
6809 | };
|
6810 | state.margin = $$.getResettedPadding(state.margin);
|
6811 | state.margin2 = isRotated ? {
|
6812 | top: state.margin.top,
|
6813 | right: NaN,
|
6814 | bottom: 20 + legendSize.bottom,
|
6815 | left: $$.state.rotatedPadding.left
|
6816 | } : {
|
6817 | top: state.current.height - subchartHeight - legendSize.bottom,
|
6818 | right: NaN,
|
6819 | bottom: subchartXAxisHeight + legendSize.bottom,
|
6820 | left: state.margin.left
|
6821 | };
|
6822 | state.margin3 = {
|
6823 | top: 0,
|
6824 | right: NaN,
|
6825 | bottom: 0,
|
6826 | left: 0
|
6827 | };
|
6828 | (_b = $$.updateSizeForLegend) == null ? void 0 : _b.call($$, currLegend);
|
6829 | state.width = state.current.width - state.margin.left - state.margin.right;
|
6830 | state.height = state.current.height - state.margin.top - state.margin.bottom;
|
6831 | if (state.width < 0) {
|
6832 | state.width = 0;
|
6833 | }
|
6834 | if (state.height < 0) {
|
6835 | state.height = 0;
|
6836 | }
|
6837 | state.width2 = isRotated ? state.margin.left - state.rotatedPadding.left - state.rotatedPadding.right : state.width;
|
6838 | state.height2 = isRotated ? state.height : state.current.height - state.margin2.top - state.margin2.bottom;
|
6839 | if (state.width2 < 0) {
|
6840 | state.width2 = 0;
|
6841 | }
|
6842 | if (state.height2 < 0) {
|
6843 | state.height2 = 0;
|
6844 | }
|
6845 | if ($$.hasArcType()) {
|
6846 | const hasGauge = $$.hasType("gauge");
|
6847 | const isLegendRight = config.legend_show && state.isLegendRight;
|
6848 | const textWidth = (_c = state.hasRadar && $$.cache.get(KEY.radarTextWidth)) != null ? _c : 0;
|
6849 | state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0) - textWidth;
|
6850 | state.arcHeight = state.height - (isLegendRight && !hasGauge ? 0 : 10);
|
6851 | if ((_d = config.arc_rangeText_values) == null ? void 0 : _d.length) {
|
6852 | if (hasGauge) {
|
6853 | state.arcWidth -= 25;
|
6854 | state.arcHeight -= 10;
|
6855 | state.margin.left += 10;
|
6856 | } else {
|
6857 | state.arcHeight -= 20;
|
6858 | state.margin.top += 10;
|
6859 | }
|
6860 | }
|
6861 | if (hasGauge && !config.gauge_fullCircle) {
|
6862 | state.arcHeight += state.height - $$.getPaddingBottomForGauge();
|
6863 | }
|
6864 | (_e = $$.updateRadius) == null ? void 0 : _e.call($$);
|
6865 | }
|
6866 | if (state.isLegendRight && isNonAxis) {
|
6867 | state.margin3.left = state.arcWidth / 2 + state.radiusExpanded * 1.1;
|
6868 | }
|
6869 | }
|
6870 | });
|
6871 |
|
6872 | ;
|
6873 |
|
6874 |
|
6875 | var style = ({
|
6876 | |
6877 |
|
6878 |
|
6879 |
|
6880 |
|
6881 |
|
6882 |
|
6883 |
|
6884 |
|
6885 | setCssRule(withShape, selector, props, propsFn) {
|
6886 | const $$ = this;
|
6887 | const { config, state: { cssRule, style } } = $$;
|
6888 | return config.boost_useCssRule ? (selection) => {
|
6889 | selection.each((d) => {
|
6890 | const res = propsFn && (propsFn == null ? void 0 : propsFn.call($$, d));
|
6891 | const shapeSelector = `${withShape ? `.${$SHAPE.shapes + $$.getTargetSelectorSuffix(d.id)}` : ""}${selector}`;
|
6892 | selector in cssRule && style.sheet.deleteRule(cssRule[shapeSelector]);
|
6893 | $$.state.cssRule[shapeSelector] = addCssRules(
|
6894 | style,
|
6895 | shapeSelector,
|
6896 | props.filter(Boolean).map((v) => isString(res) && v.indexOf(":") === -1 ? `${v}: ${res}` : v || "")
|
6897 | );
|
6898 | });
|
6899 | } : () => {
|
6900 | };
|
6901 | },
|
6902 | |
6903 |
|
6904 |
|
6905 |
|
6906 |
|
6907 |
|
6908 | getStylePropValue(v) {
|
6909 | const { config: { boost_useCssRule: useCssRule } } = this;
|
6910 | return useCssRule ? null : isFunction(v) ? v.bind(this) : v;
|
6911 | }
|
6912 | });
|
6913 |
|
6914 | ;
|
6915 |
|
6916 |
|
6917 |
|
6918 |
|
6919 | function getRotateAnchor(angle) {
|
6920 | let anchor = "middle";
|
6921 | if (angle > 0 && angle <= 170) {
|
6922 | anchor = "end";
|
6923 | } else if (angle > 190 && angle <= 360) {
|
6924 | anchor = "start";
|
6925 | }
|
6926 | return anchor;
|
6927 | }
|
6928 | function setRotatePos(d, pos, anchor, isRotated, isInverted) {
|
6929 | var _a;
|
6930 | const $$ = this;
|
6931 | const { value } = d;
|
6932 | const isCandlestickType = $$.isCandlestickType(d);
|
6933 | const isNegative = isNumber(value) && value < 0 || isCandlestickType && !((_a = $$.getCandlestickData(d)) == null ? void 0 : _a._isUp);
|
6934 | let { x, y } = pos;
|
6935 | const gap = 4;
|
6936 | const doubleGap = gap * 2;
|
6937 | if (isRotated) {
|
6938 | if (anchor === "start") {
|
6939 | x += isNegative ? 0 : doubleGap;
|
6940 | y += gap;
|
6941 | } else if (anchor === "middle") {
|
6942 | x += doubleGap;
|
6943 | y -= doubleGap;
|
6944 | } else if (anchor === "end") {
|
6945 | isNegative && (x -= doubleGap);
|
6946 | y += gap;
|
6947 | }
|
6948 | } else {
|
6949 | if (anchor === "start") {
|
6950 | x += gap;
|
6951 | isNegative && (y += doubleGap * 2);
|
6952 | } else if (anchor === "middle") {
|
6953 | y -= doubleGap;
|
6954 | } else if (anchor === "end") {
|
6955 | x -= gap;
|
6956 | isNegative && (y += doubleGap * 2);
|
6957 | }
|
6958 | if (isInverted) {
|
6959 | y += isNegative ? -17 : isCandlestickType ? 13 : 7;
|
6960 | }
|
6961 | }
|
6962 | return { x, y };
|
6963 | }
|
6964 | function getTextPos(d, type) {
|
6965 | var _a;
|
6966 | const position = this.config.data_labels_position;
|
6967 | const { id, index, value } = d;
|
6968 | return (_a = isFunction(position) ? position.bind(this.api)(type, value, id, index, this.$el.text) : (id in position ? position[id] : position)[type]) != null ? _a : 0;
|
6969 | }
|
6970 | var internals_text = ({
|
6971 | opacityForText(d) {
|
6972 | const $$ = this;
|
6973 | return $$.isBarType(d) && !$$.meetsLabelThreshold(
|
6974 | Math.abs($$.getRatio("bar", d)),
|
6975 | "bar"
|
6976 | ) ? "0" : $$.hasDataLabel ? null : "0";
|
6977 | },
|
6978 | |
6979 |
|
6980 |
|
6981 |
|
6982 | initText() {
|
6983 | const { $el } = this;
|
6984 | $el.main.select(`.${$COMMON.chart}`).append("g").attr("class", $TEXT.chartTexts).style("pointer-events", $el.funnel || $el.treemap ? "none" : null);
|
6985 | },
|
6986 | |
6987 |
|
6988 |
|
6989 |
|
6990 |
|
6991 | updateTargetsForText(targets) {
|
6992 | const $$ = this;
|
6993 | const classChartText = $$.getChartClass("Text");
|
6994 | const classTexts = $$.getClass("texts", "id");
|
6995 | const classFocus = $$.classFocus.bind($$);
|
6996 | const mainTextUpdate = $$.$el.main.select(`.${$TEXT.chartTexts}`).selectAll(`.${$TEXT.chartText}`).data(targets).attr("class", (d) => `${classChartText(d)}${classFocus(d)}`.trim());
|
6997 | const mainTextEnter = mainTextUpdate.enter().append("g").style("opacity", "0").attr("class", classChartText).call(
|
6998 | $$.setCssRule(
|
6999 | true,
|
7000 | ` .${$TEXT.text}`,
|
7001 | ["fill", "pointer-events:none"],
|
7002 | $$.updateTextColor
|
7003 | )
|
7004 | );
|
7005 | mainTextEnter.append("g").attr("class", classTexts);
|
7006 | },
|
7007 | |
7008 |
|
7009 |
|
7010 |
|
7011 | updateText() {
|
7012 | const $$ = this;
|
7013 | const { $el, $T, config, axis } = $$;
|
7014 | const classText = $$.getClass("text", "index");
|
7015 | const labelsCentered = config.data_labels.centered;
|
7016 | const text = $el.main.selectAll(`.${$TEXT.texts}`).selectAll(`.${$TEXT.text}`).data($$.labelishData.bind($$));
|
7017 | $T(text.exit()).style("fill-opacity", "0").remove();
|
7018 | $el.text = text.enter().append("text").merge(text).attr("class", classText).attr("text-anchor", (d) => {
|
7019 | const isInverted = config[`axis_${axis == null ? void 0 : axis.getId(d.id)}_inverted`];
|
7020 | let isEndAnchor = isInverted ? d.value > 0 : d.value < 0;
|
7021 | if ($$.isCandlestickType(d)) {
|
7022 | const data = $$.getCandlestickData(d);
|
7023 | isEndAnchor = !(data == null ? void 0 : data._isUp);
|
7024 | } else if ($$.isTreemapType(d)) {
|
7025 | return labelsCentered ? "middle" : "start";
|
7026 | }
|
7027 | return config.axis_rotated ? isEndAnchor ? "end" : "start" : "middle";
|
7028 | }).style("fill", $$.getStylePropValue($$.updateTextColor)).style("fill-opacity", "0").each(function(d, i, texts) {
|
7029 | const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
7030 | let { value } = d;
|
7031 | if ($$.isBubbleZType(d)) {
|
7032 | value = $$.getBubbleZData(value, "z");
|
7033 | } else if ($$.isCandlestickType(d)) {
|
7034 | const data = $$.getCandlestickData(d);
|
7035 | if (data) {
|
7036 | value = data.close;
|
7037 | }
|
7038 | }
|
7039 | value = $$.isTreemapType(d) ? $$.treemapDataLabelFormat(d)(node) : $$.dataLabelFormat(d.id)(value, d.id, d.index, texts);
|
7040 | if (isNumber(value)) {
|
7041 | this.textContent = value;
|
7042 | } else {
|
7043 | setTextValue(node, value);
|
7044 | }
|
7045 | });
|
7046 | },
|
7047 | updateTextColor(d) {
|
7048 | const $$ = this;
|
7049 | const { config } = $$;
|
7050 | const labelColors = config.data_labels_colors;
|
7051 | const defaultColor = $$.isArcType(d) && !$$.isRadarType(d) || $$.isFunnelType(d) || $$.isTreemapType(d) ? null : $$.color(d);
|
7052 | let color;
|
7053 | if (isString(labelColors)) {
|
7054 | color = labelColors;
|
7055 | } else if (isObject(labelColors)) {
|
7056 | const { id } = d.data || d;
|
7057 | color = labelColors[id];
|
7058 | } else if (isFunction(labelColors)) {
|
7059 | color = labelColors.bind($$.api)(defaultColor, d);
|
7060 | }
|
7061 | if ($$.isCandlestickType(d) && !isFunction(labelColors)) {
|
7062 | const value = $$.getCandlestickData(d);
|
7063 | if (!(value == null ? void 0 : value._isUp)) {
|
7064 | const downColor = config.candlestick_color_down;
|
7065 | color = isObject(downColor) ? downColor[d.id] : downColor;
|
7066 | }
|
7067 | }
|
7068 | return color || defaultColor;
|
7069 | },
|
7070 | |
7071 |
|
7072 |
|
7073 |
|
7074 |
|
7075 |
|
7076 |
|
7077 | updateTextBGColor(d, option) {
|
7078 | const $$ = this;
|
7079 | const { $el } = $$;
|
7080 | let color = "";
|
7081 | if (isString(option) || isObject(option)) {
|
7082 | const id = isString(option) ? "" : $$.getTargetSelectorSuffix("id" in d ? d.id : d.data.id);
|
7083 | const filter = $el.defs.select(["filter[id*='labels-bg", "']"].join(id));
|
7084 | if (filter.size()) {
|
7085 | color = `url(#${filter.attr("id")})`;
|
7086 | }
|
7087 | }
|
7088 | return color || null;
|
7089 | },
|
7090 | |
7091 |
|
7092 |
|
7093 |
|
7094 |
|
7095 |
|
7096 |
|
7097 |
|
7098 |
|
7099 | redrawText(getX, getY, forFlow, withTransition) {
|
7100 | const $$ = this;
|
7101 | const { $T, axis, config, state: { hasTreemap } } = $$;
|
7102 | const t = getRandom(true);
|
7103 | const isRotated = config.axis_rotated;
|
7104 | const angle = config.data_labels.rotate;
|
7105 | const anchorString = getRotateAnchor(angle);
|
7106 | const rotateString = angle ? `rotate(${angle})` : "";
|
7107 | $$.$el.text.style("fill", $$.getStylePropValue($$.updateTextColor)).attr(
|
7108 | "filter",
|
7109 | (d) => $$.updateTextBGColor.bind($$)(d, config.data_labels_backgroundColors)
|
7110 | ).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function(d, i) {
|
7111 | const node = $T(
|
7112 | hasTreemap && this.childElementCount ? this.parentNode : this,
|
7113 | !!(withTransition && this.getAttribute("x")),
|
7114 | t
|
7115 | );
|
7116 | const isInverted = config[`axis_${axis == null ? void 0 : axis.getId(d.id)}_inverted`];
|
7117 | let pos = {
|
7118 | x: getX.bind(this)(d, i),
|
7119 | y: getY.bind(this)(d, i)
|
7120 | };
|
7121 | if (angle) {
|
7122 | pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
|
7123 | node.attr("text-anchor", anchorString);
|
7124 | }
|
7125 | if (this.childElementCount || angle) {
|
7126 | node.attr("transform", `translate(${pos.x} ${pos.y}) ${rotateString}`);
|
7127 | } else {
|
7128 | node.attr("x", pos.x).attr("y", pos.y);
|
7129 | }
|
7130 | });
|
7131 | return true;
|
7132 | },
|
7133 | |
7134 |
|
7135 |
|
7136 |
|
7137 |
|
7138 |
|
7139 |
|
7140 | getTextRect(element, className) {
|
7141 | const $$ = this;
|
7142 | let base = element.node ? element.node() : element;
|
7143 | if (!/text/i.test(base.tagName)) {
|
7144 | base = base.querySelector("text");
|
7145 | }
|
7146 | const text = base.textContent;
|
7147 | const cacheKey = `${KEY.textRect}-${text.replace(/\W/g, "_")}`;
|
7148 | let rect = $$.cache.get(cacheKey);
|
7149 | if (!rect) {
|
7150 | $$.$el.svg.append("text").style("visibility", "hidden").style("font", (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(base).style("font")).classed(className, true).text(text).call((v) => {
|
7151 | rect = getBoundingRect(v.node());
|
7152 | }).remove();
|
7153 | $$.cache.add(cacheKey, rect);
|
7154 | }
|
7155 | return rect;
|
7156 | },
|
7157 | |
7158 |
|
7159 |
|
7160 |
|
7161 |
|
7162 |
|
7163 |
|
7164 | generateXYForText(indices, forX) {
|
7165 | const $$ = this;
|
7166 | const { state: { hasRadar, hasFunnel, hasTreemap } } = $$;
|
7167 | const types = Object.keys(indices);
|
7168 | const points = {};
|
7169 | const getter = forX ? $$.getXForText : $$.getYForText;
|
7170 | hasFunnel && types.push("funnel");
|
7171 | hasRadar && types.push("radar");
|
7172 | hasTreemap && types.push("treemap");
|
7173 | types.forEach((v) => {
|
7174 | points[v] = $$[`generateGet${capitalize(v)}Points`](indices[v], false);
|
7175 | });
|
7176 | return function(d, i) {
|
7177 | const type = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar" || $$.isCandlestickType(d) && "candlestick" || $$.isFunnelType(d) && "funnel" || $$.isRadarType(d) && "radar" || $$.isTreemapType(d) && "treemap" || "line";
|
7178 | return getter.call($$, points[type](d, i), d, this);
|
7179 | };
|
7180 | },
|
7181 | |
7182 |
|
7183 |
|
7184 |
|
7185 |
|
7186 |
|
7187 |
|
7188 |
|
7189 |
|
7190 | getCenteredTextPos(d, points, textElement, type) {
|
7191 | const $$ = this;
|
7192 | const { config } = $$;
|
7193 | const isRotated = config.axis_rotated;
|
7194 | const isBarType = $$.isBarType(d);
|
7195 | const isTreemapType = $$.isTreemapType(d);
|
7196 | if (config.data_labels.centered && (isBarType || isTreemapType)) {
|
7197 | const rect = getBoundingRect(textElement);
|
7198 | if (isBarType) {
|
7199 | const isPositive = $$.getRangedData(d, null, "bar") >= 0;
|
7200 | if (isRotated) {
|
7201 | const w = (isPositive ? points[1][1] - points[0][1] : points[0][1] - points[1][1]) / 2 + rect.width / 2;
|
7202 | return isPositive ? -w - 3 : w + 2;
|
7203 | } else {
|
7204 | const h = (isPositive ? points[0][1] - points[1][1] : points[1][1] - points[0][1]) / 2 + rect.height / 2;
|
7205 | return isPositive ? h : -h - 2;
|
7206 | }
|
7207 | } else if (isTreemapType) {
|
7208 | return type === "x" ? (points[1][0] - points[0][0]) / 2 : (points[1][1] - points[0][1]) / 2 + rect.height / 2;
|
7209 | }
|
7210 | }
|
7211 | return 0;
|
7212 | },
|
7213 | |
7214 |
|
7215 |
|
7216 |
|
7217 |
|
7218 |
|
7219 |
|
7220 |
|
7221 | getXForText(points, d, textElement) {
|
7222 | var _a;
|
7223 | const $$ = this;
|
7224 | const { config } = $$;
|
7225 | const isRotated = config.axis_rotated;
|
7226 | const isFunnelType = $$.isFunnelType(d);
|
7227 | const isTreemapType = $$.isTreemapType(d);
|
7228 | let xPos = points ? points[0][0] : 0;
|
7229 | if ($$.isCandlestickType(d)) {
|
7230 | if (isRotated) {
|
7231 | xPos = ((_a = $$.getCandlestickData(d)) == null ? void 0 : _a._isUp) ? points[2][2] + 4 : points[2][1] - 4;
|
7232 | } else {
|
7233 | xPos += (points[1][0] - xPos) / 2;
|
7234 | }
|
7235 | } else if (isFunnelType) {
|
7236 | xPos += $$.state.current.width / 2;
|
7237 | } else if (isTreemapType) {
|
7238 | xPos += config.data_labels.centered ? 0 : 5;
|
7239 | } else {
|
7240 | if (isRotated) {
|
7241 | const isInverted = config[`axis_${$$.axis.getId(d.id)}_inverted`];
|
7242 | const padding = $$.isBarType(d) ? 4 : 6;
|
7243 | const value = d.value;
|
7244 | xPos = points[2][1];
|
7245 | if (isInverted) {
|
7246 | xPos -= padding * (value > 0 ? 1 : -1);
|
7247 | } else {
|
7248 | xPos += padding * (value < 0 ? -1 : 1);
|
7249 | }
|
7250 | } else {
|
7251 | xPos = $$.hasType("bar") ? (points[2][0] + points[0][0]) / 2 : xPos;
|
7252 | }
|
7253 | }
|
7254 | if (isRotated || isTreemapType) {
|
7255 | xPos += $$.getCenteredTextPos(d, points, textElement, "x");
|
7256 | }
|
7257 | return xPos + getTextPos.call(this, d, "x");
|
7258 | },
|
7259 | |
7260 |
|
7261 |
|
7262 |
|
7263 |
|
7264 |
|
7265 |
|
7266 |
|
7267 | getYForText(points, d, textElement) {
|
7268 | const $$ = this;
|
7269 | const { axis, config, state } = $$;
|
7270 | const isRotated = config.axis_rotated;
|
7271 | const isInverted = config[`axis_${axis == null ? void 0 : axis.getId(d.id)}_inverted`];
|
7272 | const isBarType = $$.isBarType(d);
|
7273 | const isFunnelType = $$.isFunnelType(d);
|
7274 | const isTreemapType = $$.isTreemapType(d);
|
7275 | const r = config.point_r;
|
7276 | const rect = getBoundingRect(textElement);
|
7277 | let { value } = d;
|
7278 | let baseY = 3;
|
7279 | let yPos;
|
7280 | if ($$.isCandlestickType(d)) {
|
7281 | value = $$.getCandlestickData(d);
|
7282 | if (isRotated) {
|
7283 | yPos = points[0][0];
|
7284 | yPos += (points[1][0] - yPos) / 2 + baseY;
|
7285 | } else {
|
7286 | yPos = value && value._isUp ? points[2][2] - baseY : points[2][1] + baseY * 4;
|
7287 | if (isInverted) {
|
7288 | yPos += 15 * (value._isUp ? 1 : -1);
|
7289 | }
|
7290 | }
|
7291 | } else if (isFunnelType) {
|
7292 | yPos = points ? points[0][1] + (points[1][1] - points[0][1]) / 2 + rect.height / 2 - 3 : 0;
|
7293 | } else if (isTreemapType) {
|
7294 | yPos = points[0][1] + (config.data_labels.centered ? 0 : rect.height + 5);
|
7295 | } else {
|
7296 | if (isRotated) {
|
7297 | yPos = (points[0][0] + points[2][0] + rect.height * 0.6) / 2;
|
7298 | } else {
|
7299 | yPos = points[2][1];
|
7300 | if (isNumber(r) && r > 5 && ($$.isLineType(d) || $$.isScatterType(d))) {
|
7301 | baseY += config.point_r / 2.3;
|
7302 | }
|
7303 | if (value < 0 || value === 0 && !state.hasPositiveValue && state.hasNegativeValue) {
|
7304 | yPos += isInverted ? isBarType ? -3 : -5 : rect.height + (isBarType ? -baseY : baseY);
|
7305 | } else {
|
7306 | let diff = -baseY * 2;
|
7307 | if (isBarType) {
|
7308 | diff = -baseY;
|
7309 | } else if ($$.isBubbleType(d)) {
|
7310 | diff = baseY;
|
7311 | }
|
7312 | if (isInverted) {
|
7313 | diff = isBarType ? 10 : 15;
|
7314 | }
|
7315 | yPos += diff;
|
7316 | }
|
7317 | }
|
7318 | }
|
7319 | if (!isRotated || isTreemapType) {
|
7320 | yPos += $$.getCenteredTextPos(d, points, textElement, "y");
|
7321 | }
|
7322 | return yPos + getTextPos.call(this, d, "y");
|
7323 | },
|
7324 | |
7325 |
|
7326 |
|
7327 |
|
7328 |
|
7329 |
|
7330 |
|
7331 |
|
7332 | markOverlapped(id, $$, selector) {
|
7333 | const textNodes = $$.$el.arcs.selectAll(selector);
|
7334 | const filteredTextNodes = textNodes.filter((node) => node.data.id !== id);
|
7335 | const textNode = textNodes.filter((node) => node.data.id === id);
|
7336 | const translate = getTranslation(textNode.node());
|
7337 | const calcHypo = (x, y) => Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
|
7338 | textNode.node() && filteredTextNodes.each(function() {
|
7339 | const coordinate = getTranslation(this);
|
7340 | const filteredTextNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
7341 | const nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : filteredTextNode;
|
7342 | const overlapsX = Math.ceil(Math.abs(translate.e - coordinate.e)) < Math.ceil(nodeForWidth.node().getComputedTextLength());
|
7343 | const overlapsY = Math.ceil(Math.abs(translate.f - coordinate.f)) < parseInt(textNode.style("font-size"), 10);
|
7344 | filteredTextNode.classed($TEXT.TextOverlapping, overlapsX && overlapsY);
|
7345 | });
|
7346 | },
|
7347 | |
7348 |
|
7349 |
|
7350 |
|
7351 |
|
7352 |
|
7353 |
|
7354 | undoMarkOverlapped($$, selector) {
|
7355 | $$.$el.arcs.selectAll(selector).each(function() {
|
7356 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([this, this.previousSibling]).classed($TEXT.TextOverlapping, false);
|
7357 | });
|
7358 | },
|
7359 | |
7360 |
|
7361 |
|
7362 |
|
7363 |
|
7364 |
|
7365 |
|
7366 | meetsLabelThreshold(ratio = 0, type) {
|
7367 | const $$ = this;
|
7368 | const { config } = $$;
|
7369 | const threshold = config[`${type}_label_threshold`] || 0;
|
7370 | return ratio >= threshold;
|
7371 | }
|
7372 | });
|
7373 |
|
7374 | ;
|
7375 |
|
7376 |
|
7377 | function getTextXPos(pos = "left", width) {
|
7378 | const isNum = isNumber(width);
|
7379 | let position;
|
7380 | if (pos.indexOf("center") > -1) {
|
7381 | position = isNum ? width / 2 : "middle";
|
7382 | } else if (pos.indexOf("right") > -1) {
|
7383 | position = isNum ? width : "end";
|
7384 | } else {
|
7385 | position = isNum ? 0 : "start";
|
7386 | }
|
7387 | return position;
|
7388 | }
|
7389 | var internals_title = ({
|
7390 | |
7391 |
|
7392 |
|
7393 |
|
7394 | initTitle() {
|
7395 | const $$ = this;
|
7396 | const { config, $el } = $$;
|
7397 | if (config.title_text) {
|
7398 | $el.title = $el.svg.append("g");
|
7399 | const text = $el.title.append("text").style("text-anchor", getTextXPos(config.title_position)).attr("class", $TEXT.title);
|
7400 | setTextValue(text, config.title_text, [0.3, 1.5]);
|
7401 | }
|
7402 | },
|
7403 | |
7404 |
|
7405 |
|
7406 |
|
7407 | redrawTitle() {
|
7408 | const $$ = this;
|
7409 | const { config, state: { current }, $el: { title } } = $$;
|
7410 | if (title) {
|
7411 | const x = getTextXPos(config.title_position, current.width);
|
7412 | const y = (config.title_padding.top || 0) + $$.getTextRect($$.$el.title, $TEXT.title).height;
|
7413 | title.attr("transform", `translate(${x}, ${y})`);
|
7414 | }
|
7415 | },
|
7416 | |
7417 |
|
7418 |
|
7419 |
|
7420 |
|
7421 | getTitlePadding() {
|
7422 | const $$ = this;
|
7423 | const { $el: { title }, config } = $$;
|
7424 | return (config.title_padding.top || 0) + (title ? $$.getTextRect(title, $TEXT.title).height : 0) + (config.title_padding.bottom || 0);
|
7425 | }
|
7426 | });
|
7427 |
|
7428 | ;
|
7429 |
|
7430 |
|
7431 |
|
7432 |
|
7433 | var internals_tooltip = ({
|
7434 | |
7435 |
|
7436 |
|
7437 |
|
7438 | initTooltip() {
|
7439 | const $$ = this;
|
7440 | const { config, $el } = $$;
|
7441 | $el.tooltip = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.tooltip_contents.bindto);
|
7442 | if ($el.tooltip.empty()) {
|
7443 | $el.tooltip = $el.chart.append("div").attr("class", $TOOLTIP.tooltipContainer).style("position", "absolute").style("pointer-events", "none").style("display", "none");
|
7444 | }
|
7445 | $$.bindTooltipResizePos();
|
7446 | },
|
7447 | |
7448 |
|
7449 |
|
7450 |
|
7451 |
|
7452 | initShowTooltip() {
|
7453 | var _a;
|
7454 | const $$ = this;
|
7455 | const { config, $el, state: { hasAxis, hasRadar } } = $$;
|
7456 | if (config.tooltip_init_show) {
|
7457 | const isArc = !(hasAxis || hasRadar);
|
7458 | if (((_a = $$.axis) == null ? void 0 : _a.isTimeSeries()) && isString(config.tooltip_init_x)) {
|
7459 | config.tooltip_init_x = parseDate.call($$, config.tooltip_init_x);
|
7460 | }
|
7461 | $$.api.tooltip.show({
|
7462 | data: {
|
7463 | [isArc ? "index" : "x"]: config.tooltip_init_x
|
7464 | }
|
7465 | });
|
7466 | const position = config.tooltip_init_position;
|
7467 | if (!config.tooltip_contents.bindto && !isEmpty(position)) {
|
7468 | const { top = 0, left = 50 } = position;
|
7469 | $el.tooltip.style("top", isString(top) ? top : `${top}px`).style("left", isString(left) ? left : `${left}px`).style("display", null);
|
7470 | }
|
7471 | }
|
7472 | },
|
7473 | |
7474 |
|
7475 |
|
7476 |
|
7477 |
|
7478 |
|
7479 | getTooltipHTML(...args) {
|
7480 | const $$ = this;
|
7481 | const { api, config } = $$;
|
7482 | return isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api)(...args) : $$.getTooltipContent(...args);
|
7483 | },
|
7484 | |
7485 |
|
7486 |
|
7487 |
|
7488 |
|
7489 |
|
7490 |
|
7491 |
|
7492 |
|
7493 | getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) {
|
7494 | var _a;
|
7495 | const $$ = this;
|
7496 | const { api, config, state, $el } = $$;
|
7497 | const [titleFn, nameFn, valueFn] = ["title", "name", "value"].map((v) => {
|
7498 | const fn = config[`tooltip_format_${v}`];
|
7499 | return isFunction(fn) ? fn.bind(api) : fn;
|
7500 | });
|
7501 | const titleFormat = (...arg) => sanitize((titleFn || defaultTitleFormat)(...arg));
|
7502 | const nameFormat = (...arg) => sanitize((nameFn || ((name) => name))(...arg));
|
7503 | const valueFormat = (...arg) => {
|
7504 | const fn = valueFn || (state.hasTreemap || $$.isStackNormalized() ? (v, ratio) => `${(ratio * 100).toFixed(2)}%` : defaultValueFormat);
|
7505 | return sanitize(fn(...arg));
|
7506 | };
|
7507 | const order = config.tooltip_order;
|
7508 | const getRowValue = (row2) => $$.axis && $$.isBubbleZType(row2) ? $$.getBubbleZData(row2.value, "z") : $$.getBaseValue(row2);
|
7509 | const getBgColor = $$.levelColor ? (row2) => $$.levelColor(row2.value) : (row2) => color(row2);
|
7510 | const contents = config.tooltip_contents;
|
7511 | const tplStr = contents.template;
|
7512 | const targetIds = $$.mapToTargetIds();
|
7513 | if (order === null && config.data_groups.length) {
|
7514 | const ids = $$.orderTargets($$.data.targets).map((i2) => i2.id).reverse();
|
7515 | d.sort((a, b) => {
|
7516 | let v1 = a ? a.value : null;
|
7517 | let v2 = b ? b.value : null;
|
7518 | if (v1 > 0 && v2 > 0) {
|
7519 | v1 = a.id ? ids.indexOf(a.id) : null;
|
7520 | v2 = b.id ? ids.indexOf(b.id) : null;
|
7521 | }
|
7522 | return v1 - v2;
|
7523 | });
|
7524 | } else if (/^(asc|desc)$/.test(order)) {
|
7525 | const isAscending = order === "asc";
|
7526 | d.sort((a, b) => {
|
7527 | const v1 = a ? getRowValue(a) : null;
|
7528 | const v2 = b ? getRowValue(b) : null;
|
7529 | return isAscending ? v1 - v2 : v2 - v1;
|
7530 | });
|
7531 | } else if (isFunction(order)) {
|
7532 | d.sort(order.bind(api));
|
7533 | }
|
7534 | const tpl = $$.getTooltipContentTemplate(tplStr);
|
7535 | const len = d.length;
|
7536 | let text;
|
7537 | let row;
|
7538 | let param;
|
7539 | let value;
|
7540 | let i;
|
7541 | for (i = 0; i < len; i++) {
|
7542 | row = d[i];
|
7543 | if (!row || !(getRowValue(row) || getRowValue(row) === 0)) {
|
7544 | continue;
|
7545 | }
|
7546 | if (isUndefined(text)) {
|
7547 | const title = (state.hasAxis || state.hasRadar) && titleFormat(row.x);
|
7548 | text = tplProcess(tpl[0], {
|
7549 | CLASS_TOOLTIP: $TOOLTIP.tooltip,
|
7550 | TITLE: isValue(title) ? tplStr ? title : `<tr><th colspan="2">${title}</th></tr>` : ""
|
7551 | });
|
7552 | }
|
7553 | if (!row.ratio && $el.arcs) {
|
7554 | param = ["arc", $$.$el.arcs.select(`path.${$ARC.arc}-${row.id}`).data()[0]];
|
7555 | row.ratio = $$.getRatio(...param);
|
7556 | }
|
7557 | param = [row.ratio, row.id, row.index];
|
7558 | if ($$.isAreaRangeType(row)) {
|
7559 | const [high, low] = ["high", "low"].map(
|
7560 | (v) => valueFormat($$.getRangedData(row, v), ...param)
|
7561 | );
|
7562 | const mid = valueFormat(getRowValue(row), ...param);
|
7563 | value = `<b>Mid:</b> ${mid} <b>High:</b> ${high} <b>Low:</b> ${low}`;
|
7564 | } else if ($$.isCandlestickType(row)) {
|
7565 | const [open, high, low, close, volume] = ["open", "high", "low", "close", "volume"].map((v) => {
|
7566 | const value2 = $$.getRangedData(row, v, "candlestick");
|
7567 | return value2 ? valueFormat(
|
7568 | $$.getRangedData(row, v, "candlestick"),
|
7569 | ...param
|
7570 | ) : void 0;
|
7571 | });
|
7572 | value = `<b>Open:</b> ${open} <b>High:</b> ${high} <b>Low:</b> ${low} <b>Close:</b> ${close}${volume ? ` <b>Volume:</b> ${volume}` : ""}`;
|
7573 | } else if ($$.isBarRangeType(row)) {
|
7574 | const { value: rangeValue, id, index } = row;
|
7575 | value = `${valueFormat(rangeValue, void 0, id, index)}`;
|
7576 | } else {
|
7577 | value = valueFormat(getRowValue(row), ...param);
|
7578 | }
|
7579 | if (value !== void 0) {
|
7580 | if (row.name === null) {
|
7581 | continue;
|
7582 | }
|
7583 | const name = nameFormat((_a = row.name) != null ? _a : row.id, ...param);
|
7584 | const color2 = getBgColor(row);
|
7585 | const contentValue = {
|
7586 | CLASS_TOOLTIP_NAME: $TOOLTIP.tooltipName + $$.getTargetSelectorSuffix(row.id),
|
7587 | COLOR: tplStr || !$$.patterns ? color2 : `<svg><rect style="fill:${color2}" width="10" height="10"></rect></svg>`,
|
7588 | NAME: name,
|
7589 | VALUE: value
|
7590 | };
|
7591 | if (tplStr && isObject(contents.text)) {
|
7592 | const index = targetIds.indexOf(row.id);
|
7593 | Object.keys(contents.text).forEach((key) => {
|
7594 | contentValue[key] = contents.text[key][index];
|
7595 | });
|
7596 | }
|
7597 | text += tplProcess(tpl[1], contentValue);
|
7598 | }
|
7599 | }
|
7600 | return `${text}</table>`;
|
7601 | },
|
7602 | |
7603 |
|
7604 |
|
7605 |
|
7606 |
|
7607 |
|
7608 | getTooltipContentTemplate(tplStr) {
|
7609 | return (tplStr || `<table class="{=CLASS_TOOLTIP}"><tbody>
|
7610 | {=TITLE}
|
7611 | {{<tr class="{=CLASS_TOOLTIP_NAME}">
|
7612 | <td class="name">${this.patterns ? `{=COLOR}` : `<span style="background-color:{=COLOR}"></span>`}{=NAME}</td>
|
7613 | <td class="value">{=VALUE}</td>
|
7614 | </tr>}}
|
7615 | </tbody></table>`).replace(/(\r?\n|\t)/g, "").split(/{{(.*)}}/);
|
7616 | },
|
7617 | |
7618 |
|
7619 |
|
7620 |
|
7621 |
|
7622 |
|
7623 | setTooltipPosition(dataToShow, eventTarget) {
|
7624 | var _a, _b;
|
7625 | const $$ = this;
|
7626 | const { config, scale, state, $el: { eventRect, tooltip, svg } } = $$;
|
7627 | const { bindto } = config.tooltip_contents;
|
7628 | const isRotated = config.axis_rotated;
|
7629 | const datum = tooltip == null ? void 0 : tooltip.datum();
|
7630 | if (!bindto && datum) {
|
7631 | const data = dataToShow != null ? dataToShow : JSON.parse(datum.current);
|
7632 | const [x, y] = getPointer(state.event, eventTarget != null ? eventTarget : eventRect == null ? void 0 : eventRect.node());
|
7633 | const currPos = { x, y };
|
7634 | if (state.hasAxis && scale.x && datum && "x" in datum) {
|
7635 | const getYPos = (value = 0, id, axisId = "y") => {
|
7636 | var _a2;
|
7637 | const scaleFn = scale[id ? (_a2 = $$.axis) == null ? void 0 : _a2.getId(id) : axisId];
|
7638 | return scaleFn ? scaleFn(value) + (isRotated ? state.margin.left : state.margin.top) : 0;
|
7639 | };
|
7640 | currPos.xAxis = scale.x(datum.x) +
|
7641 | (config.tooltip_position ? isRotated ? state.margin.top : state.margin.left : 0);
|
7642 | if (data.length === 1) {
|
7643 | currPos.yAxis = getYPos(data[0].value, data[0].id);
|
7644 | } else {
|
7645 | currPos.yAxis = getYPos;
|
7646 | }
|
7647 | }
|
7648 | const { width = 0, height = 0 } = datum;
|
7649 | const pos = (_b = (_a = config.tooltip_position) == null ? void 0 : _a.bind($$.api)(
|
7650 | data,
|
7651 | width,
|
7652 | height,
|
7653 | eventRect == null ? void 0 : eventRect.node(),
|
7654 | currPos
|
7655 | )) != null ? _b : hasViewBox(svg) ? $$.getTooltipPositionViewBox.bind($$)(width, height, currPos) : $$.getTooltipPosition.bind($$)(width, height, currPos);
|
7656 | ["top", "left"].forEach((v) => {
|
7657 | const value = pos[v];
|
7658 | tooltip.style(v, `${value}px`);
|
7659 | if (v === "left" && !datum.xPosInPercent) {
|
7660 | datum.xPosInPercent = value / state.current.width * 100;
|
7661 | }
|
7662 | });
|
7663 | }
|
7664 | },
|
7665 | |
7666 |
|
7667 |
|
7668 |
|
7669 |
|
7670 |
|
7671 |
|
7672 | getTooltipPositionViewBox(tWidth, tHeight, currPos) {
|
7673 | var _a, _b;
|
7674 | const $$ = this;
|
7675 | const { $el: { eventRect, svg }, config, state } = $$;
|
7676 | const isRotated = config.axis_rotated;
|
7677 | const hasArcType = $$.hasArcType() || state.hasFunnel || state.hasTreemap;
|
7678 | const target = (_b = (_a = hasArcType ? svg : eventRect) == null ? void 0 : _a.node()) != null ? _b : state.event.target;
|
7679 | let { x, y } = currPos;
|
7680 | if (state.hasAxis) {
|
7681 | x = isRotated ? x : currPos.xAxis;
|
7682 | y = isRotated ? currPos.xAxis : y;
|
7683 | }
|
7684 | const ctm = getTransformCTM(target, x, y, false);
|
7685 | const rect = target.getBoundingClientRect();
|
7686 | const size = getTransformCTM(target, 20, 0, false).x;
|
7687 | let top = ctm.y;
|
7688 | let left = ctm.x + tWidth / 2 + size;
|
7689 | if (hasArcType) {
|
7690 | if (state.hasFunnel || state.hasTreemap || state.hasRadar) {
|
7691 | left -= tWidth / 2 + size;
|
7692 | top += tHeight;
|
7693 | } else {
|
7694 | top += rect.height / 2;
|
7695 | left += rect.width / 2 - (tWidth - size);
|
7696 | }
|
7697 | }
|
7698 | if (left + tWidth > rect.width) {
|
7699 | left = rect.width - tWidth - size;
|
7700 | }
|
7701 | if (top + tHeight > rect.height) {
|
7702 | top -= tHeight * 2;
|
7703 | }
|
7704 | return {
|
7705 | top,
|
7706 | left
|
7707 | };
|
7708 | },
|
7709 | |
7710 |
|
7711 |
|
7712 |
|
7713 |
|
7714 |
|
7715 |
|
7716 |
|
7717 | getTooltipPosition(tWidth, tHeight, currPos) {
|
7718 | var _a, _b, _c;
|
7719 | const $$ = this;
|
7720 | const { config, scale, state } = $$;
|
7721 | const { width, height, current, hasFunnel, hasRadar, hasTreemap, isLegendRight, inputType } = state;
|
7722 | const hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle;
|
7723 | const isRotated = config.axis_rotated;
|
7724 | const hasArcType = $$.hasArcType();
|
7725 | const svgLeft = $$.getSvgLeft(true);
|
7726 | let chartRight = svgLeft + current.width - $$.getCurrentPaddingByDirection("right");
|
7727 | const size = 20;
|
7728 | let { x, y } = currPos;
|
7729 | if (hasRadar) {
|
7730 | x += x >= width / 2 ? 15 : -(tWidth + 15);
|
7731 | y += 15;
|
7732 | } else if (hasArcType) {
|
7733 | const notTouch = inputType !== "touch";
|
7734 | if (notTouch) {
|
7735 | let titlePadding = (_b = (_a = $$.getTitlePadding) == null ? void 0 : _a.call($$)) != null ? _b : 0;
|
7736 | if (titlePadding && hasGauge && ((_c = config.arc_rangeText_values) == null ? void 0 : _c.length)) {
|
7737 | titlePadding += 10;
|
7738 | }
|
7739 | x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
|
7740 | y += (hasGauge ? height : height / 2 + tHeight) + titlePadding;
|
7741 | }
|
7742 | } else if (hasFunnel || hasTreemap) {
|
7743 | y += tHeight;
|
7744 | } else {
|
7745 | const padding = {
|
7746 | top: $$.getCurrentPaddingByDirection("top", true),
|
7747 | left: $$.getCurrentPaddingByDirection("left", true)
|
7748 | };
|
7749 | if (isRotated) {
|
7750 | x += svgLeft + padding.left + size;
|
7751 | y = padding.top + currPos.xAxis + size;
|
7752 | chartRight -= svgLeft;
|
7753 | } else {
|
7754 | x = svgLeft + padding.left + size + (scale.zoom ? x : currPos.xAxis);
|
7755 | y += padding.top - 5;
|
7756 | }
|
7757 | }
|
7758 | if (x + tWidth + 15 > chartRight) {
|
7759 | x -= tWidth + (hasFunnel || hasTreemap || hasArcType ? 0 : isRotated ? size * 2 : 38);
|
7760 | }
|
7761 | if (y + tHeight > current.height) {
|
7762 | const gap = hasTreemap ? tHeight + 10 : 30;
|
7763 | y -= hasGauge ? tHeight * 1.5 : tHeight + gap;
|
7764 | }
|
7765 | const pos = { top: y, left: x };
|
7766 | Object.keys(pos).forEach((v) => {
|
7767 | if (pos[v] < 0) {
|
7768 | pos[v] = 0;
|
7769 | }
|
7770 | });
|
7771 | return pos;
|
7772 | },
|
7773 | |
7774 |
|
7775 |
|
7776 |
|
7777 |
|
7778 |
|
7779 | showTooltip(selectedData, eventTarget) {
|
7780 | const $$ = this;
|
7781 | const { config, $el: { tooltip } } = $$;
|
7782 | const dataToShow = selectedData.filter((d) => d && isValue($$.getBaseValue(d)));
|
7783 | if (!tooltip || dataToShow.length === 0 || !config.tooltip_show) {
|
7784 | return;
|
7785 | }
|
7786 | let datum = tooltip.datum();
|
7787 | const dataStr = JSON.stringify(selectedData);
|
7788 | if (!datum || datum.current !== dataStr) {
|
7789 | const { index, x } = selectedData.concat().sort()[0];
|
7790 | callFn(config.tooltip_onshow, $$.api, selectedData);
|
7791 | tooltip.html($$.getTooltipHTML(
|
7792 | selectedData,
|
7793 |
|
7794 | $$.axis ? $$.axis.getXAxisTickFormat() : $$.categoryName.bind($$),
|
7795 |
|
7796 | $$.getDefaultValueFormat(),
|
7797 |
|
7798 | $$.color
|
7799 |
|
7800 | )).style("display", null).style("visibility", null).datum(datum = {
|
7801 | index,
|
7802 | x,
|
7803 | current: dataStr,
|
7804 | width: tooltip.property("offsetWidth"),
|
7805 | height: tooltip.property("offsetHeight")
|
7806 | });
|
7807 | callFn(config.tooltip_onshown, $$.api, selectedData);
|
7808 | $$._handleLinkedCharts(true, index);
|
7809 | }
|
7810 | $$.setTooltipPosition(dataToShow, eventTarget);
|
7811 | },
|
7812 | |
7813 |
|
7814 |
|
7815 |
|
7816 | bindTooltipResizePos() {
|
7817 | const $$ = this;
|
7818 | const { resizeFunction, state, $el: { tooltip } } = $$;
|
7819 | resizeFunction.add(() => {
|
7820 | if (tooltip.style("display") === "block") {
|
7821 | const { current } = state;
|
7822 | const { width, xPosInPercent } = tooltip.datum();
|
7823 | let value = current.width / 100 * xPosInPercent;
|
7824 | const diff = current.width - (value + width);
|
7825 | if (diff < 0) {
|
7826 | value += diff;
|
7827 | }
|
7828 | tooltip.style("left", `${value}px`);
|
7829 | }
|
7830 | });
|
7831 | },
|
7832 | |
7833 |
|
7834 |
|
7835 |
|
7836 |
|
7837 | hideTooltip(force) {
|
7838 | var _a;
|
7839 | const $$ = this;
|
7840 | const { api, config, $el: { tooltip } } = $$;
|
7841 | if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
|
7842 | const selectedData = JSON.parse((_a = tooltip.datum().current) != null ? _a : {});
|
7843 | callFn(config.tooltip_onhide, api, selectedData);
|
7844 | tooltip.style("display", "none").style("visibility", "hidden").datum(null);
|
7845 | callFn(config.tooltip_onhidden, api, selectedData);
|
7846 | }
|
7847 | },
|
7848 | |
7849 |
|
7850 |
|
7851 |
|
7852 |
|
7853 |
|
7854 | _handleLinkedCharts(show, index) {
|
7855 | const $$ = this;
|
7856 | const { charts, config, state: { event } } = $$;
|
7857 | if ((event == null ? void 0 : event.isTrusted) && config.tooltip_linked && charts.length > 1) {
|
7858 | const linkedName = config.tooltip_linked_name;
|
7859 | charts.filter((c) => c !== $$.api).forEach((c) => {
|
7860 | const { config: config2, $el } = c.internal;
|
7861 | const isLinked = config2.tooltip_linked;
|
7862 | const name = config2.tooltip_linked_name;
|
7863 | const isInDom = browser_doc.body.contains($el.chart.node());
|
7864 | if (isLinked && linkedName === name && isInDom) {
|
7865 | const data = $el.tooltip.data()[0];
|
7866 | const isNotSameIndex = index !== (data == null ? void 0 : data.index);
|
7867 | try {
|
7868 | c.tooltip[show && isNotSameIndex ? "show" : "hide"]({ index });
|
7869 | } catch (e) {
|
7870 | }
|
7871 | }
|
7872 | });
|
7873 | }
|
7874 | },
|
7875 | |
7876 |
|
7877 |
|
7878 |
|
7879 |
|
7880 |
|
7881 |
|
7882 | updateTooltipOnRedraw(context, index) {
|
7883 | var _a;
|
7884 | const $$ = this;
|
7885 | const {
|
7886 | config,
|
7887 | $el: { eventRect, svg, tooltip },
|
7888 | state: { event, hasAxis, hasRadar, hasTreemap }
|
7889 | } = $$;
|
7890 | if ((tooltip == null ? void 0 : tooltip.style("display")) === "block" && event) {
|
7891 | const rect = context != null ? context : (_a = hasRadar ? svg : eventRect) == null ? void 0 : _a.node();
|
7892 | if (hasAxis || hasRadar) {
|
7893 | if ($$.isMultipleX()) {
|
7894 | $$.selectRectForMultipleXs(rect, false);
|
7895 | } else {
|
7896 | const idx = index != null ? index : $$.getDataIndexFromEvent(event);
|
7897 | if (index === -1) {
|
7898 | $$.api.tooltip.hide();
|
7899 | } else {
|
7900 | $$.selectRectForSingle(rect, idx);
|
7901 | $$.setExpand(idx, null, true);
|
7902 | }
|
7903 | }
|
7904 | } else {
|
7905 | const { clientX, clientY } = event;
|
7906 | setTimeout(() => {
|
7907 | let target = [clientX, clientY].every(Number.isFinite) && browser_doc.elementFromPoint(clientX, clientY);
|
7908 | const data = target && (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
|
7909 | if (data) {
|
7910 | const d = $$.hasArcType() ? $$.convertToArcData($$.updateAngle(data)) : data == null ? void 0 : data.data;
|
7911 | hasTreemap && (target = svg.node());
|
7912 | d && $$.showTooltip([d], target);
|
7913 | } else {
|
7914 | $$.api.tooltip.hide();
|
7915 | }
|
7916 | }, config.transition_duration);
|
7917 | }
|
7918 | }
|
7919 | }
|
7920 | });
|
7921 |
|
7922 | ;
|
7923 |
|
7924 |
|
7925 | var transform = ({
|
7926 | getTranslate(target, index = 0) {
|
7927 | var _a;
|
7928 | const $$ = this;
|
7929 | const { config, state } = $$;
|
7930 | const isRotated = config.axis_rotated;
|
7931 | let padding = 0;
|
7932 | let x;
|
7933 | let y;
|
7934 | if (index && /^(x|y2?)$/.test(target)) {
|
7935 | padding = $$.getAxisSize(target) * index;
|
7936 | }
|
7937 | if (target === "main") {
|
7938 | x = asHalfPixel(state.margin.left);
|
7939 | y = asHalfPixel(state.margin.top);
|
7940 | } else if (target === "context") {
|
7941 | x = asHalfPixel(state.margin2.left);
|
7942 | y = asHalfPixel(state.margin2.top);
|
7943 | } else if (target === "legend") {
|
7944 | x = state.margin3.left;
|
7945 | y = state.margin3.top;
|
7946 | } else if (target === "x") {
|
7947 | x = isRotated ? -padding : 0;
|
7948 | y = isRotated ? 0 : state.height + padding;
|
7949 | } else if (target === "y") {
|
7950 | x = isRotated ? 0 : -padding;
|
7951 | y = isRotated ? state.height + padding : 0;
|
7952 | } else if (target === "y2") {
|
7953 | x = isRotated ? 0 : state.width + padding;
|
7954 | y = isRotated ? -padding - 1 : 0;
|
7955 | } else if (target === "subX") {
|
7956 | x = 0;
|
7957 | y = isRotated ? 0 : state.height2;
|
7958 | } else if (target === "arc") {
|
7959 | x = state.arcWidth / 2;
|
7960 | y = state.arcHeight / 2;
|
7961 | if ((_a = config.arc_rangeText_values) == null ? void 0 : _a.length) {
|
7962 | y += 5 + ($$.hasType("gauge") && config.title_text ? 10 : 0);
|
7963 | }
|
7964 | } else if (target === "polar") {
|
7965 | x = state.arcWidth / 2;
|
7966 | y = state.arcHeight / 2;
|
7967 | } else if (target === "radar") {
|
7968 | const [width, height] = $$.getRadarSize();
|
7969 | x = state.width / 2 - width;
|
7970 | y = state.height / 2 - height;
|
7971 | }
|
7972 | return `translate(${x}, ${y})`;
|
7973 | },
|
7974 | transformMain(withTransition, transitions) {
|
7975 | const $$ = this;
|
7976 | const { $el: { main }, $T } = $$;
|
7977 | const xAxis = (transitions == null ? void 0 : transitions.axisX) ? transitions.axisX : $T(main.select(`.${$AXIS.axisX}`), withTransition);
|
7978 | const yAxis = (transitions == null ? void 0 : transitions.axisY) ? transitions.axisY : $T(main.select(`.${$AXIS.axisY}`), withTransition);
|
7979 | const y2Axis = (transitions == null ? void 0 : transitions.axisY2) ? transitions.axisY2 : $T(main.select(`.${$AXIS.axisY2}`), withTransition);
|
7980 | $T(main, withTransition).attr("transform", $$.getTranslate("main"));
|
7981 | xAxis.attr("transform", $$.getTranslate("x"));
|
7982 | yAxis.attr("transform", $$.getTranslate("y"));
|
7983 | y2Axis.attr("transform", $$.getTranslate("y2"));
|
7984 | main.select(`.${$ARC.chartArcs}`).attr("transform", $$.getTranslate("arc"));
|
7985 | },
|
7986 | transformAll(withTransition, transitions) {
|
7987 | const $$ = this;
|
7988 | const { config, state: { hasAxis, hasFunnel, hasTreemap }, $el } = $$;
|
7989 | !hasFunnel && !hasTreemap && $$.transformMain(withTransition, transitions);
|
7990 | hasAxis && config.subchart_show && $$.transformContext(withTransition, transitions);
|
7991 | $el.legend && $$.transformLegend(withTransition);
|
7992 | }
|
7993 | });
|
7994 |
|
7995 | ;
|
7996 |
|
7997 |
|
7998 | var type = ({
|
7999 | |
8000 |
|
8001 |
|
8002 |
|
8003 |
|
8004 |
|
8005 | isValidChartType(type) {
|
8006 | return !!(type && Object.values(TYPE).indexOf(type) > -1);
|
8007 | },
|
8008 | setTargetType(targetIds, type) {
|
8009 | const $$ = this;
|
8010 | const { config, state: { withoutFadeIn } } = $$;
|
8011 | $$.mapToTargetIds(targetIds).forEach((id) => {
|
8012 | withoutFadeIn[id] = type === config.data_types[id];
|
8013 | config.data_types[id] = type;
|
8014 | });
|
8015 | if (!targetIds) {
|
8016 | config.data_type = type;
|
8017 | }
|
8018 | },
|
8019 | |
8020 |
|
8021 |
|
8022 |
|
8023 | updateTypesElements() {
|
8024 | const $$ = this;
|
8025 | const { state: { current } } = $$;
|
8026 | Object.keys(TYPE).forEach((v) => {
|
8027 | const t = TYPE[v];
|
8028 | const has = $$.hasType(t, null, true);
|
8029 | const idx = current.types.indexOf(t);
|
8030 | if (idx === -1 && has) {
|
8031 | current.types.push(t);
|
8032 | } else if (idx > -1 && !has) {
|
8033 | current.types.splice(idx, 1);
|
8034 | }
|
8035 | });
|
8036 | $$.setChartElements();
|
8037 | },
|
8038 | |
8039 |
|
8040 |
|
8041 |
|
8042 |
|
8043 |
|
8044 |
|
8045 |
|
8046 | hasType(type, targetsValue, checkFromData = false) {
|
8047 | var _a;
|
8048 | const $$ = this;
|
8049 | const { config, state: { current } } = $$;
|
8050 | const types = config.data_types;
|
8051 | const targets = targetsValue || $$.data.targets;
|
8052 | let has = false;
|
8053 | if (!checkFromData && ((_a = current.types) == null ? void 0 : _a.indexOf(type)) > -1) {
|
8054 | has = true;
|
8055 | } else if (targets == null ? void 0 : targets.length) {
|
8056 | targets.forEach((target) => {
|
8057 | const t = types[target.id];
|
8058 | if (t === type || !t && type === "line") {
|
8059 | has = true;
|
8060 | }
|
8061 | });
|
8062 | } else if (Object.keys(types).length) {
|
8063 | Object.keys(types).forEach((id) => {
|
8064 | if (types[id] === type) {
|
8065 | has = true;
|
8066 | }
|
8067 | });
|
8068 | } else {
|
8069 | has = config.data_type === type;
|
8070 | }
|
8071 | return has;
|
8072 | },
|
8073 | |
8074 |
|
8075 |
|
8076 |
|
8077 |
|
8078 |
|
8079 |
|
8080 |
|
8081 | hasTypeOf(type, targets, exclude = []) {
|
8082 | if (type in TYPE_BY_CATEGORY) {
|
8083 | return !TYPE_BY_CATEGORY[type].filter((v) => exclude.indexOf(v) === -1).every((v) => !this.hasType(v, targets));
|
8084 | }
|
8085 | return false;
|
8086 | },
|
8087 | |
8088 |
|
8089 |
|
8090 |
|
8091 |
|
8092 |
|
8093 |
|
8094 | isTypeOf(d, type) {
|
8095 | var _a;
|
8096 | const id = isString(d) ? d : d.id;
|
8097 | const dataType = this.config && (((_a = this.config.data_types) == null ? void 0 : _a[id]) || this.config.data_type);
|
8098 | return isArray(type) ? type.indexOf(dataType) >= 0 : dataType === type;
|
8099 | },
|
8100 | hasPointType() {
|
8101 | const $$ = this;
|
8102 | return $$.hasTypeOf("Line") || $$.hasType("bubble") || $$.hasType("scatter");
|
8103 | },
|
8104 | |
8105 |
|
8106 |
|
8107 |
|
8108 |
|
8109 |
|
8110 |
|
8111 | hasArcType(targets, exclude) {
|
8112 | return this.hasTypeOf("Arc", targets, exclude);
|
8113 | },
|
8114 | hasMultiArcGauge() {
|
8115 | return this.hasType("gauge") && this.config.gauge_type === "multi";
|
8116 | },
|
8117 | isLineType(d) {
|
8118 | const id = isString(d) ? d : d.id;
|
8119 | return !this.config.data_types[id] || this.isTypeOf(id, TYPE_BY_CATEGORY.Line);
|
8120 | },
|
8121 | isStepType(d) {
|
8122 | return this.isTypeOf(d, TYPE_BY_CATEGORY.Step);
|
8123 | },
|
8124 | isSplineType(d) {
|
8125 | return this.isTypeOf(d, TYPE_BY_CATEGORY.Spline);
|
8126 | },
|
8127 | isAreaType(d) {
|
8128 | return this.isTypeOf(d, TYPE_BY_CATEGORY.Area);
|
8129 | },
|
8130 | isAreaRangeType(d) {
|
8131 | return this.isTypeOf(d, TYPE_BY_CATEGORY.AreaRange);
|
8132 | },
|
8133 | isBarType(d) {
|
8134 | return this.isTypeOf(d, "bar");
|
8135 | },
|
8136 | isBubbleType(d) {
|
8137 | return this.isTypeOf(d, "bubble");
|
8138 | },
|
8139 | isCandlestickType(d) {
|
8140 | return this.isTypeOf(d, "candlestick");
|
8141 | },
|
8142 | isScatterType(d) {
|
8143 | return this.isTypeOf(d, "scatter");
|
8144 | },
|
8145 | isTreemapType(d) {
|
8146 | return this.isTypeOf(d, "treemap");
|
8147 | },
|
8148 | isPieType(d) {
|
8149 | return this.isTypeOf(d, "pie");
|
8150 | },
|
8151 | isFunnelType(d) {
|
8152 | return this.isTypeOf(d, "funnel");
|
8153 | },
|
8154 | isGaugeType(d) {
|
8155 | return this.isTypeOf(d, "gauge");
|
8156 | },
|
8157 | isDonutType(d) {
|
8158 | return this.isTypeOf(d, "donut");
|
8159 | },
|
8160 | isPolarType(d) {
|
8161 | return this.isTypeOf(d, "polar");
|
8162 | },
|
8163 | isRadarType(d) {
|
8164 | return this.isTypeOf(d, "radar");
|
8165 | },
|
8166 | isArcType(d) {
|
8167 | return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d) || this.isPolarType(d) || this.isRadarType(d);
|
8168 | },
|
8169 |
|
8170 | isCirclePoint(node) {
|
8171 | const { config } = this;
|
8172 | const pattern = config.point_pattern;
|
8173 | let isCircle = false;
|
8174 | if ((node == null ? void 0 : node.tagName) === "circle") {
|
8175 | isCircle = true;
|
8176 | } else {
|
8177 | isCircle = config.point_type === "circle" && (!pattern || isArray(pattern) && pattern.length === 0);
|
8178 | }
|
8179 | return isCircle;
|
8180 | },
|
8181 | lineData(d) {
|
8182 | return this.isLineType(d) ? [d] : [];
|
8183 | },
|
8184 | arcData(d) {
|
8185 | return this.isArcType(d.data) ? [d] : [];
|
8186 | },
|
8187 | |
8188 |
|
8189 |
|
8190 |
|
8191 |
|
8192 |
|
8193 | labelishData(d) {
|
8194 | return this.isBarType(d) || this.isLineType(d) || this.isScatterType(d) || this.isBubbleType(d) || this.isCandlestickType(d) || this.isFunnelType(d) || this.isRadarType(d) || this.isTreemapType(d) ? d.values.filter((v) => isNumber(v.value) || Boolean(v.value)) : [];
|
8195 | },
|
8196 | barLineBubbleData(d) {
|
8197 | return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ? d.values : [];
|
8198 | },
|
8199 |
|
8200 | isInterpolationType(type) {
|
8201 | return [
|
8202 | "basis",
|
8203 | "basis-closed",
|
8204 | "basis-open",
|
8205 | "bundle",
|
8206 | "cardinal",
|
8207 | "cardinal-closed",
|
8208 | "cardinal-open",
|
8209 | "catmull-rom",
|
8210 | "catmull-rom-closed",
|
8211 | "catmull-rom-open",
|
8212 | "linear",
|
8213 | "linear-closed",
|
8214 | "monotone-x",
|
8215 | "monotone-y",
|
8216 | "natural"
|
8217 | ].indexOf(type) >= 0;
|
8218 | }
|
8219 | });
|
8220 |
|
8221 |
|
8222 | var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webpack_require__(9);
|
8223 | ;
|
8224 |
|
8225 |
|
8226 |
|
8227 |
|
8228 | function getGroupedDataPointsFn(d) {
|
8229 | const $$ = this;
|
8230 | let fn;
|
8231 | if ($$.isLineType(d)) {
|
8232 | fn = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType));
|
8233 | } else if ($$.isBarType(d)) {
|
8234 | fn = $$.generateGetBarPoints($$.getShapeIndices($$.isBarType));
|
8235 | }
|
8236 | return fn;
|
8237 | }
|
8238 | var shape = ({
|
8239 | |
8240 |
|
8241 |
|
8242 |
|
8243 |
|
8244 | getDrawShape() {
|
8245 | const $$ = this;
|
8246 | const isRotated = $$.config.axis_rotated;
|
8247 | const { hasRadar, hasTreemap } = $$.state;
|
8248 | const shape = { type: {}, indices: {}, pos: {} };
|
8249 | !hasTreemap && ["bar", "candlestick", "line", "area"].forEach((v) => {
|
8250 | const name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
|
8251 | if ($$.hasType(v) || $$.hasTypeOf(name) || v === "line" && ($$.hasType("bubble") || $$.hasType("scatter"))) {
|
8252 | const indices = $$.getShapeIndices($$[`is${name}Type`]);
|
8253 | const drawFn = $$[`generateDraw${name}`];
|
8254 | shape.indices[v] = indices;
|
8255 | shape.type[v] = drawFn ? drawFn.bind($$)(indices, false) : void 0;
|
8256 | }
|
8257 | });
|
8258 | if (!$$.hasArcType() || hasRadar || hasTreemap) {
|
8259 | let cx;
|
8260 | let cy;
|
8261 | if (!hasTreemap) {
|
8262 | cx = hasRadar ? $$.radarCircleX : isRotated ? $$.circleY : $$.circleX;
|
8263 | cy = hasRadar ? $$.radarCircleY : isRotated ? $$.circleX : $$.circleY;
|
8264 | }
|
8265 | shape.pos = {
|
8266 | xForText: $$.generateXYForText(shape.indices, true),
|
8267 | yForText: $$.generateXYForText(shape.indices, false),
|
8268 | cx: (cx || function() {
|
8269 | }).bind($$),
|
8270 | cy: (cy || function() {
|
8271 | }).bind($$)
|
8272 | };
|
8273 | }
|
8274 | return shape;
|
8275 | },
|
8276 | |
8277 |
|
8278 |
|
8279 |
|
8280 |
|
8281 |
|
8282 |
|
8283 |
|
8284 |
|
8285 |
|
8286 |
|
8287 |
|
8288 |
|
8289 | getShapeIndices(typeFilter) {
|
8290 | const $$ = this;
|
8291 | const { config } = $$;
|
8292 | const xs = config.data_xs;
|
8293 | const hasXs = notEmpty(xs);
|
8294 | const indices = {};
|
8295 | let i = hasXs ? {} : 0;
|
8296 | if (hasXs) {
|
8297 | getUnique(Object.keys(xs).map((v) => xs[v])).forEach((v) => {
|
8298 | i[v] = 0;
|
8299 | indices[v] = {};
|
8300 | });
|
8301 | }
|
8302 | $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach((d) => {
|
8303 | var _a;
|
8304 | const xKey = d.id in xs ? xs[d.id] : "";
|
8305 | const ind = xKey ? indices[xKey] : indices;
|
8306 | for (let j = 0, groups; groups = config.data_groups[j]; j++) {
|
8307 | if (groups.indexOf(d.id) < 0) {
|
8308 | continue;
|
8309 | }
|
8310 | for (let k = 0, key; key = groups[k]; k++) {
|
8311 | if (key in ind) {
|
8312 | ind[d.id] = ind[key];
|
8313 | break;
|
8314 | }
|
8315 | if (d.id !== key && xKey) {
|
8316 | ind[key] = (_a = ind[d.id]) != null ? _a : i[xKey];
|
8317 | }
|
8318 | }
|
8319 | }
|
8320 | if (isUndefined(ind[d.id])) {
|
8321 | ind[d.id] = xKey ? i[xKey]++ : i++;
|
8322 | ind.__max__ = (xKey ? i[xKey] : i) - 1;
|
8323 | }
|
8324 | });
|
8325 | return indices;
|
8326 | },
|
8327 | |
8328 |
|
8329 |
|
8330 |
|
8331 |
|
8332 |
|
8333 |
|
8334 |
|
8335 | getIndices(indices, d, caller) {
|
8336 | const $$ = this;
|
8337 | const { data_xs: xs, bar_indices_removeNull: removeNull } = $$.config;
|
8338 | const { id, index } = d;
|
8339 | if ($$.isBarType(id) && removeNull) {
|
8340 | const ind = {};
|
8341 | $$.getAllValuesOnIndex(index, true).forEach((v, i) => {
|
8342 | ind[v.id] = i;
|
8343 | ind.__max__ = i;
|
8344 | });
|
8345 | return ind;
|
8346 | }
|
8347 | return notEmpty(xs) ? indices[xs[id]] : indices;
|
8348 | },
|
8349 | |
8350 |
|
8351 |
|
8352 |
|
8353 |
|
8354 |
|
8355 | getIndicesMax(indices) {
|
8356 | return notEmpty(this.config.data_xs) ? (
|
8357 |
|
8358 | Object.keys(indices).map((v) => indices[v].__max__ || 0).reduce((acc, curr) => acc + curr)
|
8359 | ) : indices.__max__;
|
8360 | },
|
8361 | getShapeX(offset, indices, isSub) {
|
8362 | const $$ = this;
|
8363 | const { config, scale } = $$;
|
8364 | const currScale = isSub ? scale.subX : scale.zoom || scale.x;
|
8365 | const barOverlap = config.bar_overlap;
|
8366 | const barPadding = config.bar_padding;
|
8367 | const sum = (p, c) => p + c;
|
8368 | const halfWidth = isObjectType(offset) && (offset._$total.length ? offset._$total.reduce(sum) / 2 : 0);
|
8369 | return (d) => {
|
8370 | const ind = $$.getIndices(indices, d, "getShapeX");
|
8371 | const index = d.id in ind ? ind[d.id] : 0;
|
8372 | const targetsNum = (ind.__max__ || 0) + 1;
|
8373 | let x = 0;
|
8374 | if (notEmpty(d.x)) {
|
8375 | const xPos = currScale(d.x, true);
|
8376 | if (halfWidth) {
|
8377 | const offsetWidth = offset[d.id] || offset._$width;
|
8378 | x = barOverlap ? xPos - offsetWidth / 2 : xPos - offsetWidth + offset._$total.slice(0, index + 1).reduce(sum) - halfWidth;
|
8379 | } else {
|
8380 | x = xPos - (isNumber(offset) ? offset : offset._$width) * (targetsNum / 2 - (barOverlap ? 1 : index));
|
8381 | }
|
8382 | }
|
8383 | if (offset && x && targetsNum > 1 && barPadding) {
|
8384 | if (index) {
|
8385 | x += barPadding * index;
|
8386 | }
|
8387 | if (targetsNum > 2) {
|
8388 | x -= (targetsNum - 1) * barPadding / 2;
|
8389 | } else if (targetsNum === 2) {
|
8390 | x -= barPadding / 2;
|
8391 | }
|
8392 | }
|
8393 | return x;
|
8394 | };
|
8395 | },
|
8396 | getShapeY(isSub) {
|
8397 | const $$ = this;
|
8398 | const isStackNormalized = $$.isStackNormalized();
|
8399 | return (d) => {
|
8400 | let { value } = d;
|
8401 | if (isNumber(d)) {
|
8402 | value = d;
|
8403 | } else if ($$.isAreaRangeType(d)) {
|
8404 | value = $$.getBaseValue(d, "mid");
|
8405 | } else if (isStackNormalized) {
|
8406 | value = $$.getRatio("index", d, true);
|
8407 | } else if ($$.isBubbleZType(d)) {
|
8408 | value = $$.getBubbleZData(d.value, "y");
|
8409 | } else if ($$.isBarRangeType(d)) {
|
8410 | value = value[1];
|
8411 | }
|
8412 | return $$.getYScaleById(d.id, isSub)(value);
|
8413 | };
|
8414 | },
|
8415 | |
8416 |
|
8417 |
|
8418 |
|
8419 |
|
8420 |
|
8421 | getShapeYMin(id) {
|
8422 | const $$ = this;
|
8423 | const axisId = $$.axis.getId(id);
|
8424 | const scale = $$.scale[axisId];
|
8425 | const [yMin] = scale.domain();
|
8426 | const inverted = $$.config[`axis_${axisId}_inverted`];
|
8427 | return !$$.isGrouped(id) && !inverted && yMin > 0 ? yMin : 0;
|
8428 | },
|
8429 | |
8430 |
|
8431 |
|
8432 |
|
8433 |
|
8434 |
|
8435 | getShapeOffsetData(typeFilter) {
|
8436 | const $$ = this;
|
8437 | const targets = $$.orderTargets(
|
8438 | $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
|
8439 | );
|
8440 | const isStackNormalized = $$.isStackNormalized();
|
8441 | const shapeOffsetTargets = targets.map((target) => {
|
8442 | let rowValues = target.values;
|
8443 | const values = {};
|
8444 | if ($$.isStepType(target)) {
|
8445 | rowValues = $$.convertValuesToStep(rowValues);
|
8446 | }
|
8447 | const rowValueMapByXValue = rowValues.reduce((out, d) => {
|
8448 | const key = Number(d.x);
|
8449 | out[key] = d;
|
8450 | values[key] = isStackNormalized ? $$.getRatio("index", d, true) : d.value;
|
8451 | return out;
|
8452 | }, {});
|
8453 | return {
|
8454 | id: target.id,
|
8455 | rowValues,
|
8456 | rowValueMapByXValue,
|
8457 | values
|
8458 | };
|
8459 | });
|
8460 | const indexMapByTargetId = targets.reduce((out, { id }, index) => {
|
8461 | out[id] = index;
|
8462 | return out;
|
8463 | }, {});
|
8464 | return { indexMapByTargetId, shapeOffsetTargets };
|
8465 | },
|
8466 | getShapeOffset(typeFilter, indices, isSub) {
|
8467 | const $$ = this;
|
8468 | const { shapeOffsetTargets, indexMapByTargetId } = $$.getShapeOffsetData(
|
8469 | typeFilter
|
8470 | );
|
8471 | const groupsZeroAs = $$.config.data_groupsZeroAs;
|
8472 | return (d, idx) => {
|
8473 | const { id, value, x } = d;
|
8474 | const ind = $$.getIndices(indices, d);
|
8475 | const scale = $$.getYScaleById(id, isSub);
|
8476 | if ($$.isBarRangeType(d)) {
|
8477 | return scale(value[0]);
|
8478 | }
|
8479 | const dataXAsNumber = Number(x);
|
8480 | const y0 = scale(groupsZeroAs === "zero" ? 0 : $$.getShapeYMin(id));
|
8481 | let offset = y0;
|
8482 | shapeOffsetTargets.filter((t) => t.id !== id && ind[t.id] === ind[id]).forEach((t) => {
|
8483 | const {
|
8484 | id: tid,
|
8485 | rowValueMapByXValue,
|
8486 | rowValues,
|
8487 | values: tvalues
|
8488 | } = t;
|
8489 | if (indexMapByTargetId[tid] < indexMapByTargetId[id]) {
|
8490 | const rValue = tvalues[dataXAsNumber];
|
8491 | let row = rowValues[idx];
|
8492 | if (!row || Number(row.x) !== dataXAsNumber) {
|
8493 | row = rowValueMapByXValue[dataXAsNumber];
|
8494 | }
|
8495 | if ((row == null ? void 0 : row.value) * value >= 0 && isNumber(rValue)) {
|
8496 | const addOffset = value === 0 ? groupsZeroAs === "positive" && rValue > 0 || groupsZeroAs === "negative" && rValue < 0 : true;
|
8497 | if (addOffset) {
|
8498 | offset += scale(rValue) - y0;
|
8499 | }
|
8500 | }
|
8501 | }
|
8502 | });
|
8503 | return offset;
|
8504 | };
|
8505 | },
|
8506 | |
8507 |
|
8508 |
|
8509 |
|
8510 |
|
8511 |
|
8512 |
|
8513 | circleY(d, i) {
|
8514 | const $$ = this;
|
8515 | const id = d.id;
|
8516 | let points;
|
8517 | if ($$.isGrouped(id)) {
|
8518 | points = getGroupedDataPointsFn.bind($$)(d);
|
8519 | }
|
8520 | return points ? points(d, i)[0][1] : $$.getYScaleById(id)($$.getBaseValue(d));
|
8521 | },
|
8522 | getBarW(type, axis, targetsNum) {
|
8523 | var _a, _b, _c, _d, _e;
|
8524 | const $$ = this;
|
8525 | const { config, org, scale, state } = $$;
|
8526 | const maxDataCount = $$.getMaxDataCount();
|
8527 | const isGrouped = type === "bar" && ((_a = config.data_groups) == null ? void 0 : _a.length);
|
8528 | const configName = `${type}_width`;
|
8529 | const { k } = (_c = (_b = $$.getZoomTransform) == null ? void 0 : _b.call($$)) != null ? _c : { k: 1 };
|
8530 | const xMinMax = [
|
8531 | (_d = config.axis_x_min) != null ? _d : org.xDomain[0],
|
8532 | (_e = config.axis_x_max) != null ? _e : org.xDomain[1]
|
8533 | ].map($$.axis.isTimeSeries() ? parseDate.bind($$) : Number);
|
8534 | let tickInterval = axis.tickInterval(maxDataCount);
|
8535 | if (scale.zoom && !$$.axis.isCategorized() && k > 1) {
|
8536 | const isSameMinMax = xMinMax.every((v, i) => v === org.xDomain[i]);
|
8537 | tickInterval = org.xDomain.map((v, i) => {
|
8538 | const value = isSameMinMax ? v : v - Math.abs(xMinMax[i]);
|
8539 | return scale.zoom(value);
|
8540 | }).reduce((a, c) => Math.abs(a) + c) / maxDataCount;
|
8541 | }
|
8542 | const getWidth = (id) => {
|
8543 | const width = id ? config[configName][id] : config[configName];
|
8544 | const ratio = id ? width.ratio : config[`${configName}_ratio`];
|
8545 | const max = id ? width.max : config[`${configName}_max`];
|
8546 | const w = isNumber(width) ? width : isFunction(width) ? width.call($$, state.width, targetsNum, maxDataCount) : targetsNum ? tickInterval * ratio / targetsNum : 0;
|
8547 | return max && w > max ? max : w;
|
8548 | };
|
8549 | let result = getWidth();
|
8550 | if (!isGrouped && isObjectType(config[configName])) {
|
8551 | result = { _$width: result, _$total: [] };
|
8552 | $$.filterTargetsToShow($$.data.targets).forEach((v) => {
|
8553 | if (config[configName][v.id]) {
|
8554 | result[v.id] = getWidth(v.id);
|
8555 | result._$total.push(result[v.id] || result._$width);
|
8556 | }
|
8557 | });
|
8558 | }
|
8559 | return result;
|
8560 | },
|
8561 | |
8562 |
|
8563 |
|
8564 |
|
8565 |
|
8566 |
|
8567 |
|
8568 |
|
8569 | getShapeByIndex(shapeName, i, id) {
|
8570 | const $$ = this;
|
8571 | const { $el } = $$;
|
8572 | const suffix = isValue(i) ? `-${i}` : ``;
|
8573 | let shape = $el[shapeName];
|
8574 | if (shape && !shape.empty()) {
|
8575 | shape = shape.filter((d) => id ? d.id === id : true).filter((d) => isValue(i) ? d.index === i : true);
|
8576 | } else {
|
8577 | shape = (id ? $el.main.selectAll(
|
8578 | `.${classes[`${shapeName}s`]}${$$.getTargetSelectorSuffix(id)}`
|
8579 | ) : $el.main).selectAll(`.${classes[shapeName]}${suffix}`);
|
8580 | }
|
8581 | return shape;
|
8582 | },
|
8583 | isWithinShape(that, d) {
|
8584 | var _a;
|
8585 | const $$ = this;
|
8586 | const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that);
|
8587 | let isWithin;
|
8588 | if (!$$.isTargetToShow(d.id)) {
|
8589 | isWithin = false;
|
8590 | } else if ((_a = $$.hasValidPointType) == null ? void 0 : _a.call($$, that.nodeName)) {
|
8591 | isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScaleById(d.id)($$.getBaseValue(d))) : $$.isWithinCircle(
|
8592 | that,
|
8593 | $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0
|
8594 | );
|
8595 | } else if (that.nodeName === "path") {
|
8596 | isWithin = shape.classed(classes.bar) ? $$.isWithinBar(that) : true;
|
8597 | }
|
8598 | return isWithin;
|
8599 | },
|
8600 | getInterpolate(d) {
|
8601 | const $$ = this;
|
8602 | const interpolation = $$.getInterpolateType(d);
|
8603 | return {
|
8604 | basis: external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasis,
|
8605 | "basis-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisClosed,
|
8606 | "basis-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisOpen,
|
8607 | bundle: external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBundle,
|
8608 | cardinal: external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinal,
|
8609 | "cardinal-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalClosed,
|
8610 | "cardinal-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalOpen,
|
8611 | "catmull-rom": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRom,
|
8612 | "catmull-rom-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomClosed,
|
8613 | "catmull-rom-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomOpen,
|
8614 | "monotone-x": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneX,
|
8615 | "monotone-y": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneY,
|
8616 | natural: external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveNatural,
|
8617 | "linear-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinearClosed,
|
8618 | linear: external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinear,
|
8619 | step: external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStep,
|
8620 | "step-after": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepAfter,
|
8621 | "step-before": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepBefore
|
8622 | }[interpolation];
|
8623 | },
|
8624 | getInterpolateType(d) {
|
8625 | const $$ = this;
|
8626 | const { config } = $$;
|
8627 | const type = config.spline_interpolation_type;
|
8628 | const interpolation = $$.isInterpolationType(type) ? type : "cardinal";
|
8629 | return $$.isSplineType(d) ? interpolation : $$.isStepType(d) ? config.line_step_type : "linear";
|
8630 | },
|
8631 | isWithinBar(that) {
|
8632 | const mouse = getPointer(this.state.event, that);
|
8633 | const list = getRectSegList(that);
|
8634 | const [seg0, seg1] = list;
|
8635 | const x = Math.min(seg0.x, seg1.x);
|
8636 | const y = Math.min(seg0.y, seg1.y);
|
8637 | const offset = this.config.bar_sensitivity;
|
8638 | const { width, height } = that.getBBox();
|
8639 | const sx = x - offset;
|
8640 | const ex = x + width + offset;
|
8641 | const sy = y + height + offset;
|
8642 | const ey = y - offset;
|
8643 | const isWithin = sx < mouse[0] && mouse[0] < ex && ey < mouse[1] && mouse[1] < sy;
|
8644 | return isWithin;
|
8645 | }
|
8646 | });
|
8647 |
|
8648 | ;
|
8649 | var ChartInternal_defProp = Object.defineProperty;
|
8650 | var ChartInternal_defNormalProp = (obj, key, value) => key in obj ? ChartInternal_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8651 | var ChartInternal_publicField = (obj, key, value) => ChartInternal_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
8652 |
|
8653 |
|
8654 |
|
8655 |
|
8656 |
|
8657 |
|
8658 |
|
8659 |
|
8660 |
|
8661 |
|
8662 |
|
8663 |
|
8664 |
|
8665 |
|
8666 |
|
8667 |
|
8668 |
|
8669 |
|
8670 |
|
8671 |
|
8672 |
|
8673 |
|
8674 |
|
8675 |
|
8676 |
|
8677 |
|
8678 |
|
8679 |
|
8680 |
|
8681 |
|
8682 | class ChartInternal {
|
8683 | constructor(api) {
|
8684 | ChartInternal_publicField(this, "api");
|
8685 |
|
8686 | ChartInternal_publicField(this, "config");
|
8687 |
|
8688 | ChartInternal_publicField(this, "cache");
|
8689 |
|
8690 | ChartInternal_publicField(this, "$el");
|
8691 |
|
8692 | ChartInternal_publicField(this, "state");
|
8693 |
|
8694 | ChartInternal_publicField(this, "charts");
|
8695 |
|
8696 |
|
8697 | ChartInternal_publicField(this, "data", {
|
8698 | xs: {},
|
8699 | targets: []
|
8700 | });
|
8701 |
|
8702 | ChartInternal_publicField(this, "axis");
|
8703 |
|
8704 |
|
8705 | ChartInternal_publicField(this, "scale", {
|
8706 | x: null,
|
8707 | y: null,
|
8708 | y2: null,
|
8709 | subX: null,
|
8710 | subY: null,
|
8711 | subY2: null,
|
8712 | zoom: null
|
8713 | });
|
8714 |
|
8715 | ChartInternal_publicField(this, "org", {
|
8716 | xScale: null,
|
8717 | xDomain: null
|
8718 | });
|
8719 |
|
8720 | ChartInternal_publicField(this, "color");
|
8721 | ChartInternal_publicField(this, "patterns");
|
8722 | ChartInternal_publicField(this, "levelColor");
|
8723 | ChartInternal_publicField(this, "point");
|
8724 | ChartInternal_publicField(this, "brush");
|
8725 |
|
8726 | ChartInternal_publicField(this, "format", {
|
8727 | extraLineClasses: null,
|
8728 | xAxisTick: null,
|
8729 | dataTime: null,
|
8730 |
|
8731 | defaultAxisTime: null,
|
8732 |
|
8733 | axisTime: null
|
8734 |
|
8735 | });
|
8736 | const $$ = this;
|
8737 | $$.api = api;
|
8738 | $$.config = new Options();
|
8739 | $$.cache = new Cache();
|
8740 | const store = new Store();
|
8741 | $$.$el = store.getStore("element");
|
8742 | $$.state = store.getStore("state");
|
8743 | $$.$T = $$.$T.bind($$);
|
8744 | }
|
8745 | |
8746 |
|
8747 |
|
8748 |
|
8749 |
|
8750 |
|
8751 |
|
8752 |
|
8753 | $T(selection, force, name) {
|
8754 | const { config, state } = this;
|
8755 | const duration = config.transition_duration;
|
8756 | const subchart = config.subchart_show;
|
8757 | let t = selection;
|
8758 | if (t) {
|
8759 | if ("tagName" in t) {
|
8760 | t = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(t);
|
8761 | }
|
8762 | const transit = (force !== false && duration || force) && (!state.zooming || state.dragging) && !state.resizing && state.rendered && !subchart;
|
8763 | t = transit ? t.transition(name).duration(duration) : t;
|
8764 | }
|
8765 | return t;
|
8766 | }
|
8767 | beforeInit() {
|
8768 | const $$ = this;
|
8769 | $$.callPluginHook("$beforeInit");
|
8770 | callFn($$.config.onbeforeinit, $$.api);
|
8771 | }
|
8772 | afterInit() {
|
8773 | const $$ = this;
|
8774 | $$.callPluginHook("$afterInit");
|
8775 | callFn($$.config.onafterinit, $$.api);
|
8776 | }
|
8777 | init() {
|
8778 | const $$ = this;
|
8779 | const { config, state, $el } = $$;
|
8780 | const useCssRule = config.boost_useCssRule;
|
8781 | checkModuleImport($$);
|
8782 | state.hasRadar = !state.hasAxis && $$.hasType("radar");
|
8783 | state.hasFunnel = !state.hasAxis && $$.hasType("funnel");
|
8784 | state.hasTreemap = !state.hasAxis && $$.hasType("treemap");
|
8785 | state.hasAxis = !$$.hasArcType() && !state.hasFunnel && !state.hasTreemap;
|
8786 | state.datetimeId = `bb-${+/* @__PURE__ */ new Date() * getRandom()}`;
|
8787 | if (useCssRule) {
|
8788 | const styleEl = browser_doc.createElement("style");
|
8789 | styleEl.type = "text/css";
|
8790 | browser_doc.head.appendChild(styleEl);
|
8791 | state.style = {
|
8792 | rootSelctor: `.${state.datetimeId}`,
|
8793 | sheet: styleEl.sheet
|
8794 | };
|
8795 | $el.style = styleEl;
|
8796 | }
|
8797 | const bindto = {
|
8798 | element: config.bindto,
|
8799 | classname: "bb"
|
8800 | };
|
8801 | if (isObject(config.bindto)) {
|
8802 | bindto.element = config.bindto.element || "#chart";
|
8803 | bindto.classname = config.bindto.classname || bindto.classname;
|
8804 | }
|
8805 | $el.chart = isFunction(bindto.element.node) ? config.bindto.element : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(bindto.element || []);
|
8806 | if ($el.chart.empty()) {
|
8807 | $el.chart = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.body.appendChild(browser_doc.createElement("div")));
|
8808 | }
|
8809 | $el.chart.html("").classed(bindto.classname, true).classed(state.datetimeId, useCssRule).style("position", "relative");
|
8810 | $$.initParams();
|
8811 | $$.initToRender();
|
8812 | }
|
8813 | |
8814 |
|
8815 |
|
8816 |
|
8817 |
|
8818 | initToRender(forced) {
|
8819 | const $$ = this;
|
8820 | const { config, state, $el: { chart } } = $$;
|
8821 | const isHidden = () => hasStyle(chart, { display: "none", visibility: "hidden" });
|
8822 | const isLazy = config.render.lazy === false ? false : config.render.lazy || isHidden();
|
8823 | const MutationObserver = win.MutationObserver;
|
8824 | if (isLazy && MutationObserver && config.render.observe !== false && !forced) {
|
8825 | new MutationObserver((mutation, observer) => {
|
8826 | if (!isHidden()) {
|
8827 | observer.disconnect();
|
8828 | !state.rendered && $$.initToRender(true);
|
8829 | }
|
8830 | }).observe(chart.node(), {
|
8831 | attributes: true,
|
8832 | attributeFilter: ["class", "style"]
|
8833 | });
|
8834 | }
|
8835 | if (!isLazy || forced) {
|
8836 | $$.convertData(config, (res) => {
|
8837 | $$.initWithData(res);
|
8838 | $$.afterInit();
|
8839 | });
|
8840 | }
|
8841 | }
|
8842 | initParams() {
|
8843 | var _a;
|
8844 | const $$ = this;
|
8845 | const { config, format: format2, state } = $$;
|
8846 | const isRotated = config.axis_rotated;
|
8847 | $$.color = $$.generateColor();
|
8848 | $$.levelColor = $$.generateLevelColor();
|
8849 | if (config.padding === false) {
|
8850 | config.axis_x_show = false;
|
8851 | config.axis_y_show = false;
|
8852 | config.axis_y2_show = false;
|
8853 | config.subchart_show = false;
|
8854 | }
|
8855 | if ($$.hasPointType() || ((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$))) {
|
8856 | $$.point = $$.generatePoint();
|
8857 | }
|
8858 | if (state.hasAxis) {
|
8859 | $$.initClip();
|
8860 | format2.extraLineClasses = $$.generateExtraLineClass();
|
8861 | format2.dataTime = config.data_xLocaltime ? external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.timeParse : external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.utcParse;
|
8862 | format2.axisTime = config.axis_x_localtime ? external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.timeFormat : external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_.utcFormat;
|
8863 | const isDragZoom = $$.config.zoom_enabled && $$.config.zoom_type === "drag";
|
8864 | format2.defaultAxisTime = (d) => {
|
8865 | const { x, zoom } = $$.scale;
|
8866 | const isZoomed = isDragZoom ? zoom : zoom && x.orgDomain().toString() !== zoom.domain().toString();
|
8867 | const specifier = d.getMilliseconds() && ".%L" || d.getSeconds() && ".:%S" || d.getMinutes() && "%I:%M" || d.getHours() && "%I %p" || d.getDate() !== 1 && "%b %d" || isZoomed && d.getDate() === 1 && "%b'%y" || d.getMonth() && "%-m/%-d" || "%Y";
|
8868 | return format2.axisTime(specifier)(d);
|
8869 | };
|
8870 | }
|
8871 | state.isLegendRight = config.legend_position === "right";
|
8872 | state.isLegendInset = config.legend_position === "inset";
|
8873 | state.isLegendTop = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "top-right";
|
8874 | state.isLegendLeft = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "bottom-left";
|
8875 | state.rotatedPadding.top = $$.getResettedPadding(state.rotatedPadding.top);
|
8876 | state.rotatedPadding.right = isRotated && !config.axis_x_show ? 0 : 30;
|
8877 | state.inputType = convertInputType(
|
8878 | config.interaction_inputType_mouse,
|
8879 | config.interaction_inputType_touch
|
8880 | );
|
8881 | }
|
8882 | initWithData(data2) {
|
8883 | var _a, _b, _c;
|
8884 | const $$ = this;
|
8885 | const { config, scale: scale2, state, $el, org } = $$;
|
8886 | const { hasAxis, hasFunnel, hasTreemap } = state;
|
8887 | const hasInteraction = config.interaction_enabled;
|
8888 | const hasPolar = $$.hasType("polar");
|
8889 | const labelsBGColor = config.data_labels_backgroundColors;
|
8890 | if (hasAxis) {
|
8891 | $$.axis = $$.getAxisInstance();
|
8892 | config.zoom_enabled && $$.initZoom();
|
8893 | }
|
8894 | $$.data.xs = {};
|
8895 | $$.data.targets = $$.convertDataToTargets(data2);
|
8896 | if (config.data_filter) {
|
8897 | $$.data.targets = $$.data.targets.filter(config.data_filter.bind($$.api));
|
8898 | }
|
8899 | if (config.data_hide) {
|
8900 | $$.addHiddenTargetIds(
|
8901 | config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide
|
8902 | );
|
8903 | }
|
8904 | if (config.legend_hide) {
|
8905 | $$.addHiddenLegendIds(
|
8906 | config.legend_hide === true ? $$.mapToIds($$.data.targets) : config.legend_hide
|
8907 | );
|
8908 | }
|
8909 | $$.updateSizes();
|
8910 | $$.updateScales(true);
|
8911 | if (hasAxis) {
|
8912 | const { x, y, y2, subX, subY, subY2 } = scale2;
|
8913 | if (x) {
|
8914 | x.domain(sortValue($$.getXDomain($$.data.targets), !config.axis_x_inverted));
|
8915 | subX.domain(x.domain());
|
8916 | org.xDomain = x.domain();
|
8917 | }
|
8918 | if (y) {
|
8919 | y.domain($$.getYDomain($$.data.targets, "y"));
|
8920 | subY.domain(y.domain());
|
8921 | }
|
8922 | if (y2) {
|
8923 | y2.domain($$.getYDomain($$.data.targets, "y2"));
|
8924 | subY2 && subY2.domain(y2.domain());
|
8925 | }
|
8926 | }
|
8927 | $el.svg = $el.chart.append("svg").style("overflow", "hidden").style("display", "block");
|
8928 | if (hasInteraction && state.inputType) {
|
8929 | const isTouch = state.inputType === "touch";
|
8930 | const { onclick, onover, onout } = config;
|
8931 | $el.svg.on("click", (onclick == null ? void 0 : onclick.bind($$.api)) || null).on(isTouch ? "touchstart" : "mouseenter", (onover == null ? void 0 : onover.bind($$.api)) || null).on(isTouch ? "touchend" : "mouseleave", (onout == null ? void 0 : onout.bind($$.api)) || null);
|
8932 | }
|
8933 | config.svg_classname && $el.svg.attr("class", config.svg_classname);
|
8934 | const hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
|
8935 | if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$))) {
|
8936 | $el.defs = $el.svg.append("defs");
|
8937 | if (hasAxis) {
|
8938 | ["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
|
8939 | $$.appendClip($el.defs, state.clip[v]);
|
8940 | });
|
8941 | }
|
8942 | $$.generateTextBGColorFilter(labelsBGColor);
|
8943 | if (hasColorPatterns) {
|
8944 | $$.patterns.forEach((p) => $el.defs.append(() => p.node));
|
8945 | }
|
8946 | }
|
8947 | $$.updateSvgSize();
|
8948 | $$.bindResize();
|
8949 | const main = $el.svg.append("g").classed($COMMON.main, true).attr("transform", hasFunnel || hasTreemap ? null : $$.getTranslate("main"));
|
8950 | $el.main = main;
|
8951 | config.subchart_show && $$.initSubchart();
|
8952 | config.tooltip_show && $$.initTooltip();
|
8953 | config.title_text && $$.initTitle();
|
8954 | !hasTreemap && config.legend_show && $$.initLegend();
|
8955 | if (config.data_empty_label_text) {
|
8956 | main.append("text").attr("class", `${$TEXT.text} ${$COMMON.empty}`).attr("text-anchor", "middle").attr("dominant-baseline", "middle");
|
8957 | }
|
8958 | if (hasAxis) {
|
8959 | config.regions.length && $$.initRegion();
|
8960 | !config.clipPath && $$.axis.init();
|
8961 | }
|
8962 | main.append("g").classed($COMMON.chart, true).attr("clip-path", hasAxis ? state.clip.path : null);
|
8963 | $$.callPluginHook("$init");
|
8964 | $$.initChartElements();
|
8965 | if (hasAxis) {
|
8966 | hasInteraction && ((_b = $$.initEventRect) == null ? void 0 : _b.call($$));
|
8967 | $$.initGrid();
|
8968 | config.clipPath && ((_c = $$.axis) == null ? void 0 : _c.init());
|
8969 | }
|
8970 | $$.updateTargets($$.data.targets);
|
8971 | $$.updateDimension();
|
8972 | callFn(config.oninit, $$.api);
|
8973 | $$.setBackground();
|
8974 | $$.redraw({
|
8975 | withTransition: false,
|
8976 | withTransform: true,
|
8977 | withUpdateXDomain: true,
|
8978 | withUpdateOrgXDomain: true,
|
8979 | withTransitionForAxis: false,
|
8980 | initializing: true
|
8981 | });
|
8982 | if (config.data_onmin || config.data_onmax) {
|
8983 | const minMax = $$.getMinMaxData();
|
8984 | callFn(config.data_onmin, $$.api, minMax.min);
|
8985 | callFn(config.data_onmax, $$.api, minMax.max);
|
8986 | }
|
8987 | config.tooltip_show && $$.initShowTooltip();
|
8988 | state.rendered = true;
|
8989 | }
|
8990 | |
8991 |
|
8992 |
|
8993 |
|
8994 | initChartElements() {
|
8995 | const $$ = this;
|
8996 | const { hasAxis, hasRadar, hasTreemap } = $$.state;
|
8997 | const types = [];
|
8998 | if (hasAxis) {
|
8999 | const shapes = ["bar", "bubble", "candlestick", "line"];
|
9000 | if ($$.config.bar_front) {
|
9001 | shapes.push(shapes.shift());
|
9002 | }
|
9003 | shapes.forEach((v) => {
|
9004 | const name = capitalize(v);
|
9005 | if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
|
9006 | types.push(name);
|
9007 | }
|
9008 | });
|
9009 | } else if (hasTreemap) {
|
9010 | types.push("Treemap");
|
9011 | } else if ($$.hasType("funnel")) {
|
9012 | types.push("Funnel");
|
9013 | } else {
|
9014 | const hasPolar = $$.hasType("polar");
|
9015 | if (!hasRadar) {
|
9016 | types.push("Arc", "Pie");
|
9017 | }
|
9018 | if ($$.hasType("gauge")) {
|
9019 | types.push("Gauge");
|
9020 | } else if (hasRadar) {
|
9021 | types.push("Radar");
|
9022 | } else if (hasPolar) {
|
9023 | types.push("Polar");
|
9024 | }
|
9025 | }
|
9026 | types.forEach((v) => {
|
9027 | $$[`init${v}`]();
|
9028 | });
|
9029 | notEmpty($$.config.data_labels) && !$$.hasArcType(null, ["radar"]) && $$.initText();
|
9030 | }
|
9031 | |
9032 |
|
9033 |
|
9034 |
|
9035 | setChartElements() {
|
9036 | const $$ = this;
|
9037 | const {
|
9038 | $el: {
|
9039 | chart,
|
9040 | svg,
|
9041 | defs,
|
9042 | main,
|
9043 | tooltip: tooltip2,
|
9044 | legend: legend2,
|
9045 | title: title2,
|
9046 | grid,
|
9047 | needle,
|
9048 | arcs: arc,
|
9049 | circle: circles,
|
9050 | bar: bars,
|
9051 | candlestick,
|
9052 | line: lines,
|
9053 | area: areas,
|
9054 | text: texts
|
9055 | }
|
9056 | } = $$;
|
9057 | $$.api.$ = {
|
9058 | chart,
|
9059 | svg,
|
9060 | defs,
|
9061 | main,
|
9062 | tooltip: tooltip2,
|
9063 | legend: legend2,
|
9064 | title: title2,
|
9065 | grid,
|
9066 | arc,
|
9067 | circles,
|
9068 | bar: { bars },
|
9069 | candlestick,
|
9070 | line: { lines, areas },
|
9071 | needle,
|
9072 | text: { texts }
|
9073 | };
|
9074 | }
|
9075 | |
9076 |
|
9077 |
|
9078 |
|
9079 | setBackground() {
|
9080 | const $$ = this;
|
9081 | const { config: { background: bg }, state, $el: { svg } } = $$;
|
9082 | if (notEmpty(bg)) {
|
9083 | const element = svg.select("g").insert(bg.imgUrl ? "image" : "rect", ":first-child");
|
9084 | if (bg.imgUrl) {
|
9085 | element.attr("href", bg.imgUrl);
|
9086 | } else if (bg.color) {
|
9087 | element.style("fill", bg.color).attr("clip-path", state.clip.path);
|
9088 | }
|
9089 | element.attr("class", bg.class || null).attr("width", "100%").attr("height", "100%");
|
9090 | }
|
9091 | }
|
9092 | |
9093 |
|
9094 |
|
9095 |
|
9096 |
|
9097 | updateTargets(targets) {
|
9098 | var _a;
|
9099 | const $$ = this;
|
9100 | const { hasAxis, hasFunnel, hasRadar, hasTreemap } = $$.state;
|
9101 | const helper = (type) => $$[`updateTargetsFor${type}`](
|
9102 | targets.filter($$[`is${type}Type`].bind($$))
|
9103 | );
|
9104 | $$.updateTargetsForText(targets);
|
9105 | if (hasAxis) {
|
9106 | ["bar", "candlestick", "line"].forEach((v) => {
|
9107 | const name = capitalize(v);
|
9108 | if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
|
9109 | helper(name);
|
9110 | }
|
9111 | });
|
9112 | $$.updateTargetsForSubchart && $$.updateTargetsForSubchart(targets);
|
9113 | } else if ($$.hasArcType(targets)) {
|
9114 | let type = "Arc";
|
9115 | if (hasRadar) {
|
9116 | type = "Radar";
|
9117 | } else if ($$.hasType("polar")) {
|
9118 | type = "Polar";
|
9119 | }
|
9120 | helper(type);
|
9121 | } else if (hasFunnel) {
|
9122 | helper("Funnel");
|
9123 | } else if (hasTreemap) {
|
9124 | helper("Treemap");
|
9125 | }
|
9126 | const hasPointType = $$.hasType("bubble") || $$.hasType("scatter");
|
9127 | if (hasPointType) {
|
9128 | (_a = $$.updateTargetForCircle) == null ? void 0 : _a.call($$);
|
9129 | }
|
9130 | $$.filterTargetsToShowAtInit(hasPointType);
|
9131 | }
|
9132 | |
9133 |
|
9134 |
|
9135 |
|
9136 |
|
9137 | filterTargetsToShowAtInit(hasPointType = false) {
|
9138 | const $$ = this;
|
9139 | const { $el: { svg }, $T } = $$;
|
9140 | let selector = `.${$COMMON.target}`;
|
9141 | if (hasPointType) {
|
9142 | selector += `, .${$CIRCLE.chartCircles} > .${$CIRCLE.circles}`;
|
9143 | }
|
9144 | $T(svg.selectAll(selector).filter((d) => $$.isTargetToShow(d.id))).style("opacity", null);
|
9145 | }
|
9146 | getWithOption(options) {
|
9147 | const withOptions = {
|
9148 | Dimension: true,
|
9149 | EventRect: true,
|
9150 | Legend: false,
|
9151 | Subchart: true,
|
9152 | Transform: false,
|
9153 | Transition: true,
|
9154 | TrimXDomain: true,
|
9155 | UpdateXAxis: "UpdateXDomain",
|
9156 | UpdateXDomain: false,
|
9157 | UpdateOrgXDomain: false,
|
9158 | TransitionForExit: "Transition",
|
9159 | TransitionForAxis: "Transition",
|
9160 | Y: true
|
9161 | };
|
9162 | Object.keys(withOptions).forEach((key) => {
|
9163 | let defVal = withOptions[key];
|
9164 | if (isString(defVal)) {
|
9165 | defVal = withOptions[defVal];
|
9166 | }
|
9167 | withOptions[key] = getOption(options, `with${key}`, defVal);
|
9168 | });
|
9169 | return withOptions;
|
9170 | }
|
9171 | initialOpacity(d) {
|
9172 | const $$ = this;
|
9173 | const { withoutFadeIn } = $$.state;
|
9174 | const r = $$.getBaseValue(d) !== null && withoutFadeIn[d.id] ? null : "0";
|
9175 | return r;
|
9176 | }
|
9177 | bindResize() {
|
9178 | const $$ = this;
|
9179 | const { config, state } = $$;
|
9180 | const resizeFunction = generateResize(config.resize_timer);
|
9181 | const list = [];
|
9182 | list.push(() => callFn(config.onresize, $$.api));
|
9183 | if (config.resize_auto === true) {
|
9184 | list.push(() => {
|
9185 | state.resizing = true;
|
9186 | if (config.legend_show) {
|
9187 | $$.updateSizes();
|
9188 | $$.updateLegend();
|
9189 | }
|
9190 | $$.api.flush(false);
|
9191 | });
|
9192 | }
|
9193 | list.push(() => {
|
9194 | callFn(config.onresized, $$.api);
|
9195 | state.resizing = false;
|
9196 | });
|
9197 | list.forEach((v) => resizeFunction.add(v));
|
9198 | $$.resizeFunction = resizeFunction;
|
9199 | win.addEventListener("resize", $$.resizeFunction = resizeFunction);
|
9200 | }
|
9201 | |
9202 |
|
9203 |
|
9204 |
|
9205 |
|
9206 |
|
9207 | callPluginHook(phase, ...args) {
|
9208 | this.config.plugins.forEach((v) => {
|
9209 | if (phase === "$beforeInit") {
|
9210 | v.$$ = this;
|
9211 | this.api.plugins.push(v);
|
9212 | }
|
9213 | v[phase](...args);
|
9214 | });
|
9215 | }
|
9216 | }
|
9217 | extend(ChartInternal.prototype, [
|
9218 |
|
9219 | convert,
|
9220 | data_data,
|
9221 | load,
|
9222 | category,
|
9223 | internals_class,
|
9224 | internals_color,
|
9225 | domain,
|
9226 | interactions_interaction,
|
9227 | format,
|
9228 | internals_legend,
|
9229 | redraw,
|
9230 | scale,
|
9231 | shape,
|
9232 | size,
|
9233 | style,
|
9234 | internals_text,
|
9235 | internals_title,
|
9236 | internals_tooltip,
|
9237 | transform,
|
9238 | type
|
9239 | ]);
|
9240 |
|
9241 | ;
|
9242 |
|
9243 | function loadConfig(config) {
|
9244 | const thisConfig = this.config;
|
9245 | let target;
|
9246 | let keys;
|
9247 | let read;
|
9248 | const find = () => {
|
9249 | const key = keys.shift();
|
9250 | if (key && target && isObjectType(target) && key in target) {
|
9251 | target = target[key];
|
9252 | return find();
|
9253 | } else if (!key) {
|
9254 | return target;
|
9255 | }
|
9256 | return void 0;
|
9257 | };
|
9258 | Object.keys(thisConfig).forEach((key) => {
|
9259 | target = config;
|
9260 | keys = key.split("_");
|
9261 | read = find();
|
9262 | if (isDefined(read)) {
|
9263 | thisConfig[key] = read;
|
9264 | }
|
9265 | });
|
9266 | if (this.api) {
|
9267 | this.state.orgConfig = config;
|
9268 | }
|
9269 | }
|
9270 |
|
9271 | ;
|
9272 |
|
9273 |
|
9274 | var chart = ({
|
9275 | |
9276 |
|
9277 |
|
9278 |
|
9279 |
|
9280 |
|
9281 |
|
9282 |
|
9283 |
|
9284 |
|
9285 |
|
9286 |
|
9287 |
|
9288 |
|
9289 |
|
9290 | resize(size) {
|
9291 | const $$ = this.internal;
|
9292 | const { config, state } = $$;
|
9293 | if (state.rendered) {
|
9294 | config.size_width = size ? size.width : null;
|
9295 | config.size_height = size ? size.height : null;
|
9296 | state.resizing = true;
|
9297 | this.flush(false);
|
9298 | $$.resizeFunction();
|
9299 | }
|
9300 | },
|
9301 | |
9302 |
|
9303 |
|
9304 |
|
9305 |
|
9306 |
|
9307 |
|
9308 |
|
9309 |
|
9310 |
|
9311 |
|
9312 |
|
9313 |
|
9314 | flush(soft) {
|
9315 | var _a, _b;
|
9316 | const $$ = this.internal;
|
9317 | const { state, $el: { zoomResetBtn } } = $$;
|
9318 | if (state.rendered) {
|
9319 | if (state.resizing) {
|
9320 | (_a = $$.brush) == null ? void 0 : _a.updateResize();
|
9321 | } else {
|
9322 | (_b = $$.axis) == null ? void 0 : _b.setOrient();
|
9323 | }
|
9324 | zoomResetBtn == null ? void 0 : zoomResetBtn.style("display", "none");
|
9325 | $$.scale.zoom = null;
|
9326 | soft ? $$.redraw({
|
9327 | withTransform: true,
|
9328 | withUpdateXDomain: true,
|
9329 | withUpdateOrgXDomain: true,
|
9330 | withLegend: true
|
9331 | }) : $$.updateAndRedraw({
|
9332 | withLegend: true,
|
9333 | withTransition: false,
|
9334 | withTransitionForTransform: false
|
9335 | });
|
9336 | if (!state.resizing && $$.brush) {
|
9337 | $$.brush.getSelection().call($$.brush.move);
|
9338 | $$.unselectRect();
|
9339 | }
|
9340 | } else {
|
9341 | $$.initToRender(true);
|
9342 | }
|
9343 | },
|
9344 | |
9345 |
|
9346 |
|
9347 |
|
9348 |
|
9349 |
|
9350 |
|
9351 |
|
9352 |
|
9353 | destroy() {
|
9354 | const $$ = this.internal;
|
9355 | const { $el: { chart, style, svg } } = $$;
|
9356 | if (notEmpty($$)) {
|
9357 | $$.callPluginHook("$willDestroy");
|
9358 | $$.charts.splice($$.charts.indexOf(this), 1);
|
9359 | $$.unbindAllEvents();
|
9360 | svg.select("*").interrupt();
|
9361 | $$.resizeFunction.clear();
|
9362 | win.removeEventListener("resize", $$.resizeFunction);
|
9363 | chart.classed("bb", false).style("position", null).selectChildren().remove();
|
9364 | style && style.parentNode.removeChild(style);
|
9365 | Object.keys(this).forEach((key) => {
|
9366 | key === "internal" && Object.keys($$).forEach((k) => {
|
9367 | $$[k] = null;
|
9368 | });
|
9369 | this[key] = null;
|
9370 | delete this[key];
|
9371 | });
|
9372 | for (const key in this) {
|
9373 | this[key] = () => {
|
9374 | };
|
9375 | }
|
9376 | }
|
9377 | return null;
|
9378 | },
|
9379 | |
9380 |
|
9381 |
|
9382 |
|
9383 |
|
9384 |
|
9385 |
|
9386 |
|
9387 |
|
9388 |
|
9389 |
|
9390 |
|
9391 |
|
9392 |
|
9393 |
|
9394 |
|
9395 |
|
9396 |
|
9397 |
|
9398 |
|
9399 |
|
9400 |
|
9401 |
|
9402 |
|
9403 |
|
9404 |
|
9405 |
|
9406 |
|
9407 |
|
9408 |
|
9409 |
|
9410 |
|
9411 |
|
9412 |
|
9413 |
|
9414 | config(name, value, redraw) {
|
9415 | const $$ = this.internal;
|
9416 | const { config, state } = $$;
|
9417 | const key = name == null ? void 0 : name.replace(/\./g, "_");
|
9418 | let res;
|
9419 | if (name && key in config) {
|
9420 | if (isDefined(value)) {
|
9421 | config[key] = value;
|
9422 | res = value;
|
9423 | redraw && this.flush();
|
9424 | } else {
|
9425 | res = config[key];
|
9426 | }
|
9427 | } else if (arguments.length === 0 || isEmpty(name)) {
|
9428 | res = state.orgConfig;
|
9429 | }
|
9430 | return res;
|
9431 | }
|
9432 | });
|
9433 |
|
9434 | ;
|
9435 | var api_color = ({
|
9436 | |
9437 |
|
9438 |
|
9439 |
|
9440 |
|
9441 |
|
9442 |
|
9443 |
|
9444 |
|
9445 |
|
9446 | color(id) {
|
9447 | return this.internal.color(id);
|
9448 | }
|
9449 | });
|
9450 |
|
9451 | ;
|
9452 |
|
9453 | const api_data_data = function(targetIds) {
|
9454 | const { targets } = this.internal.data;
|
9455 | if (!isUndefined(targetIds)) {
|
9456 | const ids = isArray(targetIds) ? targetIds : [targetIds];
|
9457 | return targets.filter((t) => ids.some((v) => v === t.id));
|
9458 | }
|
9459 | return targets;
|
9460 | };
|
9461 | extend(api_data_data, {
|
9462 | |
9463 |
|
9464 |
|
9465 |
|
9466 |
|
9467 |
|
9468 |
|
9469 |
|
9470 |
|
9471 |
|
9472 |
|
9473 |
|
9474 |
|
9475 |
|
9476 |
|
9477 |
|
9478 |
|
9479 |
|
9480 | shown: function(targetIds) {
|
9481 | return this.internal.filterTargetsToShow(this.data(targetIds));
|
9482 | },
|
9483 | |
9484 |
|
9485 |
|
9486 |
|
9487 |
|
9488 |
|
9489 |
|
9490 |
|
9491 |
|
9492 |
|
9493 |
|
9494 |
|
9495 |
|
9496 | values: function(targetIds, flat = true) {
|
9497 | let values = null;
|
9498 | if (targetIds) {
|
9499 | const targets = this.data(targetIds);
|
9500 | if (isArray(targets)) {
|
9501 | values = [];
|
9502 | targets.forEach((v) => {
|
9503 | const dataValue = v.values.map((d) => d.value);
|
9504 | flat ? values = values.concat(dataValue) : values.push(dataValue);
|
9505 | });
|
9506 | }
|
9507 | }
|
9508 | return values;
|
9509 | },
|
9510 | |
9511 |
|
9512 |
|
9513 |
|
9514 |
|
9515 |
|
9516 |
|
9517 |
|
9518 |
|
9519 |
|
9520 |
|
9521 |
|
9522 |
|
9523 |
|
9524 |
|
9525 |
|
9526 |
|
9527 |
|
9528 | names: function(names) {
|
9529 | const $$ = this.internal;
|
9530 | return $$.updateDataAttributes("names", names);
|
9531 | },
|
9532 | |
9533 |
|
9534 |
|
9535 |
|
9536 |
|
9537 |
|
9538 |
|
9539 |
|
9540 |
|
9541 |
|
9542 |
|
9543 |
|
9544 |
|
9545 |
|
9546 |
|
9547 |
|
9548 |
|
9549 |
|
9550 | colors: function(colors) {
|
9551 | return this.internal.updateDataAttributes("colors", colors);
|
9552 | },
|
9553 | |
9554 |
|
9555 |
|
9556 |
|
9557 |
|
9558 |
|
9559 |
|
9560 |
|
9561 |
|
9562 |
|
9563 |
|
9564 |
|
9565 |
|
9566 |
|
9567 |
|
9568 |
|
9569 |
|
9570 |
|
9571 |
|
9572 | axes: function(axes) {
|
9573 | return this.internal.updateDataAttributes("axes", axes);
|
9574 | },
|
9575 | |
9576 |
|
9577 |
|
9578 |
|
9579 |
|
9580 |
|
9581 |
|
9582 |
|
9583 |
|
9584 |
|
9585 |
|
9586 | min: function() {
|
9587 | return this.internal.getMinMaxData().min;
|
9588 | },
|
9589 | |
9590 |
|
9591 |
|
9592 |
|
9593 |
|
9594 |
|
9595 |
|
9596 |
|
9597 |
|
9598 |
|
9599 |
|
9600 | max: function() {
|
9601 | return this.internal.getMinMaxData().max;
|
9602 | }
|
9603 | });
|
9604 | var api_data = ({ data: api_data_data });
|
9605 |
|
9606 | ;
|
9607 |
|
9608 |
|
9609 |
|
9610 | const b64EncodeUnicode = (str) => {
|
9611 | var _a, _b;
|
9612 | return (_b = (_a = win).btoa) == null ? void 0 : _b.call(
|
9613 | _a,
|
9614 | encodeURIComponent(str).replace(
|
9615 | /%([0-9A-F]{2})/g,
|
9616 | (match, p) => String.fromCharCode(Number(`0x${p}`))
|
9617 | )
|
9618 | );
|
9619 | };
|
9620 | function nodeToSvgDataUrl(node, option, orgSize) {
|
9621 | const { width, height } = option || orgSize;
|
9622 | const serializer = new XMLSerializer();
|
9623 | const clone = node.cloneNode(true);
|
9624 | const cssText = getCssRules(toArray(browser_doc.styleSheets)).filter((r) => r.cssText).map((r) => r.cssText);
|
9625 | clone.setAttribute("xmlns", external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.xhtml);
|
9626 | clone.style.margin = "0";
|
9627 | clone.style.padding = "0";
|
9628 | if (option.preserveFontStyle) {
|
9629 | clone.querySelectorAll("text").forEach((t) => {
|
9630 | t.innerHTML = "";
|
9631 | });
|
9632 | }
|
9633 | const nodeXml = serializer.serializeToString(clone);
|
9634 | const style = browser_doc.createElement("style");
|
9635 | style.appendChild(browser_doc.createTextNode(cssText.join("\n")));
|
9636 | const styleXml = serializer.serializeToString(style);
|
9637 | const dataStr = `<svg xmlns="${external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg}" width="${width}" height="${height}"
|
9638 | viewBox="0 0 ${orgSize.width} ${orgSize.height}"
|
9639 | preserveAspectRatio="${(option == null ? void 0 : option.preserveAspectRatio) === false ? "none" : "xMinYMid meet"}">
|
9640 | <foreignObject width="100%" height="100%">
|
9641 | ${styleXml}
|
9642 | ${nodeXml.replace(/(url\()[^#]+/g, "$1")}
|
9643 | </foreignObject></svg>`;
|
9644 | return `data:image/svg+xml;base64,${b64EncodeUnicode(dataStr)}`;
|
9645 | }
|
9646 | function getCoords(elem, svgOffset) {
|
9647 | const { top, left } = svgOffset;
|
9648 | const { x, y } = elem.getBBox();
|
9649 | const { a, b, c, d, e, f } = elem.getScreenCTM();
|
9650 | const { width, height } = elem.getBoundingClientRect();
|
9651 | return {
|
9652 | x: a * x + c * y + e - left,
|
9653 | y: b * x + d * y + f - top + (height - Math.round(height / 4)),
|
9654 | width,
|
9655 | height
|
9656 | };
|
9657 | }
|
9658 | function getGlyph(svg) {
|
9659 | const { left, top } = svg.getBoundingClientRect();
|
9660 | const filterFn = (t) => t.textContent || t.childElementCount;
|
9661 | const glyph = [];
|
9662 | toArray(svg.querySelectorAll("text")).filter(filterFn).forEach((t) => {
|
9663 | const getStyleFn = (ts) => {
|
9664 | const { fill, fontFamily, fontSize, textAnchor, transform } = win.getComputedStyle(
|
9665 | ts
|
9666 | );
|
9667 | const { x, y, width, height } = getCoords(ts, { left, top });
|
9668 | return {
|
9669 | [ts.textContent]: {
|
9670 | x,
|
9671 | y,
|
9672 | width,
|
9673 | height,
|
9674 | fill,
|
9675 | fontFamily,
|
9676 | fontSize,
|
9677 | textAnchor,
|
9678 | transform
|
9679 | }
|
9680 | };
|
9681 | };
|
9682 | if (t.childElementCount > 1) {
|
9683 | const text = [];
|
9684 | toArray(t.querySelectorAll("tspan")).filter(filterFn).forEach((ts) => {
|
9685 | glyph.push(getStyleFn(ts));
|
9686 | });
|
9687 | return text;
|
9688 | } else {
|
9689 | glyph.push(getStyleFn(t));
|
9690 | }
|
9691 | });
|
9692 | return glyph;
|
9693 | }
|
9694 | function renderText(ctx, glyph) {
|
9695 | glyph.forEach((g) => {
|
9696 | Object.keys(g).forEach((key) => {
|
9697 | const { x, y, width, height, fill, fontFamily, fontSize, transform } = g[key];
|
9698 | ctx.save();
|
9699 | ctx.font = `${fontSize} ${fontFamily}`;
|
9700 | ctx.fillStyle = fill;
|
9701 | if (transform === "none") {
|
9702 | ctx.fillText(key, x, y);
|
9703 | } else {
|
9704 | const args = transform.replace(/(matrix|\(|\))/g, "").split(",");
|
9705 | if (args.splice(4).every((v) => +v === 0)) {
|
9706 | args.push(x + width - width / 4);
|
9707 | args.push(y - height + height / 3);
|
9708 | } else {
|
9709 | args.push(x);
|
9710 | args.push(y);
|
9711 | }
|
9712 | ctx.transform(...args);
|
9713 | ctx.fillText(key, 0, 0);
|
9714 | }
|
9715 | ctx.restore();
|
9716 | });
|
9717 | });
|
9718 | }
|
9719 | var api_export = ({
|
9720 | |
9721 |
|
9722 |
|
9723 |
|
9724 |
|
9725 |
|
9726 |
|
9727 |
|
9728 |
|
9729 |
|
9730 |
|
9731 |
|
9732 |
|
9733 |
|
9734 |
|
9735 |
|
9736 |
|
9737 |
|
9738 |
|
9739 |
|
9740 |
|
9741 |
|
9742 |
|
9743 |
|
9744 |
|
9745 |
|
9746 |
|
9747 |
|
9748 |
|
9749 |
|
9750 |
|
9751 |
|
9752 |
|
9753 |
|
9754 |
|
9755 |
|
9756 |
|
9757 |
|
9758 |
|
9759 |
|
9760 |
|
9761 |
|
9762 |
|
9763 |
|
9764 |
|
9765 |
|
9766 |
|
9767 |
|
9768 | export(option, callback) {
|
9769 | const $$ = this.internal;
|
9770 | const { state, $el: { chart, svg } } = $$;
|
9771 | const { width, height } = state.current;
|
9772 | const opt = mergeObj({
|
9773 | width,
|
9774 | height,
|
9775 | preserveAspectRatio: true,
|
9776 | preserveFontStyle: false,
|
9777 | mimeType: "image/png"
|
9778 | }, option);
|
9779 | const svgDataUrl = nodeToSvgDataUrl(chart.node(), opt, { width, height });
|
9780 | const glyph = opt.preserveFontStyle ? getGlyph(svg.node()) : [];
|
9781 | if (callback && isFunction(callback)) {
|
9782 | const img = new Image();
|
9783 | img.crossOrigin = "Anonymous";
|
9784 | img.onload = () => {
|
9785 | const canvas = browser_doc.createElement("canvas");
|
9786 | const ctx = canvas.getContext("2d");
|
9787 | canvas.width = opt.width || width;
|
9788 | canvas.height = opt.height || height;
|
9789 | ctx.drawImage(img, 0, 0);
|
9790 | if (glyph.length) {
|
9791 | renderText(ctx, glyph);
|
9792 | glyph.length = 0;
|
9793 | }
|
9794 | callback.bind(this)(canvas.toDataURL(opt.mimeType));
|
9795 | };
|
9796 | img.src = svgDataUrl;
|
9797 | }
|
9798 | return svgDataUrl;
|
9799 | }
|
9800 | });
|
9801 |
|
9802 | ;
|
9803 |
|
9804 |
|
9805 | var api_focus = ({
|
9806 | |
9807 |
|
9808 |
|
9809 |
|
9810 |
|
9811 |
|
9812 |
|
9813 |
|
9814 |
|
9815 |
|
9816 |
|
9817 |
|
9818 |
|
9819 |
|
9820 |
|
9821 |
|
9822 |
|
9823 | focus(targetIdsValue) {
|
9824 | const $$ = this.internal;
|
9825 | const { state } = $$;
|
9826 | const targetIds = $$.mapToTargetIds(targetIdsValue);
|
9827 | const candidates = $$.$el.svg.selectAll(
|
9828 | $$.selectorTargets(targetIds.filter($$.isTargetToShow, $$))
|
9829 | );
|
9830 | this.revert();
|
9831 | this.defocus();
|
9832 | candidates.classed($FOCUS.focused, true).classed($FOCUS.defocused, false);
|
9833 | if ($$.hasArcType() && !state.hasRadar) {
|
9834 | $$.expandArc(targetIds);
|
9835 | $$.hasType("gauge") && $$.markOverlapped(targetIdsValue, $$, `.${$GAUGE.gaugeValue}`);
|
9836 | }
|
9837 | $$.toggleFocusLegend(targetIds, true);
|
9838 | state.focusedTargetIds = targetIds;
|
9839 | state.defocusedTargetIds = state.defocusedTargetIds.filter((id) => targetIds.indexOf(id) < 0);
|
9840 | },
|
9841 | |
9842 |
|
9843 |
|
9844 |
|
9845 |
|
9846 |
|
9847 |
|
9848 |
|
9849 |
|
9850 |
|
9851 |
|
9852 |
|
9853 |
|
9854 |
|
9855 |
|
9856 |
|
9857 |
|
9858 | defocus(targetIdsValue) {
|
9859 | const $$ = this.internal;
|
9860 | const { state } = $$;
|
9861 | const targetIds = $$.mapToTargetIds(targetIdsValue);
|
9862 | const candidates = $$.$el.svg.selectAll(
|
9863 | $$.selectorTargets(targetIds.filter($$.isTargetToShow, $$))
|
9864 | );
|
9865 | candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, true);
|
9866 | if ($$.hasArcType(null, ["polar"])) {
|
9867 | $$.unexpandArc(targetIds);
|
9868 | $$.hasType("gauge") && $$.undoMarkOverlapped($$, `.${$GAUGE.gaugeValue}`);
|
9869 | }
|
9870 | $$.toggleFocusLegend(targetIds, false);
|
9871 | state.focusedTargetIds = state.focusedTargetIds.filter((id) => targetIds.indexOf(id) < 0);
|
9872 | state.defocusedTargetIds = targetIds;
|
9873 | },
|
9874 | |
9875 |
|
9876 |
|
9877 |
|
9878 |
|
9879 |
|
9880 |
|
9881 |
|
9882 |
|
9883 |
|
9884 |
|
9885 |
|
9886 |
|
9887 |
|
9888 |
|
9889 |
|
9890 |
|
9891 | revert(targetIdsValue) {
|
9892 | const $$ = this.internal;
|
9893 | const { config, state, $el } = $$;
|
9894 | const targetIds = $$.mapToTargetIds(targetIdsValue);
|
9895 | const candidates = $el.svg.selectAll($$.selectorTargets(targetIds));
|
9896 | candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, false);
|
9897 | $$.hasArcType(null, ["polar"]) && $$.unexpandArc(targetIds);
|
9898 | if (config.legend_show) {
|
9899 | $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
|
9900 | $el.legend.selectAll($$.selectorLegends(targetIds)).filter(function() {
|
9901 | return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused);
|
9902 | }).classed($FOCUS.legendItemFocused, false);
|
9903 | }
|
9904 | state.focusedTargetIds = [];
|
9905 | state.defocusedTargetIds = [];
|
9906 | }
|
9907 | });
|
9908 |
|
9909 | ;
|
9910 | const legend_legend = {
|
9911 | |
9912 |
|
9913 |
|
9914 |
|
9915 |
|
9916 |
|
9917 |
|
9918 |
|
9919 |
|
9920 |
|
9921 |
|
9922 |
|
9923 |
|
9924 |
|
9925 |
|
9926 |
|
9927 |
|
9928 |
|
9929 |
|
9930 |
|
9931 | show: function(targetIds) {
|
9932 | const $$ = this.internal;
|
9933 | $$.showLegend($$.mapToTargetIds(targetIds));
|
9934 | $$.updateAndRedraw({ withLegend: true });
|
9935 | },
|
9936 | |
9937 |
|
9938 |
|
9939 |
|
9940 |
|
9941 |
|
9942 |
|
9943 |
|
9944 |
|
9945 |
|
9946 |
|
9947 |
|
9948 |
|
9949 |
|
9950 |
|
9951 |
|
9952 |
|
9953 |
|
9954 |
|
9955 | hide: function(targetIds) {
|
9956 | const $$ = this.internal;
|
9957 | $$.hideLegend($$.mapToTargetIds(targetIds));
|
9958 | $$.updateAndRedraw({ withLegend: true });
|
9959 | }
|
9960 | };
|
9961 | var api_legend = ({ legend: legend_legend });
|
9962 |
|
9963 | ;
|
9964 |
|
9965 |
|
9966 |
|
9967 | var api_load = ({
|
9968 | |
9969 |
|
9970 |
|
9971 |
|
9972 |
|
9973 |
|
9974 |
|
9975 |
|
9976 |
|
9977 |
|
9978 |
|
9979 |
|
9980 |
|
9981 |
|
9982 |
|
9983 |
|
9984 |
|
9985 |
|
9986 |
|
9987 |
|
9988 |
|
9989 |
|
9990 |
|
9991 |
|
9992 |
|
9993 |
|
9994 |
|
9995 |
|
9996 |
|
9997 |
|
9998 |
|
9999 |
|
10000 |
|
10001 |
|
10002 |
|
10003 |
|
10004 |
|
10005 |
|
10006 |
|
10007 |
|
10008 |
|
10009 |
|
10010 |
|
10011 |
|
10012 |
|
10013 |
|
10014 |
|
10015 |
|
10016 |
|
10017 |
|
10018 |
|
10019 |
|
10020 |
|
10021 |
|
10022 |
|
10023 |
|
10024 |
|
10025 |
|
10026 |
|
10027 |
|
10028 |
|
10029 |
|
10030 |
|
10031 |
|
10032 |
|
10033 |
|
10034 |
|
10035 |
|
10036 |
|
10037 |
|
10038 |
|
10039 |
|
10040 |
|
10041 |
|
10042 |
|
10043 |
|
10044 |
|
10045 |
|
10046 |
|
10047 |
|
10048 |
|
10049 |
|
10050 |
|
10051 |
|
10052 |
|
10053 |
|
10054 |
|
10055 |
|
10056 |
|
10057 |
|
10058 |
|
10059 |
|
10060 |
|
10061 |
|
10062 |
|
10063 |
|
10064 |
|
10065 |
|
10066 |
|
10067 |
|
10068 |
|
10069 |
|
10070 |
|
10071 |
|
10072 |
|
10073 |
|
10074 |
|
10075 |
|
10076 |
|
10077 |
|
10078 |
|
10079 |
|
10080 |
|
10081 |
|
10082 |
|
10083 |
|
10084 |
|
10085 |
|
10086 |
|
10087 |
|
10088 |
|
10089 |
|
10090 |
|
10091 |
|
10092 |
|
10093 |
|
10094 |
|
10095 |
|
10096 |
|
10097 |
|
10098 |
|
10099 |
|
10100 |
|
10101 |
|
10102 |
|
10103 |
|
10104 | load(args) {
|
10105 | const $$ = this.internal;
|
10106 | const { config } = $$;
|
10107 | args.xs && $$.addXs(args.xs);
|
10108 | "names" in args && this.data.names(args.names);
|
10109 | "classes" in args && Object.keys(args.classes).forEach((id) => {
|
10110 | config.data_classes[id] = args.classes[id];
|
10111 | });
|
10112 | if ("categories" in args && $$.axis.isCategorized()) {
|
10113 | config.axis_x_categories = args.categories;
|
10114 | }
|
10115 | "axes" in args && Object.keys(args.axes).forEach((id) => {
|
10116 | config.data_axes[id] = args.axes[id];
|
10117 | });
|
10118 | "colors" in args && Object.keys(args.colors).forEach((id) => {
|
10119 | config.data_colors[id] = args.colors[id];
|
10120 | });
|
10121 | if ("unload" in args && args.unload !== false) {
|
10122 | $$.unload($$.mapToTargetIds(args.unload === true ? null : args.unload), () => {
|
10123 | requestIdleCallback(() => $$.loadFromArgs(args));
|
10124 | });
|
10125 | } else {
|
10126 | $$.loadFromArgs(args);
|
10127 | }
|
10128 | },
|
10129 | |
10130 |
|
10131 |
|
10132 |
|
10133 |
|
10134 |
|
10135 |
|
10136 |
|
10137 |
|
10138 |
|
10139 |
|
10140 |
|
10141 |
|
10142 |
|
10143 |
|
10144 |
|
10145 |
|
10146 |
|
10147 |
|
10148 |
|
10149 |
|
10150 |
|
10151 |
|
10152 |
|
10153 |
|
10154 | unload(argsValue) {
|
10155 | const $$ = this.internal;
|
10156 | let args = argsValue || {};
|
10157 | isEmpty(args) && this.tooltip.hide();
|
10158 | if (isArray(args)) {
|
10159 | args = { ids: args };
|
10160 | } else if (isString(args)) {
|
10161 | args = { ids: [args] };
|
10162 | }
|
10163 | const ids = $$.mapToTargetIds(args.ids);
|
10164 | $$.unload(ids, () => {
|
10165 | $$.redraw({
|
10166 | withUpdateOrgXDomain: true,
|
10167 | withUpdateXDomain: true,
|
10168 | withLegend: true
|
10169 | });
|
10170 | $$.cache.remove(ids);
|
10171 | callDone.call($$, args.done, args.resizeAfter);
|
10172 | });
|
10173 | }
|
10174 | });
|
10175 |
|
10176 | ;
|
10177 |
|
10178 | function showHide(show, targetIdsValue, options) {
|
10179 | const $$ = this.internal;
|
10180 | const targetIds = $$.mapToTargetIds(targetIdsValue);
|
10181 | const hiddenIds = $$.state.hiddenTargetIds.map((v) => targetIds.indexOf(v) > -1 && v).filter(Boolean);
|
10182 | $$.state.toggling = true;
|
10183 | $$[`${show ? "remove" : "add"}HiddenTargetIds`](targetIds);
|
10184 | const targets = $$.$el.svg.selectAll($$.selectorTargets(targetIds));
|
10185 | const opacity = show ? null : "0";
|
10186 | if (show && hiddenIds.length) {
|
10187 | targets.style("display", null);
|
10188 | callFn($$.config.data_onshown, this, hiddenIds);
|
10189 | }
|
10190 | $$.$T(targets).style("opacity", opacity, "important").call(endall, () => {
|
10191 | var _a;
|
10192 | if (!show && hiddenIds.length === 0) {
|
10193 | targets.style("display", "none");
|
10194 | callFn((_a = $$.config) == null ? void 0 : _a.data_onhidden, this, targetIds);
|
10195 | }
|
10196 | targets.style("opacity", opacity);
|
10197 | });
|
10198 | options.withLegend && $$[`${show ? "show" : "hide"}Legend`](targetIds);
|
10199 | $$.redraw({
|
10200 | withUpdateOrgXDomain: true,
|
10201 | withUpdateXDomain: true,
|
10202 | withLegend: true
|
10203 | });
|
10204 | $$.state.toggling = false;
|
10205 | }
|
10206 | var show = ({
|
10207 | |
10208 |
|
10209 |
|
10210 |
|
10211 |
|
10212 |
|
10213 |
|
10214 |
|
10215 |
|
10216 |
|
10217 |
|
10218 |
|
10219 |
|
10220 |
|
10221 |
|
10222 |
|
10223 |
|
10224 |
|
10225 |
|
10226 | show(targetIdsValue, options = {}) {
|
10227 | showHide.call(this, true, targetIdsValue, options);
|
10228 | },
|
10229 | |
10230 |
|
10231 |
|
10232 |
|
10233 |
|
10234 |
|
10235 |
|
10236 |
|
10237 |
|
10238 |
|
10239 |
|
10240 |
|
10241 |
|
10242 |
|
10243 |
|
10244 |
|
10245 |
|
10246 |
|
10247 |
|
10248 | hide(targetIdsValue, options = {}) {
|
10249 | showHide.call(this, false, targetIdsValue, options);
|
10250 | },
|
10251 | |
10252 |
|
10253 |
|
10254 |
|
10255 |
|
10256 |
|
10257 |
|
10258 |
|
10259 |
|
10260 |
|
10261 |
|
10262 |
|
10263 |
|
10264 |
|
10265 |
|
10266 |
|
10267 |
|
10268 |
|
10269 |
|
10270 | toggle(targetIds, options = {}) {
|
10271 | const $$ = this.internal;
|
10272 | const targets = { show: [], hide: [] };
|
10273 | $$.mapToTargetIds(targetIds).forEach((id) => targets[$$.isTargetToShow(id) ? "hide" : "show"].push(id));
|
10274 | targets.show.length && this.show(targets.show, options);
|
10275 | targets.hide.length && setTimeout(() => this.hide(targets.hide, options), 0);
|
10276 | }
|
10277 | });
|
10278 |
|
10279 | ;
|
10280 |
|
10281 |
|
10282 | const tooltip_tooltip = {
|
10283 | |
10284 |
|
10285 |
|
10286 |
|
10287 |
|
10288 |
|
10289 |
|
10290 |
|
10291 |
|
10292 |
|
10293 |
|
10294 |
|
10295 |
|
10296 |
|
10297 |
|
10298 |
|
10299 |
|
10300 |
|
10301 |
|
10302 |
|
10303 |
|
10304 |
|
10305 |
|
10306 |
|
10307 |
|
10308 |
|
10309 |
|
10310 |
|
10311 |
|
10312 |
|
10313 |
|
10314 |
|
10315 |
|
10316 |
|
10317 |
|
10318 |
|
10319 |
|
10320 |
|
10321 |
|
10322 |
|
10323 |
|
10324 |
|
10325 |
|
10326 |
|
10327 |
|
10328 |
|
10329 |
|
10330 |
|
10331 |
|
10332 |
|
10333 |
|
10334 |
|
10335 |
|
10336 |
|
10337 |
|
10338 |
|
10339 |
|
10340 |
|
10341 |
|
10342 |
|
10343 |
|
10344 | show: function(args) {
|
10345 | var _a, _b, _c;
|
10346 | const $$ = this.internal;
|
10347 | const { $el, config, state: { eventReceiver, hasFunnel, hasTreemap, inputType } } = $$;
|
10348 | let index;
|
10349 | let mouse;
|
10350 | if (args.mouse) {
|
10351 | mouse = args.mouse;
|
10352 | }
|
10353 | if (args.data) {
|
10354 | const { data } = args;
|
10355 | const y = (_a = $$.getYScaleById(data.id)) == null ? void 0 : _a(data.value);
|
10356 | if ((hasFunnel || hasTreemap) && data.id) {
|
10357 | const selector = $$.selectorTarget(data.id, void 0, `.${$SHAPE.shape}`);
|
10358 | eventReceiver.rect = $el.main.select(selector);
|
10359 | } else if ($$.isMultipleX()) {
|
10360 | mouse = [$$.xx(data), y];
|
10361 | } else {
|
10362 | if (!config.tooltip_grouped) {
|
10363 | mouse = [0, y];
|
10364 | }
|
10365 | index = (_c = data.index) != null ? _c : $$.hasArcType() && data.id ? (_b = $$.getArcElementByIdOrIndex(data.id)) == null ? void 0 : _b.datum().index : $$.getIndexByX(data.x);
|
10366 | }
|
10367 | } else if (isDefined(args.x)) {
|
10368 | index = $$.getIndexByX(args.x);
|
10369 | } else if (isDefined(args.index)) {
|
10370 | index = args.index;
|
10371 | }
|
10372 | (inputType === "mouse" ? ["mouseover", "mousemove"] : ["touchstart"]).forEach((eventName) => {
|
10373 | $$.dispatchEvent(eventName, index, mouse);
|
10374 | });
|
10375 | },
|
10376 | |
10377 |
|
10378 |
|
10379 |
|
10380 |
|
10381 |
|
10382 | hide: function() {
|
10383 | var _a, _b, _c;
|
10384 | const $$ = this.internal;
|
10385 | const { state: { inputType }, $el: { tooltip: tooltip2 } } = $$;
|
10386 | const data = tooltip2 == null ? void 0 : tooltip2.datum();
|
10387 | if (data) {
|
10388 | const { index } = JSON.parse(data.current)[0];
|
10389 | (inputType === "mouse" ? ["mouseout"] : ["touchend"]).forEach((eventName) => {
|
10390 | $$.dispatchEvent(eventName, index);
|
10391 | });
|
10392 | }
|
10393 | inputType === "touch" && $$.callOverOutForTouch();
|
10394 | $$.hideTooltip(true);
|
10395 | (_a = $$.hideGridFocus) == null ? void 0 : _a.call($$);
|
10396 | (_b = $$.unexpandCircles) == null ? void 0 : _b.call($$);
|
10397 | (_c = $$.expandBarTypeShapes) == null ? void 0 : _c.call($$, false);
|
10398 | }
|
10399 | };
|
10400 | var api_tooltip = ({ tooltip: tooltip_tooltip });
|
10401 |
|
10402 | ;
|
10403 | var Chart_defProp = Object.defineProperty;
|
10404 | var Chart_defNormalProp = (obj, key, value) => key in obj ? Chart_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
10405 | var Chart_publicField = (obj, key, value) => Chart_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
10406 |
|
10407 |
|
10408 |
|
10409 |
|
10410 |
|
10411 |
|
10412 |
|
10413 |
|
10414 |
|
10415 |
|
10416 |
|
10417 |
|
10418 | class Chart {
|
10419 | constructor(options) {
|
10420 | Chart_publicField(this, "plugins", []);
|
10421 | Chart_publicField(this, "internal");
|
10422 | const $$ = new ChartInternal(this);
|
10423 | this.internal = $$;
|
10424 | (function bindThis(fn, target, argThis) {
|
10425 | Object.keys(fn).forEach((key) => {
|
10426 | const isFunc = isFunction(fn[key]);
|
10427 | const isChild = target !== argThis;
|
10428 | const isNotNil = notEmpty(fn[key]);
|
10429 | const hasChild = isNotNil && Object.keys(fn[key]).length > 0;
|
10430 | if (isFunc && (!isChild && hasChild || isChild)) {
|
10431 | target[key] = fn[key].bind(argThis);
|
10432 | } else if (isNotNil && !isFunc) {
|
10433 | target[key] = {};
|
10434 | } else {
|
10435 | target[key] = fn[key];
|
10436 | }
|
10437 | hasChild && bindThis(fn[key], target[key], argThis);
|
10438 | });
|
10439 | })(Chart.prototype, this, this);
|
10440 | loadConfig.call($$, options);
|
10441 | $$.beforeInit();
|
10442 | $$.init();
|
10443 | }
|
10444 | }
|
10445 | extend(Chart.prototype, [
|
10446 | chart,
|
10447 | api_color,
|
10448 | api_data,
|
10449 | api_export,
|
10450 | api_focus,
|
10451 | api_legend,
|
10452 | api_load,
|
10453 | show,
|
10454 | api_tooltip
|
10455 | ]);
|
10456 |
|
10457 | ;
|
10458 |
|
10459 |
|
10460 |
|
10461 | function setSelection(isSelection = false, ids, indices, resetOther) {
|
10462 | const $$ = this;
|
10463 | const { config, $el: { main } } = $$;
|
10464 | const selectionGrouped = config.data_selection_grouped;
|
10465 | const isSelectable = config.data_selection_isselectable.bind($$.api);
|
10466 | if (!config.data_selection_enabled) {
|
10467 | return;
|
10468 | }
|
10469 | main.selectAll(`.${$SHAPE.shapes}`).selectAll(`.${$SHAPE.shape}`).each(function(d) {
|
10470 | const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
10471 | const { id, index } = d.data ? d.data : d;
|
10472 | const toggle = $$.getToggle(this, d).bind($$);
|
10473 | const isTargetId = selectionGrouped || !ids || ids.indexOf(id) >= 0;
|
10474 | const isTargetIndex = !indices || indices.indexOf(index) >= 0;
|
10475 | const isSelected = shape.classed($SELECT.SELECTED);
|
10476 | if (shape.classed($LINE.line) || shape.classed($AREA.area)) {
|
10477 | return;
|
10478 | }
|
10479 | if (isSelection) {
|
10480 | if (isTargetId && isTargetIndex && isSelectable(d) && !isSelected) {
|
10481 | toggle(true, shape.classed($SELECT.SELECTED, true), d, index);
|
10482 | } else if (isDefined(resetOther) && resetOther && isSelected) {
|
10483 | toggle(false, shape.classed($SELECT.SELECTED, false), d, index);
|
10484 | }
|
10485 | } else {
|
10486 | if (isTargetId && isTargetIndex && isSelectable(d) && isSelected) {
|
10487 | toggle(false, shape.classed($SELECT.SELECTED, false), d, index);
|
10488 | }
|
10489 | }
|
10490 | });
|
10491 | }
|
10492 | var selection = ({
|
10493 | |
10494 |
|
10495 |
|
10496 |
|
10497 |
|
10498 |
|
10499 |
|
10500 |
|
10501 |
|
10502 |
|
10503 |
|
10504 |
|
10505 |
|
10506 |
|
10507 |
|
10508 |
|
10509 | selected(targetId) {
|
10510 | const $$ = this.internal;
|
10511 | const dataPoint = [];
|
10512 | $$.$el.main.selectAll(`.${$SHAPE.shapes + $$.getTargetSelectorSuffix(targetId)}`).selectAll(`.${$SHAPE.shape}`).filter(function() {
|
10513 | return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($SELECT.SELECTED);
|
10514 | }).each((d) => dataPoint.push(d));
|
10515 | return dataPoint;
|
10516 | },
|
10517 | |
10518 |
|
10519 |
|
10520 |
|
10521 |
|
10522 |
|
10523 |
|
10524 |
|
10525 |
|
10526 |
|
10527 |
|
10528 |
|
10529 |
|
10530 |
|
10531 |
|
10532 |
|
10533 |
|
10534 |
|
10535 |
|
10536 |
|
10537 |
|
10538 |
|
10539 |
|
10540 |
|
10541 | select(ids, indices, resetOther) {
|
10542 | const $$ = this.internal;
|
10543 | setSelection.bind($$)(true, ids, indices, resetOther);
|
10544 | },
|
10545 | |
10546 |
|
10547 |
|
10548 |
|
10549 |
|
10550 |
|
10551 |
|
10552 |
|
10553 |
|
10554 |
|
10555 |
|
10556 |
|
10557 |
|
10558 |
|
10559 |
|
10560 |
|
10561 |
|
10562 | unselect(ids, indices) {
|
10563 | const $$ = this.internal;
|
10564 | setSelection.bind($$)(false, ids, indices);
|
10565 | }
|
10566 | });
|
10567 |
|
10568 | ;
|
10569 |
|
10570 |
|
10571 | const subchart = function(domainValue) {
|
10572 | var _a;
|
10573 | const $$ = this.internal;
|
10574 | const { axis, brush, config, scale: { x, subX }, state } = $$;
|
10575 | let domain;
|
10576 | if (config.subchart_show) {
|
10577 | domain = domainValue;
|
10578 | if (Array.isArray(domain)) {
|
10579 | if (axis.isTimeSeries()) {
|
10580 | domain = domain.map((x2) => parseDate.bind($$)(x2));
|
10581 | }
|
10582 | const isWithinRange = $$.withinRange(
|
10583 | domain,
|
10584 | $$.getZoomDomain("subX", true),
|
10585 | $$.getZoomDomain("subX")
|
10586 | );
|
10587 | if (isWithinRange) {
|
10588 | state.domain = domain;
|
10589 | brush.move(
|
10590 | brush.getSelection(),
|
10591 | domain.map(subX)
|
10592 | );
|
10593 | }
|
10594 | } else {
|
10595 | domain = (_a = state.domain) != null ? _a : x.orgDomain();
|
10596 | }
|
10597 | }
|
10598 | return domain;
|
10599 | };
|
10600 | extend(subchart, {
|
10601 | |
10602 |
|
10603 |
|
10604 |
|
10605 |
|
10606 |
|
10607 |
|
10608 |
|
10609 |
|
10610 |
|
10611 |
|
10612 |
|
10613 |
|
10614 |
|
10615 |
|
10616 |
|
10617 |
|
10618 |
|
10619 |
|
10620 |
|
10621 |
|
10622 |
|
10623 |
|
10624 | show() {
|
10625 | var _a, _b;
|
10626 | const $$ = this.internal;
|
10627 | const { $el: { subchart: subchart2 }, config } = $$;
|
10628 | const show = config.subchart_show;
|
10629 | if (!show) {
|
10630 | $$.unbindZoomEvent();
|
10631 | config.subchart_show = !show;
|
10632 | !subchart2.main && $$.initSubchart();
|
10633 | let $target = subchart2.main.selectAll(`.${$COMMON.target}`);
|
10634 | if ($$.data.targets.length !== $target.size()) {
|
10635 | $$.updateSizes();
|
10636 | $$.updateTargetsForSubchart($$.data.targets);
|
10637 | $target = (_a = subchart2.main) == null ? void 0 : _a.selectAll(`.${$COMMON.target}`);
|
10638 | }
|
10639 | $target == null ? void 0 : $target.style("opacity", null);
|
10640 | (_b = subchart2.main) == null ? void 0 : _b.style("display", null);
|
10641 | this.resize();
|
10642 | }
|
10643 | },
|
10644 | |
10645 |
|
10646 |
|
10647 |
|
10648 |
|
10649 |
|
10650 |
|
10651 |
|
10652 |
|
10653 | hide() {
|
10654 | const $$ = this.internal;
|
10655 | const { $el: { subchart: { main } }, config } = $$;
|
10656 | if (config.subchart_show && (main == null ? void 0 : main.style("display")) !== "none") {
|
10657 | config.subchart_show = false;
|
10658 | main.style("display", "none");
|
10659 | this.resize();
|
10660 | }
|
10661 | },
|
10662 | |
10663 |
|
10664 |
|
10665 |
|
10666 |
|
10667 |
|
10668 |
|
10669 |
|
10670 |
|
10671 |
|
10672 |
|
10673 | toggle() {
|
10674 | const $$ = this.internal;
|
10675 | const { config } = $$;
|
10676 | this.subchart[config.subchart_show ? "hide" : "show"]();
|
10677 | },
|
10678 | |
10679 |
|
10680 |
|
10681 |
|
10682 |
|
10683 |
|
10684 |
|
10685 |
|
10686 |
|
10687 | reset() {
|
10688 | const $$ = this.internal;
|
10689 | const { brush } = $$;
|
10690 | brush.clear(brush.getSelection());
|
10691 | }
|
10692 | });
|
10693 | var api_subchart = ({
|
10694 | subchart
|
10695 | });
|
10696 |
|
10697 |
|
10698 | var external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_ = __webpack_require__(10);
|
10699 | ;
|
10700 |
|
10701 |
|
10702 | const zoom = function(domainValue) {
|
10703 | var _a;
|
10704 | const $$ = this.internal;
|
10705 | const { axis, config, org, scale, state } = $$;
|
10706 | const isCategorized = axis.isCategorized();
|
10707 | let domain;
|
10708 | if (config.zoom_enabled) {
|
10709 | domain = domainValue;
|
10710 | if (Array.isArray(domain)) {
|
10711 | if (axis.isTimeSeries()) {
|
10712 | domain = domain.map((x) => parseDate.bind($$)(x));
|
10713 | }
|
10714 | const isWithinRange = $$.withinRange(
|
10715 | domain,
|
10716 | $$.getZoomDomain("zoom", true),
|
10717 | $$.getZoomDomain("zoom")
|
10718 | );
|
10719 | if (isWithinRange) {
|
10720 | state.domain = domain;
|
10721 | domain = $$.getZoomDomainValue(domain);
|
10722 | $$.api.tooltip.hide();
|
10723 | if (config.subchart_show) {
|
10724 | const x = scale.zoom || scale.x;
|
10725 | $$.brush.getSelection().call($$.brush.move, domain.map(x));
|
10726 | } else {
|
10727 | const x = isCategorized ? scale.x.orgScale() : org.xScale || scale.x;
|
10728 | $$.updateCurrentZoomTransform(x, domain);
|
10729 | }
|
10730 | $$.setZoomResetButton();
|
10731 | }
|
10732 | } else {
|
10733 | domain = $$.zoom.getDomain();
|
10734 | }
|
10735 | }
|
10736 | return (_a = state.domain) != null ? _a : domain;
|
10737 | };
|
10738 | extend(zoom, {
|
10739 | |
10740 |
|
10741 |
|
10742 |
|
10743 |
|
10744 |
|
10745 |
|
10746 |
|
10747 |
|
10748 |
|
10749 |
|
10750 |
|
10751 |
|
10752 |
|
10753 |
|
10754 |
|
10755 |
|
10756 |
|
10757 | enable(enabled) {
|
10758 | const $$ = this.internal;
|
10759 | const { config } = $$;
|
10760 | if (/^(drag|wheel)$/.test(enabled)) {
|
10761 | config.zoom_type = enabled;
|
10762 | }
|
10763 | config.zoom_enabled = !!enabled;
|
10764 | if (!$$.zoom) {
|
10765 | $$.initZoom();
|
10766 | $$.bindZoomEvent();
|
10767 | } else if (enabled === false) {
|
10768 | $$.bindZoomEvent(false);
|
10769 | }
|
10770 | $$.updateAndRedraw();
|
10771 | },
|
10772 | |
10773 |
|
10774 |
|
10775 |
|
10776 |
|
10777 |
|
10778 |
|
10779 |
|
10780 |
|
10781 |
|
10782 |
|
10783 | max(max) {
|
10784 | const $$ = this.internal;
|
10785 | const { config, org: { xDomain } } = $$;
|
10786 | if (max === 0 || max) {
|
10787 | config.zoom_x_max = getMinMax("max", [xDomain[1], max]);
|
10788 | }
|
10789 | return config.zoom_x_max;
|
10790 | },
|
10791 | |
10792 |
|
10793 |
|
10794 |
|
10795 |
|
10796 |
|
10797 |
|
10798 |
|
10799 |
|
10800 |
|
10801 |
|
10802 | min(min) {
|
10803 | const $$ = this.internal;
|
10804 | const { config, org: { xDomain } } = $$;
|
10805 | if (min === 0 || min) {
|
10806 | config.zoom_x_min = getMinMax("min", [xDomain[0], min]);
|
10807 | }
|
10808 | return config.zoom_x_min;
|
10809 | },
|
10810 | |
10811 |
|
10812 |
|
10813 |
|
10814 |
|
10815 |
|
10816 |
|
10817 |
|
10818 |
|
10819 |
|
10820 |
|
10821 |
|
10822 |
|
10823 |
|
10824 |
|
10825 |
|
10826 |
|
10827 | range(range) {
|
10828 | const zoom2 = this.zoom;
|
10829 | if (isObject(range)) {
|
10830 | const { min, max } = range;
|
10831 | isDefined(min) && zoom2.min(min);
|
10832 | isDefined(max) && zoom2.max(max);
|
10833 | }
|
10834 | return {
|
10835 | min: zoom2.min(),
|
10836 | max: zoom2.max()
|
10837 | };
|
10838 | }
|
10839 | });
|
10840 | var api_zoom = ({
|
10841 | zoom,
|
10842 | |
10843 |
|
10844 |
|
10845 |
|
10846 |
|
10847 |
|
10848 |
|
10849 |
|
10850 |
|
10851 | unzoom() {
|
10852 | const $$ = this.internal;
|
10853 | const { config, $el: { eventRect, zoomResetBtn }, scale: { zoom: zoom2 }, state } = $$;
|
10854 | if (zoom2) {
|
10855 | config.subchart_show ? $$.brush.getSelection().call($$.brush.move, null) : $$.zoom.updateTransformScale(external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
|
10856 | $$.updateZoom(true);
|
10857 | zoomResetBtn == null ? void 0 : zoomResetBtn.style("display", "none");
|
10858 | if ((0,external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomTransform)(eventRect.node()) !== external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity) {
|
10859 | $$.zoom.transform(eventRect, external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
|
10860 | }
|
10861 | state.domain = void 0;
|
10862 | }
|
10863 | }
|
10864 | });
|
10865 |
|
10866 | ;
|
10867 |
|
10868 |
|
10869 |
|
10870 |
|
10871 | var interactions_subchart = ({
|
10872 | |
10873 |
|
10874 |
|
10875 |
|
10876 | initBrush() {
|
10877 | const $$ = this;
|
10878 | const { config, scale, $el: { subchart }, state } = $$;
|
10879 | const isRotated = config.axis_rotated;
|
10880 | const height = config.subchart_size_height;
|
10881 | let lastDomain;
|
10882 | let lastSelection;
|
10883 | let timeout;
|
10884 | $$.brush = (isRotated ? (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushY)() : (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushX)()).handleSize(5);
|
10885 | $$.brush.on("start brush end", (event) => {
|
10886 | const { selection, sourceEvent, target, type } = event;
|
10887 | if (type === "start") {
|
10888 | $$.state.inputType === "touch" && $$.hideTooltip();
|
10889 | lastSelection = sourceEvent ? selection : null;
|
10890 | }
|
10891 | if (/(start|brush)/.test(type)) {
|
10892 | type === "brush" && sourceEvent && state.domain && (lastSelection == null ? void 0 : lastSelection.forEach((v, i) => {
|
10893 | if (v !== selection[i]) {
|
10894 | state.domain[i] = scale.x.orgDomain()[i];
|
10895 | }
|
10896 | }));
|
10897 | $$.redrawForBrush(type !== "start");
|
10898 | }
|
10899 | if (type === "end") {
|
10900 | lastDomain = scale.x.orgDomain();
|
10901 | }
|
10902 | if (target == null ? void 0 : target.handle) {
|
10903 | if (selection === null) {
|
10904 | $$.brush.handle.attr("display", "none");
|
10905 | } else {
|
10906 | $$.brush.handle.attr("display", null).attr("transform", (d, i) => {
|
10907 | const pos = [selection[i], height / 2];
|
10908 | return `translate(${isRotated ? pos.reverse() : pos})`;
|
10909 | });
|
10910 | }
|
10911 | }
|
10912 | });
|
10913 | $$.brush.updateResize = function() {
|
10914 | timeout && clearTimeout(timeout);
|
10915 | timeout = setTimeout(() => {
|
10916 | const selection = this.getSelection();
|
10917 | lastDomain && (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection.node()) && this.move(selection, lastDomain.map(scale.subX.orgScale()));
|
10918 | }, 0);
|
10919 | };
|
10920 | $$.brush.update = function() {
|
10921 | var _a;
|
10922 | const extent = this.extent()();
|
10923 | if (extent[1].filter((v) => isNaN(v)).length === 0) {
|
10924 | (_a = subchart.main) == null ? void 0 : _a.select(`.${classes.brush}`).call(this);
|
10925 | }
|
10926 | return this;
|
10927 | };
|
10928 | $$.brush.scale = function(scale2) {
|
10929 | const h = config.subchart_size_height;
|
10930 | let extent = $$.axis.getExtent();
|
10931 | if (!extent && scale2.range) {
|
10932 | extent = [[0, 0], [scale2.range()[1], h]];
|
10933 | } else if (isArray(extent)) {
|
10934 | extent = extent.map((v, i) => [v, i > 0 ? h : i]);
|
10935 | }
|
10936 | isRotated && extent[1].reverse();
|
10937 | this.extent(extent);
|
10938 | this.update();
|
10939 | };
|
10940 | $$.brush.getSelection = () => (
|
10941 |
|
10942 | subchart.main ? subchart.main.select(`.${classes.brush}`) : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)([])
|
10943 | );
|
10944 | },
|
10945 | |
10946 |
|
10947 |
|
10948 |
|
10949 | initSubchart() {
|
10950 | const $$ = this;
|
10951 | const { config, state: { clip, hasAxis }, $el: { defs, svg, subchart, axis } } = $$;
|
10952 | if (!hasAxis) {
|
10953 | return;
|
10954 | }
|
10955 | const visibility = config.subchart_show ? null : "hidden";
|
10956 | const clipId = `${clip.id}-subchart`;
|
10957 | const clipPath = $$.getClipPath(clipId);
|
10958 | clip.idSubchart = clipId;
|
10959 | $$.appendClip(defs, clipId);
|
10960 | $$.initBrush();
|
10961 | subchart.main = svg.append("g").classed(classes.subchart, true).attr("transform", $$.getTranslate("context"));
|
10962 | const { main } = subchart;
|
10963 | main.style("visibility", visibility);
|
10964 | main.append("g").attr("clip-path", clipPath).attr("class", classes.chart);
|
10965 | ["bar", "line", "bubble", "candlestick", "scatter"].forEach((v) => {
|
10966 | const type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
|
10967 | if ($$.hasType(v) || $$.hasTypeOf(type)) {
|
10968 | const chart = main.select(`.${classes.chart}`);
|
10969 | const chartClassName = classes[`chart${type}s`];
|
10970 | if (chart.select(`.${chartClassName}`).empty()) {
|
10971 | chart.append("g").attr("class", chartClassName);
|
10972 | }
|
10973 | }
|
10974 | });
|
10975 | const brush = main.append("g").attr("clip-path", clipPath).attr("class", classes.brush).call($$.brush);
|
10976 | config.subchart_showHandle && $$.addBrushHandle(brush);
|
10977 | axis.subX = main.append("g").attr("class", classes.axisX).attr("transform", $$.getTranslate("subX")).attr("clip-path", config.axis_rotated ? "" : clip.pathXAxis).style("visibility", config.subchart_axis_x_show ? visibility : "hidden");
|
10978 | },
|
10979 | |
10980 |
|
10981 |
|
10982 |
|
10983 |
|
10984 |
|
10985 | addBrushHandle(brush) {
|
10986 | const $$ = this;
|
10987 | const { config } = $$;
|
10988 | const isRotated = config.axis_rotated;
|
10989 | const initRange = config.subchart_init_range;
|
10990 | const customHandleClass = "handle--custom";
|
10991 | const path = isRotated ? [
|
10992 | "M8.5 0 a6 6 0 0 0 -6 -6.5 H-2.5 a 6 6 0 0 0 -6 6.5 z m-5 -2 H-3.5 m7 -2 H-3.5z",
|
10993 | "M8.5 0 a6 -6 0 0 1 -6 6.5 H-2.5 a 6 -6 0 0 1 -6 -6.5z m-5 2 H-3.5 m7 2 H-3.5z"
|
10994 | ] : [
|
10995 | "M0 -8.5 A6 6 0 0 0 -6.5 -3.5 V2.5 A6 6 0 0 0 0 8.5 Z M-2 -3.5 V3.5 M-4 -3.5 V3.5z",
|
10996 | "M0 -8.5 A6 6 0 0 1 6.5 -3.5 V2.5 A6 6 0 0 1 0 8.5 Z M2 -3.5 V3.5 M4 -3.5 V3.5z"
|
10997 | ];
|
10998 | $$.brush.handle = brush.selectAll(`.${customHandleClass}`).data(isRotated ? [{ type: "n" }, { type: "s" }] : [{ type: "w" }, { type: "e" }]).enter().append("path").attr("class", customHandleClass).attr("cursor", `${isRotated ? "ns" : "ew"}-resize`).attr("d", (d) => path[+/[se]/.test(d.type)]).attr("display", initRange ? null : "none");
|
10999 | },
|
11000 | |
11001 |
|
11002 |
|
11003 |
|
11004 |
|
11005 | updateTargetsForSubchart(targets) {
|
11006 | const $$ = this;
|
11007 | const { config, state, $el: { subchart: { main } } } = $$;
|
11008 | if (config.subchart_show) {
|
11009 | ["bar", "line", "bubble", "candlestick", "scatter"].filter((v) => $$.hasType(v) || $$.hasTypeOf(capitalize(v))).forEach((v) => {
|
11010 | const isPointType = /^(bubble|scatter)$/.test(v);
|
11011 | const name = capitalize(isPointType ? "circle" : v);
|
11012 | const chartClass = $$.getChartClass(name, true);
|
11013 | const shapeClass = $$.getClass(isPointType ? "circles" : `${v}s`, true);
|
11014 | const shapeChart = main.select(`.${classes[`chart${`${name}s`}`]}`);
|
11015 | if (isPointType) {
|
11016 | const circle = shapeChart.selectAll(`.${classes.circles}`).data(targets.filter($$[`is${capitalize(v)}Type`].bind($$))).attr("class", shapeClass);
|
11017 | circle.exit().remove();
|
11018 | circle.enter().append("g").attr("class", shapeClass);
|
11019 | } else {
|
11020 | const shapeUpdate = shapeChart.selectAll(`.${classes[`chart${name}`]}`).attr("class", chartClass).data(targets.filter($$[`is${name}Type`].bind($$)));
|
11021 | const shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
|
11022 | shapeUpdate.exit().remove();
|
11023 | v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", true));
|
11024 | }
|
11025 | });
|
11026 | main.selectAll(`.${classes.brush} rect`).attr(
|
11027 | config.axis_rotated ? "width" : "height",
|
11028 | config.axis_rotated ? state.width2 : state.height2
|
11029 | );
|
11030 | }
|
11031 | },
|
11032 | |
11033 |
|
11034 |
|
11035 |
|
11036 |
|
11037 |
|
11038 |
|
11039 | redrawSubchart(withSubchart, duration, shape) {
|
11040 | var _a;
|
11041 | const $$ = this;
|
11042 | const { config, $el: { subchart: { main } }, state } = $$;
|
11043 | const withTransition = !!duration;
|
11044 | main.style("visibility", config.subchart_show ? null : "hidden");
|
11045 | if (config.subchart_show) {
|
11046 | if (((_a = state.event) == null ? void 0 : _a.type) === "zoom") {
|
11047 | $$.brush.update();
|
11048 | }
|
11049 | if (withSubchart) {
|
11050 | const initRange = config.subchart_init_range;
|
11051 | !brushEmpty($$) && $$.brush.update();
|
11052 | Object.keys(shape.type).forEach((v) => {
|
11053 | const name = capitalize(v);
|
11054 | const drawFn = $$[`generateDraw${name}`](shape.indices[v], true);
|
11055 | $$[`update${name}`](withTransition, true);
|
11056 | $$[`redraw${name}`](drawFn, withTransition, true);
|
11057 | });
|
11058 | if ($$.hasType("bubble") || $$.hasType("scatter")) {
|
11059 | const { cx } = shape.pos;
|
11060 | const cy = $$.updateCircleY(true);
|
11061 | $$.updateCircle(true);
|
11062 | $$.redrawCircle(cx, cy, withTransition, void 0, true);
|
11063 | }
|
11064 | if (!state.rendered && initRange) {
|
11065 | state.domain = initRange;
|
11066 | $$.brush.move(
|
11067 | $$.brush.getSelection(),
|
11068 | initRange.map($$.scale.x)
|
11069 | );
|
11070 | }
|
11071 | }
|
11072 | }
|
11073 | },
|
11074 | |
11075 |
|
11076 |
|
11077 |
|
11078 |
|
11079 | redrawForBrush(callCallbck = true) {
|
11080 | var _a;
|
11081 | const $$ = this;
|
11082 | const {
|
11083 | config: {
|
11084 | subchart_onbrush: onBrush,
|
11085 | zoom_rescale: withY
|
11086 | },
|
11087 | scale,
|
11088 | state
|
11089 | } = $$;
|
11090 | $$.redraw({
|
11091 | withTransition: false,
|
11092 | withY,
|
11093 | withSubchart: false,
|
11094 | withUpdateXDomain: true,
|
11095 | withDimension: false
|
11096 | });
|
11097 | callCallbck && state.rendered && onBrush.bind($$.api)((_a = state.domain) != null ? _a : scale.x.orgDomain());
|
11098 | },
|
11099 | |
11100 |
|
11101 |
|
11102 |
|
11103 |
|
11104 |
|
11105 | transformContext(withTransition, transitions) {
|
11106 | const $$ = this;
|
11107 | const { $el: { subchart }, $T } = $$;
|
11108 | const subXAxis = (transitions == null ? void 0 : transitions.axisSubX) ? transitions.axisSubX : $T(subchart.main.select(`.${classes.axisX}`), withTransition);
|
11109 | subchart.main.attr("transform", $$.getTranslate("context"));
|
11110 | subXAxis.attr("transform", $$.getTranslate("subX"));
|
11111 | }
|
11112 | });
|
11113 |
|
11114 | ;
|
11115 |
|
11116 |
|
11117 |
|
11118 |
|
11119 |
|
11120 | var interactions_zoom = ({
|
11121 | |
11122 |
|
11123 |
|
11124 |
|
11125 | initZoom() {
|
11126 | const $$ = this;
|
11127 | $$.scale.zoom = null;
|
11128 | $$.generateZoom();
|
11129 | $$.config.zoom_type === "drag" && $$.initZoomBehaviour();
|
11130 | },
|
11131 | |
11132 |
|
11133 |
|
11134 |
|
11135 |
|
11136 | bindZoomEvent(bind = true) {
|
11137 | const $$ = this;
|
11138 | const { config } = $$;
|
11139 | const zoomEnabled = config.zoom_enabled;
|
11140 | if (zoomEnabled && bind) {
|
11141 | !config.subchart_show && $$.bindZoomOnEventRect();
|
11142 | } else if (bind === false) {
|
11143 | $$.api.unzoom();
|
11144 | $$.unbindZoomEvent();
|
11145 | }
|
11146 | },
|
11147 | |
11148 |
|
11149 |
|
11150 |
|
11151 | generateZoom() {
|
11152 | const $$ = this;
|
11153 | const { config, org, scale } = $$;
|
11154 | const zoom = (0,external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoom)().duration(0).on("start", $$.onZoomStart.bind($$)).on("zoom", $$.onZoom.bind($$)).on("end", $$.onZoomEnd.bind($$));
|
11155 | zoom.orgScaleExtent = () => {
|
11156 | const extent = config.zoom_extent || [1, 10];
|
11157 | return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])];
|
11158 | };
|
11159 | zoom.updateScaleExtent = function() {
|
11160 | const ratio = diffDomain($$.scale.x.orgDomain()) / diffDomain($$.getZoomDomain());
|
11161 | const extent = this.orgScaleExtent();
|
11162 | this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
|
11163 | return this;
|
11164 | };
|
11165 | zoom.updateTransformScale = (transform, correctTransform) => {
|
11166 | var _a;
|
11167 | const isRotated = config.axis_rotated;
|
11168 | (_a = org.xScale) == null ? void 0 : _a.range(scale.x.range());
|
11169 | const newScale = transform[isRotated ? "rescaleY" : "rescaleX"](org.xScale || scale.x);
|
11170 | if (newScale.domain().some((v) => /(Invalid Date|NaN)/.test(v.toString()))) {
|
11171 | return;
|
11172 | }
|
11173 | const domain = $$.trimXDomain(newScale.domain());
|
11174 | const rescale = config.zoom_rescale;
|
11175 | newScale.domain(domain, org.xDomain);
|
11176 | if (correctTransform) {
|
11177 | const t = newScale(scale.x.domain()[0]);
|
11178 | const tX = isRotated ? transform.x : t;
|
11179 | const tY = isRotated ? t : transform.y;
|
11180 | $$.$el.eventRect.property(
|
11181 | "__zoom",
|
11182 | external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.translate(tX, tY).scale(transform.k)
|
11183 | );
|
11184 | }
|
11185 | if (!$$.state.xTickOffset) {
|
11186 | $$.state.xTickOffset = $$.axis.x.tickOffset();
|
11187 | }
|
11188 | scale.zoom = $$.getCustomizedXScale(newScale);
|
11189 | $$.axis.x.scale(scale.zoom);
|
11190 | if (rescale) {
|
11191 | !org.xScale && (org.xScale = scale.x.copy());
|
11192 | scale.x.domain(domain);
|
11193 | } else if (org.xScale) {
|
11194 | scale.x.domain(org.xScale.domain());
|
11195 | org.xScale = null;
|
11196 | }
|
11197 | };
|
11198 | zoom.getDomain = () => {
|
11199 | const domain = scale[scale.zoom ? "zoom" : "subX"].domain();
|
11200 | const isCategorized = $$.axis.isCategorized();
|
11201 | if (isCategorized) {
|
11202 | domain[1] -= 2;
|
11203 | }
|
11204 | return domain;
|
11205 | };
|
11206 | $$.zoom = zoom;
|
11207 | },
|
11208 | |
11209 |
|
11210 |
|
11211 |
|
11212 |
|
11213 | onZoomStart(event) {
|
11214 | const $$ = this;
|
11215 | const { sourceEvent } = event;
|
11216 | if (sourceEvent) {
|
11217 | $$.zoom.startEvent = sourceEvent;
|
11218 | $$.state.zooming = true;
|
11219 | callFn($$.config.zoom_onzoomstart, $$.api, event);
|
11220 | }
|
11221 | },
|
11222 | |
11223 |
|
11224 |
|
11225 |
|
11226 |
|
11227 | onZoom(event) {
|
11228 | var _a;
|
11229 | const $$ = this;
|
11230 | const { config, scale, state, org } = $$;
|
11231 | const { sourceEvent } = event;
|
11232 | const isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
|
11233 | if (!config.zoom_enabled || $$.filterTargetsToShow($$.data.targets).length === 0 || !scale.zoom && (sourceEvent == null ? void 0 : sourceEvent.type.indexOf("touch")) > -1 && (sourceEvent == null ? void 0 : sourceEvent.touches.length) === 1) {
|
11234 | return;
|
11235 | }
|
11236 | if (event.sourceEvent) {
|
11237 | state.zooming = true;
|
11238 | state.domain = void 0;
|
11239 | }
|
11240 | const isMousemove = (sourceEvent == null ? void 0 : sourceEvent.type) === "mousemove";
|
11241 | const isZoomOut = (sourceEvent == null ? void 0 : sourceEvent.wheelDelta) < 0;
|
11242 | const { transform } = event;
|
11243 | if (!isMousemove && isZoomOut && scale.x.domain().every((v, i) => v !== org.xDomain[i])) {
|
11244 | scale.x.domain(org.xDomain);
|
11245 | }
|
11246 | $$.zoom.updateTransformScale(transform, config.zoom_type === "wheel" && sourceEvent);
|
11247 | const doTransition = config.transition_duration > 0 && !config.subchart_show && (state.dragging || isUnZoom || !event.sourceEvent);
|
11248 | $$.redraw({
|
11249 | withTransition: doTransition,
|
11250 | withY: config.zoom_rescale,
|
11251 | withSubchart: false,
|
11252 | withEventRect: false,
|
11253 | withDimension: false
|
11254 | });
|
11255 | $$.state.cancelClick = isMousemove;
|
11256 | !isUnZoom && callFn(
|
11257 | config.zoom_onzoom,
|
11258 | $$.api,
|
11259 | (_a = $$.state.domain) != null ? _a : $$.zoom.getDomain()
|
11260 | );
|
11261 | },
|
11262 | |
11263 |
|
11264 |
|
11265 |
|
11266 |
|
11267 | onZoomEnd(event) {
|
11268 | var _a, _b;
|
11269 | const $$ = this;
|
11270 | const { config, state } = $$;
|
11271 | let { startEvent } = $$.zoom;
|
11272 | let e = event == null ? void 0 : event.sourceEvent;
|
11273 | const isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
|
11274 | if ((startEvent == null ? void 0 : startEvent.type.indexOf("touch")) > -1) {
|
11275 | startEvent = startEvent.changedTouches[0];
|
11276 | e = (_a = e == null ? void 0 : e.changedTouches) == null ? void 0 : _a[0];
|
11277 | }
|
11278 | if (config.zoom_type === "drag" && (e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY)) {
|
11279 | return;
|
11280 | }
|
11281 | state.zooming = false;
|
11282 | $$.redrawEventRect();
|
11283 | $$.updateZoom();
|
11284 | !isUnZoom && (e || state.dragging) && callFn(
|
11285 | config.zoom_onzoomend,
|
11286 | $$.api,
|
11287 | (_b = $$.state.domain) != null ? _b : $$.zoom.getDomain()
|
11288 | );
|
11289 | },
|
11290 | |
11291 |
|
11292 |
|
11293 |
|
11294 |
|
11295 | updateZoom(force) {
|
11296 | const $$ = this;
|
11297 | const { subX, x, zoom } = $$.scale;
|
11298 | if (zoom) {
|
11299 | const zoomDomain = zoom.domain();
|
11300 | const xDomain = subX.domain();
|
11301 | const delta = 0.015;
|
11302 | const isfullyShown = $$.config.axis_x_inverted ? (zoomDomain[0] >= xDomain[0] || zoomDomain[0] + delta >= xDomain[0]) && (xDomain[1] >= zoomDomain[1] || xDomain[1] >= zoomDomain[1] + delta) : (zoomDomain[0] <= xDomain[0] || zoomDomain[0] - delta <= xDomain[0]) && (xDomain[1] <= zoomDomain[1] || xDomain[1] <= zoomDomain[1] - delta);
|
11303 | if (force || isfullyShown) {
|
11304 | $$.axis.x.scale(subX);
|
11305 | x.domain(subX.orgDomain());
|
11306 | $$.scale.zoom = null;
|
11307 | }
|
11308 | }
|
11309 | },
|
11310 | |
11311 |
|
11312 |
|
11313 |
|
11314 |
|
11315 |
|
11316 | updateCurrentZoomTransform(x, domain) {
|
11317 | const $$ = this;
|
11318 | const { $el: { eventRect }, config } = $$;
|
11319 | const isRotated = config.axis_rotated;
|
11320 | const translate = [-x(domain[0]), 0];
|
11321 | const transform = external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.scale(x.range()[1] / (x(domain[1]) - x(domain[0]))).translate(
|
11322 | ...isRotated ? translate.reverse() : translate
|
11323 | );
|
11324 | eventRect.call($$.zoom.transform, transform);
|
11325 | },
|
11326 | |
11327 |
|
11328 |
|
11329 |
|
11330 | bindZoomOnEventRect() {
|
11331 | var _a;
|
11332 | const $$ = this;
|
11333 | const { config, $el: { eventRect, svg } } = $$;
|
11334 | const behaviour = config.zoom_type === "drag" ? $$.zoomBehaviour : $$.zoom;
|
11335 | if (win.GestureEvent && /^((?!chrome|android|mobile).)*safari/i.test((_a = win.navigator) == null ? void 0 : _a.userAgent)) {
|
11336 | svg.on("wheel", () => {
|
11337 | });
|
11338 | }
|
11339 | eventRect == null ? void 0 : eventRect.call(behaviour).on("dblclick.zoom", null);
|
11340 | },
|
11341 | |
11342 |
|
11343 |
|
11344 |
|
11345 | initZoomBehaviour() {
|
11346 | const $$ = this;
|
11347 | const { config, state } = $$;
|
11348 | const isRotated = config.axis_rotated;
|
11349 | let start = 0;
|
11350 | let end = 0;
|
11351 | let zoomRect;
|
11352 | let extent;
|
11353 | const prop = {
|
11354 | axis: isRotated ? "y" : "x",
|
11355 | attr: isRotated ? "height" : "width",
|
11356 | index: isRotated ? 1 : 0
|
11357 | };
|
11358 | $$.zoomBehaviour = (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().clickDistance(4).on("start", function(event) {
|
11359 | extent = $$.scale.zoom ? null : $$.axis.getExtent();
|
11360 | state.event = event;
|
11361 | $$.setDragStatus(true);
|
11362 | $$.unselectRect();
|
11363 | if (!zoomRect) {
|
11364 | zoomRect = $$.$el.main.append("rect").attr("clip-path", state.clip.path).attr("class", $ZOOM.zoomBrush).attr("width", isRotated ? state.width : 0).attr("height", isRotated ? 0 : state.height);
|
11365 | }
|
11366 | start = getPointer(event, this)[prop.index];
|
11367 | if (extent) {
|
11368 | if (start < extent[0]) {
|
11369 | start = extent[0];
|
11370 | } else if (start > extent[1]) {
|
11371 | start = extent[1];
|
11372 | }
|
11373 | }
|
11374 | end = start;
|
11375 | zoomRect.attr(prop.axis, start).attr(prop.attr, 0);
|
11376 | $$.onZoomStart(event);
|
11377 | }).on("drag", function(event) {
|
11378 | end = getPointer(event, this)[prop.index];
|
11379 | if (extent) {
|
11380 | if (end > extent[1]) {
|
11381 | end = extent[1];
|
11382 | } else if (end < extent[0]) {
|
11383 | end = extent[0];
|
11384 | }
|
11385 | }
|
11386 | zoomRect.attr(prop.axis, Math.min(start, end)).attr(prop.attr, Math.abs(end - start));
|
11387 | }).on("end", (event) => {
|
11388 | const scale = $$.scale.zoom || $$.scale.x;
|
11389 | state.event = event;
|
11390 | zoomRect.attr(prop.axis, 0).attr(prop.attr, 0);
|
11391 | if (start > end) {
|
11392 | [start, end] = [end, start];
|
11393 | }
|
11394 | if (start < 0) {
|
11395 | end += Math.abs(start);
|
11396 | start = 0;
|
11397 | }
|
11398 | if (start !== end) {
|
11399 | $$.api.zoom([start, end].map((v) => scale.invert(v)));
|
11400 | }
|
11401 | $$.setDragStatus(false);
|
11402 | });
|
11403 | },
|
11404 | setZoomResetButton() {
|
11405 | const $$ = this;
|
11406 | const { config, $el } = $$;
|
11407 | const resetButton = config.zoom_resetButton;
|
11408 | if (resetButton && config.zoom_type === "drag") {
|
11409 | if (!$el.zoomResetBtn) {
|
11410 | $el.zoomResetBtn = $$.$el.chart.append("div").classed($COMMON.button, true).append("span").on("click", function() {
|
11411 | isFunction(resetButton.onclick) && resetButton.onclick.bind($$.api)(this);
|
11412 | $$.api.unzoom();
|
11413 | }).classed($ZOOM.buttonZoomReset, true).text(resetButton.text || "Reset Zoom");
|
11414 | } else {
|
11415 | $el.zoomResetBtn.style("display", null);
|
11416 | }
|
11417 | }
|
11418 | },
|
11419 | getZoomTransform() {
|
11420 | const $$ = this;
|
11421 | const { $el: { eventRect } } = $$;
|
11422 | return (eventRect == null ? void 0 : eventRect.node()) ? (0,external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomTransform)(eventRect.node()) : { k: 1 };
|
11423 | }
|
11424 | });
|
11425 |
|
11426 | ;
|
11427 |
|
11428 |
|
11429 |
|
11430 | var drag = ({
|
11431 | |
11432 |
|
11433 |
|
11434 |
|
11435 |
|
11436 |
|
11437 | drag(mouse) {
|
11438 | const $$ = this;
|
11439 | const { config, state, $el: { main } } = $$;
|
11440 | const isSelectionGrouped = config.data_selection_grouped;
|
11441 | const isSelectable = config.interaction_enabled && config.data_selection_isselectable;
|
11442 | if ($$.hasArcType() || !config.data_selection_enabled ||
|
11443 | config.zoom_enabled && !$$.zoom.altDomain ||
|
11444 | !config.data_selection_multiple) {
|
11445 | return;
|
11446 | }
|
11447 | const [sx, sy] = state.dragStart || [0, 0];
|
11448 | const [mx, my] = mouse;
|
11449 | const minX = Math.min(sx, mx);
|
11450 | const maxX = Math.max(sx, mx);
|
11451 | const minY = isSelectionGrouped ? state.margin.top : Math.min(sy, my);
|
11452 | const maxY = isSelectionGrouped ? state.height : Math.max(sy, my);
|
11453 | main.select(`.${$DRAG.dragarea}`).attr("x", minX).attr("y", minY).attr("width", maxX - minX).attr("height", maxY - minY);
|
11454 | main.selectAll(`.${$SHAPE.shapes}`).selectAll(`.${$SHAPE.shape}`).filter((d) => isSelectable == null ? void 0 : isSelectable.bind($$.api)(d)).each(function(d, i) {
|
11455 | const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
11456 | const isSelected = shape.classed($SELECT.SELECTED);
|
11457 | const isIncluded = shape.classed($DRAG.INCLUDED);
|
11458 | let isWithin = false;
|
11459 | let toggle;
|
11460 | if (shape.classed($CIRCLE.circle)) {
|
11461 | const x = +shape.attr("cx") * 1;
|
11462 | const y = +shape.attr("cy") * 1;
|
11463 | toggle = $$.togglePoint;
|
11464 | isWithin = minX < x && x < maxX && minY < y && y < maxY;
|
11465 | } else if (shape.classed($BAR.bar)) {
|
11466 | const { x, y, width, height } = getPathBox(this);
|
11467 | toggle = $$.togglePath;
|
11468 | isWithin = !(maxX < x || x + width < minX) && !(maxY < y || y + height < minY);
|
11469 | } else {
|
11470 | return;
|
11471 | }
|
11472 | if (isWithin ^ isIncluded) {
|
11473 | shape.classed($DRAG.INCLUDED, !isIncluded);
|
11474 | shape.classed($SELECT.SELECTED, !isSelected);
|
11475 | toggle.call($$, !isSelected, shape, d, i);
|
11476 | }
|
11477 | });
|
11478 | },
|
11479 | |
11480 |
|
11481 |
|
11482 |
|
11483 |
|
11484 |
|
11485 | dragstart(mouse) {
|
11486 | const $$ = this;
|
11487 | const { config, state, $el: { main } } = $$;
|
11488 | if ($$.hasArcType() || !config.data_selection_enabled) {
|
11489 | return;
|
11490 | }
|
11491 | state.dragStart = mouse;
|
11492 | main.select(`.${$COMMON.chart}`).append("rect").attr("class", $DRAG.dragarea).style("opacity", "0.1");
|
11493 | $$.setDragStatus(true);
|
11494 | },
|
11495 | |
11496 |
|
11497 |
|
11498 |
|
11499 |
|
11500 | dragend() {
|
11501 | const $$ = this;
|
11502 | const { config, $el: { main }, $T } = $$;
|
11503 | if ($$.hasArcType() || !config.data_selection_enabled) {
|
11504 | return;
|
11505 | }
|
11506 | $T(main.select(`.${$DRAG.dragarea}`)).style("opacity", "0").remove();
|
11507 | main.selectAll(`.${$SHAPE.shape}`).classed($DRAG.INCLUDED, false);
|
11508 | $$.setDragStatus(false);
|
11509 | }
|
11510 | });
|
11511 |
|
11512 | ;
|
11513 | var selection_defProp = Object.defineProperty;
|
11514 | var __defProps = Object.defineProperties;
|
11515 | var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
11516 | var selection_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
11517 | var selection_hasOwnProp = Object.prototype.hasOwnProperty;
|
11518 | var selection_propIsEnum = Object.prototype.propertyIsEnumerable;
|
11519 | var selection_defNormalProp = (obj, key, value) => key in obj ? selection_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
11520 | var selection_spreadValues = (a, b) => {
|
11521 | for (var prop in b || (b = {}))
|
11522 | if (selection_hasOwnProp.call(b, prop))
|
11523 | selection_defNormalProp(a, prop, b[prop]);
|
11524 | if (selection_getOwnPropSymbols)
|
11525 | for (var prop of selection_getOwnPropSymbols(b)) {
|
11526 | if (selection_propIsEnum.call(b, prop))
|
11527 | selection_defNormalProp(a, prop, b[prop]);
|
11528 | }
|
11529 | return a;
|
11530 | };
|
11531 | var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
11532 |
|
11533 |
|
11534 |
|
11535 |
|
11536 | var internals_selection = (__spreadProps(selection_spreadValues({}, drag), {
|
11537 | |
11538 |
|
11539 |
|
11540 |
|
11541 |
|
11542 |
|
11543 |
|
11544 | selectPoint(target, d, i) {
|
11545 | const $$ = this;
|
11546 | const { config, $el: { main }, $T } = $$;
|
11547 | const isRotated = config.axis_rotated;
|
11548 | const cx = (isRotated ? $$.circleY : $$.circleX).bind($$);
|
11549 | const cy = (isRotated ? $$.circleX : $$.circleY).bind($$);
|
11550 | const r = $$.pointSelectR.bind($$);
|
11551 | callFn(config.data_onselected, $$.api, d, target.node());
|
11552 | $T(main.select(`.${$SELECT.selectedCircles}${$$.getTargetSelectorSuffix(d.id)}`).selectAll(`.${$SELECT.selectedCircle}-${i}`).data([d]).enter().append("circle").attr("class", () => $$.generateClass($SELECT.selectedCircle, i)).attr("cx", cx).attr("cy", cy).attr("stroke", $$.color).attr("r", (d2) => $$.pointSelectR(d2) * 1.4)).attr("r", r);
|
11553 | },
|
11554 | |
11555 |
|
11556 |
|
11557 |
|
11558 |
|
11559 |
|
11560 |
|
11561 | unselectPoint(target, d, i) {
|
11562 | const $$ = this;
|
11563 | const { config, $el: { main }, $T } = $$;
|
11564 | callFn(config.data_onunselected, $$.api, d, target == null ? void 0 : target.node());
|
11565 | $T(main.select(`.${$SELECT.selectedCircles}${$$.getTargetSelectorSuffix(d.id)}`).selectAll(`.${$SELECT.selectedCircle}-${i}`)).attr("r", 0).remove();
|
11566 | },
|
11567 | |
11568 |
|
11569 |
|
11570 |
|
11571 |
|
11572 |
|
11573 |
|
11574 |
|
11575 | togglePoint(selected, target, d, i) {
|
11576 | const method = `${selected ? "" : "un"}selectPoint`;
|
11577 | this[method](target, d, i);
|
11578 | },
|
11579 | |
11580 |
|
11581 |
|
11582 |
|
11583 |
|
11584 |
|
11585 | selectPath(target, d) {
|
11586 | const $$ = this;
|
11587 | const { config } = $$;
|
11588 | callFn(config.data_onselected, $$.api, d, target.node());
|
11589 | if (config.interaction_brighten) {
|
11590 | target.style("filter", "brightness(1.25)");
|
11591 | }
|
11592 | },
|
11593 | |
11594 |
|
11595 |
|
11596 |
|
11597 |
|
11598 |
|
11599 | unselectPath(target, d) {
|
11600 | const $$ = this;
|
11601 | const { config } = $$;
|
11602 | callFn(config.data_onunselected, $$.api, d, target.node());
|
11603 | if (config.interaction_brighten) {
|
11604 | target.style("filter", null);
|
11605 | }
|
11606 | },
|
11607 | |
11608 |
|
11609 |
|
11610 |
|
11611 |
|
11612 |
|
11613 |
|
11614 |
|
11615 | togglePath(selected, target, d, i) {
|
11616 | this[`${selected ? "" : "un"}selectPath`](target, d, i);
|
11617 | },
|
11618 | |
11619 |
|
11620 |
|
11621 |
|
11622 |
|
11623 |
|
11624 |
|
11625 | getToggle(that, d) {
|
11626 | const $$ = this;
|
11627 | return that.nodeName === "path" ? $$.togglePath : $$.isStepType(d) ? () => {
|
11628 | } : (
|
11629 |
|
11630 | $$.togglePoint
|
11631 | );
|
11632 | },
|
11633 | |
11634 |
|
11635 |
|
11636 |
|
11637 |
|
11638 |
|
11639 |
|
11640 | toggleShape(that, d, i) {
|
11641 | var _a;
|
11642 | const $$ = this;
|
11643 | const { config, $el: { main } } = $$;
|
11644 | if (config.data_selection_enabled && config.data_selection_isselectable.bind($$.api)(d)) {
|
11645 | const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that);
|
11646 | const isSelected = shape.classed($SELECT.SELECTED);
|
11647 | const toggle = $$.getToggle(that, d).bind($$);
|
11648 | let toggledShape;
|
11649 | if (!config.data_selection_multiple) {
|
11650 | const focusOnly = (_a = $$.isPointFocusOnly) == null ? void 0 : _a.call($$);
|
11651 | let selector = `.${focusOnly ? $SELECT.selectedCircles : $SHAPE.shapes}`;
|
11652 | if (config.data_selection_grouped) {
|
11653 | selector += $$.getTargetSelectorSuffix(d.id);
|
11654 | }
|
11655 | main.selectAll(selector).selectAll(
|
11656 | focusOnly ? `.${$SELECT.selectedCircle}` : `.${$SHAPE.shape}.${$SELECT.SELECTED}`
|
11657 | ).classed($SELECT.SELECTED, false).each(function(d2) {
|
11658 | const shape2 = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
11659 | toggledShape = shape2;
|
11660 | toggle(false, shape2, d2, d2.index);
|
11661 | });
|
11662 | }
|
11663 | if (!toggledShape || toggledShape.node() !== shape.node()) {
|
11664 | shape.classed($SELECT.SELECTED, !isSelected);
|
11665 | toggle(!isSelected, shape, d, i);
|
11666 | }
|
11667 | }
|
11668 | }
|
11669 | }));
|
11670 |
|
11671 | ;
|
11672 | var data_selection = ({
|
11673 | |
11674 |
|
11675 |
|
11676 |
|
11677 |
|
11678 |
|
11679 |
|
11680 |
|
11681 |
|
11682 |
|
11683 |
|
11684 |
|
11685 |
|
11686 |
|
11687 |
|
11688 |
|
11689 |
|
11690 |
|
11691 |
|
11692 |
|
11693 |
|
11694 |
|
11695 |
|
11696 |
|
11697 |
|
11698 |
|
11699 |
|
11700 | data_selection_enabled: false,
|
11701 | |
11702 |
|
11703 |
|
11704 |
|
11705 |
|
11706 |
|
11707 |
|
11708 |
|
11709 |
|
11710 |
|
11711 |
|
11712 |
|
11713 |
|
11714 |
|
11715 | data_selection_grouped: false,
|
11716 | |
11717 |
|
11718 |
|
11719 |
|
11720 |
|
11721 |
|
11722 |
|
11723 |
|
11724 |
|
11725 |
|
11726 |
|
11727 |
|
11728 |
|
11729 |
|
11730 | data_selection_isselectable: () => true,
|
11731 | |
11732 |
|
11733 |
|
11734 |
|
11735 |
|
11736 |
|
11737 |
|
11738 |
|
11739 |
|
11740 |
|
11741 |
|
11742 |
|
11743 |
|
11744 |
|
11745 | data_selection_multiple: true,
|
11746 | |
11747 |
|
11748 |
|
11749 |
|
11750 |
|
11751 |
|
11752 |
|
11753 |
|
11754 |
|
11755 |
|
11756 |
|
11757 |
|
11758 |
|
11759 |
|
11760 |
|
11761 | data_selection_draggable: false,
|
11762 | |
11763 |
|
11764 |
|
11765 |
|
11766 |
|
11767 |
|
11768 |
|
11769 |
|
11770 |
|
11771 |
|
11772 |
|
11773 |
|
11774 |
|
11775 |
|
11776 |
|
11777 | data_onselected: () => {
|
11778 | },
|
11779 | |
11780 |
|
11781 |
|
11782 |
|
11783 |
|
11784 |
|
11785 |
|
11786 |
|
11787 |
|
11788 |
|
11789 |
|
11790 |
|
11791 |
|
11792 |
|
11793 |
|
11794 | data_onunselected: () => {
|
11795 | }
|
11796 | });
|
11797 |
|
11798 | ;
|
11799 | var interaction_subchart = ({
|
11800 | |
11801 |
|
11802 |
|
11803 |
|
11804 |
|
11805 |
|
11806 |
|
11807 |
|
11808 |
|
11809 |
|
11810 |
|
11811 |
|
11812 |
|
11813 |
|
11814 |
|
11815 |
|
11816 |
|
11817 |
|
11818 |
|
11819 |
|
11820 |
|
11821 |
|
11822 |
|
11823 |
|
11824 |
|
11825 |
|
11826 |
|
11827 |
|
11828 |
|
11829 |
|
11830 |
|
11831 |
|
11832 |
|
11833 |
|
11834 |
|
11835 |
|
11836 |
|
11837 |
|
11838 |
|
11839 |
|
11840 |
|
11841 |
|
11842 |
|
11843 |
|
11844 |
|
11845 |
|
11846 |
|
11847 |
|
11848 |
|
11849 |
|
11850 |
|
11851 |
|
11852 |
|
11853 |
|
11854 | subchart_show: false,
|
11855 | subchart_showHandle: false,
|
11856 | subchart_size_height: 60,
|
11857 | subchart_axis_x_show: true,
|
11858 | subchart_axis_x_tick_show: true,
|
11859 | subchart_axis_x_tick_format: void 0,
|
11860 | subchart_axis_x_tick_text_show: true,
|
11861 | subchart_init_range: void 0,
|
11862 | subchart_onbrush: () => {
|
11863 | }
|
11864 | });
|
11865 |
|
11866 | ;
|
11867 | var interaction_zoom = ({
|
11868 | |
11869 |
|
11870 |
|
11871 |
|
11872 |
|
11873 |
|
11874 |
|
11875 |
|
11876 |
|
11877 |
|
11878 |
|
11879 |
|
11880 |
|
11881 |
|
11882 |
|
11883 |
|
11884 |
|
11885 |
|
11886 |
|
11887 |
|
11888 |
|
11889 |
|
11890 |
|
11891 |
|
11892 |
|
11893 |
|
11894 |
|
11895 |
|
11896 |
|
11897 |
|
11898 |
|
11899 |
|
11900 |
|
11901 |
|
11902 |
|
11903 |
|
11904 |
|
11905 |
|
11906 |
|
11907 |
|
11908 |
|
11909 |
|
11910 |
|
11911 |
|
11912 |
|
11913 |
|
11914 |
|
11915 |
|
11916 |
|
11917 |
|
11918 |
|
11919 |
|
11920 |
|
11921 |
|
11922 |
|
11923 |
|
11924 |
|
11925 |
|
11926 |
|
11927 |
|
11928 |
|
11929 |
|
11930 |
|
11931 |
|
11932 |
|
11933 |
|
11934 | zoom_enabled: false,
|
11935 | zoom_type: "wheel",
|
11936 | zoom_extent: void 0,
|
11937 | zoom_privileged: false,
|
11938 | zoom_rescale: false,
|
11939 | zoom_onzoom: void 0,
|
11940 | zoom_onzoomstart: void 0,
|
11941 | zoom_onzoomend: void 0,
|
11942 | zoom_resetButton: true,
|
11943 | zoom_x_min: void 0,
|
11944 | zoom_x_max: void 0
|
11945 | });
|
11946 |
|
11947 | ;
|
11948 |
|
11949 |
|
11950 |
|
11951 |
|
11952 |
|
11953 |
|
11954 |
|
11955 |
|
11956 |
|
11957 |
|
11958 |
|
11959 |
|
11960 |
|
11961 |
|
11962 | let selectionModule = () => {
|
11963 | extend(ChartInternal.prototype, internals_selection);
|
11964 | extend(Chart.prototype, selection);
|
11965 | Options.setOptions([data_selection]);
|
11966 | return (selectionModule = () => true)();
|
11967 | };
|
11968 | let subchartModule = () => {
|
11969 | extend(ChartInternal.prototype, interactions_subchart);
|
11970 | extend(Chart.prototype, api_subchart);
|
11971 | Options.setOptions([interaction_subchart]);
|
11972 | return (subchartModule = () => true)();
|
11973 | };
|
11974 | let zoomModule = () => {
|
11975 | extend(ChartInternal.prototype, interactions_zoom);
|
11976 | extend(Chart.prototype, api_zoom);
|
11977 | Options.setOptions([interaction_zoom]);
|
11978 | return (zoomModule = () => true)();
|
11979 | };
|
11980 |
|
11981 | ;
|
11982 |
|
11983 | function setMinMax($$, type, value) {
|
11984 | const { config } = $$;
|
11985 | const helper = (key, value2) => {
|
11986 | const v = isNumber(value2) ? value2 : value2 === false ? void 0 : null;
|
11987 | if (v !== null) {
|
11988 | config[`axis_${key}_${type}`] = v;
|
11989 | }
|
11990 | };
|
11991 | if (isDefined(value)) {
|
11992 | if (isObjectType(value)) {
|
11993 | Object.keys(value).forEach((key) => {
|
11994 | helper(key, value[key]);
|
11995 | });
|
11996 | } else if (isNumber(value) || value === false) {
|
11997 | ["y", "y2"].forEach((key) => {
|
11998 | helper(key, value);
|
11999 | });
|
12000 | }
|
12001 | $$.redraw({
|
12002 | withUpdateOrgXDomain: true,
|
12003 | withUpdateXDomain: true
|
12004 | });
|
12005 | }
|
12006 | }
|
12007 | function axis_getMinMax($$, type) {
|
12008 | const { config } = $$;
|
12009 | return {
|
12010 | x: config[`axis_x_${type}`],
|
12011 | y: config[`axis_y_${type}`],
|
12012 | y2: config[`axis_y2_${type}`]
|
12013 | };
|
12014 | }
|
12015 | const axis = {
|
12016 | |
12017 |
|
12018 |
|
12019 |
|
12020 |
|
12021 |
|
12022 |
|
12023 |
|
12024 |
|
12025 |
|
12026 |
|
12027 |
|
12028 |
|
12029 |
|
12030 |
|
12031 |
|
12032 |
|
12033 |
|
12034 |
|
12035 |
|
12036 |
|
12037 |
|
12038 |
|
12039 |
|
12040 |
|
12041 |
|
12042 | labels: function(labels) {
|
12043 | const $$ = this.internal;
|
12044 | let labelText;
|
12045 | if (labels) {
|
12046 | Object.keys(labels).forEach((axisId) => {
|
12047 | $$.axis.setLabelText(axisId, labels[axisId]);
|
12048 | });
|
12049 | $$.axis.updateLabels();
|
12050 | }
|
12051 | ["x", "y", "y2"].forEach((v) => {
|
12052 | const text = $$.axis.getLabelText(v);
|
12053 | if (text) {
|
12054 | !labelText && (labelText = {});
|
12055 | labelText[v] = text;
|
12056 | }
|
12057 | });
|
12058 | return labelText;
|
12059 | },
|
12060 | |
12061 |
|
12062 |
|
12063 |
|
12064 |
|
12065 |
|
12066 |
|
12067 |
|
12068 |
|
12069 |
|
12070 |
|
12071 |
|
12072 |
|
12073 |
|
12074 |
|
12075 |
|
12076 |
|
12077 |
|
12078 |
|
12079 |
|
12080 |
|
12081 |
|
12082 |
|
12083 |
|
12084 |
|
12085 |
|
12086 |
|
12087 |
|
12088 |
|
12089 |
|
12090 | min: function(min) {
|
12091 | const $$ = this.internal;
|
12092 | return isValue(min) || min === false ? setMinMax($$, "min", min) : axis_getMinMax($$, "min");
|
12093 | },
|
12094 | |
12095 |
|
12096 |
|
12097 |
|
12098 |
|
12099 |
|
12100 |
|
12101 |
|
12102 |
|
12103 |
|
12104 |
|
12105 |
|
12106 |
|
12107 |
|
12108 |
|
12109 |
|
12110 |
|
12111 |
|
12112 |
|
12113 |
|
12114 |
|
12115 |
|
12116 |
|
12117 |
|
12118 |
|
12119 |
|
12120 |
|
12121 |
|
12122 |
|
12123 |
|
12124 | max: function(max) {
|
12125 | const $$ = this.internal;
|
12126 | return isValue(max) || max === false ? setMinMax($$, "max", max) : axis_getMinMax($$, "max");
|
12127 | },
|
12128 | |
12129 |
|
12130 |
|
12131 |
|
12132 |
|
12133 |
|
12134 |
|
12135 |
|
12136 |
|
12137 |
|
12138 |
|
12139 |
|
12140 |
|
12141 |
|
12142 |
|
12143 |
|
12144 |
|
12145 |
|
12146 |
|
12147 |
|
12148 |
|
12149 |
|
12150 |
|
12151 |
|
12152 |
|
12153 |
|
12154 |
|
12155 |
|
12156 |
|
12157 |
|
12158 |
|
12159 |
|
12160 |
|
12161 |
|
12162 |
|
12163 |
|
12164 |
|
12165 |
|
12166 |
|
12167 |
|
12168 |
|
12169 |
|
12170 |
|
12171 | range: function(range) {
|
12172 | const { axis: axis2 } = this;
|
12173 | if (arguments.length) {
|
12174 | const { min, max } = range;
|
12175 | isDefined(max) && axis2.max(max);
|
12176 | isDefined(min) && axis2.min(min);
|
12177 | } else {
|
12178 | return {
|
12179 | max: axis2.max(),
|
12180 | min: axis2.min()
|
12181 | };
|
12182 | }
|
12183 | return void 0;
|
12184 | }
|
12185 | };
|
12186 | var api_axis = ({ axis });
|
12187 |
|
12188 | ;
|
12189 |
|
12190 | var api_category = ({
|
12191 | |
12192 |
|
12193 |
|
12194 |
|
12195 |
|
12196 |
|
12197 |
|
12198 |
|
12199 |
|
12200 |
|
12201 |
|
12202 | category(i, category) {
|
12203 | const $$ = this.internal;
|
12204 | const { config } = $$;
|
12205 | if (arguments.length > 1) {
|
12206 | config.axis_x_categories[i] = category;
|
12207 | $$.redraw();
|
12208 | }
|
12209 | return config.axis_x_categories[i];
|
12210 | },
|
12211 | |
12212 |
|
12213 |
|
12214 |
|
12215 |
|
12216 |
|
12217 |
|
12218 |
|
12219 |
|
12220 |
|
12221 |
|
12222 |
|
12223 | categories(categories) {
|
12224 | const $$ = this.internal;
|
12225 | const { config } = $$;
|
12226 | if (!categories || !Array.isArray(categories)) {
|
12227 | const cat = config.axis_x_categories;
|
12228 | return isEmpty(cat) ? Object.values($$.data.xs)[0] : cat;
|
12229 | }
|
12230 | config.axis_x_categories = categories;
|
12231 | $$.redraw();
|
12232 | return config.axis_x_categories;
|
12233 | }
|
12234 | });
|
12235 |
|
12236 | ;
|
12237 |
|
12238 | var flow = ({
|
12239 | |
12240 |
|
12241 |
|
12242 |
|
12243 |
|
12244 |
|
12245 |
|
12246 |
|
12247 |
|
12248 |
|
12249 |
|
12250 |
|
12251 |
|
12252 |
|
12253 |
|
12254 |
|
12255 |
|
12256 |
|
12257 |
|
12258 |
|
12259 |
|
12260 |
|
12261 |
|
12262 |
|
12263 |
|
12264 |
|
12265 |
|
12266 |
|
12267 |
|
12268 |
|
12269 |
|
12270 |
|
12271 |
|
12272 |
|
12273 |
|
12274 |
|
12275 |
|
12276 |
|
12277 |
|
12278 |
|
12279 |
|
12280 |
|
12281 |
|
12282 |
|
12283 |
|
12284 |
|
12285 |
|
12286 |
|
12287 |
|
12288 | flow(args) {
|
12289 | const $$ = this.internal;
|
12290 | let data;
|
12291 | if (args.json || args.rows || args.columns) {
|
12292 | $$.convertData(args, (res) => {
|
12293 | data = res;
|
12294 | _();
|
12295 | });
|
12296 | }
|
12297 | function _() {
|
12298 | let domain;
|
12299 | let length = 0;
|
12300 | let tail = 0;
|
12301 | let diff;
|
12302 | let to;
|
12303 | if ($$.state.redrawing || !data || !isTabVisible()) {
|
12304 | return;
|
12305 | }
|
12306 | const notfoundIds = [];
|
12307 | const orgDataCount = $$.getMaxDataCount();
|
12308 | const targets = $$.convertDataToTargets(data, true);
|
12309 | const isTimeSeries = $$.axis.isTimeSeries();
|
12310 | $$.data.targets.forEach((t) => {
|
12311 | let found = false;
|
12312 | for (let i = 0; i < targets.length; i++) {
|
12313 | if (t.id === targets[i].id) {
|
12314 | found = true;
|
12315 | if (t.values[t.values.length - 1]) {
|
12316 | tail = t.values[t.values.length - 1].index + 1;
|
12317 | }
|
12318 | length = targets[i].values.length;
|
12319 | for (let j = 0; j < length; j++) {
|
12320 | targets[i].values[j].index = tail + j;
|
12321 | if (!isTimeSeries) {
|
12322 | targets[i].values[j].x = tail + j;
|
12323 | }
|
12324 | }
|
12325 | t.values = t.values.concat(targets[i].values);
|
12326 | targets.splice(i, 1);
|
12327 | break;
|
12328 | }
|
12329 | }
|
12330 | !found && notfoundIds.push(t.id);
|
12331 | });
|
12332 | $$.data.targets.forEach((t) => {
|
12333 | for (let i = 0; i < notfoundIds.length; i++) {
|
12334 | if (t.id === notfoundIds[i]) {
|
12335 | tail = t.values[t.values.length - 1].index + 1;
|
12336 | for (let j = 0; j < length; j++) {
|
12337 | t.values.push({
|
12338 | id: t.id,
|
12339 | index: tail + j,
|
12340 | x: isTimeSeries ? $$.getOtherTargetX(tail + j) : tail + j,
|
12341 | value: null
|
12342 | });
|
12343 | }
|
12344 | }
|
12345 | }
|
12346 | });
|
12347 | if ($$.data.targets.length) {
|
12348 | targets.forEach((t) => {
|
12349 | const missing = [];
|
12350 | for (let i = $$.data.targets[0].values[0].index; i < tail; i++) {
|
12351 | missing.push({
|
12352 | id: t.id,
|
12353 | index: i,
|
12354 | x: isTimeSeries ? $$.getOtherTargetX(i) : i,
|
12355 | value: null
|
12356 | });
|
12357 | }
|
12358 | t.values.forEach((v) => {
|
12359 | v.index += tail;
|
12360 | if (!isTimeSeries) {
|
12361 | v.x += tail;
|
12362 | }
|
12363 | });
|
12364 | t.values = missing.concat(t.values);
|
12365 | });
|
12366 | }
|
12367 | $$.data.targets = $$.data.targets.concat(targets);
|
12368 | const baseTarget = $$.data.targets[0];
|
12369 | const baseValue = baseTarget.values[0];
|
12370 | if (isDefined(args.to)) {
|
12371 | length = 0;
|
12372 | to = isTimeSeries ? parseDate.call($$, args.to) : args.to;
|
12373 | baseTarget.values.forEach((v) => {
|
12374 | v.x < to && length++;
|
12375 | });
|
12376 | } else if (isDefined(args.length)) {
|
12377 | length = args.length;
|
12378 | }
|
12379 | if (!orgDataCount) {
|
12380 | if (isTimeSeries) {
|
12381 | diff = baseTarget.values.length > 1 ? baseTarget.values[baseTarget.values.length - 1].x - baseValue.x : baseValue.x - $$.getXDomain($$.data.targets)[0];
|
12382 | } else {
|
12383 | diff = 1;
|
12384 | }
|
12385 | domain = [baseValue.x - diff, baseValue.x];
|
12386 | } else if (orgDataCount === 1 && isTimeSeries) {
|
12387 | diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2;
|
12388 | domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)];
|
12389 | }
|
12390 | domain && $$.updateXDomain(null, true, true, false, domain);
|
12391 | $$.updateTargets($$.data.targets);
|
12392 | $$.redraw({
|
12393 | flow: {
|
12394 | index: baseValue.index,
|
12395 | length,
|
12396 | duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
|
12397 | done: args.done,
|
12398 | orgDataCount
|
12399 | },
|
12400 | withLegend: true,
|
12401 | withTransition: orgDataCount > 1,
|
12402 | withTrimXDomain: false,
|
12403 | withUpdateXAxis: true
|
12404 | });
|
12405 | }
|
12406 | }
|
12407 | });
|
12408 |
|
12409 | ;
|
12410 |
|
12411 | function grid(grids, axisId) {
|
12412 | const $$ = this.internal;
|
12413 | const { config } = $$;
|
12414 | const withTransition = config.transition_duration && isTabVisible();
|
12415 | const gridPropLines = `grid_${axisId}_lines`;
|
12416 | if (!grids) {
|
12417 | return config[gridPropLines];
|
12418 | }
|
12419 | config[gridPropLines] = grids;
|
12420 | $$.updateGrid();
|
12421 | $$.redrawGrid(withTransition);
|
12422 | return config[gridPropLines];
|
12423 | }
|
12424 | function add(grids, axisId) {
|
12425 | const gridPropLines = `grid_${axisId}_lines`;
|
12426 | return grid.bind(this)(
|
12427 | this.internal.config[gridPropLines].concat(grids || []),
|
12428 | axisId
|
12429 | );
|
12430 | }
|
12431 | function remove(grids, isXAxis) {
|
12432 | this.internal.removeGridLines(grids, isXAxis);
|
12433 | }
|
12434 | const xgrids = function(grids) {
|
12435 | return grid.bind(this)(grids, "x");
|
12436 | };
|
12437 | extend(xgrids, {
|
12438 | |
12439 |
|
12440 |
|
12441 |
|
12442 |
|
12443 |
|
12444 |
|
12445 |
|
12446 |
|
12447 |
|
12448 |
|
12449 |
|
12450 |
|
12451 |
|
12452 |
|
12453 |
|
12454 |
|
12455 |
|
12456 |
|
12457 |
|
12458 | add(grids) {
|
12459 | return add.bind(this)(grids, "x");
|
12460 | },
|
12461 | |
12462 |
|
12463 |
|
12464 |
|
12465 |
|
12466 |
|
12467 |
|
12468 |
|
12469 |
|
12470 |
|
12471 |
|
12472 |
|
12473 |
|
12474 |
|
12475 |
|
12476 |
|
12477 |
|
12478 |
|
12479 |
|
12480 |
|
12481 |
|
12482 |
|
12483 | remove(grids) {
|
12484 | return remove.bind(this)(grids, true);
|
12485 | }
|
12486 | });
|
12487 | const ygrids = function(grids) {
|
12488 | return grid.bind(this)(grids, "y");
|
12489 | };
|
12490 | extend(ygrids, {
|
12491 | |
12492 |
|
12493 |
|
12494 |
|
12495 |
|
12496 |
|
12497 |
|
12498 |
|
12499 |
|
12500 |
|
12501 |
|
12502 |
|
12503 |
|
12504 |
|
12505 |
|
12506 |
|
12507 |
|
12508 |
|
12509 |
|
12510 |
|
12511 | add(grids) {
|
12512 | return add.bind(this)(grids, "y");
|
12513 | },
|
12514 | |
12515 |
|
12516 |
|
12517 |
|
12518 |
|
12519 |
|
12520 |
|
12521 |
|
12522 |
|
12523 |
|
12524 |
|
12525 |
|
12526 |
|
12527 |
|
12528 |
|
12529 |
|
12530 |
|
12531 |
|
12532 |
|
12533 |
|
12534 |
|
12535 |
|
12536 | remove(grids) {
|
12537 | return remove.bind(this)(grids, false);
|
12538 | }
|
12539 | });
|
12540 | var api_grid = ({ xgrids, ygrids });
|
12541 |
|
12542 | ;
|
12543 |
|
12544 | var group = ({
|
12545 | |
12546 |
|
12547 |
|
12548 |
|
12549 |
|
12550 |
|
12551 |
|
12552 |
|
12553 |
|
12554 |
|
12555 |
|
12556 |
|
12557 |
|
12558 | groups(groups) {
|
12559 | const $$ = this.internal;
|
12560 | const { config } = $$;
|
12561 | if (isUndefined(groups)) {
|
12562 | return config.data_groups;
|
12563 | }
|
12564 | config.data_groups = groups;
|
12565 | $$.redraw();
|
12566 | return config.data_groups;
|
12567 | }
|
12568 | });
|
12569 |
|
12570 | ;
|
12571 |
|
12572 |
|
12573 | function regionsFn(regions2, isAdd = false) {
|
12574 | const $$ = this.internal;
|
12575 | const { config } = $$;
|
12576 | const withTransition = config.transition_duration && isTabVisible();
|
12577 | if (!regions2) {
|
12578 | return config.regions;
|
12579 | }
|
12580 | config.regions = isAdd ? config.regions.concat(regions2) : regions2;
|
12581 | $$.updateRegion();
|
12582 | $$.redrawRegion(withTransition);
|
12583 | return isAdd ? config.regions : regions2;
|
12584 | }
|
12585 | const regions = function(regions2) {
|
12586 | return regionsFn.bind(this)(regions2);
|
12587 | };
|
12588 | extend(regions, {
|
12589 | |
12590 |
|
12591 |
|
12592 |
|
12593 |
|
12594 |
|
12595 |
|
12596 |
|
12597 |
|
12598 |
|
12599 |
|
12600 |
|
12601 |
|
12602 |
|
12603 |
|
12604 |
|
12605 |
|
12606 |
|
12607 |
|
12608 |
|
12609 |
|
12610 |
|
12611 |
|
12612 |
|
12613 |
|
12614 |
|
12615 |
|
12616 |
|
12617 |
|
12618 |
|
12619 |
|
12620 |
|
12621 |
|
12622 |
|
12623 |
|
12624 | add: function(regions2) {
|
12625 | return regionsFn.bind(this)(regions2, true);
|
12626 | },
|
12627 | |
12628 |
|
12629 |
|
12630 |
|
12631 |
|
12632 |
|
12633 |
|
12634 |
|
12635 |
|
12636 |
|
12637 |
|
12638 |
|
12639 |
|
12640 |
|
12641 |
|
12642 |
|
12643 |
|
12644 |
|
12645 |
|
12646 | remove: function(optionsValue) {
|
12647 | const $$ = this.internal;
|
12648 | const { config, $T } = $$;
|
12649 | const options = optionsValue || {};
|
12650 | const classes = getOption(options, "classes", [$REGION.region]);
|
12651 | let regions2 = $$.$el.main.select(`.${$REGION.regions}`).selectAll(classes.map((c) => `.${c}`));
|
12652 | $T(regions2).style("opacity", "0").remove();
|
12653 | regions2 = config.regions;
|
12654 | if (Object.keys(options).length) {
|
12655 | regions2 = regions2.filter((region) => {
|
12656 | let found = false;
|
12657 | if (!region.class) {
|
12658 | return true;
|
12659 | }
|
12660 | region.class.split(" ").forEach((c) => {
|
12661 | if (classes.indexOf(c) >= 0) {
|
12662 | found = true;
|
12663 | }
|
12664 | });
|
12665 | return !found;
|
12666 | });
|
12667 | config.regions = regions2;
|
12668 | } else {
|
12669 | config.regions = [];
|
12670 | }
|
12671 | return regions2;
|
12672 | }
|
12673 | });
|
12674 | var api_regions = ({ regions });
|
12675 |
|
12676 | ;
|
12677 |
|
12678 | var x = ({
|
12679 | |
12680 |
|
12681 |
|
12682 |
|
12683 |
|
12684 |
|
12685 |
|
12686 |
|
12687 |
|
12688 |
|
12689 |
|
12690 |
|
12691 |
|
12692 |
|
12693 | x(x) {
|
12694 | const $$ = this.internal;
|
12695 | const { axis, data } = $$;
|
12696 | const isCategorized = axis.isCustomX() && axis.isCategorized();
|
12697 | if (isArray(x)) {
|
12698 | if (isCategorized) {
|
12699 | this.categories(x);
|
12700 | } else {
|
12701 | $$.updateTargetX(data.targets, x);
|
12702 | $$.redraw({
|
12703 | withUpdateOrgXDomain: true,
|
12704 | withUpdateXDomain: true
|
12705 | });
|
12706 | }
|
12707 | }
|
12708 | return isCategorized ? this.categories() : data.xs;
|
12709 | },
|
12710 | |
12711 |
|
12712 |
|
12713 |
|
12714 |
|
12715 |
|
12716 |
|
12717 |
|
12718 |
|
12719 |
|
12720 |
|
12721 |
|
12722 |
|
12723 |
|
12724 |
|
12725 |
|
12726 |
|
12727 | xs(xs) {
|
12728 | const $$ = this.internal;
|
12729 | if (isObject(xs)) {
|
12730 | $$.updateTargetXs($$.data.targets, xs);
|
12731 | $$.redraw({
|
12732 | withUpdateOrgXDomain: true,
|
12733 | withUpdateXDomain: true
|
12734 | });
|
12735 | }
|
12736 | return $$.data.xs;
|
12737 | }
|
12738 | });
|
12739 |
|
12740 |
|
12741 | var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack_require__(11);
|
12742 | ;
|
12743 | var AxisRendererHelper_defProp = Object.defineProperty;
|
12744 | var AxisRendererHelper_defNormalProp = (obj, key, value) => key in obj ? AxisRendererHelper_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
12745 | var AxisRendererHelper_publicField = (obj, key, value) => AxisRendererHelper_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
12746 |
|
12747 |
|
12748 | class AxisRendererHelper {
|
12749 | constructor(owner) {
|
12750 | AxisRendererHelper_publicField(this, "owner");
|
12751 | AxisRendererHelper_publicField(this, "config");
|
12752 | AxisRendererHelper_publicField(this, "scale");
|
12753 | const scale = getScale();
|
12754 | const { config, params } = owner;
|
12755 | this.owner = owner;
|
12756 | this.config = config;
|
12757 | this.scale = scale;
|
12758 | if (config.noTransition || !params.config.transition_duration) {
|
12759 | config.withoutTransition = true;
|
12760 | }
|
12761 | config.range = this.scaleExtent((params.orgXScale || scale).range());
|
12762 | }
|
12763 | |
12764 |
|
12765 |
|
12766 |
|
12767 |
|
12768 |
|
12769 |
|
12770 | static getSizeFor1Char(text, memoize = true) {
|
12771 | const size = {
|
12772 | w: 5.5,
|
12773 | h: 11.5
|
12774 | };
|
12775 | !text.empty() && text.text("0").call((el) => {
|
12776 | try {
|
12777 | const { width, height } = el.node().getBBox();
|
12778 | if (width && height) {
|
12779 | size.w = width;
|
12780 | size.h = height;
|
12781 | }
|
12782 | } finally {
|
12783 | el.text("");
|
12784 | }
|
12785 | });
|
12786 | if (memoize) {
|
12787 | this.getSizeFor1Char = () => size;
|
12788 | }
|
12789 | return size;
|
12790 | }
|
12791 | |
12792 |
|
12793 |
|
12794 |
|
12795 |
|
12796 |
|
12797 | getTickTransformSetter(id) {
|
12798 | const { config } = this;
|
12799 | const fn = id === "x" ? (value) => `translate(${value + config.tickOffset},0)` : (value) => `translate(0,${value})`;
|
12800 | return (selection, scale) => {
|
12801 | selection.attr("transform", (d) => {
|
12802 | const x = scale(d);
|
12803 | return isValue(d) ? fn(x) : null;
|
12804 | });
|
12805 | };
|
12806 | }
|
12807 | scaleExtent(domain) {
|
12808 | const start = domain[0];
|
12809 | const stop = domain[domain.length - 1];
|
12810 | return start < stop ? [start, stop] : [stop, start];
|
12811 | }
|
12812 | generateTicks(scale, isYAxes) {
|
12813 | const { tickStepSize } = this.owner.params;
|
12814 | const [start, end] = scale.domain();
|
12815 | let ticks = [];
|
12816 | if (isYAxes && tickStepSize) {
|
12817 | let interval = Math.round(start);
|
12818 | while (interval <= end) {
|
12819 | ticks.push(interval);
|
12820 | interval += tickStepSize;
|
12821 | }
|
12822 | } else if (scale.ticks) {
|
12823 | const { tickArguments } = this.config;
|
12824 | if (scale.type === "log" && !tickArguments) {
|
12825 | const s = getScale("_log").domain([start > 0 ? start : 1, end]).range(scale.range());
|
12826 | ticks = s.ticks();
|
12827 | for (let cnt = end.toFixed().length; ticks.length > 15; cnt--) {
|
12828 | ticks = s.ticks(cnt);
|
12829 | }
|
12830 | ticks.splice(0, 1, start);
|
12831 | ticks.splice(ticks.length - 1, 1, end);
|
12832 | } else {
|
12833 | ticks = scale.ticks(...this.config.tickArguments || []);
|
12834 | }
|
12835 | ticks = ticks.map((v) => {
|
12836 | const r = isString(v) && isNumber(v) && !isNaN(v) && Math.round(v * 10) / 10 || v;
|
12837 | return r;
|
12838 | });
|
12839 | }
|
12840 | return ticks;
|
12841 | }
|
12842 | copyScale() {
|
12843 | const newScale = this.scale.copy();
|
12844 | if (!newScale.domain().length) {
|
12845 | newScale.domain(this.scale.domain());
|
12846 | }
|
12847 | newScale.type = this.scale.type;
|
12848 | return newScale;
|
12849 | }
|
12850 | textFormatted(v) {
|
12851 | const tickFormat = this.config.tickFormat;
|
12852 | const value = /\d+\.\d+0{5,}\d$/.test(v) ? +String(v).replace(/0+\d$/, "") : v;
|
12853 | const formatted = tickFormat ? tickFormat(value) : value;
|
12854 | return isDefined(formatted) ? formatted : "";
|
12855 | }
|
12856 | transitionise(selection) {
|
12857 | const { config } = this;
|
12858 | let transitionSelection = selection;
|
12859 | if (config.withoutTransition) {
|
12860 | transitionSelection = selection.interrupt();
|
12861 | } else if (config.transition || !this.owner.params.noTransition) {
|
12862 | try {
|
12863 | transitionSelection = selection.transition(config.transition);
|
12864 | } catch (e) {
|
12865 | }
|
12866 | }
|
12867 | return transitionSelection;
|
12868 | }
|
12869 | }
|
12870 |
|
12871 | ;
|
12872 | var AxisRenderer_defProp = Object.defineProperty;
|
12873 | var AxisRenderer_defNormalProp = (obj, key, value) => key in obj ? AxisRenderer_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
12874 | var AxisRenderer_publicField = (obj, key, value) => AxisRenderer_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
12875 |
|
12876 |
|
12877 |
|
12878 | class AxisRenderer {
|
12879 | constructor(params = {}) {
|
12880 | AxisRenderer_publicField(this, "helper");
|
12881 | AxisRenderer_publicField(this, "config");
|
12882 | AxisRenderer_publicField(this, "params");
|
12883 | AxisRenderer_publicField(this, "g");
|
12884 | AxisRenderer_publicField(this, "generatedTicks");
|
12885 | const config = {
|
12886 | innerTickSize: 6,
|
12887 | outerTickSize: params.outerTick ? 6 : 0,
|
12888 | orient: "bottom",
|
12889 | range: [],
|
12890 | tickArguments: null,
|
12891 | tickCentered: null,
|
12892 | tickCulling: true,
|
12893 | tickFormat: null,
|
12894 | tickLength: 9,
|
12895 | tickOffset: 0,
|
12896 | tickPadding: 3,
|
12897 | tickValues: null,
|
12898 | transition: null,
|
12899 | noTransition: params.noTransition
|
12900 | };
|
12901 | config.tickLength = Math.max(config.innerTickSize, 0) + config.tickPadding;
|
12902 | this.config = config;
|
12903 | this.params = params;
|
12904 | this.helper = new AxisRendererHelper(this);
|
12905 | }
|
12906 | |
12907 |
|
12908 |
|
12909 |
|
12910 |
|
12911 | create(g) {
|
12912 | const ctx = this;
|
12913 | const { config, helper, params } = ctx;
|
12914 | const { scale } = helper;
|
12915 | const { orient } = config;
|
12916 | const splitTickText = this.splitTickText.bind(ctx);
|
12917 | const isLeftRight = /^(left|right)$/.test(orient);
|
12918 | const isTopBottom = /^(top|bottom)$/.test(orient);
|
12919 | const tickTransform = helper.getTickTransformSetter(isTopBottom ? "x" : "y");
|
12920 | const axisPx = tickTransform === helper.axisX ? "y" : "x";
|
12921 | const sign = /^(top|left)$/.test(orient) ? -1 : 1;
|
12922 | const rotate = params.tickTextRotate;
|
12923 | this.config.range = scale.rangeExtent ? scale.rangeExtent() : helper.scaleExtent((params.orgXScale || scale).range());
|
12924 | const { innerTickSize, tickLength, range } = config;
|
12925 | const id = params.id;
|
12926 | const tickTextPos = id && /^(x|y|y2)$/.test(id) ? params.config[`axis_${id}_tick_text_position`] : { x: 0, y: 0 };
|
12927 | const prefix = id === "subX" ? `subchart_axis_x` : `axis_${id}`;
|
12928 | const axisShow = params.config[`${prefix}_show`];
|
12929 | const tickShow = {
|
12930 | tick: axisShow ? params.config[`${prefix}_tick_show`] : false,
|
12931 | text: axisShow ? params.config[`${prefix}_tick_text_show`] : false
|
12932 | };
|
12933 | const evalTextSize = params.config.axis_evalTextSize;
|
12934 | let $g;
|
12935 | g.each(function() {
|
12936 | const g2 = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
12937 | let scale0 = this.__chart__ || scale;
|
12938 | let scale1 = helper.copyScale();
|
12939 | $g = g2;
|
12940 | this.__chart__ = scale1;
|
12941 | config.tickOffset = params.isCategory ? (scale1(1) - scale1(0)) / 2 : 0;
|
12942 | const path = g2.selectAll(".domain").data([0]);
|
12943 | path.enter().append("path").attr("class", "domain").merge(path).attr("d", () => {
|
12944 | const outerTickSized = config.outerTickSize * sign;
|
12945 | return isTopBottom ? `M${range[0]},${outerTickSized}V0H${range[1]}V${outerTickSized}` : `M${outerTickSized},${range[0]}H0V${range[1]}H${outerTickSized}`;
|
12946 | });
|
12947 | if (tickShow.tick || tickShow.text) {
|
12948 | const ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight);
|
12949 | ctx.generatedTicks = ticks;
|
12950 | let tick = g2.selectAll(".tick").data(ticks, scale1);
|
12951 | const tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick");
|
12952 | const tickExit = tick.exit().remove();
|
12953 | tick = tickEnter.merge(tick);
|
12954 | tickShow.tick && tickEnter.append("line");
|
12955 | tickShow.text && tickEnter.append("text");
|
12956 | const tickText = tick.select("text");
|
12957 | const sizeFor1Char = isFunction(evalTextSize) ? evalTextSize.bind(ctx.params.owner.api)(tickText.node()) : AxisRendererHelper.getSizeFor1Char(tickText, evalTextSize);
|
12958 | const counts = [];
|
12959 | let tspan = tickText.selectAll("tspan").data((d, index) => {
|
12960 | const split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
|
12961 | counts[index] = split.length;
|
12962 | return split.map((splitted) => ({ index, splitted }));
|
12963 | });
|
12964 | tspan.exit().remove();
|
12965 | tspan = tspan.enter().append("tspan").merge(tspan).text((d) => d.splitted);
|
12966 | tspan.attr("x", isTopBottom ? 0 : tickLength * sign).attr("dx", (() => {
|
12967 | let dx = 0;
|
12968 | if (/(top|bottom)/.test(orient) && rotate) {
|
12969 | dx = 8 * Math.sin(Math.PI * (rotate / 180)) * (orient === "top" ? -1 : 1);
|
12970 | }
|
12971 | return dx + (tickTextPos.x || 0);
|
12972 | })()).attr("dy", (d, i) => {
|
12973 | const defValue = ".71em";
|
12974 | let dy = 0;
|
12975 | if (orient !== "top") {
|
12976 | dy = sizeFor1Char.h;
|
12977 | if (i === 0) {
|
12978 | dy = isLeftRight ? -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3) : tickTextPos.y === 0 ? defValue : 0;
|
12979 | }
|
12980 | }
|
12981 | return isNumber(dy) && tickTextPos.y ? dy + tickTextPos.y : dy || defValue;
|
12982 | });
|
12983 | const lineUpdate = tick.select("line");
|
12984 | const textUpdate = tick.select("text");
|
12985 | tickEnter.select("line").attr(`${axisPx}2`, innerTickSize * sign);
|
12986 | tickEnter.select("text").attr(axisPx, tickLength * sign);
|
12987 | ctx.setTickLineTextPosition(lineUpdate, textUpdate);
|
12988 | if (params.tickTitle) {
|
12989 | const title = textUpdate.select("title");
|
12990 | (title.empty() ? textUpdate.append("title") : title).text((index) => params.tickTitle[index]);
|
12991 | }
|
12992 | if (scale1.bandwidth) {
|
12993 | const x = scale1;
|
12994 | const dx = x.bandwidth() / 2;
|
12995 | scale0 = (d) => x(d) + dx;
|
12996 | scale1 = scale0;
|
12997 | } else if (scale0.bandwidth) {
|
12998 | scale0 = scale1;
|
12999 | } else {
|
13000 | tickTransform(tickExit, scale1);
|
13001 | }
|
13002 | tick = params.owner.state.flowing ? helper.transitionise(tick) : params.owner.$T(tick);
|
13003 | tickTransform(tickEnter, scale0);
|
13004 | tickTransform(tick.style("opacity", null), scale1);
|
13005 | }
|
13006 | });
|
13007 | this.g = $g;
|
13008 | }
|
13009 | |
13010 |
|
13011 |
|
13012 |
|
13013 |
|
13014 |
|
13015 | getGeneratedTicks(count) {
|
13016 | var _a;
|
13017 | const len = ((_a = this.generatedTicks) == null ? void 0 : _a.length) - 1;
|
13018 | let res = this.generatedTicks;
|
13019 | if (len > count) {
|
13020 | const interval = Math.round(len / count + 0.1);
|
13021 | res = this.generatedTicks.map((v, i) => i % interval === 0 ? v : null).filter((v) => v !== null).splice(0, count);
|
13022 | }
|
13023 | return res;
|
13024 | }
|
13025 | |
13026 |
|
13027 |
|
13028 |
|
13029 |
|
13030 | getTickXY() {
|
13031 | const { config } = this;
|
13032 | const pos = { x: 0, y: 0 };
|
13033 | if (this.params.isCategory) {
|
13034 | pos.x = config.tickCentered ? 0 : config.tickOffset;
|
13035 | pos.y = config.tickCentered ? config.tickOffset : 0;
|
13036 | }
|
13037 | return pos;
|
13038 | }
|
13039 | |
13040 |
|
13041 |
|
13042 |
|
13043 |
|
13044 |
|
13045 | getTickSize(d) {
|
13046 | const { scale } = this.helper;
|
13047 | const { config } = this;
|
13048 | const { innerTickSize, range } = config;
|
13049 | const tickPosition = scale(d) + (config.tickCentered ? 0 : config.tickOffset);
|
13050 | return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0;
|
13051 | }
|
13052 | |
13053 |
|
13054 |
|
13055 |
|
13056 |
|
13057 |
|
13058 | setTickLineTextPosition(lineUpdate, textUpdate) {
|
13059 | const tickPos = this.getTickXY();
|
13060 | const { innerTickSize, orient, tickLength, tickOffset } = this.config;
|
13061 | const rotate = this.params.tickTextRotate;
|
13062 | const textAnchorForText = (r) => {
|
13063 | const value = ["start", "end"];
|
13064 | orient === "top" && value.reverse();
|
13065 | return !r ? "middle" : value[r > 0 ? 0 : 1];
|
13066 | };
|
13067 | const textTransform = (r) => r ? `rotate(${r})` : null;
|
13068 | const yForText = (r) => {
|
13069 | const r2 = r / (orient === "bottom" ? 15 : 23);
|
13070 | return r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
|
13071 | };
|
13072 | const {
|
13073 | config: {
|
13074 | axis_rotated: isRotated,
|
13075 | axis_x_tick_text_inner: inner
|
13076 | }
|
13077 | } = this.params.owner;
|
13078 | switch (orient) {
|
13079 | case "bottom":
|
13080 | lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", this.getTickSize.bind(this));
|
13081 | textUpdate.attr("x", 0).attr("y", yForText(rotate)).style("text-anchor", textAnchorForText(rotate)).style("text-anchor", (d, i, { length }) => {
|
13082 | if (!isRotated && i === 0 && (inner === true || inner.first)) {
|
13083 | return "start";
|
13084 | } else if (!isRotated && i === length - 1 && (inner === true || inner.last)) {
|
13085 | return "end";
|
13086 | }
|
13087 | return textAnchorForText(rotate);
|
13088 | }).attr("transform", textTransform(rotate));
|
13089 | break;
|
13090 | case "top":
|
13091 | lineUpdate.attr("x2", 0).attr("y2", -innerTickSize);
|
13092 | textUpdate.attr("x", 0).attr("y", -yForText(rotate) * 2).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
|
13093 | break;
|
13094 | case "left":
|
13095 | lineUpdate.attr("x2", -innerTickSize).attr("y1", tickPos.y).attr("y2", tickPos.y);
|
13096 | textUpdate.attr("x", -tickLength).attr("y", tickOffset).style("text-anchor", "end");
|
13097 | break;
|
13098 | case "right":
|
13099 | lineUpdate.attr("x2", innerTickSize).attr("y2", 0);
|
13100 | textUpdate.attr("x", tickLength).attr("y", 0).style("text-anchor", "start");
|
13101 | }
|
13102 | }
|
13103 |
|
13104 | splitTickText(d, scale, ticks, isLeftRight, charWidth) {
|
13105 | const { params } = this;
|
13106 | const tickText = this.helper.textFormatted(d);
|
13107 | const splitted = isString(tickText) && tickText.indexOf("\n") > -1 ? tickText.split("\n") : [];
|
13108 | if (splitted.length) {
|
13109 | return splitted;
|
13110 | }
|
13111 | if (isArray(tickText)) {
|
13112 | return tickText;
|
13113 | }
|
13114 | let tickWidth = params.tickWidth;
|
13115 | if (!tickWidth || tickWidth <= 0) {
|
13116 | tickWidth = isLeftRight ? 95 : params.isCategory ? (params.isInverted ? scale(ticks[0]) - scale(ticks[1]) : scale(ticks[1]) - scale(ticks[0])) - 12 : 110;
|
13117 | }
|
13118 | function split(splitted2, text) {
|
13119 | let subtext;
|
13120 | let spaceIndex;
|
13121 | let textWidth;
|
13122 | for (let i = 1; i < text.length; i++) {
|
13123 | if (text.charAt(i) === " ") {
|
13124 | spaceIndex = i;
|
13125 | }
|
13126 | subtext = text.substr(0, i + 1);
|
13127 | textWidth = charWidth * subtext.length;
|
13128 | if (tickWidth < textWidth) {
|
13129 | return split(
|
13130 | splitted2.concat(text.substr(0, spaceIndex || i)),
|
13131 | text.slice(spaceIndex ? spaceIndex + 1 : i)
|
13132 | );
|
13133 | }
|
13134 | }
|
13135 | return splitted2.concat(text);
|
13136 | }
|
13137 | return split(splitted, String(tickText));
|
13138 | }
|
13139 | scale(x) {
|
13140 | if (!arguments.length) {
|
13141 | return this.helper.scale;
|
13142 | }
|
13143 | this.helper.scale = x;
|
13144 | return this;
|
13145 | }
|
13146 | orient(x) {
|
13147 | if (!arguments.length) {
|
13148 | return this.config.orient;
|
13149 | }
|
13150 | this.config.orient = x in {
|
13151 | top: 1,
|
13152 | right: 1,
|
13153 | bottom: 1,
|
13154 | left: 1
|
13155 | } ? String(x) : "bottom";
|
13156 | return this;
|
13157 | }
|
13158 | tickFormat(format) {
|
13159 | const { config } = this;
|
13160 | if (!arguments.length) {
|
13161 | return config.tickFormat;
|
13162 | }
|
13163 | config.tickFormat = format;
|
13164 | return this;
|
13165 | }
|
13166 | tickCentered(isCentered) {
|
13167 | const { config } = this;
|
13168 | if (!arguments.length) {
|
13169 | return config.tickCentered;
|
13170 | }
|
13171 | config.tickCentered = isCentered;
|
13172 | return this;
|
13173 | }
|
13174 | |
13175 |
|
13176 |
|
13177 |
|
13178 |
|
13179 |
|
13180 | tickOffset() {
|
13181 | return this.config.tickOffset;
|
13182 | }
|
13183 | |
13184 |
|
13185 |
|
13186 |
|
13187 |
|
13188 |
|
13189 | tickInterval(size) {
|
13190 | var _a;
|
13191 | const { outerTickSize, tickOffset, tickValues } = this.config;
|
13192 | let interval;
|
13193 | if (this.params.isCategory) {
|
13194 | interval = tickOffset * 2;
|
13195 | } else {
|
13196 | const scale = (_a = this.params.owner.scale.zoom) != null ? _a : this.helper.scale;
|
13197 | const length = this.g.select("path.domain").node().getTotalLength() - outerTickSize * 2;
|
13198 | interval = length / (size || this.g.selectAll("line").size());
|
13199 | const intervalByValue = tickValues ? tickValues.map((v, i, arr) => {
|
13200 | const next = i + 1;
|
13201 | return next < arr.length ? scale(arr[next]) - scale(v) : null;
|
13202 | }).filter(Boolean) : [];
|
13203 | interval = Math.min(...intervalByValue, interval);
|
13204 | }
|
13205 | return interval === Infinity ? 0 : interval;
|
13206 | }
|
13207 | ticks(...args) {
|
13208 | const { config } = this;
|
13209 | if (!args.length) {
|
13210 | return config.tickArguments;
|
13211 | }
|
13212 | config.tickArguments = toArray(args);
|
13213 | return this;
|
13214 | }
|
13215 | tickCulling(culling) {
|
13216 | const { config } = this;
|
13217 | if (!arguments.length) {
|
13218 | return config.tickCulling;
|
13219 | }
|
13220 | config.tickCulling = culling;
|
13221 | return this;
|
13222 | }
|
13223 | tickValues(x) {
|
13224 | const { config } = this;
|
13225 | if (isFunction(x)) {
|
13226 | config.tickValues = () => x(this.helper.scale.domain());
|
13227 | } else {
|
13228 | if (!arguments.length) {
|
13229 | return config.tickValues;
|
13230 | }
|
13231 | config.tickValues = x;
|
13232 | }
|
13233 | return this;
|
13234 | }
|
13235 | setTransition(t) {
|
13236 | this.config.transition = t;
|
13237 | return this;
|
13238 | }
|
13239 | }
|
13240 |
|
13241 | ;
|
13242 | var Axis_defProp = Object.defineProperty;
|
13243 | var Axis_defNormalProp = (obj, key, value) => key in obj ? Axis_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
13244 | var Axis_publicField = (obj, key, value) => Axis_defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
13245 |
|
13246 |
|
13247 |
|
13248 |
|
13249 |
|
13250 | var Axis = ({
|
13251 | getAxisInstance: function() {
|
13252 | return this.axis || new Axis_Axis(this);
|
13253 | }
|
13254 | });
|
13255 | class Axis_Axis {
|
13256 | constructor(owner) {
|
13257 | Axis_publicField(this, "owner");
|
13258 | Axis_publicField(this, "x");
|
13259 | Axis_publicField(this, "subX");
|
13260 | Axis_publicField(this, "y");
|
13261 | Axis_publicField(this, "y2");
|
13262 | Axis_publicField(this, "axesList", {});
|
13263 | Axis_publicField(this, "tick", {
|
13264 | x: null,
|
13265 | y: null,
|
13266 | y2: null
|
13267 | });
|
13268 | Axis_publicField(this, "xs", []);
|
13269 | Axis_publicField(this, "orient", {
|
13270 | x: "bottom",
|
13271 | y: "left",
|
13272 | y2: "right",
|
13273 | subX: "bottom"
|
13274 | });
|
13275 | this.owner = owner;
|
13276 | this.setOrient();
|
13277 | }
|
13278 | getAxisClassName(id) {
|
13279 | return `${$AXIS.axis} ${$AXIS[`axis${capitalize(id)}`]}`;
|
13280 | }
|
13281 | isHorizontal($$, forHorizontal) {
|
13282 | const isRotated = $$.config.axis_rotated;
|
13283 | return forHorizontal ? isRotated : !isRotated;
|
13284 | }
|
13285 | isCategorized() {
|
13286 | const { config, state } = this.owner;
|
13287 | return config.axis_x_type.indexOf("category") >= 0 || state.hasRadar;
|
13288 | }
|
13289 | isCustomX() {
|
13290 | const { config } = this.owner;
|
13291 | return !this.isTimeSeries() && (config.data_x || notEmpty(config.data_xs));
|
13292 | }
|
13293 | isTimeSeries(id = "x") {
|
13294 | return this.owner.config[`axis_${id}_type`] === "timeseries";
|
13295 | }
|
13296 | isLog(id = "x") {
|
13297 | return this.owner.config[`axis_${id}_type`] === "log";
|
13298 | }
|
13299 | isTimeSeriesY() {
|
13300 | return this.isTimeSeries("y");
|
13301 | }
|
13302 | getAxisType(id = "x") {
|
13303 | let type = "linear";
|
13304 | if (this.isTimeSeries(id)) {
|
13305 | type = this.owner.config.axis_x_localtime ? "time" : "utc";
|
13306 | } else if (this.isLog(id)) {
|
13307 | type = "log";
|
13308 | }
|
13309 | return type;
|
13310 | }
|
13311 | |
13312 |
|
13313 |
|
13314 |
|
13315 |
|
13316 | getExtent() {
|
13317 | const $$ = this.owner;
|
13318 | const { config, scale } = $$;
|
13319 | let extent = config.axis_x_extent;
|
13320 | if (extent) {
|
13321 | if (isFunction(extent)) {
|
13322 | extent = extent.bind($$.api)($$.getXDomain($$.data.targets), scale.subX);
|
13323 | } else if (this.isTimeSeries() && extent.every(isNaN)) {
|
13324 | const fn = parseDate.bind($$);
|
13325 | extent = extent.map((v) => scale.subX(fn(v)));
|
13326 | }
|
13327 | }
|
13328 | return extent;
|
13329 | }
|
13330 | init() {
|
13331 | const $$ = this.owner;
|
13332 | const { config, $el: { main, axis }, state: { clip } } = $$;
|
13333 | const isRotated = config.axis_rotated;
|
13334 | const target = ["x", "y"];
|
13335 | config.axis_y2_show && target.push("y2");
|
13336 | target.forEach((v) => {
|
13337 | const classAxis = this.getAxisClassName(v);
|
13338 | const classLabel = $AXIS[`axis${v.toUpperCase()}Label`];
|
13339 | axis[v] = main.append("g").attr("class", classAxis).attr("clip-path", () => {
|
13340 | let res = null;
|
13341 | if (v === "x") {
|
13342 | res = clip.pathXAxis;
|
13343 | } else if (v === "y") {
|
13344 | res = clip.pathYAxis;
|
13345 | }
|
13346 | return res;
|
13347 | }).attr("transform", $$.getTranslate(v)).style("visibility", config[`axis_${v}_show`] ? null : "hidden");
|
13348 | axis[v].append("text").attr("class", classLabel).attr("transform", ["rotate(-90)", null][v === "x" ? +!isRotated : +isRotated]).style("text-anchor", () => this.textAnchorForAxisLabel(v));
|
13349 | this.generateAxes(v);
|
13350 | });
|
13351 | config.axis_tooltip && this.setAxisTooltip();
|
13352 | }
|
13353 | |
13354 |
|
13355 |
|
13356 |
|
13357 | setOrient() {
|
13358 | const $$ = this.owner;
|
13359 | const {
|
13360 | axis_rotated: isRotated,
|
13361 | axis_y_inner: yInner,
|
13362 | axis_y2_inner: y2Inner
|
13363 | } = $$.config;
|
13364 | this.orient = {
|
13365 | x: isRotated ? "left" : "bottom",
|
13366 | y: isRotated ? yInner ? "top" : "bottom" : yInner ? "right" : "left",
|
13367 | y2: isRotated ? y2Inner ? "bottom" : "top" : y2Inner ? "left" : "right",
|
13368 | subX: isRotated ? "left" : "bottom"
|
13369 | };
|
13370 | }
|
13371 | |
13372 |
|
13373 |
|
13374 |
|
13375 |
|
13376 |
|
13377 | generateAxes(id) {
|
13378 | const $$ = this.owner;
|
13379 | const { config } = $$;
|
13380 | const axes = [];
|
13381 | const axesConfig = config[`axis_${id}_axes`];
|
13382 | const isRotated = config.axis_rotated;
|
13383 | let d3Axis;
|
13384 | if (id === "x") {
|
13385 | d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisLeft : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisBottom;
|
13386 | } else if (id === "y") {
|
13387 | d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisBottom : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisLeft;
|
13388 | } else if (id === "y2") {
|
13389 | d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisTop : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisRight;
|
13390 | }
|
13391 | if (axesConfig.length) {
|
13392 | axesConfig.forEach((v) => {
|
13393 | const tick = v.tick || {};
|
13394 | const scale = $$.scale[id].copy();
|
13395 | v.domain && scale.domain(v.domain);
|
13396 | axes.push(
|
13397 | d3Axis(scale).ticks(tick.count).tickFormat(
|
13398 | isFunction(tick.format) ? tick.format.bind($$.api) : (x) => x
|
13399 | ).tickValues(tick.values).tickSizeOuter(tick.outer === false ? 0 : 6)
|
13400 | );
|
13401 | });
|
13402 | }
|
13403 | this.axesList[id] = axes;
|
13404 | }
|
13405 | |
13406 |
|
13407 |
|
13408 |
|
13409 | updateAxes() {
|
13410 | const $$ = this.owner;
|
13411 | const { config, $el: { main }, $T } = $$;
|
13412 | Object.keys(this.axesList).forEach((id) => {
|
13413 | const axesConfig = config[`axis_${id}_axes`];
|
13414 | const scale = $$.scale[id].copy();
|
13415 | const range = scale.range();
|
13416 | this.axesList[id].forEach((v, i) => {
|
13417 | const axisRange = v.scale().range();
|
13418 | if (!range.every((v2, i2) => v2 === axisRange[i2])) {
|
13419 | v.scale().range(range);
|
13420 | }
|
13421 | const className = `${this.getAxisClassName(id)}-${i + 1}`;
|
13422 | let g = main.select(`.${className.replace(/\s/, ".")}`);
|
13423 | if (g.empty()) {
|
13424 | g = main.append("g").attr("class", className).style("visibility", config[`axis_${id}_show`] ? null : "hidden").call(v);
|
13425 | } else {
|
13426 | axesConfig[i].domain && scale.domain(axesConfig[i].domain);
|
13427 | $T(g).call(v.scale(scale));
|
13428 | }
|
13429 | g.attr("transform", $$.getTranslate(id, i + 1));
|
13430 | });
|
13431 | });
|
13432 | }
|
13433 | |
13434 |
|
13435 |
|
13436 |
|
13437 |
|
13438 |
|
13439 |
|
13440 |
|
13441 |
|
13442 | setAxis(id, scale, outerTick, noTransition) {
|
13443 | const $$ = this.owner;
|
13444 | if (id !== "subX") {
|
13445 | this.tick[id] = this.getTickValues(id);
|
13446 | }
|
13447 | this[id] = this.getAxis(
|
13448 | id,
|
13449 | scale,
|
13450 | outerTick,
|
13451 |
|
13452 |
|
13453 | id === "x" && ($$.scale.zoom || $$.config.subchart_show || $$.state.resizing) ? true : noTransition
|
13454 | );
|
13455 | }
|
13456 |
|
13457 | getAxis(id, scale, outerTick, noTransition, noTickTextRotate) {
|
13458 | const $$ = this.owner;
|
13459 | const { config } = $$;
|
13460 | const isX = /^(x|subX)$/.test(id);
|
13461 | const type = isX ? "x" : id;
|
13462 | const isCategory = isX && this.isCategorized();
|
13463 | const orient = this.orient[id];
|
13464 | const tickTextRotate = noTickTextRotate ? 0 : $$.getAxisTickRotate(type);
|
13465 | let tickFormat;
|
13466 | if (isX) {
|
13467 | tickFormat = id === "subX" ? $$.format.subXAxisTick : $$.format.xAxisTick;
|
13468 | } else {
|
13469 | const fn = config[`axis_${id}_tick_format`];
|
13470 | if (isFunction(fn)) {
|
13471 | tickFormat = fn.bind($$.api);
|
13472 | }
|
13473 | }
|
13474 | let tickValues = this.tick[type];
|
13475 | const axisParams = mergeObj({
|
13476 | outerTick,
|
13477 | noTransition,
|
13478 | config,
|
13479 | id,
|
13480 | tickTextRotate,
|
13481 | owner: $$
|
13482 | }, isX && {
|
13483 | isCategory,
|
13484 | isInverted: config.axis_x_inverted,
|
13485 | tickMultiline: config.axis_x_tick_multiline,
|
13486 | tickWidth: config.axis_x_tick_width,
|
13487 | tickTitle: isCategory && config.axis_x_tick_tooltip && $$.api.categories(),
|
13488 | orgXScale: $$.scale.x
|
13489 | });
|
13490 | if (!isX) {
|
13491 | axisParams.tickStepSize = config[`axis_${type}_tick_stepSize`];
|
13492 | }
|
13493 | const axis = new AxisRenderer(axisParams).scale(isX && $$.scale.zoom || scale).orient(orient);
|
13494 | if (isX && this.isTimeSeries() && tickValues && !isFunction(tickValues)) {
|
13495 | const fn = parseDate.bind($$);
|
13496 | tickValues = tickValues.map((v) => fn(v));
|
13497 | } else if (!isX && this.isTimeSeriesY()) {
|
13498 | axis.ticks(config.axis_y_tick_time_value);
|
13499 | tickValues = null;
|
13500 | }
|
13501 | tickValues && axis.tickValues(tickValues);
|
13502 | axis.tickFormat(
|
13503 | tickFormat || !isX && ($$.isStackNormalized() && ((x) => `${x}%`))
|
13504 | );
|
13505 | if (isCategory) {
|
13506 | axis.tickCentered(config.axis_x_tick_centered);
|
13507 | if (isEmpty(config.axis_x_tick_culling)) {
|
13508 | config.axis_x_tick_culling = false;
|
13509 | }
|
13510 | }
|
13511 | const tickCount = config[`axis_${type}_tick_count`];
|
13512 | tickCount && axis.ticks(tickCount);
|
13513 | return axis;
|
13514 | }
|
13515 | updateXAxisTickValues(targets, axis) {
|
13516 | var _a;
|
13517 | const $$ = this.owner;
|
13518 | const { config } = $$;
|
13519 | const fit = config.axis_x_tick_fit;
|
13520 | let count = config.axis_x_tick_count;
|
13521 | let values;
|
13522 | if (fit || count && fit) {
|
13523 | values = $$.mapTargetsToUniqueXs(targets);
|
13524 | if (this.isCategorized() && count > values.length) {
|
13525 | count = values.length;
|
13526 | }
|
13527 | values = this.generateTickValues(
|
13528 | values,
|
13529 | count,
|
13530 | this.isTimeSeries()
|
13531 | );
|
13532 | }
|
13533 | if (axis) {
|
13534 | axis.tickValues(values);
|
13535 | } else if (this.x) {
|
13536 | this.x.tickValues(values);
|
13537 | (_a = this.subX) == null ? void 0 : _a.tickValues(values);
|
13538 | }
|
13539 | return values;
|
13540 | }
|
13541 | getId(id) {
|
13542 | const { config, scale } = this.owner;
|
13543 | let axis = config.data_axes[id];
|
13544 | if (!axis || !scale[axis]) {
|
13545 | axis = "y";
|
13546 | }
|
13547 | return axis;
|
13548 | }
|
13549 | getXAxisTickFormat(forSubchart) {
|
13550 | const $$ = this.owner;
|
13551 | const { config, format } = $$;
|
13552 | const tickFormat = forSubchart ? config.subchart_axis_x_tick_format || config.axis_x_tick_format : config.axis_x_tick_format;
|
13553 | const isTimeSeries = this.isTimeSeries();
|
13554 | const isCategorized = this.isCategorized();
|
13555 | let currFormat;
|
13556 | if (tickFormat) {
|
13557 | if (isFunction(tickFormat)) {
|
13558 | currFormat = tickFormat.bind($$.api);
|
13559 | } else if (isTimeSeries) {
|
13560 | currFormat = (date) => date ? format.axisTime(tickFormat)(date) : "";
|
13561 | }
|
13562 | } else {
|
13563 | currFormat = isTimeSeries ? format.defaultAxisTime : isCategorized ? $$.categoryName : (v) => v < 0 ? v.toFixed(0) : v;
|
13564 | }
|
13565 | return isFunction(currFormat) ? (v) => currFormat.apply($$, isCategorized ? [v, $$.categoryName(v)] : [v]) : currFormat;
|
13566 | }
|
13567 | getTickValues(id) {
|
13568 | const $$ = this.owner;
|
13569 | const tickValues = $$.config[`axis_${id}_tick_values`];
|
13570 | const axis = $$[`${id}Axis`];
|
13571 | return (isFunction(tickValues) ? tickValues.call($$.api) : tickValues) || (axis ? axis.tickValues() : void 0);
|
13572 | }
|
13573 | getLabelOptionByAxisId(id) {
|
13574 | return this.owner.config[`axis_${id}_label`];
|
13575 | }
|
13576 | getLabelText(id) {
|
13577 | const option = this.getLabelOptionByAxisId(id);
|
13578 | return isString(option) ? option : option ? option.text : null;
|
13579 | }
|
13580 | setLabelText(id, text) {
|
13581 | const $$ = this.owner;
|
13582 | const { config } = $$;
|
13583 | const option = this.getLabelOptionByAxisId(id);
|
13584 | if (isString(option)) {
|
13585 | config[`axis_${id}_label`] = text;
|
13586 | } else if (option) {
|
13587 | option.text = text;
|
13588 | }
|
13589 | }
|
13590 | getLabelPosition(id, defaultPosition) {
|
13591 | const isRotated = this.owner.config.axis_rotated;
|
13592 | const option = this.getLabelOptionByAxisId(id);
|
13593 | const position = isObjectType(option) && option.position ? option.position : defaultPosition[+!isRotated];
|
13594 | const has = (v) => !!~position.indexOf(v);
|
13595 | return {
|
13596 | isInner: has("inner"),
|
13597 | isOuter: has("outer"),
|
13598 | isLeft: has("left"),
|
13599 | isCenter: has("center"),
|
13600 | isRight: has("right"),
|
13601 | isTop: has("top"),
|
13602 | isMiddle: has("middle"),
|
13603 | isBottom: has("bottom")
|
13604 | };
|
13605 | }
|
13606 | getAxisLabelPosition(id) {
|
13607 | return this.getLabelPosition(
|
13608 | id,
|
13609 | id === "x" ? ["inner-top", "inner-right"] : ["inner-right", "inner-top"]
|
13610 | );
|
13611 | }
|
13612 | getLabelPositionById(id) {
|
13613 | return this.getAxisLabelPosition(id);
|
13614 | }
|
13615 | xForAxisLabel(id) {
|
13616 | const $$ = this.owner;
|
13617 | const { state: { width, height } } = $$;
|
13618 | const position = this.getAxisLabelPosition(id);
|
13619 | let x = position.isMiddle ? -height / 2 : 0;
|
13620 | if (this.isHorizontal($$, id !== "x")) {
|
13621 | x = position.isLeft ? 0 : position.isCenter ? width / 2 : width;
|
13622 | } else if (position.isBottom) {
|
13623 | x = -height;
|
13624 | }
|
13625 | return x;
|
13626 | }
|
13627 | dxForAxisLabel(id) {
|
13628 | const $$ = this.owner;
|
13629 | const position = this.getAxisLabelPosition(id);
|
13630 | let dx = position.isBottom ? "0.5em" : "0";
|
13631 | if (this.isHorizontal($$, id !== "x")) {
|
13632 | dx = position.isLeft ? "0.5em" : position.isRight ? "-0.5em" : "0";
|
13633 | } else if (position.isTop) {
|
13634 | dx = "-0.5em";
|
13635 | }
|
13636 | return dx;
|
13637 | }
|
13638 | textAnchorForAxisLabel(id) {
|
13639 | const $$ = this.owner;
|
13640 | const position = this.getAxisLabelPosition(id);
|
13641 | let anchor = position.isMiddle ? "middle" : "end";
|
13642 | if (this.isHorizontal($$, id !== "x")) {
|
13643 | anchor = position.isLeft ? "start" : position.isCenter ? "middle" : "end";
|
13644 | } else if (position.isBottom) {
|
13645 | anchor = "start";
|
13646 | }
|
13647 | return anchor;
|
13648 | }
|
13649 | dyForAxisLabel(id) {
|
13650 | const $$ = this.owner;
|
13651 | const { config } = $$;
|
13652 | const isRotated = config.axis_rotated;
|
13653 | const isInner = this.getAxisLabelPosition(id).isInner;
|
13654 | const tickRotate = config[`axis_${id}_tick_rotate`] ? $$.getHorizontalAxisHeight(id) : 0;
|
13655 | const { width: maxTickWidth } = this.getMaxTickSize(id);
|
13656 | let dy;
|
13657 | if (id === "x") {
|
13658 | const xHeight = config.axis_x_height;
|
13659 | if (isRotated) {
|
13660 | dy = isInner ? "1.2em" : -25 - maxTickWidth;
|
13661 | } else if (isInner) {
|
13662 | dy = "-0.5em";
|
13663 | } else if (xHeight) {
|
13664 | dy = xHeight - 10;
|
13665 | } else if (tickRotate) {
|
13666 | dy = tickRotate - 10;
|
13667 | } else {
|
13668 | dy = "3em";
|
13669 | }
|
13670 | } else {
|
13671 | dy = {
|
13672 | y: ["-0.5em", 10, "3em", "1.2em", 10],
|
13673 | y2: ["1.2em", -20, "-2.2em", "-0.5em", 15]
|
13674 | }[id];
|
13675 | if (isRotated) {
|
13676 | if (isInner) {
|
13677 | dy = dy[0];
|
13678 | } else if (tickRotate) {
|
13679 | dy = tickRotate * (id === "y2" ? -1 : 1) - dy[1];
|
13680 | } else {
|
13681 | dy = dy[2];
|
13682 | }
|
13683 | } else {
|
13684 | dy = isInner ? dy[3] : (dy[4] + (config[`axis_${id}_inner`] ? 0 : maxTickWidth + dy[4])) * (id === "y" ? -1 : 1);
|
13685 | }
|
13686 | }
|
13687 | return dy;
|
13688 | }
|
13689 | |
13690 |
|
13691 |
|
13692 |
|
13693 |
|
13694 |
|
13695 |
|
13696 | getMaxTickSize(id, withoutRecompute) {
|
13697 | const $$ = this.owner;
|
13698 | const { config, state: { current }, $el: { svg, chart } } = $$;
|
13699 | const currentTickMax = current.maxTickSize[id];
|
13700 | const configPrefix = `axis_${id}`;
|
13701 | const max = {
|
13702 | width: 0,
|
13703 | height: 0
|
13704 | };
|
13705 | if (withoutRecompute || !config[`${configPrefix}_show`] || currentTickMax.width > 0 && $$.filterTargetsToShow().length === 0) {
|
13706 | return currentTickMax;
|
13707 | }
|
13708 | if (svg) {
|
13709 | const isYAxis = /^y2?$/.test(id);
|
13710 | const targetsToShow = $$.filterTargetsToShow($$.data.targets);
|
13711 | const scale = $$.scale[id].copy().domain(
|
13712 | $$[`get${isYAxis ? "Y" : "X"}Domain`](targetsToShow, id)
|
13713 | );
|
13714 | const domain = scale.domain();
|
13715 | const isDomainSame = domain[0] === domain[1] && domain.every((v) => v > 0);
|
13716 | const isCurrentMaxTickDomainSame = isArray(currentTickMax.domain) && currentTickMax.domain[0] === currentTickMax.domain[1] && currentTickMax.domain.every((v) => v > 0);
|
13717 | if (isDomainSame || isCurrentMaxTickDomainSame) {
|
13718 | return currentTickMax.size;
|
13719 | } else {
|
13720 | currentTickMax.domain = domain;
|
13721 | }
|
13722 | if (!isYAxis) {
|
13723 | currentTickMax.ticks.splice(0);
|
13724 | }
|
13725 | const axis = this.getAxis(id, scale, false, false, true);
|
13726 | const tickRotate = config[`${configPrefix}_tick_rotate`];
|
13727 | const tickCount = config[`${configPrefix}_tick_count`];
|
13728 | const tickValues = config[`${configPrefix}_tick_values`];
|
13729 | if (!tickValues && tickCount) {
|
13730 | axis.tickValues(
|
13731 | this.generateTickValues(
|
13732 | domain,
|
13733 | tickCount,
|
13734 | isYAxis ? this.isTimeSeriesY() : this.isTimeSeries()
|
13735 | )
|
13736 | );
|
13737 | }
|
13738 | !isYAxis && this.updateXAxisTickValues(targetsToShow, axis);
|
13739 | const dummy = chart.append("svg").style("visibility", "hidden").style("position", "fixed").style("top", "0").style("left", "0");
|
13740 | axis.create(dummy);
|
13741 | dummy.selectAll("text").attr("transform", isNumber(tickRotate) ? `rotate(${tickRotate})` : null).each(function(d, i) {
|
13742 | const { width, height } = this.getBoundingClientRect();
|
13743 | max.width = Math.max(max.width, width);
|
13744 | max.height = Math.max(max.height, height);
|
13745 | if (!isYAxis) {
|
13746 | currentTickMax.ticks[i] = width;
|
13747 | }
|
13748 | });
|
13749 | dummy.remove();
|
13750 | }
|
13751 | Object.keys(max).forEach((key) => {
|
13752 | if (max[key] > 0) {
|
13753 | currentTickMax[key] = max[key];
|
13754 | }
|
13755 | });
|
13756 | return currentTickMax;
|
13757 | }
|
13758 | getXAxisTickTextY2Overflow(defaultPadding) {
|
13759 | const $$ = this.owner;
|
13760 | const { axis, config, state: { current, isLegendRight, legendItemWidth } } = $$;
|
13761 | const xAxisTickRotate = $$.getAxisTickRotate("x");
|
13762 | const positiveRotation = xAxisTickRotate > 0 && xAxisTickRotate < 90;
|
13763 | if ((axis.isCategorized() || axis.isTimeSeries()) && config.axis_x_tick_fit && (!config.axis_x_tick_culling || isEmpty(config.axis_x_tick_culling)) && !config.axis_x_tick_multiline && positiveRotation) {
|
13764 | const y2AxisWidth = config.axis_y2_show && current.maxTickSize.y2.width || 0;
|
13765 | const legendWidth = isLegendRight && legendItemWidth || 0;
|
13766 | const widthWithoutCurrentPaddingLeft = current.width - $$.getCurrentPaddingByDirection("left");
|
13767 | const maxOverflow = this.getXAxisTickMaxOverflow(
|
13768 | xAxisTickRotate,
|
13769 | widthWithoutCurrentPaddingLeft - defaultPadding
|
13770 | ) - y2AxisWidth - legendWidth;
|
13771 | const xAxisTickTextY2Overflow = Math.max(0, maxOverflow) + defaultPadding;
|
13772 | return Math.min(xAxisTickTextY2Overflow, widthWithoutCurrentPaddingLeft / 2);
|
13773 | }
|
13774 | return 0;
|
13775 | }
|
13776 | getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft) {
|
13777 | const $$ = this.owner;
|
13778 | const { axis, config, state } = $$;
|
13779 | const isTimeSeries = axis.isTimeSeries();
|
13780 | const tickTextWidths = state.current.maxTickSize.x.ticks;
|
13781 | const tickCount = tickTextWidths.length;
|
13782 | const { left, right } = state.axis.x.padding;
|
13783 | let maxOverflow = 0;
|
13784 | const remaining = tickCount - (isTimeSeries && config.axis_x_tick_fit ? 0.5 : 0);
|
13785 | for (let i = 0; i < tickCount; i++) {
|
13786 | const tickIndex = i + 1;
|
13787 | const rotatedTickTextWidth = Math.cos(Math.PI * xAxisTickRotate / 180) * tickTextWidths[i];
|
13788 | const ticksBeforeTickText = tickIndex - (isTimeSeries ? 1 : 0.5) + left;
|
13789 | if (ticksBeforeTickText <= 0) {
|
13790 | continue;
|
13791 | }
|
13792 | const xAxisLengthWithoutTickTextWidth = widthWithoutCurrentPaddingLeft - rotatedTickTextWidth;
|
13793 | const tickLength = xAxisLengthWithoutTickTextWidth / ticksBeforeTickText;
|
13794 | const remainingTicks = remaining - tickIndex;
|
13795 | const paddingRightLength = right * tickLength;
|
13796 | const remainingTickWidth = remainingTicks * tickLength + paddingRightLength;
|
13797 | const overflow = rotatedTickTextWidth - tickLength / 2 - remainingTickWidth;
|
13798 | maxOverflow = Math.max(maxOverflow, overflow);
|
13799 | }
|
13800 | const filteredTargets = $$.filterTargetsToShow($$.data.targets);
|
13801 | let tickOffset = 0;
|
13802 | if (!isTimeSeries && config.axis_x_tick_count <= filteredTargets.length && filteredTargets[0].values.length) {
|
13803 | const scale = getScale(
|
13804 | $$.axis.getAxisType("x"),
|
13805 | 0,
|
13806 | widthWithoutCurrentPaddingLeft - maxOverflow
|
13807 | ).domain([
|
13808 | left * -1,
|
13809 | $$.getXDomainMax($$.data.targets) + 1 + right
|
13810 | ]);
|
13811 | tickOffset = (scale(1) - scale(0)) / 2;
|
13812 | }
|
13813 | return maxOverflow + tickOffset;
|
13814 | }
|
13815 | updateLabels(withTransition) {
|
13816 | const $$ = this.owner;
|
13817 | const { $el: { main }, $T } = $$;
|
13818 | const labels = {
|
13819 | x: main.select(`.${$AXIS.axisX} .${$AXIS.axisXLabel}`),
|
13820 | y: main.select(`.${$AXIS.axisY} .${$AXIS.axisYLabel}`),
|
13821 | y2: main.select(`.${$AXIS.axisY2} .${$AXIS.axisY2Label}`)
|
13822 | };
|
13823 | Object.keys(labels).filter((id) => !labels[id].empty()).forEach((v) => {
|
13824 | const node = labels[v];
|
13825 | $T(node, withTransition).attr("x", () => this.xForAxisLabel(v)).attr("dx", () => this.dxForAxisLabel(v)).attr("dy", () => this.dyForAxisLabel(v)).text(() => this.getLabelText(v));
|
13826 | });
|
13827 | }
|
13828 | |
13829 |
|
13830 |
|
13831 |
|
13832 |
|
13833 |
|
13834 |
|
13835 |
|
13836 |
|
13837 | getPadding(padding, key, defaultValue, domainLength) {
|
13838 | const p = isNumber(padding) ? padding : padding[key];
|
13839 | if (!isValue(p)) {
|
13840 | return defaultValue;
|
13841 | }
|
13842 | return this.owner.convertPixelToScale(
|
13843 | /(bottom|top)/.test(key) ? "y" : "x",
|
13844 | p,
|
13845 | domainLength
|
13846 | );
|
13847 | }
|
13848 | generateTickValues(values, tickCount, forTimeSeries) {
|
13849 | let tickValues = values;
|
13850 | if (tickCount) {
|
13851 | const targetCount = isFunction(tickCount) ? tickCount() : tickCount;
|
13852 | if (targetCount === 1) {
|
13853 | tickValues = [values[0]];
|
13854 | } else if (targetCount === 2) {
|
13855 | tickValues = [values[0], values[values.length - 1]];
|
13856 | } else if (targetCount > 2) {
|
13857 | const isCategorized = this.isCategorized();
|
13858 | const count = targetCount - 2;
|
13859 | const start = values[0];
|
13860 | const end = values[values.length - 1];
|
13861 | const interval = (end - start) / (count + 1);
|
13862 | let tickValue;
|
13863 | tickValues = [start];
|
13864 | for (let i = 0; i < count; i++) {
|
13865 | tickValue = +start + interval * (i + 1);
|
13866 | tickValues.push(
|
13867 | forTimeSeries ? new Date(tickValue) : isCategorized ? Math.round(tickValue) : tickValue
|
13868 | );
|
13869 | }
|
13870 | tickValues.push(end);
|
13871 | }
|
13872 | }
|
13873 | if (!forTimeSeries) {
|
13874 | tickValues = tickValues.sort((a, b) => a - b);
|
13875 | }
|
13876 | return tickValues;
|
13877 | }
|
13878 | generateTransitions(withTransition) {
|
13879 | const $$ = this.owner;
|
13880 | const { $el: { axis }, $T } = $$;
|
13881 | const [axisX, axisY, axisY2, axisSubX] = ["x", "y", "y2", "subX"].map((v) => $T(axis[v], withTransition));
|
13882 | return { axisX, axisY, axisY2, axisSubX };
|
13883 | }
|
13884 | redraw(transitions, isHidden, isInit) {
|
13885 | const $$ = this.owner;
|
13886 | const { config, $el } = $$;
|
13887 | const opacity = isHidden ? "0" : null;
|
13888 | ["x", "y", "y2", "subX"].forEach((id) => {
|
13889 | const axis = this[id];
|
13890 | const $axis = $el.axis[id];
|
13891 | if (axis && $axis) {
|
13892 | if (!isInit && !config.transition_duration) {
|
13893 | axis.config.withoutTransition = true;
|
13894 | }
|
13895 | $axis.style("opacity", opacity);
|
13896 | axis.create(transitions[`axis${capitalize(id)}`]);
|
13897 | }
|
13898 | });
|
13899 | this.updateAxes();
|
13900 | }
|
13901 | |
13902 |
|
13903 |
|
13904 |
|
13905 |
|
13906 |
|
13907 |
|
13908 |
|
13909 |
|
13910 | redrawAxis(targetsToShow, wth, transitions, flow, isInit) {
|
13911 | var _a, _b, _c;
|
13912 | const $$ = this.owner;
|
13913 | const { config, scale, $el } = $$;
|
13914 | const hasZoom = !!scale.zoom;
|
13915 | let xDomainForZoom;
|
13916 | if (!hasZoom && this.isCategorized() && targetsToShow.length === 0) {
|
13917 | scale.x.domain([0, $el.axis.x.selectAll(".tick").size()]);
|
13918 | }
|
13919 | if (scale.x && targetsToShow.length) {
|
13920 | !hasZoom && $$.updateXDomain(
|
13921 | targetsToShow,
|
13922 | wth.UpdateXDomain,
|
13923 | wth.UpdateOrgXDomain,
|
13924 | wth.TrimXDomain
|
13925 | );
|
13926 | if (!config.axis_x_tick_values) {
|
13927 | this.updateXAxisTickValues(targetsToShow);
|
13928 | }
|
13929 | } else if (this.x) {
|
13930 | this.x.tickValues([]);
|
13931 | (_a = this.subX) == null ? void 0 : _a.tickValues([]);
|
13932 | }
|
13933 | if (config.zoom_rescale && !flow) {
|
13934 | xDomainForZoom = scale.x.orgDomain();
|
13935 | }
|
13936 | ["y", "y2"].forEach((key) => {
|
13937 | const prefix = `axis_${key}_`;
|
13938 | const axisScale = scale[key];
|
13939 | if (axisScale) {
|
13940 | const tickValues = config[`${prefix}tick_values`];
|
13941 | const tickCount = config[`${prefix}tick_count`];
|
13942 | axisScale.domain($$.getYDomain(targetsToShow, key, xDomainForZoom));
|
13943 | if (!tickValues && tickCount) {
|
13944 | const axis = $$.axis[key];
|
13945 | const domain = axisScale.domain();
|
13946 | axis.tickValues(
|
13947 | this.generateTickValues(
|
13948 | domain,
|
13949 | domain.every((v) => v === 0) ? 1 : tickCount,
|
13950 | this.isTimeSeriesY()
|
13951 | )
|
13952 | );
|
13953 | }
|
13954 | }
|
13955 | });
|
13956 | this.redraw(transitions, $$.hasArcType(), isInit);
|
13957 | this.updateLabels(wth.Transition);
|
13958 | if ((wth.UpdateXDomain || wth.UpdateXAxis || wth.Y) && targetsToShow.length) {
|
13959 | this.setCulling();
|
13960 | }
|
13961 | if (wth.Y) {
|
13962 | (_b = scale.subY) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y"));
|
13963 | (_c = scale.subY2) == null ? void 0 : _c.domain($$.getYDomain(targetsToShow, "y2"));
|
13964 | }
|
13965 | }
|
13966 | |
13967 |
|
13968 |
|
13969 |
|
13970 | setCulling() {
|
13971 | const $$ = this.owner;
|
13972 | const { config, state: { clip, current }, $el } = $$;
|
13973 | ["subX", "x", "y", "y2"].forEach((type) => {
|
13974 | const axis = $el.axis[type];
|
13975 | const id = type === "subX" ? "x" : type;
|
13976 | const cullingOptionPrefix = `axis_${id}_tick_culling`;
|
13977 | const toCull = config[cullingOptionPrefix];
|
13978 | if (axis && toCull) {
|
13979 | const tickNodes = axis.selectAll(".tick");
|
13980 | const tickValues = sortValue(tickNodes.data());
|
13981 | const tickSize = tickValues.length;
|
13982 | const cullingMax = config[`${cullingOptionPrefix}_max`];
|
13983 | const lines = config[`${cullingOptionPrefix}_lines`];
|
13984 | let intervalForCulling;
|
13985 | if (tickSize) {
|
13986 | for (let i = 1; i < tickSize; i++) {
|
13987 | if (tickSize / i < cullingMax) {
|
13988 | intervalForCulling = i;
|
13989 | break;
|
13990 | }
|
13991 | }
|
13992 | tickNodes.each(function(d) {
|
13993 | const node = lines ? this.querySelector("text") : this;
|
13994 | if (node) {
|
13995 | node.style.display = tickValues.indexOf(d) % intervalForCulling ? "none" : null;
|
13996 | }
|
13997 | });
|
13998 | } else {
|
13999 | tickNodes.style("display", null);
|
14000 | }
|
14001 | if (type === "x") {
|
14002 | const clipPath = current.maxTickSize.x.clipPath ? clip.pathXAxisTickTexts : null;
|
14003 | $el.svg.selectAll(`.${$AXIS.axisX} .tick text`).attr("clip-path", clipPath);
|
14004 | }
|
14005 | }
|
14006 | });
|
14007 | }
|
14008 | |
14009 |
|
14010 |
|
14011 |
|
14012 | setAxisTooltip() {
|
14013 | var _a;
|
14014 | const $$ = this.owner;
|
14015 | const { config: { axis_rotated: isRotated, axis_tooltip }, $el: { axis, axisTooltip } } = $$;
|
14016 | const bgColor = (_a = axis_tooltip.backgroundColor) != null ? _a : "black";
|
14017 | $$.generateTextBGColorFilter(
|
14018 | bgColor,
|
14019 | {
|
14020 | x: -0.15,
|
14021 | y: -0.2,
|
14022 | width: 1.3,
|
14023 | height: 1.3
|
14024 | }
|
14025 | );
|
14026 | ["x", "y", "y2"].forEach((v) => {
|
14027 | var _a2, _b, _c;
|
14028 | axisTooltip[v] = (_a2 = axis[v]) == null ? void 0 : _a2.append("text").classed($AXIS[`axis${v.toUpperCase()}Tooltip`], true).attr("filter", $$.updateTextBGColor({ id: v }, bgColor));
|
14029 | if (isRotated) {
|
14030 | const pos = v === "x" ? "x" : "y";
|
14031 | const val = v === "y" ? "1.15em" : v === "x" ? "-0.3em" : "-0.4em";
|
14032 | (_b = axisTooltip[v]) == null ? void 0 : _b.attr(pos, val).attr(`d${v === "x" ? "y" : "x"}`, v === "x" ? "0.4em" : "-1.3em").style("text-anchor", v === "x" ? "end" : null);
|
14033 | } else {
|
14034 | const pos = v === "x" ? "y" : "x";
|
14035 | const val = v === "x" ? "1.15em" : `${v === "y" ? "-" : ""}0.4em`;
|
14036 | (_c = axisTooltip[v]) == null ? void 0 : _c.attr(pos, val).attr(`d${v === "x" ? "x" : "y"}`, v === "x" ? "-1em" : "0.3em").style("text-anchor", v === "y" ? "end" : null);
|
14037 | }
|
14038 | });
|
14039 | }
|
14040 | }
|
14041 |
|
14042 | ;
|
14043 |
|
14044 |
|
14045 | var eventrect = ({
|
14046 | |
14047 |
|
14048 |
|
14049 |
|
14050 |
|
14051 | initEventRect() {
|
14052 | const $$ = this;
|
14053 | $$.$el.main.select(`.${$COMMON.chart}`).append("g").attr("class", $EVENT.eventRects).style("fill-opacity", "0");
|
14054 | },
|
14055 | |
14056 |
|
14057 |
|
14058 |
|
14059 | redrawEventRect() {
|
14060 | var _a;
|
14061 | const $$ = this;
|
14062 | const { config, state, $el } = $$;
|
14063 | const isMultipleX = $$.isMultipleX();
|
14064 | const isInverted = config.axis_x_inverted;
|
14065 | if ($el.eventRect) {
|
14066 | $$.updateEventRect($el.eventRect, true);
|
14067 | } else if ($$.data.targets.length) {
|
14068 | const eventRects = $$.$el.main.select(`.${$EVENT.eventRects}`).style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ? config.axis_rotated ? "ns-resize" : "ew-resize" : null).classed($EVENT.eventRectsMultiple, isMultipleX).classed($EVENT.eventRectsSingle, !isMultipleX);
|
14069 | const eventRectUpdate = eventRects.selectAll(`.${$EVENT.eventRect}`).data([0]).enter().append("rect");
|
14070 | $$.updateEventRect(eventRectUpdate);
|
14071 | $$.updateEventType(eventRectUpdate);
|
14072 | eventRectUpdate.call($$.getDraggableSelection());
|
14073 | $el.eventRect = eventRectUpdate;
|
14074 | if ($$.state.inputType === "touch" && !$el.svg.on("touchstart.eventRect") && !$$.hasArcType()) {
|
14075 | $$.bindTouchOnEventRect();
|
14076 | }
|
14077 | state.rendered && $$.updateEventRect($el.eventRect, true);
|
14078 | }
|
14079 | if (!isMultipleX) {
|
14080 | const xAxisTickValues = $$.getMaxDataCountTarget();
|
14081 | if (!config.data_xSort || isInverted) {
|
14082 | xAxisTickValues.sort((a, b) => isInverted ? b.x - a.x : a.x - b.x);
|
14083 | }
|
14084 | $$.updateDataIndexByX(xAxisTickValues);
|
14085 | $$.updateXs(xAxisTickValues);
|
14086 | (_a = $$.updatePointClass) == null ? void 0 : _a.call($$, true);
|
14087 | state.eventReceiver.data = xAxisTickValues;
|
14088 | }
|
14089 | $$.updateEventRectData();
|
14090 | },
|
14091 | bindTouchOnEventRect() {
|
14092 | const $$ = this;
|
14093 | const { config, state, $el: { eventRect, svg } } = $$;
|
14094 | const selectRect = (context) => {
|
14095 | if ($$.isMultipleX()) {
|
14096 | $$.selectRectForMultipleXs(context);
|
14097 | } else {
|
14098 | const index = $$.getDataIndexFromEvent(state.event);
|
14099 | $$.callOverOutForTouch(index);
|
14100 | index === -1 ? $$.unselectRect() : $$.selectRectForSingle(context, index);
|
14101 | }
|
14102 | };
|
14103 | const unselectRect = () => {
|
14104 | $$.unselectRect();
|
14105 | $$.callOverOutForTouch();
|
14106 | };
|
14107 | const preventDefault = config.interaction_inputType_touch.preventDefault;
|
14108 | const isPrevented = isBoolean(preventDefault) && preventDefault || false;
|
14109 | const preventThreshold = !isNaN(preventDefault) && preventDefault || null;
|
14110 | let startPx;
|
14111 | const preventEvent = (event) => {
|
14112 | const eventType = event.type;
|
14113 | const touch = event.changedTouches[0];
|
14114 | const currentXY = touch[`client${config.axis_rotated ? "Y" : "X"}`];
|
14115 | if (eventType === "touchstart") {
|
14116 | if (isPrevented) {
|
14117 | event.preventDefault();
|
14118 | } else if (preventThreshold !== null) {
|
14119 | startPx = currentXY;
|
14120 | }
|
14121 | } else if (eventType === "touchmove") {
|
14122 | if (isPrevented || startPx === true || preventThreshold !== null && Math.abs(startPx - currentXY) >= preventThreshold) {
|
14123 | startPx = true;
|
14124 | event.preventDefault();
|
14125 | }
|
14126 | }
|
14127 | };
|
14128 | eventRect.on("touchstart", (event) => {
|
14129 | state.event = event;
|
14130 | $$.updateEventRect();
|
14131 | }).on("touchstart.eventRect touchmove.eventRect", (event) => {
|
14132 | state.event = event;
|
14133 | if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
|
14134 | if (state.dragging || state.flowing || $$.hasArcType() || event.touches.length > 1) {
|
14135 | return;
|
14136 | }
|
14137 | preventEvent(event);
|
14138 | selectRect(eventRect.node());
|
14139 | } else {
|
14140 | unselectRect();
|
14141 | }
|
14142 | }, true).on("touchend.eventRect", (event) => {
|
14143 | state.event = event;
|
14144 | if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
|
14145 | if ($$.hasArcType() || !$$.toggleShape || state.cancelClick) {
|
14146 | state.cancelClick && (state.cancelClick = false);
|
14147 | }
|
14148 | }
|
14149 | }, true);
|
14150 | svg.on("touchstart", (event) => {
|
14151 | state.event = event;
|
14152 | const { target } = event;
|
14153 | if (target && target !== eventRect.node()) {
|
14154 | unselectRect();
|
14155 | }
|
14156 | });
|
14157 | },
|
14158 | |
14159 |
|
14160 |
|
14161 |
|
14162 |
|
14163 |
|
14164 | updateEventRect(eventRect, force = false) {
|
14165 | const $$ = this;
|
14166 | const { state, $el } = $$;
|
14167 | const { eventReceiver, width, height, rendered, resizing } = state;
|
14168 | const rectElement = eventRect || $el.eventRect;
|
14169 | const updateClientRect = () => {
|
14170 | if (eventReceiver) {
|
14171 | const scrollPos = getScrollPosition($el.chart.node());
|
14172 | eventReceiver.rect = rectElement.node().getBoundingClientRect().toJSON();
|
14173 | eventReceiver.rect.top += scrollPos.y;
|
14174 | eventReceiver.rect.left += scrollPos.x;
|
14175 | }
|
14176 | };
|
14177 | if (!rendered || resizing || force) {
|
14178 | rectElement.attr("x", 0).attr("y", 0).attr("width", width).attr("height", height);
|
14179 | if (!rendered || force) {
|
14180 | rectElement.classed($EVENT.eventRect, true);
|
14181 | }
|
14182 | }
|
14183 | updateClientRect();
|
14184 | },
|
14185 | |
14186 |
|
14187 |
|
14188 |
|
14189 | updateEventType(target) {
|
14190 | const $$ = this;
|
14191 | const isRebindCall = isBoolean(target);
|
14192 | const eventRect = isRebindCall ? $$.$el.eventRect : target;
|
14193 | const unbindEvent = isRebindCall ? target !== (eventRect == null ? void 0 : eventRect.datum().multipleX) : false;
|
14194 | if (eventRect) {
|
14195 | unbindEvent && (eventRect == null ? void 0 : eventRect.on("mouseover mousemove mouseout click", null));
|
14196 | $$.isMultipleX() ? $$.generateEventRectsForMultipleXs(eventRect) : $$.generateEventRectsForSingleX(eventRect);
|
14197 | }
|
14198 | },
|
14199 | |
14200 |
|
14201 |
|
14202 |
|
14203 | updateEventRectData() {
|
14204 | const $$ = this;
|
14205 | const { config, scale, state } = $$;
|
14206 | const xScale = scale.zoom || scale.x;
|
14207 | const isRotated = config.axis_rotated;
|
14208 | const isMultipleX = $$.isMultipleX();
|
14209 | let x;
|
14210 | let y;
|
14211 | let w;
|
14212 | let h;
|
14213 | $$.updateEventType(isMultipleX);
|
14214 | if (isMultipleX) {
|
14215 | x = 0;
|
14216 | y = 0;
|
14217 | w = state.width;
|
14218 | h = state.height;
|
14219 | } else {
|
14220 | let rectW;
|
14221 | let rectX;
|
14222 | if ($$.axis.isCategorized()) {
|
14223 | rectW = $$.getEventRectWidth();
|
14224 | rectX = (d) => xScale(d.x) - rectW / 2;
|
14225 | } else {
|
14226 | const getPrevNextX = ({ index }) => ({
|
14227 | prev: $$.getPrevX(index),
|
14228 | next: $$.getNextX(index)
|
14229 | });
|
14230 | rectW = (d) => {
|
14231 | const x2 = getPrevNextX(d);
|
14232 | const xDomain = xScale.domain();
|
14233 | let val;
|
14234 | if (x2.prev === null && x2.next === null) {
|
14235 | val = isRotated ? state.height : state.width;
|
14236 | } else if (x2.prev === null) {
|
14237 | val = (xScale(x2.next) + xScale(d.x)) / 2;
|
14238 | } else if (x2.next === null) {
|
14239 | val = xScale(xDomain[1]) - (xScale(x2.prev) + xScale(d.x)) / 2;
|
14240 | } else {
|
14241 | Object.keys(x2).forEach((key, i) => {
|
14242 | var _a;
|
14243 | x2[key] = (_a = x2[key]) != null ? _a : xDomain[i];
|
14244 | });
|
14245 | val = Math.max(0, (xScale(x2.next) - xScale(x2.prev)) / 2);
|
14246 | }
|
14247 | return val;
|
14248 | };
|
14249 | rectX = (d) => {
|
14250 | const x2 = getPrevNextX(d);
|
14251 | let val;
|
14252 | if (x2.prev === null && x2.next === null) {
|
14253 | val = 0;
|
14254 | } else if (x2.prev === null) {
|
14255 | val = xScale(xScale.domain()[0]);
|
14256 | } else {
|
14257 | val = (xScale(d.x) + xScale(x2.prev)) / 2;
|
14258 | }
|
14259 | return val;
|
14260 | };
|
14261 | }
|
14262 | x = isRotated ? 0 : rectX;
|
14263 | y = isRotated ? rectX : 0;
|
14264 | w = isRotated ? state.width : rectW;
|
14265 | h = isRotated ? rectW : state.height;
|
14266 | }
|
14267 | const { eventReceiver } = state;
|
14268 | const call = (fn, v) => isFunction(fn) ? fn(v) : fn;
|
14269 | eventReceiver.coords.splice(eventReceiver.data.length);
|
14270 | eventReceiver.data.forEach((d, i) => {
|
14271 | eventReceiver.coords[i] = {
|
14272 | x: call(x, d),
|
14273 | y: call(y, d),
|
14274 | w: call(w, d),
|
14275 | h: call(h, d)
|
14276 | };
|
14277 | });
|
14278 | },
|
14279 | |
14280 |
|
14281 |
|
14282 |
|
14283 |
|
14284 |
|
14285 | selectRectForSingle(context, index) {
|
14286 | var _a, _b;
|
14287 | const $$ = this;
|
14288 | const { config, $el: { main, circle } } = $$;
|
14289 | const isSelectionEnabled = config.data_selection_enabled;
|
14290 | const isSelectionGrouped = config.data_selection_grouped;
|
14291 | const isSelectable = config.data_selection_isselectable;
|
14292 | const isTooltipGrouped = config.tooltip_grouped;
|
14293 | const selectedData = $$.getAllValuesOnIndex(index);
|
14294 | if (isTooltipGrouped) {
|
14295 | $$.showTooltip(selectedData, context);
|
14296 | (_a = $$.showGridFocus) == null ? void 0 : _a.call($$, selectedData);
|
14297 | if (!isSelectionEnabled || isSelectionGrouped) {
|
14298 | return;
|
14299 | }
|
14300 | }
|
14301 | !circle && main.selectAll(`.${$COMMON.EXPANDED}:not(.${$SHAPE.shape}-${index})`).classed(
|
14302 | $COMMON.EXPANDED,
|
14303 | false
|
14304 | );
|
14305 | const shapeAtIndex = main.selectAll(`.${$SHAPE.shape}-${index}`).classed($COMMON.EXPANDED, true).style("cursor", isSelectable ? "pointer" : null).filter(function(d) {
|
14306 | return $$.isWithinShape(this, d);
|
14307 | });
|
14308 | if (shapeAtIndex.empty() && !isTooltipGrouped && config.interaction_onout) {
|
14309 | (_b = $$.hideGridFocus) == null ? void 0 : _b.call($$);
|
14310 | $$.hideTooltip();
|
14311 | !isSelectionGrouped && $$.setExpand(index);
|
14312 | }
|
14313 | shapeAtIndex.call((selected) => {
|
14314 | var _a2, _b2;
|
14315 | const d = selected.data();
|
14316 | if (isSelectionEnabled && (isSelectionGrouped || (isSelectable == null ? void 0 : isSelectable.bind($$.api)(d)))) {
|
14317 | context.style.cursor = "pointer";
|
14318 | }
|
14319 | if (!isTooltipGrouped) {
|
14320 | $$.showTooltip(d, context);
|
14321 | (_a2 = $$.showGridFocus) == null ? void 0 : _a2.call($$, d);
|
14322 | (_b2 = $$.unexpandCircles) == null ? void 0 : _b2.call($$);
|
14323 | selected.each((d2) => $$.setExpand(index, d2.id));
|
14324 | }
|
14325 | });
|
14326 | },
|
14327 | |
14328 |
|
14329 |
|
14330 |
|
14331 |
|
14332 |
|
14333 | selectRectForMultipleXs(context, triggerEvent = true) {
|
14334 | const $$ = this;
|
14335 | const { config, state } = $$;
|
14336 | const targetsToShow = $$.filterTargetsToShow($$.data.targets);
|
14337 | if (state.dragging || $$.hasArcType(targetsToShow)) {
|
14338 | return;
|
14339 | }
|
14340 | const mouse = getPointer(state.event, context);
|
14341 | const closest = $$.findClosestFromTargets(targetsToShow, mouse);
|
14342 | if (triggerEvent && state.mouseover && (!closest || closest.id !== state.mouseover.id)) {
|
14343 | config.data_onout.call($$.api, state.mouseover);
|
14344 | state.mouseover = void 0;
|
14345 | }
|
14346 | if (!closest) {
|
14347 | $$.unselectRect();
|
14348 | return;
|
14349 | }
|
14350 | const sameXData = $$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped ? [closest] : $$.filterByX(targetsToShow, closest.x);
|
14351 | const selectedData = sameXData.map((d) => $$.addName(d));
|
14352 | $$.showTooltip(selectedData, context);
|
14353 | $$.setExpand(closest.index, closest.id, true);
|
14354 | $$.showGridFocus(selectedData);
|
14355 | const dist = $$.dist(closest, mouse);
|
14356 | if ($$.isBarType(closest.id) || dist < $$.getPointSensitivity(closest)) {
|
14357 | $$.$el.svg.select(`.${$EVENT.eventRect}`).style("cursor", "pointer");
|
14358 | if (triggerEvent && !state.mouseover) {
|
14359 | config.data_onover.call($$.api, closest);
|
14360 | state.mouseover = closest;
|
14361 | }
|
14362 | }
|
14363 | },
|
14364 | |
14365 |
|
14366 |
|
14367 |
|
14368 | unselectRect() {
|
14369 | const $$ = this;
|
14370 | const { $el: { circle, tooltip } } = $$;
|
14371 | $$.$el.svg.select(`.${$EVENT.eventRect}`).style("cursor", null);
|
14372 | $$.hideGridFocus();
|
14373 | if (tooltip) {
|
14374 | $$.hideTooltip();
|
14375 | $$._handleLinkedCharts(false);
|
14376 | }
|
14377 | circle && !$$.isPointFocusOnly() && $$.unexpandCircles();
|
14378 | $$.expandBarTypeShapes(false);
|
14379 | },
|
14380 | |
14381 |
|
14382 |
|
14383 |
|
14384 |
|
14385 |
|
14386 |
|
14387 | generateEventRectsForSingleX(eventRectEnter) {
|
14388 | const $$ = this;
|
14389 | const { config, state } = $$;
|
14390 | const { eventReceiver } = state;
|
14391 | const rect = eventRectEnter.style(
|
14392 | "cursor",
|
14393 | config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null
|
14394 | ).on("click", function(event) {
|
14395 | state.event = event;
|
14396 | const { currentIdx, data } = eventReceiver;
|
14397 | const d = data[currentIdx === -1 ? $$.getDataIndexFromEvent(event) : currentIdx];
|
14398 | $$.clickHandlerForSingleX.bind(this)(d, $$);
|
14399 | }).datum({ multipleX: false });
|
14400 | if (state.inputType === "mouse") {
|
14401 | const getData = (event) => {
|
14402 | const index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
|
14403 | return index > -1 ? eventReceiver.data[index] : null;
|
14404 | };
|
14405 | rect.on("mouseover", (event) => {
|
14406 | state.event = event;
|
14407 | $$.updateEventRect();
|
14408 | Object.values($$.$el.axisTooltip).forEach((v) => v == null ? void 0 : v.style("display", null));
|
14409 | }).on("mousemove", function(event) {
|
14410 | const d = getData(event);
|
14411 | state.event = event;
|
14412 | if (!d) {
|
14413 | return;
|
14414 | }
|
14415 | let { index } = d;
|
14416 | const stepType = config.line_step_type;
|
14417 | if (config.line_step_tooltipMatch && $$.hasType("step") && /^step\-(before|after)$/.test(stepType)) {
|
14418 | const scale = $$.scale.zoom || $$.scale.x;
|
14419 | const xs = $$.axis.xs[index];
|
14420 | const inverted = scale.invert(getPointer(event, this)[0]);
|
14421 | if (stepType === "step-after" && inverted < xs) {
|
14422 | index -= 1;
|
14423 | } else if (stepType === "step-before" && inverted > xs) {
|
14424 | index += 1;
|
14425 | }
|
14426 | }
|
14427 | $$.showAxisGridFocus();
|
14428 | const eventOnSameIdx = config.tooltip_grouped && index === eventReceiver.currentIdx;
|
14429 | if (state.dragging || state.flowing || $$.hasArcType() || eventOnSameIdx) {
|
14430 | config.tooltip_show && eventOnSameIdx && $$.setTooltipPosition();
|
14431 | return;
|
14432 | }
|
14433 | if (index !== eventReceiver.currentIdx) {
|
14434 | $$.setOverOut(false, eventReceiver.currentIdx);
|
14435 | eventReceiver.currentIdx = index;
|
14436 | }
|
14437 | index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, index);
|
14438 | $$.setOverOut(index !== -1, index);
|
14439 | }).on("mouseout", (event) => {
|
14440 | state.event = event;
|
14441 | if (!config || $$.hasArcType() || eventReceiver.currentIdx === -1 || !config.interaction_onout) {
|
14442 | return;
|
14443 | }
|
14444 | $$.hideAxisGridFocus();
|
14445 | $$.unselectRect();
|
14446 | $$.setOverOut(false, eventReceiver.currentIdx);
|
14447 | eventReceiver.currentIdx = -1;
|
14448 | });
|
14449 | }
|
14450 | return rect;
|
14451 | },
|
14452 | clickHandlerForSingleX(d, ctx) {
|
14453 | const $$ = ctx;
|
14454 | const { config, state, $el: { main } } = $$;
|
14455 | if (!d || $$.hasArcType() || state.cancelClick) {
|
14456 | state.cancelClick && (state.cancelClick = false);
|
14457 | return;
|
14458 | }
|
14459 | const { index } = d;
|
14460 | main.selectAll(`.${$SHAPE.shape}-${index}`).each(function(d2) {
|
14461 | var _a;
|
14462 | if (config.data_selection_grouped || $$.isWithinShape(this, d2)) {
|
14463 | (_a = $$.toggleShape) == null ? void 0 : _a.call($$, this, d2, index);
|
14464 | config.data_onclick.bind($$.api)(d2, this);
|
14465 | }
|
14466 | });
|
14467 | },
|
14468 | |
14469 |
|
14470 |
|
14471 |
|
14472 |
|
14473 |
|
14474 | generateEventRectsForMultipleXs(eventRectEnter) {
|
14475 | const $$ = this;
|
14476 | const { config, state } = $$;
|
14477 | eventRectEnter.on("click", function(event) {
|
14478 | state.event = event;
|
14479 | $$.clickHandlerForMultipleXS.bind(this)($$);
|
14480 | }).datum({ multipleX: true });
|
14481 | if (state.inputType === "mouse") {
|
14482 | eventRectEnter.on("mouseover mousemove", function(event) {
|
14483 | state.event = event;
|
14484 | $$.selectRectForMultipleXs(this);
|
14485 | }).on("mouseout", (event) => {
|
14486 | state.event = event;
|
14487 | if (!$$.config || $$.hasArcType() || !config.interaction_onout) {
|
14488 | return;
|
14489 | }
|
14490 | $$.unselectRect();
|
14491 | });
|
14492 | }
|
14493 | },
|
14494 | clickHandlerForMultipleXS(ctx) {
|
14495 | const $$ = ctx;
|
14496 | const { config, state } = $$;
|
14497 | const targetsToShow = $$.filterTargetsToShow($$.data.targets);
|
14498 | if ($$.hasArcType(targetsToShow)) {
|
14499 | return;
|
14500 | }
|
14501 | const mouse = getPointer(state.event, this);
|
14502 | const closest = $$.findClosestFromTargets(targetsToShow, mouse);
|
14503 | const sensitivity = $$.getPointSensitivity(closest);
|
14504 | if (!closest) {
|
14505 | return;
|
14506 | }
|
14507 | if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < sensitivity) {
|
14508 | $$.$el.main.selectAll(`.${$SHAPE.shapes}${$$.getTargetSelectorSuffix(closest.id)}`).selectAll(`.${$SHAPE.shape}-${closest.index}`).each(function() {
|
14509 | var _a;
|
14510 | if (config.data_selection_grouped || $$.isWithinShape(this, closest)) {
|
14511 | (_a = $$.toggleShape) == null ? void 0 : _a.call($$, this, closest, closest.index);
|
14512 | config.data_onclick.bind($$.api)(closest, this);
|
14513 | }
|
14514 | });
|
14515 | }
|
14516 | }
|
14517 | });
|
14518 |
|
14519 |
|
14520 | var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack_require__(12);
|
14521 | ;
|
14522 |
|
14523 |
|
14524 |
|
14525 |
|
14526 | var interactions_flow = ({
|
14527 | |
14528 |
|
14529 |
|
14530 |
|
14531 |
|
14532 |
|
14533 | generateFlow(args) {
|
14534 | const $$ = this;
|
14535 | const { data, state, $el } = $$;
|
14536 | return function() {
|
14537 | const flowLength = args.flow.length;
|
14538 | state.flowing = true;
|
14539 | data.targets.forEach((d) => {
|
14540 | d.values.splice(0, flowLength);
|
14541 | });
|
14542 | if ($$.updateXGrid) {
|
14543 | $$.updateXGrid(true);
|
14544 | }
|
14545 | const elements = {};
|
14546 | [
|
14547 | "axis.x",
|
14548 | "grid.x",
|
14549 | "gridLines.x",
|
14550 | "region.list",
|
14551 | "text",
|
14552 | "bar",
|
14553 | "line",
|
14554 | "area",
|
14555 | "circle"
|
14556 | ].forEach((v) => {
|
14557 | const name = v.split(".");
|
14558 | let node = $el[name[0]];
|
14559 | if (node && name.length > 1) {
|
14560 | node = node[name[1]];
|
14561 | }
|
14562 | if (node == null ? void 0 : node.size()) {
|
14563 | elements[v] = node;
|
14564 | }
|
14565 | });
|
14566 | $$.hideGridFocus();
|
14567 | $$.setFlowList(elements, args);
|
14568 | };
|
14569 | },
|
14570 | |
14571 |
|
14572 |
|
14573 |
|
14574 |
|
14575 |
|
14576 | setFlowList(elements, args) {
|
14577 | const $$ = this;
|
14578 | const { flow, targets } = args;
|
14579 | const {
|
14580 | duration = args.duration,
|
14581 | index: flowIndex,
|
14582 | length: flowLength,
|
14583 | orgDataCount
|
14584 | } = flow;
|
14585 | const transform = $$.getFlowTransform(targets, orgDataCount, flowIndex, flowLength);
|
14586 | const wait = generateWait();
|
14587 | let n;
|
14588 | wait.add(Object.keys(elements).map((v) => {
|
14589 | n = elements[v].transition().ease(external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_.easeLinear).duration(duration);
|
14590 | if (v === "axis.x") {
|
14591 | n = n.call((g) => {
|
14592 | $$.axis.x.setTransition(g).create(g);
|
14593 | });
|
14594 | } else if (v === "region.list") {
|
14595 | n = n.filter($$.isRegionOnX).attr("transform", transform);
|
14596 | } else {
|
14597 | n = n.attr("transform", transform);
|
14598 | }
|
14599 | return n;
|
14600 | }));
|
14601 | n.call(wait, () => {
|
14602 | $$.cleanUpFlow(elements, args);
|
14603 | });
|
14604 | },
|
14605 | |
14606 |
|
14607 |
|
14608 |
|
14609 |
|
14610 |
|
14611 | cleanUpFlow(elements, args) {
|
14612 | const $$ = this;
|
14613 | const { config, state, $el: { svg } } = $$;
|
14614 | const isRotated = config.axis_rotated;
|
14615 | const { flow, shape, xv } = args;
|
14616 | const { cx, cy, xForText, yForText } = shape.pos;
|
14617 | const {
|
14618 | done = () => {
|
14619 | },
|
14620 | length: flowLength
|
14621 | } = flow;
|
14622 | if (flowLength) {
|
14623 | ["circle", "text", "shape", "eventRect"].forEach((v) => {
|
14624 | const target = [];
|
14625 | for (let i = 0; i < flowLength; i++) {
|
14626 | target.push(`.${classes[v]}-${i}`);
|
14627 | }
|
14628 | svg.selectAll(`.${classes[`${v}s`]}`).selectAll(target).remove();
|
14629 | });
|
14630 | svg.select(`.${classes.xgrid}`).remove();
|
14631 | }
|
14632 | Object.keys(elements).forEach((v) => {
|
14633 | const n = elements[v];
|
14634 | if (v !== "axis.x") {
|
14635 | n.attr("transform", null);
|
14636 | }
|
14637 | if (v === "grid.x") {
|
14638 | n.attr(state.xgridAttr);
|
14639 | } else if (v === "gridLines.x") {
|
14640 | n.attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);
|
14641 | n.select("text").attr("x", isRotated ? state.width : 0).attr("y", xv);
|
14642 | } else if (/^(area|bar|line)$/.test(v)) {
|
14643 | n.attr("d", shape.type[v]);
|
14644 | } else if (v === "text") {
|
14645 | n.attr("x", xForText).attr("y", yForText).style("fill-opacity", $$.opacityForText.bind($$));
|
14646 | } else if (v === "circle") {
|
14647 | if ($$.isCirclePoint()) {
|
14648 | n.attr("cx", cx).attr("cy", cy);
|
14649 | } else {
|
14650 | const xFunc = (d) => cx(d) - config.point_r;
|
14651 | const yFunc = (d) => cy(d) - config.point_r;
|
14652 | n.attr("x", xFunc).attr("y", yFunc);
|
14653 | }
|
14654 | } else if (v === "region.list") {
|
14655 | n.select("rect").filter($$.isRegionOnX).attr("x", $$.regionX.bind($$)).attr("width", $$.regionWidth.bind($$));
|
14656 | }
|
14657 | });
|
14658 | config.interaction_enabled && $$.redrawEventRect();
|
14659 | done.call($$.api);
|
14660 | state.flowing = false;
|
14661 | },
|
14662 | |
14663 |
|
14664 |
|
14665 |
|
14666 |
|
14667 |
|
14668 |
|
14669 |
|
14670 |
|
14671 | getFlowTransform(targets, orgDataCount, flowIndex, flowLength) {
|
14672 | const $$ = this;
|
14673 | const { data, scale: { x } } = $$;
|
14674 | const dataValues = data.targets[0].values;
|
14675 | let flowStart = $$.getValueOnIndex(dataValues, flowIndex);
|
14676 | let flowEnd = $$.getValueOnIndex(dataValues, flowIndex + flowLength);
|
14677 | let translateX;
|
14678 | const orgDomain = x.domain();
|
14679 | const domain = $$.updateXDomain(targets, true, true);
|
14680 | if (!orgDataCount) {
|
14681 | if (dataValues.length !== 1) {
|
14682 | translateX = x(orgDomain[0]) - x(domain[0]);
|
14683 | } else {
|
14684 | if ($$.axis.isTimeSeries()) {
|
14685 | flowStart = $$.getValueOnIndex(dataValues, 0);
|
14686 | flowEnd = $$.getValueOnIndex(dataValues, dataValues.length - 1);
|
14687 | translateX = x(flowStart.x) - x(flowEnd.x);
|
14688 | } else {
|
14689 | translateX = diffDomain(domain) / 2;
|
14690 | }
|
14691 | }
|
14692 | } else if (orgDataCount === 1 || (flowStart == null ? void 0 : flowStart.x) === (flowEnd == null ? void 0 : flowEnd.x)) {
|
14693 | translateX = x(orgDomain[0]) - x(domain[0]);
|
14694 | } else {
|
14695 | translateX = $$.axis.isTimeSeries() ? x(orgDomain[0]) - x(domain[0]) : x((flowStart == null ? void 0 : flowStart.x) || 0) - x(flowEnd.x);
|
14696 | }
|
14697 | const scaleX = diffDomain(orgDomain) / diffDomain(domain);
|
14698 | return `translate(${translateX},0) scale(${scaleX},1)`;
|
14699 | }
|
14700 | });
|
14701 |
|
14702 | ;
|
14703 | var clip = ({
|
14704 | initClip() {
|
14705 | const $$ = this;
|
14706 | const { clip, datetimeId } = $$.state;
|
14707 | clip.id = `${datetimeId}-clip`;
|
14708 | clip.idXAxis = `${clip.id}-xaxis`;
|
14709 | clip.idYAxis = `${clip.id}-yaxis`;
|
14710 | clip.idGrid = `${clip.id}-grid`;
|
14711 | clip.path = $$.getClipPath(clip.id);
|
14712 | clip.pathXAxis = $$.getClipPath(clip.idXAxis);
|
14713 | clip.pathYAxis = $$.getClipPath(clip.idYAxis);
|
14714 | clip.pathGrid = $$.getClipPath(clip.idGrid);
|
14715 | },
|
14716 | getClipPath(id) {
|
14717 | const $$ = this;
|
14718 | const { config } = $$;
|
14719 | if (!config.clipPath && /-clip$/.test(id) || !config.axis_x_clipPath && /-clip-xaxis$/.test(id) || !config.axis_y_clipPath && /-clip-yaxis$/.test(id)) {
|
14720 | return null;
|
14721 | }
|
14722 | return `url(#${id})`;
|
14723 | },
|
14724 | appendClip(parent, id) {
|
14725 | id && parent.append("clipPath").attr("id", id).append("rect");
|
14726 | },
|
14727 | |
14728 |
|
14729 |
|
14730 |
|
14731 |
|
14732 | setXAxisClipPath(node) {
|
14733 | const $$ = this;
|
14734 | const { config, state: { margin, width, height } } = $$;
|
14735 | const isRotated = config.axis_rotated;
|
14736 | const left = Math.max(30, margin.left) - (isRotated ? 0 : 20);
|
14737 | const h = (isRotated ? margin.top + height + 10 : margin.bottom) + 20;
|
14738 | const x = isRotated ? -(1 + left) : -(left - 1);
|
14739 | const y = -15;
|
14740 | const w = isRotated ? margin.left + 20 : width + 10 + left;
|
14741 | node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
|
14742 | },
|
14743 | |
14744 |
|
14745 |
|
14746 |
|
14747 |
|
14748 | setYAxisClipPath(node) {
|
14749 | const $$ = this;
|
14750 | const { config, state: { margin, width, height } } = $$;
|
14751 | const isRotated = config.axis_rotated;
|
14752 | const left = Math.max(30, margin.left) - (isRotated ? 20 : 0);
|
14753 | const isInner = config.axis_y_inner;
|
14754 | const x = isInner && !isRotated ? config.axis_y_label.text ? -20 : -1 : isRotated ? -(1 + left) : -(left - 1);
|
14755 | const y = -(isRotated ? 20 : margin.top);
|
14756 | const w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0);
|
14757 | const h = (isRotated ? margin.bottom + 10 : margin.top + height) + 10;
|
14758 | node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
|
14759 | },
|
14760 | updateXAxisTickClip() {
|
14761 | const $$ = this;
|
14762 | const { config, state: { clip, xAxisHeight }, $el: { defs } } = $$;
|
14763 | const newXAxisHeight = $$.getHorizontalAxisHeight("x");
|
14764 | if (defs && !clip.idXAxisTickTexts) {
|
14765 | const clipId = `${clip.id}-xaxisticktexts`;
|
14766 | $$.appendClip(defs, clipId);
|
14767 | clip.pathXAxisTickTexts = $$.getClipPath(clip.idXAxisTickTexts);
|
14768 | clip.idXAxisTickTexts = clipId;
|
14769 | }
|
14770 | if (!config.axis_x_tick_multiline && $$.getAxisTickRotate("x") && newXAxisHeight !== xAxisHeight) {
|
14771 | $$.setXAxisTickClipWidth();
|
14772 | $$.setXAxisTickTextClipPathWidth();
|
14773 | }
|
14774 | $$.state.xAxisHeight = newXAxisHeight;
|
14775 | },
|
14776 | setXAxisTickClipWidth() {
|
14777 | const $$ = this;
|
14778 | const { config, state: { current: { maxTickSize } } } = $$;
|
14779 | const xAxisTickRotate = $$.getAxisTickRotate("x");
|
14780 | if (!config.axis_x_tick_multiline && xAxisTickRotate) {
|
14781 | const sinRotation = Math.sin(Math.PI / 180 * Math.abs(xAxisTickRotate));
|
14782 | maxTickSize.x.clipPath = ($$.getHorizontalAxisHeight("x") - 20) / sinRotation;
|
14783 | } else {
|
14784 | maxTickSize.x.clipPath = null;
|
14785 | }
|
14786 | },
|
14787 | setXAxisTickTextClipPathWidth() {
|
14788 | const $$ = this;
|
14789 | const { state: { clip, current }, $el: { svg } } = $$;
|
14790 | if (svg) {
|
14791 | svg.select(`#${clip.idXAxisTickTexts} rect`).attr("width", current.maxTickSize.x.clipPath).attr("height", 30);
|
14792 | }
|
14793 | }
|
14794 | });
|
14795 |
|
14796 | ;
|
14797 |
|
14798 |
|
14799 |
|
14800 | const getGridTextAnchor = (d) => isValue(d.position) || "end";
|
14801 | const getGridTextDx = (d) => d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
|
14802 | function getGridTextX(isX, width, height) {
|
14803 | return (d) => {
|
14804 | let x = isX ? 0 : width;
|
14805 | if (d.position === "start") {
|
14806 | x = isX ? -height : 0;
|
14807 | } else if (d.position === "middle") {
|
14808 | x = (isX ? -height : width) / 2;
|
14809 | }
|
14810 | return x;
|
14811 | };
|
14812 | }
|
14813 | function smoothLines(el, type) {
|
14814 | if (type === "grid") {
|
14815 | el.each(function() {
|
14816 | const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
14817 | ["x1", "x2", "y1", "y2"].forEach((v) => g.attr(v, +g.attr(v)));
|
14818 | });
|
14819 | }
|
14820 | }
|
14821 | var internals_grid = ({
|
14822 | hasGrid() {
|
14823 | const { config } = this;
|
14824 | return ["x", "y"].some((v) => config[`grid_${v}_show`] || config[`grid_${v}_lines`].length);
|
14825 | },
|
14826 | initGrid() {
|
14827 | const $$ = this;
|
14828 | $$.hasGrid() && $$.initGridLines();
|
14829 | $$.initFocusGrid();
|
14830 | },
|
14831 | initGridLines() {
|
14832 | const $$ = this;
|
14833 | const { config, state: { clip }, $el } = $$;
|
14834 | if (config.grid_x_lines.length || config.grid_y_lines.length) {
|
14835 | $el.gridLines.main = $el.main.insert(
|
14836 | "g",
|
14837 | `.${$COMMON.chart}${config.grid_lines_front ? " + *" : ""}`
|
14838 | ).attr("clip-path", clip.pathGrid).attr("class", `${$GRID.grid} ${$GRID.gridLines}`);
|
14839 | $el.gridLines.main.append("g").attr("class", $GRID.xgridLines);
|
14840 | $el.gridLines.main.append("g").attr("class", $GRID.ygridLines);
|
14841 | $el.gridLines.x = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([]);
|
14842 | }
|
14843 | },
|
14844 | updateXGrid(withoutUpdate) {
|
14845 | const $$ = this;
|
14846 | const { config, scale, state, $el: { main, grid } } = $$;
|
14847 | const isRotated = config.axis_rotated;
|
14848 | const xgridData = $$.generateGridData(config.grid_x_type, scale.x);
|
14849 | const tickOffset = $$.axis.isCategorized() ? $$.axis.x.tickOffset() : 0;
|
14850 | const pos = (d) => (scale.zoom || scale.x)(d) + tickOffset * (isRotated ? -1 : 1);
|
14851 | state.xgridAttr = isRotated ? {
|
14852 | x1: 0,
|
14853 | x2: state.width,
|
14854 | y1: pos,
|
14855 | y2: pos
|
14856 | } : {
|
14857 | x1: pos,
|
14858 | x2: pos,
|
14859 | y1: 0,
|
14860 | y2: state.height
|
14861 | };
|
14862 | grid.x = main.select(`.${$GRID.xgrids}`).selectAll(`.${$GRID.xgrid}`).data(xgridData);
|
14863 | grid.x.exit().remove();
|
14864 | grid.x = grid.x.enter().append("line").attr("class", $GRID.xgrid).merge(grid.x);
|
14865 | if (!withoutUpdate) {
|
14866 | grid.x.each(function() {
|
14867 | const grid2 = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
14868 | Object.keys(state.xgridAttr).forEach((id) => {
|
14869 | grid2.attr(id, state.xgridAttr[id]).style("opacity", () => grid2.attr(isRotated ? "y1" : "x1") === (isRotated ? state.height : 0) ? "0" : null);
|
14870 | });
|
14871 | });
|
14872 | }
|
14873 | },
|
14874 | updateYGrid() {
|
14875 | const $$ = this;
|
14876 | const { axis, config, scale, state, $el: { grid, main } } = $$;
|
14877 | const isRotated = config.axis_rotated;
|
14878 | const pos = (d) => scale.y(d);
|
14879 | const gridValues = axis.y.getGeneratedTicks(config.grid_y_ticks) || $$.scale.y.ticks(config.grid_y_ticks);
|
14880 | grid.y = main.select(`.${$GRID.ygrids}`).selectAll(`.${$GRID.ygrid}`).data(gridValues);
|
14881 | grid.y.exit().remove();
|
14882 | grid.y = grid.y.enter().append("line").attr("class", $GRID.ygrid).merge(grid.y);
|
14883 | grid.y.attr("x1", isRotated ? pos : 0).attr("x2", isRotated ? pos : state.width).attr("y1", isRotated ? 0 : pos).attr("y2", isRotated ? state.height : pos);
|
14884 | smoothLines(grid.y, "grid");
|
14885 | },
|
14886 | updateGrid() {
|
14887 | const $$ = this;
|
14888 | const { $el: { grid, gridLines } } = $$;
|
14889 | !gridLines.main && $$.initGridLines();
|
14890 | grid.main.style("visibility", $$.hasArcType() ? "hidden" : null);
|
14891 | $$.hideGridFocus();
|
14892 | $$.updateGridLines("x");
|
14893 | $$.updateGridLines("y");
|
14894 | },
|
14895 | |
14896 |
|
14897 |
|
14898 |
|
14899 |
|
14900 | updateGridLines(type) {
|
14901 | const $$ = this;
|
14902 | const { config, $el: { gridLines, main }, $T } = $$;
|
14903 | const isRotated = config.axis_rotated;
|
14904 | const isX = type === "x";
|
14905 | config[`grid_${type}_show`] && $$[`update${type.toUpperCase()}Grid`]();
|
14906 | let lines = main.select(`.${$GRID[`${type}gridLines`]}`).selectAll(`.${$GRID[`${type}gridLine`]}`).data(config[`grid_${type}_lines`]);
|
14907 | $T(lines.exit()).style("opacity", "0").remove();
|
14908 | const gridLine = lines.enter().append("g");
|
14909 | gridLine.append("line").style("opacity", "0");
|
14910 | lines = gridLine.merge(lines);
|
14911 | lines.each(function(d) {
|
14912 | const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
14913 | if (g.select("text").empty() && d.text) {
|
14914 | g.append("text").style("opacity", "0");
|
14915 | }
|
14916 | });
|
14917 | $T(lines.attr("class", (d) => `${$GRID[`${type}gridLine`]} ${d.class || ""}`.trim()).select("text").attr("text-anchor", getGridTextAnchor).attr(
|
14918 | "transform",
|
14919 | () => isX ? isRotated ? null : "rotate(-90)" : isRotated ? "rotate(-90)" : null
|
14920 | ).attr("dx", getGridTextDx).attr("dy", -5)).text(function(d) {
|
14921 | var _a;
|
14922 | return (_a = d.text) != null ? _a : this.remove();
|
14923 | });
|
14924 | gridLines[type] = lines;
|
14925 | },
|
14926 | redrawGrid(withTransition) {
|
14927 | const $$ = this;
|
14928 | const {
|
14929 | config: { axis_rotated: isRotated },
|
14930 | state: { width, height },
|
14931 | $el: { gridLines },
|
14932 | $T
|
14933 | } = $$;
|
14934 | const xv = $$.xv.bind($$);
|
14935 | const yv = $$.yv.bind($$);
|
14936 | let xLines = gridLines.x.select("line");
|
14937 | let xTexts = gridLines.x.select("text");
|
14938 | let yLines = gridLines.y.select("line");
|
14939 | let yTexts = gridLines.y.select("text");
|
14940 | xLines = $T(xLines, withTransition).attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? width : xv).attr("y1", isRotated ? xv : 0).attr("y2", isRotated ? xv : height);
|
14941 | xTexts = $T(xTexts, withTransition).attr("x", getGridTextX(!isRotated, width, height)).attr("y", xv);
|
14942 | yLines = $T(yLines, withTransition).attr("x1", isRotated ? yv : 0).attr("x2", isRotated ? yv : width).attr("y1", isRotated ? 0 : yv).attr("y2", isRotated ? height : yv);
|
14943 | yTexts = $T(yTexts, withTransition).attr("x", getGridTextX(isRotated, width, height)).attr("y", yv);
|
14944 | return [
|
14945 | xLines.style("opacity", null),
|
14946 | xTexts.style("opacity", null),
|
14947 | yLines.style("opacity", null),
|
14948 | yTexts.style("opacity", null)
|
14949 | ];
|
14950 | },
|
14951 | initFocusGrid() {
|
14952 | const $$ = this;
|
14953 | const { config, state: { clip }, $el } = $$;
|
14954 | const isFront = config.grid_front;
|
14955 | const className = `.${isFront && $el.gridLines.main ? $GRID.gridLines : $COMMON.chart}${isFront ? " + *" : ""}`;
|
14956 | const grid = $el.main.insert("g", className).attr("clip-path", clip.pathGrid).attr("class", $GRID.grid);
|
14957 | $el.grid.main = grid;
|
14958 | config.grid_x_show && grid.append("g").attr("class", $GRID.xgrids);
|
14959 | config.grid_y_show && grid.append("g").attr("class", $GRID.ygrids);
|
14960 | if (config.axis_tooltip) {
|
14961 | const axis = grid.append("g").attr("class", "bb-axis-tooltip");
|
14962 | axis.append("line").attr("class", "bb-axis-tooltip-x");
|
14963 | axis.append("line").attr("class", "bb-axis-tooltip-y");
|
14964 | }
|
14965 | if (config.interaction_enabled && config.grid_focus_show && !config.axis_tooltip) {
|
14966 | grid.append("g").attr("class", $FOCUS.xgridFocus).append("line").attr("class", $FOCUS.xgridFocus);
|
14967 | if (config.grid_focus_y && !config.tooltip_grouped) {
|
14968 | grid.append("g").attr("class", $FOCUS.ygridFocus).append("line").attr("class", $FOCUS.ygridFocus);
|
14969 | }
|
14970 | }
|
14971 | },
|
14972 | showAxisGridFocus() {
|
14973 | var _a, _b;
|
14974 | const $$ = this;
|
14975 | const { config, format, state: { event, width, height } } = $$;
|
14976 | const isRotated = config.axis_rotated;
|
14977 | const [x, y] = getPointer(event, (_a = $$.$el.eventRect) == null ? void 0 : _a.node());
|
14978 | const pos = { x, y };
|
14979 | for (const [axis, node] of Object.entries($$.$el.axisTooltip)) {
|
14980 | const attr = axis === "x" && !isRotated || axis !== "x" && isRotated ? "x" : "y";
|
14981 | const value = pos[attr];
|
14982 | let scaleText = (_b = $$.scale[axis]) == null ? void 0 : _b.invert(value);
|
14983 | if (scaleText) {
|
14984 | scaleText = axis === "x" && $$.axis.isTimeSeries() ? format.xAxisTick(scaleText) : scaleText == null ? void 0 : scaleText.toFixed(2);
|
14985 | node == null ? void 0 : node.attr(attr, value).text(scaleText);
|
14986 | }
|
14987 | }
|
14988 | $$.$el.main.selectAll(
|
14989 | `line.bb-axis-tooltip-x, line.bb-axis-tooltip-y`
|
14990 | ).style("visibility", null).each(function(d, i) {
|
14991 | const line = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
14992 | if (i === 0) {
|
14993 | line.attr("x1", x).attr("x2", x).attr("y1", i ? 0 : height).attr("y2", i ? height : 0);
|
14994 | } else {
|
14995 | line.attr("x1", i ? 0 : width).attr("x2", i ? width : 0).attr("y1", y).attr("y2", y);
|
14996 | }
|
14997 | });
|
14998 | },
|
14999 | hideAxisGridFocus() {
|
15000 | const $$ = this;
|
15001 | $$.$el.main.selectAll(
|
15002 | `line.bb-axis-tooltip-x, line.bb-axis-tooltip-y`
|
15003 | ).style("visibility", "hidden");
|
15004 | Object.values($$.$el.axisTooltip).forEach((v) => v == null ? void 0 : v.style("display", "none"));
|
15005 | },
|
15006 | |
15007 |
|
15008 |
|
15009 |
|
15010 |
|
15011 | showGridFocus(data) {
|
15012 | var _a;
|
15013 | const $$ = this;
|
15014 | const { config, state: { width, height } } = $$;
|
15015 | const isRotated = config.axis_rotated;
|
15016 | const focusEl = $$.$el.main.selectAll(
|
15017 | `line.${$FOCUS.xgridFocus}, line.${$FOCUS.ygridFocus}`
|
15018 | );
|
15019 | const dataToShow = (data || [focusEl.datum()]).filter(
|
15020 | (d) => d && isValue($$.getBaseValue(d))
|
15021 | );
|
15022 | if (!config.tooltip_show || dataToShow.length === 0 || !config.axis_x_forceAsSingle && $$.hasType("bubble") || $$.hasArcType()) {
|
15023 | return;
|
15024 | }
|
15025 | const isEdge = config.grid_focus_edge && !config.tooltip_grouped;
|
15026 | const xx = $$.xx.bind($$);
|
15027 | focusEl.style("visibility", null).data(dataToShow.concat(dataToShow)).each(function(d) {
|
15028 | const el = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
15029 | const pos = {
|
15030 | x: xx(d),
|
15031 | y: $$.getYScaleById(d.id)(d.value)
|
15032 | };
|
15033 | let xy;
|
15034 | if (el.classed($FOCUS.xgridFocus)) {
|
15035 | xy = isRotated ? [
|
15036 | null,
|
15037 |
|
15038 | pos.x,
|
15039 |
|
15040 | isEdge ? pos.y : width,
|
15041 |
|
15042 | pos.x
|
15043 |
|
15044 | ] : [
|
15045 | pos.x,
|
15046 | isEdge ? pos.y : null,
|
15047 | pos.x,
|
15048 | height
|
15049 | ];
|
15050 | } else {
|
15051 | const isY2 = $$.axis.getId(d.id) === "y2";
|
15052 | xy = isRotated ? [
|
15053 | pos.y,
|
15054 |
|
15055 | isEdge && !isY2 ? pos.x : null,
|
15056 |
|
15057 | pos.y,
|
15058 |
|
15059 | isEdge && isY2 ? pos.x : height
|
15060 |
|
15061 | ] : [
|
15062 | isEdge && isY2 ? pos.x : null,
|
15063 | pos.y,
|
15064 | isEdge && !isY2 ? pos.x : width,
|
15065 | pos.y
|
15066 | ];
|
15067 | }
|
15068 | ["x1", "y1", "x2", "y2"].forEach((v, i) => el.attr(v, xy[i]));
|
15069 | });
|
15070 | smoothLines(focusEl, "grid");
|
15071 | (_a = $$.showCircleFocus) == null ? void 0 : _a.call($$, data);
|
15072 | },
|
15073 | hideGridFocus() {
|
15074 | var _a;
|
15075 | const $$ = this;
|
15076 | const { state: { inputType, resizing }, $el: { main } } = $$;
|
15077 | if (inputType === "mouse" || !resizing) {
|
15078 | main.selectAll(`line.${$FOCUS.xgridFocus}, line.${$FOCUS.ygridFocus}`).style("visibility", "hidden");
|
15079 | (_a = $$.hideCircleFocus) == null ? void 0 : _a.call($$);
|
15080 | }
|
15081 | },
|
15082 | updateGridFocus() {
|
15083 | var _a;
|
15084 | const $$ = this;
|
15085 | const { state: { inputType, width, height, resizing }, $el: { grid } } = $$;
|
15086 | const xgridFocus = grid.main.select(`line.${$FOCUS.xgridFocus}`);
|
15087 | if (inputType === "touch") {
|
15088 | if (xgridFocus.empty()) {
|
15089 | resizing && ((_a = $$.showCircleFocus) == null ? void 0 : _a.call($$));
|
15090 | } else {
|
15091 | $$.showGridFocus();
|
15092 | }
|
15093 | } else {
|
15094 | const isRotated = $$.config.axis_rotated;
|
15095 | xgridFocus.attr("x1", isRotated ? 0 : -10).attr("x2", isRotated ? width : -10).attr("y1", isRotated ? -10 : 0).attr("y2", isRotated ? -10 : height);
|
15096 | }
|
15097 | return true;
|
15098 | },
|
15099 | generateGridData(type, scale) {
|
15100 | const $$ = this;
|
15101 | const tickNum = $$.$el.main.select(`.${$AXIS.axisX}`).selectAll(".tick").size();
|
15102 | let gridData = [];
|
15103 | if (type === "year") {
|
15104 | const xDomain = $$.getXDomain();
|
15105 | const [firstYear, lastYear] = xDomain.map((v) => v.getFullYear());
|
15106 | for (let i = firstYear; i <= lastYear; i++) {
|
15107 | gridData.push( new Date(`${i}-01-01 00:00:00`));
|
15108 | }
|
15109 | } else {
|
15110 | gridData = scale.ticks(10);
|
15111 | if (gridData.length > tickNum) {
|
15112 | gridData = gridData.filter((d) => String(d).indexOf(".") < 0);
|
15113 | }
|
15114 | }
|
15115 | return gridData;
|
15116 | },
|
15117 | getGridFilterToRemove(params) {
|
15118 | return params ? (line) => {
|
15119 | let found = false;
|
15120 | (isArray(params) ? params.concat() : [params]).forEach((param) => {
|
15121 | if ("value" in param && line.value === param.value || "class" in param && line.class === param.class) {
|
15122 | found = true;
|
15123 | }
|
15124 | });
|
15125 | return found;
|
15126 | } : () => true;
|
15127 | },
|
15128 | removeGridLines(params, forX) {
|
15129 | const $$ = this;
|
15130 | const { config, $T } = $$;
|
15131 | const toRemove = $$.getGridFilterToRemove(params);
|
15132 | const toShow = (line) => !toRemove(line);
|
15133 | const classLines = forX ? $GRID.xgridLines : $GRID.ygridLines;
|
15134 | const classLine = forX ? $GRID.xgridLine : $GRID.ygridLine;
|
15135 | $T($$.$el.main.select(`.${classLines}`).selectAll(`.${classLine}`).filter(toRemove)).style("opacity", "0").remove();
|
15136 | const gridLines = `grid_${forX ? "x" : "y"}_lines`;
|
15137 | config[gridLines] = config[gridLines].filter(toShow);
|
15138 | }
|
15139 | });
|
15140 |
|
15141 | ;
|
15142 |
|
15143 |
|
15144 |
|
15145 | var region = ({
|
15146 | initRegion() {
|
15147 | const $$ = this;
|
15148 | const { $el } = $$;
|
15149 | $el.region.main = $el.main.insert("g", ":first-child").attr("clip-path", $$.state.clip.path).attr("class", $REGION.regions);
|
15150 | },
|
15151 | updateRegion() {
|
15152 | const $$ = this;
|
15153 | const { config, $el: { region }, $T } = $$;
|
15154 | if (!region.main) {
|
15155 | $$.initRegion();
|
15156 | }
|
15157 | region.main.style("visibility", $$.hasArcType() ? "hidden" : null);
|
15158 | const regions = region.main.selectAll(`.${$REGION.region}`).data(config.regions);
|
15159 | $T(regions.exit()).style("opacity", "0").remove();
|
15160 | const regionsEnter = regions.enter().append("g");
|
15161 | regionsEnter.append("rect").style("fill-opacity", "0");
|
15162 | region.list = regionsEnter.merge(regions).attr("class", $$.classRegion.bind($$));
|
15163 | region.list.each(function(d) {
|
15164 | var _a;
|
15165 | const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
15166 | if (g.select("text").empty() && ((_a = d.label) == null ? void 0 : _a.text)) {
|
15167 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).append("text").style("opacity", "0");
|
15168 | }
|
15169 | });
|
15170 | },
|
15171 | redrawRegion(withTransition) {
|
15172 | const $$ = this;
|
15173 | const { $el: { region }, $T } = $$;
|
15174 | let regions = region.list.select("rect");
|
15175 | let label = region.list.selectAll("text");
|
15176 | regions = $T(regions, withTransition).attr("x", $$.regionX.bind($$)).attr("y", $$.regionY.bind($$)).attr("width", $$.regionWidth.bind($$)).attr("height", $$.regionHeight.bind($$));
|
15177 | label = $T(label, withTransition).attr("transform", (d) => {
|
15178 | var _a;
|
15179 | const { x = 0, y = 0, rotated = false } = (_a = d.label) != null ? _a : {};
|
15180 | return `translate(${$$.regionX.bind($$)(d) + x}, ${$$.regionY.bind($$)(d) + y})${rotated ? ` rotate(-90)` : ``}`;
|
15181 | }).attr("text-anchor", (d) => {
|
15182 | var _a;
|
15183 | return ((_a = d.label) == null ? void 0 : _a.rotated) ? "end" : null;
|
15184 | }).attr("dy", "1em").style("fill", (d) => {
|
15185 | var _a, _b;
|
15186 | return (_b = (_a = d.label) == null ? void 0 : _a.color) != null ? _b : null;
|
15187 | }).text((d) => {
|
15188 | var _a;
|
15189 | return (_a = d.label) == null ? void 0 : _a.text;
|
15190 | });
|
15191 | return [
|
15192 | regions.style("fill-opacity", (d) => isValue(d.opacity) ? d.opacity : null).on("end", function() {
|
15193 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode).selectAll("rect:not([x])").remove();
|
15194 | }),
|
15195 | label.style("opacity", null)
|
15196 | ];
|
15197 | },
|
15198 | getRegionXY(type, d) {
|
15199 | const $$ = this;
|
15200 | const { config, scale } = $$;
|
15201 | const isRotated = config.axis_rotated;
|
15202 | const isX = type === "x";
|
15203 | let key = "start";
|
15204 | let currScale;
|
15205 | let pos = 0;
|
15206 | if (d.axis === "y" || d.axis === "y2") {
|
15207 | if (!isX) {
|
15208 | key = "end";
|
15209 | }
|
15210 | if ((isX ? isRotated : !isRotated) && key in d) {
|
15211 | currScale = scale[d.axis];
|
15212 | pos = currScale(d[key]);
|
15213 | }
|
15214 | } else if ((isX ? !isRotated : isRotated) && key in d) {
|
15215 | currScale = scale.zoom || scale.x;
|
15216 | pos = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key]);
|
15217 | }
|
15218 | return pos;
|
15219 | },
|
15220 | regionX(d) {
|
15221 | return this.getRegionXY("x", d);
|
15222 | },
|
15223 | regionY(d) {
|
15224 | return this.getRegionXY("y", d);
|
15225 | },
|
15226 | getRegionSize(type, d) {
|
15227 | const $$ = this;
|
15228 | const { config, scale, state } = $$;
|
15229 | const isRotated = config.axis_rotated;
|
15230 | const isWidth = type === "width";
|
15231 | const start = $$[isWidth ? "regionX" : "regionY"](d);
|
15232 | let currScale;
|
15233 | let key = "end";
|
15234 | let end = state[type];
|
15235 | if (d.axis === "y" || d.axis === "y2") {
|
15236 | if (!isWidth) {
|
15237 | key = "start";
|
15238 | }
|
15239 | if ((isWidth ? isRotated : !isRotated) && key in d) {
|
15240 | currScale = scale[d.axis];
|
15241 | end = currScale(d[key]);
|
15242 | }
|
15243 | } else if ((isWidth ? !isRotated : isRotated) && key in d) {
|
15244 | currScale = scale.zoom || scale.x;
|
15245 | end = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key]);
|
15246 | }
|
15247 | return end < start ? 0 : end - start;
|
15248 | },
|
15249 | regionWidth(d) {
|
15250 | return this.getRegionSize("width", d);
|
15251 | },
|
15252 | regionHeight(d) {
|
15253 | return this.getRegionSize("height", d);
|
15254 | },
|
15255 | isRegionOnX(d) {
|
15256 | return !d.axis || d.axis === "x";
|
15257 | }
|
15258 | });
|
15259 |
|
15260 | ;
|
15261 |
|
15262 | var size_axis = ({
|
15263 | |
15264 |
|
15265 |
|
15266 |
|
15267 |
|
15268 |
|
15269 | getAxisSize(id) {
|
15270 | const $$ = this;
|
15271 | const isRotated = $$.config.axis_rotated;
|
15272 | return isRotated && id === "x" || !isRotated && /y2?/.test(id) ? $$.getAxisWidthByAxisId(id, true) : $$.getHorizontalAxisHeight(id);
|
15273 | },
|
15274 | getAxisWidthByAxisId(id, withoutRecompute) {
|
15275 | var _a, _b;
|
15276 | const $$ = this;
|
15277 | if ($$.axis) {
|
15278 | const position = (_a = $$.axis) == null ? void 0 : _a.getLabelPositionById(id);
|
15279 | const { width } = $$.axis.getMaxTickSize(id, withoutRecompute);
|
15280 | const gap = width === 0 ? 0.5 : 0;
|
15281 | return width + (((_b = $$.config.padding) == null ? void 0 : _b.mode) === "fit" ? position.isInner ? 10 + gap : 10 : position.isInner ? 20 + gap : 40);
|
15282 | } else {
|
15283 | return 40;
|
15284 | }
|
15285 | },
|
15286 | getHorizontalAxisHeight(id) {
|
15287 | var _a, _b;
|
15288 | const $$ = this;
|
15289 | const { config, state } = $$;
|
15290 | const { rotatedPadding, isLegendRight, isLegendInset } = state;
|
15291 | const isRotated = config.axis_rotated;
|
15292 | const isFitPadding = ((_a = config.padding) == null ? void 0 : _a.mode) === "fit";
|
15293 | const isInner = config[`axis_${id}_inner`];
|
15294 | const hasLabelText = config[`axis_${id}_label`].text;
|
15295 | const defaultHeight = 13;
|
15296 | let h = ((_b = config.padding) == null ? void 0 : _b.mode) === "fit" ? isInner && !hasLabelText ? id === "y" ? 1 : 0 : 20 : 30;
|
15297 | if (id === "x" && !config.axis_x_show) {
|
15298 | return 8;
|
15299 | }
|
15300 | if (id === "x" && isNumber(config.axis_x_height)) {
|
15301 | return config.axis_x_height;
|
15302 | }
|
15303 | if (id === "y" && !config.axis_y_show) {
|
15304 | return config.legend_show && !isLegendRight && !isLegendInset ? 10 : 1;
|
15305 | }
|
15306 | if (id === "y2" && !config.axis_y2_show) {
|
15307 | return isFitPadding ? 0 : rotatedPadding.top;
|
15308 | }
|
15309 | const maxtickSize = $$.axis.getMaxTickSize(id);
|
15310 | const isXAxisTickRotated = Math.abs(config.axis_x_tick_rotate) > 0 && (!config.axis_x_tick_autorotate || $$.needToRotateXAxisTickTexts());
|
15311 | if ((config.axis_x_tick_multiline || isXAxisTickRotated) && maxtickSize.height > defaultHeight) {
|
15312 | h += maxtickSize.height - defaultHeight;
|
15313 | }
|
15314 | return h + ($$.axis.getLabelPositionById(id).isInner ? 0 : 10) + (id === "y2" && !isRotated ? -10 : 0);
|
15315 | },
|
15316 | getEventRectWidth() {
|
15317 | const $$ = this;
|
15318 | const { config, axis } = $$;
|
15319 | const isInverted = config.axis_x_inverted;
|
15320 | const tickInterval = axis.x.tickInterval();
|
15321 | return Math.max(0, isInverted ? Math.abs(tickInterval) : tickInterval);
|
15322 | },
|
15323 | |
15324 |
|
15325 |
|
15326 |
|
15327 |
|
15328 |
|
15329 | getAxisTickRotate(id) {
|
15330 | const $$ = this;
|
15331 | const { axis, config, state, $el } = $$;
|
15332 | let rotate = config[`axis_${id}_tick_rotate`];
|
15333 | if (id === "x") {
|
15334 | const allowedXAxisTypes = axis.isCategorized() || axis.isTimeSeries();
|
15335 | if (config.axis_x_tick_fit && allowedXAxisTypes) {
|
15336 | const xTickCount = config.axis_x_tick_count;
|
15337 | const currentXTicksLength = state.current.maxTickSize.x.ticks.length;
|
15338 | let tickCount = 0;
|
15339 | if (xTickCount) {
|
15340 | tickCount = xTickCount > currentXTicksLength ? currentXTicksLength : xTickCount;
|
15341 | } else if (currentXTicksLength) {
|
15342 | tickCount = currentXTicksLength;
|
15343 | }
|
15344 | if (tickCount !== state.axis.x.tickCount) {
|
15345 | const { targets } = $$.data;
|
15346 | state.axis.x.padding = $$.getXDomainPadding([
|
15347 | $$.getXDomainMinMax(targets, "min"),
|
15348 | $$.getXDomainMinMax(targets, "max")
|
15349 | ], tickCount);
|
15350 | }
|
15351 | state.axis.x.tickCount = tickCount;
|
15352 | }
|
15353 | if ($el.svg && config.axis_x_tick_autorotate && config.axis_x_tick_fit && !config.axis_x_tick_multiline && !config.axis_x_tick_culling && allowedXAxisTypes) {
|
15354 | rotate = $$.needToRotateXAxisTickTexts() ? config.axis_x_tick_rotate : 0;
|
15355 | }
|
15356 | }
|
15357 | return rotate;
|
15358 | },
|
15359 | |
15360 |
|
15361 |
|
15362 |
|
15363 |
|
15364 | needToRotateXAxisTickTexts() {
|
15365 | const $$ = this;
|
15366 | const { state: { axis, current, isLegendRight, legendItemWidth } } = $$;
|
15367 | const legendWidth = isLegendRight && legendItemWidth;
|
15368 | const xAxisLength = current.width - legendWidth - $$.getCurrentPaddingByDirection("left") - $$.getCurrentPaddingByDirection("right");
|
15369 | const tickCountWithPadding = axis.x.tickCount + axis.x.padding.left + axis.x.padding.right;
|
15370 | const { width } = $$.axis.getMaxTickSize("x");
|
15371 | const tickLength = tickCountWithPadding ? xAxisLength / tickCountWithPadding : 0;
|
15372 | return width > tickLength;
|
15373 | }
|
15374 | });
|
15375 |
|
15376 | ;
|
15377 | var axis_x = ({
|
15378 | |
15379 |
|
15380 |
|
15381 |
|
15382 |
|
15383 |
|
15384 |
|
15385 |
|
15386 |
|
15387 |
|
15388 |
|
15389 | axis_x_clipPath: true,
|
15390 | |
15391 |
|
15392 |
|
15393 |
|
15394 |
|
15395 |
|
15396 |
|
15397 |
|
15398 |
|
15399 |
|
15400 |
|
15401 |
|
15402 |
|
15403 | axis_x_show: true,
|
15404 | |
15405 |
|
15406 |
|
15407 |
|
15408 |
|
15409 |
|
15410 |
|
15411 |
|
15412 |
|
15413 |
|
15414 |
|
15415 |
|
15416 |
|
15417 |
|
15418 |
|
15419 |
|
15420 |
|
15421 |
|
15422 |
|
15423 |
|
15424 | axis_x_forceAsSingle: false,
|
15425 | |
15426 |
|
15427 |
|
15428 |
|
15429 |
|
15430 |
|
15431 |
|
15432 |
|
15433 |
|
15434 |
|
15435 |
|
15436 |
|
15437 |
|
15438 |
|
15439 |
|
15440 |
|
15441 |
|
15442 |
|
15443 |
|
15444 |
|
15445 |
|
15446 |
|
15447 |
|
15448 |
|
15449 |
|
15450 |
|
15451 |
|
15452 |
|
15453 | axis_x_type: "indexed",
|
15454 | |
15455 |
|
15456 |
|
15457 |
|
15458 |
|
15459 |
|
15460 |
|
15461 |
|
15462 |
|
15463 |
|
15464 |
|
15465 |
|
15466 |
|
15467 |
|
15468 | axis_x_localtime: true,
|
15469 | |
15470 |
|
15471 |
|
15472 |
|
15473 |
|
15474 |
|
15475 |
|
15476 |
|
15477 |
|
15478 |
|
15479 |
|
15480 |
|
15481 |
|
15482 |
|
15483 | axis_x_categories: [],
|
15484 | |
15485 |
|
15486 |
|
15487 |
|
15488 |
|
15489 |
|
15490 |
|
15491 |
|
15492 |
|
15493 |
|
15494 |
|
15495 |
|
15496 |
|
15497 |
|
15498 |
|
15499 | axis_x_tick_centered: false,
|
15500 | |
15501 |
|
15502 |
|
15503 |
|
15504 |
|
15505 |
|
15506 |
|
15507 |
|
15508 |
|
15509 |
|
15510 |
|
15511 |
|
15512 |
|
15513 |
|
15514 |
|
15515 |
|
15516 |
|
15517 |
|
15518 |
|
15519 |
|
15520 |
|
15521 |
|
15522 |
|
15523 |
|
15524 |
|
15525 |
|
15526 |
|
15527 | axis_x_tick_format: void 0,
|
15528 | |
15529 |
|
15530 |
|
15531 |
|
15532 |
|
15533 |
|
15534 |
|
15535 |
|
15536 |
|
15537 |
|
15538 |
|
15539 |
|
15540 |
|
15541 |
|
15542 |
|
15543 |
|
15544 |
|
15545 |
|
15546 |
|
15547 |
|
15548 | axis_x_tick_culling: {},
|
15549 | |
15550 |
|
15551 |
|
15552 |
|
15553 |
|
15554 |
|
15555 |
|
15556 |
|
15557 |
|
15558 |
|
15559 |
|
15560 |
|
15561 |
|
15562 |
|
15563 |
|
15564 |
|
15565 |
|
15566 | axis_x_tick_culling_max: 10,
|
15567 | |
15568 |
|
15569 |
|
15570 |
|
15571 |
|
15572 |
|
15573 |
|
15574 |
|
15575 |
|
15576 |
|
15577 |
|
15578 |
|
15579 |
|
15580 |
|
15581 |
|
15582 |
|
15583 |
|
15584 | axis_x_tick_culling_lines: true,
|
15585 | |
15586 |
|
15587 |
|
15588 |
|
15589 |
|
15590 |
|
15591 |
|
15592 |
|
15593 |
|
15594 |
|
15595 |
|
15596 |
|
15597 |
|
15598 |
|
15599 |
|
15600 |
|
15601 | axis_x_tick_count: void 0,
|
15602 | |
15603 |
|
15604 |
|
15605 |
|
15606 |
|
15607 |
|
15608 |
|
15609 |
|
15610 |
|
15611 |
|
15612 |
|
15613 |
|
15614 |
|
15615 |
|
15616 |
|
15617 |
|
15618 | axis_x_tick_show: true,
|
15619 | |
15620 |
|
15621 |
|
15622 |
|
15623 |
|
15624 |
|
15625 |
|
15626 |
|
15627 |
|
15628 |
|
15629 |
|
15630 |
|
15631 |
|
15632 |
|
15633 |
|
15634 |
|
15635 |
|
15636 |
|
15637 | axis_x_tick_text_show: true,
|
15638 | |
15639 |
|
15640 |
|
15641 |
|
15642 |
|
15643 |
|
15644 |
|
15645 |
|
15646 |
|
15647 |
|
15648 |
|
15649 |
|
15650 |
|
15651 |
|
15652 |
|
15653 |
|
15654 |
|
15655 |
|
15656 |
|
15657 |
|
15658 |
|
15659 |
|
15660 |
|
15661 |
|
15662 | axis_x_tick_text_inner: false,
|
15663 | |
15664 |
|
15665 |
|
15666 |
|
15667 |
|
15668 |
|
15669 |
|
15670 |
|
15671 |
|
15672 |
|
15673 |
|
15674 |
|
15675 |
|
15676 |
|
15677 |
|
15678 |
|
15679 |
|
15680 |
|
15681 |
|
15682 |
|
15683 | axis_x_tick_text_position: { x: 0, y: 0 },
|
15684 | |
15685 |
|
15686 |
|
15687 |
|
15688 |
|
15689 |
|
15690 |
|
15691 |
|
15692 |
|
15693 |
|
15694 |
|
15695 |
|
15696 |
|
15697 |
|
15698 |
|
15699 |
|
15700 |
|
15701 |
|
15702 |
|
15703 | axis_x_tick_fit: true,
|
15704 | |
15705 |
|
15706 |
|
15707 |
|
15708 |
|
15709 |
|
15710 |
|
15711 |
|
15712 |
|
15713 |
|
15714 |
|
15715 |
|
15716 |
|
15717 |
|
15718 |
|
15719 |
|
15720 |
|
15721 |
|
15722 |
|
15723 |
|
15724 |
|
15725 |
|
15726 | axis_x_tick_values: null,
|
15727 | |
15728 |
|
15729 |
|
15730 |
|
15731 |
|
15732 |
|
15733 |
|
15734 |
|
15735 |
|
15736 |
|
15737 |
|
15738 |
|
15739 |
|
15740 |
|
15741 |
|
15742 |
|
15743 |
|
15744 |
|
15745 |
|
15746 |
|
15747 |
|
15748 |
|
15749 |
|
15750 |
|
15751 |
|
15752 |
|
15753 |
|
15754 | axis_x_tick_autorotate: false,
|
15755 | |
15756 |
|
15757 |
|
15758 |
|
15759 |
|
15760 |
|
15761 |
|
15762 |
|
15763 |
|
15764 |
|
15765 |
|
15766 |
|
15767 |
|
15768 |
|
15769 |
|
15770 |
|
15771 |
|
15772 |
|
15773 |
|
15774 | axis_x_tick_rotate: 0,
|
15775 | |
15776 |
|
15777 |
|
15778 |
|
15779 |
|
15780 |
|
15781 |
|
15782 |
|
15783 |
|
15784 |
|
15785 |
|
15786 |
|
15787 |
|
15788 |
|
15789 |
|
15790 | axis_x_tick_outer: true,
|
15791 | |
15792 |
|
15793 |
|
15794 |
|
15795 |
|
15796 |
|
15797 |
|
15798 |
|
15799 |
|
15800 |
|
15801 |
|
15802 |
|
15803 |
|
15804 |
|
15805 |
|
15806 |
|
15807 |
|
15808 |
|
15809 |
|
15810 |
|
15811 |
|
15812 |
|
15813 |
|
15814 |
|
15815 |
|
15816 |
|
15817 |
|
15818 |
|
15819 | axis_x_tick_multiline: true,
|
15820 | |
15821 |
|
15822 |
|
15823 |
|
15824 |
|
15825 |
|
15826 |
|
15827 |
|
15828 |
|
15829 |
|
15830 |
|
15831 |
|
15832 |
|
15833 |
|
15834 |
|
15835 |
|
15836 |
|
15837 | axis_x_tick_width: null,
|
15838 | |
15839 |
|
15840 |
|
15841 |
|
15842 |
|
15843 |
|
15844 |
|
15845 |
|
15846 |
|
15847 |
|
15848 |
|
15849 |
|
15850 |
|
15851 |
|
15852 |
|
15853 |
|
15854 | axis_x_tick_tooltip: false,
|
15855 | |
15856 |
|
15857 |
|
15858 |
|
15859 |
|
15860 |
|
15861 |
|
15862 |
|
15863 |
|
15864 |
|
15865 |
|
15866 |
|
15867 |
|
15868 |
|
15869 |
|
15870 |
|
15871 |
|
15872 |
|
15873 |
|
15874 |
|
15875 |
|
15876 |
|
15877 |
|
15878 | axis_x_max: void 0,
|
15879 | |
15880 |
|
15881 |
|
15882 |
|
15883 |
|
15884 |
|
15885 |
|
15886 |
|
15887 |
|
15888 |
|
15889 |
|
15890 |
|
15891 |
|
15892 |
|
15893 |
|
15894 |
|
15895 |
|
15896 |
|
15897 |
|
15898 |
|
15899 |
|
15900 |
|
15901 |
|
15902 | axis_x_min: void 0,
|
15903 | |
15904 |
|
15905 |
|
15906 |
|
15907 |
|
15908 |
|
15909 |
|
15910 |
|
15911 |
|
15912 |
|
15913 |
|
15914 |
|
15915 |
|
15916 |
|
15917 |
|
15918 | axis_x_inverted: false,
|
15919 | |
15920 |
|
15921 |
|
15922 |
|
15923 |
|
15924 |
|
15925 |
|
15926 |
|
15927 |
|
15928 |
|
15929 |
|
15930 |
|
15931 |
|
15932 |
|
15933 |
|
15934 |
|
15935 |
|
15936 |
|
15937 |
|
15938 |
|
15939 |
|
15940 |
|
15941 |
|
15942 |
|
15943 |
|
15944 |
|
15945 |
|
15946 |
|
15947 |
|
15948 |
|
15949 |
|
15950 |
|
15951 |
|
15952 |
|
15953 |
|
15954 |
|
15955 |
|
15956 |
|
15957 |
|
15958 |
|
15959 |
|
15960 |
|
15961 | axis_x_padding: {},
|
15962 | |
15963 |
|
15964 |
|
15965 |
|
15966 |
|
15967 |
|
15968 |
|
15969 |
|
15970 |
|
15971 |
|
15972 |
|
15973 |
|
15974 |
|
15975 |
|
15976 | axis_x_height: void 0,
|
15977 | |
15978 |
|
15979 |
|
15980 |
|
15981 |
|
15982 |
|
15983 |
|
15984 |
|
15985 |
|
15986 |
|
15987 |
|
15988 |
|
15989 |
|
15990 |
|
15991 |
|
15992 |
|
15993 |
|
15994 |
|
15995 |
|
15996 |
|
15997 |
|
15998 |
|
15999 |
|
16000 |
|
16001 |
|
16002 |
|
16003 |
|
16004 |
|
16005 |
|
16006 | axis_x_extent: void 0,
|
16007 | |
16008 |
|
16009 |
|
16010 |
|
16011 |
|
16012 |
|
16013 |
|
16014 |
|
16015 |
|
16016 |
|
16017 |
|
16018 |
|
16019 |
|
16020 |
|
16021 |
|
16022 |
|
16023 |
|
16024 |
|
16025 |
|
16026 |
|
16027 |
|
16028 |
|
16029 |
|
16030 |
|
16031 |
|
16032 |
|
16033 |
|
16034 |
|
16035 |
|
16036 |
|
16037 |
|
16038 |
|
16039 |
|
16040 |
|
16041 |
|
16042 |
|
16043 |
|
16044 |
|
16045 |
|
16046 |
|
16047 |
|
16048 | axis_x_label: {},
|
16049 | |
16050 |
|
16051 |
|
16052 |
|
16053 |
|
16054 |
|
16055 |
|
16056 |
|
16057 |
|
16058 |
|
16059 |
|
16060 |
|
16061 |
|
16062 |
|
16063 |
|
16064 |
|
16065 |
|
16066 |
|
16067 |
|
16068 |
|
16069 |
|
16070 |
|
16071 |
|
16072 |
|
16073 |
|
16074 |
|
16075 |
|
16076 |
|
16077 |
|
16078 |
|
16079 |
|
16080 |
|
16081 |
|
16082 |
|
16083 |
|
16084 |
|
16085 |
|
16086 | axis_x_axes: []
|
16087 | });
|
16088 |
|
16089 | ;
|
16090 | var y = ({
|
16091 | |
16092 |
|
16093 |
|
16094 |
|
16095 |
|
16096 |
|
16097 |
|
16098 |
|
16099 |
|
16100 |
|
16101 |
|
16102 | axis_y_clipPath: true,
|
16103 | |
16104 |
|
16105 |
|
16106 |
|
16107 |
|
16108 |
|
16109 |
|
16110 |
|
16111 |
|
16112 |
|
16113 |
|
16114 |
|
16115 |
|
16116 | axis_y_show: true,
|
16117 | |
16118 |
|
16119 |
|
16120 |
|
16121 |
|
16122 |
|
16123 |
|
16124 |
|
16125 |
|
16126 |
|
16127 |
|
16128 |
|
16129 |
|
16130 |
|
16131 |
|
16132 |
|
16133 |
|
16134 |
|
16135 |
|
16136 |
|
16137 |
|
16138 |
|
16139 |
|
16140 |
|
16141 |
|
16142 | axis_y_type: "indexed",
|
16143 | |
16144 |
|
16145 |
|
16146 |
|
16147 |
|
16148 |
|
16149 |
|
16150 |
|
16151 |
|
16152 |
|
16153 |
|
16154 |
|
16155 |
|
16156 |
|
16157 | axis_y_max: void 0,
|
16158 | |
16159 |
|
16160 |
|
16161 |
|
16162 |
|
16163 |
|
16164 |
|
16165 |
|
16166 |
|
16167 |
|
16168 |
|
16169 |
|
16170 |
|
16171 |
|
16172 |
|
16173 | axis_y_min: void 0,
|
16174 | |
16175 |
|
16176 |
|
16177 |
|
16178 |
|
16179 |
|
16180 |
|
16181 |
|
16182 |
|
16183 |
|
16184 |
|
16185 |
|
16186 |
|
16187 |
|
16188 |
|
16189 | axis_y_inverted: false,
|
16190 | |
16191 |
|
16192 |
|
16193 |
|
16194 |
|
16195 |
|
16196 |
|
16197 |
|
16198 |
|
16199 |
|
16200 |
|
16201 |
|
16202 |
|
16203 | axis_y_center: void 0,
|
16204 | |
16205 |
|
16206 |
|
16207 |
|
16208 |
|
16209 |
|
16210 |
|
16211 |
|
16212 |
|
16213 |
|
16214 |
|
16215 |
|
16216 |
|
16217 | axis_y_inner: false,
|
16218 | |
16219 |
|
16220 |
|
16221 |
|
16222 |
|
16223 |
|
16224 |
|
16225 |
|
16226 |
|
16227 |
|
16228 |
|
16229 |
|
16230 |
|
16231 |
|
16232 |
|
16233 |
|
16234 |
|
16235 |
|
16236 |
|
16237 |
|
16238 |
|
16239 |
|
16240 |
|
16241 |
|
16242 | axis_y_label: {},
|
16243 | |
16244 |
|
16245 |
|
16246 |
|
16247 |
|
16248 |
|
16249 |
|
16250 |
|
16251 |
|
16252 |
|
16253 |
|
16254 |
|
16255 |
|
16256 |
|
16257 |
|
16258 |
|
16259 |
|
16260 |
|
16261 | axis_y_tick_format: void 0,
|
16262 | |
16263 |
|
16264 |
|
16265 |
|
16266 |
|
16267 |
|
16268 |
|
16269 |
|
16270 |
|
16271 |
|
16272 |
|
16273 |
|
16274 |
|
16275 |
|
16276 |
|
16277 |
|
16278 |
|
16279 |
|
16280 |
|
16281 | axis_y_tick_culling: false,
|
16282 | |
16283 |
|
16284 |
|
16285 |
|
16286 |
|
16287 |
|
16288 |
|
16289 |
|
16290 |
|
16291 |
|
16292 |
|
16293 |
|
16294 |
|
16295 |
|
16296 |
|
16297 |
|
16298 |
|
16299 | axis_y_tick_culling_max: 5,
|
16300 | |
16301 |
|
16302 |
|
16303 |
|
16304 |
|
16305 |
|
16306 |
|
16307 |
|
16308 |
|
16309 |
|
16310 |
|
16311 |
|
16312 |
|
16313 |
|
16314 |
|
16315 |
|
16316 |
|
16317 | axis_y_tick_culling_lines: true,
|
16318 | |
16319 |
|
16320 |
|
16321 |
|
16322 |
|
16323 |
|
16324 |
|
16325 |
|
16326 |
|
16327 |
|
16328 |
|
16329 |
|
16330 |
|
16331 |
|
16332 |
|
16333 | axis_y_tick_outer: true,
|
16334 | |
16335 |
|
16336 |
|
16337 |
|
16338 |
|
16339 |
|
16340 |
|
16341 |
|
16342 |
|
16343 |
|
16344 |
|
16345 |
|
16346 |
|
16347 |
|
16348 |
|
16349 |
|
16350 |
|
16351 |
|
16352 |
|
16353 |
|
16354 | axis_y_tick_values: null,
|
16355 | |
16356 |
|
16357 |
|
16358 |
|
16359 |
|
16360 |
|
16361 |
|
16362 |
|
16363 |
|
16364 |
|
16365 |
|
16366 |
|
16367 |
|
16368 |
|
16369 |
|
16370 |
|
16371 |
|
16372 | axis_y_tick_rotate: 0,
|
16373 | |
16374 |
|
16375 |
|
16376 |
|
16377 |
|
16378 |
|
16379 |
|
16380 |
|
16381 |
|
16382 |
|
16383 |
|
16384 |
|
16385 |
|
16386 |
|
16387 |
|
16388 |
|
16389 | axis_y_tick_count: void 0,
|
16390 | |
16391 |
|
16392 |
|
16393 |
|
16394 |
|
16395 |
|
16396 |
|
16397 |
|
16398 |
|
16399 |
|
16400 |
|
16401 |
|
16402 |
|
16403 |
|
16404 |
|
16405 |
|
16406 | axis_y_tick_show: true,
|
16407 | |
16408 |
|
16409 |
|
16410 |
|
16411 |
|
16412 |
|
16413 |
|
16414 |
|
16415 |
|
16416 |
|
16417 |
|
16418 |
|
16419 |
|
16420 |
|
16421 |
|
16422 |
|
16423 |
|
16424 |
|
16425 | axis_y_tick_stepSize: null,
|
16426 | |
16427 |
|
16428 |
|
16429 |
|
16430 |
|
16431 |
|
16432 |
|
16433 |
|
16434 |
|
16435 |
|
16436 |
|
16437 |
|
16438 |
|
16439 |
|
16440 |
|
16441 |
|
16442 |
|
16443 |
|
16444 | axis_y_tick_text_show: true,
|
16445 | |
16446 |
|
16447 |
|
16448 |
|
16449 |
|
16450 |
|
16451 |
|
16452 |
|
16453 |
|
16454 |
|
16455 |
|
16456 |
|
16457 |
|
16458 |
|
16459 |
|
16460 |
|
16461 |
|
16462 |
|
16463 |
|
16464 |
|
16465 | axis_y_tick_text_position: { x: 0, y: 0 },
|
16466 | |
16467 |
|
16468 |
|
16469 |
|
16470 |
|
16471 |
|
16472 |
|
16473 |
|
16474 |
|
16475 |
|
16476 |
|
16477 |
|
16478 |
|
16479 |
|
16480 |
|
16481 |
|
16482 |
|
16483 |
|
16484 |
|
16485 |
|
16486 |
|
16487 |
|
16488 |
|
16489 | axis_y_tick_time_value: void 0,
|
16490 | |
16491 |
|
16492 |
|
16493 |
|
16494 |
|
16495 |
|
16496 |
|
16497 |
|
16498 |
|
16499 |
|
16500 |
|
16501 |
|
16502 |
|
16503 |
|
16504 |
|
16505 |
|
16506 |
|
16507 |
|
16508 |
|
16509 |
|
16510 |
|
16511 |
|
16512 |
|
16513 |
|
16514 |
|
16515 | axis_y_padding: {},
|
16516 | |
16517 |
|
16518 |
|
16519 |
|
16520 |
|
16521 |
|
16522 |
|
16523 |
|
16524 |
|
16525 |
|
16526 |
|
16527 |
|
16528 |
|
16529 |
|
16530 | axis_y_default: void 0,
|
16531 | |
16532 |
|
16533 |
|
16534 |
|
16535 |
|
16536 |
|
16537 |
|
16538 |
|
16539 |
|
16540 |
|
16541 |
|
16542 |
|
16543 |
|
16544 |
|
16545 |
|
16546 |
|
16547 |
|
16548 |
|
16549 |
|
16550 |
|
16551 |
|
16552 |
|
16553 |
|
16554 |
|
16555 |
|
16556 |
|
16557 |
|
16558 |
|
16559 |
|
16560 |
|
16561 |
|
16562 |
|
16563 |
|
16564 |
|
16565 |
|
16566 |
|
16567 |
|
16568 | axis_y_axes: []
|
16569 | });
|
16570 |
|
16571 | ;
|
16572 | var y2 = ({
|
16573 | |
16574 |
|
16575 |
|
16576 |
|
16577 |
|
16578 |
|
16579 |
|
16580 |
|
16581 |
|
16582 |
|
16583 |
|
16584 |
|
16585 |
|
16586 |
|
16587 |
|
16588 |
|
16589 | axis_y2_show: false,
|
16590 | |
16591 |
|
16592 |
|
16593 |
|
16594 |
|
16595 |
|
16596 |
|
16597 |
|
16598 |
|
16599 |
|
16600 |
|
16601 |
|
16602 |
|
16603 |
|
16604 |
|
16605 |
|
16606 |
|
16607 |
|
16608 |
|
16609 |
|
16610 |
|
16611 |
|
16612 |
|
16613 |
|
16614 |
|
16615 | axis_y2_type: "indexed",
|
16616 | |
16617 |
|
16618 |
|
16619 |
|
16620 |
|
16621 |
|
16622 |
|
16623 |
|
16624 |
|
16625 |
|
16626 |
|
16627 |
|
16628 |
|
16629 | axis_y2_max: void 0,
|
16630 | |
16631 |
|
16632 |
|
16633 |
|
16634 |
|
16635 |
|
16636 |
|
16637 |
|
16638 |
|
16639 |
|
16640 |
|
16641 |
|
16642 |
|
16643 | axis_y2_min: void 0,
|
16644 | |
16645 |
|
16646 |
|
16647 |
|
16648 |
|
16649 |
|
16650 |
|
16651 |
|
16652 |
|
16653 |
|
16654 |
|
16655 |
|
16656 |
|
16657 |
|
16658 |
|
16659 | axis_y2_inverted: false,
|
16660 | |
16661 |
|
16662 |
|
16663 |
|
16664 |
|
16665 |
|
16666 |
|
16667 |
|
16668 |
|
16669 |
|
16670 |
|
16671 |
|
16672 |
|
16673 | axis_y2_center: void 0,
|
16674 | |
16675 |
|
16676 |
|
16677 |
|
16678 |
|
16679 |
|
16680 |
|
16681 |
|
16682 |
|
16683 |
|
16684 |
|
16685 |
|
16686 |
|
16687 | axis_y2_inner: false,
|
16688 | |
16689 |
|
16690 |
|
16691 |
|
16692 |
|
16693 |
|
16694 |
|
16695 |
|
16696 |
|
16697 |
|
16698 |
|
16699 |
|
16700 |
|
16701 |
|
16702 |
|
16703 |
|
16704 |
|
16705 |
|
16706 |
|
16707 |
|
16708 |
|
16709 |
|
16710 |
|
16711 |
|
16712 | axis_y2_label: {},
|
16713 | |
16714 |
|
16715 |
|
16716 |
|
16717 |
|
16718 |
|
16719 |
|
16720 |
|
16721 |
|
16722 |
|
16723 |
|
16724 |
|
16725 |
|
16726 |
|
16727 |
|
16728 |
|
16729 |
|
16730 | axis_y2_tick_format: void 0,
|
16731 | |
16732 |
|
16733 |
|
16734 |
|
16735 |
|
16736 |
|
16737 |
|
16738 |
|
16739 |
|
16740 |
|
16741 |
|
16742 |
|
16743 |
|
16744 |
|
16745 |
|
16746 |
|
16747 |
|
16748 |
|
16749 |
|
16750 | axis_y2_tick_culling: false,
|
16751 | |
16752 |
|
16753 |
|
16754 |
|
16755 |
|
16756 |
|
16757 |
|
16758 |
|
16759 |
|
16760 |
|
16761 |
|
16762 |
|
16763 |
|
16764 |
|
16765 |
|
16766 |
|
16767 |
|
16768 | axis_y2_tick_culling_max: 5,
|
16769 | |
16770 |
|
16771 |
|
16772 |
|
16773 |
|
16774 |
|
16775 |
|
16776 |
|
16777 |
|
16778 |
|
16779 |
|
16780 |
|
16781 |
|
16782 |
|
16783 |
|
16784 |
|
16785 |
|
16786 | axis_y2_tick_culling_lines: true,
|
16787 | |
16788 |
|
16789 |
|
16790 |
|
16791 |
|
16792 |
|
16793 |
|
16794 |
|
16795 |
|
16796 |
|
16797 |
|
16798 |
|
16799 |
|
16800 |
|
16801 |
|
16802 | axis_y2_tick_outer: true,
|
16803 | |
16804 |
|
16805 |
|
16806 |
|
16807 |
|
16808 |
|
16809 |
|
16810 |
|
16811 |
|
16812 |
|
16813 |
|
16814 |
|
16815 |
|
16816 |
|
16817 |
|
16818 |
|
16819 |
|
16820 |
|
16821 |
|
16822 |
|
16823 | axis_y2_tick_values: null,
|
16824 | |
16825 |
|
16826 |
|
16827 |
|
16828 |
|
16829 |
|
16830 |
|
16831 |
|
16832 |
|
16833 |
|
16834 |
|
16835 |
|
16836 |
|
16837 |
|
16838 |
|
16839 |
|
16840 |
|
16841 | axis_y2_tick_rotate: 0,
|
16842 | |
16843 |
|
16844 |
|
16845 |
|
16846 |
|
16847 |
|
16848 |
|
16849 |
|
16850 |
|
16851 |
|
16852 |
|
16853 |
|
16854 |
|
16855 |
|
16856 |
|
16857 |
|
16858 | axis_y2_tick_count: void 0,
|
16859 | |
16860 |
|
16861 |
|
16862 |
|
16863 |
|
16864 |
|
16865 |
|
16866 |
|
16867 |
|
16868 |
|
16869 |
|
16870 |
|
16871 |
|
16872 |
|
16873 |
|
16874 |
|
16875 | axis_y2_tick_show: true,
|
16876 | |
16877 |
|
16878 |
|
16879 |
|
16880 |
|
16881 |
|
16882 |
|
16883 |
|
16884 |
|
16885 |
|
16886 |
|
16887 |
|
16888 |
|
16889 |
|
16890 |
|
16891 |
|
16892 |
|
16893 |
|
16894 | axis_y2_tick_stepSize: null,
|
16895 | |
16896 |
|
16897 |
|
16898 |
|
16899 |
|
16900 |
|
16901 |
|
16902 |
|
16903 |
|
16904 |
|
16905 |
|
16906 |
|
16907 |
|
16908 |
|
16909 |
|
16910 |
|
16911 |
|
16912 |
|
16913 | axis_y2_tick_text_show: true,
|
16914 | |
16915 |
|
16916 |
|
16917 |
|
16918 |
|
16919 |
|
16920 |
|
16921 |
|
16922 |
|
16923 |
|
16924 |
|
16925 |
|
16926 |
|
16927 |
|
16928 |
|
16929 |
|
16930 |
|
16931 |
|
16932 |
|
16933 |
|
16934 | axis_y2_tick_text_position: { x: 0, y: 0 },
|
16935 | |
16936 |
|
16937 |
|
16938 |
|
16939 |
|
16940 |
|
16941 |
|
16942 |
|
16943 |
|
16944 |
|
16945 |
|
16946 |
|
16947 |
|
16948 |
|
16949 |
|
16950 |
|
16951 |
|
16952 |
|
16953 |
|
16954 |
|
16955 |
|
16956 |
|
16957 |
|
16958 |
|
16959 | axis_y2_padding: {},
|
16960 | |
16961 |
|
16962 |
|
16963 |
|
16964 |
|
16965 |
|
16966 |
|
16967 |
|
16968 |
|
16969 |
|
16970 |
|
16971 |
|
16972 |
|
16973 |
|
16974 | axis_y2_default: void 0,
|
16975 | |
16976 |
|
16977 |
|
16978 |
|
16979 |
|
16980 |
|
16981 |
|
16982 |
|
16983 |
|
16984 |
|
16985 |
|
16986 |
|
16987 |
|
16988 |
|
16989 |
|
16990 |
|
16991 |
|
16992 |
|
16993 |
|
16994 |
|
16995 |
|
16996 |
|
16997 |
|
16998 |
|
16999 |
|
17000 |
|
17001 |
|
17002 |
|
17003 |
|
17004 |
|
17005 |
|
17006 |
|
17007 |
|
17008 |
|
17009 |
|
17010 |
|
17011 |
|
17012 | axis_y2_axes: []
|
17013 | });
|
17014 |
|
17015 | ;
|
17016 | var axis_defProp = Object.defineProperty;
|
17017 | var axis_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
17018 | var axis_hasOwnProp = Object.prototype.hasOwnProperty;
|
17019 | var axis_propIsEnum = Object.prototype.propertyIsEnumerable;
|
17020 | var axis_defNormalProp = (obj, key, value) => key in obj ? axis_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
17021 | var axis_spreadValues = (a, b) => {
|
17022 | for (var prop in b || (b = {}))
|
17023 | if (axis_hasOwnProp.call(b, prop))
|
17024 | axis_defNormalProp(a, prop, b[prop]);
|
17025 | if (axis_getOwnPropSymbols)
|
17026 | for (var prop of axis_getOwnPropSymbols(b)) {
|
17027 | if (axis_propIsEnum.call(b, prop))
|
17028 | axis_defNormalProp(a, prop, b[prop]);
|
17029 | }
|
17030 | return a;
|
17031 | };
|
17032 |
|
17033 |
|
17034 |
|
17035 | var axis_axis = (axis_spreadValues(axis_spreadValues(axis_spreadValues({
|
17036 | |
17037 |
|
17038 |
|
17039 |
|
17040 |
|
17041 |
|
17042 |
|
17043 |
|
17044 |
|
17045 |
|
17046 |
|
17047 |
|
17048 |
|
17049 |
|
17050 |
|
17051 |
|
17052 |
|
17053 |
|
17054 |
|
17055 |
|
17056 |
|
17057 |
|
17058 |
|
17059 |
|
17060 |
|
17061 |
|
17062 |
|
17063 |
|
17064 | axis_evalTextSize: true,
|
17065 | |
17066 |
|
17067 |
|
17068 |
|
17069 |
|
17070 |
|
17071 |
|
17072 |
|
17073 |
|
17074 |
|
17075 |
|
17076 | axis_rotated: false,
|
17077 | |
17078 |
|
17079 |
|
17080 |
|
17081 |
|
17082 |
|
17083 |
|
17084 |
|
17085 |
|
17086 |
|
17087 |
|
17088 |
|
17089 |
|
17090 |
|
17091 |
|
17092 |
|
17093 |
|
17094 |
|
17095 |
|
17096 |
|
17097 |
|
17098 |
|
17099 |
|
17100 |
|
17101 |
|
17102 |
|
17103 |
|
17104 |
|
17105 |
|
17106 |
|
17107 |
|
17108 |
|
17109 | axis_tooltip: false
|
17110 | }, axis_x), y), y2));
|
17111 |
|
17112 | ;
|
17113 | var common_grid = ({
|
17114 | |
17115 |
|
17116 |
|
17117 |
|
17118 |
|
17119 |
|
17120 |
|
17121 |
|
17122 |
|
17123 |
|
17124 |
|
17125 |
|
17126 |
|
17127 |
|
17128 |
|
17129 |
|
17130 |
|
17131 |
|
17132 |
|
17133 |
|
17134 |
|
17135 |
|
17136 |
|
17137 |
|
17138 |
|
17139 |
|
17140 |
|
17141 |
|
17142 |
|
17143 |
|
17144 |
|
17145 |
|
17146 |
|
17147 |
|
17148 |
|
17149 |
|
17150 |
|
17151 |
|
17152 |
|
17153 |
|
17154 |
|
17155 |
|
17156 |
|
17157 |
|
17158 |
|
17159 |
|
17160 |
|
17161 |
|
17162 |
|
17163 |
|
17164 |
|
17165 |
|
17166 |
|
17167 |
|
17168 |
|
17169 |
|
17170 |
|
17171 |
|
17172 | grid_x_show: false,
|
17173 | grid_x_type: "tick",
|
17174 | grid_x_lines: [],
|
17175 | grid_y_show: false,
|
17176 | grid_y_lines: [],
|
17177 | grid_y_ticks: void 0,
|
17178 | grid_focus_edge: false,
|
17179 | grid_focus_show: true,
|
17180 | grid_focus_y: false,
|
17181 | grid_front: false,
|
17182 | grid_lines_front: true
|
17183 | });
|
17184 |
|
17185 | ;
|
17186 | var data_axis = ({
|
17187 | |
17188 |
|
17189 |
|
17190 |
|
17191 |
|
17192 |
|
17193 |
|
17194 |
|
17195 |
|
17196 |
|
17197 |
|
17198 |
|
17199 |
|
17200 |
|
17201 |
|
17202 | data_xs: {},
|
17203 | |
17204 |
|
17205 |
|
17206 |
|
17207 |
|
17208 |
|
17209 |
|
17210 |
|
17211 |
|
17212 |
|
17213 |
|
17214 |
|
17215 |
|
17216 |
|
17217 |
|
17218 |
|
17219 |
|
17220 |
|
17221 |
|
17222 |
|
17223 |
|
17224 |
|
17225 |
|
17226 | data_xFormat: "%Y-%m-%d",
|
17227 | |
17228 |
|
17229 |
|
17230 |
|
17231 |
|
17232 |
|
17233 |
|
17234 |
|
17235 |
|
17236 |
|
17237 |
|
17238 | data_xLocaltime: true,
|
17239 | |
17240 |
|
17241 |
|
17242 |
|
17243 |
|
17244 |
|
17245 |
|
17246 |
|
17247 |
|
17248 |
|
17249 |
|
17250 |
|
17251 |
|
17252 |
|
17253 |
|
17254 |
|
17255 |
|
17256 |
|
17257 |
|
17258 |
|
17259 | data_xSort: true,
|
17260 | |
17261 |
|
17262 |
|
17263 |
|
17264 |
|
17265 |
|
17266 |
|
17267 |
|
17268 |
|
17269 |
|
17270 |
|
17271 |
|
17272 |
|
17273 |
|
17274 |
|
17275 | data_axes: {},
|
17276 | |
17277 |
|
17278 |
|
17279 |
|
17280 |
|
17281 |
|
17282 |
|
17283 |
|
17284 |
|
17285 |
|
17286 |
|
17287 |
|
17288 |
|
17289 |
|
17290 |
|
17291 |
|
17292 |
|
17293 |
|
17294 |
|
17295 |
|
17296 |
|
17297 |
|
17298 |
|
17299 |
|
17300 |
|
17301 |
|
17302 |
|
17303 |
|
17304 |
|
17305 |
|
17306 |
|
17307 |
|
17308 | data_regions: {},
|
17309 | |
17310 |
|
17311 |
|
17312 |
|
17313 |
|
17314 |
|
17315 |
|
17316 |
|
17317 |
|
17318 |
|
17319 |
|
17320 |
|
17321 |
|
17322 |
|
17323 |
|
17324 |
|
17325 |
|
17326 |
|
17327 | data_stack_normalize: false
|
17328 | });
|
17329 |
|
17330 | ;
|
17331 |
|
17332 |
|
17333 |
|
17334 |
|
17335 |
|
17336 |
|
17337 |
|
17338 |
|
17339 |
|
17340 |
|
17341 |
|
17342 |
|
17343 |
|
17344 |
|
17345 |
|
17346 |
|
17347 |
|
17348 | const api = [
|
17349 | api_axis,
|
17350 | api_category,
|
17351 | flow,
|
17352 | api_grid,
|
17353 | group,
|
17354 | api_regions,
|
17355 | x
|
17356 | ];
|
17357 | const internal = {
|
17358 | axis: Axis,
|
17359 | clip: clip,
|
17360 | eventrect: eventrect,
|
17361 | flow: interactions_flow,
|
17362 | grid: internals_grid,
|
17363 | region: region,
|
17364 | sizeAxis: size_axis
|
17365 | };
|
17366 | const options = {
|
17367 | optDataAxis: data_axis,
|
17368 | optAxis: axis_axis,
|
17369 | optGrid: common_grid
|
17370 | };
|
17371 |
|
17372 |
|
17373 | var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(13);
|
17374 | ;
|
17375 | var arc_defProp = Object.defineProperty;
|
17376 | var arc_defProps = Object.defineProperties;
|
17377 | var arc_getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
17378 | var arc_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
17379 | var arc_hasOwnProp = Object.prototype.hasOwnProperty;
|
17380 | var arc_propIsEnum = Object.prototype.propertyIsEnumerable;
|
17381 | var arc_defNormalProp = (obj, key, value) => key in obj ? arc_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
17382 | var arc_spreadValues = (a, b) => {
|
17383 | for (var prop in b || (b = {}))
|
17384 | if (arc_hasOwnProp.call(b, prop))
|
17385 | arc_defNormalProp(a, prop, b[prop]);
|
17386 | if (arc_getOwnPropSymbols)
|
17387 | for (var prop of arc_getOwnPropSymbols(b)) {
|
17388 | if (arc_propIsEnum.call(b, prop))
|
17389 | arc_defNormalProp(a, prop, b[prop]);
|
17390 | }
|
17391 | return a;
|
17392 | };
|
17393 | var arc_spreadProps = (a, b) => arc_defProps(a, arc_getOwnPropDescs(b));
|
17394 |
|
17395 |
|
17396 |
|
17397 |
|
17398 |
|
17399 |
|
17400 | function getRadiusFn(expandRate = 0) {
|
17401 | const $$ = this;
|
17402 | const { config, state } = $$;
|
17403 | const hasMultiArcGauge = $$.hasMultiArcGauge();
|
17404 | const singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
|
17405 | const expandWidth = expandRate ? Math.min(
|
17406 | state.radiusExpanded * expandRate - state.radius,
|
17407 | singleArcWidth * 0.8 - (1 - expandRate) * 100
|
17408 | ) : 0;
|
17409 | return {
|
17410 | |
17411 |
|
17412 |
|
17413 |
|
17414 |
|
17415 |
|
17416 | inner(d) {
|
17417 | const { innerRadius } = $$.getRadius(d);
|
17418 | return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : isNumber(innerRadius) ? innerRadius : 0;
|
17419 | },
|
17420 | |
17421 |
|
17422 |
|
17423 |
|
17424 |
|
17425 |
|
17426 | outer(d) {
|
17427 | const { outerRadius } = $$.getRadius(d);
|
17428 | let radius;
|
17429 | if (hasMultiArcGauge) {
|
17430 | radius = state.radius - singleArcWidth * d.index + expandWidth;
|
17431 | } else if ($$.hasType("polar") && !expandRate) {
|
17432 | radius = $$.getPolarOuterRadius(d, outerRadius);
|
17433 | } else {
|
17434 | radius = outerRadius;
|
17435 | if (expandRate) {
|
17436 | let { radiusExpanded } = state;
|
17437 | if (state.radius !== outerRadius) {
|
17438 | radiusExpanded -= Math.abs(state.radius - outerRadius);
|
17439 | }
|
17440 | radius = radiusExpanded * expandRate;
|
17441 | }
|
17442 | }
|
17443 | return radius;
|
17444 | },
|
17445 | |
17446 |
|
17447 |
|
17448 |
|
17449 |
|
17450 |
|
17451 |
|
17452 | corner(d, outerRadius) {
|
17453 | const {
|
17454 | arc_cornerRadius_ratio: ratio = 0,
|
17455 | arc_cornerRadius: cornerRadius = 0
|
17456 | } = config;
|
17457 | const { data: { id }, value } = d;
|
17458 | let corner = 0;
|
17459 | if (ratio) {
|
17460 | corner = ratio * outerRadius;
|
17461 | } else {
|
17462 | corner = isNumber(cornerRadius) ? cornerRadius : cornerRadius.call($$.api, id, value, outerRadius);
|
17463 | }
|
17464 | return corner;
|
17465 | }
|
17466 | };
|
17467 | }
|
17468 | function getAttrTweenFn(fn) {
|
17469 | return function(d) {
|
17470 | const getAngleKeyValue = ({ startAngle = 0, endAngle = 0, padAngle = 0 }) => ({
|
17471 | startAngle,
|
17472 | endAngle,
|
17473 | padAngle
|
17474 | });
|
17475 | const interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(
|
17476 | getAngleKeyValue(this._current),
|
17477 | getAngleKeyValue(d)
|
17478 | );
|
17479 | this._current = d;
|
17480 | return function(t) {
|
17481 | const interpolated = interpolate(t);
|
17482 | const { data, index, value } = d;
|
17483 | return fn(arc_spreadProps(arc_spreadValues({}, interpolated), { data, index, value }));
|
17484 | };
|
17485 | };
|
17486 | }
|
17487 | var arc = ({
|
17488 | initPie() {
|
17489 | const $$ = this;
|
17490 | const { config } = $$;
|
17491 | const dataType = config.data_type;
|
17492 | const padding = config[`${dataType}_padding`];
|
17493 | const startingAngle = config[`${dataType}_startingAngle`] || 0;
|
17494 | const padAngle = (padding ? padding * 0.01 : config[`${dataType}_padAngle`]) || 0;
|
17495 | $$.pie = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.pie)().startAngle(startingAngle).endAngle(startingAngle + 2 * Math.PI).padAngle(padAngle).value((d) => {
|
17496 | var _a, _b;
|
17497 | return (_b = (_a = d.values) == null ? void 0 : _a.reduce((a, b) => a + b.value, 0)) != null ? _b : d;
|
17498 | }).sort($$.getSortCompareFn.bind($$)(true));
|
17499 | },
|
17500 | updateRadius() {
|
17501 | const $$ = this;
|
17502 | const { config, state } = $$;
|
17503 | const dataType = config.data_type;
|
17504 | const padding = config[`${dataType}_padding`];
|
17505 | const w = config.gauge_width || config.donut_width;
|
17506 | const gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length * config.gauge_arcs_minWidth;
|
17507 | state.radiusExpanded = Math.min(state.arcWidth, state.arcHeight) / 2 * ($$.hasMultiArcGauge() && config.gauge_label_show ? 0.85 : 1);
|
17508 | state.radius = state.radiusExpanded * 0.95;
|
17509 | state.innerRadiusRatio = w ? (state.radius - w) / state.radius : 0.6;
|
17510 | state.gaugeArcWidth = w || (gaugeArcWidth <= state.radius - state.innerRadius ? state.radius - state.innerRadius : gaugeArcWidth <= state.radius ? gaugeArcWidth : state.radius);
|
17511 | const innerRadius = config.pie_innerRadius || (padding ? padding * (state.innerRadiusRatio + 0.1) : 0);
|
17512 | state.outerRadius = config.pie_outerRadius;
|
17513 | state.innerRadius = $$.hasType("donut") || $$.hasType("gauge") ? state.radius * state.innerRadiusRatio : innerRadius;
|
17514 | },
|
17515 | |
17516 |
|
17517 |
|
17518 |
|
17519 |
|
17520 |
|
17521 | getRadius(d) {
|
17522 | const $$ = this;
|
17523 | const data = d == null ? void 0 : d.data;
|
17524 | let { innerRadius, outerRadius } = $$.state;
|
17525 | if (!isNumber(innerRadius) && data) {
|
17526 | innerRadius = innerRadius[data.id] || 0;
|
17527 | }
|
17528 | if (isObject(outerRadius) && data && data.id in outerRadius) {
|
17529 | outerRadius = outerRadius[data.id];
|
17530 | } else if (!isNumber(outerRadius)) {
|
17531 | outerRadius = $$.state.radius;
|
17532 | }
|
17533 | return { innerRadius, outerRadius };
|
17534 | },
|
17535 | updateArc() {
|
17536 | const $$ = this;
|
17537 | $$.updateRadius();
|
17538 | $$.svgArc = $$.getSvgArc();
|
17539 | $$.svgArcExpanded = $$.getSvgArcExpanded();
|
17540 | },
|
17541 | getArcLength() {
|
17542 | const $$ = this;
|
17543 | const { config } = $$;
|
17544 | const arcLengthInPercent = config.gauge_arcLength * 3.6;
|
17545 | let len = 2 * (arcLengthInPercent / 360);
|
17546 | if (arcLengthInPercent < -360) {
|
17547 | len = -2;
|
17548 | } else if (arcLengthInPercent > 360) {
|
17549 | len = 2;
|
17550 | }
|
17551 | return len * Math.PI;
|
17552 | },
|
17553 | getStartingAngle() {
|
17554 | const $$ = this;
|
17555 | const { config } = $$;
|
17556 | const dataType = config.data_type;
|
17557 | const isFullCircle = $$.hasType("gauge") ? config.gauge_fullCircle : false;
|
17558 | const defaultStartAngle = -1 * Math.PI / 2;
|
17559 | const defaultEndAngle = Math.PI / 2;
|
17560 | let startAngle = config[`${dataType}_startingAngle`] || 0;
|
17561 | if (!isFullCircle && startAngle <= defaultStartAngle) {
|
17562 | startAngle = defaultStartAngle;
|
17563 | } else if (!isFullCircle && startAngle >= defaultEndAngle) {
|
17564 | startAngle = defaultEndAngle;
|
17565 | } else if (startAngle > Math.PI || startAngle < -1 * Math.PI) {
|
17566 | startAngle = Math.PI;
|
17567 | }
|
17568 | return startAngle;
|
17569 | },
|
17570 | |
17571 |
|
17572 |
|
17573 |
|
17574 |
|
17575 |
|
17576 |
|
17577 | updateAngle(dValue, forRange = false) {
|
17578 | var _a;
|
17579 | const $$ = this;
|
17580 | const { config, state } = $$;
|
17581 | const hasGauge = forRange && $$.hasType("gauge");
|
17582 | let { pie } = $$;
|
17583 | let d = dValue;
|
17584 | let found = false;
|
17585 | if (!config) {
|
17586 | return null;
|
17587 | }
|
17588 | const gStart = $$.getStartingAngle();
|
17589 | const radius = config.gauge_fullCircle || forRange && !hasGauge ? $$.getArcLength() : gStart * -2;
|
17590 | if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
|
17591 | const { gauge_min: gMin, gauge_max: gMax } = config;
|
17592 | const totalSum = $$.getTotalDataSum(state.rendered);
|
17593 | const gEnd = radius * ((totalSum - gMin) / (gMax - gMin));
|
17594 | pie = pie.startAngle(gStart).endAngle(gEnd + gStart);
|
17595 | }
|
17596 | if (forRange === false) {
|
17597 | pie($$.filterTargetsToShow()).forEach((t, i) => {
|
17598 | var _a2;
|
17599 | if (!found && t.data.id === ((_a2 = d.data) == null ? void 0 : _a2.id)) {
|
17600 | found = true;
|
17601 | d = t;
|
17602 | d.index = i;
|
17603 | }
|
17604 | });
|
17605 | }
|
17606 | if (isNaN(d.startAngle)) {
|
17607 | d.startAngle = 0;
|
17608 | }
|
17609 | if (isNaN(d.endAngle)) {
|
17610 | d.endAngle = d.startAngle;
|
17611 | }
|
17612 | if (forRange || d.data && (config.gauge_enforceMinMax || $$.hasMultiArcGauge())) {
|
17613 | const { gauge_min: gMin, gauge_max: gMax } = config;
|
17614 | const max = forRange && !hasGauge ? $$.getTotalDataSum(state.rendered) : gMax;
|
17615 | const gTic = radius / (max - gMin);
|
17616 | const value = (_a = d.value) != null ? _a : 0;
|
17617 | const gValue = value < gMin ? 0 : value < max ? value - gMin : max - gMin;
|
17618 | d.startAngle = gStart;
|
17619 | d.endAngle = gStart + gTic * gValue;
|
17620 | }
|
17621 | return found || forRange ? d : null;
|
17622 | },
|
17623 | getSvgArc() {
|
17624 | const $$ = this;
|
17625 | const { inner, outer, corner } = getRadiusFn.call($$);
|
17626 | const arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer);
|
17627 | const newArc = function(d, withoutUpdate) {
|
17628 | var _a;
|
17629 | let path = "M 0 0";
|
17630 | if (d.value || d.data) {
|
17631 | const data = withoutUpdate ? d : (_a = $$.updateAngle(d)) != null ? _a : null;
|
17632 | if (data) {
|
17633 | path = arc.cornerRadius(
|
17634 | corner(data, outer(data))
|
17635 | )(data);
|
17636 | }
|
17637 | }
|
17638 | return path;
|
17639 | };
|
17640 | newArc.centroid = arc.centroid;
|
17641 | return newArc;
|
17642 | },
|
17643 | |
17644 |
|
17645 |
|
17646 |
|
17647 |
|
17648 |
|
17649 | getSvgArcExpanded(rate = 1) {
|
17650 | const $$ = this;
|
17651 | const { inner, outer, corner } = getRadiusFn.call($$, rate);
|
17652 | const arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer);
|
17653 | return (d) => {
|
17654 | const updated = $$.updateAngle(d);
|
17655 | const outerR = outer(updated);
|
17656 | let cornerR = 0;
|
17657 | if (updated) {
|
17658 | cornerR = corner(updated, outerR);
|
17659 | }
|
17660 | return updated ? arc.cornerRadius(cornerR)(updated) : "M 0 0";
|
17661 | };
|
17662 | },
|
17663 | getArc(d, withoutUpdate, force) {
|
17664 | return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0";
|
17665 | },
|
17666 | |
17667 |
|
17668 |
|
17669 |
|
17670 | redrawArcRangeText() {
|
17671 | const $$ = this;
|
17672 | const { config, $el: { arcs }, state, $T } = $$;
|
17673 | const format = config.arc_rangeText_format;
|
17674 | const fixed = $$.hasType("gauge") && config.arc_rangeText_fixed;
|
17675 | let values = config.arc_rangeText_values;
|
17676 | if (values == null ? void 0 : values.length) {
|
17677 | const isPercent = config.arc_rangeText_unit === "%";
|
17678 | const totalSum = $$.getTotalDataSum(state.rendered);
|
17679 | if (isPercent) {
|
17680 | values = values.map((v) => totalSum / 100 * v);
|
17681 | }
|
17682 | const pieData = $$.pie(values).map((d, i) => (d.index = i, d));
|
17683 | let rangeText = arcs.selectAll(`.${$ARC.arcRange}`).data(values);
|
17684 | rangeText.exit();
|
17685 | rangeText = $T(rangeText.enter().append("text").attr("class", $ARC.arcRange).style("text-anchor", "middle").style("pointer-events", "none").style("opacity", "0").text((v) => {
|
17686 | const range = isPercent ? v / totalSum * 100 : v;
|
17687 | return isFunction(format) ? format(range) : `${range}${isPercent ? "%" : ""}`;
|
17688 | }).merge(rangeText));
|
17689 | if ((!state.rendered || state.rendered && !fixed) && totalSum > 0) {
|
17690 | rangeText.attr("transform", (d, i) => $$.transformForArcLabel(pieData[i], true));
|
17691 | }
|
17692 | rangeText.style(
|
17693 | "opacity",
|
17694 | (d) => !fixed && (d > totalSum || totalSum === 0) ? "0" : null
|
17695 | );
|
17696 | }
|
17697 | },
|
17698 | |
17699 |
|
17700 |
|
17701 |
|
17702 |
|
17703 |
|
17704 |
|
17705 | transformForArcLabel(d, forRange = false) {
|
17706 | var _a, _b, _c;
|
17707 | const $$ = this;
|
17708 | const { config, state: { radiusExpanded } } = $$;
|
17709 | const updated = $$.updateAngle(d, forRange);
|
17710 | let translate = "";
|
17711 | if (updated) {
|
17712 | if (forRange || $$.hasMultiArcGauge()) {
|
17713 | const y1 = Math.sin(updated.endAngle - Math.PI / 2);
|
17714 | const rangeTextPosition = config.arc_rangeText_position;
|
17715 | let x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + (forRange ? 5 : 25));
|
17716 | let y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
|
17717 | if (forRange && rangeTextPosition) {
|
17718 | const rangeValues = config.arc_rangeText_values;
|
17719 | const pos = isFunction(rangeTextPosition) ? rangeTextPosition(rangeValues[d.index]) : rangeTextPosition;
|
17720 | x += (_a = pos == null ? void 0 : pos.x) != null ? _a : 0;
|
17721 | y += (_b = pos == null ? void 0 : pos.y) != null ? _b : 0;
|
17722 | }
|
17723 | translate = `translate(${x},${y})`;
|
17724 | } else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
|
17725 | let { outerRadius } = $$.getRadius(d);
|
17726 | if ($$.hasType("polar")) {
|
17727 | outerRadius = $$.getPolarOuterRadius(d, outerRadius);
|
17728 | }
|
17729 | const c = this.svgArc.centroid(updated);
|
17730 | const [x, y] = c.map((v) => isNaN(v) ? 0 : v);
|
17731 | const h = Math.sqrt(x * x + y * y);
|
17732 | let ratio = (_c = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).map((v) => config[`${v}_label_ratio`])) == null ? void 0 : _c[0];
|
17733 | if (ratio) {
|
17734 | ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
|
17735 | } else {
|
17736 | ratio = outerRadius && (h ? (36 / outerRadius > 0.375 ? 1.175 - 36 / outerRadius : 0.8) * outerRadius / h : 0);
|
17737 | }
|
17738 | translate = `translate(${x * ratio},${y * ratio})`;
|
17739 | }
|
17740 | }
|
17741 | return translate;
|
17742 | },
|
17743 | convertToArcData(d) {
|
17744 | return this.addName({
|
17745 | id: "data" in d ? d.data.id : d.id,
|
17746 | value: d.value,
|
17747 | ratio: this.getRatio("arc", d),
|
17748 | index: d.index
|
17749 | });
|
17750 | },
|
17751 | textForArcLabel(selection) {
|
17752 | const $$ = this;
|
17753 | const hasGauge = $$.hasType("gauge");
|
17754 | if ($$.shouldShowArcLabel()) {
|
17755 | selection.style("fill", $$.updateTextColor.bind($$)).attr("filter", (d) => $$.updateTextBGColor.bind($$)(d, $$.config.data_labels_backgroundColors)).each(function(d) {
|
17756 | var _a;
|
17757 | const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
17758 | const updated = $$.updateAngle(d);
|
17759 | const ratio = $$.getRatio("arc", updated);
|
17760 | const isUnderThreshold = $$.meetsLabelThreshold(
|
17761 | ratio,
|
17762 | (_a = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) == null ? void 0 : _a[0]
|
17763 | );
|
17764 | if (isUnderThreshold) {
|
17765 | const { value } = updated || d;
|
17766 | const text = ($$.getArcLabelFormat() || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
|
17767 | setTextValue(node, text, [-1, 1], hasGauge);
|
17768 | } else {
|
17769 | node.text("");
|
17770 | }
|
17771 | });
|
17772 | }
|
17773 | },
|
17774 | expandArc(targetIds) {
|
17775 | const $$ = this;
|
17776 | const { state: { transiting }, $el } = $$;
|
17777 | if (transiting) {
|
17778 | const interval = setInterval(() => {
|
17779 | if (!transiting) {
|
17780 | clearInterval(interval);
|
17781 | $el.legend.selectAll(`.${$FOCUS.legendItemFocused}`).size() > 0 && $$.expandArc(targetIds);
|
17782 | }
|
17783 | }, 10);
|
17784 | return;
|
17785 | }
|
17786 | const newTargetIds = $$.mapToTargetIds(targetIds);
|
17787 | $el.svg.selectAll($$.selectorTargets(newTargetIds, `.${$ARC.chartArc}`)).each(function(d) {
|
17788 | if (!$$.shouldExpand(d.data.id)) {
|
17789 | return;
|
17790 | }
|
17791 | const expandDuration = $$.getExpandConfig(d.data.id, "duration");
|
17792 | const svgArcExpandedSub = $$.getSvgArcExpanded(
|
17793 | $$.getExpandConfig(d.data.id, "rate")
|
17794 | );
|
17795 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attrTween("d", getAttrTweenFn($$.svgArcExpanded.bind($$))).transition().duration(expandDuration * 2).attrTween("d", getAttrTweenFn(svgArcExpandedSub.bind($$)));
|
17796 | });
|
17797 | },
|
17798 | unexpandArc(targetIds) {
|
17799 | const $$ = this;
|
17800 | const { state: { transiting }, $el: { svg } } = $$;
|
17801 | if (transiting) {
|
17802 | return;
|
17803 | }
|
17804 | const newTargetIds = $$.mapToTargetIds(targetIds);
|
17805 | svg.selectAll($$.selectorTargets(newTargetIds, `.${$ARC.chartArc}`)).selectAll("path").transition().duration((d) => $$.getExpandConfig(d.data.id, "duration")).attrTween("d", getAttrTweenFn($$.svgArc.bind($$)));
|
17806 | svg.selectAll(`${$ARC.arc}`).style("opacity", null);
|
17807 | },
|
17808 | |
17809 |
|
17810 |
|
17811 |
|
17812 |
|
17813 |
|
17814 |
|
17815 | getExpandConfig(id, key) {
|
17816 | const $$ = this;
|
17817 | const { config } = $$;
|
17818 | const def = {
|
17819 | duration: 50,
|
17820 | rate: 0.98
|
17821 | };
|
17822 | let type;
|
17823 | if ($$.isDonutType(id)) {
|
17824 | type = "donut";
|
17825 | } else if ($$.isGaugeType(id)) {
|
17826 | type = "gauge";
|
17827 | } else if ($$.isPieType(id)) {
|
17828 | type = "pie";
|
17829 | }
|
17830 | return type ? config[`${type}_expand_${key}`] : def[key];
|
17831 | },
|
17832 | shouldExpand(id) {
|
17833 | const $$ = this;
|
17834 | const { config } = $$;
|
17835 | return $$.isDonutType(id) && config.donut_expand || $$.isGaugeType(id) && config.gauge_expand || $$.isPieType(id) && config.pie_expand;
|
17836 | },
|
17837 | shouldShowArcLabel() {
|
17838 | const $$ = this;
|
17839 | const { config } = $$;
|
17840 | return ["donut", "gauge", "pie", "polar"].some((v) => $$.hasType(v) && config[`${v}_label_show`]);
|
17841 | },
|
17842 | getArcLabelFormat() {
|
17843 | const $$ = this;
|
17844 | const { config } = $$;
|
17845 | let format = (v) => v;
|
17846 | ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).forEach((v) => {
|
17847 | format = config[`${v}_label_format`];
|
17848 | });
|
17849 | return isFunction(format) ? format.bind($$.api) : format;
|
17850 | },
|
17851 | updateTargetsForArc(targets) {
|
17852 | const $$ = this;
|
17853 | const { $el } = $$;
|
17854 | const hasGauge = $$.hasType("gauge");
|
17855 | const classChartArc = $$.getChartClass("Arc");
|
17856 | const classArcs = $$.getClass("arcs", true);
|
17857 | const classFocus = $$.classFocus.bind($$);
|
17858 | const chartArcs = $el.main.select(`.${$ARC.chartArcs}`);
|
17859 | const mainPieUpdate = chartArcs.selectAll(`.${$ARC.chartArc}`).data($$.pie(targets)).attr("class", (d) => classChartArc(d) + classFocus(d.data));
|
17860 | const mainPieEnter = mainPieUpdate.enter().append("g").attr("class", classChartArc).call(
|
17861 | this.setCssRule(false, `.${$ARC.chartArcs} text`, [
|
17862 | "pointer-events:none",
|
17863 | "text-anchor:middle"
|
17864 | ])
|
17865 | );
|
17866 | mainPieEnter.append("g").attr("class", classArcs).merge(mainPieUpdate);
|
17867 | mainPieEnter.append("text").attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" : ".35em").style("opacity", "0").style("text-anchor", $$.getStylePropValue("middle")).style("pointer-events", $$.getStylePropValue("none"));
|
17868 | $el.text = chartArcs.selectAll(`.${$COMMON.target} text`);
|
17869 | },
|
17870 | initArc() {
|
17871 | const $$ = this;
|
17872 | const { $el } = $$;
|
17873 | $el.arcs = $el.main.select(`.${$COMMON.chart}`).append("g").attr("class", $ARC.chartArcs).attr("transform", $$.getTranslate("arc"));
|
17874 | $$.setArcTitle();
|
17875 | },
|
17876 | |
17877 |
|
17878 |
|
17879 |
|
17880 |
|
17881 | setArcTitle(str) {
|
17882 | const $$ = this;
|
17883 | const title = str || $$.getArcTitle();
|
17884 | const hasGauge = $$.hasType("gauge");
|
17885 | if (title) {
|
17886 | const className = hasGauge ? $GAUGE.chartArcsGaugeTitle : $ARC.chartArcsTitle;
|
17887 | let text = $$.$el.arcs.select(`.${className}`);
|
17888 | if (text.empty()) {
|
17889 | text = $$.$el.arcs.append("text").attr("class", className).style("text-anchor", "middle");
|
17890 | }
|
17891 | hasGauge && text.attr("dy", "-0.3em");
|
17892 | setTextValue(text, title, hasGauge ? void 0 : [-0.6, 1.35], true);
|
17893 | }
|
17894 | },
|
17895 | |
17896 |
|
17897 |
|
17898 |
|
17899 |
|
17900 | getArcTitle() {
|
17901 | const $$ = this;
|
17902 | const type = $$.hasType("donut") && "donut" || $$.hasType("gauge") && "gauge";
|
17903 | return type ? $$.config[`${type}_title`] : "";
|
17904 | },
|
17905 | |
17906 |
|
17907 |
|
17908 |
|
17909 |
|
17910 | getArcTitleWithNeedleValue() {
|
17911 | const $$ = this;
|
17912 | const { config, state } = $$;
|
17913 | const title = $$.getArcTitle();
|
17914 | if (title && $$.config.arc_needle_show && /{=[A-Z_]+}/.test(title)) {
|
17915 | let value = state.current.needle;
|
17916 | if (!isNumber(value)) {
|
17917 | value = config.arc_needle_value;
|
17918 | }
|
17919 | return tplProcess(title, {
|
17920 | NEEDLE_VALUE: isNumber(value) ? value : 0
|
17921 | });
|
17922 | }
|
17923 | return false;
|
17924 | },
|
17925 | redrawArc(duration, durationForExit, withTransform) {
|
17926 | const $$ = this;
|
17927 | const { config, state, $el: { main } } = $$;
|
17928 | const hasInteraction = config.interaction_enabled;
|
17929 | const isSelectable = hasInteraction && config.data_selection_isselectable;
|
17930 | let mainArc = main.selectAll(`.${$ARC.arcs}`).selectAll(`.${$ARC.arc}`).data($$.arcData.bind($$));
|
17931 | mainArc.exit().transition().duration(durationForExit).style("opacity", "0").remove();
|
17932 | mainArc = mainArc.enter().append("path").attr("class", $$.getClass("arc", true)).style("fill", (d) => $$.color(d.data)).style("cursor", (d) => {
|
17933 | var _a;
|
17934 | return ((_a = isSelectable == null ? void 0 : isSelectable.bind) == null ? void 0 : _a.call(isSelectable, $$.api)(d)) ? "pointer" : null;
|
17935 | }).style("opacity", "0").each(function(d) {
|
17936 | if ($$.isGaugeType(d.data)) {
|
17937 | d.startAngle = config.gauge_startingAngle;
|
17938 | d.endAngle = config.gauge_startingAngle;
|
17939 | }
|
17940 | this._current = d;
|
17941 | }).merge(mainArc);
|
17942 | if ($$.hasType("gauge")) {
|
17943 | $$.updateGaugeMax();
|
17944 | $$.hasMultiArcGauge() && $$.redrawArcGaugeLine();
|
17945 | }
|
17946 | mainArc.attr("transform", (d) => !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : "").style("opacity", function(d) {
|
17947 | return d === this._current ? "0" : null;
|
17948 | }).each(() => {
|
17949 | state.transiting = true;
|
17950 | }).transition().duration(duration).attrTween("d", function(d) {
|
17951 | const updated = $$.updateAngle(d);
|
17952 | if (!updated) {
|
17953 | return () => "M 0 0";
|
17954 | }
|
17955 | if (isNaN(this._current.startAngle)) {
|
17956 | this._current.startAngle = 0;
|
17957 | }
|
17958 | if (isNaN(this._current.endAngle)) {
|
17959 | this._current.endAngle = this._current.startAngle;
|
17960 | }
|
17961 | const interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(this._current, updated);
|
17962 | this._current = interpolate(0);
|
17963 | return function(t) {
|
17964 | const interpolated = interpolate(t);
|
17965 | interpolated.data = d.data;
|
17966 | return $$.getArc(interpolated, true);
|
17967 | };
|
17968 | }).attr("transform", withTransform ? "scale(1)" : "").style("fill", (d) => {
|
17969 | let color;
|
17970 | if ($$.levelColor) {
|
17971 | color = $$.levelColor(d.data.values[0].value);
|
17972 | config.data_colors[d.data.id] = color;
|
17973 | } else {
|
17974 | color = $$.color(d.data);
|
17975 | }
|
17976 | return color;
|
17977 | }).style("opacity", null).call(endall, function() {
|
17978 | if ($$.levelColor) {
|
17979 | const path = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
17980 | const d = path.datum(this._current);
|
17981 | $$.updateLegendItemColor(d.data.id, path.style("fill"));
|
17982 | }
|
17983 | state.transiting = false;
|
17984 | callFn(config.onrendered, $$.api);
|
17985 | });
|
17986 | hasInteraction && $$.bindArcEvent(mainArc);
|
17987 | $$.hasType("polar") && $$.redrawPolar();
|
17988 | $$.hasType("gauge") && $$.redrawBackgroundArcs();
|
17989 | config.arc_needle_show && $$.redrawNeedle();
|
17990 | $$.redrawArcText(duration);
|
17991 | $$.redrawArcRangeText();
|
17992 | },
|
17993 | |
17994 |
|
17995 |
|
17996 |
|
17997 | redrawNeedle() {
|
17998 | const $$ = this;
|
17999 | const { $el, config, state: { hiddenTargetIds, radius } } = $$;
|
18000 | const length = (radius - 1) / 100 * config.arc_needle_length;
|
18001 | const hasDataToShow = hiddenTargetIds.length !== $$.data.targets.length;
|
18002 | let needle = $$.$el.arcs.select(`.${$ARC.needle}`);
|
18003 | const pathFn = config.arc_needle_path;
|
18004 | const baseWidth = config.arc_needle_bottom_width / 2;
|
18005 | const topWidth = config.arc_needle_top_width / 2;
|
18006 | const topRx = config.arc_needle_top_rx;
|
18007 | const topRy = config.arc_needle_top_ry;
|
18008 | const bottomLen = config.arc_needle_bottom_len;
|
18009 | const bottomRx = config.arc_needle_bottom_rx;
|
18010 | const bottomRy = config.arc_needle_bottom_ry;
|
18011 | const needleAngle = $$.getNeedleAngle();
|
18012 | const updateNeedleValue = () => {
|
18013 | const title = $$.getArcTitleWithNeedleValue();
|
18014 | title && $$.setArcTitle(title);
|
18015 | };
|
18016 | updateNeedleValue();
|
18017 | if (needle.empty()) {
|
18018 | needle = $el.arcs.append("path").classed($ARC.needle, true);
|
18019 | $el.needle = needle;
|
18020 | $el.needle.updateHelper = (v, updateConfig = false) => {
|
18021 | if ($el.needle.style("display") !== "none") {
|
18022 | $$.$T($el.needle).style("transform", `rotate(${$$.getNeedleAngle(v)}deg)`).call(endall, () => {
|
18023 | updateConfig && (config.arc_needle_value = v);
|
18024 | updateNeedleValue();
|
18025 | });
|
18026 | }
|
18027 | };
|
18028 | }
|
18029 | if (hasDataToShow) {
|
18030 | const path = isFunction(pathFn) ? pathFn.call($$, length) : `M-${baseWidth} ${bottomLen} A${bottomRx} ${bottomRy} 0 0 0 ${baseWidth} ${bottomLen} L${topWidth} -${length} A${topRx} ${topRy} 0 0 0 -${topWidth} -${length} L-${baseWidth} ${bottomLen} Z`;
|
18031 | $$.$T(needle).attr("d", path).style("fill", config.arc_needle_color).style("display", null).style("transform", `rotate(${needleAngle}deg)`);
|
18032 | } else {
|
18033 | needle.style("display", "none");
|
18034 | }
|
18035 | },
|
18036 | |
18037 |
|
18038 |
|
18039 |
|
18040 |
|
18041 |
|
18042 | getNeedleAngle(v) {
|
18043 | const $$ = this;
|
18044 | const { config, state } = $$;
|
18045 | const arcLength = $$.getArcLength();
|
18046 | const hasGauge = $$.hasType("gauge");
|
18047 | const total = $$.getTotalDataSum(true);
|
18048 | let value = isDefined(v) ? v : config.arc_needle_value;
|
18049 | let startingAngle = config[`${config.data_type}_startingAngle`] || 0;
|
18050 | let radian = 0;
|
18051 | if (!isNumber(value)) {
|
18052 | value = hasGauge && $$.data.targets.length === 1 ? total : 0;
|
18053 | }
|
18054 | state.current.needle = value;
|
18055 | if (hasGauge) {
|
18056 | startingAngle = $$.getStartingAngle();
|
18057 | const radius = config.gauge_fullCircle ? arcLength : startingAngle * -2;
|
18058 | const { gauge_min: min, gauge_max: max } = config;
|
18059 | radian = radius * ((value - min) / (max - min));
|
18060 | } else {
|
18061 | radian = arcLength * (value / total);
|
18062 | }
|
18063 | return (startingAngle + radian) * (180 / Math.PI);
|
18064 | },
|
18065 | redrawBackgroundArcs() {
|
18066 | const $$ = this;
|
18067 | const { config, state } = $$;
|
18068 | const hasMultiArcGauge = $$.hasMultiArcGauge();
|
18069 | const isFullCircle = config.gauge_fullCircle;
|
18070 | const showEmptyTextLabel = $$.filterTargetsToShow($$.data.targets).length === 0 && !!config.data_empty_label_text;
|
18071 | const startAngle = $$.getStartingAngle();
|
18072 | const endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1;
|
18073 | let backgroundArc = $$.$el.arcs.select(
|
18074 | `${hasMultiArcGauge ? "g" : ""}.${$ARC.chartArcsBackground}`
|
18075 | );
|
18076 | if (hasMultiArcGauge) {
|
18077 | let index = 0;
|
18078 | backgroundArc = backgroundArc.selectAll(`path.${$ARC.chartArcsBackground}`).data($$.data.targets);
|
18079 | backgroundArc.enter().append("path").attr("class", (d, i) => `${$ARC.chartArcsBackground} ${$ARC.chartArcsBackground}-${i}`).merge(backgroundArc).style("fill", config.gauge_background || null).attr("d", ({ id }) => {
|
18080 | if (showEmptyTextLabel || state.hiddenTargetIds.indexOf(id) >= 0) {
|
18081 | return "M 0 0";
|
18082 | }
|
18083 | const d = {
|
18084 | data: [{ value: config.gauge_max }],
|
18085 | startAngle,
|
18086 | endAngle,
|
18087 | index: index++
|
18088 | };
|
18089 | return $$.getArc(d, true, true);
|
18090 | });
|
18091 | backgroundArc.exit().remove();
|
18092 | } else {
|
18093 | backgroundArc.attr("d", showEmptyTextLabel ? "M 0 0" : () => {
|
18094 | const d = {
|
18095 | data: [{ value: config.gauge_max }],
|
18096 | startAngle,
|
18097 | endAngle
|
18098 | };
|
18099 | return $$.getArc(d, true, true);
|
18100 | });
|
18101 | }
|
18102 | },
|
18103 | bindArcEvent(arc) {
|
18104 | const $$ = this;
|
18105 | const { config, state } = $$;
|
18106 | const isTouch = state.inputType === "touch";
|
18107 | const isMouse = state.inputType === "mouse";
|
18108 | function selectArc(_this, arcData, id) {
|
18109 | $$.expandArc(id);
|
18110 | $$.api.focus(id);
|
18111 | $$.toggleFocusLegend(id, true);
|
18112 | $$.showTooltip([arcData], _this);
|
18113 | }
|
18114 | function unselectArc(arcData) {
|
18115 | const id = (arcData == null ? void 0 : arcData.id) || void 0;
|
18116 | $$.unexpandArc(id);
|
18117 | $$.api.revert();
|
18118 | $$.revertLegend();
|
18119 | $$.hideTooltip();
|
18120 | }
|
18121 | arc.on("click", function(event, d, i) {
|
18122 | var _a;
|
18123 | const updated = $$.updateAngle(d);
|
18124 | let arcData;
|
18125 | if (updated) {
|
18126 | arcData = $$.convertToArcData(updated);
|
18127 | (_a = $$.toggleShape) == null ? void 0 : _a.call($$, this, arcData, i);
|
18128 | config.data_onclick.bind($$.api)(arcData, this);
|
18129 | }
|
18130 | });
|
18131 | if (isMouse) {
|
18132 | arc.on("mouseover", function(event, d) {
|
18133 | if (state.transiting) {
|
18134 | return;
|
18135 | }
|
18136 | state.event = event;
|
18137 | const updated = $$.updateAngle(d);
|
18138 | const arcData = updated ? $$.convertToArcData(updated) : null;
|
18139 | const id = (arcData == null ? void 0 : arcData.id) || void 0;
|
18140 | selectArc(this, arcData, id);
|
18141 | $$.setOverOut(true, arcData);
|
18142 | }).on("mouseout", (event, d) => {
|
18143 | if (state.transiting || !config.interaction_onout) {
|
18144 | return;
|
18145 | }
|
18146 | state.event = event;
|
18147 | const updated = $$.updateAngle(d);
|
18148 | const arcData = updated ? $$.convertToArcData(updated) : null;
|
18149 | unselectArc();
|
18150 | $$.setOverOut(false, arcData);
|
18151 | }).on("mousemove", function(event, d) {
|
18152 | const updated = $$.updateAngle(d);
|
18153 | const arcData = updated ? $$.convertToArcData(updated) : null;
|
18154 | state.event = event;
|
18155 | $$.showTooltip([arcData], this);
|
18156 | });
|
18157 | }
|
18158 | if (isTouch && $$.hasArcType() && !$$.radars) {
|
18159 | const getEventArc = (event) => {
|
18160 | var _a, _b;
|
18161 | const { clientX, clientY } = (_b = (_a = event.changedTouches) == null ? void 0 : _a[0]) != null ? _b : { clientX: 0, clientY: 0 };
|
18162 | const eventArc = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.elementFromPoint(clientX, clientY));
|
18163 | return eventArc;
|
18164 | };
|
18165 | $$.$el.svg.on("touchstart touchmove", function(event) {
|
18166 | if (state.transiting) {
|
18167 | return;
|
18168 | }
|
18169 | state.event = event;
|
18170 | const eventArc = getEventArc(event);
|
18171 | const datum = eventArc.datum();
|
18172 | const updated = (datum == null ? void 0 : datum.data) && datum.data.id ? $$.updateAngle(datum) : null;
|
18173 | const arcData = updated ? $$.convertToArcData(updated) : null;
|
18174 | const id = (arcData == null ? void 0 : arcData.id) || void 0;
|
18175 | $$.callOverOutForTouch(arcData);
|
18176 | isUndefined(id) ? unselectArc() : selectArc(this, arcData, id);
|
18177 | });
|
18178 | }
|
18179 | },
|
18180 | redrawArcText(duration) {
|
18181 | const $$ = this;
|
18182 | const { config, state, $el: { main, arcs } } = $$;
|
18183 | const hasGauge = $$.hasType("gauge");
|
18184 | const hasMultiArcGauge = $$.hasMultiArcGauge();
|
18185 | let text;
|
18186 | if (!(hasGauge && $$.data.targets.length === 1 && config.gauge_title)) {
|
18187 | text = main.selectAll(`.${$ARC.chartArc}`).select("text").style("opacity", "0").attr("class", (d) => $$.isGaugeType(d.data) ? $GAUGE.gaugeValue : null).call($$.textForArcLabel.bind($$)).attr("transform", (d) => $$.transformForArcLabel.bind($$)(d)).style("font-size", (d) => $$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ? `${Math.round(state.radius / 5)}px` : null).transition().duration(duration).style(
|
18188 | "opacity",
|
18189 | (d) => $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0"
|
18190 | );
|
18191 | hasMultiArcGauge && text.attr("dy", "-.1em");
|
18192 | }
|
18193 | main.select(`.${$ARC.chartArcsTitle}`).style("opacity", $$.hasType("donut") || hasGauge ? null : "0");
|
18194 | if (hasGauge) {
|
18195 | const isFullCircle = config.gauge_fullCircle;
|
18196 | isFullCircle && (text == null ? void 0 : text.attr("dy", `${hasMultiArcGauge ? 0 : Math.round(state.radius / 14)}`));
|
18197 | if (config.gauge_label_show) {
|
18198 | arcs.select(`.${$GAUGE.chartArcsGaugeUnit}`).attr("dy", `${isFullCircle ? 1.5 : 0.75}em`).text(config.gauge_units);
|
18199 | arcs.select(`.${$GAUGE.chartArcsGaugeMin}`).attr("dx", `${-1 * (state.innerRadius + (state.radius - state.innerRadius) / (isFullCircle ? 1 : 2))}px`).attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_min, false));
|
18200 | !isFullCircle && arcs.select(`.${$GAUGE.chartArcsGaugeMax}`).attr("dx", `${state.innerRadius + (state.radius - state.innerRadius) / 2}px`).attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_max, true));
|
18201 | }
|
18202 | }
|
18203 | },
|
18204 | |
18205 |
|
18206 |
|
18207 |
|
18208 |
|
18209 |
|
18210 | getArcElementByIdOrIndex(value) {
|
18211 | const $$ = this;
|
18212 | const { $el: { arcs } } = $$;
|
18213 | const filterFn = isNumber(value) ? (d) => d.index === value : (d) => d.data.id === value;
|
18214 | return arcs == null ? void 0 : arcs.selectAll(`.${$COMMON.target} path`).filter(filterFn);
|
18215 | }
|
18216 | });
|
18217 |
|
18218 | ;
|
18219 |
|
18220 |
|
18221 |
|
18222 |
|
18223 | var shape_area = ({
|
18224 | initArea(mainLine) {
|
18225 | const $$ = this;
|
18226 | const { config } = $$;
|
18227 | mainLine.insert("g", `.${config.area_front ? $CIRCLE.circles : $LINE.lines}`).attr("class", $$.getClass("areas", true));
|
18228 | },
|
18229 | |
18230 |
|
18231 |
|
18232 |
|
18233 |
|
18234 |
|
18235 | updateAreaColor(d) {
|
18236 | const $$ = this;
|
18237 | return $$.config.area_linearGradient ? $$.getGradienColortUrl(d.id) : $$.color(d);
|
18238 | },
|
18239 | |
18240 |
|
18241 |
|
18242 |
|
18243 |
|
18244 |
|
18245 | updateArea(withTransition, isSub = false) {
|
18246 | const $$ = this;
|
18247 | const { config, state, $el, $T } = $$;
|
18248 | const $root = isSub ? $el.subchart : $el;
|
18249 | config.area_linearGradient && $$.updateLinearGradient();
|
18250 | const area = $root.main.selectAll(`.${$AREA.areas}`).selectAll(`.${$AREA.area}`).data($$.lineData.bind($$));
|
18251 | $T(area.exit(), withTransition).style("opacity", "0").remove();
|
18252 | $root.area = area.enter().append("path").attr("class", $$.getClass("area", true)).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function() {
|
18253 | state.orgAreaOpacity = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).style("opacity");
|
18254 | return "0";
|
18255 | }).merge(area);
|
18256 | area.style("opacity", state.orgAreaOpacity);
|
18257 | $$.setRatioForGroupedData($root.area.data());
|
18258 | },
|
18259 | |
18260 |
|
18261 |
|
18262 |
|
18263 |
|
18264 |
|
18265 |
|
18266 | redrawArea(drawFn, withTransition, isSub = false) {
|
18267 | const $$ = this;
|
18268 | const { area } = isSub ? this.$el.subchart : this.$el;
|
18269 | const { orgAreaOpacity } = $$.state;
|
18270 | return [
|
18271 | $$.$T(area, withTransition, getRandom()).attr("d", drawFn).style("fill", $$.updateAreaColor.bind($$)).style(
|
18272 | "opacity",
|
18273 | (d) => String($$.isAreaRangeType(d) ? orgAreaOpacity / 1.75 : orgAreaOpacity)
|
18274 | )
|
18275 | ];
|
18276 | },
|
18277 | |
18278 |
|
18279 |
|
18280 |
|
18281 |
|
18282 |
|
18283 |
|
18284 | generateDrawArea(areaIndices, isSub) {
|
18285 | const $$ = this;
|
18286 | const { config } = $$;
|
18287 | const lineConnectNull = config.line_connectNull;
|
18288 | const isRotated = config.axis_rotated;
|
18289 | const getPoints = $$.generateGetAreaPoints(areaIndices, isSub);
|
18290 | const yScale = $$.getYScaleById.bind($$);
|
18291 | const xValue = (d) => (isSub ? $$.subxx : $$.xx).call($$, d);
|
18292 | const value0 = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)(
|
18293 | $$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : $$.getShapeYMin(d.id)
|
18294 | );
|
18295 | const value1 = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[1][1] : yScale(d.id, isSub)(
|
18296 | $$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : d.value
|
18297 | );
|
18298 | return (d) => {
|
18299 | let values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values;
|
18300 | let x0 = 0;
|
18301 | let y0 = 0;
|
18302 | let path;
|
18303 | if ($$.isAreaType(d)) {
|
18304 | let area = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.area)();
|
18305 | area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue).y0(config.area_above ? 0 : config.area_below ? $$.state.height : value0).y1(value1);
|
18306 | if (!lineConnectNull) {
|
18307 | area = area.defined((d2) => $$.getBaseValue(d2) !== null);
|
18308 | }
|
18309 | if ($$.isStepType(d)) {
|
18310 | values = $$.convertValuesToStep(values);
|
18311 | }
|
18312 | path = area.curve($$.getCurve(d))(values);
|
18313 | } else {
|
18314 | if (values[0]) {
|
18315 | x0 = $$.scale.x(values[0].x);
|
18316 | y0 = $$.getYScaleById(d.id)(values[0].value);
|
18317 | }
|
18318 | path = isRotated ? `M ${y0} ${x0}` : `M ${x0} ${y0}`;
|
18319 | }
|
18320 | return path || "M 0 0";
|
18321 | };
|
18322 | },
|
18323 | generateGetAreaPoints(areaIndices, isSub) {
|
18324 | const $$ = this;
|
18325 | const { config } = $$;
|
18326 | const x = $$.getShapeX(0, areaIndices, isSub);
|
18327 | const y = $$.getShapeY(!!isSub);
|
18328 | const areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, isSub);
|
18329 | const yScale = $$.getYScaleById.bind($$);
|
18330 | return function(d, i) {
|
18331 | const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
|
18332 | const offset = areaOffset(d, i) || y0;
|
18333 | const posX = x(d);
|
18334 | const value = d.value;
|
18335 | let posY = y(d);
|
18336 | if (config.axis_rotated && (value > 0 && posY < y0 || value < 0 && y0 < posY)) {
|
18337 | posY = y0;
|
18338 | }
|
18339 | return [
|
18340 | [posX, offset],
|
18341 | [posX, posY - (y0 - offset)],
|
18342 | [posX, posY - (y0 - offset)],
|
18343 |
|
18344 | [posX, offset]
|
18345 |
|
18346 | ];
|
18347 | };
|
18348 | }
|
18349 | });
|
18350 |
|
18351 | ;
|
18352 |
|
18353 |
|
18354 | var bar = ({
|
18355 | initBar() {
|
18356 | const { $el, config, state: { clip } } = this;
|
18357 | $el.bar = $el.main.select(`.${$COMMON.chart}`);
|
18358 | $el.bar = config.bar_front ? $el.bar.append("g") : $el.bar.insert("g", ":first-child");
|
18359 | $el.bar.attr("class", $BAR.chartBars).call(this.setCssRule(false, `.${$BAR.chartBars}`, ["pointer-events:none"]));
|
18360 | if (config.clipPath === false && (config.bar_radius || config.bar_radius_ratio)) {
|
18361 | $el.bar.attr("clip-path", clip.pathXAxis.replace(/#[^)]*/, `#${clip.id}`));
|
18362 | }
|
18363 | },
|
18364 | updateTargetsForBar(targets) {
|
18365 | const $$ = this;
|
18366 | const { config, $el } = $$;
|
18367 | const classChartBar = $$.getChartClass("Bar");
|
18368 | const classBars = $$.getClass("bars", true);
|
18369 | const classFocus = $$.classFocus.bind($$);
|
18370 | const isSelectable = config.interaction_enabled && config.data_selection_isselectable;
|
18371 | if (!$el.bar) {
|
18372 | $$.initBar();
|
18373 | }
|
18374 | const mainBarUpdate = $el.main.select(`.${$BAR.chartBars}`).selectAll(`.${$BAR.chartBar}`).data(
|
18375 |
|
18376 | targets.filter(
|
18377 | (v) => v.values.some((d) => isNumber(d.value) || $$.isBarRangeType(d))
|
18378 | )
|
18379 | ).attr("class", (d) => classChartBar(d) + classFocus(d));
|
18380 | const mainBarEnter = mainBarUpdate.enter().append("g").attr("class", classChartBar).style("opacity", "0").style("pointer-events", $$.getStylePropValue("none"));
|
18381 | mainBarEnter.append("g").attr("class", classBars).style("cursor", (d) => {
|
18382 | var _a;
|
18383 | return ((_a = isSelectable == null ? void 0 : isSelectable.bind) == null ? void 0 : _a.call(isSelectable, $$.api)(d)) ? "pointer" : null;
|
18384 | }).call($$.setCssRule(true, ` .${$BAR.bar}`, ["fill"], $$.color));
|
18385 | },
|
18386 | |
18387 |
|
18388 |
|
18389 |
|
18390 |
|
18391 |
|
18392 | updateBar(withTransition, isSub = false) {
|
18393 | const $$ = this;
|
18394 | const { config, $el, $T } = $$;
|
18395 | const $root = isSub ? $el.subchart : $el;
|
18396 | const classBar = $$.getClass("bar", true);
|
18397 | const initialOpacity = $$.initialOpacity.bind($$);
|
18398 | config.bar_linearGradient && $$.updateLinearGradient();
|
18399 | const bar = $root.main.selectAll(`.${$BAR.bars}`).selectAll(`.${$BAR.bar}`).data($$.labelishData.bind($$));
|
18400 | $T(bar.exit(), withTransition).style("opacity", "0").remove();
|
18401 | $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.updateBarColor.bind($$)).merge(bar).style("opacity", initialOpacity);
|
18402 | $$.setRatioForGroupedData($root.bar.data());
|
18403 | },
|
18404 | |
18405 |
|
18406 |
|
18407 |
|
18408 |
|
18409 |
|
18410 | updateBarColor(d) {
|
18411 | const $$ = this;
|
18412 | const fn = $$.getStylePropValue($$.color);
|
18413 | return $$.config.bar_linearGradient ? $$.getGradienColortUrl(d.id) : fn ? fn(d) : null;
|
18414 | },
|
18415 | |
18416 |
|
18417 |
|
18418 |
|
18419 |
|
18420 |
|
18421 |
|
18422 |
|
18423 | redrawBar(drawFn, withTransition, isSub = false) {
|
18424 | const $$ = this;
|
18425 | const { bar } = isSub ? $$.$el.subchart : $$.$el;
|
18426 | return [
|
18427 | $$.$T(bar, withTransition, getRandom()).attr("d", (d) => (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d)).style("fill", $$.updateBarColor.bind($$)).style("clip-path", (d) => d.clipPath).style("opacity", null)
|
18428 | ];
|
18429 | },
|
18430 | |
18431 |
|
18432 |
|
18433 |
|
18434 |
|
18435 |
|
18436 |
|
18437 |
|
18438 |
|
18439 |
|
18440 |
|
18441 |
|
18442 |
|
18443 |
|
18444 |
|
18445 |
|
18446 |
|
18447 |
|
18448 |
|
18449 |
|
18450 | generateDrawBar(barIndices, isSub) {
|
18451 | const $$ = this;
|
18452 | const { config } = $$;
|
18453 | const getPoints = $$.generateGetBarPoints(barIndices, isSub);
|
18454 | const isRotated = config.axis_rotated;
|
18455 | const barRadius = config.bar_radius;
|
18456 | const barRadiusRatio = config.bar_radius_ratio;
|
18457 | const getRadius = isNumber(barRadius) && barRadius > 0 ? () => barRadius : isNumber(barRadiusRatio) ? (w) => w * barRadiusRatio : null;
|
18458 | return (d, i) => {
|
18459 | const points = getPoints(d, i);
|
18460 | const indexX = +isRotated;
|
18461 | const indexY = +!indexX;
|
18462 | const isUnderZero = d.value < 0;
|
18463 | const isInverted = config[`axis_${$$.axis.getId(d.id)}_inverted`];
|
18464 | const isNegative = !isInverted && isUnderZero || isInverted && !isUnderZero;
|
18465 | const pathRadius = ["", ""];
|
18466 | const isGrouped = $$.isGrouped(d.id);
|
18467 | const isRadiusData = getRadius && isGrouped ? $$.isStackingRadiusData(d) : false;
|
18468 | const init = [
|
18469 | points[0][indexX],
|
18470 | points[0][indexY]
|
18471 | ];
|
18472 | let radius = 0;
|
18473 | d.clipPath = null;
|
18474 | if (getRadius) {
|
18475 | const index = isRotated ? indexY : indexX;
|
18476 | const barW = points[2][index] - points[0][index];
|
18477 | radius = !isGrouped || isRadiusData ? getRadius(barW) : 0;
|
18478 | const arc = `a${radius} ${radius} ${isNegative ? `1 0 0` : `0 0 1`} `;
|
18479 | pathRadius[+!isRotated] = `${arc}${radius},${radius}`;
|
18480 | pathRadius[+isRotated] = `${arc}${[-radius, radius][isRotated ? "sort" : "reverse"]()}`;
|
18481 | isNegative && pathRadius.reverse();
|
18482 | }
|
18483 | const pos = isRotated ? points[1][indexX] + (isNegative ? radius : -radius) : points[1][indexY] + (isNegative ? -radius : radius);
|
18484 | if (radius) {
|
18485 | let clipPath = "";
|
18486 | if (isRotated) {
|
18487 | if (isNegative && init[0] < pos) {
|
18488 | clipPath = `0 ${pos - init[0]}px 0 0`;
|
18489 | } else if (!isNegative && init[0] > pos) {
|
18490 | clipPath = `0 0 0 ${init[0] - pos}px`;
|
18491 | }
|
18492 | } else {
|
18493 | if (isNegative && init[1] > pos) {
|
18494 | clipPath = `${init[1] - pos}px 0 0 0`;
|
18495 | } else if (!isNegative && init[1] < pos) {
|
18496 | clipPath = `0 0 ${pos - init[1]}px 0`;
|
18497 | }
|
18498 | }
|
18499 | if (clipPath) {
|
18500 | d.clipPath = `inset(${clipPath})`;
|
18501 | }
|
18502 | }
|
18503 | const path = isRotated ? `H${pos} ${pathRadius[0]}V${points[2][indexY] - radius} ${pathRadius[1]}H${points[3][indexX]}` : `V${pos} ${pathRadius[0]}H${points[2][indexX] - radius} ${pathRadius[1]}V${points[3][indexY]}`;
|
18504 | return `M${points[0][indexX]},${points[0][indexY]}${path}z`;
|
18505 | };
|
18506 | },
|
18507 | |
18508 |
|
18509 |
|
18510 |
|
18511 |
|
18512 | isStackingRadiusData(d) {
|
18513 | const $$ = this;
|
18514 | const { $el, config, data, state } = $$;
|
18515 | const { id, index, value } = d;
|
18516 | if (state.hiddenTargetIds.indexOf(id) > -1) {
|
18517 | const target = $el.bar.filter((d2) => d2.id === id && d2.value === value);
|
18518 | return !target.empty() && /a\d+/i.test(target.attr("d"));
|
18519 | }
|
18520 | const keys = config.data_groups.find((v) => v.indexOf(id) > -1);
|
18521 | const sortedList = $$.orderTargets(
|
18522 | $$.filterTargetsToShow(data.targets.filter($$.isBarType, $$))
|
18523 | ).filter((v) => keys.indexOf(v.id) > -1);
|
18524 | const sortedIds = sortedList.map(
|
18525 | (v) => v.values.filter(
|
18526 | (v2) => v2.index === index && (isNumber(value) && value > 0 ? v2.value > 0 : v2.value < 0)
|
18527 | )[0]
|
18528 | ).filter(Boolean).map((v) => v.id);
|
18529 | return value !== 0 && sortedIds.indexOf(id) === sortedIds.length - 1;
|
18530 | },
|
18531 | |
18532 |
|
18533 |
|
18534 |
|
18535 |
|
18536 |
|
18537 |
|
18538 | generateGetBarPoints(barIndices, isSub) {
|
18539 | const $$ = this;
|
18540 | const { config } = $$;
|
18541 | const axis = isSub ? $$.axis.subX : $$.axis.x;
|
18542 | const barTargetsNum = $$.getIndicesMax(barIndices) + 1;
|
18543 | const barW = $$.getBarW("bar", axis, barTargetsNum);
|
18544 | const barX = $$.getShapeX(barW, barIndices, !!isSub);
|
18545 | const barY = $$.getShapeY(!!isSub);
|
18546 | const barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub);
|
18547 | const yScale = $$.getYScaleById.bind($$);
|
18548 | return (d, i) => {
|
18549 | const { id } = d;
|
18550 | const y0 = yScale.call($$, id, isSub)($$.getShapeYMin(id));
|
18551 | const offset = barOffset(d, i) || y0;
|
18552 | const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
|
18553 | const isInverted = config[`axis_${$$.axis.getId(id)}_inverted`];
|
18554 | const value = d.value;
|
18555 | const posX = barX(d);
|
18556 | let posY = barY(d);
|
18557 | if (config.axis_rotated && !isInverted && (value > 0 && posY < y0 || value < 0 && y0 < posY)) {
|
18558 | posY = y0;
|
18559 | }
|
18560 | if (!$$.isBarRangeType(d)) {
|
18561 | posY -= y0 - offset;
|
18562 | }
|
18563 | const startPosX = posX + width;
|
18564 | return [
|
18565 | [posX, offset],
|
18566 | [posX, posY],
|
18567 | [startPosX, posY],
|
18568 | [startPosX, offset]
|
18569 | ];
|
18570 | };
|
18571 | }
|
18572 | });
|
18573 |
|
18574 | ;
|
18575 |
|
18576 |
|
18577 | var bubble = ({
|
18578 | |
18579 |
|
18580 |
|
18581 |
|
18582 | initBubble() {
|
18583 | const $$ = this;
|
18584 | const { config } = $$;
|
18585 | if ($$.hasType("bubble")) {
|
18586 | config.point_show = true;
|
18587 | config.point_type = "circle";
|
18588 | }
|
18589 | },
|
18590 | |
18591 |
|
18592 |
|
18593 |
|
18594 |
|
18595 | getBaseLength() {
|
18596 | const $$ = this;
|
18597 | const { width, height } = $$.state;
|
18598 | const cacheKey = KEY.bubbleBaseLength;
|
18599 | let baseLength = $$.cache.get(cacheKey);
|
18600 | if (!baseLength) {
|
18601 | $$.cache.add(cacheKey, baseLength = getMinMax("min", [width, height]));
|
18602 | }
|
18603 | return baseLength;
|
18604 | },
|
18605 | |
18606 |
|
18607 |
|
18608 |
|
18609 |
|
18610 |
|
18611 | getBubbleR(d) {
|
18612 | const $$ = this;
|
18613 | let maxR = $$.config.bubble_maxR;
|
18614 | if (isFunction(maxR)) {
|
18615 | maxR = maxR.bind($$.api)(d);
|
18616 | } else if (!isNumber(maxR)) {
|
18617 | maxR = $$.getBaseLength() / ($$.getMaxDataCount() * 2) + 12;
|
18618 | }
|
18619 | const max = getMinMax("max", $$.getMinMaxData().max.map((d2) => $$.isBubbleZType(d2) ? $$.getBubbleZData(d2.value, "y") : isObject(d2.value) ? d2.value.mid : d2.value));
|
18620 | const maxArea = maxR * maxR * Math.PI;
|
18621 | const area = ($$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "z") : d.value) * (maxArea / max);
|
18622 | return Math.sqrt(area / Math.PI);
|
18623 | },
|
18624 | |
18625 |
|
18626 |
|
18627 |
|
18628 |
|
18629 |
|
18630 |
|
18631 | getBubbleZData(d, type) {
|
18632 | return isObject(d) ? d[type] : d[type === "y" ? 0 : 1];
|
18633 | }
|
18634 | });
|
18635 |
|
18636 | ;
|
18637 | var candlestick_defProp = Object.defineProperty;
|
18638 | var candlestick_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
18639 | var candlestick_hasOwnProp = Object.prototype.hasOwnProperty;
|
18640 | var candlestick_propIsEnum = Object.prototype.propertyIsEnumerable;
|
18641 | var candlestick_defNormalProp = (obj, key, value) => key in obj ? candlestick_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
18642 | var candlestick_spreadValues = (a, b) => {
|
18643 | for (var prop in b || (b = {}))
|
18644 | if (candlestick_hasOwnProp.call(b, prop))
|
18645 | candlestick_defNormalProp(a, prop, b[prop]);
|
18646 | if (candlestick_getOwnPropSymbols)
|
18647 | for (var prop of candlestick_getOwnPropSymbols(b)) {
|
18648 | if (candlestick_propIsEnum.call(b, prop))
|
18649 | candlestick_defNormalProp(a, prop, b[prop]);
|
18650 | }
|
18651 | return a;
|
18652 | };
|
18653 |
|
18654 |
|
18655 |
|
18656 | var candlestick = ({
|
18657 | initCandlestick() {
|
18658 | const { $el } = this;
|
18659 | $el.candlestick = $el.main.select(`.${$COMMON.chart}`).append("g").attr("class", $CANDLESTICK.chartCandlesticks);
|
18660 | },
|
18661 | |
18662 |
|
18663 |
|
18664 |
|
18665 |
|
18666 |
|
18667 | updateTargetsForCandlestick(targets) {
|
18668 | const $$ = this;
|
18669 | const { $el } = $$;
|
18670 | const classChart = $$.getChartClass("Candlestick");
|
18671 | if (!$el.candlestick) {
|
18672 | $$.initCandlestick();
|
18673 | }
|
18674 | const mainUpdate = $$.$el.main.select(`.${$CANDLESTICK.chartCandlesticks}`).selectAll(`.${$CANDLESTICK.chartCandlestick}`).data(targets);
|
18675 | mainUpdate.enter().append("g").attr("class", classChart).style("pointer-events", "none");
|
18676 | },
|
18677 | |
18678 |
|
18679 |
|
18680 |
|
18681 |
|
18682 |
|
18683 | updateCandlestick(withTransition, isSub = false) {
|
18684 | const $$ = this;
|
18685 | const { $el, $T } = $$;
|
18686 | const $root = isSub ? $el.subchart : $el;
|
18687 | const classSetter = $$.getClass("candlestick", true);
|
18688 | const initialOpacity = $$.initialOpacity.bind($$);
|
18689 | const candlestick = $root.main.selectAll(`.${$CANDLESTICK.chartCandlestick}`).selectAll(`.${$CANDLESTICK.candlestick}`).data($$.labelishData.bind($$));
|
18690 | $T(candlestick.exit(), withTransition).style("opacity", "0").remove();
|
18691 | const candlestickEnter = candlestick.enter().filter((d) => d.value).append("g").attr("class", classSetter);
|
18692 | candlestickEnter.append("line");
|
18693 | candlestickEnter.append("path");
|
18694 | $root.candlestick = candlestick.merge(candlestickEnter).style("opacity", initialOpacity);
|
18695 | },
|
18696 | |
18697 |
|
18698 |
|
18699 |
|
18700 |
|
18701 |
|
18702 |
|
18703 | generateDrawCandlestick(indices, isSub) {
|
18704 | const $$ = this;
|
18705 | const { config } = $$;
|
18706 | const getPoints = $$.generateGetCandlestickPoints(indices, isSub);
|
18707 | const isRotated = config.axis_rotated;
|
18708 | const downColor = config.candlestick_color_down;
|
18709 | return (d, i, g) => {
|
18710 | const points = getPoints(d, i);
|
18711 | const value = $$.getCandlestickData(d);
|
18712 | const isUp = value == null ? void 0 : value._isUp;
|
18713 | const indexX = +isRotated;
|
18714 | const indexY = +!indexX;
|
18715 | if (g.classed) {
|
18716 | g.classed($CANDLESTICK[isUp ? "valueUp" : "valueDown"], true);
|
18717 | }
|
18718 | const path = isRotated ? `H${points[1][1]} V${points[1][0]} H${points[0][1]}` : `V${points[1][1]} H${points[1][0]} V${points[0][1]}`;
|
18719 | g.select("path").attr("d", `M${points[0][indexX]},${points[0][indexY]}${path}z`).style("fill", (d2) => {
|
18720 | const color = isUp ? $$.color(d2) : isObject(downColor) ? downColor[d2.id] : downColor;
|
18721 | return color || $$.color(d2);
|
18722 | });
|
18723 | const line = g.select("line");
|
18724 | const pos = isRotated ? {
|
18725 | x1: points[2][1],
|
18726 | x2: points[2][2],
|
18727 | y1: points[2][0],
|
18728 | y2: points[2][0]
|
18729 | } : {
|
18730 | x1: points[2][0],
|
18731 | x2: points[2][0],
|
18732 | y1: points[2][1],
|
18733 | y2: points[2][2]
|
18734 | };
|
18735 | for (const x in pos) {
|
18736 | line.attr(x, pos[x]);
|
18737 | }
|
18738 | };
|
18739 | },
|
18740 | |
18741 |
|
18742 |
|
18743 |
|
18744 |
|
18745 |
|
18746 | generateGetCandlestickPoints(indices, isSub = false) {
|
18747 | const $$ = this;
|
18748 | const axis = isSub ? $$.axis.subX : $$.axis.x;
|
18749 | const targetsNum = $$.getIndicesMax(indices) + 1;
|
18750 | const barW = $$.getBarW("candlestick", axis, targetsNum);
|
18751 | const x = $$.getShapeX(barW, indices, !!isSub);
|
18752 | const y = $$.getShapeY(!!isSub);
|
18753 | const shapeOffset = $$.getShapeOffset($$.isBarType, indices, !!isSub);
|
18754 | const yScale = $$.getYScaleById.bind($$);
|
18755 | return (d, i) => {
|
18756 | const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
|
18757 | const offset = shapeOffset(d, i) || y0;
|
18758 | const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
|
18759 | const value = $$.getCandlestickData(d);
|
18760 | let points;
|
18761 | if (value && isNumber(value.open) && isNumber(value.close)) {
|
18762 | const posX = {
|
18763 | start: x(d),
|
18764 | end: 0
|
18765 | };
|
18766 | posX.end = posX.start + width;
|
18767 | const posY = {
|
18768 | start: y(value.open),
|
18769 | end: y(value.close)
|
18770 | };
|
18771 | const posLine = {
|
18772 | x: posX.start + width / 2,
|
18773 | high: y(value.high),
|
18774 | low: y(value.low)
|
18775 | };
|
18776 | posY.start -= y0 - offset;
|
18777 | points = [
|
18778 | [posX.start, posY.start],
|
18779 | [posX.end, posY.end],
|
18780 | [posLine.x, posLine.low, posLine.high]
|
18781 | ];
|
18782 | } else {
|
18783 | points = [[0, 0], [0, 0], [0, 0, 0]];
|
18784 | }
|
18785 | return points;
|
18786 | };
|
18787 | },
|
18788 | |
18789 |
|
18790 |
|
18791 |
|
18792 |
|
18793 |
|
18794 |
|
18795 | redrawCandlestick(drawFn, withTransition, isSub = false) {
|
18796 | const $$ = this;
|
18797 | const { $el, $T } = $$;
|
18798 | const { candlestick } = isSub ? $el.subchart : $el;
|
18799 | const rand = getRandom(true);
|
18800 | return [
|
18801 | candlestick.each(function(d, i) {
|
18802 | const g = $T((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), withTransition, rand);
|
18803 | drawFn(d, i, g);
|
18804 | }).style("opacity", null)
|
18805 | ];
|
18806 | },
|
18807 | |
18808 |
|
18809 |
|
18810 |
|
18811 |
|
18812 |
|
18813 |
|
18814 | getCandlestickData({ value }) {
|
18815 | let d;
|
18816 | if (isArray(value)) {
|
18817 | const [open, high, low, close, volume = false] = value;
|
18818 | d = { open, high, low, close };
|
18819 | if (volume !== false) {
|
18820 | d.volume = volume;
|
18821 | }
|
18822 | } else if (isObject(value)) {
|
18823 | d = candlestick_spreadValues({}, value);
|
18824 | }
|
18825 | if (d) {
|
18826 | d._isUp = d.close >= d.open;
|
18827 | }
|
18828 | return d || null;
|
18829 | }
|
18830 | });
|
18831 |
|
18832 | ;
|
18833 | var funnel_defProp = Object.defineProperty;
|
18834 | var funnel_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
18835 | var funnel_hasOwnProp = Object.prototype.hasOwnProperty;
|
18836 | var funnel_propIsEnum = Object.prototype.propertyIsEnumerable;
|
18837 | var funnel_defNormalProp = (obj, key, value) => key in obj ? funnel_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
18838 | var funnel_spreadValues = (a, b) => {
|
18839 | for (var prop in b || (b = {}))
|
18840 | if (funnel_hasOwnProp.call(b, prop))
|
18841 | funnel_defNormalProp(a, prop, b[prop]);
|
18842 | if (funnel_getOwnPropSymbols)
|
18843 | for (var prop of funnel_getOwnPropSymbols(b)) {
|
18844 | if (funnel_propIsEnum.call(b, prop))
|
18845 | funnel_defNormalProp(a, prop, b[prop]);
|
18846 | }
|
18847 | return a;
|
18848 | };
|
18849 |
|
18850 |
|
18851 |
|
18852 | function getSize(checkNeck = false) {
|
18853 | const $$ = this;
|
18854 | const { config, state: { current: { width, height } } } = $$;
|
18855 | const padding = $$.getCurrentPadding();
|
18856 | const size = funnel_spreadValues({
|
18857 | width: width - (padding.left + padding.right),
|
18858 | height: height - (config.legend_show ? $$.getLegendHeight() + 10 : 0) - (padding.top + padding.bottom)
|
18859 | }, padding);
|
18860 | if (checkNeck) {
|
18861 | const { width: neckWidth, height: neckHeight } = getNecklSize.call($$, {
|
18862 | width: size.width,
|
18863 | height: size.height
|
18864 | });
|
18865 | if (size.width < neckWidth) {
|
18866 | size.width = neckWidth;
|
18867 | }
|
18868 | if (size.height < neckHeight) {
|
18869 | size.height = neckHeight;
|
18870 | }
|
18871 | }
|
18872 | return size;
|
18873 | }
|
18874 | function getNecklSize(current) {
|
18875 | const $$ = this;
|
18876 | const { config } = $$;
|
18877 | let width = config.funnel_neck_width;
|
18878 | let height = config.funnel_neck_height;
|
18879 | [width, height] = [width, height].map((v, i) => {
|
18880 | let size = v;
|
18881 | if (isObject(v)) {
|
18882 | size = current[i ? "height" : "width"] * v.ratio;
|
18883 | }
|
18884 | return size;
|
18885 | });
|
18886 | return {
|
18887 | width,
|
18888 | height
|
18889 | };
|
18890 | }
|
18891 | function getCoord(d) {
|
18892 | const $$ = this;
|
18893 | const { top, left, width } = getSize.call($$, true);
|
18894 | const coords = [];
|
18895 | d.forEach((d2, i) => {
|
18896 | const { ratio } = d2;
|
18897 | const y = i > 0 ? coords[i - 1][2][1] : top;
|
18898 | coords.push(d2.coords = [
|
18899 | [left, y],
|
18900 |
|
18901 | [left + width, y],
|
18902 |
|
18903 | [left + width, i > 0 ? ratio + y : ratio + top],
|
18904 |
|
18905 | [left, i > 0 ? ratio + y : ratio + top],
|
18906 |
|
18907 | [left, y]
|
18908 |
|
18909 | ]);
|
18910 | });
|
18911 | return coords;
|
18912 | }
|
18913 | function getClipPath(forBackground = false) {
|
18914 | const $$ = this;
|
18915 | const { width, height, top, left } = getSize.call($$, true);
|
18916 | const neck = getNecklSize.call($$, { width, height });
|
18917 | const leftX = (width - neck.width) / 2;
|
18918 | const rightX = (width + neck.width) / 2;
|
18919 | const bodyHeigth = height - neck.height;
|
18920 | const coords = [
|
18921 | [0, 0],
|
18922 |
|
18923 | [width, 0],
|
18924 |
|
18925 | [rightX, bodyHeigth],
|
18926 |
|
18927 | [rightX, height],
|
18928 |
|
18929 | [leftX, height],
|
18930 |
|
18931 | [leftX, bodyHeigth],
|
18932 |
|
18933 | [0, 0]
|
18934 |
|
18935 | ];
|
18936 | if (forBackground) {
|
18937 | coords.forEach((d) => {
|
18938 | d[0] += left;
|
18939 | d[1] += top;
|
18940 | });
|
18941 | }
|
18942 | return `M${coords.join("L")}z`;
|
18943 | }
|
18944 | function getFunnelData(d) {
|
18945 | const $$ = this;
|
18946 | const { config } = $$;
|
18947 | const data = d.map((d2) => ({
|
18948 | id: d2.id,
|
18949 | value: d2.values.reduce((a, b) => a + b.value, 0)
|
18950 | }));
|
18951 | if (config.data_order) {
|
18952 | data.sort($$.getSortCompareFn.bind($$)(true));
|
18953 | }
|
18954 | return updateRatio.call($$, data);
|
18955 | }
|
18956 | function updateRatio(data) {
|
18957 | const $$ = this;
|
18958 | const { height } = getSize.call($$);
|
18959 | const total = $$.getTotalDataSum(true);
|
18960 | data.forEach((d) => {
|
18961 | d.ratio = d.value / total * height;
|
18962 | });
|
18963 | return data;
|
18964 | }
|
18965 | var funnel = ({
|
18966 | |
18967 |
|
18968 |
|
18969 |
|
18970 | initFunnel() {
|
18971 | const $$ = this;
|
18972 | const { $el } = $$;
|
18973 | $el.funnel = $el.main.select(`.${$COMMON.chart}`).append("g").classed($FUNNEL.chartFunnels, true);
|
18974 | $el.funnel.background = $el.funnel.append("path").classed($FUNNEL.funnelBackground, true);
|
18975 | $$.bindFunnelEvent();
|
18976 | },
|
18977 | |
18978 |
|
18979 |
|
18980 |
|
18981 | bindFunnelEvent() {
|
18982 | const $$ = this;
|
18983 | const { $el: { funnel }, config, state } = $$;
|
18984 | const getTarget = (event) => {
|
18985 | var _a;
|
18986 | const target = event.isTrusted ? event.target : (_a = state.eventReceiver.rect) == null ? void 0 : _a.node();
|
18987 | let data;
|
18988 | if (/^path$/i.test(target.tagName)) {
|
18989 | state.event = event;
|
18990 | data = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
|
18991 | }
|
18992 | return data;
|
18993 | };
|
18994 | if (config.interaction_enabled) {
|
18995 | const isTouch = state.inputType === "touch";
|
18996 | funnel.on(isTouch ? "touchstart" : "mouseover mousemove", (event) => {
|
18997 | const data = getTarget(event);
|
18998 | if (data) {
|
18999 | $$.showTooltip([data], event.target);
|
19000 | /^(touchstart|mouseover)$/.test(event.type) && $$.setOverOut(true, data);
|
19001 | }
|
19002 | }).on(isTouch ? "touchend" : "mouseout", (event) => {
|
19003 | const data = getTarget(event);
|
19004 | if (config.interaction_onout) {
|
19005 | $$.hideTooltip();
|
19006 | $$.setOverOut(false, data);
|
19007 | }
|
19008 | });
|
19009 | }
|
19010 | },
|
19011 | |
19012 |
|
19013 |
|
19014 |
|
19015 |
|
19016 | updateTargetsForFunnel(t) {
|
19017 | const $$ = this;
|
19018 | const { $el: { funnel } } = $$;
|
19019 | const classChartFunnel = $$.getChartClass("Funnel");
|
19020 | const classFunnel = $$.getClass("funnel", true);
|
19021 | if (!funnel) {
|
19022 | $$.initFunnel();
|
19023 | }
|
19024 | const targets = getFunnelData.call($$, t.filter($$.isFunnelType.bind($$)));
|
19025 | const mainFunnelUpdate = funnel.selectAll(`.${$FUNNEL.chartFunnel}`).data(targets);
|
19026 | mainFunnelUpdate.exit().remove();
|
19027 | const mainFunnelEnter = mainFunnelUpdate.enter().insert("g", `.${$FUNNEL.funnelBackground}`);
|
19028 | mainFunnelEnter.append("path");
|
19029 | funnel.path = mainFunnelEnter.merge(mainFunnelUpdate).attr("class", (d) => classChartFunnel(d)).select("path").attr("class", classFunnel).style("opacity", "0").style("fill", $$.color);
|
19030 | },
|
19031 | |
19032 |
|
19033 |
|
19034 |
|
19035 |
|
19036 | updateFunnel(targets) {
|
19037 | const $$ = this;
|
19038 | const { $el: { funnel } } = $$;
|
19039 | const targetIds = targets.map(({ id }) => id);
|
19040 | funnel.path = funnel.path.filter((d) => targetIds.indexOf(d.id) >= 0);
|
19041 | },
|
19042 | |
19043 |
|
19044 |
|
19045 |
|
19046 |
|
19047 | generateGetFunnelPoints() {
|
19048 | const $$ = this;
|
19049 | const { $el: { funnel } } = $$;
|
19050 | const targets = $$.filterTargetsToShow(funnel.path);
|
19051 | const { top, left, right } = getSize.call($$);
|
19052 | const center = (left - right) / 2;
|
19053 | const points = {};
|
19054 | let accumulatedHeight = top != null ? top : 0;
|
19055 | targets.each((d, i) => {
|
19056 | var _a;
|
19057 | points[d.id] = [
|
19058 | [center, accumulatedHeight],
|
19059 | [center, accumulatedHeight += ((_a = targets == null ? void 0 : targets[i]) != null ? _a : d).ratio]
|
19060 | ];
|
19061 | });
|
19062 | return (d) => points[d.id];
|
19063 | },
|
19064 | |
19065 |
|
19066 |
|
19067 |
|
19068 | redrawFunnel() {
|
19069 | const $$ = this;
|
19070 | const { $T, $el: { funnel } } = $$;
|
19071 | const targets = $$.filterTargetsToShow(funnel.path);
|
19072 | const coords = getCoord.call($$, updateRatio.call($$, targets.data()));
|
19073 | funnel.attr("clip-path", `path('${getClipPath.bind($$)()}')`);
|
19074 | funnel.background.attr("d", getClipPath.call($$, true));
|
19075 | $T(targets).attr("d", (d, i) => `M${coords[i].join("L")}z`).style("opacity", "1");
|
19076 | funnel.selectAll("g").style("opacity", null);
|
19077 | }
|
19078 | });
|
19079 |
|
19080 | ;
|
19081 |
|
19082 |
|
19083 |
|
19084 | var gauge = ({
|
19085 | initGauge() {
|
19086 | const $$ = this;
|
19087 | const { config, $el: { arcs } } = $$;
|
19088 | const appendText = (className = null, value = "") => {
|
19089 | arcs.append("text").attr("class", className).style("text-anchor", "middle").style("pointer-events", "none").text(value);
|
19090 | };
|
19091 | if ($$.hasType("gauge")) {
|
19092 | const hasMulti = $$.hasMultiArcGauge();
|
19093 | arcs.append(hasMulti ? "g" : "path").attr("class", $ARC.chartArcsBackground).style("fill", !hasMulti && config.gauge_background || null);
|
19094 | config.gauge_units && appendText($GAUGE.chartArcsGaugeUnit);
|
19095 | if (config.gauge_label_show) {
|
19096 | appendText($GAUGE.chartArcsGaugeMin);
|
19097 | !config.gauge_fullCircle && appendText($GAUGE.chartArcsGaugeMax);
|
19098 | }
|
19099 | }
|
19100 | },
|
19101 | updateGaugeMax() {
|
19102 | const $$ = this;
|
19103 | const { config, state } = $$;
|
19104 | const hasMultiGauge = $$.hasMultiArcGauge();
|
19105 | const max = hasMultiGauge ? $$.getMinMaxData().max[0].value : $$.getTotalDataSum(state.rendered);
|
19106 | if (!config.gauge_enforceMinMax && max + config.gauge_min * (config.gauge_min > 0 ? -1 : 1) > config.gauge_max) {
|
19107 | config.gauge_max = max - config.gauge_min;
|
19108 | }
|
19109 | },
|
19110 | redrawArcGaugeLine() {
|
19111 | const $$ = this;
|
19112 | const { config, state, $el } = $$;
|
19113 | const { hiddenTargetIds } = $$.state;
|
19114 | const arcLabelLines = $el.main.selectAll(`.${$ARC.arcs}`).selectAll(`.${$ARC.arcLabelLine}`).data($$.arcData.bind($$));
|
19115 | const mainArcLabelLine = arcLabelLines.enter().append("rect").attr(
|
19116 | "class",
|
19117 | (d) => `${$ARC.arcLabelLine} ${$COMMON.target} ${$COMMON.target}-${d.data.id}`
|
19118 | ).merge(arcLabelLines);
|
19119 | mainArcLabelLine.style(
|
19120 | "fill",
|
19121 | (d) => $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data)
|
19122 | ).style("display", config.gauge_label_show ? null : "none").each(function(d) {
|
19123 | let lineLength = 0;
|
19124 | const lineThickness = 2;
|
19125 | let x = 0;
|
19126 | let y = 0;
|
19127 | let transform = "";
|
19128 | if (hiddenTargetIds.indexOf(d.data.id) < 0) {
|
19129 | const updated = $$.updateAngle(d);
|
19130 | const innerLineLength = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length * (updated.index + 1);
|
19131 | const lineAngle = updated.endAngle - Math.PI / 2;
|
19132 | const arcInnerRadius = state.radius - innerLineLength;
|
19133 | const linePositioningAngle = lineAngle - (arcInnerRadius === 0 ? 0 : 1 / arcInnerRadius);
|
19134 | lineLength = state.radiusExpanded - state.radius + innerLineLength;
|
19135 | x = Math.cos(linePositioningAngle) * arcInnerRadius;
|
19136 | y = Math.sin(linePositioningAngle) * arcInnerRadius;
|
19137 | transform = `rotate(${lineAngle * 180 / Math.PI}, ${x}, ${y})`;
|
19138 | }
|
19139 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).attr("x", x).attr("y", y).attr("width", lineLength).attr("height", lineThickness).attr("transform", transform).style("stroke-dasharray", `0, ${lineLength + lineThickness}, 0`);
|
19140 | });
|
19141 | },
|
19142 | textForGaugeMinMax(value, isMax) {
|
19143 | const $$ = this;
|
19144 | const { config } = $$;
|
19145 | const format = config.gauge_label_extents;
|
19146 | return isFunction(format) ? format.bind($$.api)(value, isMax) : value;
|
19147 | },
|
19148 | getGaugeLabelHeight() {
|
19149 | const { config } = this;
|
19150 | return this.config.gauge_label_show && !config.gauge_fullCircle ? 20 : 0;
|
19151 | },
|
19152 | getPaddingBottomForGauge() {
|
19153 | const $$ = this;
|
19154 | return $$.getGaugeLabelHeight() * ($$.config.gauge_label_show ? 2 : 2.5);
|
19155 | }
|
19156 | });
|
19157 |
|
19158 | ;
|
19159 |
|
19160 |
|
19161 |
|
19162 |
|
19163 | function getStrokeDashArray(start, end, pattern, isLastX = false) {
|
19164 | const dash = start ? [start, 0] : pattern;
|
19165 | for (let i = start ? start : pattern.reduce((a, c) => a + c); i <= end; ) {
|
19166 | pattern.forEach((v) => {
|
19167 | if (i + v <= end) {
|
19168 | dash.push(v);
|
19169 | }
|
19170 | i += v;
|
19171 | });
|
19172 | }
|
19173 | dash.length % 2 !== 0 && dash.push(isLastX ? pattern[1] : 0);
|
19174 | return {
|
19175 | dash: dash.join(" "),
|
19176 | length: dash.reduce((a, b) => a + b, 0)
|
19177 | };
|
19178 | }
|
19179 | function getRegions(d, _regions, isTimeSeries) {
|
19180 | const $$ = this;
|
19181 | const regions = [];
|
19182 | const dasharray = "2 2";
|
19183 | if (isDefined(_regions)) {
|
19184 | const getValue = (v, def) => isUndefined(v) ? def : isTimeSeries ? parseDate.call($$, v) : v;
|
19185 | for (let i = 0, reg; reg = _regions[i]; i++) {
|
19186 | const start = getValue(reg.start, d[0].x);
|
19187 | const end = getValue(reg.end, d[d.length - 1].x);
|
19188 | const style = reg.style || { dasharray };
|
19189 | regions[i] = { start, end, style };
|
19190 | }
|
19191 | }
|
19192 | return regions;
|
19193 | }
|
19194 | var line = ({
|
19195 | initLine() {
|
19196 | const { $el } = this;
|
19197 | $el.line = $el.main.select(`.${$COMMON.chart}`).append("g").attr("class", $LINE.chartLines).call(this.setCssRule(false, `.${$LINE.chartLines}`, ["pointer-events:none"]));
|
19198 | },
|
19199 | updateTargetsForLine(t) {
|
19200 | const $$ = this;
|
19201 | const { $el: { area, line, main } } = $$;
|
19202 | const classChartLine = $$.getChartClass("Line");
|
19203 | const classLines = $$.getClass("lines", true);
|
19204 | const classFocus = $$.classFocus.bind($$);
|
19205 | if (!line) {
|
19206 | $$.initLine();
|
19207 | }
|
19208 | const targets = t.filter((d) => !($$.isScatterType(d) || $$.isBubbleType(d)));
|
19209 | const mainLineUpdate = main.select(`.${$LINE.chartLines}`).selectAll(`.${$LINE.chartLine}`).data(targets).attr("class", (d) => classChartLine(d) + classFocus(d));
|
19210 | const mainLineEnter = mainLineUpdate.enter().append("g").attr("class", classChartLine).style("opacity", "0").style("pointer-events", $$.getStylePropValue("none"));
|
19211 | mainLineEnter.append("g").attr("class", classLines);
|
19212 | if ($$.hasTypeOf("Area")) {
|
19213 | const mainLine = (!area && mainLineEnter.empty() ? mainLineUpdate : mainLineEnter).filter($$.isAreaType.bind($$));
|
19214 | $$.initArea(mainLine);
|
19215 | }
|
19216 | $$.updateTargetForCircle(targets, mainLineEnter);
|
19217 | },
|
19218 | |
19219 |
|
19220 |
|
19221 |
|
19222 |
|
19223 |
|
19224 | updateLine(withTransition, isSub = false) {
|
19225 | const $$ = this;
|
19226 | const { format: { extraLineClasses }, $el, $T } = $$;
|
19227 | const $root = isSub ? $el.subchart : $el;
|
19228 | const line = $root.main.selectAll(`.${$LINE.lines}`).selectAll(`.${$LINE.line}`).data($$.lineData.bind($$));
|
19229 | $T(line.exit(), withTransition).style("opacity", "0").remove();
|
19230 | $root.line = line.enter().append("path").attr("class", (d) => `${$$.getClass("line", true)(d)} ${extraLineClasses(d) || ""}`).style("stroke", $$.color).merge(line).style("opacity", $$.initialOpacity.bind($$)).attr("transform", null);
|
19231 | },
|
19232 | |
19233 |
|
19234 |
|
19235 |
|
19236 |
|
19237 |
|
19238 |
|
19239 |
|
19240 | redrawLine(drawFn, withTransition, isSub = false) {
|
19241 | const $$ = this;
|
19242 | const { $el, $T } = $$;
|
19243 | const { line } = isSub ? $el.subchart : $el;
|
19244 | return [
|
19245 | $T(line, withTransition, getRandom()).attr("d", drawFn).style("stroke", this.color).style("opacity", null)
|
19246 | ];
|
19247 | },
|
19248 | |
19249 |
|
19250 |
|
19251 |
|
19252 |
|
19253 |
|
19254 | getCurve(d) {
|
19255 | const $$ = this;
|
19256 | const isRotatedStepType = $$.config.axis_rotated && $$.isStepType(d);
|
19257 | return isRotatedStepType ? (context) => {
|
19258 | const step = $$.getInterpolate(d)(context);
|
19259 | step.orgPoint = step.point;
|
19260 | step.pointRotated = function(x, y) {
|
19261 | this._point === 1 && (this._point = 2);
|
19262 | const y1 = this._y * (1 - this._t) + y * this._t;
|
19263 | this._context.lineTo(this._x, y1);
|
19264 | this._context.lineTo(x, y1);
|
19265 | this._x = x;
|
19266 | this._y = y;
|
19267 | };
|
19268 | step.point = function(x, y) {
|
19269 | this._point === 0 ? this.orgPoint(x, y) : this.pointRotated(x, y);
|
19270 | };
|
19271 | return step;
|
19272 | } : $$.getInterpolate(d);
|
19273 | },
|
19274 | generateDrawLine(lineIndices, isSub) {
|
19275 | const $$ = this;
|
19276 | const { config, scale } = $$;
|
19277 | const lineConnectNull = config.line_connectNull;
|
19278 | const isRotated = config.axis_rotated;
|
19279 | const getPoints = $$.generateGetLinePoints(lineIndices, isSub);
|
19280 | const yScale = $$.getYScaleById.bind($$);
|
19281 | const xValue = (d) => (isSub ? $$.subxx : $$.xx).call($$, d);
|
19282 | const yValue = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.getBaseValue(d));
|
19283 | let line = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.line)();
|
19284 | line = isRotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
|
19285 | if (!lineConnectNull) {
|
19286 | line = line.defined((d) => $$.getBaseValue(d) !== null);
|
19287 | }
|
19288 | const x = isSub ? scale.subX : scale.x;
|
19289 | return (d) => {
|
19290 | const y = yScale(d.id, isSub);
|
19291 | let values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values;
|
19292 | let x0 = 0;
|
19293 | let y0 = 0;
|
19294 | let path;
|
19295 | if ($$.isLineType(d)) {
|
19296 | const regions = config.data_regions[d.id];
|
19297 | if (regions) {
|
19298 | path = $$.lineWithRegions(values, scale.zoom || x, y, regions);
|
19299 | } else {
|
19300 | if ($$.isStepType(d)) {
|
19301 | values = $$.convertValuesToStep(values);
|
19302 | }
|
19303 | path = line.curve($$.getCurve(d))(values);
|
19304 | }
|
19305 | } else {
|
19306 | if (values[0]) {
|
19307 | x0 = x(values[0].x);
|
19308 | y0 = y(values[0].value);
|
19309 | }
|
19310 | path = isRotated ? `M ${y0} ${x0}` : `M ${x0} ${y0}`;
|
19311 | }
|
19312 | return path || "M 0 0";
|
19313 | };
|
19314 | },
|
19315 | |
19316 |
|
19317 |
|
19318 |
|
19319 |
|
19320 |
|
19321 |
|
19322 |
|
19323 |
|
19324 | lineWithRegions(d, x, y, _regions) {
|
19325 | const $$ = this;
|
19326 | const { config } = $$;
|
19327 | const isRotated = config.axis_rotated;
|
19328 | const isTimeSeries = $$.axis.isTimeSeries();
|
19329 | const dasharray = "2 2";
|
19330 | const regions = getRegions.bind($$)(d, _regions, isTimeSeries);
|
19331 | const hasNullDataValue = $$.hasNullDataValue(d);
|
19332 | let xp;
|
19333 | let yp;
|
19334 | let diff;
|
19335 | let diffx2;
|
19336 | const xValue = isRotated ? (dt) => y(dt.value) : (dt) => x(dt.x);
|
19337 | const yValue = isRotated ? (dt) => x(dt.x) : (dt) => y(dt.value);
|
19338 | const generateM = (points) => `M${points[0][0]},${points[0][1]}L${points[1][0]},${points[1][1]}`;
|
19339 | const sWithRegion = isTimeSeries ? (d0, d1, k, timeseriesDiff) => {
|
19340 | const x0 = d0.x.getTime();
|
19341 | const xDiff = d1.x - d0.x;
|
19342 | const xv0 = new Date(x0 + xDiff * k);
|
19343 | const xv1 = new Date(x0 + xDiff * (k + timeseriesDiff));
|
19344 | const points = isRotated ? [[y(yp(k)), x(xv0)], [y(yp(k + diff)), x(xv1)]] : [[x(xv0), y(yp(k))], [x(xv1), y(yp(k + diff))]];
|
19345 | return generateM(points);
|
19346 | } : (d0, d1, k, otherDiff) => {
|
19347 | const x0 = x(d1.x, !isRotated);
|
19348 | const y0 = y(d1.value, isRotated);
|
19349 | const gap = k + otherDiff;
|
19350 | const xValue2 = x(xp(k), !isRotated);
|
19351 | const yValue2 = y(yp(k), isRotated);
|
19352 | let xDiff = x(xp(gap), !isRotated);
|
19353 | let yDiff = y(yp(gap), isRotated);
|
19354 | if (xDiff > x0) {
|
19355 | xDiff = x0;
|
19356 | }
|
19357 | if (d0.value > d1.value && (isRotated ? yDiff < y0 : yDiff > y0)) {
|
19358 | yDiff = y0;
|
19359 | }
|
19360 | const points = [
|
19361 | [xValue2, yValue2],
|
19362 | [xDiff, yDiff]
|
19363 | ];
|
19364 | isRotated && points.forEach((v) => v.reverse());
|
19365 | return generateM(points);
|
19366 | };
|
19367 | const axisType = { x: $$.axis.getAxisType("x"), y: $$.axis.getAxisType("y") };
|
19368 | let path = "";
|
19369 | const target = $$.$el.line.filter(({ id }) => id === d[0].id);
|
19370 | const tempNode = target.clone().style("display", "none");
|
19371 | const getLength = (node, path2) => node.attr("d", path2).node().getTotalLength();
|
19372 | const dashArray = {
|
19373 | dash: [],
|
19374 | lastLength: 0
|
19375 | };
|
19376 | let isLastX = false;
|
19377 | for (let i = 0, data; data = d[i]; i++) {
|
19378 | const prevData = d[i - 1];
|
19379 | const hasPrevData = prevData && isValue(prevData.value);
|
19380 | let style = $$.isWithinRegions(data.x, regions);
|
19381 | if (!isValue(data.value)) {
|
19382 | continue;
|
19383 | }
|
19384 | if (isUndefined(regions) || !style || !hasPrevData) {
|
19385 | path += `${i && hasPrevData ? "L" : "M"}${xValue(data)},${yValue(data)}`;
|
19386 | } else if (hasPrevData) {
|
19387 | style = ((style == null ? void 0 : style.dasharray) || dasharray).split(" ").map(Number);
|
19388 | xp = getScale(axisType.x, prevData.x, data.x);
|
19389 | yp = getScale(axisType.y, prevData.value, data.value);
|
19390 | if (hasNullDataValue) {
|
19391 | const dx = x(data.x) - x(prevData.x);
|
19392 | const dy = y(data.value) - y(prevData.value);
|
19393 | const dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
|
19394 | diff = style[0] / dd;
|
19395 | diffx2 = diff * style[1];
|
19396 | for (let j = diff; j <= 1; j += diffx2) {
|
19397 | path += sWithRegion(prevData, data, j, diff);
|
19398 | if (j + diffx2 >= 1) {
|
19399 | path += sWithRegion(prevData, data, 1, 0);
|
19400 | }
|
19401 | }
|
19402 | } else {
|
19403 | let points = [];
|
19404 | isLastX = data.x === d[d.length - 1].x;
|
19405 | if (isTimeSeries) {
|
19406 | const x0 = +prevData.x;
|
19407 | const xv0 = new Date(x0);
|
19408 | const xv1 = new Date(x0 + (+data.x - x0));
|
19409 | points = [
|
19410 | [x(xv0), y(yp(0))],
|
19411 |
|
19412 | [x(xv1), y(yp(1))]
|
19413 |
|
19414 | ];
|
19415 | } else {
|
19416 | points = [
|
19417 | [x(xp(0)), y(yp(0))],
|
19418 |
|
19419 | [x(xp(1)), y(yp(1))]
|
19420 |
|
19421 | ];
|
19422 | }
|
19423 | isRotated && points.forEach((v) => v.reverse());
|
19424 | const startLength = getLength(tempNode, path);
|
19425 | const endLength = getLength(tempNode, path += `L${points[1].join(",")}`);
|
19426 | const strokeDashArray = getStrokeDashArray(
|
19427 | startLength - dashArray.lastLength,
|
19428 | endLength - dashArray.lastLength,
|
19429 | style,
|
19430 | isLastX
|
19431 | );
|
19432 | dashArray.lastLength += strokeDashArray.length;
|
19433 | dashArray.dash.push(strokeDashArray.dash);
|
19434 | }
|
19435 | }
|
19436 | }
|
19437 | if (dashArray.dash.length) {
|
19438 | !isLastX && dashArray.dash.push(getLength(tempNode, path));
|
19439 | tempNode.remove();
|
19440 | target.attr("stroke-dasharray", dashArray.dash.join(" "));
|
19441 | }
|
19442 | return path;
|
19443 | },
|
19444 | isWithinRegions(withinX, withinRegions) {
|
19445 | for (let i = 0, reg; reg = withinRegions[i]; i++) {
|
19446 | if (reg.start < withinX && withinX <= reg.end) {
|
19447 | return reg.style;
|
19448 | }
|
19449 | }
|
19450 | return false;
|
19451 | },
|
19452 | isWithinStep(that, y) {
|
19453 | return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
|
19454 | },
|
19455 | shouldDrawPointsForLine(d) {
|
19456 | const linePoint = this.config.line_point;
|
19457 | return linePoint === true || isArray(linePoint) && linePoint.indexOf(d.id) !== -1;
|
19458 | }
|
19459 | });
|
19460 |
|
19461 | ;
|
19462 |
|
19463 |
|
19464 |
|
19465 | const getTransitionName = () => getRandom();
|
19466 | var point = ({
|
19467 | initialOpacityForCircle(d) {
|
19468 | const { config, state: { withoutFadeIn } } = this;
|
19469 | let opacity = config.point_opacity;
|
19470 | if (isUndefined(opacity)) {
|
19471 | opacity = this.getBaseValue(d) !== null && withoutFadeIn[d.id] ? this.opacityForCircle(d) : "0";
|
19472 | }
|
19473 | return opacity;
|
19474 | },
|
19475 | opacityForCircle(d) {
|
19476 | var _a;
|
19477 | const { config } = this;
|
19478 | let opacity = config.point_opacity;
|
19479 | if (isUndefined(opacity)) {
|
19480 | opacity = config.point_show && !((_a = this.isPointFocusOnly) == null ? void 0 : _a.call(this)) ? null : "0";
|
19481 | opacity = isValue(this.getBaseValue(d)) ? this.isBubbleType(d) || this.isScatterType(d) ? "0.5" : opacity : "0";
|
19482 | }
|
19483 | return opacity;
|
19484 | },
|
19485 | initCircle() {
|
19486 | const $$ = this;
|
19487 | const { $el: { main } } = $$;
|
19488 | !$$.point && ($$.point = $$.generatePoint());
|
19489 | if (($$.hasType("bubble") || $$.hasType("scatter")) && main.select(`.${$COMMON.chart} > .${$CIRCLE.chartCircles}`).empty()) {
|
19490 | main.select(`.${$COMMON.chart}`).append("g").attr("class", $CIRCLE.chartCircles);
|
19491 | }
|
19492 | },
|
19493 | updateTargetForCircle(targetsValue, enterNodeValue) {
|
19494 | const $$ = this;
|
19495 | const { config, data, $el } = $$;
|
19496 | const selectionEnabled = config.interaction_enabled && config.data_selection_enabled;
|
19497 | const isSelectable = selectionEnabled && config.data_selection_isselectable;
|
19498 | const classCircles = $$.getClass("circles", true);
|
19499 | if (!config.point_show) {
|
19500 | return;
|
19501 | }
|
19502 | $$.initCircle();
|
19503 | let targets = targetsValue;
|
19504 | let enterNode = enterNodeValue;
|
19505 | if (!targets) {
|
19506 | targets = data.targets.filter((d) => this.isScatterType(d) || this.isBubbleType(d));
|
19507 | const mainCircle = $el.main.select(`.${$CIRCLE.chartCircles}`).style("pointer-events", "none").selectAll(`.${$CIRCLE.circles}`).data(targets);
|
19508 | mainCircle.exit().remove();
|
19509 | enterNode = mainCircle.enter();
|
19510 | }
|
19511 | selectionEnabled && enterNode.append("g").attr("class", (d) => $$.generateClass($SELECT.selectedCircles, d.id));
|
19512 | enterNode.append("g").attr("class", classCircles).call((selection) => {
|
19513 | $$.setCssRule(true, `.${$CIRCLE.circles}`, ["cursor:pointer"], isSelectable)(
|
19514 | selection
|
19515 | );
|
19516 | $$.setCssRule(true, ` .${$CIRCLE.circle}`, ["fill", "stroke"], $$.color)(selection);
|
19517 | }).style("opacity", function() {
|
19518 | const parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode);
|
19519 | return parent.attr("class").indexOf($CIRCLE.chartCircles) > -1 ? "0" : null;
|
19520 | });
|
19521 | selectionEnabled && targets.forEach((t) => {
|
19522 | $el.main.selectAll(`.${$SELECT.selectedCircles}${$$.getTargetSelectorSuffix(t.id)}`).selectAll(`${$SELECT.selectedCircle}`).each((d) => {
|
19523 | d.value = t.values[d.index].value;
|
19524 | });
|
19525 | });
|
19526 | },
|
19527 | updateCircle(isSub = false) {
|
19528 | const $$ = this;
|
19529 | const { config, state, $el } = $$;
|
19530 | const focusOnly = $$.isPointFocusOnly();
|
19531 | const $root = isSub ? $el.subchart : $el;
|
19532 | if (config.point_show && !state.toggling) {
|
19533 | config.point_radialGradient && $$.updateLinearGradient();
|
19534 | const circles = $root.main.selectAll(`.${$CIRCLE.circles}`).selectAll(`.${$CIRCLE.circle}`).data((d) => $$.isLineType(d) && $$.shouldDrawPointsForLine(d) || $$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ? focusOnly ? [d.values[0]] : d.values : []);
|
19535 | circles.exit().remove();
|
19536 | circles.enter().filter(Boolean).append(
|
19537 | $$.point("create", this, $$.pointR.bind($$), $$.updateCircleColor.bind($$))
|
19538 | );
|
19539 | $root.circle = $root.main.selectAll(`.${$CIRCLE.circles} .${$CIRCLE.circle}`).style("stroke", $$.getStylePropValue($$.color)).style("opacity", $$.initialOpacityForCircle.bind($$));
|
19540 | }
|
19541 | },
|
19542 | |
19543 |
|
19544 |
|
19545 |
|
19546 |
|
19547 |
|
19548 | updateCircleColor(d) {
|
19549 | const $$ = this;
|
19550 | const fn = $$.getStylePropValue($$.color);
|
19551 | return $$.config.point_radialGradient ? $$.getGradienColortUrl(d.id) : fn ? fn(d) : null;
|
19552 | },
|
19553 | redrawCircle(cx, cy, withTransition, flow, isSub = false) {
|
19554 | const $$ = this;
|
19555 | const { state: { rendered }, $el, $T } = $$;
|
19556 | const $root = isSub ? $el.subchart : $el;
|
19557 | const selectedCircles = $root.main.selectAll(`.${$SELECT.selectedCircle}`);
|
19558 | if (!$$.config.point_show) {
|
19559 | return [];
|
19560 | }
|
19561 | const fn = $$.point(
|
19562 | "update",
|
19563 | $$,
|
19564 | cx,
|
19565 | cy,
|
19566 | $$.updateCircleColor.bind($$),
|
19567 | withTransition,
|
19568 | flow,
|
19569 | selectedCircles
|
19570 | );
|
19571 | const posAttr = $$.isCirclePoint() ? "c" : "";
|
19572 | const t = getRandom();
|
19573 | const opacityStyleFn = $$.opacityForCircle.bind($$);
|
19574 | const mainCircles = [];
|
19575 | $root.circle.each(function(d) {
|
19576 | let result = fn.bind(this)(d);
|
19577 | result = $T(result, withTransition || !rendered, t).style("opacity", opacityStyleFn);
|
19578 | mainCircles.push(result);
|
19579 | });
|
19580 | return [
|
19581 | mainCircles,
|
19582 | $T(selectedCircles, withTransition).attr(`${posAttr}x`, cx).attr(`${posAttr}y`, cy)
|
19583 | ];
|
19584 | },
|
19585 | |
19586 |
|
19587 |
|
19588 |
|
19589 |
|
19590 | showCircleFocus(d) {
|
19591 | const $$ = this;
|
19592 | const { state: { hasRadar, resizing, toggling, transiting }, $el } = $$;
|
19593 | let { circle } = $el;
|
19594 | if (transiting === false && circle && $$.isPointFocusOnly()) {
|
19595 | const cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$);
|
19596 | const cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$);
|
19597 | const withTransition = toggling || isUndefined(d);
|
19598 | const fn = $$.point(
|
19599 | "update",
|
19600 | $$,
|
19601 | cx,
|
19602 | cy,
|
19603 | $$.getStylePropValue($$.color),
|
19604 | resizing ? false : withTransition
|
19605 | );
|
19606 | if (d) {
|
19607 | circle = circle.filter(function(t) {
|
19608 | var _a;
|
19609 | const data = (_a = d.filter) == null ? void 0 : _a.call(d, (v) => v.id === t.id);
|
19610 | return data.length ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).datum(data[0]) : false;
|
19611 | });
|
19612 | }
|
19613 | circle.attr("class", this.updatePointClass.bind(this)).style("opacity", null).each(function(d2) {
|
19614 | const { id, index, value } = d2;
|
19615 | let visibility = "hidden";
|
19616 | if (isValue(value)) {
|
19617 | fn.bind(this)(d2);
|
19618 | $$.expandCircles(index, id);
|
19619 | visibility = "";
|
19620 | }
|
19621 | this.style.visibility = visibility;
|
19622 | });
|
19623 | }
|
19624 | },
|
19625 | |
19626 |
|
19627 |
|
19628 |
|
19629 | hideCircleFocus() {
|
19630 | const $$ = this;
|
19631 | const { $el: { circle } } = $$;
|
19632 | if ($$.isPointFocusOnly() && circle) {
|
19633 | $$.unexpandCircles();
|
19634 | circle.style("visibility", "hidden");
|
19635 | }
|
19636 | },
|
19637 | circleX(d) {
|
19638 | return this.xx(d);
|
19639 | },
|
19640 | updateCircleY(isSub = false) {
|
19641 | const $$ = this;
|
19642 | const getPoints = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType), isSub);
|
19643 | return (d, i) => {
|
19644 | const id = d.id;
|
19645 | return $$.isGrouped(id) ? getPoints(d, i)[0][1] : $$.getYScaleById(id, isSub)($$.getBaseValue(d));
|
19646 | };
|
19647 | },
|
19648 | expandCircles(i, id, reset) {
|
19649 | const $$ = this;
|
19650 | const r = $$.pointExpandedR.bind($$);
|
19651 | reset && $$.unexpandCircles();
|
19652 | const circles = $$.getShapeByIndex("circle", i, id).classed($COMMON.EXPANDED, true);
|
19653 | const scale = r(circles) / $$.config.point_r;
|
19654 | const ratio = 1 - scale;
|
19655 | if ($$.isCirclePoint()) {
|
19656 | circles.attr("r", r);
|
19657 | } else {
|
19658 | circles.each(function() {
|
19659 | const point = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
19660 | if (this.tagName === "circle") {
|
19661 | point.attr("r", r);
|
19662 | } else {
|
19663 | const { width, height } = this.getBBox();
|
19664 | const x = ratio * (+point.attr("x") + width / 2);
|
19665 | const y = ratio * (+point.attr("y") + height / 2);
|
19666 | point.attr("transform", `translate(${x} ${y}) scale(${scale})`);
|
19667 | }
|
19668 | });
|
19669 | }
|
19670 | },
|
19671 | unexpandCircles(i) {
|
19672 | const $$ = this;
|
19673 | const r = $$.pointR.bind($$);
|
19674 | const circles = $$.getShapeByIndex("circle", i).filter(function() {
|
19675 | return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($COMMON.EXPANDED);
|
19676 | }).classed($COMMON.EXPANDED, false);
|
19677 | circles.attr("r", r);
|
19678 | if (!$$.isCirclePoint()) {
|
19679 | const scale = r(circles) / $$.config.point_r;
|
19680 | circles.attr("transform", scale !== 1 ? `scale(${scale})` : null);
|
19681 | }
|
19682 | },
|
19683 | pointR(d) {
|
19684 | const $$ = this;
|
19685 | const { config } = $$;
|
19686 | const pointR = config.point_r;
|
19687 | let r = pointR;
|
19688 | if ($$.isBubbleType(d)) {
|
19689 | r = $$.getBubbleR(d);
|
19690 | } else if (isFunction(pointR)) {
|
19691 | r = pointR.bind($$.api)(d);
|
19692 | }
|
19693 | d.r = r;
|
19694 | return r;
|
19695 | },
|
19696 | pointExpandedR(d) {
|
19697 | const $$ = this;
|
19698 | const { config } = $$;
|
19699 | const scale = $$.isBubbleType(d) ? 1.15 : 1.75;
|
19700 | return config.point_focus_expand_enabled ? config.point_focus_expand_r || $$.pointR(d) * scale : $$.pointR(d);
|
19701 | },
|
19702 | pointSelectR(d) {
|
19703 | const $$ = this;
|
19704 | const selectR = $$.config.point_select_r;
|
19705 | return isFunction(selectR) ? selectR(d) : selectR || $$.pointR(d) * 4;
|
19706 | },
|
19707 | |
19708 |
|
19709 |
|
19710 |
|
19711 |
|
19712 | isPointFocusOnly() {
|
19713 | const $$ = this;
|
19714 | return $$.config.point_focus_only && !$$.hasType("bubble") && !$$.hasType("scatter") && !$$.hasArcType(null, ["radar"]);
|
19715 | },
|
19716 | isWithinCircle(node, r) {
|
19717 | const { state } = this;
|
19718 | const mouse = getPointer(state.event, node);
|
19719 | const element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(node);
|
19720 | const prefix = this.isCirclePoint(node) ? "c" : "";
|
19721 | const pointSensitivity = this.getPointSensitivity(element == null ? void 0 : element.datum());
|
19722 | let cx = +element.attr(`${prefix}x`);
|
19723 | let cy = +element.attr(`${prefix}y`);
|
19724 | if (!(cx || cy) && node.nodeType === 1) {
|
19725 | const { x, y } = getBoundingRect(node);
|
19726 | cx = x;
|
19727 | cy = y;
|
19728 | }
|
19729 | return Math.sqrt(
|
19730 | Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)
|
19731 | ) < (r || pointSensitivity);
|
19732 | },
|
19733 | |
19734 |
|
19735 |
|
19736 |
|
19737 |
|
19738 | getPointSensitivity(d) {
|
19739 | const $$ = this;
|
19740 | let sensitivity = $$.config.point_sensitivity;
|
19741 | if (!d) {
|
19742 | return sensitivity;
|
19743 | } else if (isFunction(sensitivity)) {
|
19744 | sensitivity = sensitivity.call($$.api, d);
|
19745 | } else if (sensitivity === "radius") {
|
19746 | sensitivity = d.r;
|
19747 | }
|
19748 | return sensitivity;
|
19749 | },
|
19750 | updatePointClass(d) {
|
19751 | const $$ = this;
|
19752 | const { circle } = $$.$el;
|
19753 | let pointClass = false;
|
19754 | if (isObject(d) || circle) {
|
19755 | pointClass = d === true ? circle.each(function(d2) {
|
19756 | let className = $$.getClass("circle", true)(d2);
|
19757 | if (this.getAttribute("class").indexOf($COMMON.EXPANDED) > -1) {
|
19758 | className += ` ${$COMMON.EXPANDED}`;
|
19759 | }
|
19760 | this.setAttribute("class", className);
|
19761 | }) : $$.getClass("circle", true)(d);
|
19762 | }
|
19763 | return pointClass;
|
19764 | },
|
19765 | generateGetLinePoints(lineIndices, isSub) {
|
19766 | const $$ = this;
|
19767 | const { config } = $$;
|
19768 | const x = $$.getShapeX(0, lineIndices, isSub);
|
19769 | const y = $$.getShapeY(isSub);
|
19770 | const lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, isSub);
|
19771 | const yScale = $$.getYScaleById.bind($$);
|
19772 | return (d, i) => {
|
19773 | const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
|
19774 | const offset = lineOffset(d, i) || y0;
|
19775 | const posX = x(d);
|
19776 | let posY = y(d);
|
19777 | if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
|
19778 | posY = y0;
|
19779 | }
|
19780 | const point = [posX, posY - (y0 - offset)];
|
19781 | return [
|
19782 | point,
|
19783 | point,
|
19784 |
|
19785 | point,
|
19786 | point
|
19787 | ];
|
19788 | };
|
19789 | },
|
19790 | custom: {
|
19791 | create(element, id, fillStyleFn) {
|
19792 | return element.append("use").attr("xlink:href", `#${id}`).attr("class", this.updatePointClass.bind(this)).style("fill", fillStyleFn).node();
|
19793 | },
|
19794 | update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
19795 | const $$ = this;
|
19796 | const { width, height } = element.node().getBBox();
|
19797 | const xPosFn2 = (d) => isValue(d.value) ? xPosFn(d) - width / 2 : 0;
|
19798 | const yPosFn2 = (d) => isValue(d.value) ? yPosFn(d) - height / 2 : 0;
|
19799 | let mainCircles = element;
|
19800 | if (withTransition) {
|
19801 | flow && mainCircles.attr("x", xPosFn2);
|
19802 | mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
|
19803 | selectedCircles && $$.$T(selectedCircles, withTransition, getTransitionName());
|
19804 | }
|
19805 | return mainCircles.attr("x", xPosFn2).attr("y", yPosFn2).style("fill", fillStyleFn);
|
19806 | }
|
19807 | },
|
19808 |
|
19809 | circle: {
|
19810 | create(element, sizeFn, fillStyleFn) {
|
19811 | return element.append("circle").attr("class", this.updatePointClass.bind(this)).attr("r", sizeFn).style("fill", fillStyleFn).node();
|
19812 | },
|
19813 | update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
19814 | const $$ = this;
|
19815 | let mainCircles = element;
|
19816 | if ($$.hasType("bubble")) {
|
19817 | mainCircles.attr("r", $$.pointR.bind($$));
|
19818 | }
|
19819 | if (withTransition) {
|
19820 | flow && mainCircles.attr("cx", xPosFn);
|
19821 | if (mainCircles.attr("cx")) {
|
19822 | mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
|
19823 | }
|
19824 | selectedCircles && $$.$T(mainCircles, withTransition, getTransitionName());
|
19825 | }
|
19826 | return mainCircles.attr("cx", xPosFn).attr("cy", yPosFn).style("fill", fillStyleFn);
|
19827 | }
|
19828 | },
|
19829 |
|
19830 | rectangle: {
|
19831 | create(element, sizeFn, fillStyleFn) {
|
19832 | const rectSizeFn = (d) => sizeFn(d) * 2;
|
19833 | return element.append("rect").attr("class", this.updatePointClass.bind(this)).attr("width", rectSizeFn).attr("height", rectSizeFn).style("fill", fillStyleFn).node();
|
19834 | },
|
19835 | update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
19836 | const $$ = this;
|
19837 | const r = $$.config.point_r;
|
19838 | const rectXPosFn = (d) => xPosFn(d) - r;
|
19839 | const rectYPosFn = (d) => yPosFn(d) - r;
|
19840 | let mainCircles = element;
|
19841 | if (withTransition) {
|
19842 | flow && mainCircles.attr("x", rectXPosFn);
|
19843 | mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
|
19844 | selectedCircles && $$.$T(selectedCircles, withTransition, getTransitionName());
|
19845 | }
|
19846 | return mainCircles.attr("x", rectXPosFn).attr("y", rectYPosFn).style("fill", fillStyleFn);
|
19847 | }
|
19848 | }
|
19849 | });
|
19850 |
|
19851 | ;
|
19852 |
|
19853 |
|
19854 |
|
19855 | function hasValidPointDrawMethods(point) {
|
19856 | return isObjectType(point) && isFunction(point.create) && isFunction(point.update);
|
19857 | }
|
19858 | function insertPointInfoDefs(point, id) {
|
19859 | var _a;
|
19860 | const $$ = this;
|
19861 | const copyAttr = (from, target) => {
|
19862 | const attribs = from.attributes;
|
19863 | for (let i = 0, name; name = attribs[i]; i++) {
|
19864 | name = name.name;
|
19865 | target.setAttribute(name, from.getAttribute(name));
|
19866 | }
|
19867 | };
|
19868 | const doc = new DOMParser().parseFromString(point, "image/svg+xml");
|
19869 | const node = doc.documentElement;
|
19870 | const clone = browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, node.nodeName.toLowerCase());
|
19871 | clone.id = id;
|
19872 | clone.style.fill = "inherit";
|
19873 | clone.style.stroke = "inherit";
|
19874 | copyAttr(node, clone);
|
19875 | if ((_a = node.childNodes) == null ? void 0 : _a.length) {
|
19876 | const parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(clone);
|
19877 | if ("innerHTML" in clone) {
|
19878 | parent.html(node.innerHTML);
|
19879 | } else {
|
19880 | toArray(node.childNodes).forEach((v) => {
|
19881 | copyAttr(v, parent.append(v.tagName).node());
|
19882 | });
|
19883 | }
|
19884 | }
|
19885 | $$.$el.defs.node().appendChild(clone);
|
19886 | }
|
19887 | var point_common = ({
|
19888 | |
19889 |
|
19890 |
|
19891 |
|
19892 |
|
19893 |
|
19894 | hasValidPointType(type) {
|
19895 | return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
|
19896 | },
|
19897 | |
19898 |
|
19899 |
|
19900 |
|
19901 |
|
19902 | hasLegendDefsPoint() {
|
19903 | var _a;
|
19904 | const { config } = this;
|
19905 | return config.legend_show && ((_a = config.point_pattern) == null ? void 0 : _a.length) && config.legend_usePoint;
|
19906 | },
|
19907 | getDefsPointId(id) {
|
19908 | const { state: { datetimeId } } = this;
|
19909 | return `${datetimeId}-point${id}`;
|
19910 | },
|
19911 | |
19912 |
|
19913 |
|
19914 |
|
19915 |
|
19916 | generatePoint() {
|
19917 | const $$ = this;
|
19918 | const { $el, config } = $$;
|
19919 | const ids = [];
|
19920 | const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
|
19921 | return function(method, context, ...args) {
|
19922 | return function(d) {
|
19923 | var _a, _b, _c, _d;
|
19924 | const id = $$.getTargetSelectorSuffix(d.id || ((_a = d.data) == null ? void 0 : _a.id) || d);
|
19925 | const element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
19926 | ids.indexOf(id) < 0 && ids.push(id);
|
19927 | let point = pattern[ids.indexOf(id) % pattern.length];
|
19928 | if ($$.hasValidPointType(point)) {
|
19929 | point = $$[point];
|
19930 | } else if (!hasValidPointDrawMethods(point || config.point_type)) {
|
19931 | const pointId = $$.getDefsPointId(id);
|
19932 | const defsPoint = $el.defs.select(`#${pointId}`);
|
19933 | if (defsPoint.size() < 1) {
|
19934 | insertPointInfoDefs.bind($$)(point, pointId);
|
19935 | }
|
19936 | if (method === "create") {
|
19937 | return (_b = $$.custom) == null ? void 0 : _b.create.bind(context)(element, pointId, ...args);
|
19938 | } else if (method === "update") {
|
19939 | return (_c = $$.custom) == null ? void 0 : _c.update.bind(context)(element, ...args);
|
19940 | }
|
19941 | }
|
19942 | return (_d = point[method]) == null ? void 0 : _d.bind(context)(element, ...args);
|
19943 | };
|
19944 | };
|
19945 | }
|
19946 | });
|
19947 |
|
19948 | ;
|
19949 |
|
19950 |
|
19951 | function getDataMax($$) {
|
19952 | const levelMax = $$.config.polar_level_max;
|
19953 | let dataMax = $$.getMinMaxData().max[0].value;
|
19954 | if (levelMax && levelMax > dataMax) {
|
19955 | dataMax = levelMax;
|
19956 | }
|
19957 | return dataMax;
|
19958 | }
|
19959 | var polar = ({
|
19960 | |
19961 |
|
19962 |
|
19963 |
|
19964 | initPolar() {
|
19965 | const $$ = this;
|
19966 | const { $el: { arcs }, config } = $$;
|
19967 | const levelTextShow = config.polar_level_text_show;
|
19968 | const levelTextBgColor = config.polar_level_text_backgroundColor;
|
19969 | arcs.levels = arcs.append("g").attr("class", $LEVEL.levels);
|
19970 | if (levelTextShow && levelTextBgColor) {
|
19971 | $$.generateTextBGColorFilter(levelTextBgColor);
|
19972 | }
|
19973 | },
|
19974 | |
19975 |
|
19976 |
|
19977 |
|
19978 |
|
19979 |
|
19980 |
|
19981 | getPolarOuterRadius(d, outerRadius) {
|
19982 | var _a;
|
19983 | const dataMax = getDataMax(this);
|
19984 | return ((_a = d == null ? void 0 : d.data.values[0].value) != null ? _a : 0) / dataMax * outerRadius;
|
19985 | },
|
19986 | |
19987 |
|
19988 |
|
19989 |
|
19990 |
|
19991 | updateTargetsForPolar(targets) {
|
19992 | this.updateTargetsForArc(targets);
|
19993 | },
|
19994 | |
19995 |
|
19996 |
|
19997 |
|
19998 | redrawPolar() {
|
19999 | const $$ = this;
|
20000 | const { config } = $$;
|
20001 | config.polar_level_show && $$.updatePolarLevel();
|
20002 | },
|
20003 | |
20004 |
|
20005 |
|
20006 |
|
20007 | updatePolarLevel() {
|
20008 | const $$ = this;
|
20009 | const { config, state, $el: { arcs: { levels } } } = $$;
|
20010 | const depth = config.polar_level_depth;
|
20011 | const dataMax = getDataMax($$);
|
20012 | const levelData = getRange(0, depth);
|
20013 | const outerRadius = state.radius;
|
20014 | const levelRatio = levelData.map((l) => outerRadius * ((l + 1) / depth));
|
20015 | const levelTextFormat = (config.polar_level_text_format || function() {
|
20016 | }).bind($$.api);
|
20017 | const level = levels.selectAll(`.${$LEVEL.level}`).data(levelData);
|
20018 | level.exit().remove();
|
20019 | const levelEnter = level.enter().append("g").attr("class", (d, i) => `${$LEVEL.level} ${$LEVEL.level}-${i}`);
|
20020 | levelEnter.append("circle");
|
20021 | levelEnter.merge(level).selectAll("circle").style("visibility", config.polar_level_show ? null : "hidden").attr("cx", 0).attr("cy", 0).attr("r", (d) => levelRatio[d]);
|
20022 | if (config.polar_level_text_show) {
|
20023 | const levelTextBackgroundColor = config.polar_level_text_backgroundColor;
|
20024 | const defsId = `#${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(levelTextBackgroundColor)}`;
|
20025 | levelEnter.append("text").style("text-anchor", "middle");
|
20026 | levelEnter.merge(level).selectAll("text").attr("dy", (d) => -levelRatio[d] + 5).attr("filter", levelTextBackgroundColor ? `url(${defsId})` : null).text((d) => levelTextFormat(dataMax / levelData.length * (d + 1)));
|
20027 | }
|
20028 | }
|
20029 | });
|
20030 |
|
20031 | ;
|
20032 |
|
20033 |
|
20034 |
|
20035 |
|
20036 | function getPosition(isClockwise, type, edge, pos, range, ratio) {
|
20037 | const index = isClockwise && pos > 0 ? edge - pos : pos;
|
20038 | const r = 2 * Math.PI;
|
20039 | const func = type === "x" ? Math.sin : Math.cos;
|
20040 | return range * (1 - ratio * func(index * r / edge));
|
20041 | }
|
20042 | const cacheKeyPoints = KEY.radarPoints;
|
20043 | const cacheKeyTextWidth = KEY.radarTextWidth;
|
20044 | var radar = ({
|
20045 | initRadar() {
|
20046 | const $$ = this;
|
20047 | const { config, state: { current }, $el } = $$;
|
20048 | if ($$.hasType("radar")) {
|
20049 | $el.radar = $el.main.select(`.${$COMMON.chart}`).append("g").attr("class", $RADAR.chartRadars);
|
20050 | $el.radar.levels = $el.radar.append("g").attr("class", $LEVEL.levels);
|
20051 | $el.radar.axes = $el.radar.append("g").attr("class", $AXIS.axis);
|
20052 | $el.radar.shapes = $el.radar.append("g").attr("class", $SHAPE.shapes);
|
20053 | current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value;
|
20054 | if (config.radar_axis_text_show) {
|
20055 | config.interaction_enabled && $$.bindRadarEvent();
|
20056 | $$.updateRadarLevel();
|
20057 | $$.updateRadarAxes();
|
20058 | }
|
20059 | }
|
20060 | },
|
20061 | getRadarSize() {
|
20062 | const $$ = this;
|
20063 | const { config, state: { arcWidth, arcHeight } } = $$;
|
20064 | const padding = config.axis_x_categories.length < 4 ? -20 : 10;
|
20065 | const size = (Math.min(arcWidth, arcHeight) - padding) / 2;
|
20066 | return [size, size];
|
20067 | },
|
20068 | updateTargetsForRadar(targets) {
|
20069 | const $$ = this;
|
20070 | const { config } = $$;
|
20071 | if (isEmpty(config.axis_x_categories)) {
|
20072 | config.axis_x_categories = getRange(0, getMinMax("max", targets.map(
|
20073 | (v) => v.values.length
|
20074 | )));
|
20075 | }
|
20076 | $$.generateRadarPoints();
|
20077 | },
|
20078 | getRadarPosition(type, index, range, ratio) {
|
20079 | const $$ = this;
|
20080 | const { config } = $$;
|
20081 | const [width, height] = $$.getRadarSize();
|
20082 | const edge = config.axis_x_categories.length;
|
20083 | const isClockwise = config.radar_direction_clockwise;
|
20084 | const pos = toArray(type).map(
|
20085 | (v) => getPosition(
|
20086 | isClockwise,
|
20087 | v,
|
20088 | edge,
|
20089 | index,
|
20090 | isDefined(range) ? range : type === "x" ? width : height,
|
20091 | isNumber(ratio) ? ratio : config.radar_size_ratio
|
20092 | )
|
20093 | );
|
20094 | return pos.length === 1 ? pos[0] : pos;
|
20095 | },
|
20096 | |
20097 |
|
20098 |
|
20099 |
|
20100 | generateRadarPoints() {
|
20101 | const $$ = this;
|
20102 | const targets = $$.data.targets;
|
20103 | const [width, height] = $$.getRadarSize();
|
20104 | const points = $$.cache.get(cacheKeyPoints) || {};
|
20105 | const size = points._size;
|
20106 | if (!size || size.width !== width && size.height !== height) {
|
20107 | targets.forEach((d) => {
|
20108 | points[d.id] = d.values.map((v, i) => $$.getRadarPosition(["x", "y"], i, void 0, $$.getRatio("radar", v)));
|
20109 | });
|
20110 | points._size = { width, height };
|
20111 | $$.cache.add(cacheKeyPoints, points);
|
20112 | }
|
20113 | },
|
20114 | redrawRadar() {
|
20115 | const $$ = this;
|
20116 | const { radar, main } = $$.$el;
|
20117 | const translate = $$.getTranslate("radar");
|
20118 | if (translate) {
|
20119 | radar.attr("transform", translate);
|
20120 | main.select(`.${$TEXT.chartTexts}`).attr("transform", translate);
|
20121 | $$.generateRadarPoints();
|
20122 | $$.updateRadarLevel();
|
20123 | $$.updateRadarAxes();
|
20124 | $$.updateRadarShape();
|
20125 | }
|
20126 | },
|
20127 | generateGetRadarPoints() {
|
20128 | const points = this.cache.get(cacheKeyPoints);
|
20129 | return (d, i) => {
|
20130 | const point = points[d.id][i];
|
20131 | return [
|
20132 | point,
|
20133 | point,
|
20134 | point,
|
20135 | point
|
20136 | ];
|
20137 | };
|
20138 | },
|
20139 | updateRadarLevel() {
|
20140 | const $$ = this;
|
20141 | const { config, state, $el: { radar } } = $$;
|
20142 | const [width, height] = $$.getRadarSize();
|
20143 | const depth = config.radar_level_depth;
|
20144 | const edge = config.axis_x_categories.length;
|
20145 | const showText = config.radar_level_text_show;
|
20146 | const radarLevels = radar.levels;
|
20147 | const levelData = getRange(0, depth);
|
20148 | const radius = config.radar_size_ratio * Math.min(width, height);
|
20149 | const levelRatio = levelData.map((l) => radius * ((l + 1) / depth));
|
20150 | const levelTextFormat = (config.radar_level_text_format || function() {
|
20151 | }).bind($$.api);
|
20152 | const points = levelData.map((v) => {
|
20153 | const range = levelRatio[v];
|
20154 | const pos = getRange(0, edge).map(
|
20155 | (i) => $$.getRadarPosition(["x", "y"], i, range, 1).join(",")
|
20156 | );
|
20157 | return pos.join(" ");
|
20158 | });
|
20159 | const level = radarLevels.selectAll(`.${$LEVEL.level}`).data(levelData);
|
20160 | level.exit().remove();
|
20161 | const levelEnter = level.enter().append("g").attr("class", (d, i) => `${$LEVEL.level} ${$LEVEL.level}-${i}`);
|
20162 | levelEnter.append("polygon").style("visibility", config.radar_level_show ? null : "hidden");
|
20163 | if (showText) {
|
20164 | if (radarLevels.select("text").empty()) {
|
20165 | radarLevels.append("text").attr("dx", "-.5em").attr("dy", "-.7em").style("text-anchor", "end").text(() => levelTextFormat(0));
|
20166 | }
|
20167 | levelEnter.append("text").attr("dx", "-.5em").style("text-anchor", "end").text(
|
20168 | (d) => levelTextFormat(
|
20169 | state.current.dataMax / levelData.length * (d + 1)
|
20170 | )
|
20171 | );
|
20172 | }
|
20173 | levelEnter.merge(level).attr(
|
20174 | "transform",
|
20175 | (d) => `translate(${width - levelRatio[d]}, ${height - levelRatio[d]})`
|
20176 | ).selectAll("polygon").attr("points", (d) => points[d]);
|
20177 | if (showText) {
|
20178 | radarLevels.selectAll("text").attr("x", (d) => isUndefined(d) ? width : points[d].split(",")[0]).attr("y", (d) => isUndefined(d) ? height : 0);
|
20179 | }
|
20180 | },
|
20181 | updateRadarAxes() {
|
20182 | const $$ = this;
|
20183 | const { config, $el: { radar } } = $$;
|
20184 | const [width, height] = $$.getRadarSize();
|
20185 | const categories = config.axis_x_categories;
|
20186 | let axis = radar.axes.selectAll("g").data(categories);
|
20187 | axis.exit().remove();
|
20188 | const axisEnter = axis.enter().append("g").attr("class", (d, i) => `${$AXIS.axis}-${i}`);
|
20189 | config.radar_axis_line_show && axisEnter.append("line");
|
20190 | config.radar_axis_text_show && axisEnter.append("text");
|
20191 | axis = axisEnter.merge(axis);
|
20192 | if (config.radar_axis_line_show) {
|
20193 | axis.select("line").attr("x1", width).attr("y1", height).attr("x2", (d, i) => $$.getRadarPosition("x", i)).attr("y2", (d, i) => $$.getRadarPosition("y", i));
|
20194 | }
|
20195 | if (config.radar_axis_text_show) {
|
20196 | const { x = 0, y = 0 } = config.radar_axis_text_position;
|
20197 | const textWidth = $$.cache.get(cacheKeyTextWidth) || 0;
|
20198 | axis.select("text").style("text-anchor", "middle").attr("dy", ".5em").call((selection) => {
|
20199 | selection.each(function(d) {
|
20200 | setTextValue((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), String(d), [-0.6, 1.2]);
|
20201 | });
|
20202 | }).datum((d, i) => ({ index: i })).attr("transform", function(d) {
|
20203 | if (isUndefined(this.width)) {
|
20204 | this.width = this.getBoundingClientRect().width / 2;
|
20205 | }
|
20206 | let posX = $$.getRadarPosition("x", d.index, void 0, 1);
|
20207 | let posY = Math.round($$.getRadarPosition("y", d.index, void 0, 1));
|
20208 | if (posX > width) {
|
20209 | posX += this.width + x;
|
20210 | } else if (Math.round(posX) < width) {
|
20211 | posX -= this.width + x;
|
20212 | }
|
20213 | if (posY > height) {
|
20214 | if (posY / 2 === height && this.firstChild.tagName === "tspan") {
|
20215 | this.firstChild.setAttribute("dy", "0em");
|
20216 | }
|
20217 | posY += y;
|
20218 | } else if (posY < height) {
|
20219 | posY -= y;
|
20220 | }
|
20221 | return `translate(${posX} ${posY})`;
|
20222 | });
|
20223 | if (!textWidth) {
|
20224 | const widths = [radar.axes, radar.levels].map((v) => getPathBox(v.node()).width);
|
20225 | if (widths.every((v) => v > 0)) {
|
20226 | $$.cache.add(cacheKeyTextWidth, widths[0] - widths[1]);
|
20227 | }
|
20228 | }
|
20229 | }
|
20230 | },
|
20231 | bindRadarEvent() {
|
20232 | const $$ = this;
|
20233 | const { config, state, $el: { radar, svg } } = $$;
|
20234 | const focusOnly = $$.isPointFocusOnly();
|
20235 | const { inputType, transiting } = state;
|
20236 | const isMouse = inputType === "mouse";
|
20237 | const hide = (event) => {
|
20238 | state.event = event;
|
20239 | if (!config.interaction_onout) {
|
20240 | return;
|
20241 | }
|
20242 | const index = $$.getDataIndexFromEvent(event);
|
20243 | const noIndex = isUndefined(index);
|
20244 | if (isMouse || noIndex) {
|
20245 | $$.hideTooltip();
|
20246 | focusOnly ? $$.hideCircleFocus() : $$.unexpandCircles();
|
20247 | if (isMouse) {
|
20248 | $$.setOverOut(false, index);
|
20249 | } else if (noIndex) {
|
20250 | $$.callOverOutForTouch();
|
20251 | }
|
20252 | }
|
20253 | };
|
20254 | radar.axes.on(isMouse ? "mouseover " : "touchstart", (event) => {
|
20255 | if (transiting) {
|
20256 | return;
|
20257 | }
|
20258 | state.event = event;
|
20259 | const index = $$.getDataIndexFromEvent(event);
|
20260 | $$.selectRectForSingle(svg.node(), index);
|
20261 | isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
|
20262 | }).on("mouseout", isMouse ? hide : null);
|
20263 | if (!isMouse) {
|
20264 | svg.on("touchstart", hide);
|
20265 | }
|
20266 | },
|
20267 | updateRadarShape() {
|
20268 | const $$ = this;
|
20269 | const targets = $$.data.targets.filter((d) => $$.isRadarType(d));
|
20270 | const points = $$.cache.get(cacheKeyPoints);
|
20271 | const areas = $$.$el.radar.shapes.selectAll("polygon").data(targets);
|
20272 | const areasEnter = areas.enter().append("g").attr("class", $$.getChartClass("Radar"));
|
20273 | $$.$T(areas.exit()).remove();
|
20274 | areasEnter.append("polygon").merge(areas).style("fill", $$.color).style("stroke", $$.color).attr("points", (d) => points[d.id].join(" "));
|
20275 | $$.updateTargetForCircle(targets, areasEnter);
|
20276 | },
|
20277 | |
20278 |
|
20279 |
|
20280 |
|
20281 |
|
20282 |
|
20283 | radarCircleX(d) {
|
20284 | return this.cache.get(cacheKeyPoints)[d.id][d.index][0];
|
20285 | },
|
20286 | |
20287 |
|
20288 |
|
20289 |
|
20290 |
|
20291 |
|
20292 | radarCircleY(d) {
|
20293 | return this.cache.get(cacheKeyPoints)[d.id][d.index][1];
|
20294 | }
|
20295 | });
|
20296 |
|
20297 |
|
20298 | var external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_ = __webpack_require__(14);
|
20299 | ;
|
20300 |
|
20301 |
|
20302 |
|
20303 |
|
20304 | function position(group, root) {
|
20305 | const $$ = this;
|
20306 | const { scale: { x, y }, state: { width } } = $$;
|
20307 | group.selectAll("g").attr("transform", (d) => `translate(${d === root ? "0,0" : `${x(d.x0)},${y(d.y0)}`})`).select("rect").attr("width", (d) => d === root ? width : x(d.x1) - x(d.x0)).attr("height", (d) => d === root ? 0 : y(d.y1) - y(d.y0));
|
20308 | }
|
20309 | function convertDataToTreemapData(data) {
|
20310 | const $$ = this;
|
20311 | return data.map((d) => {
|
20312 | const { id, values } = d;
|
20313 | const { value } = values[0];
|
20314 | return {
|
20315 | name: id,
|
20316 | id,
|
20317 |
|
20318 | value,
|
20319 | ratio: $$.getRatio("treemap", values[0])
|
20320 | };
|
20321 | });
|
20322 | }
|
20323 | function getHierachyData(data) {
|
20324 | const $$ = this;
|
20325 | const hierarchyData = (0,external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.hierarchy)(data).sum((d) => d.value);
|
20326 | const sortFn = $$.getSortCompareFn(true);
|
20327 | return [
|
20328 | $$.treemap(
|
20329 | sortFn ? hierarchyData.sort(sortFn) : hierarchyData
|
20330 | )
|
20331 | ];
|
20332 | }
|
20333 | var treemap = ({
|
20334 | initTreemap() {
|
20335 | const $$ = this;
|
20336 | const {
|
20337 | $el,
|
20338 | state: {
|
20339 | current: { width, height },
|
20340 | clip,
|
20341 | datetimeId
|
20342 | }
|
20343 | } = $$;
|
20344 | clip.id = `${datetimeId}-clip`;
|
20345 | $$.treemap = (0,external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemap)().tile($$.getTreemapTile());
|
20346 | $el.defs.append("clipPath").attr("id", clip.id).append("rect").attr("width", width).attr("height", height);
|
20347 | $el.treemap = $el.main.select(`.${$COMMON.chart}`).attr("clip-path", `url(#${clip.id})`).append("g").classed($TREEMAP.chartTreemaps, true);
|
20348 | $$.bindTreemapEvent();
|
20349 | },
|
20350 | |
20351 |
|
20352 |
|
20353 |
|
20354 | bindTreemapEvent() {
|
20355 | const $$ = this;
|
20356 | const { $el, config, state } = $$;
|
20357 | const getTarget = (event) => {
|
20358 | var _a;
|
20359 | const target = event.isTrusted ? event.target : (_a = state.eventReceiver.rect) == null ? void 0 : _a.node();
|
20360 | let data;
|
20361 | if (/^rect$/i.test(target.tagName)) {
|
20362 | state.event = event;
|
20363 | data = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
|
20364 | }
|
20365 | return data == null ? void 0 : data.data;
|
20366 | };
|
20367 | if (config.interaction_enabled) {
|
20368 | const isTouch = state.inputType === "touch";
|
20369 | $el.treemap.on(isTouch ? "touchstart" : "mouseover mousemove", (event) => {
|
20370 | const data = getTarget(event);
|
20371 | if (data) {
|
20372 | $$.showTooltip([data], event.currentTarget);
|
20373 | /^(touchstart|mouseover)$/.test(event.type) && $$.setOverOut(true, data);
|
20374 | }
|
20375 | }).on(isTouch ? "touchend" : "mouseout", (event) => {
|
20376 | const data = getTarget(event);
|
20377 | if (config.interaction_onout) {
|
20378 | $$.hideTooltip();
|
20379 | $$.setOverOut(false, data);
|
20380 | }
|
20381 | });
|
20382 | }
|
20383 | },
|
20384 | |
20385 |
|
20386 |
|
20387 |
|
20388 |
|
20389 | getTreemapTile() {
|
20390 | var _a, _b;
|
20391 | const $$ = this;
|
20392 | const { config, state: { current: { width, height } } } = $$;
|
20393 | const tile = (_b = {
|
20394 | binary: external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapBinary,
|
20395 | dice: external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapDice,
|
20396 | slice: external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapSlice,
|
20397 | sliceDice: external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapSliceDice,
|
20398 | squarify: external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapSquarify,
|
20399 | resquarify: external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapResquarify
|
20400 | }[(_a = config.treemap_tile) != null ? _a : "binary"]) != null ? _b : external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_.treemapBinary;
|
20401 | return (node, x0, y0, x1, y1) => {
|
20402 | tile(node, 0, 0, width, height);
|
20403 | for (const child of node.children) {
|
20404 | child.x0 = x0 + child.x0 / width * (x1 - x0);
|
20405 | child.x1 = x0 + child.x1 / width * (x1 - x0);
|
20406 | child.y0 = y0 + child.y0 / height * (y1 - y0);
|
20407 | child.y1 = y0 + child.y1 / height * (y1 - y0);
|
20408 | }
|
20409 | };
|
20410 | },
|
20411 | |
20412 |
|
20413 |
|
20414 |
|
20415 |
|
20416 |
|
20417 | getTreemapData(targets) {
|
20418 | const $$ = this;
|
20419 | return {
|
20420 | name: "root",
|
20421 | children: convertDataToTreemapData.bind($$)(
|
20422 | $$.filterTargetsToShow(targets.filter($$.isTreemapType, $$))
|
20423 | )
|
20424 | };
|
20425 | },
|
20426 | |
20427 |
|
20428 |
|
20429 |
|
20430 |
|
20431 | updateTargetsForTreemap(targets) {
|
20432 | const $$ = this;
|
20433 | const { $el: { treemap } } = $$;
|
20434 | const treemapData = getHierachyData.call($$, $$.getTreemapData(targets != null ? targets : $$.data.targets));
|
20435 | treemap.data(treemapData);
|
20436 | },
|
20437 | |
20438 |
|
20439 |
|
20440 |
|
20441 |
|
20442 | updateTreemap(durationForExit) {
|
20443 | const $$ = this;
|
20444 | const { $el, $T } = $$;
|
20445 | const data = $el.treemap.datum();
|
20446 | const classChartTreemap = $$.getChartClass("Treemap");
|
20447 | const classTreemap = $$.getClass("treemap", true);
|
20448 | const treemap = $el.treemap.selectAll("g").data(data.children);
|
20449 | $T(treemap.exit(), durationForExit).style("opacity", "0").remove();
|
20450 | treemap.enter().append("g").append("rect");
|
20451 | $el.treemap.selectAll("g").attr("class", classChartTreemap).select("rect").attr("class", classTreemap).attr("fill", (d) => $$.color(d.data.name));
|
20452 | },
|
20453 | |
20454 |
|
20455 |
|
20456 |
|
20457 |
|
20458 | generateGetTreemapPoints() {
|
20459 | const $$ = this;
|
20460 | const { $el, scale: { x, y } } = $$;
|
20461 | const points = {};
|
20462 | $el.treemap.selectAll("g").each((d) => {
|
20463 | points[d.data.name] = [
|
20464 | [x(d.x0), y(d.y0)],
|
20465 | [x(d.x1), y(d.y1)]
|
20466 | ];
|
20467 | });
|
20468 | return (d) => points[d.id];
|
20469 | },
|
20470 | |
20471 |
|
20472 |
|
20473 |
|
20474 |
|
20475 |
|
20476 | redrawTreemap(withTransition) {
|
20477 | const $$ = this;
|
20478 | const { $el, state: { current: { width, height } } } = $$;
|
20479 | $el.defs.select("rect").attr("width", width).attr("height", height);
|
20480 | return [
|
20481 | $$.$T($el.treemap, withTransition, getRandom()).call(position.bind($$), $el.treemap.datum())
|
20482 | ];
|
20483 | },
|
20484 | |
20485 |
|
20486 |
|
20487 |
|
20488 |
|
20489 |
|
20490 | treemapDataLabelFormat(d) {
|
20491 | const $$ = this;
|
20492 | const { config } = $$;
|
20493 | const { id, value } = d;
|
20494 | const format = config.treemap_label_format;
|
20495 | const ratio = $$.getRatio("treemap", d);
|
20496 | const percentValue = (ratio * 100).toFixed(2);
|
20497 | const meetLabelThreshold = config.treemap_label_show && $$.meetsLabelThreshold(
|
20498 | ratio,
|
20499 | "treemap"
|
20500 | ) ? null : "0";
|
20501 | return function(node) {
|
20502 | node.style("opacity", meetLabelThreshold);
|
20503 | return isFunction(format) ? format.bind($$.api)(value, ratio, id) : `${id}
|
20504 | ${percentValue}%`;
|
20505 | };
|
20506 | }
|
20507 | });
|
20508 |
|
20509 | ;
|
20510 | var common_point = ({
|
20511 | |
20512 |
|
20513 |
|
20514 |
|
20515 |
|
20516 |
|
20517 |
|
20518 |
|
20519 |
|
20520 |
|
20521 |
|
20522 |
|
20523 |
|
20524 |
|
20525 |
|
20526 |
|
20527 |
|
20528 |
|
20529 |
|
20530 |
|
20531 |
|
20532 |
|
20533 |
|
20534 |
|
20535 |
|
20536 |
|
20537 |
|
20538 |
|
20539 |
|
20540 |
|
20541 |
|
20542 |
|
20543 |
|
20544 |
|
20545 |
|
20546 |
|
20547 |
|
20548 |
|
20549 |
|
20550 |
|
20551 |
|
20552 |
|
20553 |
|
20554 |
|
20555 |
|
20556 |
|
20557 |
|
20558 |
|
20559 |
|
20560 |
|
20561 |
|
20562 |
|
20563 |
|
20564 |
|
20565 |
|
20566 |
|
20567 |
|
20568 |
|
20569 |
|
20570 |
|
20571 |
|
20572 |
|
20573 |
|
20574 |
|
20575 |
|
20576 |
|
20577 |
|
20578 |
|
20579 |
|
20580 |
|
20581 |
|
20582 |
|
20583 |
|
20584 |
|
20585 |
|
20586 |
|
20587 |
|
20588 |
|
20589 |
|
20590 |
|
20591 |
|
20592 |
|
20593 |
|
20594 |
|
20595 |
|
20596 |
|
20597 |
|
20598 |
|
20599 |
|
20600 |
|
20601 |
|
20602 |
|
20603 |
|
20604 |
|
20605 |
|
20606 |
|
20607 |
|
20608 |
|
20609 |
|
20610 |
|
20611 |
|
20612 |
|
20613 |
|
20614 |
|
20615 |
|
20616 |
|
20617 |
|
20618 |
|
20619 |
|
20620 |
|
20621 |
|
20622 |
|
20623 |
|
20624 |
|
20625 |
|
20626 |
|
20627 |
|
20628 |
|
20629 |
|
20630 |
|
20631 |
|
20632 |
|
20633 |
|
20634 |
|
20635 |
|
20636 |
|
20637 |
|
20638 |
|
20639 |
|
20640 |
|
20641 |
|
20642 |
|
20643 |
|
20644 |
|
20645 |
|
20646 |
|
20647 |
|
20648 |
|
20649 |
|
20650 |
|
20651 |
|
20652 | point_show: true,
|
20653 | point_r: 2.5,
|
20654 | point_radialGradient: false,
|
20655 | point_sensitivity: 10,
|
20656 | point_focus_expand_enabled: true,
|
20657 | point_focus_expand_r: void 0,
|
20658 | point_focus_only: false,
|
20659 | point_opacity: void 0,
|
20660 | point_pattern: [],
|
20661 | point_select_r: void 0,
|
20662 | point_type: "circle"
|
20663 | });
|
20664 |
|
20665 | ;
|
20666 | var Options_shape_area = ({
|
20667 | |
20668 |
|
20669 |
|
20670 |
|
20671 |
|
20672 |
|
20673 |
|
20674 |
|
20675 |
|
20676 |
|
20677 |
|
20678 |
|
20679 |
|
20680 |
|
20681 |
|
20682 |
|
20683 |
|
20684 |
|
20685 |
|
20686 |
|
20687 |
|
20688 |
|
20689 |
|
20690 |
|
20691 |
|
20692 |
|
20693 |
|
20694 |
|
20695 |
|
20696 |
|
20697 |
|
20698 |
|
20699 |
|
20700 |
|
20701 |
|
20702 |
|
20703 |
|
20704 |
|
20705 |
|
20706 |
|
20707 |
|
20708 |
|
20709 |
|
20710 |
|
20711 |
|
20712 |
|
20713 |
|
20714 |
|
20715 |
|
20716 |
|
20717 |
|
20718 |
|
20719 |
|
20720 |
|
20721 |
|
20722 |
|
20723 |
|
20724 | area_above: false,
|
20725 | area_below: false,
|
20726 | area_front: true,
|
20727 | area_linearGradient: false,
|
20728 | area_zerobased: true
|
20729 | });
|
20730 |
|
20731 | ;
|
20732 | var shape_bar = ({
|
20733 | |
20734 |
|
20735 |
|
20736 |
|
20737 |
|
20738 |
|
20739 |
|
20740 |
|
20741 |
|
20742 |
|
20743 |
|
20744 |
|
20745 |
|
20746 |
|
20747 |
|
20748 |
|
20749 |
|
20750 |
|
20751 |
|
20752 |
|
20753 |
|
20754 |
|
20755 |
|
20756 |
|
20757 |
|
20758 |
|
20759 |
|
20760 |
|
20761 |
|
20762 |
|
20763 |
|
20764 |
|
20765 |
|
20766 |
|
20767 |
|
20768 |
|
20769 |
|
20770 |
|
20771 |
|
20772 |
|
20773 |
|
20774 |
|
20775 |
|
20776 |
|
20777 |
|
20778 |
|
20779 |
|
20780 |
|
20781 |
|
20782 |
|
20783 |
|
20784 |
|
20785 |
|
20786 |
|
20787 |
|
20788 |
|
20789 |
|
20790 |
|
20791 |
|
20792 |
|
20793 |
|
20794 |
|
20795 |
|
20796 |
|
20797 |
|
20798 |
|
20799 |
|
20800 |
|
20801 |
|
20802 |
|
20803 |
|
20804 |
|
20805 |
|
20806 |
|
20807 |
|
20808 |
|
20809 |
|
20810 |
|
20811 |
|
20812 |
|
20813 |
|
20814 |
|
20815 |
|
20816 |
|
20817 |
|
20818 |
|
20819 |
|
20820 |
|
20821 |
|
20822 |
|
20823 |
|
20824 |
|
20825 |
|
20826 |
|
20827 |
|
20828 |
|
20829 |
|
20830 |
|
20831 |
|
20832 |
|
20833 |
|
20834 |
|
20835 |
|
20836 |
|
20837 |
|
20838 |
|
20839 |
|
20840 |
|
20841 |
|
20842 |
|
20843 |
|
20844 |
|
20845 |
|
20846 |
|
20847 |
|
20848 |
|
20849 |
|
20850 |
|
20851 |
|
20852 |
|
20853 |
|
20854 |
|
20855 |
|
20856 |
|
20857 |
|
20858 |
|
20859 | bar_front: false,
|
20860 | bar_indices_removeNull: false,
|
20861 | bar_label_threshold: 0,
|
20862 | bar_linearGradient: false,
|
20863 | bar_overlap: false,
|
20864 | bar_padding: 0,
|
20865 | bar_radius: void 0,
|
20866 | bar_radius_ratio: void 0,
|
20867 | bar_sensitivity: 2,
|
20868 | bar_width: void 0,
|
20869 | bar_width_ratio: 0.6,
|
20870 | bar_width_max: void 0,
|
20871 | bar_zerobased: true
|
20872 | });
|
20873 |
|
20874 | ;
|
20875 | var shape_bubble = ({
|
20876 | |
20877 |
|
20878 |
|
20879 |
|
20880 |
|
20881 |
|
20882 |
|
20883 |
|
20884 |
|
20885 |
|
20886 |
|
20887 |
|
20888 |
|
20889 |
|
20890 |
|
20891 |
|
20892 |
|
20893 |
|
20894 |
|
20895 |
|
20896 |
|
20897 |
|
20898 |
|
20899 | bubble_maxR: 35,
|
20900 | bubble_zerobased: false
|
20901 | });
|
20902 |
|
20903 | ;
|
20904 | var shape_candlestick = ({
|
20905 | |
20906 |
|
20907 |
|
20908 |
|
20909 |
|
20910 |
|
20911 |
|
20912 |
|
20913 |
|
20914 |
|
20915 |
|
20916 |
|
20917 |
|
20918 |
|
20919 |
|
20920 |
|
20921 |
|
20922 |
|
20923 |
|
20924 |
|
20925 |
|
20926 |
|
20927 |
|
20928 |
|
20929 |
|
20930 |
|
20931 |
|
20932 |
|
20933 |
|
20934 |
|
20935 |
|
20936 |
|
20937 |
|
20938 |
|
20939 |
|
20940 |
|
20941 |
|
20942 |
|
20943 |
|
20944 |
|
20945 |
|
20946 |
|
20947 |
|
20948 |
|
20949 |
|
20950 |
|
20951 |
|
20952 | candlestick_width: void 0,
|
20953 | candlestick_width_ratio: 0.6,
|
20954 | candlestick_width_max: void 0,
|
20955 | candlestick_color_down: "red"
|
20956 | });
|
20957 |
|
20958 | ;
|
20959 | var shape_line = ({
|
20960 | |
20961 |
|
20962 |
|
20963 |
|
20964 |
|
20965 |
|
20966 |
|
20967 |
|
20968 |
|
20969 |
|
20970 |
|
20971 |
|
20972 |
|
20973 |
|
20974 |
|
20975 |
|
20976 |
|
20977 |
|
20978 |
|
20979 |
|
20980 |
|
20981 |
|
20982 |
|
20983 |
|
20984 |
|
20985 |
|
20986 |
|
20987 |
|
20988 |
|
20989 |
|
20990 |
|
20991 |
|
20992 |
|
20993 |
|
20994 |
|
20995 |
|
20996 |
|
20997 |
|
20998 |
|
20999 |
|
21000 |
|
21001 |
|
21002 | line_connectNull: false,
|
21003 | line_step_type: "step",
|
21004 | line_step_tooltipMatch: false,
|
21005 | line_zerobased: false,
|
21006 | line_classes: void 0,
|
21007 | line_point: true
|
21008 | });
|
21009 |
|
21010 | ;
|
21011 | var scatter = ({
|
21012 | |
21013 |
|
21014 |
|
21015 |
|
21016 |
|
21017 |
|
21018 |
|
21019 |
|
21020 |
|
21021 |
|
21022 |
|
21023 |
|
21024 |
|
21025 |
|
21026 |
|
21027 |
|
21028 |
|
21029 |
|
21030 |
|
21031 |
|
21032 |
|
21033 |
|
21034 |
|
21035 |
|
21036 |
|
21037 | scatter_zerobased: false
|
21038 | });
|
21039 |
|
21040 | ;
|
21041 | var spline = ({
|
21042 | |
21043 |
|
21044 |
|
21045 |
|
21046 |
|
21047 |
|
21048 |
|
21049 |
|
21050 |
|
21051 |
|
21052 |
|
21053 |
|
21054 |
|
21055 |
|
21056 |
|
21057 |
|
21058 |
|
21059 |
|
21060 |
|
21061 |
|
21062 |
|
21063 |
|
21064 |
|
21065 |
|
21066 |
|
21067 |
|
21068 |
|
21069 |
|
21070 |
|
21071 |
|
21072 |
|
21073 |
|
21074 |
|
21075 |
|
21076 |
|
21077 | spline_interpolation_type: "cardinal"
|
21078 | });
|
21079 |
|
21080 | ;
|
21081 | var shape_arc = ({
|
21082 | |
21083 |
|
21084 |
|
21085 |
|
21086 |
|
21087 |
|
21088 |
|
21089 |
|
21090 |
|
21091 |
|
21092 |
|
21093 |
|
21094 |
|
21095 |
|
21096 |
|
21097 |
|
21098 |
|
21099 |
|
21100 |
|
21101 |
|
21102 |
|
21103 |
|
21104 |
|
21105 |
|
21106 |
|
21107 |
|
21108 |
|
21109 |
|
21110 |
|
21111 |
|
21112 |
|
21113 |
|
21114 |
|
21115 |
|
21116 |
|
21117 |
|
21118 |
|
21119 |
|
21120 |
|
21121 |
|
21122 |
|
21123 |
|
21124 |
|
21125 |
|
21126 |
|
21127 |
|
21128 |
|
21129 |
|
21130 |
|
21131 |
|
21132 |
|
21133 |
|
21134 |
|
21135 |
|
21136 |
|
21137 |
|
21138 |
|
21139 |
|
21140 |
|
21141 |
|
21142 |
|
21143 |
|
21144 |
|
21145 |
|
21146 |
|
21147 |
|
21148 |
|
21149 |
|
21150 |
|
21151 |
|
21152 |
|
21153 |
|
21154 |
|
21155 |
|
21156 |
|
21157 |
|
21158 |
|
21159 |
|
21160 |
|
21161 |
|
21162 |
|
21163 |
|
21164 |
|
21165 |
|
21166 |
|
21167 |
|
21168 |
|
21169 |
|
21170 |
|
21171 |
|
21172 |
|
21173 |
|
21174 |
|
21175 |
|
21176 |
|
21177 |
|
21178 |
|
21179 |
|
21180 |
|
21181 |
|
21182 |
|
21183 |
|
21184 |
|
21185 |
|
21186 |
|
21187 |
|
21188 |
|
21189 |
|
21190 |
|
21191 |
|
21192 |
|
21193 |
|
21194 |
|
21195 |
|
21196 |
|
21197 |
|
21198 |
|
21199 |
|
21200 |
|
21201 |
|
21202 |
|
21203 | arc_cornerRadius: 0,
|
21204 | arc_cornerRadius_ratio: 0,
|
21205 | arc_needle_show: false,
|
21206 | arc_needle_color: void 0,
|
21207 | arc_needle_value: void 0,
|
21208 | arc_needle_path: void 0,
|
21209 | arc_needle_length: 100,
|
21210 | arc_needle_top_rx: 0,
|
21211 | arc_needle_top_ry: 0,
|
21212 | arc_needle_top_width: 0,
|
21213 | arc_needle_bottom_rx: 1,
|
21214 | arc_needle_bottom_ry: 1,
|
21215 | arc_needle_bottom_width: 15,
|
21216 | arc_needle_bottom_len: 0,
|
21217 | arc_rangeText_values: void 0,
|
21218 | arc_rangeText_unit: "absolute",
|
21219 | arc_rangeText_fixed: false,
|
21220 | arc_rangeText_format: void 0,
|
21221 | arc_rangeText_position: void 0
|
21222 | });
|
21223 |
|
21224 | ;
|
21225 | var donut = ({
|
21226 | |
21227 |
|
21228 |
|
21229 |
|
21230 |
|
21231 |
|
21232 |
|
21233 |
|
21234 |
|
21235 |
|
21236 |
|
21237 |
|
21238 |
|
21239 |
|
21240 |
|
21241 |
|
21242 |
|
21243 |
|
21244 |
|
21245 |
|
21246 |
|
21247 |
|
21248 |
|
21249 |
|
21250 |
|
21251 |
|
21252 |
|
21253 |
|
21254 |
|
21255 |
|
21256 |
|
21257 |
|
21258 |
|
21259 |
|
21260 |
|
21261 |
|
21262 |
|
21263 |
|
21264 |
|
21265 |
|
21266 |
|
21267 |
|
21268 |
|
21269 |
|
21270 |
|
21271 |
|
21272 |
|
21273 |
|
21274 |
|
21275 |
|
21276 |
|
21277 |
|
21278 |
|
21279 |
|
21280 |
|
21281 |
|
21282 |
|
21283 |
|
21284 |
|
21285 |
|
21286 |
|
21287 |
|
21288 |
|
21289 |
|
21290 |
|
21291 |
|
21292 | donut_label_show: true,
|
21293 | donut_label_format: void 0,
|
21294 | donut_label_threshold: 0.05,
|
21295 | donut_label_ratio: void 0,
|
21296 | donut_width: void 0,
|
21297 | donut_title: "",
|
21298 | donut_expand: {},
|
21299 | donut_expand_rate: 0.98,
|
21300 | donut_expand_duration: 50,
|
21301 | donut_padAngle: 0,
|
21302 | donut_startingAngle: 0
|
21303 | });
|
21304 |
|
21305 | ;
|
21306 | var shape_funnel = ({
|
21307 | |
21308 |
|
21309 |
|
21310 |
|
21311 |
|
21312 |
|
21313 |
|
21314 |
|
21315 |
|
21316 |
|
21317 |
|
21318 |
|
21319 |
|
21320 |
|
21321 |
|
21322 |
|
21323 |
|
21324 |
|
21325 |
|
21326 |
|
21327 |
|
21328 |
|
21329 |
|
21330 |
|
21331 |
|
21332 |
|
21333 |
|
21334 | funnel_neck_width: 0,
|
21335 | funnel_neck_height: 0
|
21336 | });
|
21337 |
|
21338 | ;
|
21339 | var shape_gauge = ({
|
21340 | |
21341 |
|
21342 |
|
21343 |
|
21344 |
|
21345 |
|
21346 |
|
21347 |
|
21348 |
|
21349 |
|
21350 |
|
21351 |
|
21352 |
|
21353 |
|
21354 |
|
21355 |
|
21356 |
|
21357 |
|
21358 |
|
21359 |
|
21360 |
|
21361 |
|
21362 |
|
21363 |
|
21364 |
|
21365 |
|
21366 |
|
21367 |
|
21368 |
|
21369 |
|
21370 |
|
21371 |
|
21372 |
|
21373 |
|
21374 |
|
21375 |
|
21376 |
|
21377 |
|
21378 |
|
21379 |
|
21380 |
|
21381 |
|
21382 |
|
21383 |
|
21384 |
|
21385 |
|
21386 |
|
21387 |
|
21388 |
|
21389 |
|
21390 |
|
21391 |
|
21392 |
|
21393 |
|
21394 |
|
21395 |
|
21396 |
|
21397 |
|
21398 |
|
21399 |
|
21400 |
|
21401 |
|
21402 |
|
21403 |
|
21404 |
|
21405 |
|
21406 |
|
21407 |
|
21408 |
|
21409 |
|
21410 |
|
21411 |
|
21412 |
|
21413 |
|
21414 |
|
21415 |
|
21416 |
|
21417 |
|
21418 |
|
21419 |
|
21420 |
|
21421 |
|
21422 |
|
21423 |
|
21424 |
|
21425 |
|
21426 |
|
21427 |
|
21428 |
|
21429 |
|
21430 |
|
21431 |
|
21432 |
|
21433 |
|
21434 |
|
21435 |
|
21436 |
|
21437 |
|
21438 |
|
21439 |
|
21440 |
|
21441 |
|
21442 |
|
21443 |
|
21444 |
|
21445 |
|
21446 |
|
21447 |
|
21448 |
|
21449 |
|
21450 |
|
21451 |
|
21452 |
|
21453 |
|
21454 |
|
21455 |
|
21456 |
|
21457 |
|
21458 |
|
21459 |
|
21460 | gauge_background: "",
|
21461 | gauge_fullCircle: false,
|
21462 | gauge_label_show: true,
|
21463 | gauge_label_extents: void 0,
|
21464 | gauge_label_format: void 0,
|
21465 | gauge_label_ratio: void 0,
|
21466 | gauge_label_threshold: 0,
|
21467 | gauge_enforceMinMax: false,
|
21468 | gauge_min: 0,
|
21469 | gauge_max: 100,
|
21470 | gauge_type: "single",
|
21471 | gauge_startingAngle: -1 * Math.PI / 2,
|
21472 | gauge_arcLength: 100,
|
21473 | gauge_title: "",
|
21474 | gauge_units: void 0,
|
21475 | gauge_width: void 0,
|
21476 | gauge_arcs_minWidth: 5,
|
21477 | gauge_expand: {},
|
21478 | gauge_expand_rate: 0.98,
|
21479 | gauge_expand_duration: 50
|
21480 | });
|
21481 |
|
21482 | ;
|
21483 | var pie = ({
|
21484 | |
21485 |
|
21486 |
|
21487 |
|
21488 |
|
21489 |
|
21490 |
|
21491 |
|
21492 |
|
21493 |
|
21494 |
|
21495 |
|
21496 |
|
21497 |
|
21498 |
|
21499 |
|
21500 |
|
21501 |
|
21502 |
|
21503 |
|
21504 |
|
21505 |
|
21506 |
|
21507 |
|
21508 |
|
21509 |
|
21510 |
|
21511 |
|
21512 |
|
21513 |
|
21514 |
|
21515 |
|
21516 |
|
21517 |
|
21518 |
|
21519 |
|
21520 |
|
21521 |
|
21522 |
|
21523 |
|
21524 |
|
21525 |
|
21526 |
|
21527 |
|
21528 |
|
21529 |
|
21530 |
|
21531 |
|
21532 |
|
21533 |
|
21534 |
|
21535 |
|
21536 |
|
21537 |
|
21538 |
|
21539 |
|
21540 |
|
21541 |
|
21542 |
|
21543 |
|
21544 |
|
21545 |
|
21546 |
|
21547 |
|
21548 |
|
21549 |
|
21550 |
|
21551 |
|
21552 |
|
21553 |
|
21554 |
|
21555 |
|
21556 |
|
21557 |
|
21558 |
|
21559 |
|
21560 |
|
21561 |
|
21562 | pie_label_show: true,
|
21563 | pie_label_format: void 0,
|
21564 | pie_label_ratio: void 0,
|
21565 | pie_label_threshold: 0.05,
|
21566 | pie_expand: {},
|
21567 | pie_expand_rate: 0.98,
|
21568 | pie_expand_duration: 50,
|
21569 | pie_innerRadius: 0,
|
21570 | pie_outerRadius: void 0,
|
21571 | pie_padAngle: 0,
|
21572 | pie_padding: 0,
|
21573 | pie_startingAngle: 0
|
21574 | });
|
21575 |
|
21576 | ;
|
21577 | var shape_polar = ({
|
21578 | |
21579 |
|
21580 |
|
21581 |
|
21582 |
|
21583 |
|
21584 |
|
21585 |
|
21586 |
|
21587 |
|
21588 |
|
21589 |
|
21590 |
|
21591 |
|
21592 |
|
21593 |
|
21594 |
|
21595 |
|
21596 |
|
21597 |
|
21598 |
|
21599 |
|
21600 |
|
21601 |
|
21602 |
|
21603 |
|
21604 |
|
21605 |
|
21606 |
|
21607 |
|
21608 |
|
21609 |
|
21610 |
|
21611 |
|
21612 |
|
21613 |
|
21614 |
|
21615 |
|
21616 |
|
21617 |
|
21618 |
|
21619 |
|
21620 |
|
21621 |
|
21622 |
|
21623 |
|
21624 |
|
21625 |
|
21626 |
|
21627 |
|
21628 |
|
21629 |
|
21630 |
|
21631 |
|
21632 |
|
21633 |
|
21634 |
|
21635 |
|
21636 |
|
21637 | polar_label_show: true,
|
21638 | polar_label_format: void 0,
|
21639 | polar_label_threshold: 0.05,
|
21640 | polar_label_ratio: void 0,
|
21641 | polar_level_depth: 3,
|
21642 | polar_level_max: void 0,
|
21643 | polar_level_show: true,
|
21644 | polar_level_text_backgroundColor: "#fff",
|
21645 | polar_level_text_format: (x) => x % 1 === 0 ? x : x.toFixed(2),
|
21646 | polar_level_text_show: true,
|
21647 | polar_padAngle: 0,
|
21648 | polar_padding: 0,
|
21649 | polar_startingAngle: 0
|
21650 | });
|
21651 |
|
21652 | ;
|
21653 | var shape_radar = ({
|
21654 | |
21655 |
|
21656 |
|
21657 |
|
21658 |
|
21659 |
|
21660 |
|
21661 |
|
21662 |
|
21663 |
|
21664 |
|
21665 |
|
21666 |
|
21667 |
|
21668 |
|
21669 |
|
21670 |
|
21671 |
|
21672 |
|
21673 |
|
21674 |
|
21675 |
|
21676 |
|
21677 |
|
21678 |
|
21679 |
|
21680 |
|
21681 |
|
21682 |
|
21683 |
|
21684 |
|
21685 |
|
21686 |
|
21687 |
|
21688 |
|
21689 |
|
21690 |
|
21691 |
|
21692 |
|
21693 |
|
21694 |
|
21695 |
|
21696 |
|
21697 |
|
21698 |
|
21699 |
|
21700 |
|
21701 |
|
21702 |
|
21703 |
|
21704 |
|
21705 |
|
21706 |
|
21707 |
|
21708 |
|
21709 |
|
21710 | radar_axis_max: void 0,
|
21711 | radar_axis_line_show: true,
|
21712 | radar_axis_text_show: true,
|
21713 | radar_axis_text_position: {},
|
21714 | radar_level_depth: 3,
|
21715 | radar_level_show: true,
|
21716 | radar_level_text_format: (x) => x % 1 === 0 ? x : x.toFixed(2),
|
21717 | radar_level_text_show: true,
|
21718 | radar_size_ratio: 0.87,
|
21719 | radar_direction_clockwise: false
|
21720 | });
|
21721 |
|
21722 | ;
|
21723 | var shape_treemap = ({
|
21724 | |
21725 |
|
21726 |
|
21727 |
|
21728 |
|
21729 |
|
21730 |
|
21731 |
|
21732 |
|
21733 |
|
21734 |
|
21735 |
|
21736 |
|
21737 |
|
21738 |
|
21739 |
|
21740 |
|
21741 |
|
21742 |
|
21743 |
|
21744 |
|
21745 |
|
21746 |
|
21747 |
|
21748 |
|
21749 |
|
21750 |
|
21751 |
|
21752 |
|
21753 |
|
21754 |
|
21755 |
|
21756 |
|
21757 |
|
21758 |
|
21759 |
|
21760 |
|
21761 |
|
21762 |
|
21763 |
|
21764 | treemap_tile: "binary",
|
21765 | treemap_label_format: void 0,
|
21766 | treemap_label_threshold: 0.05,
|
21767 | treemap_label_show: true
|
21768 | });
|
21769 |
|
21770 | ;
|
21771 |
|
21772 |
|
21773 |
|
21774 |
|
21775 |
|
21776 |
|
21777 |
|
21778 |
|
21779 |
|
21780 |
|
21781 |
|
21782 |
|
21783 |
|
21784 |
|
21785 |
|
21786 |
|
21787 |
|
21788 |
|
21789 |
|
21790 |
|
21791 |
|
21792 |
|
21793 |
|
21794 |
|
21795 |
|
21796 |
|
21797 |
|
21798 |
|
21799 |
|
21800 |
|
21801 |
|
21802 |
|
21803 |
|
21804 |
|
21805 |
|
21806 |
|
21807 | function extendAxis(module, option) {
|
21808 | extend(ChartInternal.prototype, Object.values(internal).concat(module));
|
21809 | extend(Chart.prototype, api);
|
21810 | Options.setOptions(Object.values(options).concat(option || []));
|
21811 | }
|
21812 | function extendLine(module, option) {
|
21813 | extendAxis([point_common, point, line].concat(module || []));
|
21814 | Options.setOptions([common_point, shape_line].concat(option || []));
|
21815 | }
|
21816 | function extendArc(module, option) {
|
21817 | extend(ChartInternal.prototype, [arc, point_common].concat(module || []));
|
21818 | Options.setOptions([common_point].concat(option || []));
|
21819 | }
|
21820 | let resolver_shape_area = () => (extendLine(shape_area, [Options_shape_area]), (resolver_shape_area = () => TYPE.AREA)());
|
21821 | let areaLineRange = () => (extendLine(shape_area, [Options_shape_area]), (areaLineRange = () => TYPE.AREA_LINE_RANGE)());
|
21822 | let areaStepRange = () => (extendLine(shape_area, [Options_shape_area]), (areaStepRange = () => TYPE.AREA_STEP_RANGE)());
|
21823 | let areaSpline = () => (extendLine(shape_area, [Options_shape_area, spline]), (areaSpline = () => TYPE.AREA_SPLINE)());
|
21824 | let areaSplineRange = () => (extendLine(shape_area, [Options_shape_area, spline]), (areaSplineRange = () => TYPE.AREA_SPLINE_RANGE)());
|
21825 | let areaStep = () => (extendLine(shape_area, [Options_shape_area]), (areaStep = () => TYPE.AREA_STEP)());
|
21826 | let resolver_shape_line = () => (extendLine(), (resolver_shape_line = () => TYPE.LINE)());
|
21827 | let shape_spline = () => (extendLine(void 0, [spline]), (shape_spline = () => TYPE.SPLINE)());
|
21828 | let step = () => (extendLine(), (step = () => TYPE.STEP)());
|
21829 | let shape_donut = () => (extendArc(void 0, [shape_arc, donut]), (shape_donut = () => TYPE.DONUT)());
|
21830 | let resolver_shape_gauge = () => (extendArc([gauge], [shape_arc, shape_gauge]), (resolver_shape_gauge = () => TYPE.GAUGE)());
|
21831 | let shape_pie = () => (extendArc(void 0, [shape_arc, pie]), (shape_pie = () => TYPE.PIE)());
|
21832 | let resolver_shape_polar = () => (extendArc([polar], [shape_arc, shape_polar]), (resolver_shape_polar = () => TYPE.POLAR)());
|
21833 | let resolver_shape_radar = () => (extendArc(
|
21834 | [internal.eventrect, point, radar],
|
21835 | [common_point, shape_radar, { axis_x_categories: options.optAxis.axis_x_categories }]
|
21836 | ), (resolver_shape_radar = () => TYPE.RADAR)());
|
21837 | let resolver_shape_bar = () => (extendAxis([bar, point_common], [shape_bar, common_point]), (resolver_shape_bar = () => TYPE.BAR)());
|
21838 | let resolver_shape_bubble = () => (extendAxis(
|
21839 | [point_common, point, bubble],
|
21840 | [shape_bubble, common_point]
|
21841 | ), (resolver_shape_bubble = () => TYPE.BUBBLE)());
|
21842 | let resolver_shape_candlestick = () => (extendAxis(
|
21843 | [candlestick, point_common],
|
21844 | [shape_candlestick, common_point]
|
21845 | ), (resolver_shape_candlestick = () => TYPE.CANDLESTICK)());
|
21846 | let shape_scatter = () => (extendAxis(
|
21847 | [point_common, point],
|
21848 | [common_point, scatter]
|
21849 | ), (shape_scatter = () => TYPE.SCATTER)());
|
21850 | let resolver_shape_funnel = () => (extendArc([funnel], [shape_funnel]), (resolver_shape_funnel = () => TYPE.FUNNEL)());
|
21851 | let resolver_shape_treemap = () => (extendAxis([treemap], [shape_treemap]), (resolver_shape_treemap = () => TYPE.TREEMAP)());
|
21852 |
|
21853 | ;
|
21854 |
|
21855 |
|
21856 | let defaults = {};
|
21857 | const bb = {
|
21858 | |
21859 |
|
21860 |
|
21861 |
|
21862 |
|
21863 |
|
21864 |
|
21865 | version: "3.14.2",
|
21866 | |
21867 |
|
21868 |
|
21869 |
|
21870 |
|
21871 |
|
21872 |
|
21873 |
|
21874 |
|
21875 |
|
21876 |
|
21877 |
|
21878 |
|
21879 |
|
21880 |
|
21881 |
|
21882 |
|
21883 |
|
21884 |
|
21885 |
|
21886 |
|
21887 |
|
21888 |
|
21889 |
|
21890 |
|
21891 |
|
21892 |
|
21893 |
|
21894 |
|
21895 |
|
21896 |
|
21897 |
|
21898 |
|
21899 |
|
21900 |
|
21901 |
|
21902 |
|
21903 |
|
21904 |
|
21905 |
|
21906 |
|
21907 |
|
21908 |
|
21909 |
|
21910 |
|
21911 |
|
21912 |
|
21913 |
|
21914 |
|
21915 |
|
21916 |
|
21917 |
|
21918 |
|
21919 |
|
21920 |
|
21921 |
|
21922 |
|
21923 |
|
21924 |
|
21925 |
|
21926 |
|
21927 |
|
21928 |
|
21929 |
|
21930 |
|
21931 |
|
21932 |
|
21933 |
|
21934 |
|
21935 |
|
21936 | generate(config) {
|
21937 | const options = mergeObj({}, defaults, config);
|
21938 | const inst = new Chart(options);
|
21939 | inst.internal.charts = this.instance;
|
21940 | this.instance.push(inst);
|
21941 | return inst;
|
21942 | },
|
21943 | |
21944 |
|
21945 |
|
21946 |
|
21947 |
|
21948 |
|
21949 |
|
21950 |
|
21951 |
|
21952 |
|
21953 |
|
21954 |
|
21955 |
|
21956 |
|
21957 |
|
21958 |
|
21959 |
|
21960 |
|
21961 |
|
21962 |
|
21963 |
|
21964 |
|
21965 | defaults(options) {
|
21966 | if (isObject(options)) {
|
21967 | defaults = options;
|
21968 | }
|
21969 | return defaults;
|
21970 | },
|
21971 | |
21972 |
|
21973 |
|
21974 |
|
21975 |
|
21976 |
|
21977 |
|
21978 |
|
21979 |
|
21980 |
|
21981 |
|
21982 | instance: [],
|
21983 | |
21984 |
|
21985 |
|
21986 |
|
21987 |
|
21988 |
|
21989 |
|
21990 |
|
21991 | plugin: {}
|
21992 | };
|
21993 |
|
21994 |
|
21995 | ;
|
21996 |
|
21997 |
|
21998 | Object.keys(resolver_shape_namespaceObject).forEach((v) => resolver_shape_namespaceObject[v]());
|
21999 | Object.keys(resolver_interaction_namespaceObject).forEach((v) => resolver_interaction_namespaceObject[v]());
|
22000 |
|
22001 |
|
22002 | }();
|
22003 | return __webpack_exports__;
|
22004 | })()
|
22005 | ;
|
22006 | }); |
\ | No newline at end of file |