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-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-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-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"]);
|
17 | for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
18 | }
|
19 | })(this, function(__WEBPACK_EXTERNAL_MODULE__10__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__5__, __WEBPACK_EXTERNAL_MODULE__11__, __WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__2__, __WEBPACK_EXTERNAL_MODULE__9__, __WEBPACK_EXTERNAL_MODULE__4__, __WEBPACK_EXTERNAL_MODULE__8__, __WEBPACK_EXTERNAL_MODULE__13__) {
|
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 |
|
99 |
|
100 | var __webpack_module_cache__ = {};
|
101 |
|
102 |
|
103 | function __webpack_require__(moduleId) {
|
104 |
|
105 | var cachedModule = __webpack_module_cache__[moduleId];
|
106 | if (cachedModule !== undefined) {
|
107 | return cachedModule.exports;
|
108 | }
|
109 |
|
110 | var module = __webpack_module_cache__[moduleId] = {
|
111 |
|
112 |
|
113 | exports: {}
|
114 | };
|
115 |
|
116 |
|
117 | __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
118 |
|
119 |
|
120 | return module.exports;
|
121 | }
|
122 |
|
123 |
|
124 |
|
125 | !function() {
|
126 |
|
127 | __webpack_require__.d = function(exports, definition) {
|
128 | for(var key in definition) {
|
129 | if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
130 | Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
131 | }
|
132 | }
|
133 | };
|
134 | }();
|
135 |
|
136 |
|
137 | !function() {
|
138 | __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
139 | }();
|
140 |
|
141 |
|
142 | !function() {
|
143 |
|
144 | __webpack_require__.r = function(exports) {
|
145 | if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
146 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
147 | }
|
148 | Object.defineProperty(exports, '__esModule', { value: true });
|
149 | };
|
150 | }();
|
151 |
|
152 |
|
153 | var __webpack_exports__ = {};
|
154 |
|
155 | !function() {
|
156 |
|
157 |
|
158 | }();
|
159 |
|
160 | !function() {
|
161 |
|
162 | __webpack_require__.r(__webpack_exports__);
|
163 |
|
164 |
|
165 | __webpack_require__.d(__webpack_exports__, {
|
166 | "bb": function() { return bb; },
|
167 | "default": function() { return bb; }
|
168 | });
|
169 |
|
170 |
|
171 | var resolver_shape_namespaceObject = {};
|
172 | __webpack_require__.r(resolver_shape_namespaceObject);
|
173 | __webpack_require__.d(resolver_shape_namespaceObject, {
|
174 | "area": function() { return _area; },
|
175 | "areaLineRange": function() { return areaLineRange; },
|
176 | "areaSpline": function() { return areaSpline; },
|
177 | "areaSplineRange": function() { return areaSplineRange; },
|
178 | "areaStep": function() { return areaStep; },
|
179 | "bar": function() { return resolver_shape_bar; },
|
180 | "bubble": function() { return resolver_shape_bubble; },
|
181 | "candlestick": function() { return resolver_shape_candlestick; },
|
182 | "donut": function() { return shape_donut; },
|
183 | "gauge": function() { return resolver_shape_gauge; },
|
184 | "line": function() { return resolver_shape_line; },
|
185 | "pie": function() { return shape_pie; },
|
186 | "radar": function() { return resolver_shape_radar; },
|
187 | "scatter": function() { return shape_scatter; },
|
188 | "spline": function() { return shape_spline; },
|
189 | "step": function() { return step; }
|
190 | });
|
191 |
|
192 |
|
193 | var resolver_interaction_namespaceObject = {};
|
194 | __webpack_require__.r(resolver_interaction_namespaceObject);
|
195 | __webpack_require__.d(resolver_interaction_namespaceObject, {
|
196 | "selection": function() { return _selectionModule; },
|
197 | "subchart": function() { return subchartModule; },
|
198 | "zoom": function() { return zoomModule; }
|
199 | });
|
200 |
|
201 |
|
202 | var external_commonjs_d3_time_format_commonjs2_d3_time_format_amd_d3_time_format_root_d3_ = __webpack_require__(4);
|
203 |
|
204 | var external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_ = __webpack_require__(2);
|
205 | ;
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 | var win = function () {
|
220 | var root = typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis || typeof global === "object" && global !== null && global.Object === Object && global || typeof self === "object" && self !== null && self.Object === Object && self;
|
221 | return root || Function("return this")();
|
222 | }();
|
223 |
|
224 |
|
225 |
|
226 |
|
227 | win.requestIdleCallback = win.requestIdleCallback || function (cb) {
|
228 | return setTimeout(cb, 1);
|
229 | };
|
230 |
|
231 | win.cancelIdleCallback = win.cancelIdleCallback || function (id) {
|
232 | return clearTimeout(id);
|
233 | };
|
234 |
|
235 | var browser_doc = win == null ? void 0 : win.document;
|
236 | ;
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 | var TYPE = {
|
247 | AREA: "area",
|
248 | AREA_LINE_RANGE: "area-line-range",
|
249 | AREA_SPLINE: "area-spline",
|
250 | AREA_SPLINE_RANGE: "area-spline-range",
|
251 | AREA_STEP: "area-step",
|
252 | BAR: "bar",
|
253 | BUBBLE: "bubble",
|
254 | CANDLESTICK: "candlestick",
|
255 | DONUT: "donut",
|
256 | GAUGE: "gauge",
|
257 | LINE: "line",
|
258 | PIE: "pie",
|
259 | RADAR: "radar",
|
260 | SCATTER: "scatter",
|
261 | SPLINE: "spline",
|
262 | STEP: "step"
|
263 | };
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 | var TYPE_METHOD_NEEDED = {
|
270 | AREA: "initArea",
|
271 | AREA_LINE_RANGE: "initArea",
|
272 | AREA_SPLINE: "initArea",
|
273 | AREA_SPLINE_RANGE: "initArea",
|
274 | AREA_STEP: "initArea",
|
275 | BAR: "initBar",
|
276 | BUBBLE: "initCircle",
|
277 | CANDLESTICK: "initCandlestick",
|
278 | DONUT: "initArc",
|
279 | GAUGE: "initArc",
|
280 | LINE: "initLine",
|
281 | PIE: "initArc",
|
282 | RADAR: "initCircle",
|
283 | SCATTER: "initCircle",
|
284 | SPLINE: "initLine",
|
285 | STEP: "initLine"
|
286 | };
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 | var TYPE_BY_CATEGORY = {
|
293 | Area: [TYPE.AREA, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE, TYPE.AREA_STEP],
|
294 | AreaRange: [TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE],
|
295 | Arc: [TYPE.PIE, TYPE.DONUT, TYPE.GAUGE, TYPE.RADAR],
|
296 | Line: [TYPE.LINE, TYPE.SPLINE, TYPE.AREA, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE, TYPE.AREA_LINE_RANGE, TYPE.STEP, TYPE.AREA_STEP],
|
297 | Step: [TYPE.STEP, TYPE.AREA_STEP],
|
298 | Spline: [TYPE.SPLINE, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE]
|
299 | };
|
300 | ;
|
301 | function _defineProperty(obj, key, value) {
|
302 | if (key in obj) {
|
303 | Object.defineProperty(obj, key, {
|
304 | value: value,
|
305 | enumerable: true,
|
306 | configurable: true,
|
307 | writable: true
|
308 | });
|
309 | } else {
|
310 | obj[key] = value;
|
311 | }
|
312 |
|
313 | return obj;
|
314 | }
|
315 |
|
316 | var external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_ = __webpack_require__(3);
|
317 | ;
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 | var config_classes = ({
|
328 | arc: "bb-arc",
|
329 | arcLabelLine: "bb-arc-label-line",
|
330 | arcs: "bb-arcs",
|
331 | area: "bb-area",
|
332 | areas: "bb-areas",
|
333 | axis: "bb-axis",
|
334 | axisX: "bb-axis-x",
|
335 | axisXLabel: "bb-axis-x-label",
|
336 | axisY: "bb-axis-y",
|
337 | axisY2: "bb-axis-y2",
|
338 | axisY2Label: "bb-axis-y2-label",
|
339 | axisYLabel: "bb-axis-y-label",
|
340 | bar: "bb-bar",
|
341 | bars: "bb-bars",
|
342 | brush: "bb-brush",
|
343 | button: "bb-button",
|
344 | buttonZoomReset: "bb-zoom-reset",
|
345 | candlestick: "bb-candlestick",
|
346 | candlesticks: "bb-candlesticks",
|
347 | chart: "bb-chart",
|
348 | chartArc: "bb-chart-arc",
|
349 | chartArcs: "bb-chart-arcs",
|
350 | chartArcsBackground: "bb-chart-arcs-background",
|
351 | chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
|
352 | chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
|
353 | chartArcsGaugeUnit: "bb-chart-arcs-gauge-unit",
|
354 | chartArcsTitle: "bb-chart-arcs-title",
|
355 | chartArcsGaugeTitle: "bb-chart-arcs-gauge-title",
|
356 | chartBar: "bb-chart-bar",
|
357 | chartBars: "bb-chart-bars",
|
358 | chartCandlestick: "bb-chart-candlestick",
|
359 | chartCandlesticks: "bb-chart-candlesticks",
|
360 | chartCircles: "bb-chart-circles",
|
361 | chartLine: "bb-chart-line",
|
362 | chartLines: "bb-chart-lines",
|
363 | chartRadar: "bb-chart-radar",
|
364 | chartRadars: "bb-chart-radars",
|
365 | chartText: "bb-chart-text",
|
366 | chartTexts: "bb-chart-texts",
|
367 | circle: "bb-circle",
|
368 | circles: "bb-circles",
|
369 | colorPattern: "bb-color-pattern",
|
370 | colorScale: "bb-colorscale",
|
371 | defocused: "bb-defocused",
|
372 | dragarea: "bb-dragarea",
|
373 | empty: "bb-empty",
|
374 | eventRect: "bb-event-rect",
|
375 | eventRects: "bb-event-rects",
|
376 | eventRectsMultiple: "bb-event-rects-multiple",
|
377 | eventRectsSingle: "bb-event-rects-single",
|
378 | focused: "bb-focused",
|
379 | gaugeValue: "bb-gauge-value",
|
380 | grid: "bb-grid",
|
381 | gridLines: "bb-grid-lines",
|
382 | legend: "bb-legend",
|
383 | legendBackground: "bb-legend-background",
|
384 | legendItem: "bb-legend-item",
|
385 | legendItemEvent: "bb-legend-item-event",
|
386 | legendItemFocused: "bb-legend-item-focused",
|
387 | legendItemHidden: "bb-legend-item-hidden",
|
388 | legendItemPoint: "bb-legend-item-point",
|
389 | legendItemTile: "bb-legend-item-tile",
|
390 | level: "bb-level",
|
391 | levels: "bb-levels",
|
392 | line: "bb-line",
|
393 | lines: "bb-lines",
|
394 | main: "bb-main",
|
395 | region: "bb-region",
|
396 | regions: "bb-regions",
|
397 | selectedCircle: "bb-selected-circle",
|
398 | selectedCircles: "bb-selected-circles",
|
399 | shape: "bb-shape",
|
400 | shapes: "bb-shapes",
|
401 | stanfordElements: "bb-stanford-elements",
|
402 | stanfordLine: "bb-stanford-line",
|
403 | stanfordLines: "bb-stanford-lines",
|
404 | stanfordRegion: "bb-stanford-region",
|
405 | stanfordRegions: "bb-stanford-regions",
|
406 | subchart: "bb-subchart",
|
407 | target: "bb-target",
|
408 | text: "bb-text",
|
409 | texts: "bb-texts",
|
410 | title: "bb-title",
|
411 | tooltip: "bb-tooltip",
|
412 | tooltipContainer: "bb-tooltip-container",
|
413 | tooltipName: "bb-tooltip-name",
|
414 | valueDown: "bb-value-down",
|
415 | valueUp: "bb-value-up",
|
416 | xgrid: "bb-xgrid",
|
417 | xgridFocus: "bb-xgrid-focus",
|
418 | xgridLine: "bb-xgrid-line",
|
419 | xgridLines: "bb-xgrid-lines",
|
420 | xgrids: "bb-xgrids",
|
421 | ygrid: "bb-ygrid",
|
422 | ygridFocus: "bb-ygrid-focus",
|
423 | ygridLine: "bb-ygrid-line",
|
424 | ygridLines: "bb-ygrid-lines",
|
425 | ygrids: "bb-ygrids",
|
426 | zoomBrush: "bb-zoom-brush",
|
427 | EXPANDED: "_expanded_",
|
428 | SELECTED: "_selected_",
|
429 | INCLUDED: "_included_",
|
430 | TextOverlapping: "text-overlapping"
|
431 | });
|
432 | ;
|
433 |
|
434 |
|
435 | function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
436 |
|
437 | function _objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 | var isValue = function (v) {
|
451 | return v || v === 0;
|
452 | },
|
453 | isFunction = function (v) {
|
454 | return typeof v === "function";
|
455 | },
|
456 | isString = function (v) {
|
457 | return typeof v === "string";
|
458 | },
|
459 | isNumber = function (v) {
|
460 | return typeof v === "number";
|
461 | },
|
462 | isUndefined = function (v) {
|
463 | return typeof v === "undefined";
|
464 | },
|
465 | isDefined = function (v) {
|
466 | return typeof v !== "undefined";
|
467 | },
|
468 | isboolean = function (v) {
|
469 | return typeof v === "boolean";
|
470 | },
|
471 | ceil10 = function (v) {
|
472 | return Math.ceil(v / 10) * 10;
|
473 | },
|
474 | asHalfPixel = function (n) {
|
475 | return Math.ceil(n) + .5;
|
476 | },
|
477 | diffDomain = function (d) {
|
478 | return d[1] - d[0];
|
479 | },
|
480 | isObjectType = function (v) {
|
481 | return typeof v === "object";
|
482 | },
|
483 | isEmpty = function (o) {
|
484 | return isUndefined(o) || o === null || isString(o) && o.length === 0 || isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0 || isNumber(o) && isNaN(o);
|
485 | },
|
486 | notEmpty = function (o) {
|
487 | return !isEmpty(o);
|
488 | },
|
489 | isArray = function (arr) {
|
490 | return Array.isArray(arr);
|
491 | },
|
492 | isObject = function (obj) {
|
493 | return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
|
494 | };
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 | function getOption(options, key, defaultValue) {
|
506 | return isDefined(options[key]) ? options[key] : defaultValue;
|
507 | }
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 | function hasValue(dict, value) {
|
518 | var found = !1;
|
519 | Object.keys(dict).forEach(function (key) {
|
520 | return dict[key] === value && (found = !0);
|
521 | });
|
522 | return found;
|
523 | }
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 | function callFn(fn) {
|
534 | for (var isFn = isFunction(fn), _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
535 | args[_key - 1] = arguments[_key];
|
536 | }
|
537 |
|
538 | isFn && fn.call.apply(fn, args);
|
539 | return isFn;
|
540 | }
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 | function endall(transition, cb) {
|
550 | var n = 0,
|
551 | end = function () {
|
552 | for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
553 | args[_key2] = arguments[_key2];
|
554 | }
|
555 |
|
556 | --n || cb.apply.apply(cb, [this].concat(args));
|
557 | };
|
558 |
|
559 |
|
560 | if ("duration" in transition) {
|
561 | transition.each(function () {
|
562 | return ++n;
|
563 | }).on("end", end);
|
564 | } else {
|
565 | ++n;
|
566 | transition.call(end);
|
567 | }
|
568 | }
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 | function sanitise(str) {
|
578 | return isString(str) ? str.replace(/</g, "<").replace(/>/g, ">") : str;
|
579 | }
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 | function setTextValue(node, text, dy, toMiddle) {
|
591 | if (dy === void 0) {
|
592 | dy = [-1, 1];
|
593 | }
|
594 |
|
595 | if (toMiddle === void 0) {
|
596 | toMiddle = !1;
|
597 | }
|
598 |
|
599 | if (!node || !isString(text)) {
|
600 | return;
|
601 | }
|
602 |
|
603 | if (text.indexOf("\n") === -1) {
|
604 | node.text(text);
|
605 | } else {
|
606 | var diff = [node.text(), text].map(function (v) {
|
607 | return v.replace(/[\s\n]/g, "");
|
608 | });
|
609 |
|
610 | if (diff[0] !== diff[1]) {
|
611 | var multiline = text.split("\n"),
|
612 | len = toMiddle ? multiline.length - 1 : 1;
|
613 |
|
614 | node.html("");
|
615 | multiline.forEach(function (v, i) {
|
616 | node.append("tspan").attr("x", 0).attr("dy", (i === 0 ? dy[0] * len : dy[1]) + "em").text(v);
|
617 | });
|
618 | }
|
619 | }
|
620 | }
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 | function getRectSegList(path) {
|
630 | |
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 | var _path$getBBox = path.getBBox(),
|
638 | x = _path$getBBox.x,
|
639 | y = _path$getBBox.y,
|
640 | width = _path$getBBox.width,
|
641 | height = _path$getBBox.height;
|
642 |
|
643 | return [{
|
644 | x: x,
|
645 | y: y + height
|
646 | },
|
647 | {
|
648 | x: x,
|
649 | y: y
|
650 | },
|
651 | {
|
652 | x: x + width,
|
653 | y: y
|
654 | },
|
655 | {
|
656 | x: x + width,
|
657 | y: y + height
|
658 | }
|
659 | ];
|
660 | }
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 |
|
669 | function getPathBox(path) {
|
670 | var _path$getBoundingClie = path.getBoundingClientRect(),
|
671 | width = _path$getBoundingClie.width,
|
672 | height = _path$getBoundingClie.height,
|
673 | items = getRectSegList(path),
|
674 | x = items[0].x,
|
675 | y = Math.min(items[0].y, items[1].y);
|
676 |
|
677 | return {
|
678 | x: x,
|
679 | y: y,
|
680 | width: width,
|
681 | height: height
|
682 | };
|
683 | }
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 | function getPointer(event, element) {
|
694 | var _ref,
|
695 | touches = event && ((_ref = event.touches || event.sourceEvent && event.sourceEvent.touches) == null ? void 0 : _ref[0]),
|
696 | pointer = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.pointer)(touches || event, element);
|
697 |
|
698 | return pointer.map(function (v) {
|
699 | return isNaN(v) ? 0 : v;
|
700 | });
|
701 | }
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 | function getBrushSelection(ctx) {
|
711 | var event = ctx.event,
|
712 | $el = ctx.$el,
|
713 | main = $el.subchart.main || $el.main,
|
714 | selection;
|
715 |
|
716 |
|
717 | if (event && event.type === "brush") {
|
718 | selection = event.selection;
|
719 | } else if (main && (selection = main.select("." + config_classes.brush).node())) {
|
720 | selection = (0,external_commonjs_d3_brush_commonjs2_d3_brush_amd_d3_brush_root_d3_.brushSelection)(selection);
|
721 | }
|
722 |
|
723 | return selection;
|
724 | }
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 | function getBoundingRect(node) {
|
735 | var needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +node.getAttribute("width");
|
736 | return needEvaluate ? node.rect = node.getBoundingClientRect() : node.rect;
|
737 | }
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 | function getRandom(asStr) {
|
747 | if (asStr === void 0) {
|
748 | asStr = !0;
|
749 | }
|
750 |
|
751 | var rand = Math.random();
|
752 | return asStr ? rand + "" : rand;
|
753 | }
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 | function findIndex(arr, v, start, end, isRotated) {
|
767 | if (start > end) {
|
768 | return -1;
|
769 | }
|
770 |
|
771 | var mid = Math.floor((start + end) / 2),
|
772 | _arr$mid = arr[mid],
|
773 | x = _arr$mid.x,
|
774 | _arr$mid$w = _arr$mid.w,
|
775 | w = _arr$mid$w === void 0 ? 0 : _arr$mid$w;
|
776 |
|
777 | if (isRotated) {
|
778 | x = arr[mid].y;
|
779 | w = arr[mid].h;
|
780 | }
|
781 |
|
782 | if (v >= x && v <= x + w) {
|
783 | return mid;
|
784 | }
|
785 |
|
786 | return v < x ? findIndex(arr, v, start, mid - 1, isRotated) : findIndex(arr, v, mid + 1, end, isRotated);
|
787 | }
|
788 |
|
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 |
|
795 |
|
796 | function brushEmpty(ctx) {
|
797 | var selection = getBrushSelection(ctx);
|
798 |
|
799 | if (selection) {
|
800 |
|
801 |
|
802 |
|
803 | return selection[0] === selection[1];
|
804 | }
|
805 |
|
806 | return !0;
|
807 | }
|
808 |
|
809 |
|
810 |
|
811 |
|
812 |
|
813 |
|
814 |
|
815 |
|
816 | function deepClone() {
|
817 | for (var clone = function (v) {
|
818 | if (isObject(v) && v.constructor) {
|
819 | var r = new v.constructor();
|
820 |
|
821 | for (var k in v) {
|
822 | r[k] = clone(v[k]);
|
823 | }
|
824 |
|
825 | return r;
|
826 | }
|
827 |
|
828 | return v;
|
829 | }, _len3 = arguments.length, objectN = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
830 | objectN[_key3] = arguments[_key3];
|
831 | }
|
832 |
|
833 | return objectN.map(function (v) {
|
834 | return clone(v);
|
835 | }).reduce(function (a, c) {
|
836 | return _objectSpread(_objectSpread({}, a), c);
|
837 | });
|
838 | }
|
839 |
|
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 | function extend(target, source) {
|
849 | if (target === void 0) {
|
850 | target = {};
|
851 | }
|
852 |
|
853 | if (isArray(source)) {
|
854 | source.forEach(function (v) {
|
855 | return extend(target, v);
|
856 | });
|
857 | }
|
858 |
|
859 |
|
860 | for (var p in source) {
|
861 | if (/^\d+$/.test(p) || p in target) {
|
862 | continue;
|
863 | }
|
864 |
|
865 | target[p] = source[p];
|
866 | }
|
867 |
|
868 | return target;
|
869 | }
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 | var capitalize = function (str) {
|
879 | return str.charAt(0).toUpperCase() + str.slice(1);
|
880 | };
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 | function camelize(str, separator) {
|
891 | if (separator === void 0) {
|
892 | separator = "-";
|
893 | }
|
894 |
|
895 | return str.split(separator).map(function (v, i) {
|
896 | return i ? v.charAt(0).toUpperCase() + v.slice(1).toLowerCase() : v.toLowerCase();
|
897 | }).join("");
|
898 | }
|
899 |
|
900 |
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 | var toArray = function (v) {
|
908 | return [].slice.call(v);
|
909 | };
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 | function getCssRules(styleSheets) {
|
919 | var rules = [];
|
920 | styleSheets.forEach(function (sheet) {
|
921 | try {
|
922 | if (sheet.cssRules && sheet.cssRules.length) {
|
923 | rules = rules.concat(toArray(sheet.cssRules));
|
924 | }
|
925 | } catch (e) {
|
926 | console.error("Error while reading rules from " + sheet.href + ": " + e.toString());
|
927 | }
|
928 | });
|
929 | return rules;
|
930 | }
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 | function getTranslation(node) {
|
940 | var transform = node ? node.transform : null,
|
941 | baseVal = transform && transform.baseVal;
|
942 | return baseVal && baseVal.numberOfItems ? baseVal.getItem(0).matrix : {
|
943 | a: 0,
|
944 | b: 0,
|
945 | c: 0,
|
946 | d: 0,
|
947 | e: 0,
|
948 | f: 0
|
949 | };
|
950 | }
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 | function getUnique(data) {
|
960 | var isDate = data[0] instanceof Date,
|
961 | d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
|
962 | return self.indexOf(v) === i;
|
963 | });
|
964 | return isDate ? d.map(function (v) {
|
965 | return new Date(v);
|
966 | }) : d;
|
967 | }
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 | function mergeArray(arr) {
|
977 | return arr && arr.length ? arr.reduce(function (p, c) {
|
978 | return p.concat(c);
|
979 | }) : [];
|
980 | }
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 | function mergeObj(target) {
|
991 | for (var _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
992 | objectN[_key4 - 1] = arguments[_key4];
|
993 | }
|
994 |
|
995 | if (!objectN.length || objectN.length === 1 && !objectN[0]) {
|
996 | return target;
|
997 | }
|
998 |
|
999 | var source = objectN.shift();
|
1000 |
|
1001 | if (isObject(target) && isObject(source)) {
|
1002 | Object.keys(source).forEach(function (key) {
|
1003 | var value = source[key];
|
1004 |
|
1005 | if (isObject(value)) {
|
1006 | target[key] || (target[key] = {});
|
1007 | target[key] = mergeObj(target[key], value);
|
1008 | } else {
|
1009 | target[key] = isArray(value) ? value.concat() : value;
|
1010 | }
|
1011 | });
|
1012 | }
|
1013 |
|
1014 | return mergeObj.apply(void 0, [target].concat(objectN));
|
1015 | }
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 | function sortValue(data, isAsc) {
|
1026 | if (isAsc === void 0) {
|
1027 | isAsc = !0;
|
1028 | }
|
1029 |
|
1030 | var fn;
|
1031 |
|
1032 | if (data[0] instanceof Date) {
|
1033 | fn = isAsc ? function (a, b) {
|
1034 | return a - b;
|
1035 | } : function (a, b) {
|
1036 | return b - a;
|
1037 | };
|
1038 | } else {
|
1039 | if (isAsc && !data.every(isNaN)) {
|
1040 | fn = function (a, b) {
|
1041 | return a - b;
|
1042 | };
|
1043 | } else if (!isAsc) {
|
1044 | fn = function (a, b) {
|
1045 | return a > b && -1 || a < b && 1 || a === b && 0;
|
1046 | };
|
1047 | }
|
1048 | }
|
1049 |
|
1050 | return data.concat().sort(fn);
|
1051 | }
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 | function getMinMax(type, data) {
|
1062 | var res = data.filter(function (v) {
|
1063 | return notEmpty(v);
|
1064 | });
|
1065 |
|
1066 | if (res.length) {
|
1067 | if (isNumber(res[0])) {
|
1068 | res = Math[type].apply(Math, res);
|
1069 | } else if (res[0] instanceof Date) {
|
1070 | res = sortValue(res, type === "min")[0];
|
1071 | }
|
1072 | } else {
|
1073 | res = undefined;
|
1074 | }
|
1075 |
|
1076 | return res;
|
1077 | }
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 | var getRange = function (start, end, step) {
|
1089 | if (step === void 0) {
|
1090 | step = 1;
|
1091 | }
|
1092 |
|
1093 | var res = [],
|
1094 | n = Math.max(0, Math.ceil((end - start) / step)) | 0;
|
1095 |
|
1096 | for (var i = start; i < n; i++) {
|
1097 | res.push(start + i * step);
|
1098 | }
|
1099 |
|
1100 | return res;
|
1101 | },
|
1102 | emulateEvent = {
|
1103 | mouse: function () {
|
1104 | var getParams = function () {
|
1105 | return {
|
1106 | bubbles: !1,
|
1107 | cancelable: !1,
|
1108 | screenX: 0,
|
1109 | screenY: 0,
|
1110 | clientX: 0,
|
1111 | clientY: 0
|
1112 | };
|
1113 | };
|
1114 |
|
1115 | try {
|
1116 |
|
1117 | new MouseEvent("t");
|
1118 | return function (el, eventType, params) {
|
1119 | if (params === void 0) {
|
1120 | params = getParams();
|
1121 | }
|
1122 |
|
1123 | el.dispatchEvent(new MouseEvent(eventType, params));
|
1124 | };
|
1125 | } catch (e) {
|
1126 |
|
1127 | return function (el, eventType, params) {
|
1128 | if (params === void 0) {
|
1129 | params = getParams();
|
1130 | }
|
1131 |
|
1132 | var mouseEvent = browser_doc.createEvent("MouseEvent");
|
1133 |
|
1134 | mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, win, 0,
|
1135 | params.screenX, params.screenY, params.clientX, params.clientY, !1, !1, !1, !1, 0, null);
|
1136 | el.dispatchEvent(mouseEvent);
|
1137 | };
|
1138 | }
|
1139 | }(),
|
1140 | touch: function touch(el, eventType, params) {
|
1141 | var touchObj = new Touch(mergeObj({
|
1142 | identifier: Date.now(),
|
1143 | target: el,
|
1144 | radiusX: 2.5,
|
1145 | radiusY: 2.5,
|
1146 | rotationAngle: 10,
|
1147 | force: .5
|
1148 | }, params));
|
1149 | el.dispatchEvent(new TouchEvent(eventType, {
|
1150 | cancelable: !0,
|
1151 | bubbles: !0,
|
1152 | shiftKey: !0,
|
1153 | touches: [touchObj],
|
1154 | targetTouches: [],
|
1155 | changedTouches: [touchObj]
|
1156 | }));
|
1157 | }
|
1158 | };
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 | function tplProcess(tpl, data) {
|
1169 | var res = tpl;
|
1170 |
|
1171 | for (var x in data) {
|
1172 | res = res.replace(new RegExp("{=" + x + "}", "g"), data[x]);
|
1173 | }
|
1174 |
|
1175 | return res;
|
1176 | }
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 | function parseDate(date) {
|
1187 | var parsedDate;
|
1188 |
|
1189 | if (date instanceof Date) {
|
1190 | parsedDate = date;
|
1191 | } else if (isString(date)) {
|
1192 | var config = this.config,
|
1193 | format = this.format;
|
1194 | parsedDate = format.dataTime(config.data_xFormat)(date);
|
1195 | } else if (isNumber(date) && !isNaN(date)) {
|
1196 | parsedDate = new Date(+date);
|
1197 | }
|
1198 |
|
1199 | if (!parsedDate || isNaN(+parsedDate)) {
|
1200 | console && console.error && console.error("Failed to parse x '" + date + "' to Date object");
|
1201 | }
|
1202 |
|
1203 | return parsedDate;
|
1204 | }
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 | function isTabVisible() {
|
1213 | return !browser_doc.hidden;
|
1214 | }
|
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 | function convertInputType(mouse, touch) {
|
1225 | var isMobile = !1;
|
1226 |
|
1227 | if (/Mobi/.test(win.navigator.userAgent) && touch) {
|
1228 |
|
1229 | var hasTouchPoints = win.navigator && "maxTouchPoints" in win.navigator && win.navigator.maxTouchPoints > 0,
|
1230 | hasTouch = "ontouchmove" in win || win.DocumentTouch && browser_doc instanceof win.DocumentTouch;
|
1231 |
|
1232 |
|
1233 | isMobile = hasTouchPoints || hasTouch;
|
1234 | }
|
1235 |
|
1236 | var hasMouse = mouse && !isMobile ? "onmouseover" in win : !1;
|
1237 | return hasMouse && "mouse" || isMobile && "touch" || null;
|
1238 | }
|
1239 | ;
|
1240 |
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 | function checkModuleImport(ctx) {
|
1258 | var $$ = ctx,
|
1259 | config = $$.config,
|
1260 | type = "";
|
1261 |
|
1262 | if (isEmpty(config.data_type || config.data_types) && !$$[TYPE_METHOD_NEEDED.LINE]) {
|
1263 | type = "line";
|
1264 | } else {
|
1265 | for (var x in TYPE_METHOD_NEEDED) {
|
1266 | var t = TYPE[x];
|
1267 |
|
1268 | if ($$.hasType(t) && !$$[TYPE_METHOD_NEEDED[x]]) {
|
1269 | type = t;
|
1270 | break;
|
1271 | }
|
1272 | }
|
1273 | }
|
1274 |
|
1275 | type && logError("Please, make sure if %c" + camelize(type), "module has been imported and specified correctly.");
|
1276 | }
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 | function logError(head, tail) {
|
1286 | var _window$console,
|
1287 | prefix = "[billboard.js]",
|
1288 | hasConsole = (_window$console = win.console) == null ? void 0 : _window$console.error;
|
1289 |
|
1290 | if (hasConsole) {
|
1291 | console.error("\u274C " + prefix + " " + head, "background:red;color:white;display:block;font-size:15px", tail);
|
1292 | console.info("%cℹ️", "font-size:15px", "https://github.com/naver/billboard.js/wiki/CHANGELOG-v2#modularization-by-its-functionality");
|
1293 | }
|
1294 |
|
1295 | throw Error(prefix + " " + head.replace(/\%c([a-z-]+)/i, "'$1' ") + " " + tail);
|
1296 | }
|
1297 | ;
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 | var Element = function () {
|
1310 | return {
|
1311 | chart: null,
|
1312 | main: null,
|
1313 | svg: null,
|
1314 | axis: {
|
1315 |
|
1316 | x: null,
|
1317 | y: null,
|
1318 | y2: null,
|
1319 | subX: null
|
1320 | },
|
1321 | defs: null,
|
1322 | tooltip: null,
|
1323 | legend: null,
|
1324 | title: null,
|
1325 | subchart: {
|
1326 | main: null,
|
1327 |
|
1328 | bar: null,
|
1329 |
|
1330 | line: null,
|
1331 |
|
1332 | area: null
|
1333 |
|
1334 | },
|
1335 | arcs: null,
|
1336 | bar: null,
|
1337 |
|
1338 | candlestick: null,
|
1339 | line: null,
|
1340 |
|
1341 | area: null,
|
1342 |
|
1343 | circle: null,
|
1344 |
|
1345 | radar: null,
|
1346 | text: null,
|
1347 |
|
1348 | grid: {
|
1349 | main: null,
|
1350 |
|
1351 | x: null,
|
1352 |
|
1353 | y: null
|
1354 |
|
1355 | },
|
1356 | gridLines: {
|
1357 | main: null,
|
1358 |
|
1359 | x: null,
|
1360 |
|
1361 | y: null
|
1362 |
|
1363 | },
|
1364 | region: {
|
1365 | main: null,
|
1366 |
|
1367 | list: null
|
1368 |
|
1369 | },
|
1370 | eventRect: null,
|
1371 | zoomResetBtn: null
|
1372 |
|
1373 | };
|
1374 | };
|
1375 |
|
1376 |
|
1377 | ;
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 | var State = function () {
|
1390 | return {
|
1391 |
|
1392 | width: 0,
|
1393 | width2: 0,
|
1394 | height: 0,
|
1395 | height2: 0,
|
1396 | margin: {
|
1397 | top: 0,
|
1398 | bottom: 0,
|
1399 | left: 0,
|
1400 | right: 0
|
1401 | },
|
1402 | margin2: {
|
1403 | top: 0,
|
1404 | bottom: 0,
|
1405 | left: 0,
|
1406 | right: 0
|
1407 | },
|
1408 | margin3: {
|
1409 | top: 0,
|
1410 | bottom: 0,
|
1411 | left: 0,
|
1412 | right: 0
|
1413 | },
|
1414 | arcWidth: 0,
|
1415 | arcHeight: 0,
|
1416 | xAxisHeight: 0,
|
1417 | hasAxis: !1,
|
1418 | hasRadar: !1,
|
1419 | current: {
|
1420 |
|
1421 | width: 0,
|
1422 | height: 0,
|
1423 | dataMax: 0,
|
1424 | maxTickWidths: {
|
1425 | x: {
|
1426 | size: 0,
|
1427 | ticks: [],
|
1428 | clipPath: 0,
|
1429 | domain: ""
|
1430 | },
|
1431 | y: {
|
1432 | size: 0,
|
1433 | domain: ""
|
1434 | },
|
1435 | y2: {
|
1436 | size: 0,
|
1437 | domain: ""
|
1438 | }
|
1439 | },
|
1440 |
|
1441 | types: []
|
1442 | },
|
1443 |
|
1444 | isLegendRight: !1,
|
1445 | isLegendInset: !1,
|
1446 | isLegendTop: !1,
|
1447 | isLegendLeft: !1,
|
1448 | legendStep: 0,
|
1449 | legendItemWidth: 0,
|
1450 | legendItemHeight: 0,
|
1451 | legendHasRendered: !1,
|
1452 | eventReceiver: {
|
1453 | currentIdx: -1,
|
1454 |
|
1455 | rect: {},
|
1456 |
|
1457 | data: [],
|
1458 |
|
1459 | coords: []
|
1460 |
|
1461 | },
|
1462 | axis: {
|
1463 | x: {
|
1464 | padding: {
|
1465 | left: 0,
|
1466 | right: 0
|
1467 | },
|
1468 | tickCount: 0
|
1469 | }
|
1470 | },
|
1471 | rotatedPadding: {
|
1472 | left: 30,
|
1473 | right: 0,
|
1474 | top: 5
|
1475 | },
|
1476 | withoutFadeIn: {},
|
1477 | inputType: "",
|
1478 | datetimeId: "",
|
1479 |
|
1480 | clip: {
|
1481 | id: "",
|
1482 | idXAxis: "",
|
1483 | idYAxis: "",
|
1484 | idXAxisTickTexts: "",
|
1485 | idGrid: "",
|
1486 | idSubchart: "",
|
1487 |
|
1488 | path: "",
|
1489 | pathXAxis: "",
|
1490 | pathYAxis: "",
|
1491 | pathXAxisTickTexts: "",
|
1492 | pathGrid: ""
|
1493 | },
|
1494 |
|
1495 | event: null,
|
1496 |
|
1497 | dragStart: null,
|
1498 | dragging: !1,
|
1499 | flowing: !1,
|
1500 | cancelClick: !1,
|
1501 | mouseover: !1,
|
1502 | rendered: !1,
|
1503 | transiting: !1,
|
1504 | redrawing: !1,
|
1505 |
|
1506 | resizing: !1,
|
1507 |
|
1508 | toggling: !1,
|
1509 |
|
1510 | zooming: !1,
|
1511 | hasNegativeValue: !1,
|
1512 | hasPositiveValue: !0,
|
1513 | orgAreaOpacity: "0.2",
|
1514 |
|
1515 | hiddenTargetIds: [],
|
1516 | hiddenLegendIds: [],
|
1517 | focusedTargetIds: [],
|
1518 | defocusedTargetIds: [],
|
1519 |
|
1520 | radius: 0,
|
1521 | innerRadius: 0,
|
1522 | outerRadius: undefined,
|
1523 | innerRadiusRatio: 0,
|
1524 | gaugeArcWidth: 0,
|
1525 | radiusExpanded: 0,
|
1526 |
|
1527 | xgridAttr: {
|
1528 | x1: null,
|
1529 | x2: null,
|
1530 | y1: null,
|
1531 | y2: null
|
1532 | }
|
1533 | };
|
1534 | };
|
1535 |
|
1536 |
|
1537 | ;
|
1538 |
|
1539 |
|
1540 |
|
1541 |
|
1542 |
|
1543 |
|
1544 |
|
1545 | var classes = {
|
1546 | element: Element,
|
1547 | state: State
|
1548 | };
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 |
|
1555 |
|
1556 | var Store = function () {
|
1557 | function Store() {
|
1558 | var _this = this;
|
1559 |
|
1560 | Object.keys(classes).forEach(function (v) {
|
1561 | _this[v] = new classes[v]();
|
1562 | });
|
1563 | }
|
1564 |
|
1565 | var _proto = Store.prototype;
|
1566 |
|
1567 | _proto.getStore = function getStore(name) {
|
1568 | return this[name];
|
1569 | };
|
1570 |
|
1571 | return Store;
|
1572 | }();
|
1573 |
|
1574 |
|
1575 | ;
|
1576 |
|
1577 |
|
1578 |
|
1579 |
|
1580 |
|
1581 |
|
1582 |
|
1583 |
|
1584 | var main = ({
|
1585 | |
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 |
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 |
|
1603 |
|
1604 |
|
1605 |
|
1606 |
|
1607 |
|
1608 |
|
1609 |
|
1610 |
|
1611 | bindto: "#chart",
|
1612 |
|
1613 | |
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 | background: {},
|
1633 |
|
1634 | |
1635 |
|
1636 |
|
1637 |
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 |
|
1645 |
|
1646 |
|
1647 |
|
1648 | clipPath: !0,
|
1649 |
|
1650 | |
1651 |
|
1652 |
|
1653 |
|
1654 |
|
1655 |
|
1656 |
|
1657 |
|
1658 |
|
1659 |
|
1660 |
|
1661 |
|
1662 | svg_classname: undefined,
|
1663 |
|
1664 | |
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 | size_width: undefined,
|
1681 | size_height: undefined,
|
1682 |
|
1683 | |
1684 |
|
1685 |
|
1686 |
|
1687 |
|
1688 |
|
1689 |
|
1690 |
|
1691 |
|
1692 |
|
1693 |
|
1694 |
|
1695 |
|
1696 |
|
1697 |
|
1698 |
|
1699 |
|
1700 |
|
1701 | padding_left: undefined,
|
1702 | padding_right: undefined,
|
1703 | padding_top: undefined,
|
1704 | padding_bottom: undefined,
|
1705 |
|
1706 | |
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 |
|
1715 |
|
1716 |
|
1717 |
|
1718 | resize_auto: !0,
|
1719 |
|
1720 | |
1721 |
|
1722 |
|
1723 |
|
1724 |
|
1725 |
|
1726 |
|
1727 |
|
1728 |
|
1729 |
|
1730 |
|
1731 |
|
1732 | onover: undefined,
|
1733 |
|
1734 | |
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 | onout: undefined,
|
1747 |
|
1748 | |
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 | onresize: undefined,
|
1761 |
|
1762 | |
1763 |
|
1764 |
|
1765 |
|
1766 |
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 | onresized: undefined,
|
1775 |
|
1776 | |
1777 |
|
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 |
|
1786 |
|
1787 |
|
1788 | onbeforeinit: undefined,
|
1789 |
|
1790 | |
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 |
|
1800 |
|
1801 |
|
1802 | oninit: undefined,
|
1803 |
|
1804 | |
1805 |
|
1806 |
|
1807 |
|
1808 |
|
1809 |
|
1810 |
|
1811 |
|
1812 |
|
1813 |
|
1814 |
|
1815 |
|
1816 | onafterinit: undefined,
|
1817 |
|
1818 | |
1819 |
|
1820 |
|
1821 |
|
1822 |
|
1823 |
|
1824 |
|
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 |
|
1830 | onrendered: undefined,
|
1831 |
|
1832 | |
1833 |
|
1834 |
|
1835 |
|
1836 |
|
1837 |
|
1838 |
|
1839 |
|
1840 |
|
1841 |
|
1842 |
|
1843 |
|
1844 |
|
1845 | transition_duration: 250,
|
1846 |
|
1847 | |
1848 |
|
1849 |
|
1850 |
|
1851 |
|
1852 |
|
1853 |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 |
|
1859 | plugins: [],
|
1860 |
|
1861 | |
1862 |
|
1863 |
|
1864 |
|
1865 |
|
1866 |
|
1867 |
|
1868 |
|
1869 |
|
1870 |
|
1871 |
|
1872 |
|
1873 |
|
1874 |
|
1875 |
|
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 |
|
1884 |
|
1885 |
|
1886 |
|
1887 |
|
1888 |
|
1889 |
|
1890 |
|
1891 |
|
1892 |
|
1893 |
|
1894 |
|
1895 |
|
1896 |
|
1897 |
|
1898 |
|
1899 |
|
1900 |
|
1901 | render: {},
|
1902 |
|
1903 | |
1904 |
|
1905 |
|
1906 |
|
1907 |
|
1908 |
|
1909 |
|
1910 |
|
1911 |
|
1912 |
|
1913 |
|
1914 |
|
1915 |
|
1916 |
|
1917 |
|
1918 |
|
1919 |
|
1920 |
|
1921 |
|
1922 |
|
1923 |
|
1924 |
|
1925 | regions: []
|
1926 | });
|
1927 | ;
|
1928 |
|
1929 |
|
1930 |
|
1931 |
|
1932 |
|
1933 |
|
1934 |
|
1935 |
|
1936 | var data = ({
|
1937 | |
1938 |
|
1939 |
|
1940 |
|
1941 |
|
1942 |
|
1943 |
|
1944 |
|
1945 |
|
1946 |
|
1947 |
|
1948 |
|
1949 | data_x: undefined,
|
1950 |
|
1951 | |
1952 |
|
1953 |
|
1954 |
|
1955 |
|
1956 |
|
1957 |
|
1958 |
|
1959 |
|
1960 |
|
1961 |
|
1962 |
|
1963 |
|
1964 |
|
1965 |
|
1966 |
|
1967 |
|
1968 |
|
1969 |
|
1970 | data_idConverter: function data_idConverter(id) {
|
1971 | return id;
|
1972 | },
|
1973 |
|
1974 | |
1975 |
|
1976 |
|
1977 |
|
1978 |
|
1979 |
|
1980 |
|
1981 |
|
1982 |
|
1983 |
|
1984 |
|
1985 |
|
1986 |
|
1987 |
|
1988 |
|
1989 | data_names: {},
|
1990 |
|
1991 | |
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 |
|
1997 |
|
1998 |
|
1999 |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 | data_classes: {},
|
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 | data_type: undefined,
|
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 |
|
2097 |
|
2098 |
|
2099 |
|
2100 |
|
2101 |
|
2102 |
|
2103 |
|
2104 |
|
2105 |
|
2106 |
|
2107 |
|
2108 |
|
2109 |
|
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 | data_types: {},
|
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 |
|
2166 | data_order: "desc",
|
2167 |
|
2168 | |
2169 |
|
2170 |
|
2171 |
|
2172 |
|
2173 |
|
2174 |
|
2175 |
|
2176 |
|
2177 |
|
2178 |
|
2179 |
|
2180 |
|
2181 |
|
2182 | data_groups: [],
|
2183 |
|
2184 | |
2185 |
|
2186 |
|
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 |
|
2194 |
|
2195 |
|
2196 |
|
2197 | data_color: undefined,
|
2198 |
|
2199 | |
2200 |
|
2201 |
|
2202 |
|
2203 |
|
2204 |
|
2205 |
|
2206 |
|
2207 |
|
2208 |
|
2209 |
|
2210 |
|
2211 |
|
2212 |
|
2213 |
|
2214 |
|
2215 |
|
2216 | data_colors: {},
|
2217 |
|
2218 | |
2219 |
|
2220 |
|
2221 |
|
2222 |
|
2223 |
|
2224 |
|
2225 |
|
2226 |
|
2227 |
|
2228 |
|
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 |
|
2267 |
|
2268 |
|
2269 |
|
2270 |
|
2271 |
|
2272 |
|
2273 |
|
2274 |
|
2275 |
|
2276 |
|
2277 |
|
2278 |
|
2279 |
|
2280 |
|
2281 |
|
2282 |
|
2283 |
|
2284 |
|
2285 |
|
2286 |
|
2287 |
|
2288 |
|
2289 |
|
2290 |
|
2291 |
|
2292 |
|
2293 |
|
2294 |
|
2295 |
|
2296 |
|
2297 |
|
2298 |
|
2299 |
|
2300 |
|
2301 |
|
2302 |
|
2303 |
|
2304 |
|
2305 |
|
2306 |
|
2307 |
|
2308 |
|
2309 |
|
2310 | data_labels: {},
|
2311 | data_labels_backgroundColors: undefined,
|
2312 | data_labels_colors: undefined,
|
2313 | data_labels_position: {},
|
2314 |
|
2315 | |
2316 |
|
2317 |
|
2318 |
|
2319 |
|
2320 |
|
2321 |
|
2322 |
|
2323 |
|
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 |
|
2331 | data_hide: !1,
|
2332 |
|
2333 | |
2334 |
|
2335 |
|
2336 |
|
2337 |
|
2338 |
|
2339 |
|
2340 |
|
2341 |
|
2342 |
|
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 | data_filter: undefined,
|
2352 |
|
2353 | |
2354 |
|
2355 |
|
2356 |
|
2357 |
|
2358 |
|
2359 |
|
2360 |
|
2361 |
|
2362 |
|
2363 |
|
2364 |
|
2365 |
|
2366 |
|
2367 |
|
2368 |
|
2369 |
|
2370 |
|
2371 |
|
2372 | data_onclick: function data_onclick() {},
|
2373 |
|
2374 | |
2375 |
|
2376 |
|
2377 |
|
2378 |
|
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 |
|
2384 |
|
2385 |
|
2386 |
|
2387 |
|
2388 |
|
2389 |
|
2390 |
|
2391 |
|
2392 |
|
2393 | data_onover: function data_onover() {},
|
2394 |
|
2395 | |
2396 |
|
2397 |
|
2398 |
|
2399 |
|
2400 |
|
2401 |
|
2402 |
|
2403 |
|
2404 |
|
2405 |
|
2406 |
|
2407 |
|
2408 |
|
2409 |
|
2410 |
|
2411 |
|
2412 |
|
2413 |
|
2414 | data_onout: function data_onout() {},
|
2415 |
|
2416 | |
2417 |
|
2418 |
|
2419 |
|
2420 |
|
2421 |
|
2422 |
|
2423 |
|
2424 |
|
2425 |
|
2426 |
|
2427 |
|
2428 |
|
2429 |
|
2430 |
|
2431 | data_onshown: undefined,
|
2432 |
|
2433 | |
2434 |
|
2435 |
|
2436 |
|
2437 |
|
2438 |
|
2439 |
|
2440 |
|
2441 |
|
2442 |
|
2443 |
|
2444 |
|
2445 |
|
2446 |
|
2447 |
|
2448 | data_onhidden: undefined,
|
2449 |
|
2450 | |
2451 |
|
2452 |
|
2453 |
|
2454 |
|
2455 |
|
2456 |
|
2457 |
|
2458 |
|
2459 |
|
2460 |
|
2461 |
|
2462 |
|
2463 |
|
2464 | data_onmin: undefined,
|
2465 |
|
2466 | |
2467 |
|
2468 |
|
2469 |
|
2470 |
|
2471 |
|
2472 |
|
2473 |
|
2474 |
|
2475 |
|
2476 |
|
2477 |
|
2478 |
|
2479 |
|
2480 | data_onmax: undefined,
|
2481 |
|
2482 | |
2483 |
|
2484 |
|
2485 |
|
2486 |
|
2487 |
|
2488 |
|
2489 |
|
2490 |
|
2491 |
|
2492 |
|
2493 |
|
2494 | data_url: undefined,
|
2495 |
|
2496 | |
2497 |
|
2498 |
|
2499 |
|
2500 |
|
2501 |
|
2502 |
|
2503 |
|
2504 |
|
2505 |
|
2506 |
|
2507 |
|
2508 |
|
2509 |
|
2510 |
|
2511 |
|
2512 |
|
2513 | data_headers: undefined,
|
2514 |
|
2515 | |
2516 |
|
2517 |
|
2518 |
|
2519 |
|
2520 |
|
2521 |
|
2522 |
|
2523 |
|
2524 |
|
2525 |
|
2526 |
|
2527 |
|
2528 |
|
2529 |
|
2530 |
|
2531 |
|
2532 |
|
2533 |
|
2534 |
|
2535 |
|
2536 |
|
2537 | data_json: undefined,
|
2538 |
|
2539 | |
2540 |
|
2541 |
|
2542 |
|
2543 |
|
2544 |
|
2545 |
|
2546 |
|
2547 |
|
2548 |
|
2549 |
|
2550 |
|
2551 |
|
2552 |
|
2553 |
|
2554 |
|
2555 |
|
2556 |
|
2557 |
|
2558 |
|
2559 |
|
2560 |
|
2561 |
|
2562 |
|
2563 |
|
2564 |
|
2565 |
|
2566 |
|
2567 |
|
2568 |
|
2569 |
|
2570 |
|
2571 |
|
2572 |
|
2573 |
|
2574 |
|
2575 |
|
2576 |
|
2577 |
|
2578 |
|
2579 |
|
2580 |
|
2581 |
|
2582 |
|
2583 |
|
2584 |
|
2585 |
|
2586 |
|
2587 |
|
2588 |
|
2589 |
|
2590 |
|
2591 |
|
2592 |
|
2593 |
|
2594 |
|
2595 |
|
2596 |
|
2597 |
|
2598 |
|
2599 |
|
2600 |
|
2601 |
|
2602 |
|
2603 |
|
2604 |
|
2605 |
|
2606 |
|
2607 |
|
2608 |
|
2609 |
|
2610 |
|
2611 |
|
2612 |
|
2613 |
|
2614 |
|
2615 |
|
2616 |
|
2617 | data_rows: undefined,
|
2618 |
|
2619 | |
2620 |
|
2621 |
|
2622 |
|
2623 |
|
2624 |
|
2625 |
|
2626 |
|
2627 |
|
2628 |
|
2629 |
|
2630 |
|
2631 |
|
2632 |
|
2633 |
|
2634 |
|
2635 |
|
2636 |
|
2637 |
|
2638 |
|
2639 |
|
2640 |
|
2641 |
|
2642 |
|
2643 |
|
2644 |
|
2645 |
|
2646 |
|
2647 |
|
2648 |
|
2649 |
|
2650 |
|
2651 |
|
2652 |
|
2653 |
|
2654 |
|
2655 |
|
2656 |
|
2657 |
|
2658 |
|
2659 |
|
2660 |
|
2661 |
|
2662 |
|
2663 |
|
2664 |
|
2665 |
|
2666 |
|
2667 |
|
2668 |
|
2669 |
|
2670 |
|
2671 |
|
2672 |
|
2673 |
|
2674 |
|
2675 |
|
2676 |
|
2677 | data_columns: undefined,
|
2678 |
|
2679 | |
2680 |
|
2681 |
|
2682 |
|
2683 |
|
2684 |
|
2685 |
|
2686 |
|
2687 |
|
2688 |
|
2689 |
|
2690 |
|
2691 |
|
2692 |
|
2693 |
|
2694 | data_mimeType: "csv",
|
2695 |
|
2696 | |
2697 |
|
2698 |
|
2699 |
|
2700 |
|
2701 |
|
2702 |
|
2703 |
|
2704 |
|
2705 |
|
2706 |
|
2707 |
|
2708 |
|
2709 |
|
2710 |
|
2711 |
|
2712 |
|
2713 |
|
2714 |
|
2715 |
|
2716 |
|
2717 | data_keys: undefined,
|
2718 |
|
2719 | |
2720 |
|
2721 |
|
2722 |
|
2723 |
|
2724 |
|
2725 |
|
2726 |
|
2727 |
|
2728 |
|
2729 |
|
2730 |
|
2731 |
|
2732 |
|
2733 |
|
2734 |
|
2735 | data_empty_label_text: ""
|
2736 | });
|
2737 | ;
|
2738 |
|
2739 |
|
2740 |
|
2741 |
|
2742 |
|
2743 |
|
2744 |
|
2745 |
|
2746 | var color = ({
|
2747 | |
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 |
|
2753 |
|
2754 |
|
2755 |
|
2756 |
|
2757 |
|
2758 |
|
2759 |
|
2760 |
|
2761 |
|
2762 |
|
2763 |
|
2764 |
|
2765 |
|
2766 |
|
2767 |
|
2768 |
|
2769 |
|
2770 |
|
2771 |
|
2772 |
|
2773 |
|
2774 |
|
2775 |
|
2776 |
|
2777 |
|
2778 |
|
2779 |
|
2780 |
|
2781 |
|
2782 |
|
2783 |
|
2784 |
|
2785 |
|
2786 |
|
2787 |
|
2788 |
|
2789 |
|
2790 |
|
2791 |
|
2792 |
|
2793 |
|
2794 |
|
2795 |
|
2796 |
|
2797 |
|
2798 |
|
2799 |
|
2800 |
|
2801 |
|
2802 |
|
2803 |
|
2804 |
|
2805 |
|
2806 |
|
2807 |
|
2808 |
|
2809 |
|
2810 |
|
2811 |
|
2812 |
|
2813 |
|
2814 |
|
2815 |
|
2816 |
|
2817 |
|
2818 |
|
2819 |
|
2820 |
|
2821 | color_pattern: [],
|
2822 | color_tiles: undefined,
|
2823 | color_threshold: {},
|
2824 | color_onover: undefined
|
2825 | });
|
2826 | ;
|
2827 |
|
2828 |
|
2829 |
|
2830 |
|
2831 |
|
2832 |
|
2833 |
|
2834 |
|
2835 | var interaction = ({
|
2836 | |
2837 |
|
2838 |
|
2839 |
|
2840 |
|
2841 |
|
2842 |
|
2843 |
|
2844 |
|
2845 |
|
2846 |
|
2847 |
|
2848 |
|
2849 |
|
2850 |
|
2851 |
|
2852 |
|
2853 |
|
2854 |
|
2855 |
|
2856 |
|
2857 |
|
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 |
|
2867 |
|
2868 | interaction_enabled: !0,
|
2869 | interaction_brighten: !0,
|
2870 | interaction_inputType_mouse: !0,
|
2871 | interaction_inputType_touch: {}
|
2872 | });
|
2873 | ;
|
2874 |
|
2875 |
|
2876 |
|
2877 |
|
2878 |
|
2879 |
|
2880 |
|
2881 |
|
2882 | var legend = ({
|
2883 | |
2884 |
|
2885 |
|
2886 |
|
2887 |
|
2888 |
|
2889 |
|
2890 |
|
2891 |
|
2892 |
|
2893 |
|
2894 |
|
2895 |
|
2896 |
|
2897 |
|
2898 |
|
2899 |
|
2900 |
|
2901 |
|
2902 |
|
2903 |
|
2904 |
|
2905 |
|
2906 |
|
2907 |
|
2908 |
|
2909 |
|
2910 |
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 |
|
2919 |
|
2920 |
|
2921 |
|
2922 |
|
2923 |
|
2924 |
|
2925 |
|
2926 |
|
2927 |
|
2928 |
|
2929 |
|
2930 |
|
2931 |
|
2932 |
|
2933 |
|
2934 |
|
2935 |
|
2936 |
|
2937 |
|
2938 |
|
2939 |
|
2940 |
|
2941 |
|
2942 |
|
2943 |
|
2944 |
|
2945 |
|
2946 |
|
2947 |
|
2948 |
|
2949 |
|
2950 |
|
2951 |
|
2952 |
|
2953 |
|
2954 |
|
2955 |
|
2956 |
|
2957 |
|
2958 |
|
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 |
|
2965 |
|
2966 |
|
2967 |
|
2968 | legend_show: !0,
|
2969 | legend_hide: !1,
|
2970 | legend_contents_bindto: undefined,
|
2971 | legend_contents_template: undefined,
|
2972 | legend_position: "bottom",
|
2973 | legend_inset_anchor: "top-left",
|
2974 | legend_inset_x: 10,
|
2975 | legend_inset_y: 0,
|
2976 | legend_inset_step: undefined,
|
2977 | legend_item_onclick: undefined,
|
2978 | legend_item_onover: undefined,
|
2979 | legend_item_onout: undefined,
|
2980 | legend_equally: !1,
|
2981 | legend_padding: 0,
|
2982 | legend_item_tile_width: 10,
|
2983 | legend_item_tile_height: 10,
|
2984 | legend_usePoint: !1
|
2985 | });
|
2986 | ;
|
2987 |
|
2988 |
|
2989 |
|
2990 |
|
2991 |
|
2992 |
|
2993 |
|
2994 |
|
2995 | var title = ({
|
2996 | |
2997 |
|
2998 |
|
2999 |
|
3000 |
|
3001 |
|
3002 |
|
3003 |
|
3004 |
|
3005 |
|
3006 |
|
3007 |
|
3008 |
|
3009 |
|
3010 |
|
3011 |
|
3012 |
|
3013 |
|
3014 |
|
3015 |
|
3016 |
|
3017 |
|
3018 |
|
3019 |
|
3020 |
|
3021 |
|
3022 |
|
3023 |
|
3024 |
|
3025 | title_text: undefined,
|
3026 | title_padding: {
|
3027 | top: 0,
|
3028 | right: 0,
|
3029 | bottom: 0,
|
3030 | left: 0
|
3031 | },
|
3032 | title_position: "center"
|
3033 | });
|
3034 | ;
|
3035 |
|
3036 |
|
3037 |
|
3038 |
|
3039 |
|
3040 |
|
3041 |
|
3042 |
|
3043 | var tooltip = ({
|
3044 | |
3045 |
|
3046 |
|
3047 |
|
3048 |
|
3049 |
|
3050 |
|
3051 |
|
3052 |
|
3053 |
|
3054 |
|
3055 |
|
3056 |
|
3057 |
|
3058 |
|
3059 |
|
3060 |
|
3061 |
|
3062 |
|
3063 |
|
3064 |
|
3065 |
|
3066 |
|
3067 |
|
3068 |
|
3069 |
|
3070 |
|
3071 |
|
3072 |
|
3073 |
|
3074 |
|
3075 |
|
3076 |
|
3077 |
|
3078 |
|
3079 |
|
3080 |
|
3081 |
|
3082 |
|
3083 |
|
3084 |
|
3085 |
|
3086 |
|
3087 |
|
3088 |
|
3089 |
|
3090 |
|
3091 |
|
3092 |
|
3093 |
|
3094 |
|
3095 |
|
3096 |
|
3097 |
|
3098 |
|
3099 |
|
3100 |
|
3101 |
|
3102 |
|
3103 |
|
3104 |
|
3105 |
|
3106 |
|
3107 |
|
3108 |
|
3109 |
|
3110 |
|
3111 |
|
3112 |
|
3113 |
|
3114 |
|
3115 |
|
3116 |
|
3117 |
|
3118 |
|
3119 |
|
3120 |
|
3121 |
|
3122 |
|
3123 |
|
3124 |
|
3125 |
|
3126 |
|
3127 |
|
3128 |
|
3129 |
|
3130 |
|
3131 |
|
3132 |
|
3133 |
|
3134 |
|
3135 |
|
3136 |
|
3137 |
|
3138 |
|
3139 |
|
3140 |
|
3141 |
|
3142 |
|
3143 |
|
3144 |
|
3145 |
|
3146 |
|
3147 |
|
3148 |
|
3149 |
|
3150 |
|
3151 |
|
3152 |
|
3153 |
|
3154 |
|
3155 |
|
3156 |
|
3157 |
|
3158 |
|
3159 |
|
3160 |
|
3161 |
|
3162 |
|
3163 |
|
3164 |
|
3165 |
|
3166 |
|
3167 |
|
3168 |
|
3169 |
|
3170 |
|
3171 |
|
3172 |
|
3173 |
|
3174 |
|
3175 |
|
3176 |
|
3177 |
|
3178 |
|
3179 |
|
3180 |
|
3181 |
|
3182 |
|
3183 |
|
3184 |
|
3185 |
|
3186 |
|
3187 |
|
3188 |
|
3189 |
|
3190 |
|
3191 |
|
3192 |
|
3193 |
|
3194 |
|
3195 |
|
3196 |
|
3197 |
|
3198 |
|
3199 |
|
3200 |
|
3201 |
|
3202 |
|
3203 |
|
3204 |
|
3205 |
|
3206 |
|
3207 |
|
3208 |
|
3209 |
|
3210 |
|
3211 |
|
3212 |
|
3213 |
|
3214 |
|
3215 |
|
3216 |
|
3217 |
|
3218 |
|
3219 |
|
3220 |
|
3221 |
|
3222 |
|
3223 |
|
3224 |
|
3225 |
|
3226 | tooltip_show: !0,
|
3227 | tooltip_doNotHide: !1,
|
3228 | tooltip_grouped: !0,
|
3229 | tooltip_format_title: undefined,
|
3230 | tooltip_format_name: undefined,
|
3231 | tooltip_format_value: undefined,
|
3232 | tooltip_position: undefined,
|
3233 | tooltip_contents: {},
|
3234 | tooltip_init_show: !1,
|
3235 | tooltip_init_x: 0,
|
3236 | tooltip_init_position: {
|
3237 | top: "0px",
|
3238 | left: "50px"
|
3239 | },
|
3240 | tooltip_linked: !1,
|
3241 | tooltip_linked_name: "",
|
3242 | tooltip_onshow: function tooltip_onshow() {},
|
3243 | tooltip_onhide: function tooltip_onhide() {},
|
3244 | tooltip_onshown: function tooltip_onshown() {},
|
3245 | tooltip_onhidden: function tooltip_onhidden() {},
|
3246 | tooltip_order: null
|
3247 | });
|
3248 | ;
|
3249 |
|
3250 |
|
3251 | function Options_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
3252 |
|
3253 | function Options_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { Options_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { Options_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
3254 |
|
3255 |
|
3256 |
|
3257 |
|
3258 |
|
3259 |
|
3260 |
|
3261 |
|
3262 |
|
3263 |
|
3264 |
|
3265 |
|
3266 |
|
3267 |
|
3268 |
|
3269 |
|
3270 |
|
3271 |
|
3272 |
|
3273 |
|
3274 |
|
3275 | var Options = function () {
|
3276 | Options.setOptions = function setOptions(options) {
|
3277 | this.data = options.reduce(function (a, c) {
|
3278 | return Options_objectSpread(Options_objectSpread({}, a), c);
|
3279 | }, this.data);
|
3280 | };
|
3281 |
|
3282 | function Options() {
|
3283 | return deepClone(main, data, color, interaction, legend, title, tooltip, Options.data);
|
3284 | }
|
3285 |
|
3286 | return Options;
|
3287 | }();
|
3288 |
|
3289 | Options.data = {};
|
3290 |
|
3291 | ;
|
3292 |
|
3293 |
|
3294 |
|
3295 |
|
3296 |
|
3297 |
|
3298 |
|
3299 |
|
3300 |
|
3301 |
|
3302 |
|
3303 | var KEY = {
|
3304 | bubbleBaseLength: "$baseLength",
|
3305 | colorPattern: "__colorPattern__",
|
3306 | dataMinMax: "$dataMinMax",
|
3307 | dataTotalSum: "$dataTotalSum",
|
3308 | dataTotalPerIndex: "$totalPerIndex",
|
3309 | legendItemTextBox: "legendItemTextBox",
|
3310 | radarPoints: "$radarPoints",
|
3311 | setOverOut: "setOverOut",
|
3312 | callOverOutForTouch: "callOverOutForTouch",
|
3313 | textRect: "textRect"
|
3314 | };
|
3315 |
|
3316 | var Cache = function () {
|
3317 | function Cache() {
|
3318 | this.cache = {};
|
3319 | }
|
3320 |
|
3321 | var _proto = Cache.prototype;
|
3322 |
|
3323 | |
3324 |
|
3325 |
|
3326 |
|
3327 |
|
3328 |
|
3329 |
|
3330 |
|
3331 | _proto.add = function add(key, value, isDataType) {
|
3332 | if (isDataType === void 0) {
|
3333 | isDataType = !1;
|
3334 | }
|
3335 |
|
3336 | this.cache[key] = isDataType ? this.cloneTarget(value) : value;
|
3337 | return this.cache[key];
|
3338 | }
|
3339 | |
3340 |
|
3341 |
|
3342 |
|
3343 |
|
3344 | ;
|
3345 |
|
3346 | _proto.remove = function remove(key) {
|
3347 | var _this = this;
|
3348 |
|
3349 | toArray(key).forEach(function (v) {
|
3350 | return delete _this.cache[v];
|
3351 | });
|
3352 | }
|
3353 | |
3354 |
|
3355 |
|
3356 |
|
3357 |
|
3358 |
|
3359 |
|
3360 | ;
|
3361 |
|
3362 | _proto.get = function get(key, isDataType) {
|
3363 | if (isDataType === void 0) {
|
3364 | isDataType = !1;
|
3365 | }
|
3366 |
|
3367 | if (isDataType) {
|
3368 | var targets = [];
|
3369 |
|
3370 | for (var i = 0, id; id = key[i]; i++) {
|
3371 | if (id in this.cache) {
|
3372 | targets.push(this.cloneTarget(this.cache[id]));
|
3373 | }
|
3374 | }
|
3375 |
|
3376 | return targets;
|
3377 | } else {
|
3378 | var value = this.cache[key];
|
3379 | return isValue(value) ? value : null;
|
3380 | }
|
3381 | }
|
3382 | |
3383 |
|
3384 |
|
3385 |
|
3386 |
|
3387 | ;
|
3388 |
|
3389 | _proto.reset = function reset(all) {
|
3390 | var $$ = this;
|
3391 |
|
3392 | for (var x in $$.cache) {
|
3393 |
|
3394 | if (all || /^\$/.test(x)) {
|
3395 | $$.cache[x] = null;
|
3396 | }
|
3397 | }
|
3398 | }
|
3399 | |
3400 |
|
3401 |
|
3402 |
|
3403 |
|
3404 |
|
3405 |
|
3406 | ;
|
3407 |
|
3408 | _proto.cloneTarget = function cloneTarget(target) {
|
3409 | return {
|
3410 | id: target.id,
|
3411 | id_org: target.id_org,
|
3412 | values: target.values.map(function (d) {
|
3413 | return {
|
3414 | x: d.x,
|
3415 | value: d.value,
|
3416 | id: d.id
|
3417 | };
|
3418 | })
|
3419 | };
|
3420 | };
|
3421 |
|
3422 | return Cache;
|
3423 | }();
|
3424 |
|
3425 |
|
3426 | ;
|
3427 |
|
3428 |
|
3429 |
|
3430 |
|
3431 |
|
3432 |
|
3433 | var generator_setTimeout = win.setTimeout,
|
3434 | generator_clearTimeout = win.clearTimeout;
|
3435 |
|
3436 |
|
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 | function generateResize() {
|
3442 | var fn = [],
|
3443 | timeout,
|
3444 | callResizeFn = function () {
|
3445 |
|
3446 | callResizeFn.clear();
|
3447 | timeout = generator_setTimeout(function () {
|
3448 | fn.forEach(function (f) {
|
3449 | return f();
|
3450 | });
|
3451 | }, 200);
|
3452 | };
|
3453 |
|
3454 | callResizeFn.clear = function () {
|
3455 | if (timeout) {
|
3456 | generator_clearTimeout(timeout);
|
3457 | timeout = null;
|
3458 | }
|
3459 | };
|
3460 |
|
3461 | callResizeFn.add = function (f) {
|
3462 | return fn.push(f);
|
3463 | };
|
3464 |
|
3465 | callResizeFn.remove = function (f) {
|
3466 | return fn.splice(fn.indexOf(f), 1);
|
3467 | };
|
3468 |
|
3469 | return callResizeFn;
|
3470 | }
|
3471 |
|
3472 |
|
3473 |
|
3474 |
|
3475 |
|
3476 |
|
3477 | function generateWait() {
|
3478 | var transitionsToWait = [],
|
3479 | f = function (t, callback) {
|
3480 | var timer;
|
3481 |
|
3482 | function loop() {
|
3483 | var done = 0;
|
3484 |
|
3485 | for (var i = 0, _t; _t = transitionsToWait[i]; i++) {
|
3486 | if (_t === !0 || _t.empty != null && _t.empty()) {
|
3487 | done++;
|
3488 | continue;
|
3489 | }
|
3490 |
|
3491 | try {
|
3492 | _t.transition();
|
3493 | } catch (e) {
|
3494 | done++;
|
3495 | }
|
3496 | }
|
3497 |
|
3498 | timer && generator_clearTimeout(timer);
|
3499 |
|
3500 | if (done === transitionsToWait.length) {
|
3501 | callback == null ? void 0 : callback();
|
3502 | } else {
|
3503 | timer = generator_setTimeout(loop, 50);
|
3504 | }
|
3505 | }
|
3506 |
|
3507 | loop();
|
3508 | };
|
3509 |
|
3510 | f.add = function (t) {
|
3511 | isArray(t) ? transitionsToWait = transitionsToWait.concat(t) : transitionsToWait.push(t);
|
3512 | };
|
3513 |
|
3514 | return f;
|
3515 | }
|
3516 |
|
3517 | var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_require__(5);
|
3518 | ;
|
3519 |
|
3520 |
|
3521 |
|
3522 |
|
3523 |
|
3524 |
|
3525 |
|
3526 |
|
3527 |
|
3528 |
|
3529 |
|
3530 |
|
3531 | var convert = ({
|
3532 | |
3533 |
|
3534 |
|
3535 |
|
3536 |
|
3537 |
|
3538 |
|
3539 | convertData: function convertData(args, callback) {
|
3540 | var data;
|
3541 |
|
3542 | if (args.bindto) {
|
3543 | data = {};
|
3544 | ["url", "mimeType", "headers", "keys", "json", "keys", "rows", "columns"].forEach(function (v) {
|
3545 | var key = "data_" + v;
|
3546 |
|
3547 | if (key in args) {
|
3548 | data[v] = args[key];
|
3549 | }
|
3550 | });
|
3551 | } else {
|
3552 | data = args;
|
3553 | }
|
3554 |
|
3555 | if (data.url && callback) {
|
3556 | this.convertUrlToData(data.url, data.mimeType, data.headers, data.keys, callback);
|
3557 | } else if (data.json) {
|
3558 | data = this.convertJsonToData(data.json, data.keys);
|
3559 | } else if (data.rows) {
|
3560 | data = this.convertRowsToData(data.rows);
|
3561 | } else if (data.columns) {
|
3562 | data = this.convertColumnsToData(data.columns);
|
3563 | } else if (args.bindto) {
|
3564 | throw Error("url or json or rows or columns is required.");
|
3565 | }
|
3566 |
|
3567 | return isArray(data) && data;
|
3568 | },
|
3569 |
|
3570 | |
3571 |
|
3572 |
|
3573 |
|
3574 |
|
3575 |
|
3576 |
|
3577 |
|
3578 |
|
3579 | convertUrlToData: function convertUrlToData(url, mimeType, headers, keys, done) {
|
3580 | var _this = this;
|
3581 |
|
3582 | if (mimeType === void 0) {
|
3583 | mimeType = "csv";
|
3584 | }
|
3585 |
|
3586 | var req = new XMLHttpRequest();
|
3587 | req.open("GET", url);
|
3588 |
|
3589 | if (headers) {
|
3590 | Object.keys(headers).forEach(function (key) {
|
3591 | req.setRequestHeader(key, headers[key]);
|
3592 | });
|
3593 | }
|
3594 |
|
3595 | req.onreadystatechange = function () {
|
3596 | if (req.readyState === 4) {
|
3597 | if (req.status === 200) {
|
3598 | var response = req.responseText;
|
3599 | response && done.call(_this, _this["convert" + capitalize(mimeType) + "ToData"](mimeType === "json" ? JSON.parse(response) : response, keys));
|
3600 | } else {
|
3601 | throw new Error(url + ": Something went wrong loading!");
|
3602 | }
|
3603 | }
|
3604 | };
|
3605 |
|
3606 | req.send();
|
3607 | },
|
3608 |
|
3609 | |
3610 |
|
3611 |
|
3612 |
|
3613 |
|
3614 |
|
3615 |
|
3616 | convertCsvTsvToData: function convertCsvTsvToData(parser, xsv) {
|
3617 | var rows = parser.rows(xsv),
|
3618 | d;
|
3619 |
|
3620 | if (rows.length === 1) {
|
3621 | d = [{}];
|
3622 | rows[0].forEach(function (id) {
|
3623 | d[0][id] = null;
|
3624 | });
|
3625 | } else {
|
3626 | d = parser.parse(xsv);
|
3627 | }
|
3628 |
|
3629 | return d;
|
3630 | },
|
3631 | convertCsvToData: function convertCsvToData(xsv) {
|
3632 | return this.convertCsvTsvToData({
|
3633 | rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParseRows,
|
3634 | parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParse
|
3635 | }, xsv);
|
3636 | },
|
3637 | convertTsvToData: function convertTsvToData(tsv) {
|
3638 | return this.convertCsvTsvToData({
|
3639 | rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParseRows,
|
3640 | parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParse
|
3641 | }, tsv);
|
3642 | },
|
3643 | convertJsonToData: function convertJsonToData(json, keysParam) {
|
3644 | var _this2 = this,
|
3645 | config = this.config,
|
3646 | newRows = [],
|
3647 | targetKeys,
|
3648 | data;
|
3649 |
|
3650 | if (isArray(json)) {
|
3651 | var keys = keysParam || config.data_keys;
|
3652 |
|
3653 | if (keys.x) {
|
3654 | targetKeys = keys.value.concat(keys.x);
|
3655 | config.data_x = keys.x;
|
3656 | } else {
|
3657 | targetKeys = keys.value;
|
3658 | }
|
3659 |
|
3660 | newRows.push(targetKeys);
|
3661 | json.forEach(function (o) {
|
3662 | var newRow = targetKeys.map(function (key) {
|
3663 |
|
3664 | var v = _this2.findValueInJson(o, key);
|
3665 |
|
3666 | if (isUndefined(v)) {
|
3667 | v = null;
|
3668 | }
|
3669 |
|
3670 | return v;
|
3671 | });
|
3672 | newRows.push(newRow);
|
3673 | });
|
3674 | data = this.convertRowsToData(newRows);
|
3675 | } else {
|
3676 | Object.keys(json).forEach(function (key) {
|
3677 | var tmp = json[key].concat();
|
3678 | tmp.unshift(key);
|
3679 | newRows.push(tmp);
|
3680 | });
|
3681 | data = this.convertColumnsToData(newRows);
|
3682 | }
|
3683 |
|
3684 | return data;
|
3685 | },
|
3686 | findValueInJson: function findValueInJson(object, path) {
|
3687 | if (object[path] !== undefined) {
|
3688 | return object[path];
|
3689 | }
|
3690 |
|
3691 | var convertedPath = path.replace(/\[(\w+)\]/g, ".$1"),
|
3692 | pathArray = convertedPath.replace(/^\./, "").split("."),
|
3693 | target = object;
|
3694 |
|
3695 | pathArray.some(function (k) {
|
3696 | return !(target = target && k in target ? target[k] : undefined);
|
3697 | });
|
3698 | return target;
|
3699 | },
|
3700 | convertRowsToData: function convertRowsToData(rows) {
|
3701 | var keys = rows[0],
|
3702 | newRows = [];
|
3703 | rows.forEach(function (row, i) {
|
3704 | if (i > 0) {
|
3705 | var newRow = {};
|
3706 | row.forEach(function (v, j) {
|
3707 | if (isUndefined(v)) {
|
3708 | throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
|
3709 | }
|
3710 |
|
3711 | newRow[keys[j]] = v;
|
3712 | });
|
3713 | newRows.push(newRow);
|
3714 | }
|
3715 | });
|
3716 | return newRows;
|
3717 | },
|
3718 | convertColumnsToData: function convertColumnsToData(columns) {
|
3719 | var newRows = [];
|
3720 | columns.forEach(function (col, i) {
|
3721 | var key = col[0];
|
3722 | col.forEach(function (v, j) {
|
3723 | if (j > 0) {
|
3724 | if (isUndefined(newRows[j - 1])) {
|
3725 | newRows[j - 1] = {};
|
3726 | }
|
3727 |
|
3728 | if (isUndefined(v)) {
|
3729 | throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
|
3730 | }
|
3731 |
|
3732 | newRows[j - 1][key] = v;
|
3733 | }
|
3734 | });
|
3735 | });
|
3736 | return newRows;
|
3737 | },
|
3738 | convertDataToTargets: function convertDataToTargets(data, appendXs) {
|
3739 | var _this3 = this,
|
3740 | $$ = this,
|
3741 | axis = $$.axis,
|
3742 | config = $$.config,
|
3743 | state = $$.state,
|
3744 | isCategorized = !1,
|
3745 | isTimeSeries = !1,
|
3746 | isCustomX = !1;
|
3747 |
|
3748 | if (axis) {
|
3749 | isCategorized = axis.isCategorized();
|
3750 | isTimeSeries = axis.isTimeSeries();
|
3751 | isCustomX = axis.isCustomX();
|
3752 | }
|
3753 |
|
3754 | var dataKeys = Object.keys(data[0] || {}),
|
3755 | ids = dataKeys.length ? dataKeys.filter($$.isNotX, $$) : [],
|
3756 | xs = dataKeys.length ? dataKeys.filter($$.isX, $$) : [],
|
3757 | xsData;
|
3758 |
|
3759 | ids.forEach(function (id) {
|
3760 | var xKey = _this3.getXKey(id);
|
3761 |
|
3762 | if (isCustomX || isTimeSeries) {
|
3763 |
|
3764 | if (xs.indexOf(xKey) >= 0) {
|
3765 | xsData = (appendXs && $$.data.xs[id] || []).concat(data.map(function (d) {
|
3766 | return d[xKey];
|
3767 | }).filter(isValue).map(function (rawX, i) {
|
3768 | return $$.generateTargetX(rawX, id, i);
|
3769 | }));
|
3770 | } else if (config.data_x) {
|
3771 |
|
3772 | xsData = _this3.getOtherTargetXs();
|
3773 | } else if (notEmpty(config.data_xs)) {
|
3774 |
|
3775 | xsData = $$.getXValuesOfXKey(xKey, $$.data.targets);
|
3776 | }
|
3777 |
|
3778 | } else {
|
3779 | xsData = data.map(function (d, i) {
|
3780 | return i;
|
3781 | });
|
3782 | }
|
3783 |
|
3784 | xsData && (_this3.data.xs[id] = xsData);
|
3785 | });
|
3786 |
|
3787 | ids.forEach(function (id) {
|
3788 | if (!_this3.data.xs[id]) {
|
3789 | throw new Error("x is not defined for id = \"" + id + "\".");
|
3790 | }
|
3791 | });
|
3792 |
|
3793 | var targets = ids.map(function (id, index) {
|
3794 | var convertedId = config.data_idConverter.bind($$.api)(id),
|
3795 | xKey = $$.getXKey(id),
|
3796 | isCategory = isCustomX && isCategorized,
|
3797 | hasCategory = isCategory && data.map(function (v) {
|
3798 | return v.x;
|
3799 | }).every(function (v) {
|
3800 | return config.axis_x_categories.indexOf(v) > -1;
|
3801 | }),
|
3802 | isDataAppend = data.__append__,
|
3803 | xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0;
|
3804 | return {
|
3805 | id: convertedId,
|
3806 | id_org: id,
|
3807 | values: data.map(function (d, i) {
|
3808 | var rawX = d[xKey],
|
3809 | value = d[id],
|
3810 | x;
|
3811 | value = value !== null && !isNaN(value) && !isObject(value) ? +value : isArray(value) || isObject(value) ? value : null;
|
3812 |
|
3813 | if ((isCategory || state.hasRadar) && index === 0 && !isUndefined(rawX)) {
|
3814 | if (!hasCategory && index === 0 && i === 0 && !isDataAppend) {
|
3815 | config.axis_x_categories = [];
|
3816 | }
|
3817 |
|
3818 | x = config.axis_x_categories.indexOf(rawX);
|
3819 |
|
3820 | if (x === -1) {
|
3821 | x = config.axis_x_categories.length;
|
3822 | config.axis_x_categories.push(rawX);
|
3823 | }
|
3824 | } else {
|
3825 | x = $$.generateTargetX(rawX, id, xIndex + i);
|
3826 | }
|
3827 |
|
3828 |
|
3829 | if (isUndefined(value) || $$.data.xs[id].length <= i) {
|
3830 | x = undefined;
|
3831 | }
|
3832 |
|
3833 | return {
|
3834 | x: x,
|
3835 | value: value,
|
3836 | id: convertedId
|
3837 | };
|
3838 | }).filter(function (v) {
|
3839 | return isDefined(v.x);
|
3840 | })
|
3841 | };
|
3842 | });
|
3843 |
|
3844 | targets.forEach(function (t) {
|
3845 |
|
3846 | if (config.data_xSort) {
|
3847 | t.values = t.values.sort(function (v1, v2) {
|
3848 | var x1 = v1.x || v1.x === 0 ? v1.x : Infinity,
|
3849 | x2 = v2.x || v2.x === 0 ? v2.x : Infinity;
|
3850 | return x1 - x2;
|
3851 | });
|
3852 | }
|
3853 |
|
3854 |
|
3855 | t.values.forEach(function (v, i) {
|
3856 | return v.index = i;
|
3857 | });
|
3858 |
|
3859 | $$.data.xs[t.id].sort(function (v1, v2) {
|
3860 | return v1 - v2;
|
3861 | });
|
3862 | });
|
3863 |
|
3864 | state.hasNegativeValue = $$.hasNegativeValueInTargets(targets);
|
3865 | state.hasPositiveValue = $$.hasPositiveValueInTargets(targets);
|
3866 |
|
3867 | if (config.data_type) {
|
3868 | $$.setTargetType($$.mapToIds(targets).filter(function (id) {
|
3869 | return !(id in config.data_types);
|
3870 | }), config.data_type);
|
3871 | }
|
3872 |
|
3873 |
|
3874 | targets.forEach(function (d) {
|
3875 | return $$.cache.add(d.id_org, d, !0);
|
3876 | });
|
3877 | return targets;
|
3878 | }
|
3879 | });
|
3880 | ;
|
3881 |
|
3882 |
|
3883 |
|
3884 |
|
3885 |
|
3886 |
|
3887 |
|
3888 | var data_data = ({
|
3889 | isX: function isX(key) {
|
3890 | var $$ = this,
|
3891 | config = $$.config,
|
3892 | dataKey = config.data_x && key === config.data_x,
|
3893 | existValue = notEmpty(config.data_xs) && hasValue(config.data_xs, key);
|
3894 | return dataKey || existValue;
|
3895 | },
|
3896 | isNotX: function isNotX(key) {
|
3897 | return !this.isX(key);
|
3898 | },
|
3899 | isStackNormalized: function isStackNormalized() {
|
3900 | var config = this.config;
|
3901 | return !!(config.data_stack_normalize && config.data_groups.length);
|
3902 | },
|
3903 | isGrouped: function isGrouped(id) {
|
3904 | var groups = this.config.data_groups;
|
3905 | return id ? groups.some(function (v) {
|
3906 | return v.indexOf(id) >= 0 && v.length > 1;
|
3907 | }) : groups.length > 0;
|
3908 | },
|
3909 | getXKey: function getXKey(id) {
|
3910 | var $$ = this,
|
3911 | config = $$.config;
|
3912 | return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null;
|
3913 | },
|
3914 | getXValuesOfXKey: function getXValuesOfXKey(key, targets) {
|
3915 | var $$ = this,
|
3916 | ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : [],
|
3917 | xValues;
|
3918 | ids.forEach(function (id) {
|
3919 | if ($$.getXKey(id) === key) {
|
3920 | xValues = $$.data.xs[id];
|
3921 | }
|
3922 | });
|
3923 | return xValues;
|
3924 | },
|
3925 |
|
3926 | |
3927 |
|
3928 |
|
3929 |
|
3930 |
|
3931 |
|
3932 |
|
3933 | getIndexByX: function getIndexByX(x, basedX) {
|
3934 | var $$ = this;
|
3935 | return basedX ? basedX.indexOf(isString(x) ? x : +x) : ($$.filterByX($$.data.targets, x)[0] || {
|
3936 | index: null
|
3937 | }).index;
|
3938 | },
|
3939 | getXValue: function getXValue(id, i) {
|
3940 | var $$ = this;
|
3941 | return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i;
|
3942 | },
|
3943 | getOtherTargetXs: function getOtherTargetXs() {
|
3944 | var $$ = this,
|
3945 | idsForX = Object.keys($$.data.xs);
|
3946 | return idsForX.length ? $$.data.xs[idsForX[0]] : null;
|
3947 | },
|
3948 | getOtherTargetX: function getOtherTargetX(index) {
|
3949 | var xs = this.getOtherTargetXs();
|
3950 | return xs && index < xs.length ? xs[index] : null;
|
3951 | },
|
3952 | addXs: function addXs(xs) {
|
3953 | var $$ = this,
|
3954 | config = $$.config;
|
3955 | Object.keys(xs).forEach(function (id) {
|
3956 | config.data_xs[id] = xs[id];
|
3957 | });
|
3958 | },
|
3959 | isMultipleX: function isMultipleX() {
|
3960 | return notEmpty(this.config.data_xs) || !this.config.data_xSort || this.hasType("bubble") || this.hasType("scatter");
|
3961 | },
|
3962 | addName: function addName(data) {
|
3963 | var $$ = this,
|
3964 | config = $$.config,
|
3965 | name;
|
3966 |
|
3967 | if (data) {
|
3968 | name = config.data_names[data.id];
|
3969 | data.name = name !== undefined ? name : data.id;
|
3970 | }
|
3971 |
|
3972 | return data;
|
3973 | },
|
3974 |
|
3975 | |
3976 |
|
3977 |
|
3978 |
|
3979 |
|
3980 |
|
3981 |
|
3982 | getAllValuesOnIndex: function getAllValuesOnIndex(index, filterNull) {
|
3983 | if (filterNull === void 0) {
|
3984 | filterNull = !1;
|
3985 | }
|
3986 |
|
3987 | var $$ = this,
|
3988 | value = $$.filterTargetsToShow($$.data.targets).map(function (t) {
|
3989 | return $$.addName($$.getValueOnIndex(t.values, index));
|
3990 | });
|
3991 |
|
3992 | if (filterNull) {
|
3993 | value = value.filter(function (v) {
|
3994 | return isValue(v.value);
|
3995 | });
|
3996 | }
|
3997 |
|
3998 | return value;
|
3999 | },
|
4000 | getValueOnIndex: function getValueOnIndex(values, index) {
|
4001 | var valueOnIndex = values.filter(function (v) {
|
4002 | return v.index === index;
|
4003 | });
|
4004 | return valueOnIndex.length ? valueOnIndex[0] : null;
|
4005 | },
|
4006 | updateTargetX: function updateTargetX(targets, x) {
|
4007 | var $$ = this;
|
4008 | targets.forEach(function (t) {
|
4009 | t.values.forEach(function (v, i) {
|
4010 | v.x = $$.generateTargetX(x[i], t.id, i);
|
4011 | });
|
4012 | $$.data.xs[t.id] = x;
|
4013 | });
|
4014 | },
|
4015 | updateTargetXs: function updateTargetXs(targets, xs) {
|
4016 | var $$ = this;
|
4017 | targets.forEach(function (t) {
|
4018 | xs[t.id] && $$.updateTargetX([t], xs[t.id]);
|
4019 | });
|
4020 | },
|
4021 | generateTargetX: function generateTargetX(rawX, id, index) {
|
4022 | var _axis,
|
4023 | $$ = this,
|
4024 | axis = $$.axis,
|
4025 | x = (_axis = axis) != null && _axis.isCategorized() ? index : rawX || index,
|
4026 | _axis2,
|
4027 | _axis3,
|
4028 | _axis4;
|
4029 |
|
4030 | if ((_axis2 = axis) != null && _axis2.isTimeSeries()) {
|
4031 | var fn = parseDate.bind($$);
|
4032 | x = rawX ? fn(rawX) : fn($$.getXValue(id, index));
|
4033 | } else if ((_axis3 = axis) != null && _axis3.isCustomX() && !((_axis4 = axis) != null && _axis4.isCategorized())) {
|
4034 | x = isValue(rawX) ? +rawX : $$.getXValue(id, index);
|
4035 | }
|
4036 |
|
4037 | return x;
|
4038 | },
|
4039 | updateXs: function updateXs(values) {
|
4040 | if (values.length) {
|
4041 | this.axis.xs = values.map(function (v) {
|
4042 | return v.x;
|
4043 | });
|
4044 | }
|
4045 | },
|
4046 | getPrevX: function getPrevX(i) {
|
4047 | var x = this.axis.xs[i - 1];
|
4048 | return isDefined(x) ? x : null;
|
4049 | },
|
4050 | getNextX: function getNextX(i) {
|
4051 | var x = this.axis.xs[i + 1];
|
4052 | return isDefined(x) ? x : null;
|
4053 | },
|
4054 |
|
4055 | |
4056 |
|
4057 |
|
4058 |
|
4059 |
|
4060 |
|
4061 | getBaseValue: function getBaseValue(data) {
|
4062 | var $$ = this,
|
4063 | hasAxis = $$.state.hasAxis,
|
4064 | value = data.value;
|
4065 |
|
4066 |
|
4067 |
|
4068 | if (value && hasAxis) {
|
4069 | if ($$.isAreaRangeType(data)) {
|
4070 | value = $$.getRangedData(data, "mid");
|
4071 | } else if ($$.isBubbleZType(data)) {
|
4072 | value = $$.getBubbleZData(value, "y");
|
4073 | }
|
4074 | }
|
4075 |
|
4076 | return value;
|
4077 | },
|
4078 |
|
4079 | |
4080 |
|
4081 |
|
4082 |
|
4083 |
|
4084 |
|
4085 | getMinMaxValue: function getMinMaxValue(data) {
|
4086 | var getBaseValue = this.getBaseValue.bind(this),
|
4087 | min,
|
4088 | max;
|
4089 | (data || this.data.targets.map(function (t) {
|
4090 | return t.values;
|
4091 | })).forEach(function (v, i) {
|
4092 | var value = v.map(getBaseValue).filter(isNumber);
|
4093 | min = Math.min.apply(Math, [i ? min : Infinity].concat(value));
|
4094 | max = Math.max.apply(Math, [i ? max : -Infinity].concat(value));
|
4095 | });
|
4096 | return {
|
4097 | min: min,
|
4098 | max: max
|
4099 | };
|
4100 | },
|
4101 |
|
4102 | |
4103 |
|
4104 |
|
4105 |
|
4106 |
|
4107 | getMinMaxData: function getMinMaxData() {
|
4108 | var $$ = this,
|
4109 | cacheKey = KEY.dataMinMax,
|
4110 | minMaxData = $$.cache.get(cacheKey);
|
4111 |
|
4112 | if (!minMaxData) {
|
4113 | var data = $$.data.targets.map(function (t) {
|
4114 | return t.values;
|
4115 | }),
|
4116 | minMax = $$.getMinMaxValue(data),
|
4117 | min = [],
|
4118 | max = [];
|
4119 | data.forEach(function (v) {
|
4120 | var minData = $$.getFilteredDataByValue(v, minMax.min),
|
4121 | maxData = $$.getFilteredDataByValue(v, minMax.max);
|
4122 |
|
4123 | if (minData.length) {
|
4124 | min = min.concat(minData);
|
4125 | }
|
4126 |
|
4127 | if (maxData.length) {
|
4128 | max = max.concat(maxData);
|
4129 | }
|
4130 | });
|
4131 |
|
4132 | $$.cache.add(cacheKey, minMaxData = {
|
4133 | min: min,
|
4134 | max: max
|
4135 | });
|
4136 | }
|
4137 |
|
4138 | return minMaxData;
|
4139 | },
|
4140 |
|
4141 | |
4142 |
|
4143 |
|
4144 |
|
4145 |
|
4146 | getTotalPerIndex: function getTotalPerIndex() {
|
4147 | var $$ = this,
|
4148 | cacheKey = KEY.dataTotalPerIndex,
|
4149 | sum = $$.cache.get(cacheKey);
|
4150 |
|
4151 | if ($$.isStackNormalized() && !sum) {
|
4152 | sum = [];
|
4153 | $$.data.targets.forEach(function (row) {
|
4154 | row.values.forEach(function (v, i) {
|
4155 | if (!sum[i]) {
|
4156 | sum[i] = 0;
|
4157 | }
|
4158 |
|
4159 | sum[i] += isNumber(v.value) ? v.value : 0;
|
4160 | });
|
4161 | });
|
4162 | }
|
4163 |
|
4164 | return sum;
|
4165 | },
|
4166 |
|
4167 | |
4168 |
|
4169 |
|
4170 |
|
4171 |
|
4172 |
|
4173 | getTotalDataSum: function getTotalDataSum(subtractHidden) {
|
4174 | var $$ = this,
|
4175 | cacheKey = KEY.dataTotalSum,
|
4176 | total = $$.cache.get(cacheKey);
|
4177 |
|
4178 | if (!isNumber(total)) {
|
4179 | var sum = mergeArray($$.data.targets.map(function (t) {
|
4180 | return t.values;
|
4181 | })).map(function (v) {
|
4182 | return v.value;
|
4183 | }).reduce(function (p, c) {
|
4184 | return p + c;
|
4185 | });
|
4186 | $$.cache.add(cacheKey, total = sum);
|
4187 | }
|
4188 |
|
4189 | if (subtractHidden) {
|
4190 | total -= $$.getHiddenTotalDataSum();
|
4191 | }
|
4192 |
|
4193 | return total;
|
4194 | },
|
4195 |
|
4196 | |
4197 |
|
4198 |
|
4199 |
|
4200 |
|
4201 | getHiddenTotalDataSum: function getHiddenTotalDataSum() {
|
4202 | var $$ = this,
|
4203 | api = $$.api,
|
4204 | hiddenTargetIds = $$.state.hiddenTargetIds,
|
4205 | total = 0;
|
4206 |
|
4207 | if (hiddenTargetIds.length) {
|
4208 | total = api.data.values.bind(api)(hiddenTargetIds).reduce(function (p, c) {
|
4209 | return p + c;
|
4210 | });
|
4211 | }
|
4212 |
|
4213 | return total;
|
4214 | },
|
4215 |
|
4216 | |
4217 |
|
4218 |
|
4219 |
|
4220 |
|
4221 |
|
4222 |
|
4223 | getFilteredDataByValue: function getFilteredDataByValue(data, value) {
|
4224 | var _this = this;
|
4225 |
|
4226 | return data.filter(function (t) {
|
4227 | return _this.getBaseValue(t) === value;
|
4228 | });
|
4229 | },
|
4230 |
|
4231 | |
4232 |
|
4233 |
|
4234 |
|
4235 |
|
4236 | getMaxDataCount: function getMaxDataCount() {
|
4237 | return Math.max.apply(Math, this.data.targets.map(function (t) {
|
4238 | return t.values.length;
|
4239 | }));
|
4240 | },
|
4241 | getMaxDataCountTarget: function getMaxDataCountTarget() {
|
4242 | var target = this.filterTargetsToShow() || [],
|
4243 | length = target.length;
|
4244 |
|
4245 | if (length > 1) {
|
4246 | target = target.map(function (t) {
|
4247 | return t.values;
|
4248 | }).reduce(function (a, b) {
|
4249 | return a.concat(b);
|
4250 | }).map(function (v) {
|
4251 | return v.x;
|
4252 | });
|
4253 | target = sortValue(getUnique(target)).map(function (x, index) {
|
4254 | return {
|
4255 | x: x,
|
4256 | index: index
|
4257 | };
|
4258 | });
|
4259 | } else if (length) {
|
4260 | target = target[0].values;
|
4261 | }
|
4262 |
|
4263 | return target;
|
4264 | },
|
4265 | mapToIds: function mapToIds(targets) {
|
4266 | return targets.map(function (d) {
|
4267 | return d.id;
|
4268 | });
|
4269 | },
|
4270 | mapToTargetIds: function mapToTargetIds(ids) {
|
4271 | var $$ = this;
|
4272 | return ids ? isArray(ids) ? ids.concat() : [ids] : $$.mapToIds($$.data.targets);
|
4273 | },
|
4274 | hasTarget: function hasTarget(targets, id) {
|
4275 | var ids = this.mapToIds(targets);
|
4276 |
|
4277 | for (var i = 0, val; val = ids[i]; i++) {
|
4278 | if (val === id) {
|
4279 | return !0;
|
4280 | }
|
4281 | }
|
4282 |
|
4283 | return !1;
|
4284 | },
|
4285 | isTargetToShow: function isTargetToShow(targetId) {
|
4286 | return this.state.hiddenTargetIds.indexOf(targetId) < 0;
|
4287 | },
|
4288 | isLegendToShow: function isLegendToShow(targetId) {
|
4289 | return this.state.hiddenLegendIds.indexOf(targetId) < 0;
|
4290 | },
|
4291 | filterTargetsToShow: function filterTargetsToShow(targets) {
|
4292 | var $$ = this;
|
4293 | return (targets || $$.data.targets).filter(function (t) {
|
4294 | return $$.isTargetToShow(t.id);
|
4295 | });
|
4296 | },
|
4297 | mapTargetsToUniqueXs: function mapTargetsToUniqueXs(targets) {
|
4298 | var $$ = this,
|
4299 | axis = $$.axis,
|
4300 | xs = [];
|
4301 |
|
4302 | if (targets != null && targets.length) {
|
4303 | var _axis5;
|
4304 |
|
4305 | xs = getUnique(mergeArray(targets.map(function (t) {
|
4306 | return t.values.map(function (v) {
|
4307 | return +v.x;
|
4308 | });
|
4309 | })));
|
4310 | xs = (_axis5 = axis) != null && _axis5.isTimeSeries() ? xs.map(function (x) {
|
4311 | return new Date(+x);
|
4312 | }) : xs.map(Number);
|
4313 | }
|
4314 |
|
4315 | return sortValue(xs);
|
4316 | },
|
4317 |
|
4318 | |
4319 |
|
4320 |
|
4321 |
|
4322 |
|
4323 |
|
4324 | addTargetIds: function addTargetIds(type, targetIds) {
|
4325 | var state = this.state,
|
4326 | ids = isArray(targetIds) ? targetIds : [targetIds];
|
4327 | ids.forEach(function (v) {
|
4328 | state[type].indexOf(v) < 0 && state[type].push(v);
|
4329 | });
|
4330 | },
|
4331 |
|
4332 | |
4333 |
|
4334 |
|
4335 |
|
4336 |
|
4337 |
|
4338 | removeTargetIds: function removeTargetIds(type, targetIds) {
|
4339 | var state = this.state,
|
4340 | ids = isArray(targetIds) ? targetIds : [targetIds];
|
4341 | ids.forEach(function (v) {
|
4342 | var index = state[type].indexOf(v);
|
4343 | index >= 0 && state[type].splice(index, 1);
|
4344 | });
|
4345 | },
|
4346 | addHiddenTargetIds: function addHiddenTargetIds(targetIds) {
|
4347 | this.addTargetIds("hiddenTargetIds", targetIds);
|
4348 | },
|
4349 | removeHiddenTargetIds: function removeHiddenTargetIds(targetIds) {
|
4350 | this.removeTargetIds("hiddenTargetIds", targetIds);
|
4351 | },
|
4352 | addHiddenLegendIds: function addHiddenLegendIds(targetIds) {
|
4353 | this.addTargetIds("hiddenLegendIds", targetIds);
|
4354 | },
|
4355 | removeHiddenLegendIds: function removeHiddenLegendIds(targetIds) {
|
4356 | this.removeTargetIds("hiddenLegendIds", targetIds);
|
4357 | },
|
4358 | getValuesAsIdKeyed: function getValuesAsIdKeyed(targets) {
|
4359 | var $$ = this,
|
4360 | hasAxis = $$.state.hasAxis,
|
4361 | ys = {},
|
4362 | isMultipleX = $$.isMultipleX(),
|
4363 | xs = isMultipleX ? $$.mapTargetsToUniqueXs(targets).map(function (v) {
|
4364 | return isString(v) ? v : +v;
|
4365 | }) : null;
|
4366 | targets.forEach(function (t) {
|
4367 | var data = [];
|
4368 | t.values.filter(function (_ref) {
|
4369 | var value = _ref.value;
|
4370 | return isValue(value) || value === null;
|
4371 | }).forEach(function (v) {
|
4372 | var value = v.value;
|
4373 |
|
4374 | if (value !== null && $$.isCandlestickType(v)) {
|
4375 | value = isArray(value) ? value.slice(0, 4) : [value.open, value.high, value.low, value.close];
|
4376 | }
|
4377 |
|
4378 | if (isArray(value)) {
|
4379 | data.push.apply(data, value);
|
4380 | } else if (isObject(value) && "high" in value) {
|
4381 | data.push.apply(data, Object.values(value));
|
4382 | } else if ($$.isBubbleZType(v)) {
|
4383 | data.push(hasAxis && $$.getBubbleZData(value, "y"));
|
4384 | } else {
|
4385 | if (isMultipleX) {
|
4386 | data[$$.getIndexByX(v.x, xs)] = value;
|
4387 | } else {
|
4388 | data.push(value);
|
4389 | }
|
4390 | }
|
4391 | });
|
4392 | ys[t.id] = data;
|
4393 | });
|
4394 | return ys;
|
4395 | },
|
4396 | checkValueInTargets: function checkValueInTargets(targets, checker) {
|
4397 | var ids = Object.keys(targets),
|
4398 | values;
|
4399 |
|
4400 | for (var i = 0; i < ids.length; i++) {
|
4401 | values = targets[ids[i]].values;
|
4402 |
|
4403 | for (var j = 0; j < values.length; j++) {
|
4404 | if (checker(values[j].value)) {
|
4405 | return !0;
|
4406 | }
|
4407 | }
|
4408 | }
|
4409 |
|
4410 | return !1;
|
4411 | },
|
4412 | hasMultiTargets: function hasMultiTargets() {
|
4413 | return this.filterTargetsToShow().length > 1;
|
4414 | },
|
4415 | hasNegativeValueInTargets: function hasNegativeValueInTargets(targets) {
|
4416 | return this.checkValueInTargets(targets, function (v) {
|
4417 | return v < 0;
|
4418 | });
|
4419 | },
|
4420 | hasPositiveValueInTargets: function hasPositiveValueInTargets(targets) {
|
4421 | return this.checkValueInTargets(targets, function (v) {
|
4422 | return v > 0;
|
4423 | });
|
4424 | },
|
4425 |
|
4426 | |
4427 |
|
4428 |
|
4429 |
|
4430 |
|
4431 |
|
4432 | orderTargets: function orderTargets(targetsValue) {
|
4433 | var $$ = this,
|
4434 | targets = [].concat(targetsValue),
|
4435 | fn = $$.getSortCompareFn();
|
4436 | fn && targets.sort(fn);
|
4437 | return targets;
|
4438 | },
|
4439 |
|
4440 | |
4441 |
|
4442 |
|
4443 |
|
4444 |
|
4445 |
|
4446 | getSortCompareFn: function getSortCompareFn(isArc) {
|
4447 | if (isArc === void 0) {
|
4448 | isArc = !1;
|
4449 | }
|
4450 |
|
4451 | var $$ = this,
|
4452 | config = $$.config,
|
4453 | order = config.data_order,
|
4454 | orderAsc = /asc/i.test(order),
|
4455 | orderDesc = /desc/i.test(order),
|
4456 | fn;
|
4457 |
|
4458 | if (orderAsc || orderDesc) {
|
4459 | var reducer = function (p, c) {
|
4460 | return p + Math.abs(c.value);
|
4461 | };
|
4462 |
|
4463 | fn = function (t1, t2) {
|
4464 | var t1Sum = t1.values.reduce(reducer, 0),
|
4465 | t2Sum = t2.values.reduce(reducer, 0);
|
4466 | return isArc ? orderAsc ? t1Sum - t2Sum : t2Sum - t1Sum : orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum;
|
4467 | };
|
4468 | } else if (isFunction(order)) {
|
4469 | fn = order.bind($$.api);
|
4470 | }
|
4471 |
|
4472 | return fn || null;
|
4473 | },
|
4474 | filterByX: function filterByX(targets, x) {
|
4475 | return mergeArray(targets.map(function (t) {
|
4476 | return t.values;
|
4477 | })).filter(function (v) {
|
4478 | return v.x - x === 0;
|
4479 | });
|
4480 | },
|
4481 | filterRemoveNull: function filterRemoveNull(data) {
|
4482 | var _this2 = this;
|
4483 |
|
4484 | return data.filter(function (d) {
|
4485 | return isValue(_this2.getBaseValue(d));
|
4486 | });
|
4487 | },
|
4488 | filterByXDomain: function filterByXDomain(targets, xDomain) {
|
4489 | return targets.map(function (t) {
|
4490 | return {
|
4491 | id: t.id,
|
4492 | id_org: t.id_org,
|
4493 | values: t.values.filter(function (v) {
|
4494 | return xDomain[0] <= v.x && v.x <= xDomain[1];
|
4495 | })
|
4496 | };
|
4497 | });
|
4498 | },
|
4499 | hasDataLabel: function hasDataLabel() {
|
4500 | var dataLabels = this.config.data_labels;
|
4501 | return isboolean(dataLabels) && dataLabels || isObjectType(dataLabels) && notEmpty(dataLabels);
|
4502 | },
|
4503 |
|
4504 | |
4505 |
|
4506 |
|
4507 |
|
4508 |
|
4509 | getDataIndexFromEvent: function getDataIndexFromEvent(event) {
|
4510 | var $$ = this,
|
4511 | config = $$.config,
|
4512 | _$$$state = $$.state,
|
4513 | inputType = _$$$state.inputType,
|
4514 | _$$$state$eventReceiv = _$$$state.eventReceiver,
|
4515 | coords = _$$$state$eventReceiv.coords,
|
4516 | rect = _$$$state$eventReceiv.rect,
|
4517 | isRotated = config.axis_rotated,
|
4518 | e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event,
|
4519 | index = findIndex(coords, isRotated ? e.clientY - rect.top : e.clientX - rect.left, 0, coords.length - 1, isRotated);
|
4520 | return index;
|
4521 | },
|
4522 | getDataLabelLength: function getDataLabelLength(min, max, key) {
|
4523 | var $$ = this,
|
4524 | lengths = [0, 0];
|
4525 | $$.$el.chart.select("svg").selectAll(".dummy").data([min, max]).enter().append("text").text(function (d) {
|
4526 | return $$.dataLabelFormat(d.id)(d);
|
4527 | }).each(function (d, i) {
|
4528 | lengths[i] = this.getBoundingClientRect()[key] * 1.3;
|
4529 | }).remove();
|
4530 | return lengths;
|
4531 | },
|
4532 | isNoneArc: function isNoneArc(d) {
|
4533 | return this.hasTarget(this.data.targets, d.id);
|
4534 | },
|
4535 | isArc: function isArc(d) {
|
4536 | return "data" in d && this.hasTarget(this.data.targets, d.data.id);
|
4537 | },
|
4538 | findSameXOfValues: function findSameXOfValues(values, index) {
|
4539 | var targetX = values[index].x,
|
4540 | sames = [],
|
4541 | i;
|
4542 |
|
4543 | for (i = index - 1; i >= 0; i--) {
|
4544 | if (targetX !== values[i].x) {
|
4545 | break;
|
4546 | }
|
4547 |
|
4548 | sames.push(values[i]);
|
4549 | }
|
4550 |
|
4551 | for (i = index; i < values.length; i++) {
|
4552 | if (targetX !== values[i].x) {
|
4553 | break;
|
4554 | }
|
4555 |
|
4556 | sames.push(values[i]);
|
4557 | }
|
4558 |
|
4559 | return sames;
|
4560 | },
|
4561 | findClosestFromTargets: function findClosestFromTargets(targets, pos) {
|
4562 | var $$ = this,
|
4563 | candidates = targets.map(function (target) {
|
4564 | return $$.findClosest(target.values, pos);
|
4565 | });
|
4566 |
|
4567 |
|
4568 | return $$.findClosest(candidates, pos);
|
4569 | },
|
4570 | findClosest: function findClosest(values, pos) {
|
4571 | var $$ = this,
|
4572 | config = $$.config,
|
4573 | main = $$.$el.main,
|
4574 | data = values.filter(function (v) {
|
4575 | return v && isValue(v.value);
|
4576 | }),
|
4577 | minDist = config.point_sensitivity,
|
4578 | closest;
|
4579 |
|
4580 | data.filter(function (v) {
|
4581 | return $$.isBarType(v.id);
|
4582 | }).forEach(function (v) {
|
4583 | var shape = main.select("." + config_classes.bars + $$.getTargetSelectorSuffix(v.id) + " ." + config_classes.bar + "-" + v.index).node();
|
4584 |
|
4585 | if (!closest && $$.isWithinBar(shape)) {
|
4586 | closest = v;
|
4587 | }
|
4588 | });
|
4589 |
|
4590 | data.filter(function (v) {
|
4591 | return !$$.isBarType(v.id);
|
4592 | }).forEach(function (v) {
|
4593 | var d = $$.dist(v, pos);
|
4594 |
|
4595 | if (d < minDist) {
|
4596 | minDist = d;
|
4597 | closest = v;
|
4598 | }
|
4599 | });
|
4600 | return closest;
|
4601 | },
|
4602 | dist: function dist(data, pos) {
|
4603 | var $$ = this,
|
4604 | isRotated = $$.config.axis_rotated,
|
4605 | scale = $$.scale,
|
4606 | xIndex = isRotated ? 1 : 0,
|
4607 | yIndex = isRotated ? 0 : 1,
|
4608 | y = $$.circleY(data, data.index),
|
4609 | x = (scale.zoom || scale.x)(data.x);
|
4610 | return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
|
4611 | },
|
4612 |
|
4613 | |
4614 |
|
4615 |
|
4616 |
|
4617 |
|
4618 |
|
4619 | convertValuesToStep: function convertValuesToStep(values) {
|
4620 | var $$ = this,
|
4621 | axis = $$.axis,
|
4622 | config = $$.config,
|
4623 | stepType = config.line_step_type,
|
4624 | isCategorized = axis ? axis.isCategorized() : !1,
|
4625 | converted = isArray(values) ? values.concat() : [values];
|
4626 |
|
4627 | if (!(isCategorized || /step\-(after|before)/.test(stepType))) {
|
4628 | return values;
|
4629 | }
|
4630 |
|
4631 |
|
4632 | var head = converted[0],
|
4633 | tail = converted[converted.length - 1],
|
4634 | id = head.id,
|
4635 | x = head.x;
|
4636 |
|
4637 | converted.unshift({
|
4638 | x: --x,
|
4639 | value: head.value,
|
4640 | id: id
|
4641 | });
|
4642 | isCategorized && stepType === "step-after" && converted.unshift({
|
4643 | x: --x,
|
4644 | value: head.value,
|
4645 | id: id
|
4646 | });
|
4647 |
|
4648 | x = tail.x;
|
4649 | converted.push({
|
4650 | x: ++x,
|
4651 | value: tail.value,
|
4652 | id: id
|
4653 | });
|
4654 | isCategorized && stepType === "step-before" && converted.push({
|
4655 | x: ++x,
|
4656 | value: tail.value,
|
4657 | id: id
|
4658 | });
|
4659 | return converted;
|
4660 | },
|
4661 | convertValuesToRange: function convertValuesToRange(values) {
|
4662 | var converted = isArray(values) ? values.concat() : [values],
|
4663 | ranges = [];
|
4664 | converted.forEach(function (range) {
|
4665 | var x = range.x,
|
4666 | id = range.id;
|
4667 | ranges.push({
|
4668 | x: x,
|
4669 | id: id,
|
4670 | value: range.value[0]
|
4671 | });
|
4672 | ranges.push({
|
4673 | x: x,
|
4674 | id: id,
|
4675 | value: range.value[2]
|
4676 | });
|
4677 | });
|
4678 | return ranges;
|
4679 | },
|
4680 | updateDataAttributes: function updateDataAttributes(name, attrs) {
|
4681 | var $$ = this,
|
4682 | config = $$.config,
|
4683 | current = config["data_" + name];
|
4684 |
|
4685 | if (isUndefined(attrs)) {
|
4686 | return current;
|
4687 | }
|
4688 |
|
4689 | Object.keys(attrs).forEach(function (id) {
|
4690 | current[id] = attrs[id];
|
4691 | });
|
4692 | $$.redraw({
|
4693 | withLegend: !0
|
4694 | });
|
4695 | return current;
|
4696 | },
|
4697 | getRangedData: function getRangedData(d, key, type) {
|
4698 | if (key === void 0) {
|
4699 | key = "";
|
4700 | }
|
4701 |
|
4702 | if (type === void 0) {
|
4703 | type = "areaRange";
|
4704 | }
|
4705 |
|
4706 | var value = d == null ? void 0 : d.value;
|
4707 |
|
4708 | if (isArray(value)) {
|
4709 |
|
4710 | var index = {
|
4711 | areaRange: ["high", "mid", "low"],
|
4712 | candlestick: ["open", "high", "low", "close", "volume"]
|
4713 | }[type].indexOf(key);
|
4714 | return index >= 0 && value ? value[index] : undefined;
|
4715 | } else if (value) {
|
4716 | return value[key];
|
4717 | }
|
4718 |
|
4719 | return value;
|
4720 | },
|
4721 |
|
4722 | |
4723 |
|
4724 |
|
4725 |
|
4726 |
|
4727 |
|
4728 |
|
4729 |
|
4730 | getRatio: function getRatio(type, d, asPercent) {
|
4731 | if (asPercent === void 0) {
|
4732 | asPercent = !1;
|
4733 | }
|
4734 |
|
4735 | var $$ = this,
|
4736 | config = $$.config,
|
4737 | state = $$.state,
|
4738 | api = $$.api,
|
4739 | ratio = 0;
|
4740 |
|
4741 | if (d && api.data.shown().length) {
|
4742 | ratio = d.ratio || d.value;
|
4743 |
|
4744 | if (type === "arc") {
|
4745 |
|
4746 | if ($$.pie.padAngle()()) {
|
4747 | ratio = d.value / $$.getTotalDataSum(!0);
|
4748 | } else {
|
4749 | var gaugeArcLength = config.gauge_fullCircle ? $$.getArcLength() : $$.getStartAngle() * -2,
|
4750 | arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
|
4751 | ratio = (d.endAngle - d.startAngle) / arcLength;
|
4752 | }
|
4753 | } else if (type === "index") {
|
4754 | var dataValues = api.data.values.bind(api),
|
4755 | total = this.getTotalPerIndex();
|
4756 |
|
4757 | if (state.hiddenTargetIds.length) {
|
4758 | var hiddenSum = dataValues(state.hiddenTargetIds, !1);
|
4759 |
|
4760 | if (hiddenSum.length) {
|
4761 | hiddenSum = hiddenSum.reduce(function (acc, curr) {
|
4762 | return acc.map(function (v, i) {
|
4763 | return (isNumber(v) ? v : 0) + curr[i];
|
4764 | });
|
4765 | });
|
4766 | total = total.map(function (v, i) {
|
4767 | return v - hiddenSum[i];
|
4768 | });
|
4769 | }
|
4770 | }
|
4771 |
|
4772 | d.ratio = isNumber(d.value) && total && total[d.index] > 0 ? d.value / total[d.index] : 0;
|
4773 | ratio = d.ratio;
|
4774 | } else if (type === "radar") {
|
4775 | ratio = parseFloat(Math.max(d.value, 0) + "") / state.current.dataMax * config.radar_size_ratio;
|
4776 | } else if (type === "bar") {
|
4777 | var yScale = $$.getYScaleById.bind($$)(d.id),
|
4778 | max = yScale.domain().reduce(function (a, c) {
|
4779 | return c - a;
|
4780 | });
|
4781 |
|
4782 | ratio = max === 0 ? 0 : Math.abs(d.value) / max;
|
4783 | }
|
4784 | }
|
4785 |
|
4786 | return asPercent && ratio ? ratio * 100 : ratio;
|
4787 | },
|
4788 |
|
4789 | |
4790 |
|
4791 |
|
4792 |
|
4793 |
|
4794 | updateDataIndexByX: function updateDataIndexByX(tickValues) {
|
4795 | var $$ = this,
|
4796 | tickValueMap = tickValues.reduce(function (out, tick, index) {
|
4797 | out[+tick.x] = index;
|
4798 | return out;
|
4799 | }, {});
|
4800 | $$.data.targets.forEach(function (t) {
|
4801 | t.values.forEach(function (value, valueIndex) {
|
4802 | var index = tickValueMap[+value.x];
|
4803 |
|
4804 | if (index === undefined) {
|
4805 | index = valueIndex;
|
4806 | }
|
4807 |
|
4808 | value.index = index;
|
4809 | });
|
4810 | });
|
4811 | },
|
4812 |
|
4813 | |
4814 |
|
4815 |
|
4816 |
|
4817 |
|
4818 |
|
4819 | isBubbleZType: function isBubbleZType(d) {
|
4820 | var $$ = this;
|
4821 | return $$.isBubbleType(d) && (isObject(d.value) && ("z" in d.value || "y" in d.value) || isArray(d.value) && d.value.length === 2);
|
4822 | },
|
4823 |
|
4824 | |
4825 |
|
4826 |
|
4827 |
|
4828 |
|
4829 |
|
4830 | getDataById: function getDataById(id) {
|
4831 | var _d$,
|
4832 | d = this.cache.get(id) || this.api.data(id);
|
4833 |
|
4834 | return (_d$ = d == null ? void 0 : d[0]) != null ? _d$ : d;
|
4835 | }
|
4836 | });
|
4837 | ;
|
4838 |
|
4839 |
|
4840 |
|
4841 |
|
4842 |
|
4843 |
|
4844 | var load = ({
|
4845 | load: function load(rawTargets, args) {
|
4846 | var _args$done,
|
4847 | $$ = this,
|
4848 | append = args.append,
|
4849 | targets = rawTargets;
|
4850 |
|
4851 | if (targets) {
|
4852 |
|
4853 | if (args.filter) {
|
4854 | targets = targets.filter(args.filter);
|
4855 | }
|
4856 |
|
4857 |
|
4858 | if (args.type || args.types) {
|
4859 | targets.forEach(function (t) {
|
4860 | var _args$types,
|
4861 | type = ((_args$types = args.types) == null ? void 0 : _args$types[t.id]) || args.type;
|
4862 |
|
4863 | $$.setTargetType(t.id, type);
|
4864 | });
|
4865 | }
|
4866 |
|
4867 |
|
4868 | $$.data.targets.forEach(function (d) {
|
4869 | for (var i = 0; i < targets.length; i++) {
|
4870 | if (d.id === targets[i].id) {
|
4871 | d.values = append ? d.values.concat(targets[i].values) : targets[i].values;
|
4872 | targets.splice(i, 1);
|
4873 | break;
|
4874 | }
|
4875 | }
|
4876 | });
|
4877 | $$.data.targets = $$.data.targets.concat(targets);
|
4878 | }
|
4879 |
|
4880 |
|
4881 | $$.updateTargets($$.data.targets);
|
4882 |
|
4883 | $$.redraw({
|
4884 | withUpdateOrgXDomain: !0,
|
4885 | withUpdateXDomain: !0,
|
4886 | withLegend: !0
|
4887 | });
|
4888 |
|
4889 | $$.updateTypesElements();
|
4890 | (_args$done = args.done) == null ? void 0 : _args$done.call($$.api);
|
4891 | },
|
4892 | loadFromArgs: function loadFromArgs(args) {
|
4893 | var $$ = this;
|
4894 |
|
4895 | if (!$$.config) {
|
4896 | return;
|
4897 | }
|
4898 |
|
4899 |
|
4900 | $$.cache.reset();
|
4901 | var data = args.data || $$.convertData(args, function (d) {
|
4902 | return $$.load($$.convertDataToTargets(d), args);
|
4903 | });
|
4904 | args.append && (data.__append__ = !0);
|
4905 | data && $$.load($$.convertDataToTargets(data), args);
|
4906 | },
|
4907 | unload: function unload(rawTargetIds, customDoneCb) {
|
4908 | var $$ = this,
|
4909 | state = $$.state,
|
4910 | $el = $$.$el,
|
4911 | $T = $$.$T,
|
4912 | done = customDoneCb,
|
4913 | targetIds = rawTargetIds;
|
4914 |
|
4915 | $$.cache.reset();
|
4916 |
|
4917 | if (!done) {
|
4918 | done = function () {};
|
4919 | }
|
4920 |
|
4921 |
|
4922 | targetIds = targetIds.filter(function (id) {
|
4923 | return $$.hasTarget($$.data.targets, id);
|
4924 | });
|
4925 |
|
4926 | if (!targetIds || targetIds.length === 0) {
|
4927 | done();
|
4928 | return;
|
4929 | }
|
4930 |
|
4931 | var targets = $el.svg.selectAll(targetIds.map(function (id) {
|
4932 | return $$.selectorTarget(id);
|
4933 | }));
|
4934 | $T(targets).style("opacity", "0").remove().call(endall, done);
|
4935 | targetIds.forEach(function (id) {
|
4936 |
|
4937 | state.withoutFadeIn[id] = !1;
|
4938 |
|
4939 | if ($el.legend) {
|
4940 | $el.legend.selectAll("." + config_classes.legendItem + $$.getTargetSelectorSuffix(id)).remove();
|
4941 | }
|
4942 |
|
4943 |
|
4944 | $$.data.targets = $$.data.targets.filter(function (t) {
|
4945 | return t.id !== id;
|
4946 | });
|
4947 | });
|
4948 |
|
4949 | $$.updateTypesElements();
|
4950 | }
|
4951 | });
|
4952 |
|
4953 | var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack_require__(7);
|
4954 | ;
|
4955 |
|
4956 |
|
4957 |
|
4958 |
|
4959 |
|
4960 |
|
4961 |
|
4962 |
|
4963 |
|
4964 | var interactions_interaction = ({
|
4965 | selectRectForSingle: function selectRectForSingle(context, eventRect, index) {
|
4966 | var $$ = this,
|
4967 | config = $$.config,
|
4968 | main = $$.$el.main,
|
4969 | isSelectionEnabled = config.data_selection_enabled,
|
4970 | isSelectionGrouped = config.data_selection_grouped,
|
4971 | isSelectable = config.data_selection_isselectable,
|
4972 | isTooltipGrouped = config.tooltip_grouped,
|
4973 | selectedData = $$.getAllValuesOnIndex(index);
|
4974 |
|
4975 | if (isTooltipGrouped) {
|
4976 | $$.showTooltip(selectedData, context);
|
4977 | $$.showGridFocus == null ? void 0 : $$.showGridFocus(selectedData);
|
4978 |
|
4979 | if (!isSelectionEnabled || isSelectionGrouped) {
|
4980 | return;
|
4981 | }
|
4982 | }
|
4983 |
|
4984 | main.selectAll("." + config_classes.shape + "-" + index).each(function () {
|
4985 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.EXPANDED, !0);
|
4986 |
|
4987 | if (isSelectionEnabled) {
|
4988 | eventRect.style("cursor", isSelectionGrouped ? "pointer" : null);
|
4989 | }
|
4990 |
|
4991 | if (!isTooltipGrouped) {
|
4992 | $$.hideGridFocus == null ? void 0 : $$.hideGridFocus();
|
4993 | $$.hideTooltip();
|
4994 | isSelectionGrouped || $$.setExpand(index);
|
4995 | }
|
4996 | }).filter(function (d) {
|
4997 | return $$.isWithinShape(this, d);
|
4998 | }).call(function (selected) {
|
4999 | var _isSelectable,
|
5000 | d = selected.data();
|
5001 |
|
5002 | if (isSelectionEnabled && (isSelectionGrouped || (_isSelectable = isSelectable) != null && _isSelectable.bind($$.api)(d))) {
|
5003 | eventRect.style("cursor", "pointer");
|
5004 | }
|
5005 |
|
5006 | if (!isTooltipGrouped) {
|
5007 | $$.showTooltip(d, context);
|
5008 | $$.showGridFocus == null ? void 0 : $$.showGridFocus(d);
|
5009 | $$.unexpandCircles == null ? void 0 : $$.unexpandCircles();
|
5010 | selected.each(function (d) {
|
5011 | return $$.setExpand(index, d.id);
|
5012 | });
|
5013 | }
|
5014 | });
|
5015 | },
|
5016 |
|
5017 | |
5018 |
|
5019 |
|
5020 |
|
5021 |
|
5022 |
|
5023 |
|
5024 | setExpand: function setExpand(index, id, reset) {
|
5025 | var $$ = this,
|
5026 | config = $$.config,
|
5027 | circle = $$.$el.circle;
|
5028 | circle && config.point_focus_expand_enabled && $$.expandCircles(index, id, reset);
|
5029 |
|
5030 | $$.expandBarTypeShapes(!0, index, id, reset);
|
5031 | },
|
5032 |
|
5033 | |
5034 |
|
5035 |
|
5036 |
|
5037 |
|
5038 |
|
5039 |
|
5040 |
|
5041 | expandBarTypeShapes: function expandBarTypeShapes(expand, i, id, reset) {
|
5042 | if (expand === void 0) {
|
5043 | expand = !0;
|
5044 | }
|
5045 |
|
5046 | var $$ = this;
|
5047 | ["bar", "candlestick"].filter(function (v) {
|
5048 | return $$.$el[v];
|
5049 | }).forEach(function (v) {
|
5050 | reset && $$.$el[v].classed(config_classes.EXPANDED, !1);
|
5051 | $$.getShapeByIndex(v, i, id).classed(config_classes.EXPANDED, expand);
|
5052 | });
|
5053 | },
|
5054 |
|
5055 | |
5056 |
|
5057 |
|
5058 |
|
5059 |
|
5060 |
|
5061 | setOverOut: function setOverOut(isOver, d) {
|
5062 | var $$ = this,
|
5063 | config = $$.config,
|
5064 | hasRadar = $$.state.hasRadar,
|
5065 | main = $$.$el.main,
|
5066 | isArc = isObject(d);
|
5067 |
|
5068 |
|
5069 | if (isArc || d !== -1) {
|
5070 | var callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
|
5071 | config.color_onover && $$.setOverColor(isOver, d, isArc);
|
5072 |
|
5073 | if (isArc) {
|
5074 | callback(d, main.select("." + config_classes.arc + $$.getTargetSelectorSuffix(d.id)).node());
|
5075 | } else if (!config.tooltip_grouped) {
|
5076 | var last = $$.cache.get(KEY.setOverOut) || [],
|
5077 | shape = main.selectAll("." + config_classes.shape + "-" + d).filter(function (d) {
|
5078 | return $$.isWithinShape(this, d);
|
5079 | });
|
5080 | shape.each(function (d) {
|
5081 | var _this = this;
|
5082 |
|
5083 | if (last.length === 0 || last.every(function (v) {
|
5084 | return v !== _this;
|
5085 | })) {
|
5086 | callback(d, this);
|
5087 | last.push(this);
|
5088 | }
|
5089 | });
|
5090 |
|
5091 | if (last.length > 0 && shape.empty()) {
|
5092 | callback = config.data_onout.bind($$.api);
|
5093 | last.forEach(function (v) {
|
5094 | return callback((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(v).datum(), v);
|
5095 | });
|
5096 | last = [];
|
5097 | }
|
5098 |
|
5099 | $$.cache.add(KEY.setOverOut, last);
|
5100 | } else {
|
5101 | if (isOver) {
|
5102 | config.point_focus_only && hasRadar ? $$.showCircleFocus($$.getAllValuesOnIndex(d, !0)) : $$.setExpand(d, null, !0);
|
5103 | }
|
5104 |
|
5105 | $$.isMultipleX() || main.selectAll("." + config_classes.shape + "-" + d).each(function (d) {
|
5106 | callback(d, this);
|
5107 | });
|
5108 | }
|
5109 | }
|
5110 | },
|
5111 |
|
5112 | |
5113 |
|
5114 |
|
5115 |
|
5116 |
|
5117 | callOverOutForTouch: function callOverOutForTouch(d) {
|
5118 | var $$ = this,
|
5119 | last = $$.cache.get(KEY.callOverOutForTouch);
|
5120 |
|
5121 | if (isObject(d) && last ? d.id !== last.id : d !== last) {
|
5122 | (last || isNumber(last)) && $$.setOverOut(!1, last);
|
5123 | (d || isNumber(d)) && $$.setOverOut(!0, d);
|
5124 | $$.cache.add(KEY.callOverOutForTouch, d);
|
5125 | }
|
5126 | },
|
5127 |
|
5128 | |
5129 |
|
5130 |
|
5131 |
|
5132 |
|
5133 | getDraggableSelection: function getDraggableSelection() {
|
5134 | var $$ = this,
|
5135 | config = $$.config,
|
5136 | state = $$.state;
|
5137 | 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) {
|
5138 | state.event = event;
|
5139 | $$.drag(getPointer(event, this));
|
5140 | }).on("start", function (event) {
|
5141 | state.event = event;
|
5142 | $$.dragstart(getPointer(event, this));
|
5143 | }).on("end", function (event) {
|
5144 | state.event = event;
|
5145 | $$.dragend();
|
5146 | }) : function () {};
|
5147 | },
|
5148 |
|
5149 | |
5150 |
|
5151 |
|
5152 |
|
5153 |
|
5154 |
|
5155 |
|
5156 | dispatchEvent: function dispatchEvent(type, index, mouse) {
|
5157 | var $$ = this,
|
5158 | config = $$.config,
|
5159 | _$$$state = $$.state,
|
5160 | eventReceiver = _$$$state.eventReceiver,
|
5161 | hasAxis = _$$$state.hasAxis,
|
5162 | hasRadar = _$$$state.hasRadar,
|
5163 | _$$$$el = $$.$el,
|
5164 | eventRect = _$$$$el.eventRect,
|
5165 | arcs = _$$$$el.arcs,
|
5166 | radar = _$$$$el.radar,
|
5167 | isMultipleX = $$.isMultipleX(),
|
5168 | element = (hasRadar ? radar.axes.select("." + config_classes.axis + "-" + index + " text") : eventRect || arcs.selectAll("." + config_classes.target + " path").filter(function (d, i) {
|
5169 | return i === index;
|
5170 | })).node(),
|
5171 | _element$getBoundingC = element.getBoundingClientRect(),
|
5172 | width = _element$getBoundingC.width,
|
5173 | left = _element$getBoundingC.left,
|
5174 | top = _element$getBoundingC.top;
|
5175 |
|
5176 | if (hasAxis && !hasRadar && !isMultipleX) {
|
5177 | var coords = eventReceiver.coords[index];
|
5178 | width = coords.w;
|
5179 | left += coords.x;
|
5180 | top += coords.y;
|
5181 | }
|
5182 |
|
5183 | var x = left + (mouse ? mouse[0] : 0) + (isMultipleX || config.axis_rotated ? 0 : width / 2),
|
5184 | y = top + (mouse ? mouse[1] : 0);
|
5185 | emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](element, type, {
|
5186 | screenX: x,
|
5187 | screenY: y,
|
5188 | clientX: x,
|
5189 | clientY: y
|
5190 | });
|
5191 | },
|
5192 | setDragStatus: function setDragStatus(isDragging) {
|
5193 | this.state.dragging = isDragging;
|
5194 | },
|
5195 |
|
5196 | |
5197 |
|
5198 |
|
5199 |
|
5200 | unbindZoomEvent: function unbindZoomEvent() {
|
5201 | var _zoomResetBtn,
|
5202 | $$ = this,
|
5203 | _$$$$el2 = $$.$el,
|
5204 | eventRect = _$$$$el2.eventRect,
|
5205 | zoomResetBtn = _$$$$el2.zoomResetBtn;
|
5206 |
|
5207 | eventRect.on(".zoom", null).on(".drag", null);
|
5208 | (_zoomResetBtn = zoomResetBtn) == null ? void 0 : _zoomResetBtn.style("display", "none");
|
5209 | }
|
5210 | });
|
5211 | ;
|
5212 |
|
5213 |
|
5214 |
|
5215 |
|
5216 |
|
5217 | var internals_class = ({
|
5218 | generateClass: function generateClass(prefix, targetId) {
|
5219 | return " " + prefix + " " + (prefix + this.getTargetSelectorSuffix(targetId));
|
5220 | },
|
5221 |
|
5222 | |
5223 |
|
5224 |
|
5225 |
|
5226 |
|
5227 |
|
5228 |
|
5229 | getClass: function getClass(type, withShape) {
|
5230 | var _this = this,
|
5231 | isPlural = /s$/.test(type),
|
5232 | useIdKey = /^(area|arc|line)s?$/.test(type),
|
5233 | key = isPlural ? "id" : "index";
|
5234 |
|
5235 | return function (d) {
|
5236 | var data = d.data || d,
|
5237 | result = (withShape ? _this.generateClass(config_classes[isPlural ? "shapes" : "shape"], data[key]) : "") + _this.generateClass(config_classes[type], data[useIdKey ? "id" : key]);
|
5238 |
|
5239 | return result.trim();
|
5240 | };
|
5241 | },
|
5242 |
|
5243 | |
5244 |
|
5245 |
|
5246 |
|
5247 |
|
5248 |
|
5249 | getChartClass: function getChartClass(type) {
|
5250 | var _this2 = this;
|
5251 |
|
5252 | return function (d) {
|
5253 | return config_classes["chart" + type] + _this2.classTarget((d.data ? d.data : d).id);
|
5254 | };
|
5255 | },
|
5256 | generateExtraLineClass: function generateExtraLineClass() {
|
5257 | var $$ = this,
|
5258 | classes = $$.config.line_classes || [],
|
5259 | ids = [];
|
5260 | return function (d) {
|
5261 | var _d$data,
|
5262 | id = d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d;
|
5263 |
|
5264 | if (ids.indexOf(id) < 0) {
|
5265 | ids.push(id);
|
5266 | }
|
5267 |
|
5268 | return classes[ids.indexOf(id) % classes.length];
|
5269 | };
|
5270 | },
|
5271 | classRegion: function classRegion(d, i) {
|
5272 | return this.generateClass(config_classes.region, i) + " " + ("class" in d ? d.class : "");
|
5273 | },
|
5274 | classTarget: function classTarget(id) {
|
5275 | var additionalClassSuffix = this.config.data_classes[id],
|
5276 | additionalClass = "";
|
5277 |
|
5278 | if (additionalClassSuffix) {
|
5279 | additionalClass = " " + config_classes.target + "-" + additionalClassSuffix;
|
5280 | }
|
5281 |
|
5282 | return this.generateClass(config_classes.target, id) + additionalClass;
|
5283 | },
|
5284 | classFocus: function classFocus(d) {
|
5285 | return this.classFocused(d) + this.classDefocused(d);
|
5286 | },
|
5287 | classFocused: function classFocused(d) {
|
5288 | return " " + (this.state.focusedTargetIds.indexOf(d.id) >= 0 ? config_classes.focused : "");
|
5289 | },
|
5290 | classDefocused: function classDefocused(d) {
|
5291 | return " " + (this.state.defocusedTargetIds.indexOf(d.id) >= 0 ? config_classes.defocused : "");
|
5292 | },
|
5293 | getTargetSelectorSuffix: function getTargetSelectorSuffix(targetId) {
|
5294 | var targetStr = targetId || targetId === 0 ? "-" + targetId : "";
|
5295 | return targetStr.replace(/([\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\])/g, "-");
|
5296 | },
|
5297 | selectorTarget: function selectorTarget(id, prefix) {
|
5298 | var pfx = prefix || "",
|
5299 | target = this.getTargetSelectorSuffix(id);
|
5300 |
|
5301 | return pfx + "." + (config_classes.target + target) + ", " + pfx + "." + (config_classes.circles + target);
|
5302 | },
|
5303 | selectorTargets: function selectorTargets(idsValue, prefix) {
|
5304 | var _this3 = this,
|
5305 | ids = idsValue || [];
|
5306 |
|
5307 | return ids.length ? ids.map(function (id) {
|
5308 | return _this3.selectorTarget(id, prefix);
|
5309 | }) : null;
|
5310 | },
|
5311 | selectorLegend: function selectorLegend(id) {
|
5312 | return "." + (config_classes.legendItem + this.getTargetSelectorSuffix(id));
|
5313 | },
|
5314 | selectorLegends: function selectorLegends(ids) {
|
5315 | var _this4 = this;
|
5316 |
|
5317 | return ids != null && ids.length ? ids.map(function (id) {
|
5318 | return _this4.selectorLegend(id);
|
5319 | }) : null;
|
5320 | }
|
5321 | });
|
5322 | ;
|
5323 |
|
5324 |
|
5325 |
|
5326 |
|
5327 | var category = ({
|
5328 | |
5329 |
|
5330 |
|
5331 |
|
5332 |
|
5333 |
|
5334 | categoryName: function categoryName(i) {
|
5335 | var categories = this.config.axis_x_categories;
|
5336 | return i < (categories == null ? void 0 : categories.length) ? categories[i] : i;
|
5337 | }
|
5338 | });
|
5339 |
|
5340 | var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webpack_require__(6);
|
5341 | ;
|
5342 |
|
5343 |
|
5344 |
|
5345 |
|
5346 |
|
5347 |
|
5348 |
|
5349 |
|
5350 |
|
5351 |
|
5352 |
|
5353 |
|
5354 |
|
5355 |
|
5356 |
|
5357 |
|
5358 |
|
5359 |
|
5360 |
|
5361 |
|
5362 | var colorizePattern = function (pattern, color, id) {
|
5363 | var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(!0));
|
5364 | node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color);
|
5365 | return {
|
5366 | id: id,
|
5367 | node: node.node()
|
5368 | };
|
5369 | },
|
5370 | schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
|
5371 |
|
5372 |
|
5373 |
|
5374 | var internals_color = ({
|
5375 | |
5376 |
|
5377 |
|
5378 |
|
5379 |
|
5380 |
|
5381 | getColorFromCss: function getColorFromCss() {
|
5382 | var cacheKey = KEY.colorPattern,
|
5383 | body = browser_doc.body,
|
5384 | pattern = body[cacheKey];
|
5385 |
|
5386 | if (!pattern) {
|
5387 | var span = browser_doc.createElement("span");
|
5388 | span.className = config_classes.colorPattern;
|
5389 | span.style.display = "none";
|
5390 | body.appendChild(span);
|
5391 | var content = win.getComputedStyle(span).backgroundImage;
|
5392 | span.parentNode.removeChild(span);
|
5393 |
|
5394 | if (content.indexOf(";") > -1) {
|
5395 | pattern = content.replace(/url[^#]*|["'()]|(\s|%20)/g, "").split(";").map(function (v) {
|
5396 | return v.trim().replace(/[\"'\s]/g, "");
|
5397 | }).filter(Boolean);
|
5398 | body[cacheKey] = pattern;
|
5399 | }
|
5400 | }
|
5401 |
|
5402 | return pattern;
|
5403 | },
|
5404 | generateColor: function generateColor() {
|
5405 | var $$ = this,
|
5406 | config = $$.config,
|
5407 | colors = config.data_colors,
|
5408 | callback = config.data_color,
|
5409 | ids = [],
|
5410 | pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)($$.getColorFromCss() || schemeCategory10).range(),
|
5411 | originalColorPattern = pattern;
|
5412 |
|
5413 | if (isFunction(config.color_tiles)) {
|
5414 | var tiles = config.color_tiles.bind($$.api)(),
|
5415 | colorizedPatterns = pattern.map(function (p, index) {
|
5416 | var color = p.replace(/[#\(\)\s,]/g, ""),
|
5417 | id = $$.state.datetimeId + "-pattern-" + color + "-" + index;
|
5418 | return colorizePattern(tiles[index % tiles.length], p, id);
|
5419 | });
|
5420 |
|
5421 | pattern = colorizedPatterns.map(function (p) {
|
5422 | return "url(#" + p.id + ")";
|
5423 | });
|
5424 | $$.patterns = colorizedPatterns;
|
5425 | }
|
5426 |
|
5427 | return function (d) {
|
5428 | var _d$data,
|
5429 | id = d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d,
|
5430 | isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id],
|
5431 | color;
|
5432 |
|
5433 |
|
5434 | if (isFunction(colors[id])) {
|
5435 | color = colors[id].bind($$.api)(d);
|
5436 | } else if (colors[id]) {
|
5437 | color = colors[id];
|
5438 | } else {
|
5439 | if (ids.indexOf(id) < 0) {
|
5440 | ids.push(id);
|
5441 | }
|
5442 |
|
5443 | color = isLine ? originalColorPattern[ids.indexOf(id) % originalColorPattern.length] : pattern[ids.indexOf(id) % pattern.length];
|
5444 | colors[id] = color;
|
5445 | }
|
5446 |
|
5447 | return isFunction(callback) ? callback.bind($$.api)(color, d) : color;
|
5448 | };
|
5449 | },
|
5450 | generateLevelColor: function generateLevelColor() {
|
5451 | var $$ = this,
|
5452 | config = $$.config,
|
5453 | colors = config.color_pattern,
|
5454 | threshold = config.color_threshold,
|
5455 | asValue = threshold.unit === "value",
|
5456 | max = threshold.max || 100,
|
5457 | values = threshold.values && threshold.values.length ? threshold.values : [];
|
5458 | return notEmpty(threshold) ? function (value) {
|
5459 | var v = asValue ? value : value * 100 / max,
|
5460 | color = colors[colors.length - 1];
|
5461 |
|
5462 | for (var i = 0, l = values.length; i < l; i++) {
|
5463 | if (v <= values[i]) {
|
5464 | color = colors[i];
|
5465 | break;
|
5466 | }
|
5467 | }
|
5468 |
|
5469 | return color;
|
5470 | } : null;
|
5471 | },
|
5472 |
|
5473 | |
5474 |
|
5475 |
|
5476 |
|
5477 | generateDataLabelBackgroundColorFilter: function generateDataLabelBackgroundColorFilter() {
|
5478 | var $$ = this,
|
5479 | $el = $$.$el,
|
5480 | config = $$.config,
|
5481 | state = $$.state,
|
5482 | backgroundColors = config.data_labels_backgroundColors;
|
5483 |
|
5484 | if (backgroundColors) {
|
5485 | var ids = [];
|
5486 |
|
5487 | if (isString(backgroundColors)) {
|
5488 | ids.push("");
|
5489 | } else if (isObject(backgroundColors)) {
|
5490 | ids = Object.keys(backgroundColors);
|
5491 | }
|
5492 |
|
5493 | ids.forEach(function (v) {
|
5494 | var id = state.datetimeId + "-labels-bg" + $$.getTargetSelectorSuffix(v);
|
5495 | $el.defs.append("filter").attr("x", "0").attr("y", "0").attr("width", "1").attr("height", "1").attr("id", id).html("<feFlood flood-color=\"" + (v === "" ? backgroundColors : backgroundColors[v]) + "\" /><feComposite in=\"SourceGraphic\"/>");
|
5496 | });
|
5497 | }
|
5498 | },
|
5499 |
|
5500 | |
5501 |
|
5502 |
|
5503 |
|
5504 |
|
5505 |
|
5506 |
|
5507 | setOverColor: function setOverColor(isOver, d) {
|
5508 | var $$ = this,
|
5509 | config = $$.config,
|
5510 | main = $$.$el.main,
|
5511 | onover = config.color_onover,
|
5512 | color = isOver ? onover : $$.color;
|
5513 |
|
5514 | if (isObject(color)) {
|
5515 | color = function (_ref) {
|
5516 | var id = _ref.id;
|
5517 | return id in onover ? onover[id] : $$.color(id);
|
5518 | };
|
5519 | } else if (isString(color)) {
|
5520 | color = function () {
|
5521 | return onover;
|
5522 | };
|
5523 | } else if (isFunction(onover)) {
|
5524 | color = color.bind($$.api);
|
5525 | }
|
5526 |
|
5527 | main.selectAll(isObject(d) ?
|
5528 | "." + config_classes.arc + $$.getTargetSelectorSuffix(d.id) : "." + config_classes.shape + "-" + d).style("fill", color);
|
5529 | }
|
5530 | });
|
5531 | ;
|
5532 |
|
5533 |
|
5534 |
|
5535 |
|
5536 |
|
5537 |
|
5538 | var domain = ({
|
5539 | getYDomainMinMax: function getYDomainMinMax(targets, type) {
|
5540 | var $$ = this,
|
5541 | axis = $$.axis,
|
5542 | config = $$.config,
|
5543 | isMin = type === "min",
|
5544 | dataGroups = config.data_groups,
|
5545 | ids = $$.mapToIds(targets),
|
5546 | ys = $$.getValuesAsIdKeyed(targets);
|
5547 |
|
5548 | if (dataGroups.length > 0) {
|
5549 | var hasValue = $$["has" + (isMin ? "Negative" : "Positive") + "ValueInTargets"](targets);
|
5550 | dataGroups.forEach(function (groupIds) {
|
5551 |
|
5552 | var idsInGroup = groupIds.filter(function (v) {
|
5553 | return ids.indexOf(v) >= 0;
|
5554 | });
|
5555 |
|
5556 | if (idsInGroup.length) {
|
5557 | var baseId = idsInGroup[0],
|
5558 | baseAxisId = axis.getId(baseId);
|
5559 |
|
5560 |
|
5561 | if (hasValue && ys[baseId]) {
|
5562 | ys[baseId] = ys[baseId].map(function (v) {
|
5563 | return (isMin ? v < 0 : v > 0) ? v : 0;
|
5564 | });
|
5565 | }
|
5566 |
|
5567 | idsInGroup.filter(function (v, i) {
|
5568 | return i > 0;
|
5569 | }).forEach(function (id) {
|
5570 | if (ys[id]) {
|
5571 | var axisId = axis.getId(id);
|
5572 | ys[id].forEach(function (v, i) {
|
5573 | var val = +v,
|
5574 | meetCondition = isMin ? val > 0 : val < 0;
|
5575 |
|
5576 | if (axisId === baseAxisId && !(hasValue && meetCondition)) {
|
5577 | ys[baseId][i] += val;
|
5578 | }
|
5579 | });
|
5580 | }
|
5581 | });
|
5582 | }
|
5583 | });
|
5584 | }
|
5585 |
|
5586 | return getMinMax(type, Object.keys(ys).map(function (key) {
|
5587 | return getMinMax(type, ys[key]);
|
5588 | }));
|
5589 | },
|
5590 |
|
5591 | |
5592 |
|
5593 |
|
5594 |
|
5595 |
|
5596 |
|
5597 | isHiddenTargetWithYDomain: function isHiddenTargetWithYDomain(id) {
|
5598 | var $$ = this;
|
5599 | return $$.state.hiddenTargetIds.some(function (v) {
|
5600 | return $$.axis.getId(v) === id;
|
5601 | });
|
5602 | },
|
5603 | getYDomain: function getYDomain(targets, axisId, xDomain) {
|
5604 | var _scale,
|
5605 | $$ = this,
|
5606 | axis = $$.axis,
|
5607 | config = $$.config,
|
5608 | scale = $$.scale,
|
5609 | pfx = "axis_" + axisId;
|
5610 |
|
5611 | if ($$.isStackNormalized()) {
|
5612 | return [0, 100];
|
5613 | }
|
5614 |
|
5615 | var isLog = ((_scale = scale) == null ? void 0 : _scale[axisId]) && scale[axisId].type === "log",
|
5616 | targetsByAxisId = targets.filter(function (t) {
|
5617 | return axis.getId(t.id) === axisId;
|
5618 | }),
|
5619 | yTargets = xDomain ? $$.filterByXDomain(targetsByAxisId, xDomain) : targetsByAxisId;
|
5620 |
|
5621 | if (yTargets.length === 0) {
|
5622 |
|
5623 | if ($$.isHiddenTargetWithYDomain(axisId)) {
|
5624 | return scale[axisId].domain();
|
5625 | } else {
|
5626 | return axisId === "y2" ? scale.y.domain() :
|
5627 |
|
5628 | $$.getYDomain(targets, "y2", xDomain);
|
5629 | }
|
5630 | }
|
5631 |
|
5632 | var yMin = config[pfx + "_min"],
|
5633 | yMax = config[pfx + "_max"],
|
5634 | center = config[pfx + "_center"],
|
5635 | isInverted = config[pfx + "_inverted"],
|
5636 | showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated,
|
5637 | showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated,
|
5638 | yDomainMin = $$.getYDomainMinMax(yTargets, "min"),
|
5639 | yDomainMax = $$.getYDomainMinMax(yTargets, "max"),
|
5640 | isZeroBased = [TYPE.BAR, TYPE.BUBBLE, TYPE.SCATTER].concat(TYPE_BY_CATEGORY.Line).some(function (v) {
|
5641 | var type = v.indexOf("area") > -1 ? "area" : v;
|
5642 | return $$.hasType(v, yTargets) && config[type + "_zerobased"];
|
5643 | });
|
5644 |
|
5645 | yDomainMin = isValue(yMin) ? yMin : isValue(yMax) ? yDomainMin < yMax ? yDomainMin : yMax - 10 : yDomainMin;
|
5646 | yDomainMax = isValue(yMax) ? yMax : isValue(yMin) ? yMin < yDomainMax ? yDomainMax : yMin + 10 : yDomainMax;
|
5647 |
|
5648 | if (isNaN(yDomainMin)) {
|
5649 |
|
5650 | yDomainMin = 0;
|
5651 | }
|
5652 |
|
5653 | if (isNaN(yDomainMax)) {
|
5654 |
|
5655 | yDomainMax = yDomainMin;
|
5656 | }
|
5657 |
|
5658 | if (yDomainMin === yDomainMax) {
|
5659 | yDomainMin < 0 ? yDomainMax = 0 : yDomainMin = 0;
|
5660 | }
|
5661 |
|
5662 | var isAllPositive = yDomainMin >= 0 && yDomainMax >= 0,
|
5663 | isAllNegative = yDomainMin <= 0 && yDomainMax <= 0;
|
5664 |
|
5665 |
|
5666 | if (isValue(yMin) && isAllPositive || isValue(yMax) && isAllNegative) {
|
5667 | isZeroBased = !1;
|
5668 | }
|
5669 |
|
5670 |
|
5671 | if (isZeroBased) {
|
5672 | isAllPositive && (yDomainMin = 0);
|
5673 | isAllNegative && (yDomainMax = 0);
|
5674 | }
|
5675 |
|
5676 | var domainLength = Math.abs(yDomainMax - yDomainMin),
|
5677 | padding = {
|
5678 | top: domainLength * .1,
|
5679 | bottom: domainLength * .1
|
5680 | };
|
5681 |
|
5682 | if (isDefined(center)) {
|
5683 | var yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
|
5684 | yDomainMax = center + yDomainAbs;
|
5685 | yDomainMin = center - yDomainAbs;
|
5686 | }
|
5687 |
|
5688 |
|
5689 | if (showHorizontalDataLabel) {
|
5690 | var diff = diffDomain(scale.y.range()),
|
5691 | ratio = $$.getDataLabelLength(yDomainMin, yDomainMax, "width").map(function (v) {
|
5692 | return v / diff;
|
5693 | });
|
5694 | ["bottom", "top"].forEach(function (v, i) {
|
5695 | padding[v] += domainLength * (ratio[i] / (1 - ratio[0] - ratio[1]));
|
5696 | });
|
5697 | } else if (showVerticalDataLabel) {
|
5698 | var lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, "height");
|
5699 | ["bottom", "top"].forEach(function (v, i) {
|
5700 | padding[v] += $$.convertPixelToScale("y", lengths[i], domainLength);
|
5701 | });
|
5702 | }
|
5703 |
|
5704 |
|
5705 |
|
5706 | var p = config[pfx + "_padding"];
|
5707 |
|
5708 | if (notEmpty(p)) {
|
5709 | ["bottom", "top"].forEach(function (v) {
|
5710 | padding[v] = axis.getPadding(p, v, padding[v], domainLength);
|
5711 | });
|
5712 | }
|
5713 |
|
5714 |
|
5715 | if (isZeroBased) {
|
5716 | isAllPositive && (padding.bottom = yDomainMin);
|
5717 | isAllNegative && (padding.top = -yDomainMax);
|
5718 | }
|
5719 |
|
5720 | var domain = isLog ? [yDomainMin, yDomainMax].map(function (v) {
|
5721 | return v < 0 ? 0 : v;
|
5722 | }) : [yDomainMin - padding.bottom, yDomainMax + padding.top];
|
5723 | return isInverted ? domain.reverse() : domain;
|
5724 | },
|
5725 | getXDomainMinMax: function getXDomainMinMax(targets, type) {
|
5726 | var _$$$axis,
|
5727 | $$ = this,
|
5728 | configValue = $$.config["axis_x_" + type],
|
5729 | dataValue = getMinMax(type, targets.map(function (t) {
|
5730 | return getMinMax(type, t.values.map(function (v) {
|
5731 | return v.x;
|
5732 | }));
|
5733 | })),
|
5734 | value = isObject(configValue) ? configValue.value : configValue;
|
5735 |
|
5736 | value = isDefined(value) && (_$$$axis = $$.axis) != null && _$$$axis.isTimeSeries() ? parseDate.bind(this)(value) : value;
|
5737 |
|
5738 | if (isObject(configValue) && configValue.fit && (type === "min" && value < dataValue || type === "max" && value > dataValue)) {
|
5739 | value = undefined;
|
5740 | }
|
5741 |
|
5742 | return isDefined(value) ? value : dataValue;
|
5743 | },
|
5744 |
|
5745 | |
5746 |
|
5747 |
|
5748 |
|
5749 |
|
5750 |
|
5751 |
|
5752 | getXDomainPadding: function getXDomainPadding(domain, tickCount) {
|
5753 | var $$ = this,
|
5754 | axis = $$.axis,
|
5755 | config = $$.config,
|
5756 | padding = config.axis_x_padding,
|
5757 | isTimeSeriesTickCount = axis.isTimeSeries() && tickCount,
|
5758 | diff = diffDomain(domain),
|
5759 | defaultValue;
|
5760 |
|
5761 |
|
5762 | if (axis.isCategorized() || isTimeSeriesTickCount) {
|
5763 | defaultValue = 0;
|
5764 | } else if ($$.hasType("bar")) {
|
5765 | var maxDataCount = $$.getMaxDataCount();
|
5766 | defaultValue = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : .5;
|
5767 | } else {
|
5768 | defaultValue = diff * .01;
|
5769 | }
|
5770 |
|
5771 | var _ref = isNumber(padding) ? {
|
5772 | left: padding,
|
5773 | right: padding
|
5774 | } : padding,
|
5775 | _ref$left = _ref.left,
|
5776 | left = _ref$left === void 0 ? defaultValue : _ref$left,
|
5777 | _ref$right = _ref.right,
|
5778 | right = _ref$right === void 0 ? defaultValue : _ref$right;
|
5779 |
|
5780 |
|
5781 | if (padding.unit === "px") {
|
5782 | var domainLength = Math.abs(diff + diff * .2);
|
5783 | left = axis.getPadding(padding, "left", defaultValue, domainLength);
|
5784 | right = axis.getPadding(padding, "right", defaultValue, domainLength);
|
5785 | } else {
|
5786 | var range = diff + left + right;
|
5787 |
|
5788 | if (isTimeSeriesTickCount && range) {
|
5789 | var relativeTickWidth = diff / tickCount / range;
|
5790 | left = left / range / relativeTickWidth;
|
5791 | right = right / range / relativeTickWidth;
|
5792 | }
|
5793 | }
|
5794 |
|
5795 | return {
|
5796 | left: left,
|
5797 | right: right
|
5798 | };
|
5799 | },
|
5800 |
|
5801 | |
5802 |
|
5803 |
|
5804 |
|
5805 |
|
5806 |
|
5807 | getXDomain: function getXDomain(targets) {
|
5808 | var $$ = this,
|
5809 | axis = $$.axis,
|
5810 | x = $$.scale.x,
|
5811 | domain = [$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")],
|
5812 | _domain = domain,
|
5813 | _domain$ = _domain[0],
|
5814 | min = _domain$ === void 0 ? 0 : _domain$,
|
5815 | _domain$2 = _domain[1],
|
5816 | max = _domain$2 === void 0 ? 0 : _domain$2;
|
5817 |
|
5818 | if (x.type !== "log") {
|
5819 | var isCategorized = axis.isCategorized(),
|
5820 | isTimeSeries = axis.isTimeSeries(),
|
5821 | padding = $$.getXDomainPadding(domain),
|
5822 | _domain2 = domain,
|
5823 | firstX = _domain2[0],
|
5824 | lastX = _domain2[1];
|
5825 |
|
5826 |
|
5827 | if (firstX - lastX === 0 && !isCategorized) {
|
5828 | if (isTimeSeries) {
|
5829 | firstX = new Date(firstX.getTime() * .5);
|
5830 | lastX = new Date(lastX.getTime() * 1.5);
|
5831 | } else {
|
5832 | firstX = firstX === 0 ? 1 : firstX * .5;
|
5833 | lastX = lastX === 0 ? -1 : lastX * 1.5;
|
5834 | }
|
5835 | }
|
5836 |
|
5837 | if (firstX || firstX === 0) {
|
5838 | min = isTimeSeries ? new Date(firstX.getTime() - padding.left) : firstX - padding.left;
|
5839 | }
|
5840 |
|
5841 | if (lastX || lastX === 0) {
|
5842 | max = isTimeSeries ? new Date(lastX.getTime() + padding.right) : lastX + padding.right;
|
5843 | }
|
5844 | }
|
5845 |
|
5846 | return [min, max];
|
5847 | },
|
5848 | updateXDomain: function updateXDomain(targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
|
5849 | var $$ = this,
|
5850 | config = $$.config,
|
5851 | org = $$.org,
|
5852 | _$$$scale = $$.scale,
|
5853 | x = _$$$scale.x,
|
5854 | subX = _$$$scale.subX,
|
5855 | zoomEnabled = config.zoom_enabled;
|
5856 |
|
5857 | if (withUpdateOrgXDomain) {
|
5858 | var _$$$brush;
|
5859 |
|
5860 | x.domain(domain || sortValue($$.getXDomain(targets)));
|
5861 | org.xDomain = x.domain();
|
5862 | zoomEnabled && $$.zoom.updateScaleExtent();
|
5863 | subX.domain(x.domain());
|
5864 | (_$$$brush = $$.brush) == null ? void 0 : _$$$brush.scale(subX);
|
5865 | }
|
5866 |
|
5867 | if (withUpdateXDomain) {
|
5868 | var domainValue = domain || !$$.brush || brushEmpty($$) ? org.xDomain : getBrushSelection($$).map(subX.invert);
|
5869 | x.domain(domainValue);
|
5870 | zoomEnabled && $$.zoom.updateScaleExtent();
|
5871 | }
|
5872 |
|
5873 |
|
5874 | withTrim && x.domain($$.trimXDomain(x.orgDomain()));
|
5875 | return x.domain();
|
5876 | },
|
5877 | trimXDomain: function trimXDomain(domain) {
|
5878 | var zoomDomain = this.getZoomDomain(),
|
5879 | min = zoomDomain[0],
|
5880 | max = zoomDomain[1];
|
5881 |
|
5882 | if (domain[0] <= min) {
|
5883 | domain[1] = +domain[1] + (min - domain[0]);
|
5884 | domain[0] = min;
|
5885 | }
|
5886 |
|
5887 | if (max <= domain[1]) {
|
5888 | domain[0] = +domain[0] - (domain[1] - max);
|
5889 | domain[1] = max;
|
5890 | }
|
5891 |
|
5892 | return domain;
|
5893 | },
|
5894 |
|
5895 | |
5896 |
|
5897 |
|
5898 |
|
5899 |
|
5900 | getZoomDomain: function getZoomDomain() {
|
5901 | var $$ = this,
|
5902 | config = $$.config,
|
5903 | org = $$.org,
|
5904 | _org$xDomain = org.xDomain,
|
5905 | min = _org$xDomain[0],
|
5906 | max = _org$xDomain[1];
|
5907 |
|
5908 | if (isDefined(config.zoom_x_min)) {
|
5909 | min = getMinMax("min", [min, config.zoom_x_min]);
|
5910 | }
|
5911 |
|
5912 | if (isDefined(config.zoom_x_max)) {
|
5913 | max = getMinMax("max", [max, config.zoom_x_max]);
|
5914 | }
|
5915 |
|
5916 | return [min, max];
|
5917 | },
|
5918 |
|
5919 | |
5920 |
|
5921 |
|
5922 |
|
5923 |
|
5924 |
|
5925 |
|
5926 |
|
5927 | convertPixelToScale: function convertPixelToScale(type, pixels, domainLength) {
|
5928 | var $$ = this,
|
5929 | config = $$.config,
|
5930 | state = $$.state,
|
5931 | isRotated = config.axis_rotated,
|
5932 | length;
|
5933 |
|
5934 | if (type === "x") {
|
5935 | length = isRotated ? "height" : "width";
|
5936 | } else {
|
5937 | length = isRotated ? "width" : "height";
|
5938 | }
|
5939 |
|
5940 | return domainLength * (pixels / state[length]);
|
5941 | }
|
5942 | });
|
5943 | ;
|
5944 |
|
5945 |
|
5946 |
|
5947 |
|
5948 |
|
5949 |
|
5950 |
|
5951 |
|
5952 |
|
5953 |
|
5954 |
|
5955 |
|
5956 |
|
5957 |
|
5958 | function getFormat($$, typeValue, v) {
|
5959 | var config = $$.config,
|
5960 | type = "axis_" + typeValue + "_tick_format",
|
5961 | format = config[type] ? config[type] : $$.defaultValueFormat;
|
5962 | return format(v);
|
5963 | }
|
5964 |
|
5965 | var format = ({
|
5966 | yFormat: function yFormat(v) {
|
5967 | return getFormat(this, "y", v);
|
5968 | },
|
5969 | y2Format: function y2Format(v) {
|
5970 | return getFormat(this, "y2", v);
|
5971 | },
|
5972 |
|
5973 | |
5974 |
|
5975 |
|
5976 |
|
5977 |
|
5978 | getDefaultValueFormat: function getDefaultValueFormat() {
|
5979 | var $$ = this,
|
5980 | hasArc = $$.hasArcType();
|
5981 | return hasArc && !$$.hasType("gauge") ? $$.defaultArcValueFormat : $$.defaultValueFormat;
|
5982 | },
|
5983 | defaultValueFormat: function defaultValueFormat(v) {
|
5984 | return isValue(v) ? +v : "";
|
5985 | },
|
5986 | defaultArcValueFormat: function defaultArcValueFormat(v, ratio) {
|
5987 | return (ratio * 100).toFixed(1) + "%";
|
5988 | },
|
5989 | dataLabelFormat: function dataLabelFormat(targetId) {
|
5990 | var $$ = this,
|
5991 | dataLabels = $$.config.data_labels,
|
5992 | defaultFormat = function (v) {
|
5993 | return isValue(v) ? +v : "";
|
5994 | },
|
5995 | format = defaultFormat;
|
5996 |
|
5997 |
|
5998 | if (isFunction(dataLabels.format)) {
|
5999 | format = dataLabels.format;
|
6000 | } else if (isObjectType(dataLabels.format)) {
|
6001 | if (dataLabels.format[targetId]) {
|
6002 | format = dataLabels.format[targetId] === !0 ? defaultFormat : dataLabels.format[targetId];
|
6003 | } else {
|
6004 | format = function () {
|
6005 | return "";
|
6006 | };
|
6007 | }
|
6008 | }
|
6009 |
|
6010 | return format.bind($$.api);
|
6011 | }
|
6012 | });
|
6013 | ;
|
6014 |
|
6015 |
|
6016 |
|
6017 |
|
6018 |
|
6019 |
|
6020 |
|
6021 |
|
6022 |
|
6023 | var internals_legend = ({
|
6024 | |
6025 |
|
6026 |
|
6027 |
|
6028 | initLegend: function initLegend() {
|
6029 | var $$ = this,
|
6030 | config = $$.config,
|
6031 | $el = $$.$el;
|
6032 | $$.legendItemTextBox = {};
|
6033 | $$.state.legendHasRendered = !1;
|
6034 |
|
6035 | if (config.legend_show) {
|
6036 | if (!config.legend_contents_bindto) {
|
6037 | $el.legend = $$.$el.svg.append("g").classed(config_classes.legend, !0).attr("transform", $$.getTranslate("legend"));
|
6038 | }
|
6039 |
|
6040 |
|
6041 |
|
6042 | $$.updateLegend();
|
6043 | } else {
|
6044 | $$.state.hiddenLegendIds = $$.mapToIds($$.data.targets);
|
6045 | }
|
6046 | },
|
6047 |
|
6048 | |
6049 |
|
6050 |
|
6051 |
|
6052 |
|
6053 |
|
6054 |
|
6055 | updateLegend: function updateLegend(targetIds, options, transitions) {
|
6056 | var $$ = this,
|
6057 | config = $$.config,
|
6058 | state = $$.state,
|
6059 | scale = $$.scale,
|
6060 | $el = $$.$el,
|
6061 | optionz = options || {
|
6062 | withTransform: !1,
|
6063 | withTransitionForTransform: !1,
|
6064 | withTransition: !1
|
6065 | };
|
6066 | optionz.withTransition = getOption(optionz, "withTransition", !0);
|
6067 | optionz.withTransitionForTransform = getOption(optionz, "withTransitionForTransform", !0);
|
6068 |
|
6069 | if (config.legend_contents_bindto && config.legend_contents_template) {
|
6070 | $$.updateLegendTemplate();
|
6071 | } else {
|
6072 | $$.updateLegendElement(targetIds || $$.mapToIds($$.data.targets), optionz, transitions);
|
6073 | }
|
6074 |
|
6075 |
|
6076 | $el.legend.selectAll("." + config_classes.legendItem).classed(config_classes.legendItemHidden, function (id) {
|
6077 | var hide = !$$.isTargetToShow(id);
|
6078 |
|
6079 | if (hide) {
|
6080 | this.style.opacity = null;
|
6081 | }
|
6082 |
|
6083 | return hide;
|
6084 | });
|
6085 |
|
6086 | $$.updateScales(!1, !scale.zoom);
|
6087 | $$.updateSvgSize();
|
6088 |
|
6089 | $$.transformAll(optionz.withTransitionForTransform, transitions);
|
6090 | state.legendHasRendered = !0;
|
6091 | },
|
6092 |
|
6093 | |
6094 |
|
6095 |
|
6096 |
|
6097 | updateLegendTemplate: function updateLegendTemplate() {
|
6098 | var $$ = this,
|
6099 | config = $$.config,
|
6100 | $el = $$.$el,
|
6101 | wrapper = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.legend_contents_bindto),
|
6102 | template = config.legend_contents_template;
|
6103 |
|
6104 | if (!wrapper.empty()) {
|
6105 | var targets = $$.mapToIds($$.data.targets),
|
6106 | ids = [],
|
6107 | html = "";
|
6108 | targets.forEach(function (v) {
|
6109 | var content = isFunction(template) ? template.bind($$.api)(v, $$.color(v), $$.api.data(v)[0].values) : tplProcess(template, {
|
6110 | COLOR: $$.color(v),
|
6111 | TITLE: v
|
6112 | });
|
6113 |
|
6114 | if (content) {
|
6115 | ids.push(v);
|
6116 | html += content;
|
6117 | }
|
6118 | });
|
6119 | var legendItem = wrapper.html(html).selectAll(function () {
|
6120 | return this.childNodes;
|
6121 | }).data(ids);
|
6122 | $$.setLegendItem(legendItem);
|
6123 | $el.legend = wrapper;
|
6124 | }
|
6125 | },
|
6126 |
|
6127 | |
6128 |
|
6129 |
|
6130 |
|
6131 |
|
6132 | updateSizeForLegend: function updateSizeForLegend(size) {
|
6133 | var $$ = this,
|
6134 | config = $$.config,
|
6135 | _$$$state = $$.state,
|
6136 | isLegendTop = _$$$state.isLegendTop,
|
6137 | isLegendLeft = _$$$state.isLegendLeft,
|
6138 | isLegendRight = _$$$state.isLegendRight,
|
6139 | isLegendInset = _$$$state.isLegendInset,
|
6140 | current = _$$$state.current,
|
6141 | width = size.width,
|
6142 | height = size.height,
|
6143 | insetLegendPosition = {
|
6144 | top: isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : current.height - height - $$.getCurrentPaddingBottom() - config.legend_inset_y,
|
6145 | left: isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + .5 : current.width - width - $$.getCurrentPaddingRight() - config.legend_inset_x + .5
|
6146 | };
|
6147 | $$.state.margin3 = {
|
6148 | top: isLegendRight ? 0 : isLegendInset ? insetLegendPosition.top : current.height - height,
|
6149 | right: NaN,
|
6150 | bottom: 0,
|
6151 | left: isLegendRight ? current.width - width : isLegendInset ? insetLegendPosition.left : 0
|
6152 | };
|
6153 | },
|
6154 |
|
6155 | |
6156 |
|
6157 |
|
6158 |
|
6159 |
|
6160 | transformLegend: function transformLegend(withTransition) {
|
6161 | var $$ = this,
|
6162 | legend = $$.$el.legend,
|
6163 | $T = $$.$T;
|
6164 | $T(legend, withTransition).attr("transform", $$.getTranslate("legend"));
|
6165 | },
|
6166 |
|
6167 | |
6168 |
|
6169 |
|
6170 |
|
6171 |
|
6172 | updateLegendStep: function updateLegendStep(step) {
|
6173 | this.state.legendStep = step;
|
6174 | },
|
6175 |
|
6176 | |
6177 |
|
6178 |
|
6179 |
|
6180 |
|
6181 | updateLegendItemWidth: function updateLegendItemWidth(width) {
|
6182 | this.state.legendItemWidth = width;
|
6183 | },
|
6184 |
|
6185 | |
6186 |
|
6187 |
|
6188 |
|
6189 |
|
6190 | updateLegendItemHeight: function updateLegendItemHeight(height) {
|
6191 | this.state.legendItemHeight = height;
|
6192 | },
|
6193 |
|
6194 | |
6195 |
|
6196 |
|
6197 |
|
6198 |
|
6199 |
|
6200 | updateLegendItemColor: function updateLegendItemColor(id, color) {
|
6201 | var legend = this.$el.legend;
|
6202 |
|
6203 | if (legend) {
|
6204 | legend.select("." + config_classes.legendItem + "-" + id + " line").style("stroke", color);
|
6205 | }
|
6206 | },
|
6207 |
|
6208 | |
6209 |
|
6210 |
|
6211 |
|
6212 |
|
6213 | getLegendWidth: function getLegendWidth() {
|
6214 | var $$ = this,
|
6215 | _$$$state2 = $$.state,
|
6216 | width = _$$$state2.current.width,
|
6217 | isLegendRight = _$$$state2.isLegendRight,
|
6218 | isLegendInset = _$$$state2.isLegendInset,
|
6219 | legendItemWidth = _$$$state2.legendItemWidth,
|
6220 | legendStep = _$$$state2.legendStep;
|
6221 | return $$.config.legend_show ? isLegendRight || isLegendInset ? legendItemWidth * (legendStep + 1) : width : 0;
|
6222 | },
|
6223 |
|
6224 | |
6225 |
|
6226 |
|
6227 |
|
6228 |
|
6229 | getLegendHeight: function getLegendHeight() {
|
6230 | var $$ = this,
|
6231 | _$$$state3 = $$.state,
|
6232 | current = _$$$state3.current,
|
6233 | isLegendRight = _$$$state3.isLegendRight,
|
6234 | legendItemHeight = _$$$state3.legendItemHeight,
|
6235 | legendStep = _$$$state3.legendStep;
|
6236 | return $$.config.legend_show ? isLegendRight ? current.height : Math.max(20, legendItemHeight) * (legendStep + 1) : 0;
|
6237 | },
|
6238 |
|
6239 | |
6240 |
|
6241 |
|
6242 |
|
6243 |
|
6244 |
|
6245 | opacityForUnfocusedLegend: function opacityForUnfocusedLegend(legendItem) {
|
6246 | return legendItem.classed(config_classes.legendItemHidden) ? null : "0.3";
|
6247 | },
|
6248 |
|
6249 | |
6250 |
|
6251 |
|
6252 |
|
6253 |
|
6254 |
|
6255 | toggleFocusLegend: function toggleFocusLegend(targetIds, focus) {
|
6256 | var $$ = this,
|
6257 | legend = $$.$el.legend,
|
6258 | $T = $$.$T,
|
6259 | targetIdz = $$.mapToTargetIds(targetIds);
|
6260 | legend && $T(legend.selectAll("." + config_classes.legendItem).filter(function (id) {
|
6261 | return targetIdz.indexOf(id) >= 0;
|
6262 | }).classed(config_classes.legendItemFocused, focus)).style("opacity", function () {
|
6263 | return focus ? null : $$.opacityForUnfocusedLegend.call($$, (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this));
|
6264 | });
|
6265 | },
|
6266 |
|
6267 | |
6268 |
|
6269 |
|
6270 |
|
6271 | revertLegend: function revertLegend() {
|
6272 | var $$ = this,
|
6273 | legend = $$.$el.legend,
|
6274 | $T = $$.$T;
|
6275 | legend && $T(legend.selectAll("." + config_classes.legendItem).classed(config_classes.legendItemFocused, !1)).style("opacity", null);
|
6276 | },
|
6277 |
|
6278 | |
6279 |
|
6280 |
|
6281 |
|
6282 |
|
6283 | showLegend: function showLegend(targetIds) {
|
6284 | var $$ = this,
|
6285 | config = $$.config,
|
6286 | $el = $$.$el,
|
6287 | $T = $$.$T;
|
6288 |
|
6289 | if (!config.legend_show) {
|
6290 | config.legend_show = !0;
|
6291 | $el.legend ? $el.legend.style("visibility", null) : $$.initLegend();
|
6292 | $$.state.legendHasRendered || $$.updateLegend();
|
6293 | }
|
6294 |
|
6295 | $$.removeHiddenLegendIds(targetIds);
|
6296 | $T($el.legend.selectAll($$.selectorLegends(targetIds)).style("visibility", null)).style("opacity", null);
|
6297 | },
|
6298 |
|
6299 | |
6300 |
|
6301 |
|
6302 |
|
6303 |
|
6304 | hideLegend: function hideLegend(targetIds) {
|
6305 | var $$ = this,
|
6306 | config = $$.config,
|
6307 | legend = $$.$el.legend;
|
6308 |
|
6309 | if (config.legend_show && isEmpty(targetIds)) {
|
6310 | config.legend_show = !1;
|
6311 | legend.style("visibility", "hidden");
|
6312 | }
|
6313 |
|
6314 | $$.addHiddenLegendIds(targetIds);
|
6315 | legend.selectAll($$.selectorLegends(targetIds)).style("opacity", "0").style("visibility", "hidden");
|
6316 | },
|
6317 |
|
6318 | |
6319 |
|
6320 |
|
6321 |
|
6322 |
|
6323 |
|
6324 |
|
6325 | getLegendItemTextBox: function getLegendItemTextBox(id, textElement) {
|
6326 | var $$ = this,
|
6327 | cache = $$.cache,
|
6328 | state = $$.state,
|
6329 | data,
|
6330 | cacheKey = KEY.legendItemTextBox;
|
6331 |
|
6332 | if (id) {
|
6333 | data = !state.redrawing && cache.get(cacheKey) || {};
|
6334 |
|
6335 | if (!data[id]) {
|
6336 | data[id] = $$.getTextRect(textElement, config_classes.legendItem);
|
6337 | cache.add(cacheKey, data);
|
6338 | }
|
6339 |
|
6340 | data = data[id];
|
6341 | }
|
6342 |
|
6343 | return data;
|
6344 | },
|
6345 |
|
6346 | |
6347 |
|
6348 |
|
6349 |
|
6350 |
|
6351 | setLegendItem: function setLegendItem(item) {
|
6352 | var $$ = this,
|
6353 | api = $$.api,
|
6354 | config = $$.config,
|
6355 | state = $$.state,
|
6356 | isTouch = state.inputType === "touch",
|
6357 | hasGauge = $$.hasType("gauge");
|
6358 | item.attr("class", function (id) {
|
6359 | var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
6360 | itemClass = !node.empty() && node.attr("class") || "";
|
6361 | return itemClass + $$.generateClass(config_classes.legendItem, id);
|
6362 | }).style("visibility", function (id) {
|
6363 | return $$.isLegendToShow(id) ? null : "hidden";
|
6364 | });
|
6365 |
|
6366 | if (config.interaction_enabled) {
|
6367 | item.style("cursor", "pointer").on("click", function (event, id) {
|
6368 | if (!callFn(config.legend_item_onclick, api, id)) {
|
6369 | if (event.altKey) {
|
6370 | api.hide();
|
6371 | api.show(id);
|
6372 | } else {
|
6373 | api.toggle(id);
|
6374 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused, !1);
|
6375 | }
|
6376 | }
|
6377 |
|
6378 | isTouch && $$.hideTooltip();
|
6379 | });
|
6380 | isTouch || item.on("mouseout", function (event, id) {
|
6381 | if (!callFn(config.legend_item_onout, api, id)) {
|
6382 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused, !1);
|
6383 |
|
6384 | if (hasGauge) {
|
6385 | $$.undoMarkOverlapped($$, "." + config_classes.gaugeValue);
|
6386 | }
|
6387 |
|
6388 | $$.api.revert();
|
6389 | }
|
6390 | }).on("mouseover", function (event, id) {
|
6391 | if (!callFn(config.legend_item_onover, api, id)) {
|
6392 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused, !0);
|
6393 |
|
6394 | if (hasGauge) {
|
6395 | $$.markOverlapped(id, $$, "." + config_classes.gaugeValue);
|
6396 | }
|
6397 |
|
6398 | if (!state.transiting && $$.isTargetToShow(id)) {
|
6399 | api.focus(id);
|
6400 | }
|
6401 | }
|
6402 | });
|
6403 | }
|
6404 | },
|
6405 |
|
6406 | |
6407 |
|
6408 |
|
6409 |
|
6410 |
|
6411 |
|
6412 | updateLegendElement: function updateLegendElement(targetIds, options) {
|
6413 | var $$ = this,
|
6414 | config = $$.config,
|
6415 | state = $$.state,
|
6416 | legend = $$.$el.legend,
|
6417 | $T = $$.$T,
|
6418 | posMin = 10,
|
6419 | tileWidth = config.legend_item_tile_width + 5,
|
6420 | maxWidth = 0,
|
6421 | maxHeight = 0,
|
6422 | xForLegend,
|
6423 | yForLegend,
|
6424 | totalLength = 0,
|
6425 | offsets = {},
|
6426 | widths = {},
|
6427 | heights = {},
|
6428 | margins = [0],
|
6429 | steps = {},
|
6430 | step = 0,
|
6431 | background,
|
6432 | isLegendRightOrInset = state.isLegendRight || state.isLegendInset,
|
6433 | targetIdz = targetIds.filter(function (id) {
|
6434 | return !isDefined(config.data_names[id]) || config.data_names[id] !== null;
|
6435 | }),
|
6436 | withTransition = options.withTransition,
|
6437 | updatePositions = function (textElement, id, index) {
|
6438 | var isLast = index === targetIdz.length - 1,
|
6439 | box = $$.getLegendItemTextBox(id, textElement),
|
6440 | itemWidth = box.width + tileWidth + (isLast && !isLegendRightOrInset ? 0 : 10) + config.legend_padding,
|
6441 | itemHeight = box.height + 4,
|
6442 | itemLength = isLegendRightOrInset ? itemHeight : itemWidth,
|
6443 | areaLength = isLegendRightOrInset ? $$.getLegendHeight() : $$.getLegendWidth(),
|
6444 | margin,
|
6445 | updateValues = function (id2, withoutStep) {
|
6446 | if (!withoutStep) {
|
6447 | margin = (areaLength - totalLength - itemLength) / 2;
|
6448 |
|
6449 | if (margin < posMin) {
|
6450 | margin = (areaLength - itemLength) / 2;
|
6451 | totalLength = 0;
|
6452 | step++;
|
6453 | }
|
6454 | }
|
6455 |
|
6456 | steps[id2] = step;
|
6457 | margins[step] = state.isLegendInset ? 10 : margin;
|
6458 | offsets[id2] = totalLength;
|
6459 | totalLength += itemLength;
|
6460 | };
|
6461 |
|
6462 | if (index === 0) {
|
6463 | totalLength = 0;
|
6464 | step = 0;
|
6465 | maxWidth = 0;
|
6466 | maxHeight = 0;
|
6467 | }
|
6468 |
|
6469 | if (config.legend_show && !$$.isLegendToShow(id)) {
|
6470 | widths[id] = 0;
|
6471 | heights[id] = 0;
|
6472 | steps[id] = 0;
|
6473 | offsets[id] = 0;
|
6474 | return;
|
6475 | }
|
6476 |
|
6477 | widths[id] = itemWidth;
|
6478 | heights[id] = itemHeight;
|
6479 |
|
6480 | if (!maxWidth || itemWidth >= maxWidth) {
|
6481 | maxWidth = itemWidth;
|
6482 | }
|
6483 |
|
6484 | if (!maxHeight || itemHeight >= maxHeight) {
|
6485 | maxHeight = itemHeight;
|
6486 | }
|
6487 |
|
6488 | var maxLength = isLegendRightOrInset ? maxHeight : maxWidth;
|
6489 |
|
6490 | if (config.legend_equally) {
|
6491 | Object.keys(widths).forEach(function (id2) {
|
6492 | return widths[id2] = maxWidth;
|
6493 | });
|
6494 | Object.keys(heights).forEach(function (id2) {
|
6495 | return heights[id2] = maxHeight;
|
6496 | });
|
6497 | margin = (areaLength - maxLength * targetIdz.length) / 2;
|
6498 |
|
6499 | if (margin < posMin) {
|
6500 | totalLength = 0;
|
6501 | step = 0;
|
6502 | targetIdz.forEach(function (id2) {
|
6503 | return updateValues(id2);
|
6504 | });
|
6505 | } else {
|
6506 | updateValues(id, !0);
|
6507 | }
|
6508 | } else {
|
6509 | updateValues(id);
|
6510 | }
|
6511 | };
|
6512 |
|
6513 | if (state.isLegendInset) {
|
6514 | step = config.legend_inset_step ? config.legend_inset_step : targetIdz.length;
|
6515 | $$.updateLegendStep(step);
|
6516 | }
|
6517 |
|
6518 | if (state.isLegendRight) {
|
6519 | xForLegend = function (id) {
|
6520 | return maxWidth * steps[id];
|
6521 | };
|
6522 |
|
6523 | yForLegend = function (id) {
|
6524 | return margins[steps[id]] + offsets[id];
|
6525 | };
|
6526 | } else if (state.isLegendInset) {
|
6527 | xForLegend = function (id) {
|
6528 | return maxWidth * steps[id] + 10;
|
6529 | };
|
6530 |
|
6531 | yForLegend = function (id) {
|
6532 | return margins[steps[id]] + offsets[id];
|
6533 | };
|
6534 | } else {
|
6535 | xForLegend = function (id) {
|
6536 | return margins[steps[id]] + offsets[id];
|
6537 | };
|
6538 |
|
6539 | yForLegend = function (id) {
|
6540 | return maxHeight * steps[id];
|
6541 | };
|
6542 | }
|
6543 |
|
6544 | var xForLegendText = function (id, i) {
|
6545 | return xForLegend(id, i) + 4 + config.legend_item_tile_width;
|
6546 | },
|
6547 | xForLegendRect = function (id, i) {
|
6548 | return xForLegend(id, i);
|
6549 | },
|
6550 | x1ForLegendTile = function (id, i) {
|
6551 | return xForLegend(id, i) - 2;
|
6552 | },
|
6553 | x2ForLegendTile = function (id, i) {
|
6554 | return xForLegend(id, i) - 2 + config.legend_item_tile_width;
|
6555 | },
|
6556 | yForLegendText = function (id, i) {
|
6557 | return yForLegend(id, i) + 9;
|
6558 | },
|
6559 | yForLegendRect = function (id, i) {
|
6560 | return yForLegend(id, i) - 5;
|
6561 | },
|
6562 | yForLegendTile = function (id, i) {
|
6563 | return yForLegend(id, i) + 4;
|
6564 | },
|
6565 | pos = -200,
|
6566 | l = legend.selectAll("." + config_classes.legendItem).data(targetIdz).enter().append("g");
|
6567 |
|
6568 | $$.setLegendItem(l);
|
6569 | l.append("text").text(function (id) {
|
6570 | return isDefined(config.data_names[id]) ? config.data_names[id] : id;
|
6571 | }).each(function (id, i) {
|
6572 | updatePositions(this, id, i);
|
6573 | }).style("pointer-events", "none").attr("x", isLegendRightOrInset ? xForLegendText : pos).attr("y", isLegendRightOrInset ? pos : yForLegendText);
|
6574 | l.append("rect").attr("class", config_classes.legendItemEvent).style("fill-opacity", "0").attr("x", isLegendRightOrInset ? xForLegendRect : pos).attr("y", isLegendRightOrInset ? pos : yForLegendRect);
|
6575 |
|
6576 | var getColor = function (id) {
|
6577 | var data = $$.getDataById(id);
|
6578 | return $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
|
6579 | },
|
6580 | usePoint = config.legend_usePoint;
|
6581 |
|
6582 | if (usePoint) {
|
6583 | var ids = [];
|
6584 | l.append(function (d) {
|
6585 | var pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
|
6586 | ids.indexOf(d) === -1 && ids.push(d);
|
6587 | var point = pattern[ids.indexOf(d) % pattern.length];
|
6588 |
|
6589 | if (point === "rectangle") {
|
6590 | point = "rect";
|
6591 | }
|
6592 |
|
6593 | return browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, "hasValidPointType" in $$ && $$.hasValidPointType(point) ? point : "use");
|
6594 | }).attr("class", config_classes.legendItemPoint).style("fill", getColor).style("pointer-events", "none").attr("href", function (data, idx, selection) {
|
6595 | var node = selection[idx],
|
6596 | nodeName = node.nodeName.toLowerCase(),
|
6597 | id = $$.getTargetSelectorSuffix(data);
|
6598 | return nodeName === "use" ? "#" + state.datetimeId + "-point" + id : undefined;
|
6599 | });
|
6600 | } else {
|
6601 | l.append("line").attr("class", config_classes.legendItemTile).style("stroke", getColor).style("pointer-events", "none").attr("x1", isLegendRightOrInset ? x1ForLegendTile : pos).attr("y1", isLegendRightOrInset ? pos : yForLegendTile).attr("x2", isLegendRightOrInset ? x2ForLegendTile : pos).attr("y2", isLegendRightOrInset ? pos : yForLegendTile).attr("stroke-width", config.legend_item_tile_height);
|
6602 | }
|
6603 |
|
6604 |
|
6605 | background = legend.select("." + config_classes.legendBackground + " rect");
|
6606 |
|
6607 | if (state.isLegendInset && maxWidth > 0 && background.size() === 0) {
|
6608 | background = legend.insert("g", "." + config_classes.legendItem).attr("class", config_classes.legendBackground).append("rect");
|
6609 | }
|
6610 |
|
6611 | var texts = legend.selectAll("text").data(targetIdz).text(function (id) {
|
6612 | return isDefined(config.data_names[id]) ? config.data_names[id] : id;
|
6613 | })
|
6614 | .each(function (id, i) {
|
6615 | updatePositions(this, id, i);
|
6616 | });
|
6617 | $T(texts, withTransition).attr("x", xForLegendText).attr("y", yForLegendText);
|
6618 | var rects = legend.selectAll("rect." + config_classes.legendItemEvent).data(targetIdz);
|
6619 | $T(rects, withTransition).attr("width", function (id) {
|
6620 | return widths[id];
|
6621 | }).attr("height", function (id) {
|
6622 | return heights[id];
|
6623 | }).attr("x", xForLegendRect).attr("y", yForLegendRect);
|
6624 |
|
6625 | if (usePoint) {
|
6626 | var tiles = legend.selectAll("." + config_classes.legendItemPoint).data(targetIdz);
|
6627 | $T(tiles, withTransition).each(function () {
|
6628 | var nodeName = this.nodeName.toLowerCase(),
|
6629 | pointR = config.point_r,
|
6630 | x = "x",
|
6631 | y = "y",
|
6632 | xOffset = 2,
|
6633 | yOffset = 2.5,
|
6634 | radius,
|
6635 | width,
|
6636 | height;
|
6637 |
|
6638 | if (nodeName === "circle") {
|
6639 | var size = pointR * .2;
|
6640 | x = "cx";
|
6641 | y = "cy";
|
6642 | radius = pointR + size;
|
6643 | xOffset = pointR * 2;
|
6644 | yOffset = -size;
|
6645 | } else if (nodeName === "rect") {
|
6646 | var _size = pointR * 2.5;
|
6647 |
|
6648 | width = _size;
|
6649 | height = _size;
|
6650 | yOffset = 3;
|
6651 | }
|
6652 |
|
6653 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).attr(x, function (d) {
|
6654 | return x1ForLegendTile(d) + xOffset;
|
6655 | }).attr(y, function (d) {
|
6656 | return yForLegendTile(d) - yOffset;
|
6657 | }).attr("r", radius).attr("width", width).attr("height", height);
|
6658 | });
|
6659 | } else {
|
6660 | var _tiles = legend.selectAll("line." + config_classes.legendItemTile).data(targetIdz);
|
6661 |
|
6662 | $T(_tiles, withTransition).style("stroke", getColor).attr("x1", x1ForLegendTile).attr("y1", yForLegendTile).attr("x2", x2ForLegendTile).attr("y2", yForLegendTile);
|
6663 | }
|
6664 |
|
6665 | if (background) {
|
6666 | $T(background, withTransition).attr("height", $$.getLegendHeight() - 12).attr("width", maxWidth * (step + 1) + 10);
|
6667 | }
|
6668 |
|
6669 |
|
6670 | $$.updateLegendItemWidth(maxWidth);
|
6671 | $$.updateLegendItemHeight(maxHeight);
|
6672 | $$.updateLegendStep(step);
|
6673 | }
|
6674 | });
|
6675 |
|
6676 | var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_ = __webpack_require__(8);
|
6677 | ;
|
6678 |
|
6679 |
|
6680 |
|
6681 |
|
6682 |
|
6683 |
|
6684 |
|
6685 |
|
6686 | var redraw = ({
|
6687 | redraw: function redraw(options) {
|
6688 | var _$$$axis;
|
6689 |
|
6690 | if (options === void 0) {
|
6691 | options = {};
|
6692 | }
|
6693 |
|
6694 | var $$ = this,
|
6695 | config = $$.config,
|
6696 | state = $$.state,
|
6697 | $el = $$.$el,
|
6698 | main = $el.main;
|
6699 | state.redrawing = !0;
|
6700 | var targetsToShow = $$.filterTargetsToShow($$.data.targets),
|
6701 | _options = options,
|
6702 | flow = _options.flow,
|
6703 | initializing = _options.initializing,
|
6704 | wth = $$.getWithOption(options),
|
6705 | duration = wth.Transition ? config.transition_duration : 0,
|
6706 | durationForExit = wth.TransitionForExit ? duration : 0,
|
6707 | durationForAxis = wth.TransitionForAxis ? duration : 0,
|
6708 | transitions = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.generateTransitions(durationForAxis);
|
6709 | $$.updateSizes(initializing);
|
6710 |
|
6711 | if (wth.Legend && config.legend_show) {
|
6712 | options.withTransition = !!duration;
|
6713 | $$.updateLegend($$.mapToIds($$.data.targets), options, transitions);
|
6714 | } else if (wth.Dimension) {
|
6715 |
|
6716 |
|
6717 | $$.updateDimension(!0);
|
6718 | }
|
6719 |
|
6720 |
|
6721 | if (!$$.hasArcType() || state.hasRadar) {
|
6722 | $$.updateCircleY && ($$.circleY = $$.updateCircleY());
|
6723 | }
|
6724 |
|
6725 |
|
6726 | if (state.hasAxis) {
|
6727 |
|
6728 | $$.axis.redrawAxis(targetsToShow, wth, transitions, flow, initializing);
|
6729 |
|
6730 | config.data_empty_label_text && main.select("text." + config_classes.text + "." + config_classes.empty).attr("x", state.width / 2).attr("y", state.height / 2).text(config.data_empty_label_text).style("display", targetsToShow.length ? "none" : null);
|
6731 |
|
6732 | $$.hasGrid() && $$.updateGrid();
|
6733 |
|
6734 | config.regions.length && $$.updateRegion();
|
6735 | ["bar", "candlestick", "line", "area"].forEach(function (v) {
|
6736 | var name = capitalize(v);
|
6737 |
|
6738 | if (/^(line|area)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
|
6739 | $$["update" + name](wth.TransitionForExit);
|
6740 | }
|
6741 | });
|
6742 |
|
6743 | $el.text && main.selectAll("." + config_classes.selectedCircles).filter($$.isBarType.bind($$)).selectAll("circle").remove();
|
6744 |
|
6745 | if (config.interaction_enabled && !flow && wth.EventRect) {
|
6746 | $$.redrawEventRect();
|
6747 | $$.bindZoomEvent == null ? void 0 : $$.bindZoomEvent();
|
6748 | }
|
6749 | } else {
|
6750 |
|
6751 | $el.arcs && $$.redrawArc(duration, durationForExit, wth.Transform);
|
6752 |
|
6753 | $el.radar && $$.redrawRadar();
|
6754 | }
|
6755 |
|
6756 |
|
6757 | if (!state.resizing && ($$.hasPointType() || state.hasRadar)) {
|
6758 | $$.updateCircle();
|
6759 | }
|
6760 |
|
6761 |
|
6762 | $$.hasDataLabel() && !$$.hasArcType(null, ["radar"]) && $$.updateText();
|
6763 |
|
6764 | $$.redrawTitle == null ? void 0 : $$.redrawTitle();
|
6765 | initializing && $$.updateTypesElements();
|
6766 | $$.generateRedrawList(targetsToShow, flow, duration, wth.Subchart);
|
6767 | $$.callPluginHook("$redraw", options, duration);
|
6768 | },
|
6769 |
|
6770 | |
6771 |
|
6772 |
|
6773 |
|
6774 |
|
6775 |
|
6776 |
|
6777 |
|
6778 | generateRedrawList: function generateRedrawList(targets, flow, duration, withSubchart) {
|
6779 | var $$ = this,
|
6780 | config = $$.config,
|
6781 | state = $$.state,
|
6782 | shape = $$.getDrawShape();
|
6783 |
|
6784 | if (state.hasAxis) {
|
6785 |
|
6786 | config.subchart_show && $$.redrawSubchart(withSubchart, duration, shape);
|
6787 | }
|
6788 |
|
6789 |
|
6790 | var flowFn = flow && $$.generateFlow({
|
6791 | targets: targets,
|
6792 | flow: flow,
|
6793 | duration: flow.duration,
|
6794 | shape: shape,
|
6795 | xv: $$.xv.bind($$)
|
6796 | }),
|
6797 | withTransition = (duration || flowFn) && isTabVisible(),
|
6798 | redrawList = $$.getRedrawList(shape, flow, flowFn, withTransition),
|
6799 | afterRedraw = function () {
|
6800 | flowFn && flowFn();
|
6801 | state.redrawing = !1;
|
6802 | callFn(config.onrendered, $$.api);
|
6803 | };
|
6804 |
|
6805 | if (afterRedraw) {
|
6806 |
|
6807 | if (withTransition && redrawList.length) {
|
6808 |
|
6809 | var waitForDraw = generateWait();
|
6810 |
|
6811 | (0,external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_root_d3_.transition)().duration(duration).each(function () {
|
6812 | redrawList.reduce(function (acc, t1) {
|
6813 | return acc.concat(t1);
|
6814 | }, []).forEach(function (t) {
|
6815 | return waitForDraw.add(t);
|
6816 | });
|
6817 | }).call(waitForDraw, afterRedraw);
|
6818 | } else if (!state.transiting) {
|
6819 | afterRedraw();
|
6820 | }
|
6821 | }
|
6822 |
|
6823 |
|
6824 | $$.mapToIds($$.data.targets).forEach(function (id) {
|
6825 | state.withoutFadeIn[id] = !0;
|
6826 | });
|
6827 | },
|
6828 | getRedrawList: function getRedrawList(shape, flow, flowFn, withTransition) {
|
6829 | var $$ = this,
|
6830 | config = $$.config,
|
6831 | _$$$state = $$.state,
|
6832 | hasAxis = _$$$state.hasAxis,
|
6833 | hasRadar = _$$$state.hasRadar,
|
6834 | grid = $$.$el.grid,
|
6835 | _shape$pos = shape.pos,
|
6836 | cx = _shape$pos.cx,
|
6837 | cy = _shape$pos.cy,
|
6838 | xForText = _shape$pos.xForText,
|
6839 | yForText = _shape$pos.yForText,
|
6840 | list = [];
|
6841 |
|
6842 | if (hasAxis) {
|
6843 | if (config.grid_x_lines.length || config.grid_y_lines.length) {
|
6844 | list.push($$.redrawGrid(withTransition));
|
6845 | }
|
6846 |
|
6847 | if (config.regions.length) {
|
6848 | list.push($$.redrawRegion(withTransition));
|
6849 | }
|
6850 |
|
6851 | Object.keys(shape.type).forEach(function (v) {
|
6852 | var name = capitalize(v),
|
6853 | drawFn = shape.type[v];
|
6854 |
|
6855 | if (/^(area|line)$/.test(v) && $$.hasTypeOf(name) || $$.hasType(v)) {
|
6856 | list.push($$["redraw" + name](drawFn, withTransition));
|
6857 | }
|
6858 | });
|
6859 | !flow && grid.main && list.push($$.updateGridFocus());
|
6860 | }
|
6861 |
|
6862 | if (!$$.hasArcType() || hasRadar) {
|
6863 | notEmpty(config.data_labels) && config.data_labels !== !1 && list.push($$.redrawText(xForText, yForText, flow, withTransition));
|
6864 | }
|
6865 |
|
6866 | if (($$.hasPointType() || hasRadar) && !config.point_focus_only) {
|
6867 | $$.redrawCircle && list.push($$.redrawCircle(cx, cy, withTransition, flowFn));
|
6868 | }
|
6869 |
|
6870 | return list;
|
6871 | },
|
6872 | updateAndRedraw: function updateAndRedraw(options) {
|
6873 | if (options === void 0) {
|
6874 | options = {};
|
6875 | }
|
6876 |
|
6877 | var $$ = this,
|
6878 | config = $$.config,
|
6879 | state = $$.state,
|
6880 | transitions;
|
6881 |
|
6882 | options.withTransition = getOption(options, "withTransition", !0);
|
6883 | options.withTransform = getOption(options, "withTransform", !1);
|
6884 | options.withLegend = getOption(options, "withLegend", !1);
|
6885 |
|
6886 | options.withUpdateXDomain = !0;
|
6887 | options.withUpdateOrgXDomain = !0;
|
6888 | options.withTransitionForExit = !1;
|
6889 | options.withTransitionForTransform = getOption(options, "withTransitionForTransform", options.withTransition);
|
6890 |
|
6891 | if (!(options.withLegend && config.legend_show)) {
|
6892 | if (state.hasAxis) {
|
6893 | transitions = $$.axis.generateTransitions(options.withTransitionForAxis ? config.transition_duration : 0);
|
6894 | }
|
6895 |
|
6896 |
|
6897 | $$.updateScales();
|
6898 | $$.updateSvgSize();
|
6899 |
|
6900 | $$.transformAll(options.withTransitionForTransform, transitions);
|
6901 | }
|
6902 |
|
6903 |
|
6904 | $$.redraw(options, transitions);
|
6905 | },
|
6906 | redrawWithoutRescale: function redrawWithoutRescale() {
|
6907 | this.redraw({
|
6908 | withY: !1,
|
6909 | withLegend: !0,
|
6910 | withSubchart: !1,
|
6911 | withEventRect: !1,
|
6912 | withTransitionForAxis: !1
|
6913 | });
|
6914 | }
|
6915 | });
|
6916 | ;
|
6917 |
|
6918 |
|
6919 |
|
6920 |
|
6921 |
|
6922 |
|
6923 |
|
6924 |
|
6925 |
|
6926 |
|
6927 |
|
6928 |
|
6929 |
|
6930 |
|
6931 |
|
6932 | function getScale(type, min, max) {
|
6933 | if (type === void 0) {
|
6934 | type = "linear";
|
6935 | }
|
6936 |
|
6937 | if (min === void 0) {
|
6938 | min = 0;
|
6939 | }
|
6940 |
|
6941 | if (max === void 0) {
|
6942 | max = 1;
|
6943 | }
|
6944 |
|
6945 | var scale = {
|
6946 | linear: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear,
|
6947 | log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleSymlog,
|
6948 | _log: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLog,
|
6949 | time: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleTime,
|
6950 | utc: external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleUtc
|
6951 | }[type]();
|
6952 | scale.type = type;
|
6953 | /_?log/.test(type) && scale.clamp(!0);
|
6954 | return scale.range([min, max]);
|
6955 | }
|
6956 | var scale = ({
|
6957 | |
6958 |
|
6959 |
|
6960 |
|
6961 |
|
6962 |
|
6963 |
|
6964 |
|
6965 |
|
6966 | getXScale: function getXScale(min, max, domain, offset) {
|
6967 | var $$ = this,
|
6968 | scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
|
6969 | return $$.getCustomizedScale(domain ? scale.domain(domain) : scale, offset);
|
6970 | },
|
6971 |
|
6972 | |
6973 |
|
6974 |
|
6975 |
|
6976 |
|
6977 |
|
6978 |
|
6979 |
|
6980 |
|
6981 | getYScale: function getYScale(id, min, max, domain) {
|
6982 | var $$ = this,
|
6983 | scale = getScale($$.axis.getAxisType(id), min, max);
|
6984 | domain && scale.domain(domain);
|
6985 | return scale;
|
6986 | },
|
6987 |
|
6988 | |
6989 |
|
6990 |
|
6991 |
|
6992 |
|
6993 |
|
6994 |
|
6995 | getYScaleById: function getYScaleById(id, isSub) {
|
6996 | if (isSub === void 0) {
|
6997 | isSub = !1;
|
6998 | }
|
6999 |
|
7000 | var isY2 = this.axis.getId(id) === "y2",
|
7001 | key = isSub ? isY2 ? "subY2" : "subY" : isY2 ? "y2" : "y";
|
7002 | return this.scale[key];
|
7003 | },
|
7004 |
|
7005 | |
7006 |
|
7007 |
|
7008 |
|
7009 |
|
7010 |
|
7011 |
|
7012 | getCustomizedScale: function getCustomizedScale(scaleValue, offsetValue) {
|
7013 | var $$ = this,
|
7014 | offset = offsetValue || function () {
|
7015 | return $$.axis.x.tickOffset();
|
7016 | },
|
7017 | scale = function (d, raw) {
|
7018 | var v = scaleValue(d) + offset();
|
7019 | return raw ? v : Math.ceil(v);
|
7020 | };
|
7021 |
|
7022 |
|
7023 | for (var key in scaleValue) {
|
7024 | scale[key] = scaleValue[key];
|
7025 | }
|
7026 |
|
7027 | scale.orgDomain = function () {
|
7028 | return scaleValue.domain();
|
7029 | };
|
7030 |
|
7031 | scale.orgScale = function () {
|
7032 | return scaleValue;
|
7033 | };
|
7034 |
|
7035 |
|
7036 | if ($$.axis.isCategorized()) {
|
7037 | scale.domain = function (domainValue) {
|
7038 | var domain = domainValue;
|
7039 |
|
7040 | if (!arguments.length) {
|
7041 | domain = this.orgDomain();
|
7042 | return [domain[0], domain[1] + 1];
|
7043 | }
|
7044 |
|
7045 | scaleValue.domain(domain);
|
7046 | return scale;
|
7047 | };
|
7048 | }
|
7049 |
|
7050 | return scale;
|
7051 | },
|
7052 |
|
7053 | |
7054 |
|
7055 |
|
7056 |
|
7057 |
|
7058 |
|
7059 | updateScales: function updateScales(isInit, updateXDomain) {
|
7060 | if (updateXDomain === void 0) {
|
7061 | updateXDomain = !0;
|
7062 | }
|
7063 |
|
7064 | var $$ = this,
|
7065 | axis = $$.axis,
|
7066 | config = $$.config,
|
7067 | format = $$.format,
|
7068 | org = $$.org,
|
7069 | scale = $$.scale,
|
7070 | _$$$state = $$.state,
|
7071 | width = _$$$state.width,
|
7072 | height = _$$$state.height,
|
7073 | width2 = _$$$state.width2,
|
7074 | height2 = _$$$state.height2,
|
7075 | hasAxis = _$$$state.hasAxis;
|
7076 |
|
7077 | if (hasAxis) {
|
7078 | var _scale$x,
|
7079 | isRotated = config.axis_rotated,
|
7080 | min = {
|
7081 | x: isRotated ? 1 : 0,
|
7082 | y: isRotated ? 0 : height,
|
7083 | subX: isRotated ? 1 : 0,
|
7084 | subY: isRotated ? 0 : height2
|
7085 | },
|
7086 | max = {
|
7087 | x: isRotated ? height : width,
|
7088 | y: isRotated ? width : 1,
|
7089 | subX: isRotated ? height : width,
|
7090 | subY: isRotated ? width2 : 1
|
7091 | },
|
7092 | xDomain = updateXDomain && ((_scale$x = scale.x) == null ? void 0 : _scale$x.orgDomain()),
|
7093 | xSubDomain = updateXDomain && org.xDomain;
|
7094 |
|
7095 | scale.x = $$.getXScale(min.x, max.x, xDomain, function () {
|
7096 | return axis.x.tickOffset();
|
7097 | });
|
7098 | scale.subX = $$.getXScale(min.x, max.x, xSubDomain, function (d) {
|
7099 | return d % 1 ? 0 : axis.subX.tickOffset();
|
7100 | });
|
7101 | format.xAxisTick = axis.getXAxisTickFormat();
|
7102 | format.subXAxisTick = axis.getXAxisTickFormat(!0);
|
7103 | axis.setAxis("x", scale.x, config.axis_x_tick_outer, isInit);
|
7104 |
|
7105 | if (config.subchart_show) {
|
7106 | axis.setAxis("subX", scale.subX, config.axis_x_tick_outer, isInit);
|
7107 | }
|
7108 |
|
7109 |
|
7110 | scale.y = $$.getYScale("y", min.y, max.y, scale.y ? scale.y.domain() : config.axis_y_default);
|
7111 | scale.subY = $$.getYScale("y", min.subY, max.subY, scale.subY ? scale.subY.domain() : config.axis_y_default);
|
7112 | axis.setAxis("y", scale.y, config.axis_y_tick_outer, isInit);
|
7113 |
|
7114 | if (config.axis_y2_show) {
|
7115 | scale.y2 = $$.getYScale("y2", min.y, max.y, scale.y2 ? scale.y2.domain() : config.axis_y2_default);
|
7116 | scale.subY2 = $$.getYScale("y2", min.subY, max.subY, scale.subY2 ? scale.subY2.domain() : config.axis_y2_default);
|
7117 | axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
|
7118 | }
|
7119 | } else {
|
7120 |
|
7121 | $$.updateArc == null ? void 0 : $$.updateArc();
|
7122 | }
|
7123 | },
|
7124 |
|
7125 | |
7126 |
|
7127 |
|
7128 |
|
7129 |
|
7130 |
|
7131 | xx: function xx(d) {
|
7132 | var $$ = this,
|
7133 | config = $$.config,
|
7134 | _$$$scale = $$.scale,
|
7135 | x = _$$$scale.x,
|
7136 | zoom = _$$$scale.zoom,
|
7137 | fn = config.zoom_enabled && zoom ? zoom : x;
|
7138 | return d ? fn(isValue(d.x) ? d.x : d) : null;
|
7139 | },
|
7140 | xv: function xv(d) {
|
7141 | var $$ = this,
|
7142 | axis = $$.axis,
|
7143 | config = $$.config,
|
7144 | _$$$scale2 = $$.scale,
|
7145 | x = _$$$scale2.x,
|
7146 | zoom = _$$$scale2.zoom,
|
7147 | fn = config.zoom_enabled && zoom ? zoom : x,
|
7148 | value = $$.getBaseValue(d);
|
7149 |
|
7150 | if (axis.isTimeSeries()) {
|
7151 | value = parseDate.call($$, value);
|
7152 | } else if (axis.isCategorized() && isString(value)) {
|
7153 | value = config.axis_x_categories.indexOf(value);
|
7154 | }
|
7155 |
|
7156 | return Math.ceil(fn(value));
|
7157 | },
|
7158 | yv: function yv(d) {
|
7159 | var $$ = this,
|
7160 | _$$$scale3 = $$.scale,
|
7161 | y = _$$$scale3.y,
|
7162 | y2 = _$$$scale3.y2,
|
7163 | yScale = d.axis && d.axis === "y2" ? y2 : y;
|
7164 | return Math.ceil(yScale($$.getBaseValue(d)));
|
7165 | },
|
7166 | subxx: function subxx(d) {
|
7167 | return d ? this.scale.subX(d.x) : null;
|
7168 | }
|
7169 | });
|
7170 |
|
7171 | var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webpack_require__(9);
|
7172 | ;
|
7173 |
|
7174 |
|
7175 |
|
7176 |
|
7177 |
|
7178 |
|
7179 |
|
7180 |
|
7181 | var shape = ({
|
7182 | |
7183 |
|
7184 |
|
7185 |
|
7186 |
|
7187 | getDrawShape: function getDrawShape() {
|
7188 | var $$ = this,
|
7189 | isRotated = $$.config.axis_rotated,
|
7190 | hasRadar = $$.state.hasRadar,
|
7191 | shape = {
|
7192 | type: {},
|
7193 | indices: {},
|
7194 | pos: {}
|
7195 | };
|
7196 | ["bar", "candlestick", "line", "area"].forEach(function (v) {
|
7197 | var name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
|
7198 |
|
7199 | if ($$.hasType(v) || $$.hasTypeOf(name) || v === "line" && ($$.hasType("bubble") || $$.hasType("scatter"))) {
|
7200 | var indices = $$.getShapeIndices($$["is" + name + "Type"]),
|
7201 | drawFn = $$["generateDraw" + name];
|
7202 | shape.indices[v] = indices;
|
7203 | shape.type[v] = drawFn ? drawFn.bind($$)(indices, !1) : undefined;
|
7204 | }
|
7205 | });
|
7206 |
|
7207 | if (!$$.hasArcType() || hasRadar) {
|
7208 |
|
7209 | var cx = hasRadar ? $$.radarCircleX : isRotated ? $$.circleY : $$.circleX,
|
7210 | cy = hasRadar ? $$.radarCircleY : isRotated ? $$.circleX : $$.circleY;
|
7211 | shape.pos = {
|
7212 | xForText: $$.generateXYForText(shape.indices, !0),
|
7213 | yForText: $$.generateXYForText(shape.indices, !1),
|
7214 | cx: (cx || function () {}).bind($$),
|
7215 | cy: (cy || function () {}).bind($$)
|
7216 | };
|
7217 | }
|
7218 |
|
7219 | return shape;
|
7220 | },
|
7221 | getShapeIndices: function getShapeIndices(typeFilter) {
|
7222 | var $$ = this,
|
7223 | config = $$.config,
|
7224 | xs = config.data_xs,
|
7225 | hasXs = notEmpty(xs),
|
7226 | indices = {},
|
7227 | i = hasXs ? {} : 0;
|
7228 |
|
7229 | if (hasXs) {
|
7230 | getUnique(Object.keys(xs).map(function (v) {
|
7231 | return xs[v];
|
7232 | })).forEach(function (v) {
|
7233 | i[v] = 0;
|
7234 | indices[v] = {};
|
7235 | });
|
7236 | }
|
7237 |
|
7238 | $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) {
|
7239 | var xKey = d.id in xs ? xs[d.id] : "",
|
7240 | ind = xKey ? indices[xKey] : indices;
|
7241 |
|
7242 | for (var j = 0, groups; groups = config.data_groups[j]; j++) {
|
7243 | if (groups.indexOf(d.id) < 0) {
|
7244 | continue;
|
7245 | }
|
7246 |
|
7247 | for (var k = 0, row; row = groups[k]; k++) {
|
7248 | if (row in ind) {
|
7249 | ind[d.id] = ind[row];
|
7250 | break;
|
7251 | }
|
7252 | }
|
7253 | }
|
7254 |
|
7255 | if (isUndefined(ind[d.id])) {
|
7256 | ind[d.id] = xKey ? i[xKey]++ : i++;
|
7257 | ind.__max__ = (xKey ? i[xKey] : i) - 1;
|
7258 | }
|
7259 | });
|
7260 | return indices;
|
7261 | },
|
7262 |
|
7263 | |
7264 |
|
7265 |
|
7266 |
|
7267 |
|
7268 |
|
7269 |
|
7270 | getIndices: function getIndices(indices, id) {
|
7271 | var xs = this.config.data_xs;
|
7272 | return notEmpty(xs) ? indices[xs[id]] : indices;
|
7273 | },
|
7274 |
|
7275 | |
7276 |
|
7277 |
|
7278 |
|
7279 |
|
7280 |
|
7281 | getIndicesMax: function getIndicesMax(indices) {
|
7282 | return notEmpty(this.config.data_xs) ?
|
7283 | Object.keys(indices).map(function (v) {
|
7284 | return indices[v].__max__ || 0;
|
7285 | }).reduce(function (acc, curr) {
|
7286 | return acc + curr;
|
7287 | }) : indices.__max__;
|
7288 | },
|
7289 | getShapeX: function getShapeX(offset, indices, isSub) {
|
7290 | var $$ = this,
|
7291 | config = $$.config,
|
7292 | scale = $$.scale,
|
7293 | currScale = isSub ? scale.subX : scale.zoom || scale.x,
|
7294 | barPadding = config.bar_padding,
|
7295 | sum = function (p, c) {
|
7296 | return p + c;
|
7297 | },
|
7298 | halfWidth = isObjectType(offset) && (offset._$total.length ? offset._$total.reduce(sum) / 2 : 0);
|
7299 |
|
7300 | return function (d) {
|
7301 | var ind = $$.getIndices(indices, d.id, "getShapeX"),
|
7302 | index = d.id in ind ? ind[d.id] : 0,
|
7303 | targetsNum = (ind.__max__ || 0) + 1,
|
7304 | x = 0;
|
7305 |
|
7306 | if (notEmpty(d.x)) {
|
7307 | var xPos = currScale(d.x, !0);
|
7308 |
|
7309 | if (halfWidth) {
|
7310 | x = xPos - (offset[d.id] || offset._$width) + offset._$total.slice(0, index + 1).reduce(sum) - halfWidth;
|
7311 | } else {
|
7312 | x = xPos - (isNumber(offset) ? offset : offset._$width) * (targetsNum / 2 - index);
|
7313 | }
|
7314 | }
|
7315 |
|
7316 |
|
7317 | if (offset && x && targetsNum > 1 && barPadding) {
|
7318 | if (index) {
|
7319 | x += barPadding * index;
|
7320 | }
|
7321 |
|
7322 | if (targetsNum > 2) {
|
7323 | x -= (targetsNum - 1) * barPadding / 2;
|
7324 | } else if (targetsNum === 2) {
|
7325 | x -= barPadding / 2;
|
7326 | }
|
7327 | }
|
7328 |
|
7329 | return x;
|
7330 | };
|
7331 | },
|
7332 | getShapeY: function getShapeY(isSub) {
|
7333 | var $$ = this,
|
7334 | isStackNormalized = $$.isStackNormalized();
|
7335 | return function (d) {
|
7336 | var value = d.value;
|
7337 |
|
7338 | if (isNumber(d)) {
|
7339 | value = d;
|
7340 | } else if (isStackNormalized) {
|
7341 | value = $$.getRatio("index", d, !0);
|
7342 | } else if ($$.isBubbleZType(d)) {
|
7343 | value = $$.getBubbleZData(d.value, "y");
|
7344 | }
|
7345 |
|
7346 | return $$.getYScaleById(d.id, isSub)(value);
|
7347 | };
|
7348 | },
|
7349 |
|
7350 | |
7351 |
|
7352 |
|
7353 |
|
7354 |
|
7355 |
|
7356 | getShapeYMin: function getShapeYMin(id) {
|
7357 | var $$ = this,
|
7358 | scale = $$.scale[$$.axis.getId(id)],
|
7359 | _scale$domain = scale.domain(),
|
7360 | yMin = _scale$domain[0];
|
7361 |
|
7362 | return !$$.isGrouped(id) && yMin > 0 ? yMin : 0;
|
7363 | },
|
7364 |
|
7365 | |
7366 |
|
7367 |
|
7368 |
|
7369 |
|
7370 |
|
7371 | getShapeOffsetData: function getShapeOffsetData(typeFilter) {
|
7372 | var $$ = this,
|
7373 | targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))),
|
7374 | isStackNormalized = $$.isStackNormalized(),
|
7375 | shapeOffsetTargets = targets.map(function (target) {
|
7376 | var rowValues = target.values,
|
7377 | values = {};
|
7378 |
|
7379 | if ($$.isStepType(target)) {
|
7380 | rowValues = $$.convertValuesToStep(rowValues);
|
7381 | }
|
7382 |
|
7383 | var rowValueMapByXValue = rowValues.reduce(function (out, d) {
|
7384 | var key = +d.x;
|
7385 | out[key] = d;
|
7386 | values[key] = isStackNormalized ? $$.getRatio("index", d, !0) : d.value;
|
7387 | return out;
|
7388 | }, {});
|
7389 | return {
|
7390 | id: target.id,
|
7391 | rowValues: rowValues,
|
7392 | rowValueMapByXValue: rowValueMapByXValue,
|
7393 | values: values
|
7394 | };
|
7395 | }),
|
7396 | indexMapByTargetId = targets.reduce(function (out, _ref, index) {
|
7397 | var id = _ref.id;
|
7398 | out[id] = index;
|
7399 | return out;
|
7400 | }, {});
|
7401 | return {
|
7402 | indexMapByTargetId: indexMapByTargetId,
|
7403 | shapeOffsetTargets: shapeOffsetTargets
|
7404 | };
|
7405 | },
|
7406 | getShapeOffset: function getShapeOffset(typeFilter, indices, isSub) {
|
7407 | var $$ = this,
|
7408 | _$$$getShapeOffsetDat = $$.getShapeOffsetData(typeFilter),
|
7409 | shapeOffsetTargets = _$$$getShapeOffsetDat.shapeOffsetTargets,
|
7410 | indexMapByTargetId = _$$$getShapeOffsetDat.indexMapByTargetId;
|
7411 |
|
7412 | return function (d, idx) {
|
7413 | var id = d.id,
|
7414 | value = d.value,
|
7415 | x = d.x,
|
7416 | ind = $$.getIndices(indices, id),
|
7417 | scale = $$.getYScaleById(id, isSub),
|
7418 | y0 = scale($$.getShapeYMin(id)),
|
7419 | dataXAsNumber = +x,
|
7420 | offset = y0;
|
7421 | shapeOffsetTargets.filter(function (t) {
|
7422 | return t.id !== id;
|
7423 | }).forEach(function (t) {
|
7424 | var tid = t.id,
|
7425 | rowValueMapByXValue = t.rowValueMapByXValue,
|
7426 | rowValues = t.rowValues,
|
7427 | tvalues = t.values;
|
7428 |
|
7429 | if (ind[tid] === ind[id] && indexMapByTargetId[tid] < indexMapByTargetId[id]) {
|
7430 | var _row,
|
7431 | row = rowValues[idx];
|
7432 |
|
7433 |
|
7434 | if (!row || +row.x !== dataXAsNumber) {
|
7435 | row = rowValueMapByXValue[dataXAsNumber];
|
7436 | }
|
7437 |
|
7438 | if (((_row = row) == null ? void 0 : _row.value) * value >= 0 && isNumber(tvalues[dataXAsNumber])) {
|
7439 | offset += scale(tvalues[dataXAsNumber]) - y0;
|
7440 | }
|
7441 | }
|
7442 | });
|
7443 | return offset;
|
7444 | };
|
7445 | },
|
7446 | getBarW: function getBarW(type, axis, targetsNum) {
|
7447 | var $$ = this,
|
7448 | config = $$.config,
|
7449 | org = $$.org,
|
7450 | scale = $$.scale,
|
7451 | maxDataCount = $$.getMaxDataCount(),
|
7452 | isGrouped = type === "bar" && config.data_groups.length,
|
7453 | configName = type + "_width",
|
7454 | tickInterval = scale.zoom && !$$.axis.isCategorized() ? org.xDomain.map(function (v) {
|
7455 | return scale.zoom(v);
|
7456 | }).reduce(function (a, c) {
|
7457 | return Math.abs(a) + c;
|
7458 | }) / maxDataCount : axis.tickInterval(maxDataCount),
|
7459 | getWidth = function (id) {
|
7460 | var width = id ? config[configName][id] : config[configName],
|
7461 | ratio = id ? width.ratio : config[configName + "_ratio"],
|
7462 | max = id ? width.max : config[configName + "_max"],
|
7463 | w = isNumber(width) ? width : targetsNum ? tickInterval * ratio / targetsNum : 0;
|
7464 | return max && w > max ? max : w;
|
7465 | },
|
7466 | result = getWidth();
|
7467 |
|
7468 | if (!isGrouped && isObjectType(config[configName])) {
|
7469 | result = {
|
7470 | _$width: result,
|
7471 | _$total: []
|
7472 | };
|
7473 | $$.filterTargetsToShow($$.data.targets).forEach(function (v) {
|
7474 | if (config[configName][v.id]) {
|
7475 | result[v.id] = getWidth(v.id);
|
7476 |
|
7477 | result._$total.push(result[v.id] || result._$width);
|
7478 | }
|
7479 | });
|
7480 | }
|
7481 |
|
7482 | return result;
|
7483 | },
|
7484 |
|
7485 | |
7486 |
|
7487 |
|
7488 |
|
7489 |
|
7490 |
|
7491 |
|
7492 |
|
7493 | getShapeByIndex: function getShapeByIndex(shapeName, i, id) {
|
7494 | var $$ = this,
|
7495 | $el = $$.$el,
|
7496 | suffix = isValue(i) ? "-" + i : "",
|
7497 | shape = $el[shapeName];
|
7498 |
|
7499 |
|
7500 | if (shape && !shape.empty()) {
|
7501 | shape = shape.filter(function (d) {
|
7502 | return id ? d.id === id : !0;
|
7503 | }).filter(function (d) {
|
7504 | return isValue(i) ? d.index === i : !0;
|
7505 | });
|
7506 | } else {
|
7507 | shape = (id ? $el.main.selectAll("." + config_classes[shapeName + "s"] + $$.getTargetSelectorSuffix(id)) : $el.main).selectAll("." + config_classes[shapeName] + suffix);
|
7508 | }
|
7509 |
|
7510 | return shape;
|
7511 | },
|
7512 | isWithinShape: function isWithinShape(that, d) {
|
7513 | var $$ = this,
|
7514 | shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that),
|
7515 | isWithin;
|
7516 |
|
7517 | if (!$$.isTargetToShow(d.id)) {
|
7518 | isWithin = !1;
|
7519 | } else if ($$.hasValidPointType != null && $$.hasValidPointType(that.nodeName)) {
|
7520 | isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) : $$.isWithinCircle(that, $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0);
|
7521 | } else if (that.nodeName === "path") {
|
7522 | isWithin = shape.classed(config_classes.bar) ? $$.isWithinBar(that) : !0;
|
7523 | }
|
7524 |
|
7525 | return isWithin;
|
7526 | },
|
7527 | getInterpolate: function getInterpolate(d) {
|
7528 | var $$ = this,
|
7529 | interpolation = $$.getInterpolateType(d);
|
7530 | return {
|
7531 | "basis": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasis,
|
7532 | "basis-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisClosed,
|
7533 | "basis-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisOpen,
|
7534 | "bundle": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBundle,
|
7535 | "cardinal": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinal,
|
7536 | "cardinal-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalClosed,
|
7537 | "cardinal-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCardinalOpen,
|
7538 | "catmull-rom": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRom,
|
7539 | "catmull-rom-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomClosed,
|
7540 | "catmull-rom-open": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveCatmullRomOpen,
|
7541 | "monotone-x": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneX,
|
7542 | "monotone-y": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveMonotoneY,
|
7543 | "natural": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveNatural,
|
7544 | "linear-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinearClosed,
|
7545 | "linear": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveLinear,
|
7546 | "step": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStep,
|
7547 | "step-after": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepAfter,
|
7548 | "step-before": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveStepBefore
|
7549 | }[interpolation];
|
7550 | },
|
7551 | getInterpolateType: function getInterpolateType(d) {
|
7552 | var $$ = this,
|
7553 | config = $$.config,
|
7554 | type = config.spline_interpolation_type,
|
7555 | interpolation = $$.isInterpolationType(type) ? type : "cardinal";
|
7556 | return $$.isSplineType(d) ? interpolation : $$.isStepType(d) ? config.line_step_type : "linear";
|
7557 | }
|
7558 | });
|
7559 | ;
|
7560 |
|
7561 |
|
7562 |
|
7563 |
|
7564 |
|
7565 |
|
7566 |
|
7567 | var size = ({
|
7568 | |
7569 |
|
7570 |
|
7571 |
|
7572 | setContainerSize: function setContainerSize() {
|
7573 | var $$ = this,
|
7574 | state = $$.state;
|
7575 | state.current.width = $$.getCurrentWidth();
|
7576 | state.current.height = $$.getCurrentHeight();
|
7577 | },
|
7578 | getCurrentWidth: function getCurrentWidth() {
|
7579 | var $$ = this;
|
7580 | return $$.config.size_width || $$.getParentWidth();
|
7581 | },
|
7582 | getCurrentHeight: function getCurrentHeight() {
|
7583 | var $$ = this,
|
7584 | config = $$.config,
|
7585 | h = config.size_height || $$.getParentHeight();
|
7586 | return h > 0 ? h : 320 / ($$.hasType("gauge") && !config.gauge_fullCircle ? 2 : 1);
|
7587 | },
|
7588 | getCurrentPaddingTop: function getCurrentPaddingTop() {
|
7589 | var $$ = this,
|
7590 | config = $$.config,
|
7591 | hasAxis = $$.state.hasAxis,
|
7592 | $el = $$.$el,
|
7593 | axesLen = hasAxis ? config.axis_y2_axes.length : 0,
|
7594 | padding = isValue(config.padding_top) ? config.padding_top : 0;
|
7595 |
|
7596 | if ($el.title && $el.title.node()) {
|
7597 | padding += $$.getTitlePadding();
|
7598 | }
|
7599 |
|
7600 | if (axesLen && config.axis_rotated) {
|
7601 | padding += $$.getHorizontalAxisHeight("y2") * axesLen;
|
7602 | }
|
7603 |
|
7604 | return padding;
|
7605 | },
|
7606 | getCurrentPaddingBottom: function getCurrentPaddingBottom() {
|
7607 | var $$ = this,
|
7608 | config = $$.config,
|
7609 | hasAxis = $$.state.hasAxis,
|
7610 | axisId = config.axis_rotated ? "y" : "x",
|
7611 | axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
|
7612 | padding = isValue(config.padding_bottom) ? config.padding_bottom : 0;
|
7613 | return padding + (axesLen ? $$.getHorizontalAxisHeight(axisId) * axesLen : 0);
|
7614 | },
|
7615 | getCurrentPaddingLeft: function getCurrentPaddingLeft(withoutRecompute) {
|
7616 | var $$ = this,
|
7617 | config = $$.config,
|
7618 | hasAxis = $$.state.hasAxis,
|
7619 | isRotated = config.axis_rotated,
|
7620 | axisId = isRotated ? "x" : "y",
|
7621 | axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
|
7622 | axisWidth = hasAxis ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : 0,
|
7623 | padding;
|
7624 |
|
7625 | if (isValue(config.padding_left)) {
|
7626 | padding = config.padding_left;
|
7627 | } else if (hasAxis && isRotated) {
|
7628 | padding = !config.axis_x_show ? 1 : Math.max(ceil10(axisWidth), 40);
|
7629 | } else if (hasAxis && (!config.axis_y_show || config.axis_y_inner)) {
|
7630 |
|
7631 | padding = $$.axis.getAxisLabelPosition("y").isOuter ? 30 : 1;
|
7632 | } else {
|
7633 | padding = ceil10(axisWidth);
|
7634 | }
|
7635 |
|
7636 | return padding + axisWidth * axesLen;
|
7637 | },
|
7638 | getCurrentPaddingRight: function getCurrentPaddingRight(withXAxisTickTextOverflow) {
|
7639 | if (withXAxisTickTextOverflow === void 0) {
|
7640 | withXAxisTickTextOverflow = !1;
|
7641 | }
|
7642 |
|
7643 | var $$ = this,
|
7644 | config = $$.config,
|
7645 | hasAxis = $$.state.hasAxis,
|
7646 | defaultPadding = 10,
|
7647 | legendWidthOnRight = $$.state.isLegendRight ? $$.getLegendWidth() + 20 : 0,
|
7648 | axesLen = hasAxis ? config.axis_y2_axes.length : 0,
|
7649 | axisWidth = hasAxis ? $$.getAxisWidthByAxisId("y2") : 0,
|
7650 | xAxisTickTextOverflow = withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0,
|
7651 | padding;
|
7652 |
|
7653 | if (isValue(config.padding_right)) {
|
7654 | padding = config.padding_right + 1;
|
7655 | } else if ($$.axis && config.axis_rotated) {
|
7656 | padding = defaultPadding + legendWidthOnRight;
|
7657 | } else if ($$.axis && (!config.axis_y2_show || config.axis_y2_inner)) {
|
7658 |
|
7659 | padding = Math.max(2 + legendWidthOnRight + ($$.axis.getAxisLabelPosition("y2").isOuter ? 20 : 0), xAxisTickTextOverflow);
|
7660 | } else {
|
7661 | padding = Math.max(ceil10(axisWidth) + legendWidthOnRight, xAxisTickTextOverflow);
|
7662 | }
|
7663 |
|
7664 | return padding + axisWidth * axesLen;
|
7665 | },
|
7666 |
|
7667 | |
7668 |
|
7669 |
|
7670 |
|
7671 |
|
7672 |
|
7673 | getParentRectValue: function getParentRectValue(key) {
|
7674 | var offsetName = "offset" + capitalize(key),
|
7675 | parent = this.$el.chart.node(),
|
7676 | v = 0;
|
7677 |
|
7678 | while (v < 30 && parent && parent.tagName !== "BODY") {
|
7679 | try {
|
7680 | v = parent.getBoundingClientRect()[key];
|
7681 | } catch (e) {
|
7682 | if (offsetName in parent) {
|
7683 |
|
7684 |
|
7685 | v = parent[offsetName];
|
7686 | }
|
7687 | }
|
7688 |
|
7689 | parent = parent.parentNode;
|
7690 | }
|
7691 |
|
7692 |
|
7693 |
|
7694 | var bodySize = browser_doc.body[offsetName];
|
7695 | v > bodySize && (v = bodySize);
|
7696 | return v;
|
7697 | },
|
7698 | getParentWidth: function getParentWidth() {
|
7699 | return this.getParentRectValue("width");
|
7700 | },
|
7701 | getParentHeight: function getParentHeight() {
|
7702 | var h = this.$el.chart.style("height"),
|
7703 | height = 0;
|
7704 |
|
7705 | if (h) {
|
7706 | height = /px$/.test(h) ? parseInt(h, 10) : this.getParentRectValue("height");
|
7707 | }
|
7708 |
|
7709 | return height;
|
7710 | },
|
7711 | getSvgLeft: function getSvgLeft(withoutRecompute) {
|
7712 | var $$ = this,
|
7713 | config = $$.config,
|
7714 | $el = $$.$el,
|
7715 | hasLeftAxisRect = config.axis_rotated || !config.axis_rotated && !config.axis_y_inner,
|
7716 | leftAxisClass = config.axis_rotated ? config_classes.axisX : config_classes.axisY,
|
7717 | leftAxis = $el.main.select("." + leftAxisClass).node(),
|
7718 | svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : {
|
7719 | right: 0
|
7720 | },
|
7721 | chartRect = $el.chart.node().getBoundingClientRect(),
|
7722 | hasArc = $$.hasArcType(),
|
7723 | svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute));
|
7724 | return svgLeft > 0 ? svgLeft : 0;
|
7725 | },
|
7726 | updateDimension: function updateDimension(withoutAxis) {
|
7727 | var $$ = this,
|
7728 | config = $$.config,
|
7729 | hasAxis = $$.state.hasAxis,
|
7730 | $el = $$.$el;
|
7731 |
|
7732 | if (hasAxis && !withoutAxis && $$.axis.x && config.axis_rotated) {
|
7733 | var _$$$axis$subX;
|
7734 |
|
7735 | (_$$$axis$subX = $$.axis.subX) == null ? void 0 : _$$$axis$subX.create($el.axis.subX);
|
7736 | }
|
7737 |
|
7738 |
|
7739 | $$.updateScales(withoutAxis);
|
7740 | $$.updateSvgSize();
|
7741 | $$.transformAll(!1);
|
7742 | },
|
7743 | updateSvgSize: function updateSvgSize() {
|
7744 | var $$ = this,
|
7745 | _$$$state = $$.state,
|
7746 | clip = _$$$state.clip,
|
7747 | current = _$$$state.current,
|
7748 | hasAxis = _$$$state.hasAxis,
|
7749 | width = _$$$state.width,
|
7750 | height = _$$$state.height,
|
7751 | svg = $$.$el.svg;
|
7752 | svg.attr("width", current.width).attr("height", current.height);
|
7753 |
|
7754 | if (hasAxis) {
|
7755 | var brush = svg.select("." + config_classes.brush + " .overlay"),
|
7756 | brushSize = {
|
7757 | width: 0,
|
7758 | height: 0
|
7759 | };
|
7760 |
|
7761 | if (brush.size()) {
|
7762 | brushSize.width = +brush.attr("width");
|
7763 | brushSize.height = +brush.attr("height");
|
7764 | }
|
7765 |
|
7766 | svg.selectAll(["#" + clip.id, "#" + clip.idGrid]).select("rect").attr("width", width).attr("height", height);
|
7767 | svg.select("#" + clip.idXAxis).select("rect").call($$.setXAxisClipPath.bind($$));
|
7768 | svg.select("#" + clip.idYAxis).select("rect").call($$.setYAxisClipPath.bind($$));
|
7769 | clip.idSubchart && svg.select("#" + clip.idSubchart).select("rect").attr("width", width).attr("height", brushSize.height);
|
7770 | }
|
7771 | },
|
7772 |
|
7773 | |
7774 |
|
7775 |
|
7776 |
|
7777 |
|
7778 | updateSizes: function updateSizes(isInit) {
|
7779 | var $$ = this,
|
7780 | config = $$.config,
|
7781 | state = $$.state,
|
7782 | legend = $$.$el.legend,
|
7783 | isRotated = config.axis_rotated,
|
7784 | hasArc = $$.hasArcType();
|
7785 | isInit || $$.setContainerSize();
|
7786 | var currLegend = {
|
7787 | width: legend ? $$.getLegendWidth() : 0,
|
7788 | height: legend ? $$.getLegendHeight() : 0
|
7789 | };
|
7790 |
|
7791 | if (!hasArc && config.axis_x_show && config.axis_x_tick_autorotate) {
|
7792 | $$.updateXAxisTickClip();
|
7793 | }
|
7794 |
|
7795 | var legendHeightForBottom = state.isLegendRight || state.isLegendInset ? 0 : currLegend.height,
|
7796 | xAxisHeight = isRotated || hasArc ? 0 : $$.getHorizontalAxisHeight("x"),
|
7797 | subchartXAxisHeight = config.subchart_axis_x_show && config.subchart_axis_x_tick_text_show ? xAxisHeight : 30,
|
7798 | subchartHeight = config.subchart_show && !hasArc ? config.subchart_size_height + subchartXAxisHeight : 0;
|
7799 |
|
7800 | state.margin = !hasArc && isRotated ? {
|
7801 | top: $$.getHorizontalAxisHeight("y2") + $$.getCurrentPaddingTop(),
|
7802 | right: hasArc ? 0 : $$.getCurrentPaddingRight(!0),
|
7803 | bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom + $$.getCurrentPaddingBottom(),
|
7804 | left: subchartHeight + (hasArc ? 0 : $$.getCurrentPaddingLeft())
|
7805 | } : {
|
7806 | top: 4 + $$.getCurrentPaddingTop(),
|
7807 |
|
7808 | right: hasArc ? 0 : $$.getCurrentPaddingRight(!0),
|
7809 | bottom: xAxisHeight + subchartHeight + legendHeightForBottom + $$.getCurrentPaddingBottom(),
|
7810 | left: hasArc ? 0 : $$.getCurrentPaddingLeft()
|
7811 | };
|
7812 |
|
7813 | state.margin2 = isRotated ? {
|
7814 | top: state.margin.top,
|
7815 | right: NaN,
|
7816 | bottom: 20 + legendHeightForBottom,
|
7817 | left: $$.state.rotatedPadding.left
|
7818 | } : {
|
7819 | top: state.current.height - subchartHeight - legendHeightForBottom,
|
7820 | right: NaN,
|
7821 | bottom: subchartXAxisHeight + legendHeightForBottom,
|
7822 | left: state.margin.left
|
7823 | };
|
7824 |
|
7825 | state.margin3 = {
|
7826 | top: 0,
|
7827 | right: NaN,
|
7828 | bottom: 0,
|
7829 | left: 0
|
7830 | };
|
7831 | $$.updateSizeForLegend == null ? void 0 : $$.updateSizeForLegend(currLegend);
|
7832 | state.width = state.current.width - state.margin.left - state.margin.right;
|
7833 | state.height = state.current.height - state.margin.top - state.margin.bottom;
|
7834 |
|
7835 | if (state.width < 0) {
|
7836 | state.width = 0;
|
7837 | }
|
7838 |
|
7839 | if (state.height < 0) {
|
7840 | state.height = 0;
|
7841 | }
|
7842 |
|
7843 | state.width2 = isRotated ? state.margin.left - state.rotatedPadding.left - state.rotatedPadding.right : state.width;
|
7844 | state.height2 = isRotated ? state.height : state.current.height - state.margin2.top - state.margin2.bottom;
|
7845 |
|
7846 | if (state.width2 < 0) {
|
7847 | state.width2 = 0;
|
7848 | }
|
7849 |
|
7850 | if (state.height2 < 0) {
|
7851 | state.height2 = 0;
|
7852 | }
|
7853 |
|
7854 |
|
7855 | var hasGauge = $$.hasType("gauge"),
|
7856 | isLegendRight = config.legend_show && state.isLegendRight;
|
7857 | state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0);
|
7858 | state.arcHeight = state.height - (isLegendRight && !hasGauge ? 0 : 10);
|
7859 |
|
7860 | if (hasGauge && !config.gauge_fullCircle) {
|
7861 | state.arcHeight += state.height - $$.getPaddingBottomForGauge();
|
7862 | }
|
7863 |
|
7864 | $$.updateRadius == null ? void 0 : $$.updateRadius();
|
7865 |
|
7866 | if (state.isLegendRight && hasArc) {
|
7867 | state.margin3.left = state.arcWidth / 2 + state.radiusExpanded * 1.1;
|
7868 | }
|
7869 | }
|
7870 | });
|
7871 | ;
|
7872 |
|
7873 |
|
7874 |
|
7875 |
|
7876 |
|
7877 |
|
7878 |
|
7879 |
|
7880 | var internals_text = ({
|
7881 | opacityForText: function opacityForText(d) {
|
7882 | var $$ = this;
|
7883 | return $$.isBarType(d) && !$$.meetsLabelThreshold(Math.abs($$.getRatio("bar", d)), "bar") ? "0" : $$.hasDataLabel ? null : "0";
|
7884 | },
|
7885 |
|
7886 | |
7887 |
|
7888 |
|
7889 |
|
7890 | initText: function initText() {
|
7891 | var $el = this.$el;
|
7892 | $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartTexts);
|
7893 | },
|
7894 |
|
7895 | |
7896 |
|
7897 |
|
7898 |
|
7899 |
|
7900 | updateTargetsForText: function updateTargetsForText(targets) {
|
7901 | var $$ = this,
|
7902 | classChartText = $$.getChartClass("Text"),
|
7903 | classTexts = $$.getClass("texts", "id"),
|
7904 | classFocus = $$.classFocus.bind($$),
|
7905 | mainTextUpdate = $$.$el.main.select("." + config_classes.chartTexts).selectAll("." + config_classes.chartText).data(targets).attr("class", function (d) {
|
7906 | return classChartText(d) + classFocus(d);
|
7907 | }),
|
7908 | mainTextEnter = mainTextUpdate.enter().append("g").style("opacity", "0").attr("class", classChartText).style("pointer-events", "none");
|
7909 | mainTextEnter.append("g").attr("class", classTexts);
|
7910 | },
|
7911 |
|
7912 | |
7913 |
|
7914 |
|
7915 |
|
7916 | updateText: function updateText() {
|
7917 | var $$ = this,
|
7918 | $el = $$.$el,
|
7919 | $T = $$.$T,
|
7920 | config = $$.config,
|
7921 | classText = $$.getClass("text", "index"),
|
7922 | text = $el.main.selectAll("." + config_classes.texts).selectAll("." + config_classes.text).data($$.labelishData.bind($$));
|
7923 | $T(text.exit()).style("fill-opacity", "0").remove();
|
7924 | $el.text = text.enter().append("text").merge(text).attr("class", classText).attr("text-anchor", function (d) {
|
7925 |
|
7926 | var isEndAnchor = d.value < 0;
|
7927 |
|
7928 | if ($$.isCandlestickType(d)) {
|
7929 | var data = $$.getCandlestickData(d);
|
7930 | isEndAnchor = !(data != null && data._isUp);
|
7931 | }
|
7932 |
|
7933 | return config.axis_rotated ? isEndAnchor ? "end" : "start" : "middle";
|
7934 | }).style("fill", $$.updateTextColor.bind($$)).style("fill-opacity", "0").each(function (d, i, texts) {
|
7935 | var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
7936 | value = d.value;
|
7937 |
|
7938 | if ($$.isBubbleZType(d)) {
|
7939 | value = $$.getBubbleZData(value, "z");
|
7940 | } else if ($$.isCandlestickType(d)) {
|
7941 | var data = $$.getCandlestickData(d);
|
7942 |
|
7943 | if (data) {
|
7944 | value = data.close;
|
7945 | }
|
7946 | }
|
7947 |
|
7948 | value = $$.dataLabelFormat(d.id)(value, d.id, i, texts);
|
7949 |
|
7950 | if (isNumber(value)) {
|
7951 | this.textContent = value;
|
7952 | } else {
|
7953 | setTextValue(node, value);
|
7954 | }
|
7955 | });
|
7956 | },
|
7957 | updateTextColor: function updateTextColor(d) {
|
7958 | var $$ = this,
|
7959 | config = $$.config,
|
7960 | labelColors = config.data_labels_colors,
|
7961 | defaultColor = $$.isArcType(d) && !$$.isRadarType(d) ? null : $$.color(d),
|
7962 | color;
|
7963 |
|
7964 | if (isString(labelColors)) {
|
7965 | color = labelColors;
|
7966 | } else if (isObject(labelColors)) {
|
7967 | var _ref = d.data || d,
|
7968 | id = _ref.id;
|
7969 |
|
7970 | color = labelColors[id];
|
7971 | } else if (isFunction(labelColors)) {
|
7972 | color = labelColors.bind($$.api)(defaultColor, d);
|
7973 | }
|
7974 |
|
7975 | if ($$.isCandlestickType(d) && !isFunction(labelColors)) {
|
7976 | var value = $$.getCandlestickData(d);
|
7977 |
|
7978 | if (!(value != null && value._isUp)) {
|
7979 | var downColor = config.candlestick_color_down;
|
7980 | color = isObject(downColor) ? downColor[d.id] : downColor;
|
7981 | }
|
7982 | }
|
7983 |
|
7984 | return color || defaultColor;
|
7985 | },
|
7986 |
|
7987 | |
7988 |
|
7989 |
|
7990 |
|
7991 |
|
7992 |
|
7993 | updateTextBacgroundColor: function updateTextBacgroundColor(d) {
|
7994 | var $$ = this,
|
7995 | $el = $$.$el,
|
7996 | config = $$.config,
|
7997 | backgroundColor = config.data_labels_backgroundColors,
|
7998 | color = "";
|
7999 |
|
8000 | if (isString(backgroundColor) || isObject(backgroundColor)) {
|
8001 | var id = isString(backgroundColor) ? "" : $$.getTargetSelectorSuffix("id" in d ? d.id : d.data.id),
|
8002 | filter = $el.defs.select(["filter[id*='labels-bg", "']"].join(id));
|
8003 |
|
8004 | if (filter.size()) {
|
8005 | color = "url(#" + filter.attr("id") + ")";
|
8006 | }
|
8007 | }
|
8008 |
|
8009 | return color || null;
|
8010 | },
|
8011 |
|
8012 | |
8013 |
|
8014 |
|
8015 |
|
8016 |
|
8017 |
|
8018 |
|
8019 |
|
8020 |
|
8021 | redrawText: function redrawText(x, y, forFlow, withTransition) {
|
8022 | var $$ = this,
|
8023 | $T = $$.$T,
|
8024 | t = getRandom(!0);
|
8025 | $$.$el.text.style("fill", $$.updateTextColor.bind($$)).attr("filter", $$.updateTextBacgroundColor.bind($$)).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function (d, i) {
|
8026 |
|
8027 | var node = $T(this, !!(withTransition && this.getAttribute("x")), t),
|
8028 | posX = x.bind(this)(d, i),
|
8029 | posY = y.bind(this)(d, i);
|
8030 |
|
8031 |
|
8032 | if (this.childElementCount) {
|
8033 | node.attr("transform", "translate(" + posX + " " + posY + ")");
|
8034 | } else {
|
8035 | node.attr("x", posX).attr("y", posY);
|
8036 | }
|
8037 | });
|
8038 |
|
8039 |
|
8040 | return !0;
|
8041 | },
|
8042 |
|
8043 | |
8044 |
|
8045 |
|
8046 |
|
8047 |
|
8048 |
|
8049 |
|
8050 | getTextRect: function getTextRect(element, className) {
|
8051 | var $$ = this,
|
8052 | base = element.node ? element.node() : element;
|
8053 |
|
8054 | if (!/text/i.test(base.tagName)) {
|
8055 | base = base.querySelector("text");
|
8056 | }
|
8057 |
|
8058 | var text = base.textContent,
|
8059 | cacheKey = KEY.textRect + "-" + text.replace(/\W/g, "_"),
|
8060 | rect = $$.cache.get(cacheKey);
|
8061 |
|
8062 | if (!rect) {
|
8063 | $$.$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, !0).text(text).call(function (v) {
|
8064 | rect = getBoundingRect(v.node());
|
8065 | }).remove();
|
8066 | $$.cache.add(cacheKey, rect);
|
8067 | }
|
8068 |
|
8069 | return rect;
|
8070 | },
|
8071 |
|
8072 | |
8073 |
|
8074 |
|
8075 |
|
8076 |
|
8077 |
|
8078 |
|
8079 | generateXYForText: function generateXYForText(indices, forX) {
|
8080 | var $$ = this,
|
8081 | types = Object.keys(indices),
|
8082 | points = {},
|
8083 | getter = forX ? $$.getXForText : $$.getYForText;
|
8084 | $$.hasType("radar") && types.push("radar");
|
8085 | types.forEach(function (v) {
|
8086 | points[v] = $$["generateGet" + capitalize(v) + "Points"](indices[v], !1);
|
8087 | });
|
8088 | return function (d, i) {
|
8089 | var type = $$.isAreaType(d) && "area" || $$.isBarType(d) && "bar" || $$.isCandlestickType(d) && "candlestick" || $$.isRadarType(d) && "radar" || "line";
|
8090 | return getter.call($$, points[type](d, i), d, this);
|
8091 | };
|
8092 | },
|
8093 |
|
8094 | |
8095 |
|
8096 |
|
8097 |
|
8098 |
|
8099 |
|
8100 |
|
8101 |
|
8102 | getCenteredTextPos: function getCenteredTextPos(d, points, textElement) {
|
8103 | var $$ = this,
|
8104 | config = $$.config,
|
8105 | isRotated = config.axis_rotated;
|
8106 |
|
8107 | if (config.data_labels.centered && $$.isBarType(d)) {
|
8108 | var rect = getBoundingRect(textElement),
|
8109 | isPositive = d.value >= 0;
|
8110 |
|
8111 | if (isRotated) {
|
8112 | var w = (isPositive ? points[1][1] - points[0][1] : points[0][1] - points[1][1]) / 2 + rect.width / 2;
|
8113 | return isPositive ? -w - 3 : w + 2;
|
8114 | } else {
|
8115 | var h = (isPositive ? points[0][1] - points[1][1] : points[1][1] - points[0][1]) / 2 + rect.height / 2;
|
8116 | return isPositive ? h : -h - 2;
|
8117 | }
|
8118 | }
|
8119 |
|
8120 | return 0;
|
8121 | },
|
8122 |
|
8123 | |
8124 |
|
8125 |
|
8126 |
|
8127 |
|
8128 |
|
8129 |
|
8130 | getTextPos: function getTextPos(id, type) {
|
8131 | var pos = this.config.data_labels_position;
|
8132 | return (id in pos ? pos[id] : pos)[type] || 0;
|
8133 | },
|
8134 |
|
8135 | |
8136 |
|
8137 |
|
8138 |
|
8139 |
|
8140 |
|
8141 |
|
8142 |
|
8143 | getXForText: function getXForText(points, d, textElement) {
|
8144 | var $$ = this,
|
8145 | config = $$.config,
|
8146 | state = $$.state,
|
8147 | isRotated = config.axis_rotated,
|
8148 | xPos = points[0][0];
|
8149 |
|
8150 | if ($$.hasType("candlestick")) {
|
8151 | if (isRotated) {
|
8152 | xPos = $$.getCandlestickData(d)._isUp ? points[2][2] + 4 : points[2][1] - 4;
|
8153 | } else {
|
8154 | xPos += (points[1][0] - xPos) / 2;
|
8155 | }
|
8156 | } else {
|
8157 | if (isRotated) {
|
8158 | var padding = $$.isBarType(d) ? 4 : 6;
|
8159 | xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1);
|
8160 | } else {
|
8161 | xPos = $$.hasType("bar") ? (points[2][0] + points[0][0]) / 2 : xPos;
|
8162 | }
|
8163 | }
|
8164 |
|
8165 |
|
8166 | if (d.value === null) {
|
8167 | if (xPos > state.width) {
|
8168 | var _getBoundingRect = getBoundingRect(textElement),
|
8169 | width = _getBoundingRect.width;
|
8170 |
|
8171 | xPos = state.width - width;
|
8172 | } else if (xPos < 0) {
|
8173 | xPos = 4;
|
8174 | }
|
8175 | }
|
8176 |
|
8177 | if (isRotated) {
|
8178 | xPos += $$.getCenteredTextPos(d, points, textElement);
|
8179 | }
|
8180 |
|
8181 | return xPos + $$.getTextPos(d.id, "x");
|
8182 | },
|
8183 |
|
8184 | |
8185 |
|
8186 |
|
8187 |
|
8188 |
|
8189 |
|
8190 |
|
8191 |
|
8192 | getYForText: function getYForText(points, d, textElement) {
|
8193 | var $$ = this,
|
8194 | config = $$.config,
|
8195 | state = $$.state,
|
8196 | isRotated = config.axis_rotated,
|
8197 | r = config.point_r,
|
8198 | rect = getBoundingRect(textElement),
|
8199 | value = d.value,
|
8200 | baseY = 3,
|
8201 | yPos;
|
8202 |
|
8203 | if ($$.isCandlestickType(d)) {
|
8204 | value = $$.getCandlestickData(d);
|
8205 |
|
8206 | if (isRotated) {
|
8207 | yPos = points[0][0];
|
8208 | yPos += (points[1][0] - yPos) / 2 + baseY;
|
8209 | } else {
|
8210 | yPos = value && value._isUp ? points[2][2] - baseY : points[2][1] + baseY * 4;
|
8211 | }
|
8212 | } else {
|
8213 | if (isRotated) {
|
8214 | yPos = (points[0][0] + points[2][0] + rect.height * .6) / 2;
|
8215 | } else {
|
8216 | yPos = points[2][1];
|
8217 |
|
8218 | if (isNumber(r) && r > 5 && ($$.isLineType(d) || $$.isScatterType(d))) {
|
8219 | baseY += config.point_r / 2.3;
|
8220 | }
|
8221 |
|
8222 | if (value < 0 || value === 0 && !state.hasPositiveValue && state.hasNegativeValue) {
|
8223 | yPos += rect.height + ($$.isBarType(d) ? -baseY : baseY);
|
8224 | } else {
|
8225 | var diff = -baseY * 2;
|
8226 |
|
8227 | if ($$.isBarType(d)) {
|
8228 | diff = -baseY;
|
8229 | } else if ($$.isBubbleType(d)) {
|
8230 | diff = baseY;
|
8231 | }
|
8232 |
|
8233 | yPos += diff;
|
8234 | }
|
8235 | }
|
8236 | }
|
8237 |
|
8238 |
|
8239 | if (d.value === null && !isRotated) {
|
8240 | var boxHeight = rect.height;
|
8241 |
|
8242 | if (yPos < boxHeight) {
|
8243 | yPos = boxHeight;
|
8244 | } else if (yPos > state.height) {
|
8245 | yPos = state.height - 4;
|
8246 | }
|
8247 | }
|
8248 |
|
8249 | if (!isRotated) {
|
8250 | yPos += $$.getCenteredTextPos(d, points, textElement);
|
8251 | }
|
8252 |
|
8253 | return yPos + $$.getTextPos(d.id, "y");
|
8254 | },
|
8255 |
|
8256 | |
8257 |
|
8258 |
|
8259 |
|
8260 |
|
8261 |
|
8262 |
|
8263 |
|
8264 | markOverlapped: function markOverlapped(id, $$, selector) {
|
8265 | var textNodes = $$.$el.arcs.selectAll(selector),
|
8266 | filteredTextNodes = textNodes.filter(function (node) {
|
8267 | return node.data.id !== id;
|
8268 | }),
|
8269 | textNode = textNodes.filter(function (node) {
|
8270 | return node.data.id === id;
|
8271 | }),
|
8272 | translate = getTranslation(textNode.node()),
|
8273 | calcHypo = function (x, y) {
|
8274 | return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
|
8275 | };
|
8276 |
|
8277 | textNode.node() && filteredTextNodes.each(function () {
|
8278 | var coordinate = getTranslation(this),
|
8279 | filteredTextNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
8280 | nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : filteredTextNode,
|
8281 | overlapsX = Math.ceil(Math.abs(translate.e - coordinate.e)) < Math.ceil(nodeForWidth.node().getComputedTextLength()),
|
8282 | overlapsY = Math.ceil(Math.abs(translate.f - coordinate.f)) < parseInt(textNode.style("font-size"), 10);
|
8283 | filteredTextNode.classed(config_classes.TextOverlapping, overlapsX && overlapsY);
|
8284 | });
|
8285 | },
|
8286 |
|
8287 | |
8288 |
|
8289 |
|
8290 |
|
8291 |
|
8292 |
|
8293 |
|
8294 | undoMarkOverlapped: function undoMarkOverlapped($$, selector) {
|
8295 | $$.$el.arcs.selectAll(selector).each(function () {
|
8296 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([this, this.previousSibling]).classed(config_classes.TextOverlapping, !1);
|
8297 | });
|
8298 | },
|
8299 |
|
8300 | |
8301 |
|
8302 |
|
8303 |
|
8304 |
|
8305 |
|
8306 |
|
8307 | meetsLabelThreshold: function meetsLabelThreshold(ratio, type) {
|
8308 | if (ratio === void 0) {
|
8309 | ratio = 0;
|
8310 | }
|
8311 |
|
8312 | var $$ = this,
|
8313 | config = $$.config,
|
8314 | threshold = config[type + "_label_threshold"] || 0;
|
8315 | return ratio >= threshold;
|
8316 | }
|
8317 | });
|
8318 | ;
|
8319 |
|
8320 |
|
8321 |
|
8322 |
|
8323 |
|
8324 |
|
8325 |
|
8326 |
|
8327 |
|
8328 |
|
8329 |
|
8330 |
|
8331 |
|
8332 |
|
8333 | function getTextPos(pos, width) {
|
8334 | if (pos === void 0) {
|
8335 | pos = "left";
|
8336 | }
|
8337 |
|
8338 | var isNum = isNumber(width),
|
8339 | position;
|
8340 |
|
8341 | if (pos.indexOf("center") > -1) {
|
8342 | position = isNum ? width / 2 : "middle";
|
8343 | } else if (pos.indexOf("right") > -1) {
|
8344 | position = isNum ? width : "end";
|
8345 | } else {
|
8346 | position = isNum ? 0 : "start";
|
8347 | }
|
8348 |
|
8349 | return position;
|
8350 | }
|
8351 |
|
8352 | var internals_title = ({
|
8353 | |
8354 |
|
8355 |
|
8356 |
|
8357 | initTitle: function initTitle() {
|
8358 | var $$ = this,
|
8359 | config = $$.config,
|
8360 | $el = $$.$el;
|
8361 |
|
8362 | if (config.title_text) {
|
8363 | $el.title = $el.svg.append("g");
|
8364 | var text = $el.title.append("text").style("text-anchor", getTextPos(config.title_position)).attr("class", config_classes.title);
|
8365 | setTextValue(text, config.title_text, [.3, 1.5]);
|
8366 | }
|
8367 | },
|
8368 |
|
8369 | |
8370 |
|
8371 |
|
8372 |
|
8373 | redrawTitle: function redrawTitle() {
|
8374 | var $$ = this,
|
8375 | config = $$.config,
|
8376 | current = $$.state.current,
|
8377 | title = $$.$el.title;
|
8378 |
|
8379 | if (title) {
|
8380 | var y = $$.yForTitle.call($$);
|
8381 |
|
8382 | if (/g/i.test(title.node().tagName)) {
|
8383 | title.attr("transform", "translate(" + getTextPos(config.title_position, current.width) + ", " + y + ")");
|
8384 | } else {
|
8385 | title.attr("x", $$.xForTitle.call($$)).attr("y", y);
|
8386 | }
|
8387 | }
|
8388 | },
|
8389 |
|
8390 | |
8391 |
|
8392 |
|
8393 |
|
8394 |
|
8395 | xForTitle: function xForTitle() {
|
8396 | var $$ = this,
|
8397 | config = $$.config,
|
8398 | current = $$.state.current,
|
8399 | position = config.title_position || "left",
|
8400 | textRectWidth = $$.getTextRect($$.$el.title, config_classes.title).width,
|
8401 | x;
|
8402 |
|
8403 | if (/(right|center)/.test(position)) {
|
8404 | x = current.width - textRectWidth;
|
8405 |
|
8406 | if (position.indexOf("right") >= 0) {
|
8407 | x = current.width - textRectWidth - config.title_padding.right;
|
8408 | } else if (position.indexOf("center") >= 0) {
|
8409 | x = (current.width - textRectWidth) / 2;
|
8410 | }
|
8411 | } else {
|
8412 |
|
8413 | x = config.title_padding.left || 0;
|
8414 | }
|
8415 |
|
8416 | return x;
|
8417 | },
|
8418 |
|
8419 | |
8420 |
|
8421 |
|
8422 |
|
8423 |
|
8424 | yForTitle: function yForTitle() {
|
8425 | var $$ = this;
|
8426 | return ($$.config.title_padding.top || 0) + $$.getTextRect($$.$el.title, config_classes.title).height;
|
8427 | },
|
8428 |
|
8429 | |
8430 |
|
8431 |
|
8432 |
|
8433 |
|
8434 | getTitlePadding: function getTitlePadding() {
|
8435 | var $$ = this;
|
8436 | return $$.yForTitle() + ($$.config.title_padding.bottom || 0);
|
8437 | }
|
8438 | });
|
8439 | ;
|
8440 |
|
8441 |
|
8442 |
|
8443 |
|
8444 |
|
8445 |
|
8446 |
|
8447 |
|
8448 | var internals_tooltip = ({
|
8449 | |
8450 |
|
8451 |
|
8452 |
|
8453 | initTooltip: function initTooltip() {
|
8454 | var $$ = this,
|
8455 | config = $$.config,
|
8456 | $el = $$.$el;
|
8457 | $el.tooltip = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(config.tooltip_contents.bindto);
|
8458 |
|
8459 | if ($el.tooltip.empty()) {
|
8460 | $el.tooltip = $el.chart.style("position", "relative").append("div").attr("class", config_classes.tooltipContainer).style("position", "absolute").style("pointer-events", "none").style("display", "none");
|
8461 | }
|
8462 |
|
8463 | $$.bindTooltipResizePos();
|
8464 | },
|
8465 | initShowTooltip: function initShowTooltip() {
|
8466 | var $$ = this,
|
8467 | config = $$.config,
|
8468 | $el = $$.$el,
|
8469 | _$$$state = $$.state,
|
8470 | hasAxis = _$$$state.hasAxis,
|
8471 | hasRadar = _$$$state.hasRadar;
|
8472 |
|
8473 |
|
8474 | if (config.tooltip_init_show) {
|
8475 | var _$$$axis,
|
8476 | _$$$axis2,
|
8477 | isArc = !(hasAxis && hasRadar);
|
8478 |
|
8479 | if ((_$$$axis = $$.axis) != null && _$$$axis.isTimeSeries() && isString(config.tooltip_init_x)) {
|
8480 | var targets = $$.data.targets[0],
|
8481 | i,
|
8482 | val;
|
8483 | config.tooltip_init_x = parseDate.call($$, config.tooltip_init_x);
|
8484 |
|
8485 | for (i = 0; val = targets.values[i]; i++) {
|
8486 | if (val.x - config.tooltip_init_x === 0) {
|
8487 | break;
|
8488 | }
|
8489 | }
|
8490 |
|
8491 | config.tooltip_init_x = i;
|
8492 | }
|
8493 |
|
8494 | var data = $$.data.targets.map(function (d) {
|
8495 | var x = isArc ? 0 : config.tooltip_init_x;
|
8496 | return $$.addName(d.values[x]);
|
8497 | });
|
8498 |
|
8499 | if (isArc) {
|
8500 | data = [data[config.tooltip_init_x]];
|
8501 | }
|
8502 |
|
8503 | $el.tooltip.html($$.getTooltipHTML(data, (_$$$axis2 = $$.axis) == null ? void 0 : _$$$axis2.getXAxisTickFormat(), $$.getDefaultValueFormat(), $$.color));
|
8504 |
|
8505 | if (!config.tooltip_contents.bindto) {
|
8506 | $el.tooltip.style("top", config.tooltip_init_position.top).style("left", config.tooltip_init_position.left).style("display", null);
|
8507 | }
|
8508 | }
|
8509 | },
|
8510 |
|
8511 | |
8512 |
|
8513 |
|
8514 |
|
8515 |
|
8516 |
|
8517 | getTooltipHTML: function getTooltipHTML() {
|
8518 | var $$ = this,
|
8519 | api = $$.api,
|
8520 | config = $$.config;
|
8521 | return isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api).apply(void 0, arguments) : $$.getTooltipContent.apply($$, arguments);
|
8522 | },
|
8523 |
|
8524 | |
8525 |
|
8526 |
|
8527 |
|
8528 |
|
8529 |
|
8530 |
|
8531 |
|
8532 |
|
8533 | getTooltipContent: function getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) {
|
8534 | var $$ = this,
|
8535 | api = $$.api,
|
8536 | config = $$.config,
|
8537 | state = $$.state,
|
8538 | _map = ["title", "name", "value"].map(function (v) {
|
8539 | var fn = config["tooltip_format_" + v];
|
8540 | return isFunction(fn) ? fn.bind(api) : fn;
|
8541 | }),
|
8542 | titleFormat = _map[0],
|
8543 | nameFormat = _map[1],
|
8544 | valueFormat = _map[2];
|
8545 |
|
8546 | titleFormat = titleFormat || defaultTitleFormat;
|
8547 |
|
8548 | nameFormat = nameFormat || function (name) {
|
8549 | return name;
|
8550 | };
|
8551 |
|
8552 | valueFormat = valueFormat || ($$.isStackNormalized() ? function (v, ratio) {
|
8553 | return (ratio * 100).toFixed(2) + "%";
|
8554 | } : defaultValueFormat);
|
8555 |
|
8556 | var order = config.tooltip_order,
|
8557 | getRowValue = function (row) {
|
8558 | return $$.axis && $$.isBubbleZType(row) ? $$.getBubbleZData(row.value, "z") : $$.getBaseValue(row);
|
8559 | },
|
8560 | getBgColor = $$.levelColor ? function (row) {
|
8561 | return $$.levelColor(row.value);
|
8562 | } : function (row) {
|
8563 | return color(row);
|
8564 | },
|
8565 | contents = config.tooltip_contents,
|
8566 | tplStr = contents.template,
|
8567 | targetIds = $$.mapToTargetIds();
|
8568 |
|
8569 | if (order === null && config.data_groups.length) {
|
8570 |
|
8571 | var ids = $$.orderTargets($$.data.targets).map(function (i2) {
|
8572 | return i2.id;
|
8573 | }).reverse();
|
8574 | d.sort(function (a, b) {
|
8575 | var v1 = a ? a.value : null,
|
8576 | v2 = b ? b.value : null;
|
8577 |
|
8578 | if (v1 > 0 && v2 > 0) {
|
8579 | v1 = a.id ? ids.indexOf(a.id) : null;
|
8580 | v2 = b.id ? ids.indexOf(b.id) : null;
|
8581 | }
|
8582 |
|
8583 | return v1 - v2;
|
8584 | });
|
8585 | } else if (/^(asc|desc)$/.test(order)) {
|
8586 | d.sort(function (a, b) {
|
8587 | var v1 = a ? getRowValue(a) : null,
|
8588 | v2 = b ? getRowValue(b) : null;
|
8589 | return order === "asc" ? v1 - v2 : v2 - v1;
|
8590 | });
|
8591 | } else if (isFunction(order)) {
|
8592 | d.sort(order.bind(api));
|
8593 | }
|
8594 |
|
8595 | var tpl = $$.getTooltipContentTemplate(tplStr),
|
8596 | len = d.length,
|
8597 | text,
|
8598 | row,
|
8599 | param,
|
8600 | value,
|
8601 | i;
|
8602 |
|
8603 | for (i = 0; i < len; i++) {
|
8604 | row = d[i];
|
8605 |
|
8606 | if (!row || !(getRowValue(row) || getRowValue(row) === 0)) {
|
8607 | continue;
|
8608 | }
|
8609 |
|
8610 | if (isUndefined(text)) {
|
8611 | var title = (state.hasAxis || state.hasRadar) && sanitise(titleFormat ? titleFormat(row.x) : row.x);
|
8612 | text = tplProcess(tpl[0], {
|
8613 | CLASS_TOOLTIP: config_classes.tooltip,
|
8614 | TITLE: isValue(title) ? tplStr ? title : "<tr><th colspan=\"2\">" + title + "</th></tr>" : ""
|
8615 | });
|
8616 | }
|
8617 |
|
8618 | if (!row.ratio && $$.$el.arcs) {
|
8619 | row.ratio = $$.getRatio("arc", $$.$el.arcs.select("path." + config_classes.arc + "-" + row.id).data()[0]);
|
8620 | }
|
8621 |
|
8622 | param = [row.ratio, row.id, row.index, d];
|
8623 | value = sanitise(valueFormat.apply(void 0, [getRowValue(row)].concat(param)));
|
8624 |
|
8625 | if ($$.isAreaRangeType(row)) {
|
8626 | var _map2 = ["high", "low"].map(function (v) {
|
8627 | return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v)].concat(param)));
|
8628 | }),
|
8629 | high = _map2[0],
|
8630 | low = _map2[1];
|
8631 |
|
8632 | value = "<b>Mid:</b> " + value + " <b>High:</b> " + high + " <b>Low:</b> " + low;
|
8633 | } else if ($$.isCandlestickType(row)) {
|
8634 | var _map3 = ["open", "high", "low", "close", "volume"].map(function (v) {
|
8635 | return sanitise(valueFormat.apply(void 0, [$$.getRangedData(row, v, "candlestick")].concat(param)));
|
8636 | }),
|
8637 | open = _map3[0],
|
8638 | _high = _map3[1],
|
8639 | _low = _map3[2],
|
8640 | close = _map3[3],
|
8641 | volume = _map3[4];
|
8642 |
|
8643 | value = "<b>Open:</b> " + open + " <b>High:</b> " + _high + " <b>Low:</b> " + _low + " <b>Close:</b> " + close + (volume ? " <b>Volume:</b> " + volume : "");
|
8644 | }
|
8645 |
|
8646 | if (value !== undefined) {
|
8647 | var _ret = function () {
|
8648 |
|
8649 | if (row.name === null) {
|
8650 | return "continue";
|
8651 | }
|
8652 |
|
8653 | var name = sanitise(nameFormat.apply(void 0, [row.name].concat(param))),
|
8654 | color = getBgColor(row),
|
8655 | contentValue = {
|
8656 | CLASS_TOOLTIP_NAME: config_classes.tooltipName + $$.getTargetSelectorSuffix(row.id),
|
8657 | COLOR: tplStr || !$$.patterns ? color : "<svg><rect style=\"fill:" + color + "\" width=\"10\" height=\"10\"></rect></svg>",
|
8658 | NAME: name,
|
8659 | VALUE: value
|
8660 | };
|
8661 |
|
8662 | if (tplStr && isObject(contents.text)) {
|
8663 | var index = targetIds.indexOf(row.id);
|
8664 | Object.keys(contents.text).forEach(function (key) {
|
8665 | contentValue[key] = contents.text[key][index];
|
8666 | });
|
8667 | }
|
8668 |
|
8669 | text += tplProcess(tpl[1], contentValue);
|
8670 | }();
|
8671 |
|
8672 | if (_ret === "continue") continue;
|
8673 | }
|
8674 | }
|
8675 |
|
8676 | return text + "</table>";
|
8677 | },
|
8678 |
|
8679 | |
8680 |
|
8681 |
|
8682 |
|
8683 |
|
8684 |
|
8685 | getTooltipContentTemplate: function getTooltipContentTemplate(tplStr) {
|
8686 | return (tplStr || "<table class=\"{=CLASS_TOOLTIP}\"><tbody>\n\t\t\t\t{=TITLE}\n\t\t\t\t{{<tr class=\"{=CLASS_TOOLTIP_NAME}\">\n\t\t\t\t\t<td class=\"name\">" + (this.patterns ? "{=COLOR}" : "<span style=\"background-color:{=COLOR}\"></span>") + "{=NAME}</td>\n\t\t\t\t\t<td class=\"value\">{=VALUE}</td>\n\t\t\t\t</tr>}}\n\t\t\t</tbody></table>").replace(/(\r?\n|\t)/g, "").split(/{{(.*)}}/);
|
8687 | },
|
8688 |
|
8689 | |
8690 |
|
8691 |
|
8692 |
|
8693 |
|
8694 |
|
8695 |
|
8696 |
|
8697 |
|
8698 | tooltipPosition: function tooltipPosition(dataToShow, tWidth, tHeight, element) {
|
8699 | var $$ = this,
|
8700 | config = $$.config,
|
8701 | scale = $$.scale,
|
8702 | state = $$.state,
|
8703 | _state = state,
|
8704 | width = _state.width,
|
8705 | height = _state.height,
|
8706 | current = _state.current,
|
8707 | isLegendRight = _state.isLegendRight,
|
8708 | inputType = _state.inputType,
|
8709 | event = _state.event,
|
8710 | hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle,
|
8711 | svgLeft = $$.getSvgLeft(!0),
|
8712 | chartRight = svgLeft + current.width - $$.getCurrentPaddingRight(),
|
8713 | chartLeft = $$.getCurrentPaddingLeft(!0),
|
8714 | size = 20,
|
8715 | _getPointer = getPointer(event, element),
|
8716 | x = _getPointer[0],
|
8717 | y = _getPointer[1];
|
8718 |
|
8719 |
|
8720 | if ($$.hasArcType()) {
|
8721 | var raw = inputType === "touch" || $$.hasType("radar");
|
8722 |
|
8723 | if (!raw) {
|
8724 | y += hasGauge ? height : height / 2;
|
8725 | x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
|
8726 | }
|
8727 | } else {
|
8728 | var dataScale = scale.x(dataToShow[0].x);
|
8729 |
|
8730 | if (config.axis_rotated) {
|
8731 | y = dataScale + size;
|
8732 | x += svgLeft + 100;
|
8733 | chartRight -= svgLeft;
|
8734 | } else {
|
8735 | y -= 5;
|
8736 | x = svgLeft + chartLeft + size + ($$.scale.zoom ? x : dataScale);
|
8737 | }
|
8738 | }
|
8739 |
|
8740 |
|
8741 | if (x + tWidth + 15 > chartRight) {
|
8742 | x -= tWidth + chartLeft;
|
8743 | }
|
8744 |
|
8745 | if (y + tHeight > current.height) {
|
8746 | y -= hasGauge ? tHeight * 3 : tHeight + 30;
|
8747 | }
|
8748 |
|
8749 | var pos = {
|
8750 | top: y,
|
8751 | left: x
|
8752 | };
|
8753 |
|
8754 | Object.keys(pos).forEach(function (v) {
|
8755 | if (pos[v] < 0) {
|
8756 | pos[v] = 0;
|
8757 | }
|
8758 | });
|
8759 | return pos;
|
8760 | },
|
8761 |
|
8762 | |
8763 |
|
8764 |
|
8765 |
|
8766 |
|
8767 |
|
8768 | showTooltip: function showTooltip(selectedData, eventRect) {
|
8769 | var $$ = this,
|
8770 | config = $$.config,
|
8771 | scale = $$.scale,
|
8772 | state = $$.state,
|
8773 | tooltip = $$.$el.tooltip,
|
8774 | bindto = config.tooltip_contents.bindto,
|
8775 | dataToShow = selectedData.filter(function (d) {
|
8776 | return d && isValue($$.getBaseValue(d));
|
8777 | });
|
8778 |
|
8779 | if (!tooltip || dataToShow.length === 0 || !config.tooltip_show) {
|
8780 | return;
|
8781 | }
|
8782 |
|
8783 | var datum = tooltip.datum(),
|
8784 | _ref = datum || {},
|
8785 | _ref$width = _ref.width,
|
8786 | width = _ref$width === void 0 ? 0 : _ref$width,
|
8787 | _ref$height = _ref.height,
|
8788 | height = _ref$height === void 0 ? 0 : _ref$height,
|
8789 | dataStr = JSON.stringify(selectedData);
|
8790 |
|
8791 | if (!datum || datum.current !== dataStr) {
|
8792 | var index = selectedData.concat().sort()[0].index;
|
8793 | callFn(config.tooltip_onshow, $$.api, selectedData);
|
8794 |
|
8795 | tooltip.html($$.getTooltipHTML(selectedData,
|
8796 | $$.axis ? $$.axis.getXAxisTickFormat() : $$.categoryName.bind($$),
|
8797 | $$.getDefaultValueFormat(),
|
8798 | $$.color
|
8799 | )).style("display", null).style("visibility", null)
|
8800 | .datum(datum = {
|
8801 | index: index,
|
8802 | current: dataStr,
|
8803 | width: width = tooltip.property("offsetWidth"),
|
8804 | height: height = tooltip.property("offsetHeight")
|
8805 | });
|
8806 | callFn(config.tooltip_onshown, $$.api, selectedData);
|
8807 |
|
8808 | $$._handleLinkedCharts(!0, index);
|
8809 | }
|
8810 |
|
8811 | if (!bindto) {
|
8812 | var _config$tooltip_posit,
|
8813 | _selectedData$filter,
|
8814 | fnPos = ((_config$tooltip_posit = config.tooltip_position) == null ? void 0 : _config$tooltip_posit.bind($$.api)) || $$.tooltipPosition.bind($$),
|
8815 | _getPointer2 = getPointer(state.event, eventRect),
|
8816 | x = _getPointer2[0],
|
8817 | y = _getPointer2[1],
|
8818 | currPos = {
|
8819 | x: x,
|
8820 | y: y
|
8821 | },
|
8822 | data = (_selectedData$filter = selectedData.filter(Boolean)) == null ? void 0 : _selectedData$filter.shift();
|
8823 |
|
8824 | if (scale.x && data && "x" in data) {
|
8825 | currPos.xAxis = scale.x(data.x);
|
8826 | }
|
8827 |
|
8828 |
|
8829 | var pos = fnPos(dataToShow, width, height, eventRect, currPos);
|
8830 | ["top", "left"].forEach(function (v) {
|
8831 | var value = pos[v];
|
8832 | tooltip.style(v, value + "px");
|
8833 |
|
8834 | if (v === "left" && !datum.xPosInPercent) {
|
8835 | datum.xPosInPercent = value / state.current.width * 100;
|
8836 | }
|
8837 | });
|
8838 | }
|
8839 | },
|
8840 |
|
8841 | |
8842 |
|
8843 |
|
8844 |
|
8845 | bindTooltipResizePos: function bindTooltipResizePos() {
|
8846 | var $$ = this,
|
8847 | resizeFunction = $$.resizeFunction,
|
8848 | state = $$.state,
|
8849 | tooltip = $$.$el.tooltip;
|
8850 | resizeFunction.add(function () {
|
8851 | if (tooltip.style("display") === "block") {
|
8852 | var current = state.current,
|
8853 | _tooltip$datum = tooltip.datum(),
|
8854 | width = _tooltip$datum.width,
|
8855 | xPosInPercent = _tooltip$datum.xPosInPercent,
|
8856 | _value = current.width / 100 * xPosInPercent,
|
8857 | diff = current.width - (_value + width);
|
8858 |
|
8859 |
|
8860 | if (diff < 0) {
|
8861 | _value += diff;
|
8862 | }
|
8863 |
|
8864 | tooltip.style("left", _value + "px");
|
8865 | }
|
8866 | });
|
8867 | },
|
8868 |
|
8869 | |
8870 |
|
8871 |
|
8872 |
|
8873 |
|
8874 | hideTooltip: function hideTooltip(force) {
|
8875 | var $$ = this,
|
8876 | api = $$.api,
|
8877 | config = $$.config,
|
8878 | tooltip = $$.$el.tooltip;
|
8879 |
|
8880 | if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
|
8881 | var selectedData = JSON.parse(tooltip.datum().current);
|
8882 | callFn(config.tooltip_onhide, api, selectedData);
|
8883 |
|
8884 | tooltip.style("display", "none").style("visibility", "hidden")
|
8885 | .datum(null);
|
8886 | callFn(config.tooltip_onhidden, api, selectedData);
|
8887 | }
|
8888 | },
|
8889 |
|
8890 | |
8891 |
|
8892 |
|
8893 |
|
8894 |
|
8895 |
|
8896 | _handleLinkedCharts: function _handleLinkedCharts(show, index) {
|
8897 | var _event,
|
8898 | $$ = this,
|
8899 | charts = $$.charts,
|
8900 | config = $$.config,
|
8901 | event = $$.state.event;
|
8902 |
|
8903 |
|
8904 |
|
8905 | if ((_event = event) != null && _event.isTrusted && config.tooltip_linked && charts.length > 1) {
|
8906 | var linkedName = config.tooltip_linked_name;
|
8907 | charts.filter(function (c) {
|
8908 | return c !== $$.api;
|
8909 | }).forEach(function (c) {
|
8910 | var _c$internal = c.internal,
|
8911 | config = _c$internal.config,
|
8912 | $el = _c$internal.$el,
|
8913 | isLinked = config.tooltip_linked,
|
8914 | name = config.tooltip_linked_name,
|
8915 | isInDom = browser_doc.body.contains($el.chart.node());
|
8916 |
|
8917 | if (isLinked && linkedName === name && isInDom) {
|
8918 | var data = $el.tooltip.data()[0],
|
8919 | isNotSameIndex = index !== (data == null ? void 0 : data.index);
|
8920 |
|
8921 | try {
|
8922 | c.tooltip[show && isNotSameIndex ? "show" : "hide"]({
|
8923 | index: index
|
8924 | });
|
8925 | } catch (e) {}
|
8926 | }
|
8927 | });
|
8928 | }
|
8929 | }
|
8930 | });
|
8931 | ;
|
8932 |
|
8933 |
|
8934 |
|
8935 |
|
8936 |
|
8937 |
|
8938 | var transform = ({
|
8939 | getTranslate: function getTranslate(target, index) {
|
8940 | if (index === void 0) {
|
8941 | index = 0;
|
8942 | }
|
8943 |
|
8944 | var $$ = this,
|
8945 | config = $$.config,
|
8946 | state = $$.state,
|
8947 | isRotated = config.axis_rotated,
|
8948 | padding = 0,
|
8949 | x,
|
8950 | y;
|
8951 |
|
8952 | if (index && /^(x|y2?)$/.test(target)) {
|
8953 | padding = $$.getAxisSize(target) * index;
|
8954 | }
|
8955 |
|
8956 | if (target === "main") {
|
8957 | x = asHalfPixel(state.margin.left);
|
8958 | y = asHalfPixel(state.margin.top);
|
8959 | } else if (target === "context") {
|
8960 | x = asHalfPixel(state.margin2.left);
|
8961 | y = asHalfPixel(state.margin2.top);
|
8962 | } else if (target === "legend") {
|
8963 | x = state.margin3.left;
|
8964 | y = state.margin3.top;
|
8965 | } else if (target === "x") {
|
8966 | x = isRotated ? -padding : 0;
|
8967 | y = isRotated ? 0 : state.height + padding;
|
8968 | } else if (target === "y") {
|
8969 | x = isRotated ? 0 : -padding;
|
8970 | y = isRotated ? state.height + padding : 0;
|
8971 | } else if (target === "y2") {
|
8972 | x = isRotated ? 0 : state.width + padding;
|
8973 | y = isRotated ? 1 - padding : 0;
|
8974 | } else if (target === "subX") {
|
8975 | x = 0;
|
8976 | y = isRotated ? 0 : state.height2;
|
8977 | } else if (target === "arc") {
|
8978 | x = state.arcWidth / 2;
|
8979 | y = state.arcHeight / 2;
|
8980 | } else if (target === "radar") {
|
8981 | var _$$$getRadarSize = $$.getRadarSize(),
|
8982 | width = _$$$getRadarSize[0];
|
8983 |
|
8984 | x = state.width / 2 - width;
|
8985 | y = asHalfPixel(state.margin.top);
|
8986 | }
|
8987 |
|
8988 | return "translate(" + x + ", " + y + ")";
|
8989 | },
|
8990 | transformMain: function transformMain(withTransition, transitions) {
|
8991 | var $$ = this,
|
8992 | main = $$.$el.main,
|
8993 | $T = $$.$T,
|
8994 | xAxis = transitions != null && transitions.axisX ? transitions.axisX : $T(main.select("." + config_classes.axisX), withTransition),
|
8995 | yAxis = transitions != null && transitions.axisY ? transitions.axisY : $T(main.select("." + config_classes.axisY), withTransition),
|
8996 | y2Axis = transitions != null && transitions.axisY2 ? transitions.axisY2 : $T(main.select("." + config_classes.axisY2), withTransition);
|
8997 | $T(main, withTransition).attr("transform", $$.getTranslate("main"));
|
8998 | xAxis.attr("transform", $$.getTranslate("x"));
|
8999 | yAxis.attr("transform", $$.getTranslate("y"));
|
9000 | y2Axis.attr("transform", $$.getTranslate("y2"));
|
9001 | main.select("." + config_classes.chartArcs).attr("transform", $$.getTranslate("arc"));
|
9002 | },
|
9003 | transformAll: function transformAll(withTransition, transitions) {
|
9004 | var $$ = this,
|
9005 | config = $$.config,
|
9006 | hasAxis = $$.state.hasAxis,
|
9007 | $el = $$.$el;
|
9008 | $$.transformMain(withTransition, transitions);
|
9009 | hasAxis && config.subchart_show && $$.transformContext(withTransition, transitions);
|
9010 | $el.legend && $$.transformLegend(withTransition);
|
9011 | }
|
9012 | });
|
9013 | ;
|
9014 |
|
9015 |
|
9016 |
|
9017 |
|
9018 |
|
9019 |
|
9020 | var type = ({
|
9021 | setTargetType: function setTargetType(targetIds, type) {
|
9022 | var $$ = this,
|
9023 | config = $$.config,
|
9024 | withoutFadeIn = $$.state.withoutFadeIn;
|
9025 | $$.mapToTargetIds(targetIds).forEach(function (id) {
|
9026 | withoutFadeIn[id] = type === config.data_types[id];
|
9027 | config.data_types[id] = type;
|
9028 | });
|
9029 |
|
9030 | if (!targetIds) {
|
9031 | config.data_type = type;
|
9032 | }
|
9033 | },
|
9034 |
|
9035 | |
9036 |
|
9037 |
|
9038 |
|
9039 | updateTypesElements: function updateTypesElements() {
|
9040 | var $$ = this,
|
9041 | current = $$.state.current;
|
9042 | Object.keys(TYPE).forEach(function (v) {
|
9043 | var t = TYPE[v],
|
9044 | has = $$.hasType(t, null, !0),
|
9045 | idx = current.types.indexOf(t);
|
9046 |
|
9047 | if (idx === -1 && has) {
|
9048 | current.types.push(t);
|
9049 | } else if (idx > -1 && !has) {
|
9050 | current.types.splice(idx, 1);
|
9051 | }
|
9052 | });
|
9053 |
|
9054 | $$.setChartElements();
|
9055 | },
|
9056 |
|
9057 | |
9058 |
|
9059 |
|
9060 |
|
9061 |
|
9062 |
|
9063 |
|
9064 |
|
9065 | hasType: function hasType(type, targetsValue, checkFromData) {
|
9066 | var _current$types, _targets;
|
9067 |
|
9068 | if (checkFromData === void 0) {
|
9069 | checkFromData = !1;
|
9070 | }
|
9071 |
|
9072 | var $$ = this,
|
9073 | config = $$.config,
|
9074 | current = $$.state.current,
|
9075 | types = config.data_types,
|
9076 | targets = targetsValue || $$.data.targets,
|
9077 | has = !1;
|
9078 |
|
9079 | if (!checkFromData && ((_current$types = current.types) == null ? void 0 : _current$types.indexOf(type)) > -1) {
|
9080 | has = !0;
|
9081 | } else if ((_targets = targets) != null && _targets.length) {
|
9082 | targets.forEach(function (target) {
|
9083 | var t = types[target.id];
|
9084 |
|
9085 | if (t === type || !t && type === "line") {
|
9086 | has = !0;
|
9087 | }
|
9088 | });
|
9089 | } else if (Object.keys(types).length) {
|
9090 | Object.keys(types).forEach(function (id) {
|
9091 | if (types[id] === type) {
|
9092 | has = !0;
|
9093 | }
|
9094 | });
|
9095 | } else {
|
9096 | has = config.data_type === type;
|
9097 | }
|
9098 |
|
9099 | return has;
|
9100 | },
|
9101 |
|
9102 | |
9103 |
|
9104 |
|
9105 |
|
9106 |
|
9107 |
|
9108 |
|
9109 |
|
9110 | hasTypeOf: function hasTypeOf(type, targets, exclude) {
|
9111 | var _this = this;
|
9112 |
|
9113 | if (exclude === void 0) {
|
9114 | exclude = [];
|
9115 | }
|
9116 |
|
9117 | if (type in TYPE_BY_CATEGORY) {
|
9118 | return !TYPE_BY_CATEGORY[type].filter(function (v) {
|
9119 | return exclude.indexOf(v) === -1;
|
9120 | }).every(function (v) {
|
9121 | return !_this.hasType(v, targets);
|
9122 | });
|
9123 | }
|
9124 |
|
9125 | return !1;
|
9126 | },
|
9127 |
|
9128 | |
9129 |
|
9130 |
|
9131 |
|
9132 |
|
9133 |
|
9134 |
|
9135 | isTypeOf: function isTypeOf(d, type) {
|
9136 | var id = isString(d) ? d : d.id,
|
9137 | dataType = this.config.data_types[id] || this.config.data_type;
|
9138 | return isArray(type) ? type.indexOf(dataType) >= 0 : dataType === type;
|
9139 | },
|
9140 | hasPointType: function hasPointType() {
|
9141 | var $$ = this;
|
9142 | return $$.hasTypeOf("Line") || $$.hasType("bubble") || $$.hasType("scatter");
|
9143 | },
|
9144 |
|
9145 | |
9146 |
|
9147 |
|
9148 |
|
9149 |
|
9150 |
|
9151 |
|
9152 | hasArcType: function hasArcType(targets, exclude) {
|
9153 | return this.hasTypeOf("Arc", targets, exclude);
|
9154 | },
|
9155 | hasMultiArcGauge: function hasMultiArcGauge() {
|
9156 | return this.hasType("gauge") && this.config.gauge_type === "multi";
|
9157 | },
|
9158 | isLineType: function isLineType(d) {
|
9159 | var id = isString(d) ? d : d.id;
|
9160 | return !this.config.data_types[id] || this.isTypeOf(id, TYPE_BY_CATEGORY.Line);
|
9161 | },
|
9162 | isStepType: function isStepType(d) {
|
9163 | return this.isTypeOf(d, TYPE_BY_CATEGORY.Step);
|
9164 | },
|
9165 | isSplineType: function isSplineType(d) {
|
9166 | return this.isTypeOf(d, TYPE_BY_CATEGORY.Spline);
|
9167 | },
|
9168 | isAreaType: function isAreaType(d) {
|
9169 | return this.isTypeOf(d, TYPE_BY_CATEGORY.Area);
|
9170 | },
|
9171 | isAreaRangeType: function isAreaRangeType(d) {
|
9172 | return this.isTypeOf(d, TYPE_BY_CATEGORY.AreaRange);
|
9173 | },
|
9174 | isBarType: function isBarType(d) {
|
9175 | return this.isTypeOf(d, "bar");
|
9176 | },
|
9177 | isBubbleType: function isBubbleType(d) {
|
9178 | return this.isTypeOf(d, "bubble");
|
9179 | },
|
9180 | isCandlestickType: function isCandlestickType(d) {
|
9181 | return this.isTypeOf(d, "candlestick");
|
9182 | },
|
9183 | isScatterType: function isScatterType(d) {
|
9184 | return this.isTypeOf(d, "scatter");
|
9185 | },
|
9186 | isPieType: function isPieType(d) {
|
9187 | return this.isTypeOf(d, "pie");
|
9188 | },
|
9189 | isGaugeType: function isGaugeType(d) {
|
9190 | return this.isTypeOf(d, "gauge");
|
9191 | },
|
9192 | isDonutType: function isDonutType(d) {
|
9193 | return this.isTypeOf(d, "donut");
|
9194 | },
|
9195 | isRadarType: function isRadarType(d) {
|
9196 | return this.isTypeOf(d, "radar");
|
9197 | },
|
9198 | isArcType: function isArcType(d) {
|
9199 | return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d) || this.isRadarType(d);
|
9200 | },
|
9201 |
|
9202 | isCirclePoint: function isCirclePoint(node) {
|
9203 | var config = this.config,
|
9204 | pattern = config.point_pattern,
|
9205 | isCircle = !1;
|
9206 |
|
9207 | if ((node == null ? void 0 : node.tagName) === "circle") {
|
9208 | isCircle = !0;
|
9209 | } else {
|
9210 | isCircle = config.point_type === "circle" && (!pattern || isArray(pattern) && pattern.length === 0);
|
9211 | }
|
9212 |
|
9213 | return isCircle;
|
9214 | },
|
9215 | lineData: function lineData(d) {
|
9216 | return this.isLineType(d) ? [d] : [];
|
9217 | },
|
9218 | arcData: function arcData(d) {
|
9219 | return this.isArcType(d.data) ? [d] : [];
|
9220 | },
|
9221 |
|
9222 | |
9223 |
|
9224 |
|
9225 |
|
9226 |
|
9227 |
|
9228 | labelishData: function labelishData(d) {
|
9229 | return this.isBarType(d) || this.isLineType(d) || this.isScatterType(d) || this.isBubbleType(d) || this.isCandlestickType(d) || this.isRadarType(d) ? d.values.filter(function (v) {
|
9230 | return isNumber(v.value) || !!v.value;
|
9231 | }) : [];
|
9232 | },
|
9233 | barLineBubbleData: function barLineBubbleData(d) {
|
9234 | return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ? d.values : [];
|
9235 | },
|
9236 |
|
9237 | isInterpolationType: function isInterpolationType(type) {
|
9238 | return ["basis", "basis-closed", "basis-open", "bundle", "cardinal", "cardinal-closed", "cardinal-open", "catmull-rom", "catmull-rom-closed", "catmull-rom-open", "linear", "linear-closed", "monotone-x", "monotone-y", "natural"].indexOf(type) >= 0;
|
9239 | }
|
9240 | });
|
9241 | ;
|
9242 |
|
9243 |
|
9244 |
|
9245 |
|
9246 |
|
9247 |
|
9248 |
|
9249 |
|
9250 |
|
9251 |
|
9252 |
|
9253 |
|
9254 |
|
9255 |
|
9256 |
|
9257 |
|
9258 |
|
9259 |
|
9260 |
|
9261 |
|
9262 |
|
9263 |
|
9264 |
|
9265 |
|
9266 |
|
9267 |
|
9268 |
|
9269 |
|
9270 |
|
9271 |
|
9272 |
|
9273 |
|
9274 |
|
9275 |
|
9276 |
|
9277 |
|
9278 |
|
9279 |
|
9280 |
|
9281 |
|
9282 |
|
9283 |
|
9284 |
|
9285 |
|
9286 |
|
9287 |
|
9288 | var ChartInternal = function () {
|
9289 |
|
9290 |
|
9291 |
|
9292 |
|
9293 |
|
9294 |
|
9295 |
|
9296 |
|
9297 |
|
9298 |
|
9299 |
|
9300 |
|
9301 |
|
9302 | function ChartInternal(api) {
|
9303 | this.api = void 0;
|
9304 | this.config = void 0;
|
9305 | this.cache = void 0;
|
9306 | this.$el = void 0;
|
9307 | this.state = void 0;
|
9308 | this.charts = void 0;
|
9309 | this.data = {
|
9310 | xs: {},
|
9311 | targets: []
|
9312 | };
|
9313 | this.axis = void 0;
|
9314 | this.scale = {
|
9315 | x: null,
|
9316 | y: null,
|
9317 | y2: null,
|
9318 | subX: null,
|
9319 | subY: null,
|
9320 | subY2: null,
|
9321 | zoom: null
|
9322 | };
|
9323 | this.org = {
|
9324 | xScale: null,
|
9325 | xDomain: null
|
9326 | };
|
9327 | this.color = void 0;
|
9328 | this.patterns = void 0;
|
9329 | this.levelColor = void 0;
|
9330 | this.point = void 0;
|
9331 | this.brush = void 0;
|
9332 | this.format = {
|
9333 | extraLineClasses: null,
|
9334 | xAxisTick: null,
|
9335 | dataTime: null,
|
9336 |
|
9337 | defaultAxisTime: null,
|
9338 |
|
9339 | axisTime: null
|
9340 |
|
9341 | };
|
9342 | var $$ = this;
|
9343 | $$.api = api;
|
9344 |
|
9345 | $$.config = new Options();
|
9346 | $$.cache = new Cache();
|
9347 | var store = new Store();
|
9348 | $$.$el = store.getStore("element");
|
9349 | $$.state = store.getStore("state");
|
9350 | $$.$T = $$.$T.bind($$);
|
9351 | }
|
9352 | |
9353 |
|
9354 |
|
9355 |
|
9356 |
|
9357 |
|
9358 |
|
9359 |
|
9360 |
|
9361 |
|
9362 | var _proto = ChartInternal.prototype;
|
9363 |
|
9364 | _proto.$T = function $T(selection, force, name) {
|
9365 | var config = this.config,
|
9366 | state = this.state,
|
9367 | duration = config.transition_duration,
|
9368 | subchart = config.subchart_show,
|
9369 | t = selection;
|
9370 |
|
9371 | if (t) {
|
9372 |
|
9373 | if ("tagName" in t) {
|
9374 | t = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(t);
|
9375 | }
|
9376 |
|
9377 |
|
9378 |
|
9379 |
|
9380 |
|
9381 |
|
9382 | var transit = (force !== !1 && duration || force) && (!state.zooming || state.dragging) && !state.resizing && state.rendered && !subchart;
|
9383 | t = transit ? t.transition(name).duration(duration) : t;
|
9384 | }
|
9385 |
|
9386 | return t;
|
9387 | };
|
9388 |
|
9389 | _proto.beforeInit = function beforeInit() {
|
9390 | var $$ = this;
|
9391 | $$.callPluginHook("$beforeInit");
|
9392 |
|
9393 | callFn($$.config.onbeforeinit, $$.api);
|
9394 | };
|
9395 |
|
9396 | _proto.afterInit = function afterInit() {
|
9397 | var $$ = this;
|
9398 | $$.callPluginHook("$afterInit");
|
9399 |
|
9400 | callFn($$.config.onafterinit, $$.api);
|
9401 | };
|
9402 |
|
9403 | _proto.init = function init() {
|
9404 | var $$ = this,
|
9405 | config = $$.config,
|
9406 | state = $$.state,
|
9407 | $el = $$.$el;
|
9408 | checkModuleImport($$);
|
9409 | state.hasAxis = !$$.hasArcType();
|
9410 | state.hasRadar = !state.hasAxis && $$.hasType("radar");
|
9411 | $$.initParams();
|
9412 | var bindto = {
|
9413 | element: config.bindto,
|
9414 | classname: "bb"
|
9415 | };
|
9416 |
|
9417 | if (isObject(config.bindto)) {
|
9418 | bindto.element = config.bindto.element || "#chart";
|
9419 | bindto.classname = config.bindto.classname || bindto.classname;
|
9420 | }
|
9421 |
|
9422 |
|
9423 | $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 || []);
|
9424 |
|
9425 | if ($el.chart.empty()) {
|
9426 | $el.chart = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.body.appendChild(browser_doc.createElement("div")));
|
9427 | }
|
9428 |
|
9429 | $el.chart.html("").classed(bindto.classname, !0);
|
9430 | $$.initToRender();
|
9431 | }
|
9432 | |
9433 |
|
9434 |
|
9435 |
|
9436 |
|
9437 | ;
|
9438 |
|
9439 | _proto.initToRender = function initToRender(forced) {
|
9440 | var $$ = this,
|
9441 | config = $$.config,
|
9442 | state = $$.state,
|
9443 | chart = $$.$el.chart,
|
9444 | isHidden = function () {
|
9445 | return chart.style("display") === "none" || chart.style("visibility") === "hidden";
|
9446 | },
|
9447 | isLazy = config.render.lazy || isHidden(),
|
9448 | MutationObserver = win.MutationObserver;
|
9449 |
|
9450 | if (isLazy && MutationObserver && config.render.observe !== !1 && !forced) {
|
9451 | new MutationObserver(function (mutation, observer) {
|
9452 | if (!isHidden()) {
|
9453 | observer.disconnect();
|
9454 | state.rendered || $$.initToRender(!0);
|
9455 | }
|
9456 | }).observe(chart.node(), {
|
9457 | attributes: !0,
|
9458 | attributeFilter: ["class", "style"]
|
9459 | });
|
9460 | }
|
9461 |
|
9462 | if (!isLazy || forced) {
|
9463 | var convertedData = $$.convertData(config, $$.initWithData);
|
9464 | convertedData && $$.initWithData(convertedData);
|
9465 | $$.afterInit();
|
9466 | }
|
9467 | };
|
9468 |
|
9469 | _proto.initParams = function initParams() {
|
9470 | var $$ = this,
|
9471 | _ref = $$,
|
9472 | config = _ref.config,
|
9473 | format = _ref.format,
|
9474 | state = _ref.state,
|
9475 | isRotated = config.axis_rotated;
|
9476 |
|
9477 | state.datetimeId = "bb-" + +new Date();
|
9478 | $$.color = $$.generateColor();
|
9479 | $$.levelColor = $$.generateLevelColor();
|
9480 |
|
9481 | if ($$.hasPointType()) {
|
9482 | $$.point = $$.generatePoint();
|
9483 | }
|
9484 |
|
9485 | if (state.hasAxis) {
|
9486 | $$.initClip();
|
9487 | format.extraLineClasses = $$.generateExtraLineClass();
|
9488 | format.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;
|
9489 | format.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;
|
9490 | var isDragZoom = $$.config.zoom_enabled && $$.config.zoom_type === "drag";
|
9491 |
|
9492 | format.defaultAxisTime = function (d) {
|
9493 | var _$$$scale = $$.scale,
|
9494 | x = _$$$scale.x,
|
9495 | zoom = _$$$scale.zoom,
|
9496 | isZoomed = isDragZoom ? zoom : zoom && x.orgDomain().toString() !== zoom.domain().toString(),
|
9497 | 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";
|
9498 | return format.axisTime(specifier)(d);
|
9499 | };
|
9500 | }
|
9501 |
|
9502 | state.isLegendRight = config.legend_position === "right";
|
9503 | state.isLegendInset = config.legend_position === "inset";
|
9504 | state.isLegendTop = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "top-right";
|
9505 | state.isLegendLeft = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "bottom-left";
|
9506 | state.rotatedPaddingRight = isRotated && !config.axis_x_show ? 0 : 30;
|
9507 | state.inputType = convertInputType(config.interaction_inputType_mouse, config.interaction_inputType_touch);
|
9508 | };
|
9509 |
|
9510 | _proto.initWithData = function initWithData(data) {
|
9511 | var $$ = this,
|
9512 | config = $$.config,
|
9513 | scale = $$.scale,
|
9514 | state = $$.state,
|
9515 | $el = $$.$el,
|
9516 | org = $$.org,
|
9517 | hasAxis = state.hasAxis,
|
9518 | hasInteraction = config.interaction_enabled;
|
9519 |
|
9520 |
|
9521 |
|
9522 | if (hasAxis) {
|
9523 | $$.axis = $$.getAxisInstance();
|
9524 | config.zoom_enabled && $$.initZoom();
|
9525 | }
|
9526 |
|
9527 |
|
9528 | $$.data.xs = {};
|
9529 | $$.data.targets = $$.convertDataToTargets(data);
|
9530 |
|
9531 | if (config.data_filter) {
|
9532 | $$.data.targets = $$.data.targets.filter(config.data_filter.bind($$.api));
|
9533 | }
|
9534 |
|
9535 |
|
9536 | if (config.data_hide) {
|
9537 | $$.addHiddenTargetIds(config.data_hide === !0 ? $$.mapToIds($$.data.targets) : config.data_hide);
|
9538 | }
|
9539 |
|
9540 | if (config.legend_hide) {
|
9541 | $$.addHiddenLegendIds(config.legend_hide === !0 ? $$.mapToIds($$.data.targets) : config.legend_hide);
|
9542 | }
|
9543 |
|
9544 |
|
9545 | $$.updateSizes();
|
9546 | $$.updateScales(!0);
|
9547 |
|
9548 | var x = scale.x,
|
9549 | y = scale.y,
|
9550 | y2 = scale.y2,
|
9551 | subX = scale.subX,
|
9552 | subY = scale.subY,
|
9553 | subY2 = scale.subY2;
|
9554 |
|
9555 | if (x) {
|
9556 | x.domain(sortValue($$.getXDomain($$.data.targets)));
|
9557 | subX.domain(x.domain());
|
9558 |
|
9559 | org.xDomain = x.domain();
|
9560 | }
|
9561 |
|
9562 | if (y) {
|
9563 | y.domain($$.getYDomain($$.data.targets, "y"));
|
9564 | subY.domain(y.domain());
|
9565 | }
|
9566 |
|
9567 | if (y2) {
|
9568 | y2.domain($$.getYDomain($$.data.targets, "y2"));
|
9569 | subY2 && subY2.domain(y2.domain());
|
9570 | }
|
9571 |
|
9572 |
|
9573 | $el.svg = $el.chart.append("svg").style("overflow", "hidden").style("display", "block");
|
9574 |
|
9575 | if (hasInteraction && state.inputType) {
|
9576 | var isTouch = state.inputType === "touch";
|
9577 | $el.svg.on(isTouch ? "touchstart" : "mouseenter", function () {
|
9578 | return callFn(config.onover, $$.api);
|
9579 | }).on(isTouch ? "touchend" : "mouseleave", function () {
|
9580 | return callFn(config.onout, $$.api);
|
9581 | });
|
9582 | }
|
9583 |
|
9584 | config.svg_classname && $el.svg.attr("class", config.svg_classname);
|
9585 |
|
9586 | var hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
|
9587 |
|
9588 | if (hasAxis || hasColorPatterns || config.data_labels_backgroundColors) {
|
9589 | $el.defs = $el.svg.append("defs");
|
9590 |
|
9591 | if (hasAxis) {
|
9592 | ["id", "idXAxis", "idYAxis", "idGrid"].forEach(function (v) {
|
9593 | $$.appendClip($el.defs, state.clip[v]);
|
9594 | });
|
9595 | }
|
9596 |
|
9597 |
|
9598 | $$.generateDataLabelBackgroundColorFilter();
|
9599 |
|
9600 | if (hasColorPatterns) {
|
9601 | $$.patterns.forEach(function (p) {
|
9602 | return $el.defs.append(function () {
|
9603 | return p.node;
|
9604 | });
|
9605 | });
|
9606 | }
|
9607 | }
|
9608 |
|
9609 | $$.updateSvgSize();
|
9610 |
|
9611 | $$.bindResize();
|
9612 |
|
9613 | var main = $el.svg.append("g").classed(config_classes.main, !0).attr("transform", $$.getTranslate("main"));
|
9614 | $el.main = main;
|
9615 |
|
9616 | config.subchart_show && $$.initSubchart();
|
9617 | config.tooltip_show && $$.initTooltip();
|
9618 | config.title_text && $$.initTitle();
|
9619 | config.legend_show && $$.initLegend();
|
9620 |
|
9621 |
|
9622 | if (config.data_empty_label_text) {
|
9623 | main.append("text").attr("class", config_classes.text + " " + config_classes.empty).attr("text-anchor", "middle")
|
9624 | .attr("dominant-baseline", "middle");
|
9625 | }
|
9626 |
|
9627 | if (hasAxis) {
|
9628 |
|
9629 | config.regions.length && $$.initRegion();
|
9630 |
|
9631 | config.clipPath || $$.axis.init();
|
9632 | }
|
9633 |
|
9634 |
|
9635 | main.append("g").attr("class", config_classes.chart).attr("clip-path", state.clip.path);
|
9636 | $$.callPluginHook("$init");
|
9637 |
|
9638 | if (hasAxis) {
|
9639 | var _$$$axis;
|
9640 |
|
9641 |
|
9642 | hasInteraction && ($$.initEventRect == null ? void 0 : $$.initEventRect());
|
9643 |
|
9644 | $$.initGrid();
|
9645 |
|
9646 | config.clipPath && ((_$$$axis = $$.axis) == null ? void 0 : _$$$axis.init());
|
9647 | }
|
9648 |
|
9649 | $$.initChartElements();
|
9650 |
|
9651 | $$.updateTargets($$.data.targets);
|
9652 |
|
9653 | $$.updateDimension();
|
9654 |
|
9655 | callFn(config.oninit, $$.api);
|
9656 |
|
9657 | $$.setBackground();
|
9658 | $$.redraw({
|
9659 | withTransition: !1,
|
9660 | withTransform: !0,
|
9661 | withUpdateXDomain: !0,
|
9662 | withUpdateOrgXDomain: !0,
|
9663 | withTransitionForAxis: !1,
|
9664 | initializing: !0
|
9665 | });
|
9666 |
|
9667 | if (config.data_onmin || config.data_onmax) {
|
9668 | var minMax = $$.getMinMaxData();
|
9669 | callFn(config.data_onmin, $$.api, minMax.min);
|
9670 | callFn(config.data_onmax, $$.api, minMax.max);
|
9671 | }
|
9672 |
|
9673 | config.tooltip_show && $$.initShowTooltip();
|
9674 | state.rendered = !0;
|
9675 | }
|
9676 | |
9677 |
|
9678 |
|
9679 |
|
9680 | ;
|
9681 |
|
9682 | _proto.initChartElements = function initChartElements() {
|
9683 | var $$ = this,
|
9684 | _$$$state = $$.state,
|
9685 | hasAxis = _$$$state.hasAxis,
|
9686 | hasRadar = _$$$state.hasRadar,
|
9687 | types = [];
|
9688 |
|
9689 | if (hasAxis) {
|
9690 | ["bar", "bubble", "candlestick", "line"].forEach(function (v) {
|
9691 | var name = capitalize(v);
|
9692 |
|
9693 | if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
|
9694 | types.push(name);
|
9695 | }
|
9696 | });
|
9697 | } else {
|
9698 | if (!hasRadar) {
|
9699 | types.push("Arc", "Pie");
|
9700 | }
|
9701 |
|
9702 | if ($$.hasType("gauge")) {
|
9703 | types.push("Gauge");
|
9704 | } else if (hasRadar) {
|
9705 | types.push("Radar");
|
9706 | }
|
9707 | }
|
9708 |
|
9709 | types.forEach(function (v) {
|
9710 | $$["init" + v]();
|
9711 | });
|
9712 | notEmpty($$.config.data_labels) && !$$.hasArcType(null, ["radar"]) && $$.initText();
|
9713 | }
|
9714 | |
9715 |
|
9716 |
|
9717 |
|
9718 | ;
|
9719 |
|
9720 | _proto.setChartElements = function setChartElements() {
|
9721 | var $$ = this,
|
9722 | _$$$$el = $$.$el,
|
9723 | chart = _$$$$el.chart,
|
9724 | svg = _$$$$el.svg,
|
9725 | defs = _$$$$el.defs,
|
9726 | main = _$$$$el.main,
|
9727 | tooltip = _$$$$el.tooltip,
|
9728 | legend = _$$$$el.legend,
|
9729 | title = _$$$$el.title,
|
9730 | grid = _$$$$el.grid,
|
9731 | arc = _$$$$el.arcs,
|
9732 | circles = _$$$$el.circle,
|
9733 | bars = _$$$$el.bar,
|
9734 | candlestick = _$$$$el.candlestick,
|
9735 | lines = _$$$$el.line,
|
9736 | areas = _$$$$el.area,
|
9737 | texts = _$$$$el.text;
|
9738 | $$.api.$ = {
|
9739 | chart: chart,
|
9740 | svg: svg,
|
9741 | defs: defs,
|
9742 | main: main,
|
9743 | tooltip: tooltip,
|
9744 | legend: legend,
|
9745 | title: title,
|
9746 | grid: grid,
|
9747 | arc: arc,
|
9748 | circles: circles,
|
9749 | bar: {
|
9750 | bars: bars
|
9751 | },
|
9752 | candlestick: candlestick,
|
9753 | line: {
|
9754 | lines: lines,
|
9755 | areas: areas
|
9756 | },
|
9757 | text: {
|
9758 | texts: texts
|
9759 | }
|
9760 | };
|
9761 | }
|
9762 | |
9763 |
|
9764 |
|
9765 |
|
9766 | ;
|
9767 |
|
9768 | _proto.setBackground = function setBackground() {
|
9769 | var $$ = this,
|
9770 | bg = $$.config.background,
|
9771 | state = $$.state,
|
9772 | svg = $$.$el.svg;
|
9773 |
|
9774 | if (notEmpty(bg)) {
|
9775 | var element = svg.select("g").insert(bg.imgUrl ? "image" : "rect", ":first-child");
|
9776 |
|
9777 | if (bg.imgUrl) {
|
9778 | element.attr("href", bg.imgUrl);
|
9779 | } else if (bg.color) {
|
9780 | element.style("fill", bg.color).attr("clip-path", state.clip.path);
|
9781 | }
|
9782 |
|
9783 | element.attr("class", bg.class || null).attr("width", "100%").attr("height", "100%");
|
9784 | }
|
9785 | }
|
9786 | |
9787 |
|
9788 |
|
9789 |
|
9790 |
|
9791 | ;
|
9792 |
|
9793 | _proto.updateTargets = function updateTargets(targets) {
|
9794 | var $$ = this,
|
9795 | _$$$state2 = $$.state,
|
9796 | hasAxis = _$$$state2.hasAxis,
|
9797 | hasRadar = _$$$state2.hasRadar;
|
9798 |
|
9799 | $$.updateTargetsForText(targets);
|
9800 |
|
9801 | if (hasAxis) {
|
9802 | ["bar", "candlestick", "line"].forEach(function (v) {
|
9803 | var name = capitalize(v);
|
9804 |
|
9805 | if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
|
9806 | $$["updateTargetsFor" + name](targets.filter($$["is" + name + "Type"].bind($$)));
|
9807 | }
|
9808 | });
|
9809 |
|
9810 | $$.updateTargetsForSubchart && $$.updateTargetsForSubchart(targets);
|
9811 | } else {
|
9812 |
|
9813 | $$.hasArcType(targets) && (hasRadar ? $$.updateTargetsForRadar(targets.filter($$.isRadarType.bind($$))) : $$.updateTargetsForArc(targets.filter($$.isArcType.bind($$))));
|
9814 | }
|
9815 |
|
9816 |
|
9817 | if ($$.hasType("bubble") || $$.hasType("scatter")) {
|
9818 | $$.updateTargetForCircle == null ? void 0 : $$.updateTargetForCircle();
|
9819 | }
|
9820 |
|
9821 |
|
9822 | $$.showTargets();
|
9823 | }
|
9824 | |
9825 |
|
9826 |
|
9827 |
|
9828 | ;
|
9829 |
|
9830 | _proto.showTargets = function showTargets() {
|
9831 | var $$ = this,
|
9832 | svg = $$.$el.svg,
|
9833 | $T = $$.$T;
|
9834 | $T(svg.selectAll("." + config_classes.target).filter(function (d) {
|
9835 | return $$.isTargetToShow(d.id);
|
9836 | })).style("opacity", null);
|
9837 | };
|
9838 |
|
9839 | _proto.getWithOption = function getWithOption(options) {
|
9840 | var withOptions = {
|
9841 | Dimension: !0,
|
9842 | EventRect: !0,
|
9843 | Legend: !1,
|
9844 | Subchart: !0,
|
9845 | Transform: !1,
|
9846 | Transition: !0,
|
9847 | TrimXDomain: !0,
|
9848 | UpdateXAxis: "UpdateXDomain",
|
9849 | UpdateXDomain: !1,
|
9850 | UpdateOrgXDomain: !1,
|
9851 | TransitionForExit: "Transition",
|
9852 | TransitionForAxis: "Transition",
|
9853 | Y: !0
|
9854 | };
|
9855 | Object.keys(withOptions).forEach(function (key) {
|
9856 | var defVal = withOptions[key];
|
9857 |
|
9858 | if (isString(defVal)) {
|
9859 | defVal = withOptions[defVal];
|
9860 | }
|
9861 |
|
9862 | withOptions[key] = getOption(options, "with" + key, defVal);
|
9863 | });
|
9864 | return withOptions;
|
9865 | };
|
9866 |
|
9867 | _proto.initialOpacity = function initialOpacity(d) {
|
9868 | var $$ = this,
|
9869 | withoutFadeIn = $$.state.withoutFadeIn;
|
9870 | return $$.getBaseValue(d) !== null && withoutFadeIn[d.id] ? null : "0";
|
9871 | };
|
9872 |
|
9873 | _proto.bindResize = function bindResize() {
|
9874 | var $$ = this,
|
9875 | config = $$.config,
|
9876 | state = $$.state,
|
9877 | resizeFunction = generateResize(),
|
9878 | list = [];
|
9879 | list.push(function () {
|
9880 | return callFn(config.onresize, $$, $$.api);
|
9881 | });
|
9882 |
|
9883 | if (config.resize_auto) {
|
9884 | list.push(function () {
|
9885 | state.resizing = !0;
|
9886 | $$.api.flush(!1);
|
9887 | });
|
9888 | }
|
9889 |
|
9890 | list.push(function () {
|
9891 | callFn(config.onresized, $$, $$.api);
|
9892 | state.resizing = !1;
|
9893 | });
|
9894 |
|
9895 | list.forEach(function (v) {
|
9896 | return resizeFunction.add(v);
|
9897 | });
|
9898 | $$.resizeFunction = resizeFunction;
|
9899 |
|
9900 | win.addEventListener("resize", $$.resizeFunction = resizeFunction);
|
9901 | }
|
9902 | |
9903 |
|
9904 |
|
9905 |
|
9906 |
|
9907 |
|
9908 | ;
|
9909 |
|
9910 | _proto.callPluginHook = function callPluginHook(phase) {
|
9911 | for (var _this = this, _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
9912 | args[_key - 1] = arguments[_key];
|
9913 | }
|
9914 |
|
9915 | this.config.plugins.forEach(function (v) {
|
9916 | if (phase === "$beforeInit") {
|
9917 | v.$$ = _this;
|
9918 |
|
9919 | _this.api.plugins.push(v);
|
9920 | }
|
9921 |
|
9922 | v[phase].apply(v, args);
|
9923 | });
|
9924 | };
|
9925 |
|
9926 | return ChartInternal;
|
9927 | }();
|
9928 |
|
9929 |
|
9930 | extend(ChartInternal.prototype, [
|
9931 | convert, data_data, load, category, internals_class, internals_color, domain, interactions_interaction, format, internals_legend, redraw, scale, shape, size, internals_text, internals_title, internals_tooltip, transform, type]);
|
9932 | ;
|
9933 |
|
9934 |
|
9935 |
|
9936 |
|
9937 |
|
9938 |
|
9939 |
|
9940 |
|
9941 |
|
9942 |
|
9943 |
|
9944 | function loadConfig(config) {
|
9945 | var thisConfig = this.config,
|
9946 | target,
|
9947 | keys,
|
9948 | read,
|
9949 | find = function () {
|
9950 | var key = keys.shift();
|
9951 |
|
9952 | if (key && target && isObjectType(target) && key in target) {
|
9953 | target = target[key];
|
9954 | return find();
|
9955 | } else if (!key) {
|
9956 | return target;
|
9957 | }
|
9958 |
|
9959 | return undefined;
|
9960 | };
|
9961 |
|
9962 | Object.keys(thisConfig).forEach(function (key) {
|
9963 | target = config;
|
9964 | keys = key.split("_");
|
9965 | read = find();
|
9966 |
|
9967 | if (isDefined(read)) {
|
9968 | thisConfig[key] = read;
|
9969 | }
|
9970 | });
|
9971 | }
|
9972 | ;
|
9973 |
|
9974 |
|
9975 |
|
9976 |
|
9977 |
|
9978 |
|
9979 | var chart = ({
|
9980 | |
9981 |
|
9982 |
|
9983 |
|
9984 |
|
9985 |
|
9986 |
|
9987 |
|
9988 |
|
9989 |
|
9990 |
|
9991 |
|
9992 |
|
9993 |
|
9994 |
|
9995 | resize: function resize(size) {
|
9996 | var $$ = this.internal,
|
9997 | config = $$.config,
|
9998 | state = $$.state;
|
9999 |
|
10000 | if (state.rendered) {
|
10001 | config.size_width = size ? size.width : null;
|
10002 | config.size_height = size ? size.height : null;
|
10003 | state.resizing = !0;
|
10004 | this.flush(!1, !0);
|
10005 | $$.resizeFunction();
|
10006 | }
|
10007 | },
|
10008 |
|
10009 | |
10010 |
|
10011 |
|
10012 |
|
10013 |
|
10014 |
|
10015 |
|
10016 |
|
10017 |
|
10018 |
|
10019 |
|
10020 |
|
10021 |
|
10022 | flush: function flush(soft) {
|
10023 | var $$ = this.internal,
|
10024 | state = $$.state,
|
10025 | zoomResetBtn = $$.$el.zoomResetBtn;
|
10026 |
|
10027 | if (state.rendered) {
|
10028 | var _zoomResetBtn;
|
10029 |
|
10030 |
|
10031 |
|
10032 | if (state.resizing) {
|
10033 | var _$$$brush;
|
10034 |
|
10035 |
|
10036 | (_$$$brush = $$.brush) == null ? void 0 : _$$$brush.updateResize();
|
10037 | } else {
|
10038 | var _$$$axis;
|
10039 |
|
10040 |
|
10041 | (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.setOrient();
|
10042 | }
|
10043 |
|
10044 |
|
10045 |
|
10046 | (_zoomResetBtn = zoomResetBtn) == null ? void 0 : _zoomResetBtn.style("display", "none");
|
10047 | $$.scale.zoom = null;
|
10048 | soft ? $$.redraw({
|
10049 | withTransform: !0,
|
10050 | withUpdateXDomain: !0,
|
10051 | withUpdateOrgXDomain: !0,
|
10052 | withLegend: !0
|
10053 | }) : $$.updateAndRedraw({
|
10054 | withLegend: !0,
|
10055 | withTransition: !1,
|
10056 | withTransitionForTransform: !1
|
10057 | });
|
10058 |
|
10059 | if (!state.resizing && $$.brush) {
|
10060 | $$.brush.getSelection().call($$.brush.move);
|
10061 | $$.unselectRect();
|
10062 | }
|
10063 | } else {
|
10064 | $$.initToRender(!0);
|
10065 | }
|
10066 | },
|
10067 |
|
10068 | |
10069 |
|
10070 |
|
10071 |
|
10072 |
|
10073 |
|
10074 |
|
10075 |
|
10076 |
|
10077 | destroy: function destroy() {
|
10078 | var _this = this,
|
10079 | $$ = this.internal,
|
10080 | _$$$$el = $$.$el,
|
10081 | chart = _$$$$el.chart,
|
10082 | svg = _$$$$el.svg;
|
10083 |
|
10084 | if (notEmpty($$)) {
|
10085 | $$.callPluginHook("$willDestroy");
|
10086 | $$.charts.splice($$.charts.indexOf(this), 1);
|
10087 |
|
10088 | svg.select("*").interrupt();
|
10089 | $$.resizeFunction.clear();
|
10090 | win.removeEventListener("resize", $$.resizeFunction);
|
10091 | chart.classed("bb", !1).html("");
|
10092 |
|
10093 | Object.keys(this).forEach(function (key) {
|
10094 | key === "internal" && Object.keys($$).forEach(function (k) {
|
10095 | $$[k] = null;
|
10096 | });
|
10097 | _this[key] = null;
|
10098 | delete _this[key];
|
10099 | });
|
10100 |
|
10101 | for (var key in this) {
|
10102 | this[key] = function () {};
|
10103 | }
|
10104 | }
|
10105 |
|
10106 | return null;
|
10107 | },
|
10108 |
|
10109 | |
10110 |
|
10111 |
|
10112 |
|
10113 |
|
10114 |
|
10115 |
|
10116 |
|
10117 |
|
10118 |
|
10119 |
|
10120 |
|
10121 |
|
10122 |
|
10123 |
|
10124 |
|
10125 |
|
10126 |
|
10127 |
|
10128 |
|
10129 | config: function (name, value, redraw) {
|
10130 | var $$ = this.internal,
|
10131 | config = $$.config,
|
10132 | key = name == null ? void 0 : name.replace(/\./g, "_"),
|
10133 | res;
|
10134 |
|
10135 | if (key in config) {
|
10136 | if (isDefined(value)) {
|
10137 | config[key] = value;
|
10138 | res = value;
|
10139 | redraw && this.flush();
|
10140 | } else {
|
10141 | res = config[key];
|
10142 | }
|
10143 | }
|
10144 |
|
10145 | return res;
|
10146 | }
|
10147 | });
|
10148 | ;
|
10149 |
|
10150 |
|
10151 |
|
10152 |
|
10153 | var api_color = ({
|
10154 | |
10155 |
|
10156 |
|
10157 |
|
10158 |
|
10159 |
|
10160 |
|
10161 |
|
10162 |
|
10163 |
|
10164 | color: function color(id) {
|
10165 | return this.internal.color(id);
|
10166 | }
|
10167 | });
|
10168 | ;
|
10169 |
|
10170 |
|
10171 |
|
10172 |
|
10173 |
|
10174 |
|
10175 |
|
10176 |
|
10177 |
|
10178 |
|
10179 |
|
10180 |
|
10181 |
|
10182 |
|
10183 |
|
10184 |
|
10185 |
|
10186 |
|
10187 |
|
10188 |
|
10189 |
|
10190 |
|
10191 |
|
10192 |
|
10193 | function api_data_data(targetIds) {
|
10194 | var targets = this.internal.data.targets;
|
10195 |
|
10196 | if (!isUndefined(targetIds)) {
|
10197 | var ids = isArray(targetIds) ? targetIds : [targetIds];
|
10198 | return targets.filter(function (t) {
|
10199 | return ids.some(function (v) {
|
10200 | return v === t.id;
|
10201 | });
|
10202 | });
|
10203 | }
|
10204 |
|
10205 | return targets;
|
10206 | }
|
10207 |
|
10208 | extend(api_data_data, {
|
10209 | |
10210 |
|
10211 |
|
10212 |
|
10213 |
|
10214 |
|
10215 |
|
10216 |
|
10217 |
|
10218 |
|
10219 |
|
10220 |
|
10221 |
|
10222 |
|
10223 |
|
10224 |
|
10225 |
|
10226 |
|
10227 | shown: function shown(targetIds) {
|
10228 | return this.internal.filterTargetsToShow(this.data(targetIds));
|
10229 | },
|
10230 |
|
10231 | |
10232 |
|
10233 |
|
10234 |
|
10235 |
|
10236 |
|
10237 |
|
10238 |
|
10239 |
|
10240 |
|
10241 |
|
10242 |
|
10243 |
|
10244 | values: function (targetIds, flat) {
|
10245 | if (flat === void 0) {
|
10246 | flat = !0;
|
10247 | }
|
10248 |
|
10249 | var values = null;
|
10250 |
|
10251 | if (targetIds) {
|
10252 | var targets = this.data(targetIds);
|
10253 |
|
10254 | if (isArray(targets)) {
|
10255 | values = [];
|
10256 | targets.forEach(function (v) {
|
10257 | var dataValue = v.values.map(function (d) {
|
10258 | return d.value;
|
10259 | });
|
10260 | flat ? values = values.concat(dataValue) : values.push(dataValue);
|
10261 | });
|
10262 | }
|
10263 | }
|
10264 |
|
10265 | return values;
|
10266 | },
|
10267 |
|
10268 | |
10269 |
|
10270 |
|
10271 |
|
10272 |
|
10273 |
|
10274 |
|
10275 |
|
10276 |
|
10277 |
|
10278 |
|
10279 |
|
10280 |
|
10281 |
|
10282 |
|
10283 |
|
10284 |
|
10285 |
|
10286 | names: function names(_names) {
|
10287 | var $$ = this.internal;
|
10288 | return $$.updateDataAttributes("names", _names);
|
10289 | },
|
10290 |
|
10291 | |
10292 |
|
10293 |
|
10294 |
|
10295 |
|
10296 |
|
10297 |
|
10298 |
|
10299 |
|
10300 |
|
10301 |
|
10302 |
|
10303 |
|
10304 |
|
10305 |
|
10306 |
|
10307 |
|
10308 |
|
10309 | colors: function colors(_colors) {
|
10310 | return this.internal.updateDataAttributes("colors", _colors);
|
10311 | },
|
10312 |
|
10313 | |
10314 |
|
10315 |
|
10316 |
|
10317 |
|
10318 |
|
10319 |
|
10320 |
|
10321 |
|
10322 |
|
10323 |
|
10324 |
|
10325 |
|
10326 |
|
10327 |
|
10328 |
|
10329 |
|
10330 |
|
10331 |
|
10332 | axes: function axes(_axes) {
|
10333 | return this.internal.updateDataAttributes("axes", _axes);
|
10334 | },
|
10335 |
|
10336 | |
10337 |
|
10338 |
|
10339 |
|
10340 |
|
10341 |
|
10342 |
|
10343 |
|
10344 |
|
10345 |
|
10346 |
|
10347 | min: function min() {
|
10348 | return this.internal.getMinMaxData().min;
|
10349 | },
|
10350 |
|
10351 | |
10352 |
|
10353 |
|
10354 |
|
10355 |
|
10356 |
|
10357 |
|
10358 |
|
10359 |
|
10360 |
|
10361 |
|
10362 | max: function max() {
|
10363 | return this.internal.getMinMaxData().max;
|
10364 | }
|
10365 | });
|
10366 | var api_data = ({
|
10367 | data: api_data_data
|
10368 | });
|
10369 | ;
|
10370 |
|
10371 |
|
10372 |
|
10373 |
|
10374 |
|
10375 |
|
10376 |
|
10377 |
|
10378 |
|
10379 |
|
10380 |
|
10381 |
|
10382 |
|
10383 |
|
10384 |
|
10385 | var b64EncodeUnicode = function (str) {
|
10386 | return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p) {
|
10387 | return String.fromCharCode(+("0x" + p));
|
10388 | }));
|
10389 | };
|
10390 |
|
10391 |
|
10392 |
|
10393 |
|
10394 |
|
10395 |
|
10396 |
|
10397 |
|
10398 |
|
10399 |
|
10400 | function nodeToSvgDataUrl(node, option, orgSize) {
|
10401 | var _ref = option || orgSize,
|
10402 | width = _ref.width,
|
10403 | height = _ref.height,
|
10404 | serializer = new XMLSerializer(),
|
10405 | clone = node.cloneNode(!0),
|
10406 | cssText = getCssRules(toArray(browser_doc.styleSheets)).filter(function (r) {
|
10407 | return r.cssText;
|
10408 | }).map(function (r) {
|
10409 | return r.cssText;
|
10410 | });
|
10411 |
|
10412 | clone.setAttribute("xmlns", external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.xhtml);
|
10413 | var nodeXml = serializer.serializeToString(clone),
|
10414 | style = browser_doc.createElement("style");
|
10415 |
|
10416 | style.appendChild(browser_doc.createTextNode(cssText.join("\n")));
|
10417 | var styleXml = serializer.serializeToString(style),
|
10418 | dataStr = ("<svg xmlns=\"" + external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg + "\" width=\"" + width + "\" height=\"" + height + "\" \n\t\tviewBox=\"0 0 " + orgSize.width + " " + orgSize.height + "\" \n\t\tpreserveAspectRatio=\"" + ((option == null ? void 0 : option.preserveAspectRatio) === !1 ? "none" : "xMinYMid meet") + "\">\n\t\t\t<foreignObject width=\"100%\" height=\"100%\">\n\t\t\t\t" + styleXml + "\n\t\t\t\t" + nodeXml.replace(/(url\()[^#]+/g, "$1") + "\n\t\t\t</foreignObject></svg>").replace("/\n/g", "%0A");
|
10419 |
|
10420 |
|
10421 | return "data:image/svg+xml;base64," + b64EncodeUnicode(dataStr);
|
10422 | }
|
10423 |
|
10424 | var api_export = ({
|
10425 | |
10426 |
|
10427 |
|
10428 |
|
10429 |
|
10430 |
|
10431 |
|
10432 |
|
10433 |
|
10434 |
|
10435 |
|
10436 |
|
10437 |
|
10438 |
|
10439 |
|
10440 |
|
10441 |
|
10442 |
|
10443 |
|
10444 |
|
10445 |
|
10446 |
|
10447 |
|
10448 |
|
10449 |
|
10450 |
|
10451 |
|
10452 |
|
10453 |
|
10454 |
|
10455 |
|
10456 |
|
10457 |
|
10458 |
|
10459 |
|
10460 |
|
10461 |
|
10462 |
|
10463 |
|
10464 |
|
10465 |
|
10466 | export: function _export(option, callback) {
|
10467 | var _this = this,
|
10468 | $$ = this.internal,
|
10469 | state = $$.state,
|
10470 | chart = $$.$el.chart,
|
10471 | _state$current = state.current,
|
10472 | width = _state$current.width,
|
10473 | height = _state$current.height,
|
10474 | opt = mergeObj({
|
10475 | width: width,
|
10476 | height: height,
|
10477 | preserveAspectRatio: !0,
|
10478 | mimeType: "image/png"
|
10479 | }, option),
|
10480 | svgDataUrl = nodeToSvgDataUrl(chart.node(), opt, {
|
10481 | width: width,
|
10482 | height: height
|
10483 | });
|
10484 |
|
10485 | if (callback && isFunction(callback)) {
|
10486 | var img = new Image();
|
10487 | img.crossOrigin = "Anonymous";
|
10488 |
|
10489 | img.onload = function () {
|
10490 | var canvas = browser_doc.createElement("canvas"),
|
10491 | ctx = canvas.getContext("2d");
|
10492 | canvas.width = opt.width || width;
|
10493 | canvas.height = opt.height || height;
|
10494 | ctx.drawImage(img, 0, 0);
|
10495 | callback.bind(_this)(canvas.toDataURL(opt.mimeType));
|
10496 | };
|
10497 |
|
10498 | img.src = svgDataUrl;
|
10499 | }
|
10500 |
|
10501 | return svgDataUrl;
|
10502 | }
|
10503 | });
|
10504 | ;
|
10505 |
|
10506 |
|
10507 |
|
10508 |
|
10509 |
|
10510 |
|
10511 | var api_focus = ({
|
10512 | |
10513 |
|
10514 |
|
10515 |
|
10516 |
|
10517 |
|
10518 |
|
10519 |
|
10520 |
|
10521 |
|
10522 |
|
10523 |
|
10524 |
|
10525 |
|
10526 |
|
10527 |
|
10528 |
|
10529 | focus: function focus(targetIdsValue) {
|
10530 | var $$ = this.internal,
|
10531 | state = $$.state,
|
10532 | targetIds = $$.mapToTargetIds(targetIdsValue),
|
10533 | candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
|
10534 | this.revert();
|
10535 | this.defocus();
|
10536 | candidates.classed(config_classes.focused, !0).classed(config_classes.defocused, !1);
|
10537 |
|
10538 | if ($$.hasArcType() && !state.hasRadar) {
|
10539 | $$.expandArc(targetIds);
|
10540 | $$.hasType("gauge") && $$.markOverlapped(targetIdsValue, $$, "." + config_classes.gaugeValue);
|
10541 | }
|
10542 |
|
10543 | $$.toggleFocusLegend(targetIds, !0);
|
10544 | state.focusedTargetIds = targetIds;
|
10545 | state.defocusedTargetIds = state.defocusedTargetIds.filter(function (id) {
|
10546 | return targetIds.indexOf(id) < 0;
|
10547 | });
|
10548 | },
|
10549 |
|
10550 | |
10551 |
|
10552 |
|
10553 |
|
10554 |
|
10555 |
|
10556 |
|
10557 |
|
10558 |
|
10559 |
|
10560 |
|
10561 |
|
10562 |
|
10563 |
|
10564 |
|
10565 |
|
10566 |
|
10567 | defocus: function defocus(targetIdsValue) {
|
10568 | var $$ = this.internal,
|
10569 | state = $$.state,
|
10570 | targetIds = $$.mapToTargetIds(targetIdsValue),
|
10571 | candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
|
10572 | candidates.classed(config_classes.focused, !1).classed(config_classes.defocused, !0);
|
10573 |
|
10574 | if ($$.hasArcType()) {
|
10575 | $$.unexpandArc(targetIds);
|
10576 | $$.hasType("gauge") && $$.undoMarkOverlapped($$, "." + config_classes.gaugeValue);
|
10577 | }
|
10578 |
|
10579 | $$.toggleFocusLegend(targetIds, !1);
|
10580 | state.focusedTargetIds = state.focusedTargetIds.filter(function (id) {
|
10581 | return targetIds.indexOf(id) < 0;
|
10582 | });
|
10583 | state.defocusedTargetIds = targetIds;
|
10584 | },
|
10585 |
|
10586 | |
10587 |
|
10588 |
|
10589 |
|
10590 |
|
10591 |
|
10592 |
|
10593 |
|
10594 |
|
10595 |
|
10596 |
|
10597 |
|
10598 |
|
10599 |
|
10600 |
|
10601 |
|
10602 |
|
10603 | revert: function revert(targetIdsValue) {
|
10604 | var $$ = this.internal,
|
10605 | config = $$.config,
|
10606 | state = $$.state,
|
10607 | $el = $$.$el,
|
10608 | targetIds = $$.mapToTargetIds(targetIdsValue),
|
10609 | candidates = $el.svg.selectAll($$.selectorTargets(targetIds));
|
10610 |
|
10611 | candidates.classed(config_classes.focused, !1).classed(config_classes.defocused, !1);
|
10612 | $$.hasArcType() && $$.unexpandArc(targetIds);
|
10613 |
|
10614 | if (config.legend_show) {
|
10615 | $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
|
10616 | $el.legend.selectAll($$.selectorLegends(targetIds)).filter(function () {
|
10617 | return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.legendItemFocused);
|
10618 | }).classed(config_classes.legendItemFocused, !1);
|
10619 | }
|
10620 |
|
10621 | state.focusedTargetIds = [];
|
10622 | state.defocusedTargetIds = [];
|
10623 | }
|
10624 | });
|
10625 | ;
|
10626 |
|
10627 |
|
10628 |
|
10629 |
|
10630 |
|
10631 |
|
10632 |
|
10633 |
|
10634 |
|
10635 | var legend_legend = {
|
10636 | |
10637 |
|
10638 |
|
10639 |
|
10640 |
|
10641 |
|
10642 |
|
10643 |
|
10644 |
|
10645 |
|
10646 |
|
10647 |
|
10648 |
|
10649 |
|
10650 |
|
10651 |
|
10652 |
|
10653 |
|
10654 |
|
10655 | show: function show(targetIds) {
|
10656 | var $$ = this.internal;
|
10657 | $$.showLegend($$.mapToTargetIds(targetIds));
|
10658 | $$.updateAndRedraw({
|
10659 | withLegend: !0
|
10660 | });
|
10661 | },
|
10662 |
|
10663 | |
10664 |
|
10665 |
|
10666 |
|
10667 |
|
10668 |
|
10669 |
|
10670 |
|
10671 |
|
10672 |
|
10673 |
|
10674 |
|
10675 |
|
10676 |
|
10677 |
|
10678 |
|
10679 |
|
10680 |
|
10681 |
|
10682 | hide: function hide(targetIds) {
|
10683 | var $$ = this.internal;
|
10684 | $$.hideLegend($$.mapToTargetIds(targetIds));
|
10685 | $$.updateAndRedraw({
|
10686 | withLegend: !0
|
10687 | });
|
10688 | }
|
10689 | };
|
10690 | var api_legend = ({
|
10691 | legend: legend_legend
|
10692 | });
|
10693 | ;
|
10694 |
|
10695 |
|
10696 |
|
10697 |
|
10698 |
|
10699 |
|
10700 | var api_load = ({
|
10701 | |
10702 |
|
10703 |
|
10704 |
|
10705 |
|
10706 |
|
10707 |
|
10708 |
|
10709 |
|
10710 |
|
10711 |
|
10712 |
|
10713 |
|
10714 |
|
10715 |
|
10716 |
|
10717 |
|
10718 |
|
10719 |
|
10720 |
|
10721 |
|
10722 |
|
10723 |
|
10724 |
|
10725 |
|
10726 |
|
10727 |
|
10728 |
|
10729 |
|
10730 |
|
10731 |
|
10732 |
|
10733 |
|
10734 |
|
10735 |
|
10736 |
|
10737 |
|
10738 |
|
10739 |
|
10740 |
|
10741 |
|
10742 |
|
10743 |
|
10744 |
|
10745 |
|
10746 |
|
10747 |
|
10748 |
|
10749 |
|
10750 |
|
10751 |
|
10752 |
|
10753 |
|
10754 |
|
10755 |
|
10756 |
|
10757 |
|
10758 |
|
10759 |
|
10760 |
|
10761 |
|
10762 |
|
10763 |
|
10764 |
|
10765 |
|
10766 |
|
10767 |
|
10768 |
|
10769 |
|
10770 |
|
10771 |
|
10772 |
|
10773 |
|
10774 |
|
10775 |
|
10776 |
|
10777 |
|
10778 |
|
10779 |
|
10780 |
|
10781 |
|
10782 |
|
10783 |
|
10784 |
|
10785 |
|
10786 |
|
10787 |
|
10788 |
|
10789 |
|
10790 |
|
10791 |
|
10792 |
|
10793 |
|
10794 |
|
10795 |
|
10796 |
|
10797 |
|
10798 |
|
10799 |
|
10800 |
|
10801 |
|
10802 |
|
10803 |
|
10804 |
|
10805 |
|
10806 |
|
10807 |
|
10808 |
|
10809 |
|
10810 |
|
10811 |
|
10812 |
|
10813 |
|
10814 |
|
10815 |
|
10816 |
|
10817 |
|
10818 |
|
10819 |
|
10820 |
|
10821 |
|
10822 |
|
10823 |
|
10824 |
|
10825 |
|
10826 |
|
10827 |
|
10828 |
|
10829 |
|
10830 | load: function load(args) {
|
10831 | var $$ = this.internal,
|
10832 | config = $$.config;
|
10833 |
|
10834 | args.xs && $$.addXs(args.xs);
|
10835 |
|
10836 | "names" in args && this.data.names(args.names);
|
10837 |
|
10838 | "classes" in args && Object.keys(args.classes).forEach(function (id) {
|
10839 | config.data_classes[id] = args.classes[id];
|
10840 | });
|
10841 |
|
10842 | if ("categories" in args && $$.axis.isCategorized()) {
|
10843 | config.axis_x_categories = args.categories;
|
10844 | }
|
10845 |
|
10846 |
|
10847 | "axes" in args && Object.keys(args.axes).forEach(function (id) {
|
10848 | config.data_axes[id] = args.axes[id];
|
10849 | });
|
10850 |
|
10851 | "colors" in args && Object.keys(args.colors).forEach(function (id) {
|
10852 | config.data_colors[id] = args.colors[id];
|
10853 | });
|
10854 |
|
10855 | if ("unload" in args && args.unload !== !1) {
|
10856 |
|
10857 | $$.unload($$.mapToTargetIds(args.unload === !0 ? null : args.unload), function () {
|
10858 |
|
10859 |
|
10860 | win.requestIdleCallback(function () {
|
10861 | return $$.loadFromArgs(args);
|
10862 | });
|
10863 | });
|
10864 | } else {
|
10865 | $$.loadFromArgs(args);
|
10866 | }
|
10867 | },
|
10868 |
|
10869 | |
10870 |
|
10871 |
|
10872 |
|
10873 |
|
10874 |
|
10875 |
|
10876 |
|
10877 |
|
10878 |
|
10879 |
|
10880 |
|
10881 |
|
10882 |
|
10883 |
|
10884 |
|
10885 |
|
10886 |
|
10887 |
|
10888 |
|
10889 |
|
10890 |
|
10891 |
|
10892 | unload: function unload(argsValue) {
|
10893 | var _this = this,
|
10894 | $$ = this.internal,
|
10895 | args = argsValue || {};
|
10896 |
|
10897 | if (isArray(args)) {
|
10898 | args = {
|
10899 | ids: args
|
10900 | };
|
10901 | } else if (isString(args)) {
|
10902 | args = {
|
10903 | ids: [args]
|
10904 | };
|
10905 | }
|
10906 |
|
10907 | var ids = $$.mapToTargetIds(args.ids);
|
10908 | $$.unload(ids, function () {
|
10909 | $$.redraw({
|
10910 | withUpdateOrgXDomain: !0,
|
10911 | withUpdateXDomain: !0,
|
10912 | withLegend: !0
|
10913 | });
|
10914 | $$.cache.remove(ids);
|
10915 | args.done && args.done.call(_this);
|
10916 | });
|
10917 | }
|
10918 | });
|
10919 | ;
|
10920 |
|
10921 |
|
10922 |
|
10923 |
|
10924 |
|
10925 |
|
10926 |
|
10927 |
|
10928 |
|
10929 |
|
10930 |
|
10931 |
|
10932 |
|
10933 | function showHide(show, targetIdsValue, options) {
|
10934 | var _this = this,
|
10935 | $$ = this.internal,
|
10936 | targetIds = $$.mapToTargetIds(targetIdsValue),
|
10937 | hiddenIds = $$.state.hiddenTargetIds.map(function (v) {
|
10938 | return targetIds.indexOf(v) > -1 && v;
|
10939 | }).filter(Boolean);
|
10940 |
|
10941 | $$.state.toggling = !0;
|
10942 | $$[(show ? "remove" : "add") + "HiddenTargetIds"](targetIds);
|
10943 | var targets = $$.$el.svg.selectAll($$.selectorTargets(targetIds)),
|
10944 | opacity = show ? null : "0";
|
10945 |
|
10946 | if (show && hiddenIds.length) {
|
10947 | targets.style("display", null);
|
10948 | callFn($$.config.data_onshown, this, hiddenIds);
|
10949 | }
|
10950 |
|
10951 | $$.$T(targets).style("opacity", opacity, "important").call(endall, function () {
|
10952 |
|
10953 | if (!show && hiddenIds.length === 0) {
|
10954 | targets.style("display", "none");
|
10955 | callFn($$.config.data_onhidden, _this, targetIds);
|
10956 | }
|
10957 |
|
10958 | targets.style("opacity", opacity);
|
10959 | });
|
10960 | options.withLegend && $$[(show ? "show" : "hide") + "Legend"](targetIds);
|
10961 | $$.redraw({
|
10962 | withUpdateOrgXDomain: !0,
|
10963 | withUpdateXDomain: !0,
|
10964 | withLegend: !0
|
10965 | });
|
10966 | $$.state.toggling = !1;
|
10967 | }
|
10968 |
|
10969 | var show = ({
|
10970 | |
10971 |
|
10972 |
|
10973 |
|
10974 |
|
10975 |
|
10976 |
|
10977 |
|
10978 |
|
10979 |
|
10980 |
|
10981 |
|
10982 |
|
10983 |
|
10984 |
|
10985 |
|
10986 |
|
10987 |
|
10988 |
|
10989 | show: function show(targetIdsValue, options) {
|
10990 | if (options === void 0) {
|
10991 | options = {};
|
10992 | }
|
10993 |
|
10994 | showHide.call(this, !0, targetIdsValue, options);
|
10995 | },
|
10996 |
|
10997 | |
10998 |
|
10999 |
|
11000 |
|
11001 |
|
11002 |
|
11003 |
|
11004 |
|
11005 |
|
11006 |
|
11007 |
|
11008 |
|
11009 |
|
11010 |
|
11011 |
|
11012 |
|
11013 |
|
11014 |
|
11015 |
|
11016 | hide: function hide(targetIdsValue, options) {
|
11017 | if (options === void 0) {
|
11018 | options = {};
|
11019 | }
|
11020 |
|
11021 | showHide.call(this, !1, targetIdsValue, options);
|
11022 | },
|
11023 |
|
11024 | |
11025 |
|
11026 |
|
11027 |
|
11028 |
|
11029 |
|
11030 |
|
11031 |
|
11032 |
|
11033 |
|
11034 |
|
11035 |
|
11036 |
|
11037 |
|
11038 |
|
11039 |
|
11040 |
|
11041 |
|
11042 |
|
11043 | toggle: function toggle(targetIds, options) {
|
11044 | var _this2 = this;
|
11045 |
|
11046 | if (options === void 0) {
|
11047 | options = {};
|
11048 | }
|
11049 |
|
11050 | var $$ = this.internal,
|
11051 | targets = {
|
11052 | show: [],
|
11053 | hide: []
|
11054 | };
|
11055 |
|
11056 | $$.mapToTargetIds(targetIds).forEach(function (id) {
|
11057 | return targets[$$.isTargetToShow(id) ? "hide" : "show"].push(id);
|
11058 | });
|
11059 |
|
11060 |
|
11061 | targets.show.length && this.show(targets.show, options);
|
11062 | targets.hide.length && setTimeout(function () {
|
11063 | return _this2.hide(targets.hide, options);
|
11064 | }, 0);
|
11065 | }
|
11066 | });
|
11067 | ;
|
11068 |
|
11069 |
|
11070 |
|
11071 |
|
11072 |
|
11073 |
|
11074 |
|
11075 |
|
11076 |
|
11077 |
|
11078 | var tooltip_tooltip = {
|
11079 | |
11080 |
|
11081 |
|
11082 |
|
11083 |
|
11084 |
|
11085 |
|
11086 |
|
11087 |
|
11088 |
|
11089 |
|
11090 |
|
11091 |
|
11092 |
|
11093 |
|
11094 |
|
11095 |
|
11096 |
|
11097 |
|
11098 |
|
11099 |
|
11100 |
|
11101 |
|
11102 |
|
11103 |
|
11104 |
|
11105 |
|
11106 |
|
11107 |
|
11108 |
|
11109 |
|
11110 |
|
11111 |
|
11112 |
|
11113 |
|
11114 |
|
11115 |
|
11116 |
|
11117 |
|
11118 |
|
11119 |
|
11120 |
|
11121 |
|
11122 |
|
11123 |
|
11124 |
|
11125 |
|
11126 |
|
11127 |
|
11128 |
|
11129 | show: function show(args) {
|
11130 | var $$ = this.internal,
|
11131 | config = $$.config,
|
11132 | inputType = $$.state.inputType,
|
11133 | index,
|
11134 | mouse;
|
11135 |
|
11136 |
|
11137 | if (args.mouse) {
|
11138 | mouse = args.mouse;
|
11139 | }
|
11140 |
|
11141 |
|
11142 | if (args.data) {
|
11143 | var data = args.data,
|
11144 | y = $$.getYScaleById(data.id)(data.value);
|
11145 |
|
11146 | if ($$.isMultipleX()) {
|
11147 |
|
11148 | mouse = [$$.scale.x(data.x), y];
|
11149 | } else {
|
11150 | if (!config.tooltip_grouped) {
|
11151 | mouse = [0, y];
|
11152 | }
|
11153 |
|
11154 | index = isValue(data.index) ? data.index : $$.getIndexByX(data.x);
|
11155 | }
|
11156 | } else if (isDefined(args.x)) {
|
11157 | index = $$.getIndexByX(args.x);
|
11158 | } else if (isDefined(args.index)) {
|
11159 | index = args.index;
|
11160 | }
|
11161 |
|
11162 | (inputType === "mouse" ? ["mouseover", "mousemove"] : ["touchstart"]).forEach(function (eventName) {
|
11163 | $$.dispatchEvent(eventName, index, mouse);
|
11164 | });
|
11165 | },
|
11166 |
|
11167 | |
11168 |
|
11169 |
|
11170 |
|
11171 |
|
11172 |
|
11173 | hide: function hide() {
|
11174 | var $$ = this.internal,
|
11175 | inputType = $$.state.inputType,
|
11176 | tooltip = $$.$el.tooltip,
|
11177 | data = tooltip == null ? void 0 : tooltip.datum();
|
11178 |
|
11179 | if (data) {
|
11180 | var index = JSON.parse(data.current)[0].index;
|
11181 |
|
11182 | (inputType === "mouse" ? ["mouseout"] : ["touchend"]).forEach(function (eventName) {
|
11183 | $$.dispatchEvent(eventName, index);
|
11184 | });
|
11185 | }
|
11186 |
|
11187 |
|
11188 | inputType === "touch" && $$.callOverOutForTouch();
|
11189 | $$.hideTooltip(!0);
|
11190 | $$.hideGridFocus();
|
11191 | $$.unexpandCircles == null ? void 0 : $$.unexpandCircles();
|
11192 | $$.expandBarTypeShapes(!1);
|
11193 | }
|
11194 | };
|
11195 | var api_tooltip = ({
|
11196 | tooltip: tooltip_tooltip
|
11197 | });
|
11198 | ;
|
11199 |
|
11200 |
|
11201 |
|
11202 |
|
11203 |
|
11204 |
|
11205 |
|
11206 |
|
11207 |
|
11208 |
|
11209 |
|
11210 |
|
11211 |
|
11212 |
|
11213 |
|
11214 |
|
11215 |
|
11216 |
|
11217 |
|
11218 |
|
11219 |
|
11220 |
|
11221 |
|
11222 |
|
11223 |
|
11224 |
|
11225 |
|
11226 |
|
11227 |
|
11228 |
|
11229 |
|
11230 |
|
11231 |
|
11232 |
|
11233 |
|
11234 |
|
11235 |
|
11236 |
|
11237 |
|
11238 |
|
11239 |
|
11240 |
|
11241 |
|
11242 |
|
11243 |
|
11244 |
|
11245 |
|
11246 |
|
11247 |
|
11248 |
|
11249 |
|
11250 |
|
11251 |
|
11252 |
|
11253 |
|
11254 |
|
11255 |
|
11256 |
|
11257 |
|
11258 |
|
11259 |
|
11260 |
|
11261 |
|
11262 |
|
11263 |
|
11264 |
|
11265 |
|
11266 |
|
11267 |
|
11268 |
|
11269 |
|
11270 |
|
11271 |
|
11272 |
|
11273 |
|
11274 |
|
11275 |
|
11276 |
|
11277 | var Chart = function Chart(options) {
|
11278 | this.plugins = [];
|
11279 | this.internal = void 0;
|
11280 | var $$ = new ChartInternal(this);
|
11281 | this.internal = $$;
|
11282 |
|
11283 | (function bindThis(fn, target, argThis) {
|
11284 | Object.keys(fn).forEach(function (key) {
|
11285 | var isFunc = isFunction(fn[key]),
|
11286 | isChild = target !== argThis,
|
11287 | isNotNil = notEmpty(fn[key]),
|
11288 | hasChild = isNotNil && Object.keys(fn[key]).length > 0;
|
11289 |
|
11290 | if (isFunc && (!isChild && hasChild || isChild)) {
|
11291 | target[key] = fn[key].bind(argThis);
|
11292 | } else if (isNotNil && !isFunc) {
|
11293 | target[key] = {};
|
11294 | } else {
|
11295 | target[key] = fn[key];
|
11296 | }
|
11297 |
|
11298 | hasChild && bindThis(fn[key], target[key], argThis);
|
11299 | });
|
11300 | })(Chart.prototype, this, this);
|
11301 |
|
11302 | loadConfig.call($$, options);
|
11303 | $$.beforeInit();
|
11304 | $$.init();
|
11305 | };
|
11306 |
|
11307 |
|
11308 |
|
11309 | extend(Chart.prototype, [chart, api_color, api_data, api_export, api_focus, api_legend, api_load, show, api_tooltip]);
|
11310 | ;
|
11311 |
|
11312 |
|
11313 |
|
11314 |
|
11315 |
|
11316 |
|
11317 |
|
11318 |
|
11319 |
|
11320 |
|
11321 |
|
11322 |
|
11323 |
|
11324 | function setMinMax($$, type, value) {
|
11325 | var config = $$.config,
|
11326 | axisY = "axis_y_" + type,
|
11327 | axisY2 = "axis_y2_" + type;
|
11328 |
|
11329 | if (isDefined(value)) {
|
11330 | if (isObjectType(value)) {
|
11331 | isValue(value.x) && (config["axis_x_" + type] = value.x);
|
11332 | isValue(value.y) && (config[axisY] = value.y);
|
11333 | isValue(value.y2) && (config[axisY2] = value.y2);
|
11334 | } else {
|
11335 | config[axisY] = value;
|
11336 | config[axisY2] = value;
|
11337 | }
|
11338 |
|
11339 | $$.redraw({
|
11340 | withUpdateOrgXDomain: !0,
|
11341 | withUpdateXDomain: !0
|
11342 | });
|
11343 | }
|
11344 | }
|
11345 |
|
11346 |
|
11347 |
|
11348 |
|
11349 |
|
11350 |
|
11351 |
|
11352 |
|
11353 |
|
11354 | function axis_getMinMax($$, type) {
|
11355 | var config = $$.config;
|
11356 | return {
|
11357 | x: config["axis_x_" + type],
|
11358 | y: config["axis_y_" + type],
|
11359 | y2: config["axis_y2_" + type]
|
11360 | };
|
11361 | }
|
11362 |
|
11363 |
|
11364 |
|
11365 |
|
11366 |
|
11367 |
|
11368 | var axis = {
|
11369 | |
11370 |
|
11371 |
|
11372 |
|
11373 |
|
11374 |
|
11375 |
|
11376 |
|
11377 |
|
11378 |
|
11379 |
|
11380 |
|
11381 |
|
11382 |
|
11383 |
|
11384 |
|
11385 |
|
11386 |
|
11387 |
|
11388 |
|
11389 |
|
11390 |
|
11391 |
|
11392 |
|
11393 |
|
11394 | labels: function labels(_labels) {
|
11395 | var $$ = this.internal,
|
11396 | labelText;
|
11397 |
|
11398 | if (_labels) {
|
11399 | Object.keys(_labels).forEach(function (axisId) {
|
11400 | $$.axis.setLabelText(axisId, _labels[axisId]);
|
11401 | });
|
11402 | $$.axis.updateLabels();
|
11403 | }
|
11404 |
|
11405 | ["x", "y", "y2"].forEach(function (v) {
|
11406 | var text = $$.axis.getLabelText(v);
|
11407 |
|
11408 | if (text) {
|
11409 | labelText || (labelText = {});
|
11410 | labelText[v] = text;
|
11411 | }
|
11412 | });
|
11413 | return labelText;
|
11414 | },
|
11415 |
|
11416 | |
11417 |
|
11418 |
|
11419 |
|
11420 |
|
11421 |
|
11422 |
|
11423 |
|
11424 |
|
11425 |
|
11426 |
|
11427 |
|
11428 |
|
11429 |
|
11430 |
|
11431 |
|
11432 |
|
11433 | min: function min(_min) {
|
11434 | var $$ = this.internal;
|
11435 | return isValue(_min) ? setMinMax($$, "min", _min) : axis_getMinMax($$, "min");
|
11436 | },
|
11437 |
|
11438 | |
11439 |
|
11440 |
|
11441 |
|
11442 |
|
11443 |
|
11444 |
|
11445 |
|
11446 |
|
11447 |
|
11448 |
|
11449 |
|
11450 |
|
11451 |
|
11452 |
|
11453 |
|
11454 |
|
11455 | max: function max(_max) {
|
11456 | var $$ = this.internal;
|
11457 | return arguments.length ? setMinMax($$, "max", _max) : axis_getMinMax($$, "max");
|
11458 | },
|
11459 |
|
11460 | |
11461 |
|
11462 |
|
11463 |
|
11464 |
|
11465 |
|
11466 |
|
11467 |
|
11468 |
|
11469 |
|
11470 |
|
11471 |
|
11472 |
|
11473 |
|
11474 |
|
11475 |
|
11476 |
|
11477 |
|
11478 |
|
11479 |
|
11480 |
|
11481 |
|
11482 | range: function range(_range) {
|
11483 | var axis = this.axis;
|
11484 |
|
11485 | if (arguments.length) {
|
11486 | isDefined(_range.max) && axis.max(_range.max);
|
11487 | isDefined(_range.min) && axis.min(_range.min);
|
11488 | } else {
|
11489 | return {
|
11490 | max: axis.max(),
|
11491 | min: axis.min()
|
11492 | };
|
11493 | }
|
11494 |
|
11495 | return undefined;
|
11496 | }
|
11497 | };
|
11498 | var api_axis = ({
|
11499 | axis: axis
|
11500 | });
|
11501 | ;
|
11502 |
|
11503 |
|
11504 |
|
11505 |
|
11506 | var api_category = ({
|
11507 | |
11508 |
|
11509 |
|
11510 |
|
11511 |
|
11512 |
|
11513 |
|
11514 |
|
11515 |
|
11516 |
|
11517 |
|
11518 | category: function category(i, _category) {
|
11519 | var $$ = this.internal,
|
11520 | config = $$.config;
|
11521 |
|
11522 | if (arguments.length > 1) {
|
11523 | config.axis_x_categories[i] = _category;
|
11524 | $$.redraw();
|
11525 | }
|
11526 |
|
11527 | return config.axis_x_categories[i];
|
11528 | },
|
11529 |
|
11530 | |
11531 |
|
11532 |
|
11533 |
|
11534 |
|
11535 |
|
11536 |
|
11537 |
|
11538 |
|
11539 |
|
11540 |
|
11541 |
|
11542 | categories: function categories(_categories) {
|
11543 | var $$ = this.internal,
|
11544 | config = $$.config;
|
11545 |
|
11546 | if (!arguments.length) {
|
11547 | return config.axis_x_categories;
|
11548 | }
|
11549 |
|
11550 | config.axis_x_categories = _categories;
|
11551 | $$.redraw();
|
11552 | return config.axis_x_categories;
|
11553 | }
|
11554 | });
|
11555 | ;
|
11556 |
|
11557 |
|
11558 |
|
11559 |
|
11560 |
|
11561 |
|
11562 |
|
11563 |
|
11564 |
|
11565 |
|
11566 |
|
11567 |
|
11568 |
|
11569 |
|
11570 |
|
11571 |
|
11572 |
|
11573 |
|
11574 |
|
11575 |
|
11576 |
|
11577 | function xgrids(grids) {
|
11578 | var $$ = this.internal,
|
11579 | config = $$.config;
|
11580 |
|
11581 | if (!grids) {
|
11582 | return config.grid_x_lines;
|
11583 | }
|
11584 |
|
11585 | config.grid_x_lines = grids;
|
11586 | $$.redrawWithoutRescale();
|
11587 | return config.grid_x_lines;
|
11588 | }
|
11589 |
|
11590 | extend(xgrids, {
|
11591 | |
11592 |
|
11593 |
|
11594 |
|
11595 |
|
11596 |
|
11597 |
|
11598 |
|
11599 |
|
11600 |
|
11601 |
|
11602 |
|
11603 |
|
11604 |
|
11605 |
|
11606 |
|
11607 |
|
11608 |
|
11609 |
|
11610 |
|
11611 | add: function add(grids) {
|
11612 | return this.xgrids(this.internal.config.grid_x_lines.concat(grids || []));
|
11613 | },
|
11614 |
|
11615 | |
11616 |
|
11617 |
|
11618 |
|
11619 |
|
11620 |
|
11621 |
|
11622 |
|
11623 |
|
11624 |
|
11625 |
|
11626 |
|
11627 |
|
11628 |
|
11629 |
|
11630 |
|
11631 |
|
11632 |
|
11633 |
|
11634 | remove: function remove(params) {
|
11635 |
|
11636 | this.internal.removeGridLines(params, !0);
|
11637 | }
|
11638 | });
|
11639 | var grid_x = ({
|
11640 | xgrids: xgrids
|
11641 | });
|
11642 | ;
|
11643 |
|
11644 |
|
11645 |
|
11646 |
|
11647 |
|
11648 |
|
11649 |
|
11650 |
|
11651 |
|
11652 |
|
11653 |
|
11654 |
|
11655 |
|
11656 |
|
11657 |
|
11658 |
|
11659 |
|
11660 |
|
11661 |
|
11662 |
|
11663 |
|
11664 | function ygrids(grids) {
|
11665 | var $$ = this.internal,
|
11666 | config = $$.config;
|
11667 |
|
11668 | if (!grids) {
|
11669 | return config.grid_y_lines;
|
11670 | }
|
11671 |
|
11672 | config.grid_y_lines = grids;
|
11673 | $$.redrawWithoutRescale();
|
11674 | return config.grid_y_lines;
|
11675 | }
|
11676 |
|
11677 | extend(ygrids, {
|
11678 | |
11679 |
|
11680 |
|
11681 |
|
11682 |
|
11683 |
|
11684 |
|
11685 |
|
11686 |
|
11687 |
|
11688 |
|
11689 |
|
11690 |
|
11691 |
|
11692 |
|
11693 |
|
11694 |
|
11695 |
|
11696 |
|
11697 |
|
11698 | add: function add(grids) {
|
11699 | return this.ygrids(this.internal.config.grid_y_lines.concat(grids || []));
|
11700 | },
|
11701 |
|
11702 | |
11703 |
|
11704 |
|
11705 |
|
11706 |
|
11707 |
|
11708 |
|
11709 |
|
11710 |
|
11711 |
|
11712 |
|
11713 |
|
11714 |
|
11715 |
|
11716 |
|
11717 |
|
11718 |
|
11719 |
|
11720 |
|
11721 |
|
11722 |
|
11723 | remove: function remove(params) {
|
11724 |
|
11725 | this.internal.removeGridLines(params, !1);
|
11726 | }
|
11727 | });
|
11728 | var grid_y = ({
|
11729 | ygrids: ygrids
|
11730 | });
|
11731 | ;
|
11732 |
|
11733 |
|
11734 |
|
11735 |
|
11736 |
|
11737 | var group = ({
|
11738 | |
11739 |
|
11740 |
|
11741 |
|
11742 |
|
11743 |
|
11744 |
|
11745 |
|
11746 |
|
11747 |
|
11748 |
|
11749 |
|
11750 |
|
11751 | groups: function groups(_groups) {
|
11752 | var $$ = this.internal,
|
11753 | config = $$.config;
|
11754 |
|
11755 | if (isUndefined(_groups)) {
|
11756 | return config.data_groups;
|
11757 | }
|
11758 |
|
11759 | config.data_groups = _groups;
|
11760 | $$.redraw();
|
11761 | return config.data_groups;
|
11762 | }
|
11763 | });
|
11764 | ;
|
11765 |
|
11766 |
|
11767 |
|
11768 |
|
11769 |
|
11770 |
|
11771 |
|
11772 |
|
11773 |
|
11774 |
|
11775 |
|
11776 |
|
11777 |
|
11778 |
|
11779 |
|
11780 |
|
11781 |
|
11782 |
|
11783 |
|
11784 |
|
11785 |
|
11786 | function regions(regions) {
|
11787 | var $$ = this.internal,
|
11788 | config = $$.config;
|
11789 |
|
11790 | if (!regions) {
|
11791 | return config.regions;
|
11792 | }
|
11793 |
|
11794 | config.regions = regions;
|
11795 | $$.redrawWithoutRescale();
|
11796 | return regions;
|
11797 | }
|
11798 |
|
11799 | extend(regions, {
|
11800 | |
11801 |
|
11802 |
|
11803 |
|
11804 |
|
11805 |
|
11806 |
|
11807 |
|
11808 |
|
11809 |
|
11810 |
|
11811 |
|
11812 |
|
11813 |
|
11814 |
|
11815 |
|
11816 |
|
11817 |
|
11818 |
|
11819 |
|
11820 | add: function add(regions) {
|
11821 | var $$ = this.internal,
|
11822 | config = $$.config;
|
11823 |
|
11824 | if (!regions) {
|
11825 | return config.regions;
|
11826 | }
|
11827 |
|
11828 | config.regions = config.regions.concat(regions);
|
11829 | $$.redrawWithoutRescale();
|
11830 | return config.regions;
|
11831 | },
|
11832 |
|
11833 | |
11834 |
|
11835 |
|
11836 |
|
11837 |
|
11838 |
|
11839 |
|
11840 |
|
11841 |
|
11842 |
|
11843 |
|
11844 |
|
11845 |
|
11846 |
|
11847 |
|
11848 |
|
11849 |
|
11850 |
|
11851 |
|
11852 | remove: function remove(optionsValue) {
|
11853 | var $$ = this.internal,
|
11854 | config = $$.config,
|
11855 | $T = $$.$T,
|
11856 | options = optionsValue || {},
|
11857 | classes = getOption(options, "classes", [config_classes.region]),
|
11858 | regions = $$.$el.main.select("." + config_classes.regions).selectAll(classes.map(function (c) {
|
11859 | return "." + c;
|
11860 | }));
|
11861 | $T(regions).style("opacity", "0").remove();
|
11862 | regions = config.regions;
|
11863 |
|
11864 | if (Object.keys(options).length) {
|
11865 | regions = regions.filter(function (region) {
|
11866 | var found = !1;
|
11867 |
|
11868 | if (!region.class) {
|
11869 | return !0;
|
11870 | }
|
11871 |
|
11872 | region.class.split(" ").forEach(function (c) {
|
11873 | if (classes.indexOf(c) >= 0) {
|
11874 | found = !0;
|
11875 | }
|
11876 | });
|
11877 | return !found;
|
11878 | });
|
11879 | config.regions = regions;
|
11880 | } else {
|
11881 | config.regions = [];
|
11882 | }
|
11883 |
|
11884 | return regions;
|
11885 | }
|
11886 | });
|
11887 | var api_regions = ({
|
11888 | regions: regions
|
11889 | });
|
11890 | ;
|
11891 |
|
11892 |
|
11893 |
|
11894 |
|
11895 |
|
11896 | var x = ({
|
11897 | |
11898 |
|
11899 |
|
11900 |
|
11901 |
|
11902 |
|
11903 |
|
11904 |
|
11905 |
|
11906 |
|
11907 |
|
11908 |
|
11909 |
|
11910 |
|
11911 | x: function x(_x) {
|
11912 | var $$ = this.internal,
|
11913 | axis = $$.axis,
|
11914 | data = $$.data,
|
11915 | isCategorized = axis.isCustomX() && axis.isCategorized();
|
11916 |
|
11917 | if (isArray(_x)) {
|
11918 | if (isCategorized) {
|
11919 | this.categories(_x);
|
11920 | } else {
|
11921 | $$.updateTargetX(data.targets, _x);
|
11922 | $$.redraw({
|
11923 | withUpdateOrgXDomain: !0,
|
11924 | withUpdateXDomain: !0
|
11925 | });
|
11926 | }
|
11927 | }
|
11928 |
|
11929 | return isCategorized ? this.categories() : data.xs;
|
11930 | },
|
11931 |
|
11932 | |
11933 |
|
11934 |
|
11935 |
|
11936 |
|
11937 |
|
11938 |
|
11939 |
|
11940 |
|
11941 |
|
11942 |
|
11943 |
|
11944 |
|
11945 |
|
11946 |
|
11947 |
|
11948 |
|
11949 | xs: function xs(_xs) {
|
11950 | var $$ = this.internal;
|
11951 |
|
11952 | if (isObject(_xs)) {
|
11953 | $$.updateTargetXs($$.data.targets, _xs);
|
11954 | $$.redraw({
|
11955 | withUpdateOrgXDomain: !0,
|
11956 | withUpdateXDomain: !0
|
11957 | });
|
11958 | }
|
11959 |
|
11960 | return $$.data.xs;
|
11961 | }
|
11962 | });
|
11963 | ;
|
11964 |
|
11965 |
|
11966 |
|
11967 |
|
11968 |
|
11969 | var flow = ({
|
11970 | |
11971 |
|
11972 |
|
11973 |
|
11974 |
|
11975 |
|
11976 |
|
11977 |
|
11978 |
|
11979 |
|
11980 |
|
11981 |
|
11982 |
|
11983 |
|
11984 |
|
11985 |
|
11986 |
|
11987 |
|
11988 |
|
11989 |
|
11990 |
|
11991 |
|
11992 |
|
11993 |
|
11994 |
|
11995 |
|
11996 |
|
11997 |
|
11998 |
|
11999 |
|
12000 |
|
12001 |
|
12002 |
|
12003 |
|
12004 |
|
12005 |
|
12006 |
|
12007 |
|
12008 |
|
12009 |
|
12010 |
|
12011 |
|
12012 |
|
12013 |
|
12014 |
|
12015 |
|
12016 |
|
12017 |
|
12018 |
|
12019 | flow: function flow(args) {
|
12020 | var $$ = this.internal,
|
12021 | data,
|
12022 | domain,
|
12023 | length = 0,
|
12024 | tail = 0,
|
12025 | diff,
|
12026 | to;
|
12027 |
|
12028 | if (args.json || args.rows || args.columns) {
|
12029 | data = $$.convertData(args);
|
12030 | }
|
12031 |
|
12032 | if ($$.state.redrawing || !data || !isTabVisible()) {
|
12033 | return;
|
12034 | }
|
12035 |
|
12036 | var notfoundIds = [],
|
12037 | orgDataCount = $$.getMaxDataCount(),
|
12038 | targets = $$.convertDataToTargets(data, !0),
|
12039 | isTimeSeries = $$.axis.isTimeSeries();
|
12040 |
|
12041 | $$.data.targets.forEach(function (t) {
|
12042 | var found = !1;
|
12043 |
|
12044 | for (var i = 0; i < targets.length; i++) {
|
12045 | if (t.id === targets[i].id) {
|
12046 | found = !0;
|
12047 |
|
12048 | if (t.values[t.values.length - 1]) {
|
12049 | tail = t.values[t.values.length - 1].index + 1;
|
12050 | }
|
12051 |
|
12052 | length = targets[i].values.length;
|
12053 |
|
12054 | for (var j = 0; j < length; j++) {
|
12055 | targets[i].values[j].index = tail + j;
|
12056 |
|
12057 | if (!isTimeSeries) {
|
12058 | targets[i].values[j].x = tail + j;
|
12059 | }
|
12060 | }
|
12061 |
|
12062 | t.values = t.values.concat(targets[i].values);
|
12063 | targets.splice(i, 1);
|
12064 | break;
|
12065 | }
|
12066 | }
|
12067 |
|
12068 | found || notfoundIds.push(t.id);
|
12069 | });
|
12070 |
|
12071 | $$.data.targets.forEach(function (t) {
|
12072 | for (var i = 0; i < notfoundIds.length; i++) {
|
12073 | if (t.id === notfoundIds[i]) {
|
12074 | tail = t.values[t.values.length - 1].index + 1;
|
12075 |
|
12076 | for (var j = 0; j < length; j++) {
|
12077 | t.values.push({
|
12078 | id: t.id,
|
12079 | index: tail + j,
|
12080 | x: isTimeSeries ? $$.getOtherTargetX(tail + j) : tail + j,
|
12081 | value: null
|
12082 | });
|
12083 | }
|
12084 | }
|
12085 | }
|
12086 | });
|
12087 |
|
12088 | if ($$.data.targets.length) {
|
12089 | targets.forEach(function (t) {
|
12090 | var missing = [];
|
12091 |
|
12092 | for (var i = $$.data.targets[0].values[0].index; i < tail; i++) {
|
12093 | missing.push({
|
12094 | id: t.id,
|
12095 | index: i,
|
12096 | x: isTimeSeries ? $$.getOtherTargetX(i) : i,
|
12097 | value: null
|
12098 | });
|
12099 | }
|
12100 |
|
12101 | t.values.forEach(function (v) {
|
12102 | v.index += tail;
|
12103 |
|
12104 | if (!isTimeSeries) {
|
12105 | v.x += tail;
|
12106 | }
|
12107 | });
|
12108 | t.values = missing.concat(t.values);
|
12109 | });
|
12110 | }
|
12111 |
|
12112 | $$.data.targets = $$.data.targets.concat(targets);
|
12113 |
|
12114 |
|
12115 |
|
12116 | var baseTarget = $$.data.targets[0],
|
12117 | baseValue = baseTarget.values[0];
|
12118 |
|
12119 |
|
12120 | if (isDefined(args.to)) {
|
12121 | length = 0;
|
12122 | to = isTimeSeries ? parseDate.call($$, args.to) : args.to;
|
12123 | baseTarget.values.forEach(function (v) {
|
12124 | v.x < to && length++;
|
12125 | });
|
12126 | } else if (isDefined(args.length)) {
|
12127 | length = args.length;
|
12128 | }
|
12129 |
|
12130 |
|
12131 | if (!orgDataCount) {
|
12132 | if (isTimeSeries) {
|
12133 | diff = baseTarget.values.length > 1 ? baseTarget.values[baseTarget.values.length - 1].x - baseValue.x : baseValue.x - $$.getXDomain($$.data.targets)[0];
|
12134 | } else {
|
12135 | diff = 1;
|
12136 | }
|
12137 |
|
12138 | domain = [baseValue.x - diff, baseValue.x];
|
12139 | } else if (orgDataCount === 1 && isTimeSeries) {
|
12140 | diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2;
|
12141 | domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)];
|
12142 | }
|
12143 |
|
12144 | domain && $$.updateXDomain(null, !0, !0, !1, domain);
|
12145 |
|
12146 | $$.updateTargets($$.data.targets);
|
12147 |
|
12148 | $$.redraw({
|
12149 | flow: {
|
12150 | index: baseValue.index,
|
12151 | length: length,
|
12152 | duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
|
12153 | done: args.done,
|
12154 | orgDataCount: orgDataCount
|
12155 | },
|
12156 | withLegend: !0,
|
12157 | withTransition: orgDataCount > 1,
|
12158 | withTrimXDomain: !1,
|
12159 | withUpdateXAxis: !0
|
12160 | });
|
12161 | }
|
12162 | });
|
12163 |
|
12164 | var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack_require__(10);
|
12165 | ;
|
12166 |
|
12167 |
|
12168 |
|
12169 |
|
12170 |
|
12171 |
|
12172 |
|
12173 |
|
12174 | var AxisRendererHelper = function () {
|
12175 | function AxisRendererHelper(owner) {
|
12176 | this.owner = void 0;
|
12177 | this.config = void 0;
|
12178 | this.scale = void 0;
|
12179 | var scale = getScale(),
|
12180 | config = owner.config,
|
12181 | params = owner.params;
|
12182 | this.owner = owner;
|
12183 | this.config = config;
|
12184 | this.scale = scale;
|
12185 |
|
12186 | if (config.noTransition || !params.config.transition_duration) {
|
12187 | config.withoutTransition = !0;
|
12188 | }
|
12189 |
|
12190 |
|
12191 | config.range = this.scaleExtent((params.orgXScale || scale).range());
|
12192 | }
|
12193 | |
12194 |
|
12195 |
|
12196 |
|
12197 |
|
12198 |
|
12199 |
|
12200 |
|
12201 | AxisRendererHelper.getSizeFor1Char = function getSizeFor1Char(node) {
|
12202 |
|
12203 | var size = {
|
12204 | w: 5.5,
|
12205 | h: 11.5
|
12206 | };
|
12207 | node.empty() || node.select("text").text("0").call(function (el) {
|
12208 | try {
|
12209 | var _el$node$getBBox = el.node().getBBox(),
|
12210 | width = _el$node$getBBox.width,
|
12211 | height = _el$node$getBBox.height;
|
12212 |
|
12213 | if (width && height) {
|
12214 | size.w = width;
|
12215 | size.h = height;
|
12216 | }
|
12217 | } catch (e) {} finally {
|
12218 | el.text("");
|
12219 | }
|
12220 | });
|
12221 |
|
12222 | this.getSizeFor1Char = function () {
|
12223 | return size;
|
12224 | };
|
12225 |
|
12226 | return size;
|
12227 | }
|
12228 | |
12229 |
|
12230 |
|
12231 |
|
12232 |
|
12233 |
|
12234 | ;
|
12235 |
|
12236 | var _proto = AxisRendererHelper.prototype;
|
12237 |
|
12238 | _proto.getTickTransformSetter = function getTickTransformSetter(id) {
|
12239 | var config = this.config,
|
12240 | fn = id === "x" ? function (value) {
|
12241 | return "translate(" + (value + config.tickOffset) + ",0)";
|
12242 | } : function (value) {
|
12243 | return "translate(0," + value + ")";
|
12244 | };
|
12245 | return function (selection, scale) {
|
12246 | selection.attr("transform", function (d) {
|
12247 | return fn(Math.ceil(scale(d)));
|
12248 | });
|
12249 | };
|
12250 | };
|
12251 |
|
12252 | _proto.scaleExtent = function scaleExtent(domain) {
|
12253 | var start = domain[0],
|
12254 | stop = domain[domain.length - 1];
|
12255 | return start < stop ? [start, stop] : [stop, start];
|
12256 | };
|
12257 |
|
12258 | _proto.generateTicks = function generateTicks(scale, isYAxes) {
|
12259 | var tickStepSize = this.owner.params.tickStepSize,
|
12260 | _scale$domain = scale.domain(),
|
12261 | start = _scale$domain[0],
|
12262 | end = _scale$domain[1],
|
12263 | ticks = [];
|
12264 |
|
12265 |
|
12266 | if (isYAxes && tickStepSize) {
|
12267 | var interval = Math.round(start);
|
12268 |
|
12269 | while (interval <= end) {
|
12270 | ticks.push(interval);
|
12271 | interval += tickStepSize;
|
12272 | }
|
12273 | } else if (scale.ticks) {
|
12274 | var tickArguments = this.config.tickArguments;
|
12275 |
|
12276 | if (scale.type === "log" && !tickArguments) {
|
12277 |
|
12278 |
|
12279 | var s = getScale("_log").domain([start > 0 ? start : 1, end]).range(scale.range());
|
12280 | ticks = s.ticks();
|
12281 |
|
12282 | for (var cnt = end.toFixed().length; ticks.length > 15; cnt--) {
|
12283 | ticks = s.ticks(cnt);
|
12284 | }
|
12285 |
|
12286 | ticks.splice(0, 1, start);
|
12287 | ticks.splice(ticks.length - 1, 1, end);
|
12288 | } else {
|
12289 | ticks = scale.ticks.apply(scale, this.config.tickArguments || []);
|
12290 | }
|
12291 |
|
12292 | ticks = ticks.map(function (v) {
|
12293 |
|
12294 | var r = isString(v) && isNumber(v) && !isNaN(v) && Math.round(v * 10) / 10 || v;
|
12295 | return r;
|
12296 | });
|
12297 | } else {
|
12298 | for (var i = Math.ceil(start); i < end; i++) {
|
12299 | ticks.push(i);
|
12300 | }
|
12301 |
|
12302 | if (ticks.length > 0 && ticks[0] > 0) {
|
12303 | ticks.unshift(ticks[0] - (ticks[1] - ticks[0]));
|
12304 | }
|
12305 | }
|
12306 |
|
12307 | return ticks;
|
12308 | };
|
12309 |
|
12310 | _proto.copyScale = function copyScale() {
|
12311 | var newScale = this.scale.copy();
|
12312 |
|
12313 | if (!newScale.domain().length) {
|
12314 | newScale.domain(this.scale.domain());
|
12315 | }
|
12316 |
|
12317 | newScale.type = this.scale.type;
|
12318 | return newScale;
|
12319 | };
|
12320 |
|
12321 | _proto.textFormatted = function textFormatted(v) {
|
12322 | var tickFormat = this.config.tickFormat,
|
12323 | value = /\d+\.\d+0{5,}\d$/.test(v) ? +(v + "").replace(/0+\d$/, "") : v,
|
12324 | formatted = tickFormat ? tickFormat(value) : value;
|
12325 |
|
12326 |
|
12327 |
|
12328 | return isDefined(formatted) ? formatted : "";
|
12329 | };
|
12330 |
|
12331 | _proto.transitionise = function transitionise(selection) {
|
12332 | var config = this.config,
|
12333 | transitionSelection = selection;
|
12334 |
|
12335 | if (config.withoutTransition) {
|
12336 | transitionSelection = selection.interrupt();
|
12337 | } else if (config.transition || !this.owner.params.noTransition) {
|
12338 |
|
12339 |
|
12340 | try {
|
12341 | transitionSelection = selection.transition(config.transition);
|
12342 | } catch (e) {}
|
12343 | }
|
12344 |
|
12345 | return transitionSelection;
|
12346 | };
|
12347 |
|
12348 | return AxisRendererHelper;
|
12349 | }();
|
12350 |
|
12351 |
|
12352 | ;
|
12353 |
|
12354 |
|
12355 |
|
12356 |
|
12357 |
|
12358 |
|
12359 |
|
12360 |
|
12361 |
|
12362 | var AxisRenderer = function () {
|
12363 | function AxisRenderer(params) {
|
12364 | if (params === void 0) {
|
12365 | params = {};
|
12366 | }
|
12367 |
|
12368 | this.helper = void 0;
|
12369 | this.config = void 0;
|
12370 | this.params = void 0;
|
12371 | this.g = void 0;
|
12372 | var config = {
|
12373 | innerTickSize: 6,
|
12374 | outerTickSize: params.outerTick ? 6 : 0,
|
12375 | orient: "bottom",
|
12376 | range: [],
|
12377 | tickArguments: null,
|
12378 | tickCentered: null,
|
12379 | tickCulling: !0,
|
12380 | tickFormat: null,
|
12381 | tickLength: 9,
|
12382 | tickOffset: 0,
|
12383 | tickPadding: 3,
|
12384 | tickValues: null,
|
12385 | transition: null,
|
12386 | noTransition: params.noTransition
|
12387 | };
|
12388 | config.tickLength = Math.max(config.innerTickSize, 0) + config.tickPadding;
|
12389 | this.config = config;
|
12390 | this.params = params;
|
12391 | this.helper = new AxisRendererHelper(this);
|
12392 | }
|
12393 | |
12394 |
|
12395 |
|
12396 |
|
12397 |
|
12398 |
|
12399 |
|
12400 | var _proto = AxisRenderer.prototype;
|
12401 |
|
12402 | _proto.create = function create(g) {
|
12403 | var ctx = this,
|
12404 | config = this.config,
|
12405 | helper = this.helper,
|
12406 | params = this.params,
|
12407 | scale = helper.scale,
|
12408 | orient = config.orient,
|
12409 | splitTickText = this.splitTickText.bind(this),
|
12410 | isLeftRight = /^(left|right)$/.test(orient),
|
12411 | isTopBottom = /^(top|bottom)$/.test(orient),
|
12412 | tickTransform = helper.getTickTransformSetter(isTopBottom ? "x" : "y"),
|
12413 | axisPx = tickTransform === helper.axisX ? "y" : "x",
|
12414 | sign = /^(top|left)$/.test(orient) ? -1 : 1,
|
12415 | rotate = params.tickTextRotate;
|
12416 | this.config.range = scale.rangeExtent ? scale.rangeExtent() : helper.scaleExtent((params.orgXScale || scale).range());
|
12417 | var _config2 = config,
|
12418 | innerTickSize = _config2.innerTickSize,
|
12419 | tickLength = _config2.tickLength,
|
12420 | range = _config2.range,
|
12421 | id = params.id,
|
12422 | tickTextPos = id && /^(x|y|y2)$/.test(id) ? params.config["axis_" + id + "_tick_text_position"] : {
|
12423 | x: 0,
|
12424 | y: 0
|
12425 | },
|
12426 | prefix = id === "subX" ? "subchart_axis_x" : "axis_" + id,
|
12427 | axisShow = params.config[prefix + "_show"],
|
12428 | tickShow = {
|
12429 | tick: axisShow ? params.config[prefix + "_tick_show"] : !1,
|
12430 | text: axisShow ? params.config[prefix + "_tick_text_show"] : !1
|
12431 | },
|
12432 | $g;
|
12433 |
|
12434 | g.each(function () {
|
12435 | var g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
12436 | scale0 = this.__chart__ || scale,
|
12437 | scale1 = helper.copyScale();
|
12438 | $g = g;
|
12439 | this.__chart__ = scale1;
|
12440 | config.tickOffset = params.isCategory ? Math.ceil((scale1(1) - scale1(0)) / 2) : 0;
|
12441 |
|
12442 | var path = g.selectAll(".domain").data([0]);
|
12443 |
|
12444 | path.enter().append("path").attr("class", "domain")
|
12445 | .merge(path).attr("d", function () {
|
12446 | var outerTickSized = config.outerTickSize * sign;
|
12447 | return isTopBottom ? "M" + range[0] + "," + outerTickSized + "V0H" + range[1] + "V" + outerTickSized : "M" + outerTickSized + "," + range[0] + "H0V" + range[1] + "H" + outerTickSized;
|
12448 | });
|
12449 |
|
12450 | if (tickShow.tick || tickShow.text) {
|
12451 |
|
12452 | var ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight),
|
12453 | tick = g.selectAll(".tick").data(ticks, scale1),
|
12454 | tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick"),
|
12455 | tickExit = tick.exit().remove();
|
12456 |
|
12457 |
|
12458 | tick = tickEnter.merge(tick);
|
12459 | tickShow.tick && tickEnter.append("line");
|
12460 | tickShow.text && tickEnter.append("text");
|
12461 | var sizeFor1Char = AxisRendererHelper.getSizeFor1Char(tick),
|
12462 | counts = [],
|
12463 | tspan = tick.select("text").selectAll("tspan").data(function (d, index) {
|
12464 | var split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
|
12465 | counts[index] = split.length;
|
12466 | return split.map(function (splitted) {
|
12467 | return {
|
12468 | index: index,
|
12469 | splitted: splitted
|
12470 | };
|
12471 | });
|
12472 | });
|
12473 | tspan.exit().remove();
|
12474 | tspan = tspan.enter().append("tspan").merge(tspan).text(function (d) {
|
12475 | return d.splitted;
|
12476 | });
|
12477 |
|
12478 | tspan.attr("x", isTopBottom ? 0 : tickLength * sign).attr("dx", function () {
|
12479 | var dx = 0;
|
12480 |
|
12481 | if (/(top|bottom)/.test(orient) && rotate) {
|
12482 | dx = 8 * Math.sin(Math.PI * (rotate / 180)) * (orient === "top" ? -1 : 1);
|
12483 | }
|
12484 |
|
12485 | return dx + (tickTextPos.x || 0);
|
12486 | }()).attr("dy", function (d, i) {
|
12487 | var dy = 0;
|
12488 |
|
12489 | if (orient !== "top") {
|
12490 | dy = sizeFor1Char.h;
|
12491 |
|
12492 | if (i === 0) {
|
12493 | dy = isLeftRight ? -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3) : tickTextPos.y === 0 ? ".71em" : 0;
|
12494 | }
|
12495 | }
|
12496 |
|
12497 | return isNumber(dy) && tickTextPos.y ? dy + tickTextPos.y : dy || ".71em";
|
12498 | });
|
12499 | var lineUpdate = tick.select("line"),
|
12500 | textUpdate = tick.select("text");
|
12501 | tickEnter.select("line").attr(axisPx + "2", innerTickSize * sign);
|
12502 | tickEnter.select("text").attr(axisPx, tickLength * sign);
|
12503 | ctx.setTickLineTextPosition(lineUpdate, textUpdate);
|
12504 |
|
12505 | if (params.tickTitle) {
|
12506 | var title = textUpdate.select("title");
|
12507 | (title.empty() ? textUpdate.append("title") : title).text(function (index) {
|
12508 | return params.tickTitle[index];
|
12509 | });
|
12510 | }
|
12511 |
|
12512 | if (scale1.bandwidth) {
|
12513 | var x = scale1,
|
12514 | dx = x.bandwidth() / 2;
|
12515 |
|
12516 | scale0 = function (d) {
|
12517 | return x(d) + dx;
|
12518 | };
|
12519 |
|
12520 | scale1 = scale0;
|
12521 | } else if (scale0.bandwidth) {
|
12522 | scale0 = scale1;
|
12523 | } else {
|
12524 | tickTransform(tickExit, scale1);
|
12525 | }
|
12526 |
|
12527 |
|
12528 |
|
12529 | tick = params.owner.state.flowing ? helper.transitionise(tick) : params.owner.$T(tick);
|
12530 | tickTransform(tickEnter, scale0);
|
12531 | tickTransform(tick.style("opacity", null), scale1);
|
12532 | }
|
12533 | });
|
12534 | this.g = $g;
|
12535 | }
|
12536 | |
12537 |
|
12538 |
|
12539 |
|
12540 |
|
12541 | ;
|
12542 |
|
12543 | _proto.getTickXY = function getTickXY() {
|
12544 | var config = this.config,
|
12545 | pos = {
|
12546 | x: 0,
|
12547 | y: 0
|
12548 | };
|
12549 |
|
12550 | if (this.params.isCategory) {
|
12551 | pos.x = config.tickCentered ? 0 : config.tickOffset;
|
12552 | pos.y = config.tickCentered ? config.tickOffset : 0;
|
12553 | }
|
12554 |
|
12555 | return pos;
|
12556 | }
|
12557 | |
12558 |
|
12559 |
|
12560 |
|
12561 |
|
12562 |
|
12563 | ;
|
12564 |
|
12565 | _proto.getTickSize = function getTickSize(d) {
|
12566 | var scale = this.helper.scale,
|
12567 | config = this.config,
|
12568 | _config3 = config,
|
12569 | innerTickSize = _config3.innerTickSize,
|
12570 | range = _config3.range,
|
12571 | tickPosition = scale(d) + (config.tickCentered ? 0 : config.tickOffset);
|
12572 | return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0;
|
12573 | }
|
12574 | |
12575 |
|
12576 |
|
12577 |
|
12578 |
|
12579 |
|
12580 | ;
|
12581 |
|
12582 | _proto.setTickLineTextPosition = function setTickLineTextPosition(lineUpdate, textUpdate) {
|
12583 | var tickPos = this.getTickXY(),
|
12584 | _this$config = this.config,
|
12585 | innerTickSize = _this$config.innerTickSize,
|
12586 | orient = _this$config.orient,
|
12587 | tickLength = _this$config.tickLength,
|
12588 | tickOffset = _this$config.tickOffset,
|
12589 | rotate = this.params.tickTextRotate,
|
12590 | textAnchorForText = function (r) {
|
12591 | var value = ["start", "end"];
|
12592 | orient === "top" && value.reverse();
|
12593 | return !r ? "middle" : value[r > 0 ? 0 : 1];
|
12594 | },
|
12595 | textTransform = function (r) {
|
12596 | return r ? "rotate(" + r + ")" : null;
|
12597 | },
|
12598 | yForText = function (r) {
|
12599 | var r2 = r / (orient === "bottom" ? 15 : 23);
|
12600 | return r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
|
12601 | };
|
12602 |
|
12603 | switch (orient) {
|
12604 | case "bottom":
|
12605 | lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", this.getTickSize.bind(this));
|
12606 | textUpdate.attr("x", 0).attr("y", yForText(rotate)).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
|
12607 | break;
|
12608 |
|
12609 | case "top":
|
12610 | lineUpdate.attr("x2", 0).attr("y2", -innerTickSize);
|
12611 | textUpdate.attr("x", 0).attr("y", -yForText(rotate) * 2).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
|
12612 | break;
|
12613 |
|
12614 | case "left":
|
12615 | lineUpdate.attr("x2", -innerTickSize).attr("y1", tickPos.y).attr("y2", tickPos.y);
|
12616 | textUpdate.attr("x", -tickLength).attr("y", tickOffset).style("text-anchor", "end");
|
12617 | break;
|
12618 |
|
12619 | case "right":
|
12620 | lineUpdate.attr("x2", innerTickSize).attr("y2", 0);
|
12621 | textUpdate.attr("x", tickLength).attr("y", 0).style("text-anchor", "start");
|
12622 | }
|
12623 | }
|
12624 | ;
|
12625 |
|
12626 | _proto.splitTickText = function splitTickText(d, scale, ticks, isLeftRight, charWidth) {
|
12627 | var params = this.params,
|
12628 | tickText = this.helper.textFormatted(d),
|
12629 | splitted = isString(tickText) && tickText.indexOf("\n") > -1 ? tickText.split("\n") : [];
|
12630 |
|
12631 | if (splitted.length) {
|
12632 | return splitted;
|
12633 | }
|
12634 |
|
12635 | if (isArray(tickText)) {
|
12636 | return tickText;
|
12637 | }
|
12638 |
|
12639 | var tickWidth = params.tickWidth;
|
12640 |
|
12641 | if (!tickWidth || tickWidth <= 0) {
|
12642 | tickWidth = isLeftRight ? 95 : params.isCategory ? Math.ceil(scale(ticks[1]) - scale(ticks[0])) - 12 : 110;
|
12643 | }
|
12644 |
|
12645 |
|
12646 |
|
12647 | function split(splitted, text) {
|
12648 | var subtext, spaceIndex, textWidth;
|
12649 |
|
12650 | for (var i = 1; i < text.length; i++) {
|
12651 | if (text.charAt(i) === " ") {
|
12652 | spaceIndex = i;
|
12653 | }
|
12654 |
|
12655 | subtext = text.substr(0, i + 1);
|
12656 | textWidth = charWidth * subtext.length;
|
12657 |
|
12658 | if (tickWidth < textWidth) {
|
12659 | return split(splitted.concat(text.substr(0, spaceIndex || i)), text.slice(spaceIndex ? spaceIndex + 1 : i));
|
12660 | }
|
12661 | }
|
12662 |
|
12663 | return splitted.concat(text);
|
12664 | }
|
12665 |
|
12666 | return split(splitted, tickText + "");
|
12667 | };
|
12668 |
|
12669 | _proto.scale = function scale(x) {
|
12670 | if (!arguments.length) {
|
12671 | return this.helper.scale;
|
12672 | }
|
12673 |
|
12674 | this.helper.scale = x;
|
12675 | return this;
|
12676 | };
|
12677 |
|
12678 | _proto.orient = function orient(x) {
|
12679 | if (!arguments.length) {
|
12680 | return this.config.orient;
|
12681 | }
|
12682 |
|
12683 | this.config.orient = x in {
|
12684 | top: 1,
|
12685 | right: 1,
|
12686 | bottom: 1,
|
12687 | left: 1
|
12688 | } ? x + "" : "bottom";
|
12689 | return this;
|
12690 | };
|
12691 |
|
12692 | _proto.tickFormat = function tickFormat(format) {
|
12693 | var config = this.config;
|
12694 |
|
12695 | if (!arguments.length) {
|
12696 | return config.tickFormat;
|
12697 | }
|
12698 |
|
12699 | config.tickFormat = format;
|
12700 | return this;
|
12701 | };
|
12702 |
|
12703 | _proto.tickCentered = function tickCentered(isCentered) {
|
12704 | var config = this.config;
|
12705 |
|
12706 | if (!arguments.length) {
|
12707 | return config.tickCentered;
|
12708 | }
|
12709 |
|
12710 | config.tickCentered = isCentered;
|
12711 | return this;
|
12712 | }
|
12713 | |
12714 |
|
12715 |
|
12716 |
|
12717 |
|
12718 |
|
12719 | ;
|
12720 |
|
12721 | _proto.tickOffset = function tickOffset() {
|
12722 | return this.config.tickOffset;
|
12723 | }
|
12724 | |
12725 |
|
12726 |
|
12727 |
|
12728 |
|
12729 |
|
12730 | ;
|
12731 |
|
12732 | _proto.tickInterval = function tickInterval(size) {
|
12733 | var _this = this,
|
12734 | _this$config2 = this.config,
|
12735 | outerTickSize = _this$config2.outerTickSize,
|
12736 | tickOffset = _this$config2.tickOffset,
|
12737 | tickValues = _this$config2.tickValues,
|
12738 | interval;
|
12739 |
|
12740 | if (this.params.isCategory) {
|
12741 | interval = tickOffset * 2;
|
12742 | } else {
|
12743 | var length = this.g.select("path.domain").node().getTotalLength() - outerTickSize * 2;
|
12744 | interval = length / (size || this.g.selectAll("line").size());
|
12745 |
|
12746 | var intervalByValue = tickValues ? tickValues.map(function (v, i, arr) {
|
12747 | var next = i + 1;
|
12748 | return next < arr.length ? _this.helper.scale(arr[next]) - _this.helper.scale(v) : null;
|
12749 | }).filter(Boolean) : [];
|
12750 | interval = Math.min.apply(Math, intervalByValue.concat([interval]));
|
12751 | }
|
12752 |
|
12753 | return interval === Infinity ? 0 : interval;
|
12754 | };
|
12755 |
|
12756 | _proto.ticks = function ticks() {
|
12757 | for (var config = this.config, _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
12758 | args[_key] = arguments[_key];
|
12759 | }
|
12760 |
|
12761 | if (!args.length) {
|
12762 | return config.tickArguments;
|
12763 | }
|
12764 |
|
12765 | config.tickArguments = toArray(args);
|
12766 | return this;
|
12767 | };
|
12768 |
|
12769 | _proto.tickCulling = function tickCulling(culling) {
|
12770 | var config = this.config;
|
12771 |
|
12772 | if (!arguments.length) {
|
12773 | return config.tickCulling;
|
12774 | }
|
12775 |
|
12776 | config.tickCulling = culling;
|
12777 | return this;
|
12778 | };
|
12779 |
|
12780 | _proto.tickValues = function tickValues(x) {
|
12781 | var _this2 = this,
|
12782 | config = this.config;
|
12783 |
|
12784 | if (isFunction(x)) {
|
12785 | config.tickValues = function () {
|
12786 | return x(_this2.helper.scale.domain());
|
12787 | };
|
12788 | } else {
|
12789 | if (!arguments.length) {
|
12790 | return config.tickValues;
|
12791 | }
|
12792 |
|
12793 | config.tickValues = x;
|
12794 | }
|
12795 |
|
12796 | return this;
|
12797 | };
|
12798 |
|
12799 | _proto.setTransition = function setTransition(t) {
|
12800 | this.config.transition = t;
|
12801 | return this;
|
12802 | };
|
12803 |
|
12804 | return AxisRenderer;
|
12805 | }();
|
12806 |
|
12807 |
|
12808 | ;
|
12809 |
|
12810 |
|
12811 |
|
12812 |
|
12813 |
|
12814 |
|
12815 |
|
12816 |
|
12817 |
|
12818 | var Axis = ({
|
12819 | getAxisInstance: function getAxisInstance() {
|
12820 | return this.axis || new Axis_Axis(this);
|
12821 | }
|
12822 | });
|
12823 |
|
12824 | var Axis_Axis = function () {
|
12825 | function Axis(owner) {
|
12826 | this.owner = void 0;
|
12827 | this.x = void 0;
|
12828 | this.subX = void 0;
|
12829 | this.y = void 0;
|
12830 | this.y2 = void 0;
|
12831 | this.axesList = {};
|
12832 | this.tick = {
|
12833 | x: null,
|
12834 | y: null,
|
12835 | y2: null
|
12836 | };
|
12837 | this.xs = [];
|
12838 | this.orient = {
|
12839 | x: "bottom",
|
12840 | y: "left",
|
12841 | y2: "right",
|
12842 | subX: "bottom"
|
12843 | };
|
12844 | this.owner = owner;
|
12845 | this.setOrient();
|
12846 | }
|
12847 |
|
12848 | var _proto = Axis.prototype;
|
12849 |
|
12850 | _proto.getAxisClassName = function getAxisClassName(id) {
|
12851 | return config_classes.axis + " " + config_classes["axis" + capitalize(id)];
|
12852 | };
|
12853 |
|
12854 | _proto.isHorizontal = function isHorizontal($$, forHorizontal) {
|
12855 | var isRotated = $$.config.axis_rotated;
|
12856 | return forHorizontal ? isRotated : !isRotated;
|
12857 | };
|
12858 |
|
12859 | _proto.isCategorized = function isCategorized() {
|
12860 | var _this$owner = this.owner,
|
12861 | config = _this$owner.config,
|
12862 | state = _this$owner.state;
|
12863 | return config.axis_x_type.indexOf("category") >= 0 || state.hasRadar;
|
12864 | };
|
12865 |
|
12866 | _proto.isCustomX = function isCustomX() {
|
12867 | var config = this.owner.config;
|
12868 | return !this.isTimeSeries() && (config.data_x || notEmpty(config.data_xs));
|
12869 | };
|
12870 |
|
12871 | _proto.isTimeSeries = function isTimeSeries(id) {
|
12872 | if (id === void 0) {
|
12873 | id = "x";
|
12874 | }
|
12875 |
|
12876 | return this.owner.config["axis_" + id + "_type"] === "timeseries";
|
12877 | };
|
12878 |
|
12879 | _proto.isLog = function isLog(id) {
|
12880 | if (id === void 0) {
|
12881 | id = "x";
|
12882 | }
|
12883 |
|
12884 | return this.owner.config["axis_" + id + "_type"] === "log";
|
12885 | };
|
12886 |
|
12887 | _proto.isTimeSeriesY = function isTimeSeriesY() {
|
12888 | return this.isTimeSeries("y");
|
12889 | };
|
12890 |
|
12891 | _proto.getAxisType = function getAxisType(id) {
|
12892 | if (id === void 0) {
|
12893 | id = "x";
|
12894 | }
|
12895 |
|
12896 | var type = "linear";
|
12897 |
|
12898 | if (this.isTimeSeries(id)) {
|
12899 | type = this.owner.config.axis_x_localtime ? "time" : "utc";
|
12900 | } else if (this.isLog(id)) {
|
12901 | type = "log";
|
12902 | }
|
12903 |
|
12904 | return type;
|
12905 | };
|
12906 |
|
12907 | _proto.init = function init() {
|
12908 | var _this = this,
|
12909 | $$ = this.owner,
|
12910 | config = $$.config,
|
12911 | _$$$$el = $$.$el,
|
12912 | main = _$$$$el.main,
|
12913 | axis = _$$$$el.axis,
|
12914 | clip = $$.state.clip,
|
12915 | isRotated = config.axis_rotated,
|
12916 | target = ["x", "y"];
|
12917 |
|
12918 | config.axis_y2_show && target.push("y2");
|
12919 | target.forEach(function (v) {
|
12920 | var classAxis = _this.getAxisClassName(v),
|
12921 | classLabel = config_classes["axis" + v.toUpperCase() + "Label"];
|
12922 |
|
12923 | axis[v] = main.append("g").attr("class", classAxis).attr("clip-path", function () {
|
12924 | var res = null;
|
12925 |
|
12926 | if (v === "x") {
|
12927 | res = clip.pathXAxis;
|
12928 | } else if (v === "y") {
|
12929 |
|
12930 | res = clip.pathYAxis;
|
12931 | }
|
12932 |
|
12933 | return res;
|
12934 | }).attr("transform", $$.getTranslate(v)).style("visibility", config["axis_" + v + "_show"] ? null : "hidden");
|
12935 | axis[v].append("text").attr("class", classLabel).attr("transform", ["rotate(-90)", null][v === "x" ? +!isRotated : +isRotated]).style("text-anchor", function () {
|
12936 | return _this.textAnchorForAxisLabel(v);
|
12937 | });
|
12938 |
|
12939 | _this.generateAxes(v);
|
12940 | });
|
12941 | }
|
12942 | |
12943 |
|
12944 |
|
12945 |
|
12946 | ;
|
12947 |
|
12948 | _proto.setOrient = function setOrient() {
|
12949 | var $$ = this.owner,
|
12950 | _$$$config = $$.config,
|
12951 | isRotated = _$$$config.axis_rotated,
|
12952 | yInner = _$$$config.axis_y_inner,
|
12953 | y2Inner = _$$$config.axis_y2_inner;
|
12954 | this.orient = {
|
12955 | x: isRotated ? "left" : "bottom",
|
12956 | y: isRotated ? yInner ? "top" : "bottom" : yInner ? "right" : "left",
|
12957 | y2: isRotated ? y2Inner ? "bottom" : "top" : y2Inner ? "left" : "right",
|
12958 | subX: isRotated ? "left" : "bottom"
|
12959 | };
|
12960 | }
|
12961 | |
12962 |
|
12963 |
|
12964 |
|
12965 |
|
12966 |
|
12967 | ;
|
12968 |
|
12969 | _proto.generateAxes = function generateAxes(id) {
|
12970 | var $$ = this.owner,
|
12971 | config = $$.config,
|
12972 | axes = [],
|
12973 | axesConfig = config["axis_" + id + "_axes"],
|
12974 | isRotated = config.axis_rotated,
|
12975 | d3Axis;
|
12976 |
|
12977 | if (id === "x") {
|
12978 | 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;
|
12979 | } else if (id === "y") {
|
12980 | 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;
|
12981 | } else if (id === "y2") {
|
12982 | 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;
|
12983 | }
|
12984 |
|
12985 | if (axesConfig.length) {
|
12986 | axesConfig.forEach(function (v) {
|
12987 | var tick = v.tick || {},
|
12988 | scale = $$.scale[id].copy();
|
12989 | v.domain && scale.domain(v.domain);
|
12990 | axes.push(d3Axis(scale).ticks(tick.count).tickFormat(isFunction(tick.format) ? tick.format.bind($$.api) : function (x) {
|
12991 | return x;
|
12992 | }).tickValues(tick.values).tickSizeOuter(tick.outer === !1 ? 0 : 6));
|
12993 | });
|
12994 | }
|
12995 |
|
12996 | this.axesList[id] = axes;
|
12997 | }
|
12998 | |
12999 |
|
13000 |
|
13001 |
|
13002 | ;
|
13003 |
|
13004 | _proto.updateAxes = function updateAxes() {
|
13005 | var _this2 = this,
|
13006 | $$ = this.owner,
|
13007 | config = $$.config,
|
13008 | main = $$.$el.main;
|
13009 |
|
13010 | Object.keys(this.axesList).forEach(function (id) {
|
13011 | var axesConfig = config["axis_" + id + "_axes"],
|
13012 | scale = $$.scale[id].copy(),
|
13013 | range = scale.range();
|
13014 |
|
13015 | _this2.axesList[id].forEach(function (v, i) {
|
13016 | var axisRange = v.scale().range();
|
13017 |
|
13018 |
|
13019 | if (!range.every(function (v, i) {
|
13020 | return v === axisRange[i];
|
13021 | })) {
|
13022 | v.scale().range(range);
|
13023 | }
|
13024 |
|
13025 | var className = _this2.getAxisClassName(id) + "-" + (i + 1),
|
13026 | g = main.select("." + className.replace(/\s/, "."));
|
13027 |
|
13028 | if (g.empty()) {
|
13029 | g = main.append("g").attr("class", className).style("visibility", config["axis_" + id + "_show"] ? null : "hidden").call(v);
|
13030 | } else {
|
13031 | axesConfig[i].domain && scale.domain(axesConfig[i].domain);
|
13032 | $$.$T(g).call(v.scale(scale));
|
13033 | }
|
13034 |
|
13035 | g.attr("transform", $$.getTranslate(id, i + 1));
|
13036 | });
|
13037 | });
|
13038 | }
|
13039 | |
13040 |
|
13041 |
|
13042 |
|
13043 |
|
13044 |
|
13045 |
|
13046 |
|
13047 |
|
13048 | ;
|
13049 |
|
13050 | _proto.setAxis = function setAxis(id, scale, outerTick, noTransition) {
|
13051 | var $$ = this.owner;
|
13052 |
|
13053 | if (id !== "subX") {
|
13054 | this.tick[id] = this.getTickValues(id);
|
13055 | }
|
13056 |
|
13057 |
|
13058 | this[id] = this.getAxis(id, scale, outerTick,
|
13059 |
|
13060 | id === "x" && ($$.scale.zoom || $$.config.subchart_show || $$.state.resizing) ? !0 : noTransition);
|
13061 | }
|
13062 | ;
|
13063 |
|
13064 | _proto.getAxis = function getAxis(id, scale, outerTick, noTransition, noTickTextRotate) {
|
13065 | var $$ = this.owner,
|
13066 | config = $$.config,
|
13067 | isX = /^(x|subX)$/.test(id),
|
13068 | type = isX ? "x" : id,
|
13069 | isCategory = isX && this.isCategorized(),
|
13070 | orient = this.orient[id],
|
13071 | tickTextRotate = noTickTextRotate ? 0 : $$.getAxisTickRotate(type),
|
13072 | tickFormat;
|
13073 |
|
13074 | if (isX) {
|
13075 | tickFormat = id === "subX" ? $$.format.subXAxisTick : $$.format.xAxisTick;
|
13076 | } else {
|
13077 | var fn = config["axis_" + id + "_tick_format"];
|
13078 |
|
13079 | if (isFunction(fn)) {
|
13080 | tickFormat = fn.bind($$.api);
|
13081 | }
|
13082 | }
|
13083 |
|
13084 | var tickValues = this.tick[type],
|
13085 | axisParams = mergeObj({
|
13086 | outerTick: outerTick,
|
13087 | noTransition: noTransition,
|
13088 | config: config,
|
13089 | id: id,
|
13090 | tickTextRotate: tickTextRotate,
|
13091 | owner: $$
|
13092 | }, isX && {
|
13093 | isCategory: isCategory,
|
13094 | tickMultiline: config.axis_x_tick_multiline,
|
13095 | tickWidth: config.axis_x_tick_width,
|
13096 | tickTitle: isCategory && config.axis_x_tick_tooltip && $$.api.categories(),
|
13097 | orgXScale: $$.scale.x
|
13098 | });
|
13099 |
|
13100 | if (!isX) {
|
13101 | axisParams.tickStepSize = config["axis_" + type + "_tick_stepSize"];
|
13102 | }
|
13103 |
|
13104 | var axis = new AxisRenderer(axisParams).scale(isX && $$.scale.zoom || scale).orient(orient);
|
13105 |
|
13106 | if (isX && this.isTimeSeries() && tickValues && !isFunction(tickValues)) {
|
13107 | var _fn = parseDate.bind($$);
|
13108 |
|
13109 | tickValues = tickValues.map(function (v) {
|
13110 | return _fn(v);
|
13111 | });
|
13112 | } else if (!isX && this.isTimeSeriesY()) {
|
13113 |
|
13114 | axis.ticks(config.axis_y_tick_time_value);
|
13115 | tickValues = null;
|
13116 | }
|
13117 |
|
13118 | tickValues && axis.tickValues(tickValues);
|
13119 |
|
13120 | axis.tickFormat(tickFormat || !isX && $$.isStackNormalized() && function (x) {
|
13121 | return x + "%";
|
13122 | });
|
13123 |
|
13124 | if (isCategory) {
|
13125 | axis.tickCentered(config.axis_x_tick_centered);
|
13126 |
|
13127 | if (isEmpty(config.axis_x_tick_culling)) {
|
13128 | config.axis_x_tick_culling = !1;
|
13129 | }
|
13130 | }
|
13131 |
|
13132 | var tickCount = config["axis_" + type + "_tick_count"];
|
13133 | tickCount && axis.ticks(tickCount);
|
13134 | return axis;
|
13135 | };
|
13136 |
|
13137 | _proto.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) {
|
13138 | var $$ = this.owner,
|
13139 | config = $$.config,
|
13140 | fit = config.axis_x_tick_fit,
|
13141 | count = config.axis_x_tick_count,
|
13142 | values;
|
13143 |
|
13144 | if (fit || count && fit) {
|
13145 | values = $$.mapTargetsToUniqueXs(targets);
|
13146 |
|
13147 | if (this.isCategorized() && count > values.length) {
|
13148 | count = values.length;
|
13149 | }
|
13150 |
|
13151 | values = this.generateTickValues(values, count, this.isTimeSeries());
|
13152 | }
|
13153 |
|
13154 | if (axis) {
|
13155 | axis.tickValues(values);
|
13156 | } else if (this.x) {
|
13157 | var _this$subX;
|
13158 |
|
13159 | this.x.tickValues(values);
|
13160 | (_this$subX = this.subX) == null ? void 0 : _this$subX.tickValues(values);
|
13161 | }
|
13162 |
|
13163 | return values;
|
13164 | };
|
13165 |
|
13166 | _proto.getId = function getId(id) {
|
13167 | var _this$owner2 = this.owner,
|
13168 | config = _this$owner2.config,
|
13169 | scale = _this$owner2.scale,
|
13170 | axis = config.data_axes[id];
|
13171 |
|
13172 |
|
13173 | if (!axis || !scale[axis]) {
|
13174 | axis = "y";
|
13175 | }
|
13176 |
|
13177 | return axis;
|
13178 | };
|
13179 |
|
13180 | _proto.getXAxisTickFormat = function getXAxisTickFormat(forSubchart) {
|
13181 | var $$ = this.owner,
|
13182 | config = $$.config,
|
13183 | format = $$.format,
|
13184 | tickFormat = forSubchart ? config.subchart_axis_x_tick_format || config.axis_x_tick_format : config.axis_x_tick_format,
|
13185 | isTimeSeries = this.isTimeSeries(),
|
13186 | isCategorized = this.isCategorized(),
|
13187 | currFormat;
|
13188 |
|
13189 | if (tickFormat) {
|
13190 | if (isFunction(tickFormat)) {
|
13191 | currFormat = tickFormat.bind($$.api);
|
13192 | } else if (isTimeSeries) {
|
13193 | currFormat = function (date) {
|
13194 | return date ? format.axisTime(tickFormat)(date) : "";
|
13195 | };
|
13196 | }
|
13197 | } else {
|
13198 | currFormat = isTimeSeries ? format.defaultAxisTime : isCategorized ? $$.categoryName : function (v) {
|
13199 | return v < 0 ? v.toFixed(0) : v;
|
13200 | };
|
13201 | }
|
13202 |
|
13203 | return isFunction(currFormat) ? function (v) {
|
13204 | return currFormat.apply($$, isCategorized ? [v, $$.categoryName(v)] : [v]);
|
13205 | } : currFormat;
|
13206 | };
|
13207 |
|
13208 | _proto.getTickValues = function getTickValues(id) {
|
13209 | var $$ = this.owner,
|
13210 | tickValues = $$.config["axis_" + id + "_tick_values"],
|
13211 | axis = $$[id + "Axis"];
|
13212 | return (isFunction(tickValues) ? tickValues.call($$.api) : tickValues) || (axis ? axis.tickValues() : undefined);
|
13213 | };
|
13214 |
|
13215 | _proto.getLabelOptionByAxisId = function getLabelOptionByAxisId(id) {
|
13216 | return this.owner.config["axis_" + id + "_label"];
|
13217 | };
|
13218 |
|
13219 | _proto.getLabelText = function getLabelText(id) {
|
13220 | var option = this.getLabelOptionByAxisId(id);
|
13221 | return isString(option) ? option : option ? option.text : null;
|
13222 | };
|
13223 |
|
13224 | _proto.setLabelText = function setLabelText(id, text) {
|
13225 | var $$ = this.owner,
|
13226 | config = $$.config,
|
13227 | option = this.getLabelOptionByAxisId(id);
|
13228 |
|
13229 | if (isString(option)) {
|
13230 | config["axis_" + id + "_label"] = text;
|
13231 | } else if (option) {
|
13232 | option.text = text;
|
13233 | }
|
13234 | };
|
13235 |
|
13236 | _proto.getLabelPosition = function getLabelPosition(id, defaultPosition) {
|
13237 | var isRotated = this.owner.config.axis_rotated,
|
13238 | option = this.getLabelOptionByAxisId(id),
|
13239 | position = isObjectType(option) && option.position ? option.position : defaultPosition[+!isRotated],
|
13240 | has = function (v) {
|
13241 | return !!~position.indexOf(v);
|
13242 | };
|
13243 |
|
13244 | return {
|
13245 | isInner: has("inner"),
|
13246 | isOuter: has("outer"),
|
13247 | isLeft: has("left"),
|
13248 | isCenter: has("center"),
|
13249 | isRight: has("right"),
|
13250 | isTop: has("top"),
|
13251 | isMiddle: has("middle"),
|
13252 | isBottom: has("bottom")
|
13253 | };
|
13254 | };
|
13255 |
|
13256 | _proto.getAxisLabelPosition = function getAxisLabelPosition(id) {
|
13257 | return this.getLabelPosition(id, id === "x" ? ["inner-top", "inner-right"] : ["inner-right", "inner-top"]);
|
13258 | };
|
13259 |
|
13260 | _proto.getLabelPositionById = function getLabelPositionById(id) {
|
13261 | return this.getAxisLabelPosition(id);
|
13262 | };
|
13263 |
|
13264 | _proto.xForAxisLabel = function xForAxisLabel(id) {
|
13265 | var $$ = this.owner,
|
13266 | _$$$state = $$.state,
|
13267 | width = _$$$state.width,
|
13268 | height = _$$$state.height,
|
13269 | position = this.getAxisLabelPosition(id),
|
13270 | x = position.isMiddle ? -height / 2 : 0;
|
13271 |
|
13272 | if (this.isHorizontal($$, id !== "x")) {
|
13273 | x = position.isLeft ? 0 : position.isCenter ? width / 2 : width;
|
13274 | } else if (position.isBottom) {
|
13275 | x = -height;
|
13276 | }
|
13277 |
|
13278 | return x;
|
13279 | };
|
13280 |
|
13281 | _proto.dxForAxisLabel = function dxForAxisLabel(id) {
|
13282 | var $$ = this.owner,
|
13283 | position = this.getAxisLabelPosition(id),
|
13284 | dx = position.isBottom ? "0.5em" : "0";
|
13285 |
|
13286 | if (this.isHorizontal($$, id !== "x")) {
|
13287 | dx = position.isLeft ? "0.5em" : position.isRight ? "-0.5em" : "0";
|
13288 | } else if (position.isTop) {
|
13289 | dx = "-0.5em";
|
13290 | }
|
13291 |
|
13292 | return dx;
|
13293 | };
|
13294 |
|
13295 | _proto.textAnchorForAxisLabel = function textAnchorForAxisLabel(id) {
|
13296 | var $$ = this.owner,
|
13297 | position = this.getAxisLabelPosition(id),
|
13298 | anchor = position.isMiddle ? "middle" : "end";
|
13299 |
|
13300 | if (this.isHorizontal($$, id !== "x")) {
|
13301 | anchor = position.isLeft ? "start" : position.isCenter ? "middle" : "end";
|
13302 | } else if (position.isBottom) {
|
13303 | anchor = "start";
|
13304 | }
|
13305 |
|
13306 | return anchor;
|
13307 | };
|
13308 |
|
13309 | _proto.dyForAxisLabel = function dyForAxisLabel(id) {
|
13310 | var $$ = this.owner,
|
13311 | config = $$.config,
|
13312 | isRotated = config.axis_rotated,
|
13313 | isInner = this.getAxisLabelPosition(id).isInner,
|
13314 | tickRotate = config["axis_" + id + "_tick_rotate"] ? $$.getHorizontalAxisHeight(id) : 0,
|
13315 | maxTickWidth = this.getMaxTickWidth(id),
|
13316 | dy;
|
13317 |
|
13318 | if (id === "x") {
|
13319 | var xHeight = config.axis_x_height;
|
13320 |
|
13321 | if (isRotated) {
|
13322 | dy = isInner ? "1.2em" : -25 - maxTickWidth;
|
13323 | } else if (isInner) {
|
13324 | dy = "-0.5em";
|
13325 | } else if (xHeight) {
|
13326 | dy = xHeight - 10;
|
13327 | } else if (tickRotate) {
|
13328 | dy = tickRotate - 10;
|
13329 | } else {
|
13330 | dy = "3em";
|
13331 | }
|
13332 | } else {
|
13333 | dy = {
|
13334 | y: ["-0.5em", 10, "3em", "1.2em", 10],
|
13335 | y2: ["1.2em", -20, "-2.2em", "-0.5em", 15]
|
13336 | }[id];
|
13337 |
|
13338 | if (isRotated) {
|
13339 | if (isInner) {
|
13340 | dy = dy[0];
|
13341 | } else if (tickRotate) {
|
13342 | dy = tickRotate * (id === "y2" ? -1 : 1) - dy[1];
|
13343 | } else {
|
13344 | dy = dy[2];
|
13345 | }
|
13346 | } else {
|
13347 | dy = isInner ? dy[3] : (dy[4] + (config["axis_" + id + "_inner"] ? 0 : maxTickWidth + dy[4])) * (id === "y" ? -1 : 1);
|
13348 | }
|
13349 | }
|
13350 |
|
13351 | return dy;
|
13352 | };
|
13353 |
|
13354 | _proto.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) {
|
13355 | var $$ = this.owner,
|
13356 | config = $$.config,
|
13357 | current = $$.state.current,
|
13358 | _$$$$el2 = $$.$el,
|
13359 | svg = _$$$$el2.svg,
|
13360 | chart = _$$$$el2.chart,
|
13361 | currentTickMax = current.maxTickWidths[id],
|
13362 | maxWidth = 0;
|
13363 |
|
13364 | if (withoutRecompute || !config["axis_" + id + "_show"] || $$.filterTargetsToShow().length === 0) {
|
13365 | return currentTickMax.size;
|
13366 | }
|
13367 |
|
13368 | if (svg) {
|
13369 | var isYAxis = /^y2?$/.test(id),
|
13370 | targetsToShow = $$.filterTargetsToShow($$.data.targets),
|
13371 | scale = $$.scale[id].copy().domain($$["get" + (isYAxis ? "Y" : "X") + "Domain"](targetsToShow, id)),
|
13372 | domain = scale.domain(),
|
13373 | isDomainSame = domain[0] === domain[1] && domain.every(function (v) {
|
13374 | return v > 0;
|
13375 | }),
|
13376 | isCurrentMaxTickDomainSame = isArray(currentTickMax.domain) && currentTickMax.domain[0] === currentTickMax.domain[1] && currentTickMax.domain.every(function (v) {
|
13377 | return v > 0;
|
13378 | });
|
13379 |
|
13380 |
|
13381 | if (isDomainSame || isCurrentMaxTickDomainSame) {
|
13382 | return currentTickMax.size;
|
13383 | } else {
|
13384 | currentTickMax.domain = domain;
|
13385 | }
|
13386 |
|
13387 |
|
13388 | if (!isYAxis) {
|
13389 | currentTickMax.ticks.splice(0);
|
13390 | }
|
13391 |
|
13392 | var axis = this.getAxis(id, scale, !1, !1, !0),
|
13393 | tickCount = config["axis_" + id + "_tick_count"],
|
13394 | tickValues = config["axis_" + id + "_tick_values"];
|
13395 |
|
13396 |
|
13397 |
|
13398 |
|
13399 |
|
13400 | if (!tickValues && tickCount) {
|
13401 | axis.tickValues(this.generateTickValues(domain, tickCount, isYAxis ? this.isTimeSeriesY() : this.isTimeSeries()));
|
13402 | }
|
13403 |
|
13404 | isYAxis || this.updateXAxisTickValues(targetsToShow, axis);
|
13405 | var dummy = chart.append("svg").style("visibility", "hidden").style("position", "fixed").style("top", "0").style("left", "0");
|
13406 | axis.create(dummy);
|
13407 | dummy.selectAll("text").each(function (d, i) {
|
13408 | var currentTextWidth = this.getBoundingClientRect().width;
|
13409 | maxWidth = Math.max(maxWidth, currentTextWidth);
|
13410 |
|
13411 | if (!isYAxis) {
|
13412 | currentTickMax.ticks[i] = currentTextWidth;
|
13413 | }
|
13414 | });
|
13415 | dummy.remove();
|
13416 | }
|
13417 |
|
13418 | if (maxWidth > 0) {
|
13419 | currentTickMax.size = maxWidth;
|
13420 | }
|
13421 |
|
13422 | return currentTickMax.size;
|
13423 | };
|
13424 |
|
13425 | _proto.getXAxisTickTextY2Overflow = function getXAxisTickTextY2Overflow(defaultPadding) {
|
13426 | var $$ = this.owner,
|
13427 | axis = $$.axis,
|
13428 | config = $$.config,
|
13429 | state = $$.state,
|
13430 | xAxisTickRotate = $$.getAxisTickRotate("x");
|
13431 |
|
13432 | if ((axis.isCategorized() || axis.isTimeSeries()) && config.axis_x_tick_fit && !config.axis_x_tick_culling && !config.axis_x_tick_multiline && xAxisTickRotate > 0 && xAxisTickRotate < 90) {
|
13433 | var widthWithoutCurrentPaddingLeft = state.current.width - $$.getCurrentPaddingLeft(),
|
13434 | maxOverflow = this.getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft - defaultPadding),
|
13435 | xAxisTickTextY2Overflow = Math.max(0, maxOverflow) + defaultPadding;
|
13436 |
|
13437 | return Math.min(xAxisTickTextY2Overflow, widthWithoutCurrentPaddingLeft / 2);
|
13438 | }
|
13439 |
|
13440 | return 0;
|
13441 | };
|
13442 |
|
13443 | _proto.getXAxisTickMaxOverflow = function getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft) {
|
13444 | var $$ = this.owner,
|
13445 | axis = $$.axis,
|
13446 | config = $$.config,
|
13447 | state = $$.state,
|
13448 | isTimeSeries = axis.isTimeSeries(),
|
13449 | tickTextWidths = state.current.maxTickWidths.x.ticks,
|
13450 | tickCount = tickTextWidths.length,
|
13451 | _state$axis$x$padding = state.axis.x.padding,
|
13452 | left = _state$axis$x$padding.left,
|
13453 | right = _state$axis$x$padding.right,
|
13454 | maxOverflow = 0,
|
13455 | remaining = tickCount - (isTimeSeries && config.axis_x_tick_fit ? .5 : 0);
|
13456 |
|
13457 | for (var i = 0; i < tickCount; i++) {
|
13458 | var tickIndex = i + 1,
|
13459 | rotatedTickTextWidth = Math.cos(Math.PI * xAxisTickRotate / 180) * tickTextWidths[i],
|
13460 | ticksBeforeTickText = tickIndex - (isTimeSeries ? 1 : .5) + left;
|
13461 |
|
13462 |
|
13463 | if (ticksBeforeTickText <= 0) {
|
13464 | continue;
|
13465 | }
|
13466 |
|
13467 | var tickLength = (widthWithoutCurrentPaddingLeft - rotatedTickTextWidth) / ticksBeforeTickText;
|
13468 | maxOverflow = Math.max(maxOverflow, rotatedTickTextWidth - tickLength / 2 - ((remaining - tickIndex) * tickLength + right * tickLength));
|
13469 | }
|
13470 |
|
13471 | var filteredTargets = $$.filterTargetsToShow($$.data.targets),
|
13472 | tickOffset = 0;
|
13473 |
|
13474 | if (!isTimeSeries && config.axis_x_tick_count <= filteredTargets.length && filteredTargets[0].values.length) {
|
13475 | var scale = getScale($$.axis.getAxisType("x"), 0, widthWithoutCurrentPaddingLeft - maxOverflow).domain([left * -1, $$.getXDomainMax($$.data.targets) + 1 + right]);
|
13476 | tickOffset = Math.ceil((scale(1) - scale(0)) / 2);
|
13477 | }
|
13478 |
|
13479 | return maxOverflow + tickOffset;
|
13480 | };
|
13481 |
|
13482 | _proto.updateLabels = function updateLabels(withTransition) {
|
13483 | var _this3 = this,
|
13484 | $$ = this.owner,
|
13485 | main = $$.$el.main,
|
13486 | $T = $$.$T,
|
13487 | labels = {
|
13488 | x: main.select("." + config_classes.axisX + " ." + config_classes.axisXLabel),
|
13489 | y: main.select("." + config_classes.axisY + " ." + config_classes.axisYLabel),
|
13490 | y2: main.select("." + config_classes.axisY2 + " ." + config_classes.axisY2Label)
|
13491 | };
|
13492 |
|
13493 | Object.keys(labels).filter(function (id) {
|
13494 | return !labels[id].empty();
|
13495 | }).forEach(function (v) {
|
13496 | var node = labels[v];
|
13497 |
|
13498 | $T(node, withTransition).attr("x", function () {
|
13499 | return _this3.xForAxisLabel(v);
|
13500 | }).attr("dx", function () {
|
13501 | return _this3.dxForAxisLabel(v);
|
13502 | }).attr("dy", function () {
|
13503 | return _this3.dyForAxisLabel(v);
|
13504 | }).text(function () {
|
13505 | return _this3.getLabelText(v);
|
13506 | });
|
13507 | });
|
13508 | }
|
13509 | |
13510 |
|
13511 |
|
13512 |
|
13513 |
|
13514 |
|
13515 |
|
13516 |
|
13517 |
|
13518 | ;
|
13519 |
|
13520 | _proto.getPadding = function getPadding(padding, key, defaultValue, domainLength) {
|
13521 | var p = isNumber(padding) ? padding : padding[key];
|
13522 |
|
13523 | if (!isValue(p)) {
|
13524 | return defaultValue;
|
13525 | }
|
13526 |
|
13527 | return this.owner.convertPixelToScale(/(bottom|top)/.test(key) ? "y" : "x", p, domainLength);
|
13528 | };
|
13529 |
|
13530 | _proto.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) {
|
13531 | var tickValues = values;
|
13532 |
|
13533 | if (tickCount) {
|
13534 | var targetCount = isFunction(tickCount) ? tickCount() : tickCount;
|
13535 |
|
13536 | if (targetCount === 1) {
|
13537 | tickValues = [values[0]];
|
13538 | } else if (targetCount === 2) {
|
13539 | tickValues = [values[0], values[values.length - 1]];
|
13540 | } else if (targetCount > 2) {
|
13541 | var isCategorized = this.isCategorized(),
|
13542 | count = targetCount - 2,
|
13543 | start = values[0],
|
13544 | end = values[values.length - 1],
|
13545 | tickValue;
|
13546 |
|
13547 | tickValues = [start];
|
13548 |
|
13549 | for (var i = 0; i < count; i++) {
|
13550 | tickValue = +start + (end - start) / (count + 1) * (i + 1);
|
13551 | tickValues.push(forTimeSeries ? new Date(tickValue) : isCategorized ? Math.round(tickValue) : tickValue);
|
13552 | }
|
13553 |
|
13554 | tickValues.push(end);
|
13555 | }
|
13556 | }
|
13557 |
|
13558 | if (!forTimeSeries) {
|
13559 | tickValues = tickValues.sort(function (a, b) {
|
13560 | return a - b;
|
13561 | });
|
13562 | }
|
13563 |
|
13564 | return tickValues;
|
13565 | };
|
13566 |
|
13567 | _proto.generateTransitions = function generateTransitions(withTransition) {
|
13568 | var $$ = this.owner,
|
13569 | axis = $$.$el.axis,
|
13570 | $T = $$.$T,
|
13571 | _map = ["x", "y", "y2", "subX"].map(function (v) {
|
13572 | return $T(axis[v], withTransition);
|
13573 | }),
|
13574 | axisX = _map[0],
|
13575 | axisY = _map[1],
|
13576 | axisY2 = _map[2],
|
13577 | axisSubX = _map[3];
|
13578 |
|
13579 | return {
|
13580 | axisX: axisX,
|
13581 | axisY: axisY,
|
13582 | axisY2: axisY2,
|
13583 | axisSubX: axisSubX
|
13584 | };
|
13585 | };
|
13586 |
|
13587 | _proto.redraw = function redraw(transitions, isHidden, isInit) {
|
13588 | var _this4 = this,
|
13589 | $$ = this.owner,
|
13590 | config = $$.config,
|
13591 | $el = $$.$el,
|
13592 | opacity = isHidden ? "0" : null;
|
13593 |
|
13594 | ["x", "y", "y2", "subX"].forEach(function (id) {
|
13595 | var axis = _this4[id],
|
13596 | $axis = $el.axis[id];
|
13597 |
|
13598 | if (axis && $axis) {
|
13599 | if (!isInit && !config.transition_duration) {
|
13600 | axis.config.withoutTransition = !0;
|
13601 | }
|
13602 |
|
13603 | $axis.style("opacity", opacity);
|
13604 | axis.create(transitions["axis" + capitalize(id)]);
|
13605 | }
|
13606 | });
|
13607 | this.updateAxes();
|
13608 | }
|
13609 | |
13610 |
|
13611 |
|
13612 |
|
13613 |
|
13614 |
|
13615 |
|
13616 |
|
13617 |
|
13618 | ;
|
13619 |
|
13620 | _proto.redrawAxis = function redrawAxis(targetsToShow, wth, transitions, flow, isInit) {
|
13621 | var _this5 = this,
|
13622 | $$ = this.owner,
|
13623 | config = $$.config,
|
13624 | scale = $$.scale,
|
13625 | $el = $$.$el,
|
13626 | hasZoom = !!scale.zoom,
|
13627 | xDomainForZoom;
|
13628 |
|
13629 | if (!hasZoom && this.isCategorized() && targetsToShow.length === 0) {
|
13630 | scale.x.domain([0, $el.axis.x.selectAll(".tick").size()]);
|
13631 | }
|
13632 |
|
13633 | if (scale.x && targetsToShow.length) {
|
13634 | hasZoom || $$.updateXDomain(targetsToShow, wth.UpdateXDomain, wth.UpdateOrgXDomain, wth.TrimXDomain);
|
13635 |
|
13636 | if (!config.axis_x_tick_values) {
|
13637 | this.updateXAxisTickValues(targetsToShow);
|
13638 | }
|
13639 | } else if (this.x) {
|
13640 | var _this$subX2;
|
13641 |
|
13642 | this.x.tickValues([]);
|
13643 | (_this$subX2 = this.subX) == null ? void 0 : _this$subX2.tickValues([]);
|
13644 | }
|
13645 |
|
13646 | if (config.zoom_rescale && !flow) {
|
13647 | xDomainForZoom = scale.x.orgDomain();
|
13648 | }
|
13649 |
|
13650 | ["y", "y2"].forEach(function (key) {
|
13651 | var axisScale = scale[key];
|
13652 |
|
13653 | if (axisScale) {
|
13654 | var tickValues = config["axis_" + key + "_tick_values"],
|
13655 | tickCount = config["axis_" + key + "_tick_count"];
|
13656 | axisScale.domain($$.getYDomain(targetsToShow, key, xDomainForZoom));
|
13657 |
|
13658 | if (!tickValues && tickCount) {
|
13659 | var _axis = $$.axis[key],
|
13660 | domain = axisScale.domain();
|
13661 |
|
13662 | _axis.tickValues(_this5.generateTickValues(domain, domain.every(function (v) {
|
13663 | return v === 0;
|
13664 | }) ? 1 : tickCount, _this5.isTimeSeriesY()));
|
13665 | }
|
13666 | }
|
13667 | });
|
13668 |
|
13669 | this.redraw(transitions, $$.hasArcType(), isInit);
|
13670 |
|
13671 | this.updateLabels(wth.Transition);
|
13672 |
|
13673 | if ((wth.UpdateXDomain || wth.UpdateXAxis || wth.Y) && targetsToShow.length) {
|
13674 | this.setCulling();
|
13675 | }
|
13676 |
|
13677 |
|
13678 | if (wth.Y) {
|
13679 | var _scale$subY, _scale$subY2;
|
13680 |
|
13681 | (_scale$subY = scale.subY) == null ? void 0 : _scale$subY.domain($$.getYDomain(targetsToShow, "y"));
|
13682 | (_scale$subY2 = scale.subY2) == null ? void 0 : _scale$subY2.domain($$.getYDomain(targetsToShow, "y2"));
|
13683 | }
|
13684 | }
|
13685 | |
13686 |
|
13687 |
|
13688 |
|
13689 | ;
|
13690 |
|
13691 | _proto.setCulling = function setCulling() {
|
13692 | var $$ = this.owner,
|
13693 | config = $$.config,
|
13694 | _$$$state2 = $$.state,
|
13695 | clip = _$$$state2.clip,
|
13696 | current = _$$$state2.current,
|
13697 | $el = $$.$el;
|
13698 | ["subX", "x", "y", "y2"].forEach(function (type) {
|
13699 | var axis = $el.axis[type],
|
13700 | id = type === "subX" ? "x" : type,
|
13701 | toCull = config["axis_" + id + "_tick_culling"];
|
13702 |
|
13703 | if (axis && toCull) {
|
13704 | var tickText = axis.selectAll(".tick text"),
|
13705 | tickValues = sortValue(tickText.data()),
|
13706 | tickSize = tickValues.length,
|
13707 | cullingMax = config["axis_" + id + "_tick_culling_max"],
|
13708 | intervalForCulling;
|
13709 |
|
13710 | if (tickSize) {
|
13711 | for (var i = 1; i < tickSize; i++) {
|
13712 | if (tickSize / i < cullingMax) {
|
13713 | intervalForCulling = i;
|
13714 | break;
|
13715 | }
|
13716 | }
|
13717 |
|
13718 | tickText.each(function (d) {
|
13719 | this.style.display = tickValues.indexOf(d) % intervalForCulling ? "none" : null;
|
13720 | });
|
13721 | } else {
|
13722 | tickText.style("display", null);
|
13723 | }
|
13724 |
|
13725 |
|
13726 | if (type === "x") {
|
13727 | var clipPath = current.maxTickWidths.x.clipPath ? clip.pathXAxisTickTexts : null;
|
13728 | $el.svg.selectAll("." + config_classes.axisX + " .tick text").attr("clip-path", clipPath);
|
13729 | }
|
13730 | }
|
13731 | });
|
13732 | };
|
13733 |
|
13734 | return Axis;
|
13735 | }();
|
13736 | ;
|
13737 |
|
13738 |
|
13739 |
|
13740 |
|
13741 |
|
13742 |
|
13743 | var eventrect = ({
|
13744 | |
13745 |
|
13746 |
|
13747 |
|
13748 |
|
13749 | initEventRect: function initEventRect() {
|
13750 | var $$ = this;
|
13751 | $$.$el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.eventRects).style("fill-opacity", "0");
|
13752 | },
|
13753 |
|
13754 | |
13755 |
|
13756 |
|
13757 |
|
13758 | redrawEventRect: function redrawEventRect() {
|
13759 | var $$ = this,
|
13760 | config = $$.config,
|
13761 | state = $$.state,
|
13762 | $el = $$.$el,
|
13763 | isMultipleX = $$.isMultipleX();
|
13764 |
|
13765 | if ($el.eventRect) {
|
13766 | $$.updateEventRect($el.eventRect, !0);
|
13767 | } else {
|
13768 | var eventRects = $$.$el.main.select("." + config_classes.eventRects).style("cursor", config.zoom_enabled && config.zoom_type !== "drag" ? config.axis_rotated ? "ns-resize" : "ew-resize" : null).classed(config_classes.eventRectsMultiple, isMultipleX).classed(config_classes.eventRectsSingle, !isMultipleX),
|
13769 | eventRectUpdate = eventRects.selectAll("." + config_classes.eventRect).data([0]).enter().append("rect");
|
13770 |
|
13771 | $$.updateEventRect(eventRectUpdate);
|
13772 |
|
13773 | isMultipleX ? $$.generateEventRectsForMultipleXs(eventRectUpdate) : $$.generateEventRectsForSingleX(eventRectUpdate);
|
13774 |
|
13775 | eventRectUpdate.call($$.getDraggableSelection());
|
13776 | $el.eventRect = eventRectUpdate;
|
13777 |
|
13778 | if ($$.state.inputType === "touch" && !$el.svg.on("touchstart.eventRect") && !$$.hasArcType()) {
|
13779 | $$.bindTouchOnEventRect(isMultipleX);
|
13780 | }
|
13781 | }
|
13782 |
|
13783 | if (!isMultipleX) {
|
13784 |
|
13785 | var xAxisTickValues = $$.getMaxDataCountTarget();
|
13786 |
|
13787 | $$.updateDataIndexByX(xAxisTickValues);
|
13788 | $$.updateXs(xAxisTickValues);
|
13789 | $$.updatePointClass == null ? void 0 : $$.updatePointClass(!0);
|
13790 | state.eventReceiver.data = xAxisTickValues;
|
13791 | }
|
13792 |
|
13793 | $$.updateEventRectData();
|
13794 | },
|
13795 | bindTouchOnEventRect: function bindTouchOnEventRect(isMultipleX) {
|
13796 | var $$ = this,
|
13797 | config = $$.config,
|
13798 | state = $$.state,
|
13799 | _$$$$el = $$.$el,
|
13800 | eventRect = _$$$$el.eventRect,
|
13801 | svg = _$$$$el.svg,
|
13802 | selectRect = function (context) {
|
13803 | if (isMultipleX) {
|
13804 | $$.selectRectForMultipleXs(context);
|
13805 | } else {
|
13806 | var index = $$.getDataIndexFromEvent(state.event);
|
13807 | $$.callOverOutForTouch(index);
|
13808 | index === -1 ? $$.unselectRect() : $$.selectRectForSingle(context, eventRect, index);
|
13809 | }
|
13810 | },
|
13811 | unselectRect = function () {
|
13812 | $$.unselectRect();
|
13813 | $$.callOverOutForTouch();
|
13814 | },
|
13815 | preventDefault = config.interaction_inputType_touch.preventDefault,
|
13816 | isPrevented = isboolean(preventDefault) && preventDefault || !1,
|
13817 | preventThreshold = !isNaN(preventDefault) && preventDefault || null,
|
13818 | startPx,
|
13819 | preventEvent = function (event) {
|
13820 | var eventType = event.type,
|
13821 | touch = event.changedTouches[0],
|
13822 | currentXY = touch["client" + (config.axis_rotated ? "Y" : "X")];
|
13823 |
|
13824 |
|
13825 | if (eventType === "touchstart") {
|
13826 | if (isPrevented) {
|
13827 | event.preventDefault();
|
13828 | } else if (preventThreshold !== null) {
|
13829 | startPx = currentXY;
|
13830 | }
|
13831 | } else if (eventType === "touchmove") {
|
13832 | if (isPrevented || startPx === !0 || preventThreshold !== null && Math.abs(startPx - currentXY) >= preventThreshold) {
|
13833 |
|
13834 | startPx = !0;
|
13835 | event.preventDefault();
|
13836 | }
|
13837 | }
|
13838 | };
|
13839 |
|
13840 |
|
13841 | eventRect.on("touchstart", function (event) {
|
13842 | state.event = event;
|
13843 | $$.updateEventRect();
|
13844 | }).on("touchstart.eventRect touchmove.eventRect", function (event) {
|
13845 | state.event = event;
|
13846 |
|
13847 | if (!eventRect.empty() && eventRect.classed(config_classes.eventRect)) {
|
13848 |
|
13849 | if (state.dragging || state.flowing || $$.hasArcType() || event.touches.length > 1) {
|
13850 | return;
|
13851 | }
|
13852 |
|
13853 | preventEvent(event);
|
13854 | selectRect(eventRect.node());
|
13855 | } else {
|
13856 | unselectRect();
|
13857 | }
|
13858 | }, !0).on("touchend.eventRect", function (event) {
|
13859 | state.event = event;
|
13860 |
|
13861 | if (!eventRect.empty() && eventRect.classed(config_classes.eventRect)) {
|
13862 | if ($$.hasArcType() || !$$.toggleShape || state.cancelClick) {
|
13863 | state.cancelClick && (state.cancelClick = !1);
|
13864 | }
|
13865 | }
|
13866 | }, !0);
|
13867 | svg.on("touchstart", function (event) {
|
13868 | state.event = event;
|
13869 | var target = event.target;
|
13870 |
|
13871 | if (target && target !== eventRect.node()) {
|
13872 | unselectRect();
|
13873 | }
|
13874 | });
|
13875 | },
|
13876 |
|
13877 | |
13878 |
|
13879 |
|
13880 |
|
13881 |
|
13882 |
|
13883 | updateEventRect: function updateEventRect(eventRect, force) {
|
13884 | if (force === void 0) {
|
13885 | force = !1;
|
13886 | }
|
13887 |
|
13888 | var $$ = this,
|
13889 | state = $$.state,
|
13890 | $el = $$.$el,
|
13891 | _state = state,
|
13892 | eventReceiver = _state.eventReceiver,
|
13893 | width = _state.width,
|
13894 | height = _state.height,
|
13895 | rendered = _state.rendered,
|
13896 | resizing = _state.resizing,
|
13897 | rectElement = eventRect || $el.eventRect;
|
13898 |
|
13899 | if (!rendered || resizing || force) {
|
13900 | rectElement.attr("x", 0).attr("y", 0).attr("width", width).attr("height", height);
|
13901 |
|
13902 | if (!rendered) {
|
13903 | rectElement.attr("class", config_classes.eventRect);
|
13904 | }
|
13905 | }
|
13906 |
|
13907 | (function updateClientRect() {
|
13908 | eventReceiver && (eventReceiver.rect = rectElement.node().getBoundingClientRect());
|
13909 | })();
|
13910 | },
|
13911 |
|
13912 | |
13913 |
|
13914 |
|
13915 |
|
13916 | updateEventRectData: function updateEventRectData() {
|
13917 | var $$ = this,
|
13918 | config = $$.config,
|
13919 | scale = $$.scale,
|
13920 | state = $$.state,
|
13921 | xScale = scale.zoom || scale.x,
|
13922 | isRotated = config.axis_rotated,
|
13923 | x,
|
13924 | y,
|
13925 | w,
|
13926 | h;
|
13927 |
|
13928 | if ($$.isMultipleX()) {
|
13929 |
|
13930 | x = 0;
|
13931 | y = 0;
|
13932 | w = state.width;
|
13933 | h = state.height;
|
13934 | } else {
|
13935 | var rectW, rectX;
|
13936 |
|
13937 | if ($$.axis.isCategorized()) {
|
13938 | rectW = $$.getEventRectWidth();
|
13939 |
|
13940 | rectX = function (d) {
|
13941 | return xScale(d.x) - rectW / 2;
|
13942 | };
|
13943 | } else {
|
13944 | var getPrevNextX = function (_ref) {
|
13945 | var index = _ref.index;
|
13946 | return {
|
13947 | prev: $$.getPrevX(index),
|
13948 | next: $$.getNextX(index)
|
13949 | };
|
13950 | };
|
13951 |
|
13952 | rectW = function (d) {
|
13953 | var x = getPrevNextX(d),
|
13954 | xDomain = xScale.domain();
|
13955 |
|
13956 |
|
13957 | if (x.prev === null && x.next === null) {
|
13958 | return isRotated ? state.height : state.width;
|
13959 | }
|
13960 |
|
13961 | Object.keys(x).forEach(function (key, i) {
|
13962 | var _x$key;
|
13963 |
|
13964 | x[key] = (_x$key = x[key]) != null ? _x$key : xDomain[i];
|
13965 | });
|
13966 | return Math.max(0, (xScale(x.next) - xScale(x.prev)) / 2);
|
13967 | };
|
13968 |
|
13969 | rectX = function (d) {
|
13970 | var x = getPrevNextX(d),
|
13971 | thisX = d.x;
|
13972 |
|
13973 |
|
13974 | if (x.prev === null && x.next === null) {
|
13975 | return 0;
|
13976 | }
|
13977 |
|
13978 | if (x.prev === null) {
|
13979 | x.prev = xScale.domain()[0];
|
13980 | }
|
13981 |
|
13982 | return (xScale(thisX) + xScale(x.prev)) / 2;
|
13983 | };
|
13984 | }
|
13985 |
|
13986 | x = isRotated ? 0 : rectX;
|
13987 | y = isRotated ? rectX : 0;
|
13988 | w = isRotated ? state.width : rectW;
|
13989 | h = isRotated ? rectW : state.height;
|
13990 | }
|
13991 |
|
13992 | var eventReceiver = state.eventReceiver,
|
13993 | call = function (fn, v) {
|
13994 | return isFunction(fn) ? fn(v) : fn;
|
13995 | };
|
13996 |
|
13997 |
|
13998 | eventReceiver.coords.splice(eventReceiver.data.length);
|
13999 | eventReceiver.data.forEach(function (d, i) {
|
14000 | eventReceiver.coords[i] = {
|
14001 | x: call(x, d),
|
14002 | y: call(y, d),
|
14003 | w: call(w, d),
|
14004 | h: call(h, d)
|
14005 | };
|
14006 | });
|
14007 | },
|
14008 | selectRectForMultipleXs: function selectRectForMultipleXs(context) {
|
14009 | var $$ = this,
|
14010 | config = $$.config,
|
14011 | state = $$.state,
|
14012 | targetsToShow = $$.filterTargetsToShow($$.data.targets);
|
14013 |
|
14014 |
|
14015 | if (state.dragging || $$.hasArcType(targetsToShow)) {
|
14016 | return;
|
14017 | }
|
14018 |
|
14019 | var mouse = getPointer(state.event, context),
|
14020 | closest = $$.findClosestFromTargets(targetsToShow, mouse);
|
14021 |
|
14022 | if (state.mouseover && (!closest || closest.id !== state.mouseover.id)) {
|
14023 | config.data_onout.call($$.api, state.mouseover);
|
14024 | state.mouseover = undefined;
|
14025 | }
|
14026 |
|
14027 | if (!closest) {
|
14028 | $$.unselectRect();
|
14029 | return;
|
14030 | }
|
14031 |
|
14032 | var sameXData = $$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped ? [closest] : $$.filterByX(targetsToShow, closest.x),
|
14033 | selectedData = sameXData.map(function (d) {
|
14034 | return $$.addName(d);
|
14035 | });
|
14036 |
|
14037 | $$.showTooltip(selectedData, context);
|
14038 |
|
14039 | $$.setExpand(closest.index, closest.id, !0);
|
14040 |
|
14041 | $$.showGridFocus(selectedData);
|
14042 |
|
14043 | if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
|
14044 | $$.$el.svg.select("." + config_classes.eventRect).style("cursor", "pointer");
|
14045 |
|
14046 | if (!state.mouseover) {
|
14047 | config.data_onover.call($$.api, closest);
|
14048 | state.mouseover = closest;
|
14049 | }
|
14050 | }
|
14051 | },
|
14052 |
|
14053 | |
14054 |
|
14055 |
|
14056 |
|
14057 | unselectRect: function unselectRect() {
|
14058 | var $$ = this,
|
14059 | config = $$.config,
|
14060 | _$$$$el2 = $$.$el,
|
14061 | circle = _$$$$el2.circle,
|
14062 | tooltip = _$$$$el2.tooltip;
|
14063 | $$.$el.svg.select("." + config_classes.eventRect).style("cursor", null);
|
14064 | $$.hideGridFocus();
|
14065 |
|
14066 | if (tooltip) {
|
14067 | $$.hideTooltip();
|
14068 |
|
14069 | $$._handleLinkedCharts(!1);
|
14070 | }
|
14071 |
|
14072 | circle && !config.point_focus_only && $$.unexpandCircles();
|
14073 | $$.expandBarTypeShapes(!1);
|
14074 | },
|
14075 |
|
14076 | |
14077 |
|
14078 |
|
14079 |
|
14080 |
|
14081 |
|
14082 |
|
14083 | generateEventRectsForSingleX: function generateEventRectsForSingleX(eventRectEnter) {
|
14084 | var $$ = this,
|
14085 | config = $$.config,
|
14086 | state = $$.state,
|
14087 | eventReceiver = state.eventReceiver,
|
14088 | rect = eventRectEnter.style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null).on("click", function (event) {
|
14089 | state.event = event;
|
14090 | var _eventReceiver = eventReceiver,
|
14091 | currentIdx = _eventReceiver.currentIdx,
|
14092 | data = _eventReceiver.data,
|
14093 | d = data[currentIdx === -1 ? $$.getDataIndexFromEvent(event) : currentIdx];
|
14094 | $$.clickHandlerForSingleX.bind(this)(d, $$);
|
14095 | });
|
14096 |
|
14097 | if (state.inputType === "mouse") {
|
14098 | var getData = function (event) {
|
14099 | var index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
|
14100 | return index > -1 ? eventReceiver.data[index] : null;
|
14101 | };
|
14102 |
|
14103 | rect.on("mouseover", function (event) {
|
14104 | state.event = event;
|
14105 | $$.updateEventRect();
|
14106 | }).on("mousemove", function (event) {
|
14107 | var d = getData(event);
|
14108 | state.event = event;
|
14109 |
|
14110 | if (!d) {
|
14111 | return;
|
14112 | }
|
14113 |
|
14114 | var index = d.index,
|
14115 | stepType = config.line_step_type;
|
14116 |
|
14117 |
|
14118 | if (config.line_step_tooltipMatch && $$.hasType("step") && /^step\-(before|after)$/.test(stepType)) {
|
14119 | var scale = $$.scale.zoom || $$.scale.x,
|
14120 | xs = $$.axis.xs[index],
|
14121 | inverted = scale.invert(getPointer(event, this)[0]);
|
14122 |
|
14123 | if (stepType === "step-after" && inverted < xs) {
|
14124 | index -= 1;
|
14125 | } else if (stepType === "step-before" && inverted > xs) {
|
14126 | index += 1;
|
14127 | }
|
14128 | }
|
14129 |
|
14130 |
|
14131 | if (state.dragging || state.flowing || $$.hasArcType() || config.tooltip_grouped && index === eventReceiver.currentIdx) {
|
14132 | return;
|
14133 | }
|
14134 |
|
14135 | if (index !== eventReceiver.currentIdx) {
|
14136 | $$.setOverOut(!1, eventReceiver.currentIdx);
|
14137 | eventReceiver.currentIdx = index;
|
14138 | }
|
14139 |
|
14140 | index === -1 ? $$.unselectRect() : $$.selectRectForSingle(this, rect, index);
|
14141 |
|
14142 |
|
14143 | $$.setOverOut(index !== -1, index);
|
14144 | }).on("mouseout", function (event) {
|
14145 | state.event = event;
|
14146 |
|
14147 | if (!config || $$.hasArcType() || eventReceiver.currentIdx === -1) {
|
14148 | return;
|
14149 | }
|
14150 |
|
14151 | $$.unselectRect();
|
14152 | $$.setOverOut(!1, eventReceiver.currentIdx);
|
14153 |
|
14154 | eventReceiver.currentIdx = -1;
|
14155 | });
|
14156 | }
|
14157 |
|
14158 | return rect;
|
14159 | },
|
14160 | clickHandlerForSingleX: function clickHandlerForSingleX(d, ctx) {
|
14161 | var $$ = ctx,
|
14162 | config = $$.config,
|
14163 | state = $$.state,
|
14164 | main = $$.$el.main;
|
14165 |
|
14166 | if (!d || $$.hasArcType() || state.cancelClick) {
|
14167 | state.cancelClick && (state.cancelClick = !1);
|
14168 | return;
|
14169 | }
|
14170 |
|
14171 | var index = d.index;
|
14172 | main.selectAll("." + config_classes.shape + "-" + index).each(function (d2) {
|
14173 | if (config.data_selection_grouped || $$.isWithinShape(this, d2)) {
|
14174 | $$.toggleShape == null ? void 0 : $$.toggleShape(this, d2, index);
|
14175 | config.data_onclick.bind($$.api)(d2, this);
|
14176 | }
|
14177 | });
|
14178 | },
|
14179 |
|
14180 | |
14181 |
|
14182 |
|
14183 |
|
14184 |
|
14185 |
|
14186 | generateEventRectsForMultipleXs: function generateEventRectsForMultipleXs(eventRectEnter) {
|
14187 | var $$ = this,
|
14188 | state = $$.state;
|
14189 | eventRectEnter.on("click", function (event) {
|
14190 | state.event = event;
|
14191 | $$.clickHandlerForMultipleXS.bind(this)($$);
|
14192 | });
|
14193 |
|
14194 | if (state.inputType === "mouse") {
|
14195 | eventRectEnter.on("mouseover mousemove", function (event) {
|
14196 | state.event = event;
|
14197 | $$.selectRectForMultipleXs(this);
|
14198 | }).on("mouseout", function (event) {
|
14199 | state.event = event;
|
14200 |
|
14201 | if (!$$.config || $$.hasArcType()) {
|
14202 | return;
|
14203 | }
|
14204 |
|
14205 | $$.unselectRect();
|
14206 | });
|
14207 | }
|
14208 | },
|
14209 | clickHandlerForMultipleXS: function clickHandlerForMultipleXS(ctx) {
|
14210 | var $$ = ctx,
|
14211 | config = $$.config,
|
14212 | state = $$.state,
|
14213 | targetsToShow = $$.filterTargetsToShow($$.data.targets);
|
14214 |
|
14215 | if ($$.hasArcType(targetsToShow)) {
|
14216 | return;
|
14217 | }
|
14218 |
|
14219 | var mouse = getPointer(state.event, this),
|
14220 | closest = $$.findClosestFromTargets(targetsToShow, mouse);
|
14221 |
|
14222 | if (!closest) {
|
14223 | return;
|
14224 | }
|
14225 |
|
14226 |
|
14227 | if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) {
|
14228 | $$.$el.main.selectAll("." + config_classes.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll("." + config_classes.shape + "-" + closest.index).each(function () {
|
14229 | if (config.data_selection_grouped || $$.isWithinShape(this, closest)) {
|
14230 | $$.toggleShape == null ? void 0 : $$.toggleShape(this, closest, closest.index);
|
14231 | config.data_onclick.bind($$.api)(closest, this);
|
14232 | }
|
14233 | });
|
14234 | }
|
14235 | }
|
14236 | });
|
14237 |
|
14238 | var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack_require__(11);
|
14239 | ;
|
14240 |
|
14241 |
|
14242 |
|
14243 |
|
14244 |
|
14245 |
|
14246 |
|
14247 |
|
14248 | var interactions_flow = ({
|
14249 | |
14250 |
|
14251 |
|
14252 |
|
14253 |
|
14254 |
|
14255 | generateFlow: function generateFlow(args) {
|
14256 | var $$ = this,
|
14257 | data = $$.data,
|
14258 | state = $$.state,
|
14259 | $el = $$.$el;
|
14260 | return function () {
|
14261 | var flowLength = args.flow.length;
|
14262 |
|
14263 | state.flowing = !0;
|
14264 |
|
14265 | data.targets.forEach(function (d) {
|
14266 | d.values.splice(0, flowLength);
|
14267 | });
|
14268 |
|
14269 | if ($$.updateXGrid) {
|
14270 | $$.updateXGrid(!0);
|
14271 | }
|
14272 |
|
14273 |
|
14274 | var elements = {};
|
14275 | ["axis.x", "grid.x", "gridLines.x", "region.list", "text", "bar", "line", "area", "circle"].forEach(function (v) {
|
14276 | var _node,
|
14277 | name = v.split("."),
|
14278 | node = $el[name[0]];
|
14279 |
|
14280 | if (node && name.length > 1) {
|
14281 | node = node[name[1]];
|
14282 | }
|
14283 |
|
14284 | if ((_node = node) != null && _node.size()) {
|
14285 | elements[v] = node;
|
14286 | }
|
14287 | });
|
14288 | $$.hideGridFocus();
|
14289 | $$.setFlowList(elements, args);
|
14290 | };
|
14291 | },
|
14292 |
|
14293 | |
14294 |
|
14295 |
|
14296 |
|
14297 |
|
14298 |
|
14299 | setFlowList: function setFlowList(elements, args) {
|
14300 | var $$ = this,
|
14301 | flow = args.flow,
|
14302 | targets = args.targets,
|
14303 | _flow = flow,
|
14304 | _flow$duration = _flow.duration,
|
14305 | duration = _flow$duration === void 0 ? args.duration : _flow$duration,
|
14306 | flowIndex = _flow.index,
|
14307 | flowLength = _flow.length,
|
14308 | orgDataCount = _flow.orgDataCount,
|
14309 | transform = $$.getFlowTransform(targets, orgDataCount, flowIndex, flowLength),
|
14310 | wait = generateWait(),
|
14311 | n;
|
14312 | wait.add(Object.keys(elements).map(function (v) {
|
14313 | n = elements[v].transition().ease(external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_.easeLinear).duration(duration);
|
14314 |
|
14315 | if (v === "axis.x") {
|
14316 | n = n.call(function (g) {
|
14317 | $$.axis.x.setTransition(g).create(g);
|
14318 | });
|
14319 | } else if (v === "region.list") {
|
14320 | n = n.filter($$.isRegionOnX).attr("transform", transform);
|
14321 | } else {
|
14322 | n = n.attr("transform", transform);
|
14323 | }
|
14324 |
|
14325 | return n;
|
14326 | }));
|
14327 | n.call(wait, function () {
|
14328 | $$.cleanUpFlow(elements, args);
|
14329 | });
|
14330 | },
|
14331 |
|
14332 | |
14333 |
|
14334 |
|
14335 |
|
14336 |
|
14337 |
|
14338 | cleanUpFlow: function cleanUpFlow(elements, args) {
|
14339 | var $$ = this,
|
14340 | config = $$.config,
|
14341 | state = $$.state,
|
14342 | svg = $$.$el.svg,
|
14343 | isRotated = config.axis_rotated,
|
14344 | flow = args.flow,
|
14345 | shape = args.shape,
|
14346 | xv = args.xv,
|
14347 | _shape$pos = shape.pos,
|
14348 | cx = _shape$pos.cx,
|
14349 | cy = _shape$pos.cy,
|
14350 | xForText = _shape$pos.xForText,
|
14351 | yForText = _shape$pos.yForText,
|
14352 | _flow2 = flow,
|
14353 | _flow2$done = _flow2.done,
|
14354 | done = _flow2$done === void 0 ? function () {} : _flow2$done,
|
14355 | flowLength = _flow2.length;
|
14356 |
|
14357 |
|
14358 | if (flowLength) {
|
14359 | ["circle", "text", "shape", "eventRect"].forEach(function (v) {
|
14360 | var target = [];
|
14361 |
|
14362 | for (var i = 0; i < flowLength; i++) {
|
14363 | target.push("." + config_classes[v] + "-" + i);
|
14364 | }
|
14365 |
|
14366 | svg.selectAll("." + config_classes[v + "s"])
|
14367 | .selectAll(target).remove();
|
14368 | });
|
14369 | svg.select("." + config_classes.xgrid).remove();
|
14370 | }
|
14371 |
|
14372 |
|
14373 | Object.keys(elements).forEach(function (v) {
|
14374 | var n = elements[v];
|
14375 |
|
14376 | if (v !== "axis.x") {
|
14377 | n.attr("transform", null);
|
14378 | }
|
14379 |
|
14380 | if (v === "grid.x") {
|
14381 | n.attr(state.xgridAttr);
|
14382 | } else if (v === "gridLines.x") {
|
14383 | n.attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);
|
14384 | } else if (v === "gridLines.x") {
|
14385 | n.select("line").attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? state.width : xv);
|
14386 | n.select("text").attr("x", isRotated ? state.width : 0).attr("y", xv);
|
14387 | } else if (/^(area|bar|line)$/.test(v)) {
|
14388 | n.attr("d", shape.type[v]);
|
14389 | } else if (v === "text") {
|
14390 | n.attr("x", xForText).attr("y", yForText).style("fill-opacity", $$.opacityForText.bind($$));
|
14391 | } else if (v === "circle") {
|
14392 | if ($$.isCirclePoint()) {
|
14393 | n.attr("cx", cx).attr("cy", cy);
|
14394 | } else {
|
14395 | var xFunc = function (d) {
|
14396 | return cx(d) - config.point_r;
|
14397 | },
|
14398 | yFunc = function (d) {
|
14399 | return cy(d) - config.point_r;
|
14400 | };
|
14401 |
|
14402 | n.attr("x", xFunc).attr("y", yFunc).attr("cx", cx)
|
14403 | .attr("cy", cy);
|
14404 | }
|
14405 | } else if (v === "region.list") {
|
14406 | n.select("rect").filter($$.isRegionOnX).attr("x", $$.regionX.bind($$)).attr("width", $$.regionWidth.bind($$));
|
14407 | }
|
14408 | });
|
14409 | config.interaction_enabled && $$.redrawEventRect();
|
14410 |
|
14411 | done.call($$.api);
|
14412 | state.flowing = !1;
|
14413 | },
|
14414 |
|
14415 | |
14416 |
|
14417 |
|
14418 |
|
14419 |
|
14420 |
|
14421 |
|
14422 |
|
14423 |
|
14424 | getFlowTransform: function getFlowTransform(targets, orgDataCount, flowIndex, flowLength) {
|
14425 | var _flowStart,
|
14426 | _flowEnd,
|
14427 | $$ = this,
|
14428 | data = $$.data,
|
14429 | x = $$.scale.x,
|
14430 | dataValues = data.targets[0].values,
|
14431 | flowStart = $$.getValueOnIndex(dataValues, flowIndex),
|
14432 | flowEnd = $$.getValueOnIndex(dataValues, flowIndex + flowLength),
|
14433 | translateX,
|
14434 | orgDomain = x.domain(),
|
14435 | domain = $$.updateXDomain(targets, !0, !0);
|
14436 |
|
14437 |
|
14438 | if (!orgDataCount) {
|
14439 |
|
14440 | if (dataValues.length !== 1) {
|
14441 | translateX = x(orgDomain[0]) - x(domain[0]);
|
14442 | } else {
|
14443 | if ($$.axis.isTimeSeries()) {
|
14444 | flowStart = $$.getValueOnIndex(dataValues, 0);
|
14445 | flowEnd = $$.getValueOnIndex(dataValues, dataValues.length - 1);
|
14446 | translateX = x(flowStart.x) - x(flowEnd.x);
|
14447 | } else {
|
14448 | translateX = diffDomain(domain) / 2;
|
14449 | }
|
14450 | }
|
14451 | } else if (orgDataCount === 1 || ((_flowStart = flowStart) == null ? void 0 : _flowStart.x) === ((_flowEnd = flowEnd) == null ? void 0 : _flowEnd.x)) {
|
14452 | translateX = x(orgDomain[0]) - x(domain[0]);
|
14453 | } else {
|
14454 | translateX = $$.axis.isTimeSeries() ? x(orgDomain[0]) - x(domain[0]) : x(flowStart.x) - x(flowEnd.x);
|
14455 | }
|
14456 |
|
14457 | var scaleX = diffDomain(orgDomain) / diffDomain(domain);
|
14458 | return "translate(" + translateX + ",0) scale(" + scaleX + ",1)";
|
14459 | }
|
14460 | });
|
14461 | ;
|
14462 |
|
14463 |
|
14464 |
|
14465 |
|
14466 |
|
14467 | var clip = ({
|
14468 | initClip: function initClip() {
|
14469 | var $$ = this,
|
14470 | clip = $$.state.clip;
|
14471 |
|
14472 | clip.id = $$.state.datetimeId + "-clip";
|
14473 | clip.idXAxis = clip.id + "-xaxis";
|
14474 | clip.idYAxis = clip.id + "-yaxis";
|
14475 | clip.idGrid = clip.id + "-grid";
|
14476 |
|
14477 | clip.path = $$.getClipPath(clip.id);
|
14478 | clip.pathXAxis = $$.getClipPath(clip.idXAxis);
|
14479 | clip.pathYAxis = $$.getClipPath(clip.idYAxis);
|
14480 | clip.pathGrid = $$.getClipPath(clip.idGrid);
|
14481 | },
|
14482 | getClipPath: function getClipPath(id) {
|
14483 | var $$ = this,
|
14484 | config = $$.config;
|
14485 |
|
14486 | if (!config.clipPath && /-clip$/.test(id) || !config.axis_x_clipPath && /-clip-xaxis$/.test(id) || !config.axis_y_clipPath && /-clip-yaxis$/.test(id)) {
|
14487 | return null;
|
14488 | }
|
14489 |
|
14490 | var isIE9 = win.navigator ? win.navigator.appVersion.toLowerCase().indexOf("msie 9.") >= 0 : !1;
|
14491 | return "url(" + (isIE9 ? "" : browser_doc.URL.split("#")[0]) + "#" + id + ")";
|
14492 | },
|
14493 | appendClip: function appendClip(parent, id) {
|
14494 | id && parent.append("clipPath").attr("id", id).append("rect");
|
14495 | },
|
14496 |
|
14497 | |
14498 |
|
14499 |
|
14500 |
|
14501 |
|
14502 | setXAxisClipPath: function setXAxisClipPath(node) {
|
14503 | var $$ = this,
|
14504 | config = $$.config,
|
14505 | _$$$state = $$.state,
|
14506 | margin = _$$$state.margin,
|
14507 | width = _$$$state.width,
|
14508 | height = _$$$state.height,
|
14509 | isRotated = config.axis_rotated,
|
14510 | left = Math.max(30, margin.left) - (isRotated ? 0 : 20),
|
14511 | x = isRotated ? -(1 + left) : -(left - 1),
|
14512 | y = -Math.max(15, margin.top),
|
14513 | w = isRotated ? margin.left + 20 : width + 10 + left,
|
14514 | h = (isRotated ? margin.top + height + 10 : margin.bottom) + 20;
|
14515 | node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
|
14516 | },
|
14517 |
|
14518 | |
14519 |
|
14520 |
|
14521 |
|
14522 |
|
14523 | setYAxisClipPath: function setYAxisClipPath(node) {
|
14524 | var $$ = this,
|
14525 | config = $$.config,
|
14526 | _$$$state2 = $$.state,
|
14527 | margin = _$$$state2.margin,
|
14528 | width = _$$$state2.width,
|
14529 | height = _$$$state2.height,
|
14530 | isRotated = config.axis_rotated,
|
14531 | left = Math.max(30, margin.left) - (isRotated ? 20 : 0),
|
14532 | isInner = config.axis_y_inner,
|
14533 | x = isInner ? -1 : isRotated ? -(1 + left) : -(left - 1),
|
14534 | y = -(isRotated ? 20 : margin.top),
|
14535 | w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0),
|
14536 | h = (isRotated ? margin.bottom : margin.top + height) + 10;
|
14537 | node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
|
14538 | },
|
14539 | updateXAxisTickClip: function updateXAxisTickClip() {
|
14540 | var $$ = this,
|
14541 | config = $$.config,
|
14542 | _$$$state3 = $$.state,
|
14543 | clip = _$$$state3.clip,
|
14544 | xAxisHeight = _$$$state3.xAxisHeight,
|
14545 | defs = $$.$el.defs,
|
14546 | newXAxisHeight = $$.getHorizontalAxisHeight("x");
|
14547 |
|
14548 | if (defs && !clip.idXAxisTickTexts) {
|
14549 | var clipId = clip.id + "-xaxisticktexts";
|
14550 | $$.appendClip(defs, clipId);
|
14551 | clip.pathXAxisTickTexts = $$.getClipPath(clip.idXAxisTickTexts);
|
14552 | clip.idXAxisTickTexts = clipId;
|
14553 | }
|
14554 |
|
14555 | if (!config.axis_x_tick_multiline && $$.getAxisTickRotate("x") && newXAxisHeight !== xAxisHeight) {
|
14556 | $$.setXAxisTickClipWidth();
|
14557 | $$.setXAxisTickTextClipPathWidth();
|
14558 | }
|
14559 |
|
14560 | $$.state.xAxisHeight = newXAxisHeight;
|
14561 | },
|
14562 | setXAxisTickClipWidth: function setXAxisTickClipWidth() {
|
14563 | var $$ = this,
|
14564 | config = $$.config,
|
14565 | maxTickWidths = $$.state.current.maxTickWidths,
|
14566 | xAxisTickRotate = $$.getAxisTickRotate("x");
|
14567 |
|
14568 | if (!config.axis_x_tick_multiline && xAxisTickRotate) {
|
14569 | var sinRotation = Math.sin(Math.PI / 180 * Math.abs(xAxisTickRotate));
|
14570 | maxTickWidths.x.clipPath = ($$.getHorizontalAxisHeight("x") - 20) / sinRotation;
|
14571 | } else {
|
14572 | maxTickWidths.x.clipPath = null;
|
14573 | }
|
14574 | },
|
14575 | setXAxisTickTextClipPathWidth: function setXAxisTickTextClipPathWidth() {
|
14576 | var $$ = this,
|
14577 | _$$$state4 = $$.state,
|
14578 | clip = _$$$state4.clip,
|
14579 | current = _$$$state4.current,
|
14580 | svg = $$.$el.svg;
|
14581 |
|
14582 | if (svg) {
|
14583 | svg.select("#" + clip.idXAxisTickTexts + " rect").attr("width", current.maxTickWidths.x.clipPath).attr("height", 30);
|
14584 | }
|
14585 | }
|
14586 | });
|
14587 | ;
|
14588 |
|
14589 |
|
14590 |
|
14591 |
|
14592 |
|
14593 |
|
14594 |
|
14595 |
|
14596 | var getGridTextAnchor = function (d) {
|
14597 | return isValue(d.position) || "end";
|
14598 | },
|
14599 | getGridTextDx = function (d) {
|
14600 | return d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
|
14601 | };
|
14602 |
|
14603 |
|
14604 |
|
14605 |
|
14606 |
|
14607 |
|
14608 |
|
14609 |
|
14610 |
|
14611 | function getGridTextX(isX, width, height) {
|
14612 | return function (d) {
|
14613 | var x = isX ? 0 : width;
|
14614 |
|
14615 | if (d.position === "start") {
|
14616 | x = isX ? -height : 0;
|
14617 | } else if (d.position === "middle") {
|
14618 | x = (isX ? -height : width) / 2;
|
14619 | }
|
14620 |
|
14621 | return x;
|
14622 | };
|
14623 | }
|
14624 |
|
14625 |
|
14626 |
|
14627 |
|
14628 |
|
14629 |
|
14630 |
|
14631 |
|
14632 | function smoothLines(el, type) {
|
14633 | if (type === "grid") {
|
14634 | el.each(function () {
|
14635 | var g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
14636 | ["x1", "x2", "y1", "y2"].forEach(function (v) {
|
14637 | return g.attr(v, Math.ceil(+g.attr(v)));
|
14638 | });
|
14639 | });
|
14640 | }
|
14641 | }
|
14642 |
|
14643 | var grid = ({
|
14644 | hasGrid: function hasGrid() {
|
14645 | var config = this.config;
|
14646 | return ["x", "y"].some(function (v) {
|
14647 | return config["grid_" + v + "_show"] || config["grid_" + v + "_lines"].length;
|
14648 | });
|
14649 | },
|
14650 | initGrid: function initGrid() {
|
14651 | var $$ = this;
|
14652 | $$.hasGrid() && $$.initGridLines();
|
14653 | $$.initFocusGrid();
|
14654 | },
|
14655 | initGridLines: function initGridLines() {
|
14656 | var $$ = this,
|
14657 | config = $$.config,
|
14658 | clip = $$.state.clip,
|
14659 | $el = $$.$el;
|
14660 |
|
14661 | if (config.grid_x_lines.length || config.grid_y_lines.length) {
|
14662 | $el.gridLines.main = $el.main.insert("g", "." + config_classes.chart + (config.grid_lines_front ? " + *" : "")).attr("clip-path", clip.pathGrid).attr("class", config_classes.grid + " " + config_classes.gridLines);
|
14663 | $el.gridLines.main.append("g").attr("class", config_classes.xgridLines);
|
14664 | $el.gridLines.main.append("g").attr("class", config_classes.ygridLines);
|
14665 | $el.gridLines.x = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([]);
|
14666 | }
|
14667 | },
|
14668 | updateXGrid: function updateXGrid(withoutUpdate) {
|
14669 | var $$ = this,
|
14670 | config = $$.config,
|
14671 | scale = $$.scale,
|
14672 | state = $$.state,
|
14673 | _$$$$el = $$.$el,
|
14674 | main = _$$$$el.main,
|
14675 | grid = _$$$$el.grid,
|
14676 | isRotated = config.axis_rotated,
|
14677 | xgridData = $$.generateGridData(config.grid_x_type, scale.x),
|
14678 | tickOffset = $$.axis.isCategorized() ? $$.axis.x.tickOffset() : 0,
|
14679 | pos = function (d) {
|
14680 | return (scale.zoom || scale.x)(d) + tickOffset * (isRotated ? -1 : 1);
|
14681 | };
|
14682 |
|
14683 | state.xgridAttr = isRotated ? {
|
14684 | "x1": 0,
|
14685 | "x2": state.width,
|
14686 | "y1": pos,
|
14687 | "y2": pos
|
14688 | } : {
|
14689 | "x1": pos,
|
14690 | "x2": pos,
|
14691 | "y1": 0,
|
14692 | "y2": state.height
|
14693 | };
|
14694 | grid.x = main.select("." + config_classes.xgrids).selectAll("." + config_classes.xgrid).data(xgridData);
|
14695 | grid.x.exit().remove();
|
14696 | grid.x = grid.x.enter().append("line").attr("class", config_classes.xgrid).merge(grid.x);
|
14697 |
|
14698 | if (!withoutUpdate) {
|
14699 | grid.x.each(function () {
|
14700 | var grid = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
14701 | Object.keys(state.xgridAttr).forEach(function (id) {
|
14702 | grid.attr(id, state.xgridAttr[id]).style("opacity", function () {
|
14703 | return grid.attr(isRotated ? "y1" : "x1") === (isRotated ? state.height : 0) ? "0" : null;
|
14704 | });
|
14705 | });
|
14706 | });
|
14707 | }
|
14708 | },
|
14709 | updateYGrid: function updateYGrid() {
|
14710 | var $$ = this,
|
14711 | config = $$.config,
|
14712 | state = $$.state,
|
14713 | _$$$$el2 = $$.$el,
|
14714 | grid = _$$$$el2.grid,
|
14715 | main = _$$$$el2.main,
|
14716 | isRotated = config.axis_rotated,
|
14717 | gridValues = $$.axis.y.tickValues() || $$.scale.y.ticks(config.grid_y_ticks),
|
14718 | pos = function (d) {
|
14719 | return Math.ceil($$.scale.y(d));
|
14720 | };
|
14721 |
|
14722 | grid.y = main.select("." + config_classes.ygrids).selectAll("." + config_classes.ygrid).data(gridValues);
|
14723 | grid.y.exit().remove();
|
14724 | grid.y = grid.y.enter().append("line").attr("class", config_classes.ygrid).merge(grid.y);
|
14725 | grid.y.attr("x1", isRotated ? pos : 0).attr("x2", isRotated ? pos : state.width).attr("y1", isRotated ? 0 : pos).attr("y2", isRotated ? state.height : pos);
|
14726 | smoothLines(grid.y, "grid");
|
14727 | },
|
14728 | updateGrid: function updateGrid() {
|
14729 | var $$ = this,
|
14730 | _$$$$el3 = $$.$el,
|
14731 | grid = _$$$$el3.grid,
|
14732 | gridLines = _$$$$el3.gridLines;
|
14733 | gridLines.main || $$.initGridLines();
|
14734 |
|
14735 | grid.main.style("visibility", $$.hasArcType() ? "hidden" : null);
|
14736 | $$.hideGridFocus();
|
14737 | $$.updateXGridLines();
|
14738 | $$.updateYGridLines();
|
14739 | },
|
14740 |
|
14741 | |
14742 |
|
14743 |
|
14744 |
|
14745 | updateXGridLines: function updateXGridLines() {
|
14746 | var $$ = this,
|
14747 | config = $$.config,
|
14748 | _$$$$el4 = $$.$el,
|
14749 | gridLines = _$$$$el4.gridLines,
|
14750 | main = _$$$$el4.main,
|
14751 | $T = $$.$T,
|
14752 | isRotated = config.axis_rotated;
|
14753 | config.grid_x_show && $$.updateXGrid();
|
14754 | var xLines = main.select("." + config_classes.xgridLines).selectAll("." + config_classes.xgridLine).data(config.grid_x_lines);
|
14755 |
|
14756 | $T(xLines.exit()).style("opacity", "0").remove();
|
14757 |
|
14758 | var xgridLine = xLines.enter().append("g");
|
14759 | xgridLine.append("line").style("opacity", "0");
|
14760 | xgridLine.append("text").attr("transform", isRotated ? "" : "rotate(-90)").attr("dy", -5).style("opacity", "0");
|
14761 | xLines = xgridLine.merge(xLines);
|
14762 | $T(xLines.attr("class", function (d) {
|
14763 | return (config_classes.xgridLine + " " + (d.class || "")).trim();
|
14764 | }).select("text").attr("text-anchor", getGridTextAnchor).attr("dx", getGridTextDx)).text(function (d) {
|
14765 | return d.text;
|
14766 | }).style("opacity", null);
|
14767 | gridLines.x = xLines;
|
14768 | },
|
14769 |
|
14770 | |
14771 |
|
14772 |
|
14773 |
|
14774 | updateYGridLines: function updateYGridLines() {
|
14775 | var $$ = this,
|
14776 | config = $$.config,
|
14777 | _$$$state = $$.state,
|
14778 | width = _$$$state.width,
|
14779 | height = _$$$state.height,
|
14780 | $el = $$.$el,
|
14781 | $T = $$.$T,
|
14782 | isRotated = config.axis_rotated;
|
14783 | config.grid_y_show && $$.updateYGrid();
|
14784 | var ygridLines = $el.main.select("." + config_classes.ygridLines).selectAll("." + config_classes.ygridLine).data(config.grid_y_lines);
|
14785 |
|
14786 | $T(ygridLines.exit()).style("opacity", "0").remove();
|
14787 |
|
14788 | var ygridLine = ygridLines.enter().append("g");
|
14789 | ygridLine.append("line").style("opacity", "0");
|
14790 | ygridLine.append("text").attr("transform", isRotated ? "rotate(-90)" : "").style("opacity", "0");
|
14791 | ygridLines = ygridLine.merge(ygridLines);
|
14792 |
|
14793 | var yv = $$.yv.bind($$);
|
14794 | $T(ygridLines.attr("class", function (d) {
|
14795 | return (config_classes.ygridLine + " " + (d.class || "")).trim();
|
14796 | }).select("line")).attr("x1", isRotated ? yv : 0).attr("x2", isRotated ? yv : width).attr("y1", isRotated ? 0 : yv).attr("y2", isRotated ? height : yv).style("opacity", null);
|
14797 | $T(ygridLines.select("text").attr("text-anchor", getGridTextAnchor).attr("dx", getGridTextDx)).attr("dy", -5).attr("x", getGridTextX(isRotated, width, height)).attr("y", yv).text(function (d) {
|
14798 | return d.text;
|
14799 | }).style("opacity", null);
|
14800 | $el.gridLines.y = ygridLines;
|
14801 | },
|
14802 | redrawGrid: function redrawGrid(withTransition) {
|
14803 | var $$ = this,
|
14804 | isRotated = $$.config.axis_rotated,
|
14805 | _$$$state2 = $$.state,
|
14806 | width = _$$$state2.width,
|
14807 | height = _$$$state2.height,
|
14808 | gridLines = $$.$el.gridLines,
|
14809 | $T = $$.$T,
|
14810 | xv = $$.xv.bind($$),
|
14811 | lines = gridLines.x.select("line"),
|
14812 | texts = gridLines.x.select("text");
|
14813 | lines = $T(lines, withTransition).attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? width : xv).attr("y1", isRotated ? xv : 0).attr("y2", isRotated ? xv : height);
|
14814 | texts = $T(texts, withTransition).attr("x", getGridTextX(!isRotated, width, height)).attr("y", xv).text(function (d) {
|
14815 | return d.text;
|
14816 | });
|
14817 | return [lines.style("opacity", null), texts.style("opacity", null)];
|
14818 | },
|
14819 | initFocusGrid: function initFocusGrid() {
|
14820 | var $$ = this,
|
14821 | config = $$.config,
|
14822 | clip = $$.state.clip,
|
14823 | $el = $$.$el,
|
14824 | isFront = config.grid_front,
|
14825 | className = "." + config_classes[isFront && $el.gridLines.main ? "gridLines" : "chart"] + (isFront ? " + *" : ""),
|
14826 | grid = $el.main.insert("g", className).attr("clip-path", clip.pathGrid).attr("class", config_classes.grid);
|
14827 | $el.grid.main = grid;
|
14828 | config.grid_x_show && grid.append("g").attr("class", config_classes.xgrids);
|
14829 | config.grid_y_show && grid.append("g").attr("class", config_classes.ygrids);
|
14830 |
|
14831 | if (config.interaction_enabled && config.grid_focus_show) {
|
14832 | grid.append("g").attr("class", config_classes.xgridFocus).append("line").attr("class", config_classes.xgridFocus);
|
14833 |
|
14834 | if (config.grid_focus_y && !config.tooltip_grouped) {
|
14835 | grid.append("g").attr("class", config_classes.ygridFocus).append("line").attr("class", config_classes.ygridFocus);
|
14836 | }
|
14837 | }
|
14838 | },
|
14839 |
|
14840 | |
14841 |
|
14842 |
|
14843 |
|
14844 |
|
14845 | showGridFocus: function showGridFocus(data) {
|
14846 | var $$ = this,
|
14847 | config = $$.config,
|
14848 | _$$$state3 = $$.state,
|
14849 | width = _$$$state3.width,
|
14850 | height = _$$$state3.height,
|
14851 | isRotated = config.axis_rotated,
|
14852 | focusEl = $$.$el.main.selectAll("line." + config_classes.xgridFocus + ", line." + config_classes.ygridFocus),
|
14853 | dataToShow = (data || [focusEl.datum()]).filter(function (d) {
|
14854 | return d && isValue($$.getBaseValue(d));
|
14855 | });
|
14856 |
|
14857 |
|
14858 | if (!config.tooltip_show || dataToShow.length === 0 || $$.hasType("bubble") || $$.hasArcType()) {
|
14859 | return;
|
14860 | }
|
14861 |
|
14862 | var isEdge = config.grid_focus_edge && !config.tooltip_grouped,
|
14863 | xx = $$.xx.bind($$);
|
14864 | focusEl.style("visibility", null).data(dataToShow.concat(dataToShow)).each(function (d) {
|
14865 | var el = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
14866 | pos = {
|
14867 | x: xx(d),
|
14868 | y: $$.getYScaleById(d.id)(d.value)
|
14869 | },
|
14870 | xy;
|
14871 |
|
14872 | if (el.classed(config_classes.xgridFocus)) {
|
14873 |
|
14874 | xy = isRotated ? [null,
|
14875 | pos.x,
|
14876 | isEdge ? pos.y : width,
|
14877 | pos.x
|
14878 | ] : [pos.x, isEdge ? pos.y : null, pos.x, height];
|
14879 | } else {
|
14880 | var isY2 = $$.axis.getId(d.id) === "y2";
|
14881 | xy = isRotated ? [pos.y,
|
14882 | isEdge && !isY2 ? pos.x : null,
|
14883 | pos.y,
|
14884 | isEdge && isY2 ? pos.x : height
|
14885 | ] : [isEdge && isY2 ? pos.x : null, pos.y, isEdge && !isY2 ? pos.x : width, pos.y];
|
14886 | }
|
14887 |
|
14888 | ["x1", "y1", "x2", "y2"].forEach(function (v, i) {
|
14889 | return el.attr(v, xy[i]);
|
14890 | });
|
14891 | });
|
14892 | smoothLines(focusEl, "grid");
|
14893 | $$.showCircleFocus == null ? void 0 : $$.showCircleFocus(data);
|
14894 | },
|
14895 | hideGridFocus: function hideGridFocus() {
|
14896 | var $$ = this,
|
14897 | _$$$state4 = $$.state,
|
14898 | inputType = _$$$state4.inputType,
|
14899 | resizing = _$$$state4.resizing,
|
14900 | main = $$.$el.main;
|
14901 |
|
14902 | if (inputType === "mouse" || !resizing) {
|
14903 | main.selectAll("line." + config_classes.xgridFocus + ", line." + config_classes.ygridFocus).style("visibility", "hidden");
|
14904 | $$.hideCircleFocus == null ? void 0 : $$.hideCircleFocus();
|
14905 | }
|
14906 | },
|
14907 | updateGridFocus: function updateGridFocus() {
|
14908 | var $$ = this,
|
14909 | _$$$state5 = $$.state,
|
14910 | inputType = _$$$state5.inputType,
|
14911 | width = _$$$state5.width,
|
14912 | height = _$$$state5.height,
|
14913 | resizing = _$$$state5.resizing,
|
14914 | grid = $$.$el.grid,
|
14915 | xgridFocus = grid.main.select("line." + config_classes.xgridFocus);
|
14916 |
|
14917 | if (inputType === "touch") {
|
14918 | if (xgridFocus.empty()) {
|
14919 | resizing && ($$.showCircleFocus == null ? void 0 : $$.showCircleFocus());
|
14920 | } else {
|
14921 | $$.showGridFocus();
|
14922 | }
|
14923 | } else {
|
14924 | var _isRotated = $$.config.axis_rotated;
|
14925 | xgridFocus.attr("x1", _isRotated ? 0 : -10).attr("x2", _isRotated ? width : -10).attr("y1", _isRotated ? -10 : 0).attr("y2", _isRotated ? -10 : height);
|
14926 | }
|
14927 |
|
14928 |
|
14929 |
|
14930 | return !0;
|
14931 | },
|
14932 | generateGridData: function generateGridData(type, scale) {
|
14933 | var $$ = this,
|
14934 | tickNum = $$.$el.main.select("." + config_classes.axisX).selectAll(".tick").size(),
|
14935 | gridData = [];
|
14936 |
|
14937 | if (type === "year") {
|
14938 | var xDomain = $$.getXDomain(),
|
14939 | _xDomain$map = xDomain.map(function (v) {
|
14940 | return v.getFullYear();
|
14941 | }),
|
14942 | firstYear = _xDomain$map[0],
|
14943 | lastYear = _xDomain$map[1];
|
14944 |
|
14945 | for (var i = firstYear; i <= lastYear; i++) {
|
14946 | gridData.push(new Date(i + "-01-01 00:00:00"));
|
14947 | }
|
14948 | } else {
|
14949 | gridData = scale.ticks(10);
|
14950 |
|
14951 | if (gridData.length > tickNum) {
|
14952 |
|
14953 | gridData = gridData.filter(function (d) {
|
14954 | return (d + "").indexOf(".") < 0;
|
14955 | });
|
14956 | }
|
14957 | }
|
14958 |
|
14959 | return gridData;
|
14960 | },
|
14961 | getGridFilterToRemove: function getGridFilterToRemove(params) {
|
14962 | return params ? function (line) {
|
14963 | var found = !1;
|
14964 | (isArray(params) ? params.concat() : [params]).forEach(function (param) {
|
14965 | if ("value" in param && line.value === param.value || "class" in param && line.class === param.class) {
|
14966 | found = !0;
|
14967 | }
|
14968 | });
|
14969 | return found;
|
14970 | } : function () {
|
14971 | return !0;
|
14972 | };
|
14973 | },
|
14974 | removeGridLines: function removeGridLines(params, forX) {
|
14975 | var $$ = this,
|
14976 | config = $$.config,
|
14977 | $T = $$.$T,
|
14978 | toRemove = $$.getGridFilterToRemove(params),
|
14979 | classLines = forX ? config_classes.xgridLines : config_classes.ygridLines,
|
14980 | classLine = forX ? config_classes.xgridLine : config_classes.ygridLine;
|
14981 | $T($$.$el.main.select("." + classLines).selectAll("." + classLine).filter(toRemove)).style("opacity", "0").remove();
|
14982 | var gridLines = "grid_" + (forX ? "x" : "y") + "_lines";
|
14983 | config[gridLines] = config[gridLines].filter(function toShow(line) {
|
14984 | return !toRemove(line);
|
14985 | });
|
14986 | }
|
14987 | });
|
14988 | ;
|
14989 |
|
14990 |
|
14991 |
|
14992 |
|
14993 |
|
14994 |
|
14995 |
|
14996 |
|
14997 | var region = ({
|
14998 | initRegion: function initRegion() {
|
14999 | var $$ = this,
|
15000 | $el = $$.$el;
|
15001 | $el.region.main = $el.main.insert("g", ":first-child").attr("clip-path", $$.state.clip.path).attr("class", config_classes.regions);
|
15002 | },
|
15003 | updateRegion: function updateRegion() {
|
15004 | var $$ = this,
|
15005 | config = $$.config,
|
15006 | region = $$.$el.region,
|
15007 | $T = $$.$T;
|
15008 |
|
15009 | if (!region.main) {
|
15010 | $$.initRegion();
|
15011 | }
|
15012 |
|
15013 |
|
15014 | region.main.style("visibility", $$.hasArcType() ? "hidden" : null);
|
15015 |
|
15016 | var list = region.main.selectAll("." + config_classes.region).data(config.regions);
|
15017 | $T(list.exit()).style("opacity", "0").remove();
|
15018 | list = list.enter().append("g").merge(list).attr("class", $$.classRegion.bind($$));
|
15019 | list.append("rect").style("fill-opacity", "0");
|
15020 | region.list = list;
|
15021 | },
|
15022 | redrawRegion: function redrawRegion(withTransition) {
|
15023 | var $$ = this,
|
15024 | region = $$.$el.region,
|
15025 | $T = $$.$T,
|
15026 | regions = region.list.select("rect");
|
15027 | regions = $T(regions, withTransition).attr("x", $$.regionX.bind($$)).attr("y", $$.regionY.bind($$)).attr("width", $$.regionWidth.bind($$)).attr("height", $$.regionHeight.bind($$));
|
15028 | return [regions.style("fill-opacity", function (d) {
|
15029 | return isValue(d.opacity) ? d.opacity : null;
|
15030 | }).on("end", function () {
|
15031 |
|
15032 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode).selectAll("rect:not([x])").remove();
|
15033 | })];
|
15034 | },
|
15035 | getRegionXY: function getRegionXY(type, d) {
|
15036 | var $$ = this,
|
15037 | config = $$.config,
|
15038 | scale = $$.scale,
|
15039 | isRotated = config.axis_rotated,
|
15040 | isX = type === "x",
|
15041 | key = "start",
|
15042 | currScale,
|
15043 | pos = 0;
|
15044 |
|
15045 | if (d.axis === "y" || d.axis === "y2") {
|
15046 | if (!isX) {
|
15047 | key = "end";
|
15048 | }
|
15049 |
|
15050 | if ((isX ? isRotated : !isRotated) && key in d) {
|
15051 | currScale = scale[d.axis];
|
15052 | pos = currScale(d[key]);
|
15053 | }
|
15054 | } else if ((isX ? !isRotated : isRotated) && key in d) {
|
15055 | currScale = scale.zoom || scale.x;
|
15056 | pos = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key]);
|
15057 | }
|
15058 |
|
15059 | return pos;
|
15060 | },
|
15061 | regionX: function regionX(d) {
|
15062 | return this.getRegionXY("x", d);
|
15063 | },
|
15064 | regionY: function regionY(d) {
|
15065 | return this.getRegionXY("y", d);
|
15066 | },
|
15067 | getRegionSize: function getRegionSize(type, d) {
|
15068 | var $$ = this,
|
15069 | config = $$.config,
|
15070 | scale = $$.scale,
|
15071 | state = $$.state,
|
15072 | isRotated = config.axis_rotated,
|
15073 | isWidth = type === "width",
|
15074 | start = $$[isWidth ? "regionX" : "regionY"](d),
|
15075 | currScale,
|
15076 | key = "end",
|
15077 | end = state[type];
|
15078 |
|
15079 | if (d.axis === "y" || d.axis === "y2") {
|
15080 | if (!isWidth) {
|
15081 | key = "start";
|
15082 | }
|
15083 |
|
15084 | if ((isWidth ? isRotated : !isRotated) && key in d) {
|
15085 | currScale = scale[d.axis];
|
15086 | end = currScale(d[key]);
|
15087 | }
|
15088 | } else if ((isWidth ? !isRotated : isRotated) && key in d) {
|
15089 | currScale = scale.zoom || scale.x;
|
15090 | end = currScale($$.axis.isTimeSeries() ? parseDate.call($$, d[key]) : d[key]);
|
15091 | }
|
15092 |
|
15093 | return end < start ? 0 : end - start;
|
15094 | },
|
15095 | regionWidth: function regionWidth(d) {
|
15096 | return this.getRegionSize("width", d);
|
15097 | },
|
15098 | regionHeight: function regionHeight(d) {
|
15099 | return this.getRegionSize("height", d);
|
15100 | },
|
15101 | isRegionOnX: function isRegionOnX(d) {
|
15102 | return !d.axis || d.axis === "x";
|
15103 | }
|
15104 | });
|
15105 | ;
|
15106 |
|
15107 |
|
15108 |
|
15109 |
|
15110 | var size_axis = ({
|
15111 | |
15112 |
|
15113 |
|
15114 |
|
15115 |
|
15116 |
|
15117 | getAxisSize: function getAxisSize(id) {
|
15118 | var $$ = this,
|
15119 | isRotated = $$.config.axis_rotated;
|
15120 | return isRotated && id === "x" || !isRotated && /y2?/.test(id) ? $$.getAxisWidthByAxisId(id, !0) : $$.getHorizontalAxisHeight(id);
|
15121 | },
|
15122 | getAxisWidthByAxisId: function getAxisWidthByAxisId(id, withoutRecompute) {
|
15123 | var $$ = this;
|
15124 |
|
15125 | if ($$.axis) {
|
15126 | var _$$$axis,
|
15127 | position = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.getLabelPositionById(id);
|
15128 |
|
15129 | return $$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40);
|
15130 | } else {
|
15131 | return 40;
|
15132 | }
|
15133 | },
|
15134 | getHorizontalAxisHeight: function getHorizontalAxisHeight(id) {
|
15135 | var $$ = this,
|
15136 | config = $$.config,
|
15137 | state = $$.state,
|
15138 | _state = state,
|
15139 | current = _state.current,
|
15140 | rotatedPadding = _state.rotatedPadding,
|
15141 | isLegendRight = _state.isLegendRight,
|
15142 | isLegendInset = _state.isLegendInset,
|
15143 | isRotated = config.axis_rotated,
|
15144 | h = 30;
|
15145 |
|
15146 | if (id === "x" && !config.axis_x_show) {
|
15147 | return 8;
|
15148 | }
|
15149 |
|
15150 | if (id === "x" && config.axis_x_height) {
|
15151 | return config.axis_x_height;
|
15152 | }
|
15153 |
|
15154 | if (id === "y" && !config.axis_y_show) {
|
15155 | return config.legend_show && !isLegendRight && !isLegendInset ? 10 : 1;
|
15156 | }
|
15157 |
|
15158 | if (id === "y2" && !config.axis_y2_show) {
|
15159 | return rotatedPadding.top;
|
15160 | }
|
15161 |
|
15162 | var rotate = $$.getAxisTickRotate(id);
|
15163 |
|
15164 | if ((id === "x" && !isRotated || /y2?/.test(id) && isRotated) && rotate) {
|
15165 | h = 30 + $$.axis.getMaxTickWidth(id) * Math.cos(Math.PI * (90 - Math.abs(rotate)) / 180);
|
15166 |
|
15167 | if (!config.axis_x_tick_multiline && current.height) {
|
15168 | if (h > current.height / 2) {
|
15169 | h = current.height / 2;
|
15170 | }
|
15171 | }
|
15172 | }
|
15173 |
|
15174 | return h + ($$.axis.getLabelPositionById(id).isInner ? 0 : 10) + (id === "y2" && !isRotated ? -10 : 0);
|
15175 | },
|
15176 | getEventRectWidth: function getEventRectWidth() {
|
15177 | return Math.max(0, this.axis.x.tickInterval());
|
15178 | },
|
15179 |
|
15180 | |
15181 |
|
15182 |
|
15183 |
|
15184 |
|
15185 |
|
15186 | getAxisTickRotate: function getAxisTickRotate(id) {
|
15187 | var $$ = this,
|
15188 | axis = $$.axis,
|
15189 | config = $$.config,
|
15190 | state = $$.state,
|
15191 | $el = $$.$el,
|
15192 | rotate = config["axis_" + id + "_tick_rotate"];
|
15193 |
|
15194 | if (id === "x") {
|
15195 | var allowedXAxisTypes = axis.isCategorized() || axis.isTimeSeries();
|
15196 |
|
15197 | if (config.axis_x_tick_fit && allowedXAxisTypes) {
|
15198 | var xTickCount = config.axis_x_tick_count,
|
15199 | currentXTicksLength = state.current.maxTickWidths.x.ticks.length,
|
15200 | tickCount = 0;
|
15201 |
|
15202 | if (xTickCount) {
|
15203 | tickCount = xTickCount > currentXTicksLength ? currentXTicksLength : xTickCount;
|
15204 | } else if (currentXTicksLength) {
|
15205 | tickCount = currentXTicksLength;
|
15206 | }
|
15207 |
|
15208 | if (tickCount !== state.axis.x.tickCount) {
|
15209 | var targets = $$.data.targets;
|
15210 | state.axis.x.padding = $$.getXDomainPadding([$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")], tickCount);
|
15211 | }
|
15212 |
|
15213 | state.axis.x.tickCount = tickCount;
|
15214 | }
|
15215 |
|
15216 | if ($el.svg && config.axis_x_tick_fit && !config.axis_x_tick_multiline && !config.axis_x_tick_culling && config.axis_x_tick_autorotate && allowedXAxisTypes) {
|
15217 | rotate = $$.needToRotateXAxisTickTexts() ? config.axis_x_tick_rotate : 0;
|
15218 | }
|
15219 | }
|
15220 |
|
15221 | return rotate;
|
15222 | },
|
15223 |
|
15224 | |
15225 |
|
15226 |
|
15227 |
|
15228 |
|
15229 | needToRotateXAxisTickTexts: function needToRotateXAxisTickTexts() {
|
15230 | var $$ = this,
|
15231 | _$$$state = $$.state,
|
15232 | axis = _$$$state.axis,
|
15233 | current = _$$$state.current,
|
15234 | xAxisLength = current.width - $$.getCurrentPaddingLeft(!1) - $$.getCurrentPaddingRight(),
|
15235 | tickCountWithPadding = axis.x.tickCount + axis.x.padding.left + axis.x.padding.right,
|
15236 | maxTickWidth = $$.axis.getMaxTickWidth("x"),
|
15237 | tickLength = tickCountWithPadding ? xAxisLength / tickCountWithPadding : 0;
|
15238 | return maxTickWidth > tickLength;
|
15239 | }
|
15240 | });
|
15241 | ;
|
15242 |
|
15243 |
|
15244 |
|
15245 |
|
15246 |
|
15247 |
|
15248 |
|
15249 |
|
15250 | var data_axis = ({
|
15251 | |
15252 |
|
15253 |
|
15254 |
|
15255 |
|
15256 |
|
15257 |
|
15258 |
|
15259 |
|
15260 |
|
15261 |
|
15262 |
|
15263 |
|
15264 |
|
15265 |
|
15266 | data_xs: {},
|
15267 |
|
15268 | |
15269 |
|
15270 |
|
15271 |
|
15272 |
|
15273 |
|
15274 |
|
15275 |
|
15276 |
|
15277 |
|
15278 |
|
15279 |
|
15280 |
|
15281 |
|
15282 |
|
15283 |
|
15284 |
|
15285 |
|
15286 |
|
15287 |
|
15288 |
|
15289 |
|
15290 |
|
15291 | data_xFormat: "%Y-%m-%d",
|
15292 |
|
15293 | |
15294 |
|
15295 |
|
15296 |
|
15297 |
|
15298 |
|
15299 |
|
15300 |
|
15301 |
|
15302 |
|
15303 |
|
15304 | data_xLocaltime: !0,
|
15305 |
|
15306 | |
15307 |
|
15308 |
|
15309 |
|
15310 |
|
15311 |
|
15312 |
|
15313 |
|
15314 |
|
15315 |
|
15316 |
|
15317 | data_xSort: !0,
|
15318 |
|
15319 | |
15320 |
|
15321 |
|
15322 |
|
15323 |
|
15324 |
|
15325 |
|
15326 |
|
15327 |
|
15328 |
|
15329 |
|
15330 |
|
15331 |
|
15332 |
|
15333 |
|
15334 | data_axes: {},
|
15335 |
|
15336 | |
15337 |
|
15338 |
|
15339 |
|
15340 |
|
15341 |
|
15342 |
|
15343 |
|
15344 |
|
15345 |
|
15346 |
|
15347 |
|
15348 |
|
15349 |
|
15350 |
|
15351 |
|
15352 |
|
15353 |
|
15354 |
|
15355 |
|
15356 |
|
15357 |
|
15358 |
|
15359 |
|
15360 |
|
15361 |
|
15362 |
|
15363 |
|
15364 | data_regions: {},
|
15365 |
|
15366 | |
15367 |
|
15368 |
|
15369 |
|
15370 |
|
15371 |
|
15372 |
|
15373 |
|
15374 |
|
15375 |
|
15376 |
|
15377 |
|
15378 |
|
15379 |
|
15380 |
|
15381 |
|
15382 |
|
15383 |
|
15384 | data_stack_normalize: !1
|
15385 | });
|
15386 | ;
|
15387 |
|
15388 |
|
15389 |
|
15390 |
|
15391 |
|
15392 |
|
15393 |
|
15394 |
|
15395 | var axis_x = ({
|
15396 | |
15397 |
|
15398 |
|
15399 |
|
15400 |
|
15401 |
|
15402 |
|
15403 |
|
15404 |
|
15405 |
|
15406 |
|
15407 | axis_x_clipPath: !0,
|
15408 |
|
15409 | |
15410 |
|
15411 |
|
15412 |
|
15413 |
|
15414 |
|
15415 |
|
15416 |
|
15417 |
|
15418 |
|
15419 |
|
15420 |
|
15421 |
|
15422 | axis_x_show: !0,
|
15423 |
|
15424 | |
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 | axis_x_type: "indexed",
|
15453 |
|
15454 | |
15455 |
|
15456 |
|
15457 |
|
15458 |
|
15459 |
|
15460 |
|
15461 |
|
15462 |
|
15463 |
|
15464 |
|
15465 |
|
15466 |
|
15467 |
|
15468 | axis_x_localtime: !0,
|
15469 |
|
15470 | |
15471 |
|
15472 |
|
15473 |
|
15474 |
|
15475 |
|
15476 |
|
15477 |
|
15478 |
|
15479 |
|
15480 |
|
15481 |
|
15482 |
|
15483 |
|
15484 | axis_x_categories: [],
|
15485 |
|
15486 | |
15487 |
|
15488 |
|
15489 |
|
15490 |
|
15491 |
|
15492 |
|
15493 |
|
15494 |
|
15495 |
|
15496 |
|
15497 |
|
15498 |
|
15499 |
|
15500 |
|
15501 | axis_x_tick_centered: !1,
|
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 |
|
15528 |
|
15529 |
|
15530 | axis_x_tick_format: undefined,
|
15531 |
|
15532 | |
15533 |
|
15534 |
|
15535 |
|
15536 |
|
15537 |
|
15538 |
|
15539 |
|
15540 |
|
15541 |
|
15542 |
|
15543 |
|
15544 |
|
15545 |
|
15546 |
|
15547 |
|
15548 |
|
15549 |
|
15550 |
|
15551 | axis_x_tick_culling: {},
|
15552 |
|
15553 | |
15554 |
|
15555 |
|
15556 |
|
15557 |
|
15558 |
|
15559 |
|
15560 |
|
15561 |
|
15562 |
|
15563 |
|
15564 |
|
15565 |
|
15566 |
|
15567 |
|
15568 |
|
15569 |
|
15570 | axis_x_tick_culling_max: 10,
|
15571 |
|
15572 | |
15573 |
|
15574 |
|
15575 |
|
15576 |
|
15577 |
|
15578 |
|
15579 |
|
15580 |
|
15581 |
|
15582 |
|
15583 |
|
15584 |
|
15585 |
|
15586 |
|
15587 |
|
15588 | axis_x_tick_count: undefined,
|
15589 |
|
15590 | |
15591 |
|
15592 |
|
15593 |
|
15594 |
|
15595 |
|
15596 |
|
15597 |
|
15598 |
|
15599 |
|
15600 |
|
15601 |
|
15602 |
|
15603 |
|
15604 |
|
15605 |
|
15606 | axis_x_tick_show: !0,
|
15607 |
|
15608 | |
15609 |
|
15610 |
|
15611 |
|
15612 |
|
15613 |
|
15614 |
|
15615 |
|
15616 |
|
15617 |
|
15618 |
|
15619 |
|
15620 |
|
15621 |
|
15622 |
|
15623 |
|
15624 |
|
15625 |
|
15626 | axis_x_tick_text_show: !0,
|
15627 |
|
15628 | |
15629 |
|
15630 |
|
15631 |
|
15632 |
|
15633 |
|
15634 |
|
15635 |
|
15636 |
|
15637 |
|
15638 |
|
15639 |
|
15640 |
|
15641 |
|
15642 |
|
15643 |
|
15644 |
|
15645 |
|
15646 |
|
15647 |
|
15648 | axis_x_tick_text_position: {
|
15649 | x: 0,
|
15650 | y: 0
|
15651 | },
|
15652 |
|
15653 | |
15654 |
|
15655 |
|
15656 |
|
15657 |
|
15658 |
|
15659 |
|
15660 |
|
15661 |
|
15662 |
|
15663 |
|
15664 |
|
15665 |
|
15666 |
|
15667 |
|
15668 |
|
15669 |
|
15670 |
|
15671 |
|
15672 | axis_x_tick_fit: !0,
|
15673 |
|
15674 | |
15675 |
|
15676 |
|
15677 |
|
15678 |
|
15679 |
|
15680 |
|
15681 |
|
15682 |
|
15683 |
|
15684 |
|
15685 |
|
15686 |
|
15687 |
|
15688 |
|
15689 |
|
15690 |
|
15691 |
|
15692 |
|
15693 |
|
15694 |
|
15695 |
|
15696 | axis_x_tick_values: null,
|
15697 |
|
15698 | |
15699 |
|
15700 |
|
15701 |
|
15702 |
|
15703 |
|
15704 |
|
15705 |
|
15706 |
|
15707 |
|
15708 |
|
15709 |
|
15710 |
|
15711 |
|
15712 |
|
15713 |
|
15714 |
|
15715 |
|
15716 |
|
15717 |
|
15718 |
|
15719 |
|
15720 |
|
15721 |
|
15722 |
|
15723 |
|
15724 |
|
15725 | axis_x_tick_autorotate: !1,
|
15726 |
|
15727 | |
15728 |
|
15729 |
|
15730 |
|
15731 |
|
15732 |
|
15733 |
|
15734 |
|
15735 |
|
15736 |
|
15737 |
|
15738 |
|
15739 |
|
15740 |
|
15741 |
|
15742 |
|
15743 |
|
15744 |
|
15745 |
|
15746 | axis_x_tick_rotate: 0,
|
15747 |
|
15748 | |
15749 |
|
15750 |
|
15751 |
|
15752 |
|
15753 |
|
15754 |
|
15755 |
|
15756 |
|
15757 |
|
15758 |
|
15759 |
|
15760 |
|
15761 |
|
15762 |
|
15763 | axis_x_tick_outer: !0,
|
15764 |
|
15765 | |
15766 |
|
15767 |
|
15768 |
|
15769 |
|
15770 |
|
15771 |
|
15772 |
|
15773 |
|
15774 |
|
15775 |
|
15776 |
|
15777 |
|
15778 |
|
15779 |
|
15780 |
|
15781 |
|
15782 |
|
15783 |
|
15784 |
|
15785 |
|
15786 |
|
15787 |
|
15788 |
|
15789 |
|
15790 |
|
15791 |
|
15792 |
|
15793 | axis_x_tick_multiline: !0,
|
15794 |
|
15795 | |
15796 |
|
15797 |
|
15798 |
|
15799 |
|
15800 |
|
15801 |
|
15802 |
|
15803 |
|
15804 |
|
15805 |
|
15806 |
|
15807 |
|
15808 |
|
15809 |
|
15810 |
|
15811 |
|
15812 | axis_x_tick_width: null,
|
15813 |
|
15814 | |
15815 |
|
15816 |
|
15817 |
|
15818 |
|
15819 |
|
15820 |
|
15821 |
|
15822 |
|
15823 |
|
15824 |
|
15825 |
|
15826 |
|
15827 |
|
15828 |
|
15829 |
|
15830 | axis_x_tick_tooltip: !1,
|
15831 |
|
15832 | |
15833 |
|
15834 |
|
15835 |
|
15836 |
|
15837 |
|
15838 |
|
15839 |
|
15840 |
|
15841 |
|
15842 |
|
15843 |
|
15844 |
|
15845 |
|
15846 |
|
15847 |
|
15848 |
|
15849 |
|
15850 |
|
15851 |
|
15852 |
|
15853 |
|
15854 |
|
15855 | axis_x_max: undefined,
|
15856 |
|
15857 | |
15858 |
|
15859 |
|
15860 |
|
15861 |
|
15862 |
|
15863 |
|
15864 |
|
15865 |
|
15866 |
|
15867 |
|
15868 |
|
15869 |
|
15870 |
|
15871 |
|
15872 |
|
15873 |
|
15874 |
|
15875 |
|
15876 |
|
15877 |
|
15878 |
|
15879 |
|
15880 | axis_x_min: undefined,
|
15881 |
|
15882 | |
15883 |
|
15884 |
|
15885 |
|
15886 |
|
15887 |
|
15888 |
|
15889 |
|
15890 |
|
15891 |
|
15892 |
|
15893 |
|
15894 |
|
15895 |
|
15896 |
|
15897 |
|
15898 |
|
15899 |
|
15900 |
|
15901 |
|
15902 |
|
15903 |
|
15904 |
|
15905 |
|
15906 |
|
15907 |
|
15908 |
|
15909 |
|
15910 |
|
15911 |
|
15912 |
|
15913 |
|
15914 |
|
15915 |
|
15916 |
|
15917 |
|
15918 |
|
15919 |
|
15920 |
|
15921 |
|
15922 |
|
15923 |
|
15924 | axis_x_padding: {},
|
15925 |
|
15926 | |
15927 |
|
15928 |
|
15929 |
|
15930 |
|
15931 |
|
15932 |
|
15933 |
|
15934 |
|
15935 |
|
15936 |
|
15937 |
|
15938 |
|
15939 |
|
15940 | axis_x_height: undefined,
|
15941 |
|
15942 | |
15943 |
|
15944 |
|
15945 |
|
15946 |
|
15947 |
|
15948 |
|
15949 |
|
15950 |
|
15951 |
|
15952 |
|
15953 |
|
15954 |
|
15955 |
|
15956 |
|
15957 |
|
15958 |
|
15959 |
|
15960 |
|
15961 |
|
15962 |
|
15963 |
|
15964 |
|
15965 |
|
15966 |
|
15967 |
|
15968 |
|
15969 |
|
15970 | axis_x_extent: undefined,
|
15971 |
|
15972 | |
15973 |
|
15974 |
|
15975 |
|
15976 |
|
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 |
|
16007 |
|
16008 |
|
16009 |
|
16010 |
|
16011 |
|
16012 |
|
16013 | axis_x_label: {},
|
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 |
|
16049 |
|
16050 |
|
16051 |
|
16052 | axis_x_axes: []
|
16053 | });
|
16054 | ;
|
16055 |
|
16056 |
|
16057 |
|
16058 |
|
16059 |
|
16060 |
|
16061 |
|
16062 |
|
16063 | var y = ({
|
16064 | |
16065 |
|
16066 |
|
16067 |
|
16068 |
|
16069 |
|
16070 |
|
16071 |
|
16072 |
|
16073 |
|
16074 |
|
16075 | axis_y_clipPath: !0,
|
16076 |
|
16077 | |
16078 |
|
16079 |
|
16080 |
|
16081 |
|
16082 |
|
16083 |
|
16084 |
|
16085 |
|
16086 |
|
16087 |
|
16088 |
|
16089 |
|
16090 | axis_y_show: !0,
|
16091 |
|
16092 | |
16093 |
|
16094 |
|
16095 |
|
16096 |
|
16097 |
|
16098 |
|
16099 |
|
16100 |
|
16101 |
|
16102 |
|
16103 |
|
16104 |
|
16105 |
|
16106 |
|
16107 |
|
16108 |
|
16109 |
|
16110 |
|
16111 |
|
16112 |
|
16113 |
|
16114 |
|
16115 |
|
16116 |
|
16117 | axis_y_type: "indexed",
|
16118 |
|
16119 | |
16120 |
|
16121 |
|
16122 |
|
16123 |
|
16124 |
|
16125 |
|
16126 |
|
16127 |
|
16128 |
|
16129 |
|
16130 |
|
16131 |
|
16132 |
|
16133 | axis_y_max: undefined,
|
16134 |
|
16135 | |
16136 |
|
16137 |
|
16138 |
|
16139 |
|
16140 |
|
16141 |
|
16142 |
|
16143 |
|
16144 |
|
16145 |
|
16146 |
|
16147 |
|
16148 |
|
16149 |
|
16150 | axis_y_min: undefined,
|
16151 |
|
16152 | |
16153 |
|
16154 |
|
16155 |
|
16156 |
|
16157 |
|
16158 |
|
16159 |
|
16160 |
|
16161 |
|
16162 |
|
16163 |
|
16164 |
|
16165 |
|
16166 | axis_y_inverted: !1,
|
16167 |
|
16168 | |
16169 |
|
16170 |
|
16171 |
|
16172 |
|
16173 |
|
16174 |
|
16175 |
|
16176 |
|
16177 |
|
16178 |
|
16179 |
|
16180 |
|
16181 | axis_y_center: undefined,
|
16182 |
|
16183 | |
16184 |
|
16185 |
|
16186 |
|
16187 |
|
16188 |
|
16189 |
|
16190 |
|
16191 |
|
16192 |
|
16193 |
|
16194 |
|
16195 |
|
16196 | axis_y_inner: !1,
|
16197 |
|
16198 | |
16199 |
|
16200 |
|
16201 |
|
16202 |
|
16203 |
|
16204 |
|
16205 |
|
16206 |
|
16207 |
|
16208 |
|
16209 |
|
16210 |
|
16211 |
|
16212 |
|
16213 |
|
16214 |
|
16215 |
|
16216 |
|
16217 |
|
16218 |
|
16219 |
|
16220 |
|
16221 |
|
16222 | axis_y_label: {},
|
16223 |
|
16224 | |
16225 |
|
16226 |
|
16227 |
|
16228 |
|
16229 |
|
16230 |
|
16231 |
|
16232 |
|
16233 |
|
16234 |
|
16235 |
|
16236 |
|
16237 |
|
16238 |
|
16239 |
|
16240 |
|
16241 |
|
16242 | axis_y_tick_format: undefined,
|
16243 |
|
16244 | |
16245 |
|
16246 |
|
16247 |
|
16248 |
|
16249 |
|
16250 |
|
16251 |
|
16252 |
|
16253 |
|
16254 |
|
16255 |
|
16256 |
|
16257 |
|
16258 |
|
16259 |
|
16260 |
|
16261 | axis_y_tick_culling: !1,
|
16262 |
|
16263 | |
16264 |
|
16265 |
|
16266 |
|
16267 |
|
16268 |
|
16269 |
|
16270 |
|
16271 |
|
16272 |
|
16273 |
|
16274 |
|
16275 |
|
16276 |
|
16277 |
|
16278 |
|
16279 |
|
16280 | axis_y_tick_culling_max: 5,
|
16281 |
|
16282 | |
16283 |
|
16284 |
|
16285 |
|
16286 |
|
16287 |
|
16288 |
|
16289 |
|
16290 |
|
16291 |
|
16292 |
|
16293 |
|
16294 |
|
16295 |
|
16296 |
|
16297 | axis_y_tick_outer: !0,
|
16298 |
|
16299 | |
16300 |
|
16301 |
|
16302 |
|
16303 |
|
16304 |
|
16305 |
|
16306 |
|
16307 |
|
16308 |
|
16309 |
|
16310 |
|
16311 |
|
16312 |
|
16313 |
|
16314 |
|
16315 |
|
16316 |
|
16317 |
|
16318 |
|
16319 | axis_y_tick_values: null,
|
16320 |
|
16321 | |
16322 |
|
16323 |
|
16324 |
|
16325 |
|
16326 |
|
16327 |
|
16328 |
|
16329 |
|
16330 |
|
16331 |
|
16332 |
|
16333 |
|
16334 |
|
16335 |
|
16336 |
|
16337 |
|
16338 | axis_y_tick_rotate: 0,
|
16339 |
|
16340 | |
16341 |
|
16342 |
|
16343 |
|
16344 |
|
16345 |
|
16346 |
|
16347 |
|
16348 |
|
16349 |
|
16350 |
|
16351 |
|
16352 |
|
16353 |
|
16354 |
|
16355 |
|
16356 | axis_y_tick_count: undefined,
|
16357 |
|
16358 | |
16359 |
|
16360 |
|
16361 |
|
16362 |
|
16363 |
|
16364 |
|
16365 |
|
16366 |
|
16367 |
|
16368 |
|
16369 |
|
16370 |
|
16371 |
|
16372 |
|
16373 |
|
16374 | axis_y_tick_show: !0,
|
16375 |
|
16376 | |
16377 |
|
16378 |
|
16379 |
|
16380 |
|
16381 |
|
16382 |
|
16383 |
|
16384 |
|
16385 |
|
16386 |
|
16387 |
|
16388 |
|
16389 |
|
16390 |
|
16391 |
|
16392 |
|
16393 |
|
16394 | axis_y_tick_stepSize: null,
|
16395 |
|
16396 | |
16397 |
|
16398 |
|
16399 |
|
16400 |
|
16401 |
|
16402 |
|
16403 |
|
16404 |
|
16405 |
|
16406 |
|
16407 |
|
16408 |
|
16409 |
|
16410 |
|
16411 |
|
16412 |
|
16413 |
|
16414 | axis_y_tick_text_show: !0,
|
16415 |
|
16416 | |
16417 |
|
16418 |
|
16419 |
|
16420 |
|
16421 |
|
16422 |
|
16423 |
|
16424 |
|
16425 |
|
16426 |
|
16427 |
|
16428 |
|
16429 |
|
16430 |
|
16431 |
|
16432 |
|
16433 |
|
16434 |
|
16435 |
|
16436 | axis_y_tick_text_position: {
|
16437 | x: 0,
|
16438 | y: 0
|
16439 | },
|
16440 |
|
16441 | |
16442 |
|
16443 |
|
16444 |
|
16445 |
|
16446 |
|
16447 |
|
16448 |
|
16449 |
|
16450 |
|
16451 |
|
16452 |
|
16453 |
|
16454 |
|
16455 |
|
16456 |
|
16457 |
|
16458 |
|
16459 |
|
16460 |
|
16461 |
|
16462 |
|
16463 |
|
16464 | axis_y_tick_time_value: undefined,
|
16465 |
|
16466 | |
16467 |
|
16468 |
|
16469 |
|
16470 |
|
16471 |
|
16472 |
|
16473 |
|
16474 |
|
16475 |
|
16476 |
|
16477 |
|
16478 |
|
16479 |
|
16480 |
|
16481 |
|
16482 |
|
16483 |
|
16484 |
|
16485 |
|
16486 |
|
16487 |
|
16488 |
|
16489 |
|
16490 |
|
16491 | axis_y_padding: {},
|
16492 |
|
16493 | |
16494 |
|
16495 |
|
16496 |
|
16497 |
|
16498 |
|
16499 |
|
16500 |
|
16501 |
|
16502 |
|
16503 |
|
16504 |
|
16505 |
|
16506 |
|
16507 | axis_y_default: undefined,
|
16508 |
|
16509 | |
16510 |
|
16511 |
|
16512 |
|
16513 |
|
16514 |
|
16515 |
|
16516 |
|
16517 |
|
16518 |
|
16519 |
|
16520 |
|
16521 |
|
16522 |
|
16523 |
|
16524 |
|
16525 |
|
16526 |
|
16527 |
|
16528 |
|
16529 |
|
16530 |
|
16531 |
|
16532 |
|
16533 |
|
16534 |
|
16535 |
|
16536 |
|
16537 |
|
16538 |
|
16539 |
|
16540 |
|
16541 |
|
16542 |
|
16543 |
|
16544 |
|
16545 |
|
16546 | axis_y_axes: []
|
16547 | });
|
16548 | ;
|
16549 |
|
16550 |
|
16551 |
|
16552 |
|
16553 |
|
16554 |
|
16555 |
|
16556 |
|
16557 | var y2 = ({
|
16558 | |
16559 |
|
16560 |
|
16561 |
|
16562 |
|
16563 |
|
16564 |
|
16565 |
|
16566 |
|
16567 |
|
16568 |
|
16569 |
|
16570 |
|
16571 |
|
16572 |
|
16573 |
|
16574 | axis_y2_show: !1,
|
16575 |
|
16576 | |
16577 |
|
16578 |
|
16579 |
|
16580 |
|
16581 |
|
16582 |
|
16583 |
|
16584 |
|
16585 |
|
16586 |
|
16587 |
|
16588 |
|
16589 |
|
16590 |
|
16591 |
|
16592 |
|
16593 |
|
16594 |
|
16595 |
|
16596 |
|
16597 |
|
16598 |
|
16599 |
|
16600 |
|
16601 | axis_y2_type: "indexed",
|
16602 |
|
16603 | |
16604 |
|
16605 |
|
16606 |
|
16607 |
|
16608 |
|
16609 |
|
16610 |
|
16611 |
|
16612 |
|
16613 |
|
16614 |
|
16615 |
|
16616 | axis_y2_max: undefined,
|
16617 |
|
16618 | |
16619 |
|
16620 |
|
16621 |
|
16622 |
|
16623 |
|
16624 |
|
16625 |
|
16626 |
|
16627 |
|
16628 |
|
16629 |
|
16630 |
|
16631 | axis_y2_min: undefined,
|
16632 |
|
16633 | |
16634 |
|
16635 |
|
16636 |
|
16637 |
|
16638 |
|
16639 |
|
16640 |
|
16641 |
|
16642 |
|
16643 |
|
16644 |
|
16645 |
|
16646 |
|
16647 | axis_y2_inverted: !1,
|
16648 |
|
16649 | |
16650 |
|
16651 |
|
16652 |
|
16653 |
|
16654 |
|
16655 |
|
16656 |
|
16657 |
|
16658 |
|
16659 |
|
16660 |
|
16661 |
|
16662 | axis_y2_center: undefined,
|
16663 |
|
16664 | |
16665 |
|
16666 |
|
16667 |
|
16668 |
|
16669 |
|
16670 |
|
16671 |
|
16672 |
|
16673 |
|
16674 |
|
16675 |
|
16676 |
|
16677 | axis_y2_inner: !1,
|
16678 |
|
16679 | |
16680 |
|
16681 |
|
16682 |
|
16683 |
|
16684 |
|
16685 |
|
16686 |
|
16687 |
|
16688 |
|
16689 |
|
16690 |
|
16691 |
|
16692 |
|
16693 |
|
16694 |
|
16695 |
|
16696 |
|
16697 |
|
16698 |
|
16699 |
|
16700 |
|
16701 |
|
16702 |
|
16703 | axis_y2_label: {},
|
16704 |
|
16705 | |
16706 |
|
16707 |
|
16708 |
|
16709 |
|
16710 |
|
16711 |
|
16712 |
|
16713 |
|
16714 |
|
16715 |
|
16716 |
|
16717 |
|
16718 |
|
16719 |
|
16720 |
|
16721 |
|
16722 | axis_y2_tick_format: undefined,
|
16723 |
|
16724 | |
16725 |
|
16726 |
|
16727 |
|
16728 |
|
16729 |
|
16730 |
|
16731 |
|
16732 |
|
16733 |
|
16734 |
|
16735 |
|
16736 |
|
16737 |
|
16738 |
|
16739 |
|
16740 |
|
16741 | axis_y2_tick_culling: !1,
|
16742 |
|
16743 | |
16744 |
|
16745 |
|
16746 |
|
16747 |
|
16748 |
|
16749 |
|
16750 |
|
16751 |
|
16752 |
|
16753 |
|
16754 |
|
16755 |
|
16756 |
|
16757 |
|
16758 |
|
16759 |
|
16760 | axis_y2_tick_culling_max: 5,
|
16761 |
|
16762 | |
16763 |
|
16764 |
|
16765 |
|
16766 |
|
16767 |
|
16768 |
|
16769 |
|
16770 |
|
16771 |
|
16772 |
|
16773 |
|
16774 |
|
16775 |
|
16776 |
|
16777 | axis_y2_tick_outer: !0,
|
16778 |
|
16779 | |
16780 |
|
16781 |
|
16782 |
|
16783 |
|
16784 |
|
16785 |
|
16786 |
|
16787 |
|
16788 |
|
16789 |
|
16790 |
|
16791 |
|
16792 |
|
16793 |
|
16794 |
|
16795 |
|
16796 |
|
16797 |
|
16798 |
|
16799 | axis_y2_tick_values: null,
|
16800 |
|
16801 | |
16802 |
|
16803 |
|
16804 |
|
16805 |
|
16806 |
|
16807 |
|
16808 |
|
16809 |
|
16810 |
|
16811 |
|
16812 |
|
16813 |
|
16814 |
|
16815 |
|
16816 |
|
16817 |
|
16818 | axis_y2_tick_rotate: 0,
|
16819 |
|
16820 | |
16821 |
|
16822 |
|
16823 |
|
16824 |
|
16825 |
|
16826 |
|
16827 |
|
16828 |
|
16829 |
|
16830 |
|
16831 |
|
16832 |
|
16833 |
|
16834 |
|
16835 |
|
16836 | axis_y2_tick_count: undefined,
|
16837 |
|
16838 | |
16839 |
|
16840 |
|
16841 |
|
16842 |
|
16843 |
|
16844 |
|
16845 |
|
16846 |
|
16847 |
|
16848 |
|
16849 |
|
16850 |
|
16851 |
|
16852 |
|
16853 |
|
16854 | axis_y2_tick_show: !0,
|
16855 |
|
16856 | |
16857 |
|
16858 |
|
16859 |
|
16860 |
|
16861 |
|
16862 |
|
16863 |
|
16864 |
|
16865 |
|
16866 |
|
16867 |
|
16868 |
|
16869 |
|
16870 |
|
16871 |
|
16872 |
|
16873 |
|
16874 | axis_y2_tick_stepSize: null,
|
16875 |
|
16876 | |
16877 |
|
16878 |
|
16879 |
|
16880 |
|
16881 |
|
16882 |
|
16883 |
|
16884 |
|
16885 |
|
16886 |
|
16887 |
|
16888 |
|
16889 |
|
16890 |
|
16891 |
|
16892 |
|
16893 |
|
16894 | axis_y2_tick_text_show: !0,
|
16895 |
|
16896 | |
16897 |
|
16898 |
|
16899 |
|
16900 |
|
16901 |
|
16902 |
|
16903 |
|
16904 |
|
16905 |
|
16906 |
|
16907 |
|
16908 |
|
16909 |
|
16910 |
|
16911 |
|
16912 |
|
16913 |
|
16914 |
|
16915 |
|
16916 | axis_y2_tick_text_position: {
|
16917 | x: 0,
|
16918 | y: 0
|
16919 | },
|
16920 |
|
16921 | |
16922 |
|
16923 |
|
16924 |
|
16925 |
|
16926 |
|
16927 |
|
16928 |
|
16929 |
|
16930 |
|
16931 |
|
16932 |
|
16933 |
|
16934 |
|
16935 |
|
16936 |
|
16937 |
|
16938 |
|
16939 |
|
16940 |
|
16941 |
|
16942 |
|
16943 |
|
16944 |
|
16945 | axis_y2_padding: {},
|
16946 |
|
16947 | |
16948 |
|
16949 |
|
16950 |
|
16951 |
|
16952 |
|
16953 |
|
16954 |
|
16955 |
|
16956 |
|
16957 |
|
16958 |
|
16959 |
|
16960 |
|
16961 | axis_y2_default: undefined,
|
16962 |
|
16963 | |
16964 |
|
16965 |
|
16966 |
|
16967 |
|
16968 |
|
16969 |
|
16970 |
|
16971 |
|
16972 |
|
16973 |
|
16974 |
|
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 | axis_y2_axes: []
|
17001 | });
|
17002 | ;
|
17003 |
|
17004 |
|
17005 | function axis_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
17006 |
|
17007 | function axis_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { axis_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { axis_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
17008 |
|
17009 |
|
17010 |
|
17011 |
|
17012 |
|
17013 |
|
17014 |
|
17015 |
|
17016 |
|
17017 |
|
17018 |
|
17019 |
|
17020 | var axis_axis = (axis_objectSpread(axis_objectSpread(axis_objectSpread({
|
17021 | |
17022 |
|
17023 |
|
17024 |
|
17025 |
|
17026 |
|
17027 |
|
17028 |
|
17029 |
|
17030 |
|
17031 |
|
17032 | axis_rotated: !1
|
17033 | }, axis_x), y), y2));
|
17034 | ;
|
17035 |
|
17036 |
|
17037 |
|
17038 |
|
17039 |
|
17040 |
|
17041 |
|
17042 |
|
17043 | var common_grid = ({
|
17044 | |
17045 |
|
17046 |
|
17047 |
|
17048 |
|
17049 |
|
17050 |
|
17051 |
|
17052 |
|
17053 |
|
17054 |
|
17055 |
|
17056 |
|
17057 |
|
17058 |
|
17059 |
|
17060 |
|
17061 |
|
17062 |
|
17063 |
|
17064 |
|
17065 |
|
17066 |
|
17067 |
|
17068 |
|
17069 |
|
17070 |
|
17071 |
|
17072 |
|
17073 |
|
17074 |
|
17075 |
|
17076 |
|
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 | grid_x_show: !1,
|
17103 | grid_x_type: "tick",
|
17104 | grid_x_lines: [],
|
17105 | grid_y_show: !1,
|
17106 | grid_y_lines: [],
|
17107 | grid_y_ticks: 10,
|
17108 | grid_focus_edge: !1,
|
17109 | grid_focus_show: !0,
|
17110 | grid_focus_y: !1,
|
17111 | grid_front: !1,
|
17112 | grid_lines_front: !0
|
17113 | });
|
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 | var api = [api_axis, api_category, grid_x, grid_y, flow, group, api_regions, x];
|
17145 | var internal = [Axis, clip, eventrect, interactions_flow, grid, region, size_axis];
|
17146 | var options = [data_axis, axis_axis, common_grid];
|
17147 |
|
17148 | var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(12);
|
17149 | ;
|
17150 |
|
17151 |
|
17152 |
|
17153 |
|
17154 |
|
17155 |
|
17156 |
|
17157 |
|
17158 |
|
17159 |
|
17160 | var arc = ({
|
17161 | initPie: function initPie() {
|
17162 | var $$ = this,
|
17163 | config = $$.config,
|
17164 | dataType = config.data_type,
|
17165 | padding = config.pie_padding,
|
17166 | startingAngle = config[dataType + "_startingAngle"] || 0,
|
17167 | padAngle = ($$.hasType("pie") && padding ? padding * .01 : config[dataType + "_padAngle"]) || 0;
|
17168 | $$.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(function (d) {
|
17169 | return d.values.reduce(function (a, b) {
|
17170 | return a + b.value;
|
17171 | }, 0);
|
17172 | }).sort($$.getSortCompareFn.bind($$)(!0));
|
17173 | },
|
17174 | updateRadius: function updateRadius() {
|
17175 | var $$ = this,
|
17176 | config = $$.config,
|
17177 | state = $$.state,
|
17178 | padding = config.pie_padding,
|
17179 | w = config.gauge_width || config.donut_width,
|
17180 | gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length * config.gauge_arcs_minWidth;
|
17181 |
|
17182 | state.radiusExpanded = Math.min(state.arcWidth, state.arcHeight) / 2 * ($$.hasMultiArcGauge() ? .85 : 1);
|
17183 | state.radius = state.radiusExpanded * .95;
|
17184 | state.innerRadiusRatio = w ? (state.radius - w) / state.radius : .6;
|
17185 | state.gaugeArcWidth = w || (gaugeArcWidth <= state.radius - state.innerRadius ? state.radius - state.innerRadius : gaugeArcWidth <= state.radius ? gaugeArcWidth : state.radius);
|
17186 | var innerRadius = config.pie_innerRadius || (padding ? padding * (state.innerRadiusRatio + .1) : 0);
|
17187 |
|
17188 | state.outerRadius = config.pie_outerRadius;
|
17189 | state.innerRadius = $$.hasType("donut") || $$.hasType("gauge") ? state.radius * state.innerRadiusRatio : innerRadius;
|
17190 | },
|
17191 |
|
17192 | |
17193 |
|
17194 |
|
17195 |
|
17196 |
|
17197 |
|
17198 | getRadius: function getRadius(d) {
|
17199 | var $$ = this,
|
17200 | data = d == null ? void 0 : d.data,
|
17201 | _$$$state = $$.state,
|
17202 | innerRadius = _$$$state.innerRadius,
|
17203 | outerRadius = _$$$state.outerRadius;
|
17204 |
|
17205 | if (!isNumber(innerRadius) && data) {
|
17206 | innerRadius = innerRadius[data.id] || 0;
|
17207 | }
|
17208 |
|
17209 | if (isObject(outerRadius) && data && data.id in outerRadius) {
|
17210 | outerRadius = outerRadius[data.id];
|
17211 | } else if (!isNumber(outerRadius)) {
|
17212 | outerRadius = $$.state.radius;
|
17213 | }
|
17214 |
|
17215 | return {
|
17216 | innerRadius: innerRadius,
|
17217 | outerRadius: outerRadius
|
17218 | };
|
17219 | },
|
17220 | updateArc: function updateArc() {
|
17221 | var $$ = this;
|
17222 | $$.updateRadius();
|
17223 | $$.svgArc = $$.getSvgArc();
|
17224 | $$.svgArcExpanded = $$.getSvgArcExpanded();
|
17225 | },
|
17226 | getArcLength: function getArcLength() {
|
17227 | var $$ = this,
|
17228 | config = $$.config,
|
17229 | arcLengthInPercent = config.gauge_arcLength * 3.6,
|
17230 | len = 2 * (arcLengthInPercent / 360);
|
17231 |
|
17232 | if (arcLengthInPercent < -360) {
|
17233 | len = -2;
|
17234 | } else if (arcLengthInPercent > 360) {
|
17235 | len = 2;
|
17236 | }
|
17237 |
|
17238 | return len * Math.PI;
|
17239 | },
|
17240 | getStartAngle: function getStartAngle() {
|
17241 | var $$ = this,
|
17242 | config = $$.config,
|
17243 | isFullCircle = config.gauge_fullCircle,
|
17244 | defaultStartAngle = -1 * Math.PI / 2,
|
17245 | defaultEndAngle = Math.PI / 2,
|
17246 | startAngle = config.gauge_startingAngle;
|
17247 |
|
17248 | if (!isFullCircle && startAngle <= defaultStartAngle) {
|
17249 | startAngle = defaultStartAngle;
|
17250 | } else if (!isFullCircle && startAngle >= defaultEndAngle) {
|
17251 | startAngle = defaultEndAngle;
|
17252 | } else if (startAngle > Math.PI || startAngle < -1 * Math.PI) {
|
17253 | startAngle = Math.PI;
|
17254 | }
|
17255 |
|
17256 | return startAngle;
|
17257 | },
|
17258 | updateAngle: function updateAngle(dValue) {
|
17259 | var $$ = this,
|
17260 | config = $$.config,
|
17261 | state = $$.state,
|
17262 | pie = $$.pie,
|
17263 | d = dValue,
|
17264 | found = !1;
|
17265 |
|
17266 | if (!config) {
|
17267 | return null;
|
17268 | }
|
17269 |
|
17270 | var gStart = $$.getStartAngle(),
|
17271 | radius = config.gauge_fullCircle ? $$.getArcLength() : gStart * -2;
|
17272 |
|
17273 | if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
|
17274 | var _config = config,
|
17275 | min = _config.gauge_min,
|
17276 | max = _config.gauge_max,
|
17277 | totalSum = $$.getTotalDataSum(state.rendered);
|
17278 |
|
17279 | pie = pie.startAngle(gStart).endAngle(radius * ((totalSum - min) / (max - min)) + gStart);
|
17280 | }
|
17281 |
|
17282 | pie($$.filterTargetsToShow()).forEach(function (t, i) {
|
17283 | if (!found && t.data.id === d.data.id) {
|
17284 | found = !0;
|
17285 | d = t;
|
17286 | d.index = i;
|
17287 | }
|
17288 | });
|
17289 |
|
17290 | if (isNaN(d.startAngle)) {
|
17291 | d.startAngle = 0;
|
17292 | }
|
17293 |
|
17294 | if (isNaN(d.endAngle)) {
|
17295 | d.endAngle = d.startAngle;
|
17296 | }
|
17297 |
|
17298 | if (d.data && $$.hasMultiArcGauge()) {
|
17299 | var gMin = config.gauge_min,
|
17300 | gMax = config.gauge_max,
|
17301 | gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : gMax - gMin;
|
17302 | d.startAngle = gStart;
|
17303 | d.endAngle = gStart + radius / (gMax - gMin) * gValue;
|
17304 | }
|
17305 |
|
17306 | return found ? d : null;
|
17307 | },
|
17308 | getSvgArc: function getSvgArc() {
|
17309 | var $$ = this,
|
17310 | state = $$.state,
|
17311 | singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
|
17312 | hasMultiArcGauge = $$.hasMultiArcGauge(),
|
17313 | arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
|
17314 | var _$$$getRadius = $$.getRadius(d),
|
17315 | innerRadius = _$$$getRadius.innerRadius;
|
17316 |
|
17317 | return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : isNumber(innerRadius) ? innerRadius : 0;
|
17318 | }).outerRadius(function (d) {
|
17319 | var _$$$getRadius2 = $$.getRadius(d),
|
17320 | outerRadius = _$$$getRadius2.outerRadius;
|
17321 |
|
17322 | return hasMultiArcGauge ? state.radius - singleArcWidth * d.index : outerRadius;
|
17323 | }),
|
17324 | newArc = function (d, withoutUpdate) {
|
17325 | var path = "M 0 0";
|
17326 |
|
17327 | if (d.value || d.data) {
|
17328 | var updated = !withoutUpdate && $$.updateAngle(d);
|
17329 |
|
17330 | if (withoutUpdate) {
|
17331 | path = arc(d);
|
17332 | } else if (updated) {
|
17333 | path = arc(updated);
|
17334 | }
|
17335 | }
|
17336 |
|
17337 | return path;
|
17338 | };
|
17339 |
|
17340 |
|
17341 | newArc.centroid = arc.centroid;
|
17342 | return newArc;
|
17343 | },
|
17344 | getSvgArcExpanded: function getSvgArcExpanded(rate) {
|
17345 | var $$ = this,
|
17346 | state = $$.state,
|
17347 | newRate = rate || 1,
|
17348 | singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
|
17349 | hasMultiArcGauge = $$.hasMultiArcGauge(),
|
17350 | expandWidth = Math.min(state.radiusExpanded * newRate - state.radius, singleArcWidth * .8 - (1 - newRate) * 100),
|
17351 | arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
|
17352 | return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : $$.getRadius(d).innerRadius;
|
17353 | }).outerRadius(function (d) {
|
17354 | var radius;
|
17355 |
|
17356 | if (hasMultiArcGauge) {
|
17357 | radius = state.radius - singleArcWidth * d.index + expandWidth;
|
17358 | } else {
|
17359 | var _$$$getRadius3 = $$.getRadius(d),
|
17360 | outerRadius = _$$$getRadius3.outerRadius,
|
17361 | radiusExpanded = state.radiusExpanded;
|
17362 |
|
17363 | if (state.radius !== outerRadius) {
|
17364 | radiusExpanded -= Math.abs(state.radius - outerRadius);
|
17365 | }
|
17366 |
|
17367 | radius = radiusExpanded * newRate;
|
17368 | }
|
17369 |
|
17370 | return radius;
|
17371 | });
|
17372 | return function (d) {
|
17373 | var updated = $$.updateAngle(d);
|
17374 | return updated ? arc(updated) : "M 0 0";
|
17375 | };
|
17376 | },
|
17377 | getArc: function getArc(d, withoutUpdate, force) {
|
17378 | return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0";
|
17379 | },
|
17380 | transformForArcLabel: function transformForArcLabel(d) {
|
17381 | var $$ = this,
|
17382 | config = $$.config,
|
17383 | radiusExpanded = $$.state.radiusExpanded,
|
17384 | updated = $$.updateAngle(d),
|
17385 | translate = "";
|
17386 |
|
17387 | if (updated) {
|
17388 | if ($$.hasMultiArcGauge()) {
|
17389 | var y1 = Math.sin(updated.endAngle - Math.PI / 2),
|
17390 | x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + 25),
|
17391 | y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
|
17392 | translate = "translate(" + x + "," + y + ")";
|
17393 | } else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
|
17394 | var _$$$getRadius4 = $$.getRadius(d),
|
17395 | outerRadius = _$$$getRadius4.outerRadius,
|
17396 | c = this.svgArc.centroid(updated),
|
17397 | _c$map = c.map(function (v) {
|
17398 | return isNaN(v) ? 0 : v;
|
17399 | }),
|
17400 | x = _c$map[0],
|
17401 | y = _c$map[1],
|
17402 | h = Math.sqrt(x * x + y * y),
|
17403 | ratio = $$.hasType("donut") && config.donut_label_ratio || $$.hasType("pie") && config.pie_label_ratio;
|
17404 |
|
17405 | if (ratio) {
|
17406 | ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
|
17407 | } else {
|
17408 | ratio = outerRadius && (h ? (36 / outerRadius > .375 ? 1.175 - 36 / outerRadius : .8) * outerRadius / h : 0);
|
17409 | }
|
17410 |
|
17411 | translate = "translate(" + x * ratio + "," + y * ratio + ")";
|
17412 | }
|
17413 | }
|
17414 |
|
17415 | return translate;
|
17416 | },
|
17417 | convertToArcData: function convertToArcData(d) {
|
17418 | return this.addName({
|
17419 | id: d.data ? d.data.id : d.id,
|
17420 | value: d.value,
|
17421 | ratio: this.getRatio("arc", d),
|
17422 | index: d.index
|
17423 | });
|
17424 | },
|
17425 | textForArcLabel: function textForArcLabel(selection) {
|
17426 | var $$ = this,
|
17427 | hasGauge = $$.hasType("gauge");
|
17428 |
|
17429 | if ($$.shouldShowArcLabel()) {
|
17430 | selection.style("fill", $$.updateTextColor.bind($$)).attr("filter", $$.updateTextBacgroundColor.bind($$)).each(function (d) {
|
17431 | var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
17432 | updated = $$.updateAngle(d),
|
17433 | ratio = $$.getRatio("arc", updated),
|
17434 | isUnderThreshold = $$.meetsLabelThreshold(ratio, $$.hasType("donut") && "donut" || $$.hasType("gauge") && "gauge" || $$.hasType("pie") && "pie");
|
17435 |
|
17436 | if (isUnderThreshold) {
|
17437 | var value = (updated || d).value,
|
17438 | text = ($$.getArcLabelFormat() || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
|
17439 | setTextValue(node, text, [-1, 1], hasGauge);
|
17440 | } else {
|
17441 | node.text("");
|
17442 | }
|
17443 | });
|
17444 | }
|
17445 | },
|
17446 | expandArc: function expandArc(targetIds) {
|
17447 | var $$ = this,
|
17448 | transiting = $$.state.transiting,
|
17449 | $el = $$.$el;
|
17450 |
|
17451 |
|
17452 | if (transiting) {
|
17453 | var interval = setInterval(function () {
|
17454 | if (!transiting) {
|
17455 | clearInterval(interval);
|
17456 | $el.legend.selectAll("." + config_classes.legendItemFocused).size() > 0 && $$.expandArc(targetIds);
|
17457 | }
|
17458 | }, 10);
|
17459 | return;
|
17460 | }
|
17461 |
|
17462 | var newTargetIds = $$.mapToTargetIds(targetIds);
|
17463 | $el.svg.selectAll($$.selectorTargets(newTargetIds, "." + config_classes.chartArc)).each(function (d) {
|
17464 | if (!$$.shouldExpand(d.data.id)) {
|
17465 | return;
|
17466 | }
|
17467 |
|
17468 | var expandDuration = $$.getExpandConfig(d.data.id, "duration"),
|
17469 | svgArcExpandedSub = $$.getSvgArcExpanded($$.getExpandConfig(d.data.id, "rate"));
|
17470 | (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attr("d", $$.svgArcExpanded).transition().duration(expandDuration * 2).attr("d", svgArcExpandedSub);
|
17471 | });
|
17472 | },
|
17473 | unexpandArc: function unexpandArc(targetIds) {
|
17474 | var $$ = this,
|
17475 | transiting = $$.state.transiting,
|
17476 | svg = $$.$el.svg;
|
17477 |
|
17478 | if (transiting) {
|
17479 | return;
|
17480 | }
|
17481 |
|
17482 | var newTargetIds = $$.mapToTargetIds(targetIds);
|
17483 | svg.selectAll($$.selectorTargets(newTargetIds, "." + config_classes.chartArc)).selectAll("path").transition().duration(function (d) {
|
17484 | return $$.getExpandConfig(d.data.id, "duration");
|
17485 | }).attr("d", $$.svgArc);
|
17486 | svg.selectAll("" + config_classes.arc).style("opacity", null);
|
17487 | },
|
17488 |
|
17489 | |
17490 |
|
17491 |
|
17492 |
|
17493 |
|
17494 |
|
17495 |
|
17496 | getExpandConfig: function getExpandConfig(id, key) {
|
17497 | var $$ = this,
|
17498 | config = $$.config,
|
17499 | type;
|
17500 |
|
17501 | if ($$.isDonutType(id)) {
|
17502 | type = "donut";
|
17503 | } else if ($$.isGaugeType(id)) {
|
17504 | type = "gauge";
|
17505 | } else if ($$.isPieType(id)) {
|
17506 | type = "pie";
|
17507 | }
|
17508 |
|
17509 | return type ? config[type + "_expand_" + key] : {
|
17510 | duration: 50,
|
17511 | rate: .98
|
17512 | }[key];
|
17513 | },
|
17514 | shouldExpand: function shouldExpand(id) {
|
17515 | var $$ = this,
|
17516 | config = $$.config;
|
17517 | return $$.isDonutType(id) && config.donut_expand || $$.isGaugeType(id) && config.gauge_expand || $$.isPieType(id) && config.pie_expand;
|
17518 | },
|
17519 | shouldShowArcLabel: function shouldShowArcLabel() {
|
17520 | var $$ = this,
|
17521 | config = $$.config;
|
17522 | return ["pie", "donut", "gauge"].some(function (v) {
|
17523 | return $$.hasType(v) && config[v + "_label_show"];
|
17524 | });
|
17525 | },
|
17526 | getArcLabelFormat: function getArcLabelFormat() {
|
17527 | var $$ = this,
|
17528 | config = $$.config,
|
17529 | format = config.pie_label_format;
|
17530 |
|
17531 | if ($$.hasType("gauge")) {
|
17532 | format = config.gauge_label_format;
|
17533 | } else if ($$.hasType("donut")) {
|
17534 | format = config.donut_label_format;
|
17535 | }
|
17536 |
|
17537 | return isFunction(format) ? format.bind($$.api) : format;
|
17538 | },
|
17539 | getArcTitle: function getArcTitle() {
|
17540 | var $$ = this,
|
17541 | type = $$.hasType("donut") && "donut" || $$.hasType("gauge") && "gauge";
|
17542 | return type ? $$.config[type + "_title"] : "";
|
17543 | },
|
17544 | updateTargetsForArc: function updateTargetsForArc(targets) {
|
17545 | var $$ = this,
|
17546 | $el = $$.$el,
|
17547 | hasGauge = $$.hasType("gauge"),
|
17548 | classChartArc = $$.getChartClass("Arc"),
|
17549 | classArcs = $$.getClass("arcs", !0),
|
17550 | classFocus = $$.classFocus.bind($$),
|
17551 | chartArcs = $el.main.select("." + config_classes.chartArcs),
|
17552 | mainPieUpdate = chartArcs.selectAll("." + config_classes.chartArc).data($$.pie(targets)).attr("class", function (d) {
|
17553 | return classChartArc(d) + classFocus(d.data);
|
17554 | }),
|
17555 | mainPieEnter = mainPieUpdate.enter().append("g").attr("class", classChartArc);
|
17556 | mainPieEnter.append("g").attr("class", classArcs).merge(mainPieUpdate);
|
17557 | mainPieEnter.append("text").attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" : ".35em").style("opacity", "0").style("text-anchor", "middle").style("pointer-events", "none");
|
17558 | $el.text = chartArcs.selectAll("." + config_classes.target + " text");
|
17559 |
|
17560 | },
|
17561 | initArc: function initArc() {
|
17562 | var $$ = this,
|
17563 | $el = $$.$el;
|
17564 | $el.arcs = $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartArcs).attr("transform", $$.getTranslate("arc"));
|
17565 | $$.setArcTitle();
|
17566 | },
|
17567 |
|
17568 | |
17569 |
|
17570 |
|
17571 |
|
17572 | setArcTitle: function setArcTitle() {
|
17573 | var $$ = this,
|
17574 | title = $$.getArcTitle(),
|
17575 | hasGauge = $$.hasType("gauge");
|
17576 |
|
17577 | if (title) {
|
17578 | var text = $$.$el.arcs.append("text").attr("class", config_classes[hasGauge ? "chartArcsGaugeTitle" : "chartArcsTitle"]).style("text-anchor", "middle");
|
17579 | hasGauge && text.attr("dy", "-0.3em");
|
17580 | setTextValue(text, title, hasGauge ? undefined : [-.6, 1.35], !0);
|
17581 | }
|
17582 | },
|
17583 | redrawArc: function redrawArc(duration, durationForExit, withTransform) {
|
17584 | var $$ = this,
|
17585 | config = $$.config,
|
17586 | state = $$.state,
|
17587 | main = $$.$el.main,
|
17588 | hasInteraction = config.interaction_enabled,
|
17589 | isSelectable = hasInteraction && config.data_selection_isselectable,
|
17590 | mainArc = main.selectAll("." + config_classes.arcs).selectAll("." + config_classes.arc).data($$.arcData.bind($$));
|
17591 | mainArc.exit().transition().duration(durationForExit).style("opacity", "0").remove();
|
17592 | mainArc = mainArc.enter().append("path").attr("class", $$.getClass("arc", !0)).style("fill", function (d) {
|
17593 | return $$.color(d.data);
|
17594 | }).style("cursor", function (d) {
|
17595 | var _isSelectable;
|
17596 |
|
17597 | return (_isSelectable = isSelectable) != null && _isSelectable.bind != null && _isSelectable.bind($$.api)(d) ? "pointer" : null;
|
17598 | }).style("opacity", "0").each(function (d) {
|
17599 | if ($$.isGaugeType(d.data)) {
|
17600 | d.startAngle = config.gauge_startingAngle;
|
17601 | d.endAngle = config.gauge_startingAngle;
|
17602 | }
|
17603 |
|
17604 | this._current = d;
|
17605 | }).merge(mainArc);
|
17606 |
|
17607 | if ($$.hasType("gauge")) {
|
17608 | $$.updateGaugeMax();
|
17609 | $$.hasMultiArcGauge() && $$.redrawMultiArcGauge();
|
17610 | }
|
17611 |
|
17612 | mainArc.attr("transform", function (d) {
|
17613 | return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : "";
|
17614 | }).style("opacity", function (d) {
|
17615 | return d === this._current ? "0" : null;
|
17616 | }).each(function () {
|
17617 | state.transiting = !0;
|
17618 | }).transition().duration(duration).attrTween("d", function (d) {
|
17619 | var updated = $$.updateAngle(d);
|
17620 |
|
17621 | if (!updated) {
|
17622 | return function () {
|
17623 | return "M 0 0";
|
17624 | };
|
17625 | }
|
17626 |
|
17627 | if (isNaN(this._current.startAngle)) {
|
17628 | this._current.startAngle = 0;
|
17629 | }
|
17630 |
|
17631 | if (isNaN(this._current.endAngle)) {
|
17632 | this._current.endAngle = this._current.startAngle;
|
17633 | }
|
17634 |
|
17635 | var interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(this._current, updated);
|
17636 | this._current = interpolate(0);
|
17637 | return function (t) {
|
17638 | var interpolated = interpolate(t);
|
17639 | interpolated.data = d.data;
|
17640 |
|
17641 | return $$.getArc(interpolated, !0);
|
17642 | };
|
17643 | }).attr("transform", withTransform ? "scale(1)" : "").style("fill", function (d) {
|
17644 | var color;
|
17645 |
|
17646 | if ($$.levelColor) {
|
17647 | color = $$.levelColor(d.data.values[0].value);
|
17648 |
|
17649 | config.data_colors[d.data.id] = color;
|
17650 | } else {
|
17651 | color = $$.color(d.data);
|
17652 | }
|
17653 |
|
17654 | return color;
|
17655 | })
|
17656 | .style("opacity", null).call(endall, function () {
|
17657 | if ($$.levelColor) {
|
17658 | var path = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
17659 | d = path.datum();
|
17660 | $$.updateLegendItemColor(d.data.id, path.style("fill"));
|
17661 | }
|
17662 |
|
17663 | state.transiting = !1;
|
17664 | callFn(config.onrendered, $$.api);
|
17665 | });
|
17666 |
|
17667 | hasInteraction && $$.bindArcEvent(mainArc);
|
17668 | $$.hasType("gauge") && $$.redrawBackgroundArcs();
|
17669 | $$.redrawArcText(duration);
|
17670 | },
|
17671 | redrawBackgroundArcs: function redrawBackgroundArcs() {
|
17672 | var $$ = this,
|
17673 | config = $$.config,
|
17674 | state = $$.state,
|
17675 | hasMultiArcGauge = $$.hasMultiArcGauge(),
|
17676 | isFullCircle = config.gauge_fullCircle,
|
17677 | startAngle = $$.getStartAngle(),
|
17678 | endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1,
|
17679 | backgroundArc = $$.$el.arcs.select((hasMultiArcGauge ? "g" : "") + "." + config_classes.chartArcsBackground);
|
17680 |
|
17681 | if (hasMultiArcGauge) {
|
17682 | var index = 0;
|
17683 | backgroundArc = backgroundArc.selectAll("path." + config_classes.chartArcsBackground).data($$.data.targets);
|
17684 | backgroundArc.enter().append("path").attr("class", function (d, i) {
|
17685 | return config_classes.chartArcsBackground + " " + config_classes.chartArcsBackground + "-" + i;
|
17686 | }).merge(backgroundArc).style("fill", config.gauge_background || null).attr("d", function (_ref2) {
|
17687 | var id = _ref2.id;
|
17688 |
|
17689 | if (state.hiddenTargetIds.indexOf(id) >= 0) {
|
17690 | return "M 0 0";
|
17691 | }
|
17692 |
|
17693 | var d = {
|
17694 | data: [{
|
17695 | value: config.gauge_max
|
17696 | }],
|
17697 | startAngle: startAngle,
|
17698 | endAngle: endAngle,
|
17699 | index: index++
|
17700 | };
|
17701 | return $$.getArc(d, !0, !0);
|
17702 | });
|
17703 | backgroundArc.exit().remove();
|
17704 | } else {
|
17705 | backgroundArc.attr("d", function () {
|
17706 | var d = {
|
17707 | data: [{
|
17708 | value: config.gauge_max
|
17709 | }],
|
17710 | startAngle: startAngle,
|
17711 | endAngle: endAngle
|
17712 | };
|
17713 | return $$.getArc(d, !0, !0);
|
17714 | });
|
17715 | }
|
17716 | },
|
17717 | bindArcEvent: function bindArcEvent(arc) {
|
17718 | var $$ = this,
|
17719 | config = $$.config,
|
17720 | state = $$.state,
|
17721 | isTouch = state.inputType === "touch",
|
17722 | isMouse = state.inputType === "mouse";
|
17723 |
|
17724 |
|
17725 | function selectArc(_this, arcData, id) {
|
17726 |
|
17727 | $$.expandArc(id);
|
17728 | $$.api.focus(id);
|
17729 | $$.toggleFocusLegend(id, !0);
|
17730 | $$.showTooltip([arcData], _this);
|
17731 | }
|
17732 |
|
17733 |
|
17734 | function unselectArc(arcData) {
|
17735 | var id = (arcData == null ? void 0 : arcData.id) || undefined;
|
17736 | $$.unexpandArc(id);
|
17737 | $$.api.revert();
|
17738 | $$.revertLegend();
|
17739 | $$.hideTooltip();
|
17740 | }
|
17741 |
|
17742 | arc.on("click", function (event, d, i) {
|
17743 | var updated = $$.updateAngle(d),
|
17744 | arcData;
|
17745 |
|
17746 | if (updated) {
|
17747 | arcData = $$.convertToArcData(updated);
|
17748 | $$.toggleShape == null ? void 0 : $$.toggleShape(this, arcData, i);
|
17749 | config.data_onclick.bind($$.api)(arcData, this);
|
17750 | }
|
17751 | });
|
17752 |
|
17753 | if (isMouse) {
|
17754 | arc.on("mouseover", function (event, d) {
|
17755 | var _arcData;
|
17756 |
|
17757 | if (state.transiting) {
|
17758 |
|
17759 | return;
|
17760 | }
|
17761 |
|
17762 | state.event = event;
|
17763 | var updated = $$.updateAngle(d),
|
17764 | arcData = updated ? $$.convertToArcData(updated) : null,
|
17765 | id = ((_arcData = arcData) == null ? void 0 : _arcData.id) || undefined;
|
17766 | selectArc(this, arcData, id);
|
17767 | $$.setOverOut(!0, arcData);
|
17768 | }).on("mouseout", function (event, d) {
|
17769 | if (state.transiting) {
|
17770 |
|
17771 | return;
|
17772 | }
|
17773 |
|
17774 | state.event = event;
|
17775 | var updated = $$.updateAngle(d),
|
17776 | arcData = updated ? $$.convertToArcData(updated) : null;
|
17777 | unselectArc();
|
17778 | $$.setOverOut(!1, arcData);
|
17779 | }).on("mousemove", function (event, d) {
|
17780 | var updated = $$.updateAngle(d),
|
17781 | arcData = updated ? $$.convertToArcData(updated) : null;
|
17782 | state.event = event;
|
17783 | $$.showTooltip([arcData], this);
|
17784 | });
|
17785 | }
|
17786 |
|
17787 |
|
17788 | if (isTouch && $$.hasArcType() && !$$.radars) {
|
17789 | var getEventArc = function (event) {
|
17790 | var touch = event.changedTouches[0],
|
17791 | eventArc = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.elementFromPoint(touch.clientX, touch.clientY));
|
17792 | return eventArc;
|
17793 | };
|
17794 |
|
17795 | $$.$el.svg.on("touchstart touchmove", function (event) {
|
17796 | var _datum, _arcData2;
|
17797 |
|
17798 | if (state.transiting) {
|
17799 |
|
17800 | return;
|
17801 | }
|
17802 |
|
17803 | var eventArc = getEventArc(event),
|
17804 | datum = eventArc.datum(),
|
17805 | updated = (_datum = datum) != null && _datum.data && datum.data.id ? $$.updateAngle(datum) : null,
|
17806 | arcData = updated ? $$.convertToArcData(updated) : null,
|
17807 | id = ((_arcData2 = arcData) == null ? void 0 : _arcData2.id) || undefined;
|
17808 | $$.callOverOutForTouch(arcData);
|
17809 | isUndefined(id) ? unselectArc() : selectArc(this, arcData, id);
|
17810 | });
|
17811 | }
|
17812 | },
|
17813 | redrawArcText: function redrawArcText(duration) {
|
17814 | var $$ = this,
|
17815 | config = $$.config,
|
17816 | state = $$.state,
|
17817 | _$$$$el = $$.$el,
|
17818 | main = _$$$$el.main,
|
17819 | arcs = _$$$$el.arcs,
|
17820 | hasGauge = $$.hasType("gauge"),
|
17821 | hasMultiArcGauge = $$.hasMultiArcGauge(),
|
17822 | text;
|
17823 |
|
17824 |
|
17825 | if (!(hasGauge && $$.data.targets.length === 1 && config.gauge_title)) {
|
17826 | text = main.selectAll("." + config_classes.chartArc).select("text").style("opacity", "0").attr("class", function (d) {
|
17827 | return $$.isGaugeType(d.data) ? config_classes.gaugeValue : null;
|
17828 | }).call($$.textForArcLabel.bind($$)).attr("transform", $$.transformForArcLabel.bind($$)).style("font-size", function (d) {
|
17829 | return $$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ? Math.round(state.radius / 5) + "px" : null;
|
17830 | }).transition().duration(duration).style("opacity", function (d) {
|
17831 | return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0";
|
17832 | });
|
17833 | hasMultiArcGauge && text.attr("dy", "-.1em");
|
17834 | }
|
17835 |
|
17836 | main.select("." + config_classes.chartArcsTitle).style("opacity", $$.hasType("donut") || hasGauge ? null : "0");
|
17837 |
|
17838 | if (hasGauge) {
|
17839 | var _text,
|
17840 | isFullCircle = config.gauge_fullCircle;
|
17841 |
|
17842 | isFullCircle && ((_text = text) == null ? void 0 : _text.attr("dy", "" + (hasMultiArcGauge ? 0 : Math.round(state.radius / 14))));
|
17843 |
|
17844 | if (config.gauge_label_show) {
|
17845 | arcs.select("." + config_classes.chartArcsGaugeUnit).attr("dy", (isFullCircle ? 1.5 : .75) + "em").text(config.gauge_units);
|
17846 | arcs.select("." + config_classes.chartArcsGaugeMin).attr("dx", -1 * (state.innerRadius + (state.radius - state.innerRadius) / (isFullCircle ? 1 : 2)) + "px").attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_min, !1));
|
17847 |
|
17848 | isFullCircle || arcs.select("." + config_classes.chartArcsGaugeMax).attr("dx", state.innerRadius + (state.radius - state.innerRadius) / 2 + "px").attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_max, !0));
|
17849 | }
|
17850 | }
|
17851 | }
|
17852 | });
|
17853 | ;
|
17854 |
|
17855 |
|
17856 |
|
17857 |
|
17858 |
|
17859 |
|
17860 |
|
17861 |
|
17862 | var shape_area = ({
|
17863 | initArea: function initArea(mainLine) {
|
17864 | var $$ = this,
|
17865 | config = $$.config;
|
17866 | mainLine.insert("g", "." + config_classes[config.area_front ? "circles" : "lines"]).attr("class", $$.getClass("areas", !0));
|
17867 | },
|
17868 | updateAreaGradient: function updateAreaGradient() {
|
17869 | var $$ = this,
|
17870 | config = $$.config,
|
17871 | datetimeId = $$.state.datetimeId,
|
17872 | defs = $$.$el.defs;
|
17873 | $$.data.targets.forEach(function (d) {
|
17874 | var id = datetimeId + "-areaGradient" + $$.getTargetSelectorSuffix(d.id);
|
17875 |
|
17876 | if ($$.isAreaType(d) && defs.select("#" + id).empty()) {
|
17877 | var color = $$.color(d),
|
17878 | _config$area_linearGr = config.area_linearGradient,
|
17879 | _config$area_linearGr2 = _config$area_linearGr.x,
|
17880 | x = _config$area_linearGr2 === void 0 ? [0, 0] : _config$area_linearGr2,
|
17881 | _config$area_linearGr3 = _config$area_linearGr.y,
|
17882 | y = _config$area_linearGr3 === void 0 ? [0, 1] : _config$area_linearGr3,
|
17883 | _config$area_linearGr4 = _config$area_linearGr.stops,
|
17884 | stops = _config$area_linearGr4 === void 0 ? [[0, color, 1], [1, color, 0]] : _config$area_linearGr4,
|
17885 | linearGradient = defs.append("linearGradient").attr("id", "" + id).attr("x1", x[0]).attr("x2", x[1]).attr("y1", y[0]).attr("y2", y[1]);
|
17886 | stops.forEach(function (v) {
|
17887 | var stopColor = isFunction(v[1]) ? v[1].bind($$.api)(d.id) : v[1];
|
17888 | linearGradient.append("stop").attr("offset", v[0]).attr("stop-color", stopColor || color).attr("stop-opacity", v[2]);
|
17889 | });
|
17890 | }
|
17891 | });
|
17892 | },
|
17893 | updateAreaColor: function updateAreaColor(d) {
|
17894 | var $$ = this;
|
17895 | return $$.config.area_linearGradient ? "url(#" + $$.state.datetimeId + "-areaGradient" + $$.getTargetSelectorSuffix(d.id) + ")" : $$.color(d);
|
17896 | },
|
17897 |
|
17898 | |
17899 |
|
17900 |
|
17901 |
|
17902 |
|
17903 |
|
17904 | updateArea: function updateArea(withTransition, isSub) {
|
17905 | if (isSub === void 0) {
|
17906 | isSub = !1;
|
17907 | }
|
17908 |
|
17909 | var $$ = this,
|
17910 | config = $$.config,
|
17911 | state = $$.state,
|
17912 | $el = $$.$el,
|
17913 | $T = $$.$T,
|
17914 | $root = isSub ? $el.subchart : $el;
|
17915 | config.area_linearGradient && $$.updateAreaGradient();
|
17916 | var area = $root.main.selectAll("." + config_classes.areas).selectAll("." + config_classes.area).data($$.lineData.bind($$));
|
17917 | $T(area.exit(), withTransition).style("opacity", "0").remove();
|
17918 | $root.area = area.enter().append("path").attr("class", $$.getClass("area", !0)).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function () {
|
17919 | state.orgAreaOpacity = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).style("opacity");
|
17920 | return "0";
|
17921 | }).merge(area);
|
17922 | area.style("opacity", state.orgAreaOpacity);
|
17923 | },
|
17924 |
|
17925 | |
17926 |
|
17927 |
|
17928 |
|
17929 |
|
17930 |
|
17931 |
|
17932 | redrawArea: function redrawArea(drawFn, withTransition, isSub) {
|
17933 | if (isSub === void 0) {
|
17934 | isSub = !1;
|
17935 | }
|
17936 |
|
17937 | var $$ = this,
|
17938 | _ref = isSub ? this.$el.subchart : this.$el,
|
17939 | area = _ref.area,
|
17940 | orgAreaOpacity = $$.state.orgAreaOpacity;
|
17941 |
|
17942 | return [$$.$T(area, withTransition, getRandom()).attr("d", drawFn).style("fill", $$.updateAreaColor.bind($$)).style("opacity", function (d) {
|
17943 | return ($$.isAreaRangeType(d) ? orgAreaOpacity / 1.75 : orgAreaOpacity) + "";
|
17944 | })];
|
17945 | },
|
17946 |
|
17947 | |
17948 |
|
17949 |
|
17950 |
|
17951 |
|
17952 |
|
17953 |
|
17954 | generateDrawArea: function generateDrawArea(areaIndices, isSub) {
|
17955 | var $$ = this,
|
17956 | config = $$.config,
|
17957 | lineConnectNull = config.line_connectNull,
|
17958 | isRotated = config.axis_rotated,
|
17959 | getPoints = $$.generateGetAreaPoints(areaIndices, isSub),
|
17960 | yScale = $$.getYScaleById.bind($$),
|
17961 | xValue = function (d) {
|
17962 | return (isSub ? $$.subxx : $$.xx).call($$, d);
|
17963 | },
|
17964 | value0 = function (d, i) {
|
17965 | return $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : $$.getShapeYMin(d.id));
|
17966 | },
|
17967 | value1 = function (d, i) {
|
17968 | return $$.isGrouped(d.id) ? getPoints(d, i)[1][1] : yScale(d.id, isSub)($$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : d.value);
|
17969 | };
|
17970 |
|
17971 | return function (d) {
|
17972 | var values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
|
17973 | x0 = 0,
|
17974 | y0 = 0,
|
17975 | path;
|
17976 |
|
17977 | if ($$.isAreaType(d)) {
|
17978 | var area = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.area)();
|
17979 | area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue)
|
17980 | .y0(config.area_above ? 0 : value0).y1(value1);
|
17981 |
|
17982 | if (!lineConnectNull) {
|
17983 | area = area.defined(function (d) {
|
17984 | return $$.getBaseValue(d) !== null;
|
17985 | });
|
17986 | }
|
17987 |
|
17988 | if ($$.isStepType(d)) {
|
17989 | values = $$.convertValuesToStep(values);
|
17990 | }
|
17991 |
|
17992 | path = area.curve($$.getCurve(d))(values);
|
17993 | } else {
|
17994 | if (values[0]) {
|
17995 | x0 = $$.scale.x(values[0].x);
|
17996 | y0 = $$.getYScaleById(d.id)(values[0].value);
|
17997 | }
|
17998 |
|
17999 | path = isRotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
|
18000 | }
|
18001 |
|
18002 | return path || "M 0 0";
|
18003 | };
|
18004 | },
|
18005 | generateGetAreaPoints: function generateGetAreaPoints(areaIndices, isSub) {
|
18006 |
|
18007 | var $$ = this,
|
18008 | config = $$.config,
|
18009 | x = $$.getShapeX(0, areaIndices, isSub),
|
18010 | y = $$.getShapeY(!!isSub),
|
18011 | areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, isSub),
|
18012 | yScale = $$.getYScaleById.bind($$);
|
18013 | return function (d, i) {
|
18014 | var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
|
18015 | offset = areaOffset(d, i) || y0,
|
18016 | posX = x(d),
|
18017 | posY = y(d);
|
18018 |
|
18019 |
|
18020 | if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
|
18021 | posY = y0;
|
18022 | }
|
18023 |
|
18024 |
|
18025 | return [[posX, offset], [posX, posY - (y0 - offset)], [posX, posY - (y0 - offset)],
|
18026 | [posX, offset]
|
18027 | ];
|
18028 | };
|
18029 | }
|
18030 | });
|
18031 | ;
|
18032 |
|
18033 |
|
18034 |
|
18035 |
|
18036 |
|
18037 |
|
18038 | var bar = ({
|
18039 | initBar: function initBar() {
|
18040 | var $el = this.$el,
|
18041 | config = this.config,
|
18042 | clip = this.state.clip;
|
18043 | $el.bar = $el.main.select("." + config_classes.chart)
|
18044 | .insert("g", ":first-child").attr("class", config_classes.chartBars);
|
18045 |
|
18046 |
|
18047 | if (config.clipPath === !1 && (config.bar_radius || config.bar_radius_ratio)) {
|
18048 | $el.bar.attr("clip-path", clip.pathXAxis.replace(/#[^)]*/, "#" + clip.id));
|
18049 | }
|
18050 | },
|
18051 | updateTargetsForBar: function updateTargetsForBar(targets) {
|
18052 | var $$ = this,
|
18053 | config = $$.config,
|
18054 | $el = $$.$el,
|
18055 | classChartBar = $$.getChartClass("Bar"),
|
18056 | classBars = $$.getClass("bars", !0),
|
18057 | classFocus = $$.classFocus.bind($$),
|
18058 | isSelectable = config.interaction_enabled && config.data_selection_isselectable;
|
18059 |
|
18060 | if (!$el.bar) {
|
18061 | $$.initBar();
|
18062 | }
|
18063 |
|
18064 | var mainBarUpdate = $$.$el.main.select("." + config_classes.chartBars).selectAll("." + config_classes.chartBar).data(
|
18065 | targets.filter(function (v) {
|
18066 | return !v.values.every(function (d) {
|
18067 | return !isNumber(d.value);
|
18068 | });
|
18069 | })).attr("class", function (d) {
|
18070 | return classChartBar(d) + classFocus(d);
|
18071 | }),
|
18072 | mainBarEnter = mainBarUpdate.enter().append("g").attr("class", classChartBar).style("opacity", "0").style("pointer-events", "none");
|
18073 |
|
18074 | mainBarEnter.append("g").attr("class", classBars).style("cursor", function (d) {
|
18075 | var _isSelectable;
|
18076 |
|
18077 | return (_isSelectable = isSelectable) != null && _isSelectable.bind != null && _isSelectable.bind($$.api)(d) ? "pointer" : null;
|
18078 | });
|
18079 | },
|
18080 |
|
18081 | |
18082 |
|
18083 |
|
18084 |
|
18085 |
|
18086 |
|
18087 | updateBar: function updateBar(withTransition, isSub) {
|
18088 | if (isSub === void 0) {
|
18089 | isSub = !1;
|
18090 | }
|
18091 |
|
18092 | var $$ = this,
|
18093 | $el = $$.$el,
|
18094 | $T = $$.$T,
|
18095 | $root = isSub ? $el.subchart : $el,
|
18096 | classBar = $$.getClass("bar", !0),
|
18097 | initialOpacity = $$.initialOpacity.bind($$),
|
18098 | bar = $root.main.selectAll("." + config_classes.bars).selectAll("." + config_classes.bar).data($$.labelishData.bind($$));
|
18099 | $T(bar.exit(), withTransition).style("opacity", "0").remove();
|
18100 | $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.color).merge(bar).style("opacity", initialOpacity);
|
18101 | },
|
18102 |
|
18103 | |
18104 |
|
18105 |
|
18106 |
|
18107 |
|
18108 |
|
18109 |
|
18110 | redrawBar: function redrawBar(drawFn, withTransition, isSub) {
|
18111 | if (isSub === void 0) {
|
18112 | isSub = !1;
|
18113 | }
|
18114 |
|
18115 | var $$ = this,
|
18116 | _ref = isSub ? $$.$el.subchart : $$.$el,
|
18117 | bar = _ref.bar;
|
18118 |
|
18119 | return [$$.$T(bar, withTransition, getRandom()).attr("d", function (d) {
|
18120 | return isNumber(d.value) && drawFn(d);
|
18121 | }).style("fill", this.color).style("opacity", null)];
|
18122 | },
|
18123 | generateDrawBar: function generateDrawBar(barIndices, isSub) {
|
18124 | var $$ = this,
|
18125 | config = $$.config,
|
18126 | getPoints = $$.generateGetBarPoints(barIndices, isSub),
|
18127 | isRotated = config.axis_rotated,
|
18128 | isGrouped = config.data_groups.length,
|
18129 | barRadius = config.bar_radius,
|
18130 | barRadiusRatio = config.bar_radius_ratio,
|
18131 | getRadius = isNumber(barRadius) && barRadius > 0 ? function () {
|
18132 | return barRadius;
|
18133 | } : isNumber(barRadiusRatio) ? function (w) {
|
18134 | return w * barRadiusRatio;
|
18135 | } : null;
|
18136 | return function (d, i) {
|
18137 |
|
18138 | var points = getPoints(d, i),
|
18139 | indexX = +isRotated,
|
18140 | indexY = +!indexX,
|
18141 | isNegative = d.value < 0,
|
18142 | pathRadius = ["", ""],
|
18143 | radius = 0;
|
18144 |
|
18145 | if (d.value !== 0 && getRadius && !isGrouped) {
|
18146 | var index = isRotated ? indexY : indexX,
|
18147 | barW = points[2][index] - points[0][index];
|
18148 | radius = getRadius(barW);
|
18149 | var arc = "a" + radius + "," + radius + " " + (isNegative ? "1 0 0" : "0 0 1") + " ";
|
18150 | pathRadius[+!isRotated] = "" + arc + radius + "," + radius;
|
18151 | pathRadius[+isRotated] = "" + arc + [-radius, radius][isRotated ? "sort" : "reverse"]();
|
18152 | isNegative && pathRadius.reverse();
|
18153 | }
|
18154 |
|
18155 |
|
18156 |
|
18157 | var path = isRotated ? "H" + (points[1][indexX] - radius) + " " + pathRadius[0] + "V" + (points[2][indexY] - radius) + " " + pathRadius[1] + "H" + points[3][indexX] : "V" + (points[1][indexY] + (isNegative ? -radius : radius)) + " " + pathRadius[0] + "H" + (points[2][indexX] - radius) + " " + pathRadius[1] + "V" + points[3][indexY];
|
18158 | return "M" + points[0][indexX] + "," + points[0][indexY] + path + "z";
|
18159 | };
|
18160 | },
|
18161 | generateGetBarPoints: function generateGetBarPoints(barIndices, isSub) {
|
18162 | var $$ = this,
|
18163 | config = $$.config,
|
18164 | axis = isSub ? $$.axis.subX : $$.axis.x,
|
18165 | barTargetsNum = $$.getIndicesMax(barIndices) + 1,
|
18166 | barW = $$.getBarW("bar", axis, barTargetsNum),
|
18167 | barX = $$.getShapeX(barW, barIndices, !!isSub),
|
18168 | barY = $$.getShapeY(!!isSub),
|
18169 | barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub),
|
18170 | yScale = $$.getYScaleById.bind($$);
|
18171 | return function (d, i) {
|
18172 | var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
|
18173 | offset = barOffset(d, i) || y0,
|
18174 | width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
|
18175 | posX = barX(d),
|
18176 | posY = barY(d);
|
18177 |
|
18178 |
|
18179 | if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
|
18180 | posY = y0;
|
18181 | }
|
18182 |
|
18183 | posY -= y0 - offset;
|
18184 | var startPosX = posX + width;
|
18185 |
|
18186 | return [[posX, offset], [posX, posY], [startPosX, posY], [startPosX, offset]];
|
18187 | };
|
18188 | },
|
18189 | isWithinBar: function isWithinBar(that) {
|
18190 | var mouse = getPointer(this.state.event, that),
|
18191 | list = getRectSegList(that),
|
18192 | _list = list,
|
18193 | seg0 = _list[0],
|
18194 | seg1 = _list[1],
|
18195 | x = Math.min(seg0.x, seg1.x),
|
18196 | y = Math.min(seg0.y, seg1.y),
|
18197 | offset = this.config.bar_sensitivity,
|
18198 | _that$getBBox = that.getBBox(),
|
18199 | width = _that$getBBox.width,
|
18200 | height = _that$getBBox.height,
|
18201 | isWithin = x - offset < mouse[0] && mouse[0] < x + width + offset && y - offset < mouse[1] && mouse[1] < y + height + offset;
|
18202 |
|
18203 | return isWithin;
|
18204 | }
|
18205 | });
|
18206 | ;
|
18207 |
|
18208 |
|
18209 | function candlestick_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
18210 |
|
18211 | function candlestick_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { candlestick_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { candlestick_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
18212 |
|
18213 |
|
18214 |
|
18215 |
|
18216 |
|
18217 |
|
18218 |
|
18219 |
|
18220 | var candlestick = ({
|
18221 | initCandlestick: function initCandlestick() {
|
18222 | var $el = this.$el;
|
18223 | $el.candlestick = $el.main.select("." + config_classes.chart)
|
18224 | .append("g").attr("class", config_classes.chartCandlesticks);
|
18225 | },
|
18226 |
|
18227 | |
18228 |
|
18229 |
|
18230 |
|
18231 |
|
18232 |
|
18233 | updateTargetsForCandlestick: function updateTargetsForCandlestick(targets) {
|
18234 | var $$ = this,
|
18235 | $el = $$.$el,
|
18236 | classChart = $$.getChartClass("Candlestick"),
|
18237 | classFocus = $$.classFocus.bind($$);
|
18238 |
|
18239 | if (!$el.candlestick) {
|
18240 | $$.initCandlestick();
|
18241 | }
|
18242 |
|
18243 | var mainUpdate = $$.$el.main.select("." + config_classes.chartCandlesticks).selectAll("." + config_classes.chartCandlestick).data(targets).attr("class", function (d) {
|
18244 | return classChart(d) + classFocus(d);
|
18245 | });
|
18246 | mainUpdate.enter().append("g").attr("class", classChart).style("pointer-events", "none");
|
18247 | },
|
18248 |
|
18249 | |
18250 |
|
18251 |
|
18252 |
|
18253 |
|
18254 |
|
18255 | updateCandlestick: function updateCandlestick(withTransition, isSub) {
|
18256 | if (isSub === void 0) {
|
18257 | isSub = !1;
|
18258 | }
|
18259 |
|
18260 | var $$ = this,
|
18261 | $el = $$.$el,
|
18262 | $T = $$.$T,
|
18263 | $root = isSub ? $el.subchart : $el,
|
18264 | classSetter = $$.getClass("candlestick", !0),
|
18265 | initialOpacity = $$.initialOpacity.bind($$),
|
18266 | candlestick = $root.main.selectAll("." + config_classes.chartCandlestick).selectAll("." + config_classes.candlestick).data($$.labelishData.bind($$));
|
18267 | $T(candlestick.exit(), withTransition).style("opacity", "0").remove();
|
18268 | var candlestickEnter = candlestick.enter().filter(function (d) {
|
18269 | return d.value;
|
18270 | }).append("g").attr("class", classSetter);
|
18271 | candlestickEnter.append("line");
|
18272 | candlestickEnter.append("path");
|
18273 |
|
18274 | if (!$root.candlestick) {
|
18275 | $root.candlestick = {};
|
18276 | }
|
18277 |
|
18278 | $root.candlestick = candlestick.merge(candlestickEnter).style("opacity", initialOpacity);
|
18279 | },
|
18280 |
|
18281 | |
18282 |
|
18283 |
|
18284 |
|
18285 |
|
18286 |
|
18287 |
|
18288 | generateDrawCandlestick: function generateDrawCandlestick(indices, isSub) {
|
18289 | var $$ = this,
|
18290 | config = $$.config,
|
18291 | getPoints = $$.generateGetCandlestickPoints(indices, isSub),
|
18292 | isRotated = config.axis_rotated,
|
18293 | downColor = config.candlestick_color_down;
|
18294 | return function (d, i, g) {
|
18295 | var _value,
|
18296 | points = getPoints(d, i),
|
18297 | value = $$.getCandlestickData(d),
|
18298 | isUp = (_value = value) == null ? void 0 : _value._isUp,
|
18299 | indexX = +isRotated;
|
18300 |
|
18301 | if (g.classed) {
|
18302 | g.classed(config_classes[isUp ? "valueUp" : "valueDown"], !0);
|
18303 | }
|
18304 |
|
18305 | var 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];
|
18306 | g.select("path").attr("d", "M" + points[0][indexX] + "," + points[0][+!indexX] + path + "z").style("fill", function (d) {
|
18307 | var color = isUp ? $$.color(d) : isObject(downColor) ? downColor[d.id] : downColor;
|
18308 | return color || $$.color(d);
|
18309 | });
|
18310 |
|
18311 | var line = g.select("line"),
|
18312 | pos = isRotated ? {
|
18313 | x1: points[2][1],
|
18314 | x2: points[2][2],
|
18315 | y1: points[2][0],
|
18316 | y2: points[2][0]
|
18317 | } : {
|
18318 | x1: points[2][0],
|
18319 | x2: points[2][0],
|
18320 | y1: points[2][1],
|
18321 | y2: points[2][2]
|
18322 | };
|
18323 |
|
18324 | for (var x in pos) {
|
18325 | line.attr(x, pos[x]);
|
18326 | }
|
18327 | };
|
18328 | },
|
18329 |
|
18330 | |
18331 |
|
18332 |
|
18333 |
|
18334 |
|
18335 |
|
18336 | generateGetCandlestickPoints: function generateGetCandlestickPoints(indices, isSub) {
|
18337 | if (isSub === void 0) {
|
18338 | isSub = !1;
|
18339 | }
|
18340 |
|
18341 | var $$ = this,
|
18342 | config = $$.config,
|
18343 | axis = isSub ? $$.axis.subX : $$.axis.x,
|
18344 | targetsNum = $$.getIndicesMax(indices) + 1,
|
18345 | barW = $$.getBarW("candlestick", axis, targetsNum),
|
18346 | x = $$.getShapeX(barW, indices, !!isSub),
|
18347 | y = $$.getShapeY(!!isSub),
|
18348 | shapeOffset = $$.getShapeOffset($$.isBarType, indices, !!isSub),
|
18349 | yScale = $$.getYScaleById.bind($$);
|
18350 | return function (d, i) {
|
18351 | var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
|
18352 | offset = shapeOffset(d, i) || y0,
|
18353 | width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
|
18354 | value = $$.getCandlestickData(d),
|
18355 | points;
|
18356 |
|
18357 | if (value) {
|
18358 | var posX = {
|
18359 | start: x(d),
|
18360 | end: 0
|
18361 | };
|
18362 | posX.end = posX.start + width;
|
18363 | var posY = {
|
18364 | start: y(value.open),
|
18365 | end: y(value.close)
|
18366 | },
|
18367 | posLine = {
|
18368 | x: posX.start + width / 2,
|
18369 | high: y(value.high),
|
18370 | low: y(value.low)
|
18371 | };
|
18372 |
|
18373 |
|
18374 | if (config.axis_rotated && (d.value > 0 && posY.start < y0 || d.value < 0 && y0 < posY.start)) {
|
18375 | posY.start = y0;
|
18376 | }
|
18377 |
|
18378 | posY.start -= y0 - offset;
|
18379 | points = [[posX.start, posY.start], [posX.end, posY.end], [posLine.x, posLine.low, posLine.high]];
|
18380 | } else {
|
18381 | points = [[0, 0], [0, 0], [0, 0, 0]];
|
18382 | }
|
18383 |
|
18384 | return points;
|
18385 | };
|
18386 | },
|
18387 |
|
18388 | |
18389 |
|
18390 |
|
18391 |
|
18392 |
|
18393 |
|
18394 |
|
18395 | redrawCandlestick: function redrawCandlestick(drawFn, withTransition, isSub) {
|
18396 | if (isSub === void 0) {
|
18397 | isSub = !1;
|
18398 | }
|
18399 |
|
18400 | var $$ = this,
|
18401 | $el = $$.$el,
|
18402 | $T = $$.$T,
|
18403 | _ref = isSub ? $el.subchart : $el,
|
18404 | candlestick = _ref.candlestick,
|
18405 | rand = getRandom(!0);
|
18406 |
|
18407 | return [candlestick.each(function (d, i) {
|
18408 | var g = $T((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), withTransition, rand);
|
18409 | drawFn(d, i, g);
|
18410 | }).style("opacity", null)];
|
18411 | },
|
18412 |
|
18413 | |
18414 |
|
18415 |
|
18416 |
|
18417 |
|
18418 |
|
18419 |
|
18420 | getCandlestickData: function getCandlestickData(_ref2) {
|
18421 | var value = _ref2.value,
|
18422 | d;
|
18423 |
|
18424 | if (isArray(value)) {
|
18425 | var open = value[0],
|
18426 | high = value[1],
|
18427 | low = value[2],
|
18428 | close = value[3],
|
18429 | _value$ = value[4],
|
18430 | volume = _value$ === void 0 ? !1 : _value$;
|
18431 | d = {
|
18432 | open: open,
|
18433 | high: high,
|
18434 | low: low,
|
18435 | close: close
|
18436 | };
|
18437 |
|
18438 | if (volume !== !1) {
|
18439 | d.volume = volume;
|
18440 | }
|
18441 | } else if (isObject(value)) {
|
18442 | d = candlestick_objectSpread({}, value);
|
18443 | }
|
18444 |
|
18445 | if (d) {
|
18446 | d._isUp = d.close >= d.open;
|
18447 | }
|
18448 |
|
18449 | return d || null;
|
18450 | }
|
18451 | });
|
18452 | ;
|
18453 |
|
18454 |
|
18455 |
|
18456 |
|
18457 |
|
18458 |
|
18459 |
|
18460 | var gauge = ({
|
18461 | initGauge: function initGauge() {
|
18462 | var $$ = this,
|
18463 | config = $$.config,
|
18464 | arcs = $$.$el.arcs,
|
18465 | appendText = function (className) {
|
18466 | arcs.append("text").attr("class", className).style("text-anchor", "middle").style("pointer-events", "none");
|
18467 | };
|
18468 |
|
18469 | if ($$.hasType("gauge")) {
|
18470 | var hasMulti = $$.hasMultiArcGauge();
|
18471 | arcs.append(hasMulti ? "g" : "path").attr("class", config_classes.chartArcsBackground).style("fill", !hasMulti && config.gauge_background || null);
|
18472 | config.gauge_units && appendText(config_classes.chartArcsGaugeUnit);
|
18473 |
|
18474 | if (config.gauge_label_show) {
|
18475 | appendText(config_classes.chartArcsGaugeMin);
|
18476 | config.gauge_fullCircle || appendText(config_classes.chartArcsGaugeMax);
|
18477 | }
|
18478 | }
|
18479 | },
|
18480 | updateGaugeMax: function updateGaugeMax() {
|
18481 | var $$ = this,
|
18482 | config = $$.config,
|
18483 | state = $$.state,
|
18484 | hasMultiGauge = $$.hasMultiArcGauge(),
|
18485 | max = hasMultiGauge ? $$.getMinMaxData().max[0].value : $$.getTotalDataSum(state.rendered);
|
18486 |
|
18487 |
|
18488 | if (max + config.gauge_min * (config.gauge_min > 0 ? -1 : 1) > config.gauge_max) {
|
18489 | config.gauge_max = max - config.gauge_min;
|
18490 | }
|
18491 | },
|
18492 | redrawMultiArcGauge: function redrawMultiArcGauge() {
|
18493 | var $$ = this,
|
18494 | config = $$.config,
|
18495 | state = $$.state,
|
18496 | $el = $$.$el,
|
18497 | hiddenTargetIds = $$.state.hiddenTargetIds,
|
18498 | arcLabelLines = $el.main.selectAll("." + config_classes.arcs).selectAll("." + config_classes.arcLabelLine).data($$.arcData.bind($$)),
|
18499 | mainArcLabelLine = arcLabelLines.enter().append("rect").attr("class", function (d) {
|
18500 | return config_classes.arcLabelLine + " " + config_classes.target + " " + config_classes.target + "-" + d.data.id;
|
18501 | }).merge(arcLabelLines);
|
18502 | mainArcLabelLine.style("fill", function (d) {
|
18503 | return $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data);
|
18504 | }).style("display", config.gauge_label_show ? null : "none").each(function (d) {
|
18505 | var lineLength = 0,
|
18506 | lineThickness = 2,
|
18507 | x = 0,
|
18508 | y = 0,
|
18509 | transform = "";
|
18510 |
|
18511 | if (hiddenTargetIds.indexOf(d.data.id) < 0) {
|
18512 | var updated = $$.updateAngle(d),
|
18513 | innerLineLength = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length * (updated.index + 1),
|
18514 | lineAngle = updated.endAngle - Math.PI / 2,
|
18515 | arcInnerRadius = state.radius - innerLineLength,
|
18516 | linePositioningAngle = lineAngle - (arcInnerRadius === 0 ? 0 : 1 / arcInnerRadius);
|
18517 | lineLength = state.radiusExpanded - state.radius + innerLineLength;
|
18518 | x = Math.cos(linePositioningAngle) * arcInnerRadius;
|
18519 | y = Math.sin(linePositioningAngle) * arcInnerRadius;
|
18520 | transform = "rotate(" + lineAngle * 180 / Math.PI + ", " + x + ", " + y + ")";
|
18521 | }
|
18522 |
|
18523 | (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");
|
18524 | });
|
18525 | },
|
18526 | textForGaugeMinMax: function textForGaugeMinMax(value, isMax) {
|
18527 | var $$ = this,
|
18528 | config = $$.config,
|
18529 | format = config.gauge_label_extents;
|
18530 | return isFunction(format) ? format.bind($$.api)(value, isMax) : value;
|
18531 | },
|
18532 | getGaugeLabelHeight: function getGaugeLabelHeight() {
|
18533 | var config = this.config;
|
18534 | return this.config.gauge_label_show && !config.gauge_fullCircle ? 20 : 0;
|
18535 | },
|
18536 | getPaddingBottomForGauge: function getPaddingBottomForGauge() {
|
18537 | var $$ = this;
|
18538 | return $$.getGaugeLabelHeight() * ($$.config.gauge_label_show ? 2 : 2.5);
|
18539 | }
|
18540 | });
|
18541 | ;
|
18542 |
|
18543 |
|
18544 |
|
18545 |
|
18546 |
|
18547 |
|
18548 | var bubble = ({
|
18549 | |
18550 |
|
18551 |
|
18552 |
|
18553 | initBubble: function initBubble() {
|
18554 | var $$ = this,
|
18555 | config = $$.config;
|
18556 |
|
18557 | if ($$.hasType("bubble")) {
|
18558 | config.point_show = !0;
|
18559 | config.point_type = "circle";
|
18560 | config.point_sensitivity = 25;
|
18561 | }
|
18562 | },
|
18563 |
|
18564 | |
18565 |
|
18566 |
|
18567 |
|
18568 |
|
18569 | getBaseLength: function getBaseLength() {
|
18570 | var $$ = this,
|
18571 | _$$$state = $$.state,
|
18572 | width = _$$$state.width,
|
18573 | height = _$$$state.height,
|
18574 | cacheKey = KEY.bubbleBaseLength,
|
18575 | baseLength = $$.cache.get(cacheKey);
|
18576 |
|
18577 | if (!baseLength) {
|
18578 | $$.cache.add(cacheKey, baseLength = getMinMax("min", [width, height]));
|
18579 | }
|
18580 |
|
18581 | return baseLength;
|
18582 | },
|
18583 |
|
18584 | |
18585 |
|
18586 |
|
18587 |
|
18588 |
|
18589 |
|
18590 | getBubbleR: function getBubbleR(d) {
|
18591 | var $$ = this,
|
18592 | maxR = $$.config.bubble_maxR;
|
18593 |
|
18594 | if (isFunction(maxR)) {
|
18595 | maxR = maxR.bind($$.api)(d);
|
18596 | } else if (!isNumber(maxR)) {
|
18597 | maxR = $$.getBaseLength() / ($$.getMaxDataCount() * 2) + 12;
|
18598 | }
|
18599 |
|
18600 | var max = getMinMax("max", $$.getMinMaxData().max.map(function (d) {
|
18601 | return $$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "y") : isObject(d.value) ? d.value.mid : d.value;
|
18602 | })),
|
18603 | maxArea = maxR * maxR * Math.PI,
|
18604 | area = ($$.isBubbleZType(d) ? $$.getBubbleZData(d.value, "z") : d.value) * (maxArea / max);
|
18605 | return Math.sqrt(area / Math.PI);
|
18606 | },
|
18607 |
|
18608 | |
18609 |
|
18610 |
|
18611 |
|
18612 |
|
18613 |
|
18614 |
|
18615 | getBubbleZData: function getBubbleZData(d, type) {
|
18616 | return isObject(d) ? d[type] : d[type === "y" ? 0 : 1];
|
18617 | }
|
18618 | });
|
18619 | ;
|
18620 |
|
18621 |
|
18622 |
|
18623 |
|
18624 |
|
18625 |
|
18626 |
|
18627 |
|
18628 | var line = ({
|
18629 | initLine: function initLine() {
|
18630 | var $el = this.$el;
|
18631 | $el.line = $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartLines);
|
18632 | },
|
18633 | updateTargetsForLine: function updateTargetsForLine(t) {
|
18634 | var $$ = this,
|
18635 | _$$$$el = $$.$el,
|
18636 | area = _$$$$el.area,
|
18637 | line = _$$$$el.line,
|
18638 | main = _$$$$el.main,
|
18639 | classChartLine = $$.getChartClass("Line"),
|
18640 | classLines = $$.getClass("lines", !0),
|
18641 | classFocus = $$.classFocus.bind($$);
|
18642 |
|
18643 | if (!line) {
|
18644 | $$.initLine();
|
18645 | }
|
18646 |
|
18647 | var targets = t.filter(function (d) {
|
18648 | return !($$.isScatterType(d) || $$.isBubbleType(d));
|
18649 | }),
|
18650 | mainLineUpdate = main.select("." + config_classes.chartLines).selectAll("." + config_classes.chartLine).data(targets).attr("class", function (d) {
|
18651 | return classChartLine(d) + classFocus(d);
|
18652 | }),
|
18653 | mainLineEnter = mainLineUpdate.enter().append("g").attr("class", classChartLine).style("opacity", "0").style("pointer-events", "none");
|
18654 |
|
18655 | mainLineEnter.append("g").attr("class", classLines);
|
18656 |
|
18657 | if ($$.hasTypeOf("Area")) {
|
18658 | $$.initArea(!area && mainLineEnter.empty() ? mainLineUpdate : mainLineEnter);
|
18659 | }
|
18660 |
|
18661 | $$.updateTargetForCircle(targets, mainLineEnter);
|
18662 | },
|
18663 |
|
18664 | |
18665 |
|
18666 |
|
18667 |
|
18668 |
|
18669 |
|
18670 | updateLine: function updateLine(withTransition, isSub) {
|
18671 | if (isSub === void 0) {
|
18672 | isSub = !1;
|
18673 | }
|
18674 |
|
18675 | var $$ = this,
|
18676 | extraLineClasses = $$.format.extraLineClasses,
|
18677 | $el = $$.$el,
|
18678 | $T = $$.$T,
|
18679 | $root = isSub ? $el.subchart : $el,
|
18680 | line = $root.main.selectAll("." + config_classes.lines).selectAll("." + config_classes.line).data($$.lineData.bind($$));
|
18681 | $T(line.exit(), withTransition).style("opacity", "0").remove();
|
18682 | $root.line = line.enter().append("path").attr("class", function (d) {
|
18683 | return $$.getClass("line", !0)(d) + " " + (extraLineClasses(d) || "");
|
18684 | }).style("stroke", $$.color).merge(line).style("opacity", $$.initialOpacity.bind($$)).style("shape-rendering", function (d) {
|
18685 | return $$.isStepType(d) ? "crispEdges" : "";
|
18686 | }).attr("transform", null);
|
18687 | },
|
18688 |
|
18689 | |
18690 |
|
18691 |
|
18692 |
|
18693 |
|
18694 |
|
18695 |
|
18696 | redrawLine: function redrawLine(drawFn, withTransition, isSub) {
|
18697 | if (isSub === void 0) {
|
18698 | isSub = !1;
|
18699 | }
|
18700 |
|
18701 | var $$ = this,
|
18702 | $el = $$.$el,
|
18703 | $T = $$.$T,
|
18704 | _ref = isSub ? $el.subchart : $el,
|
18705 | line = _ref.line;
|
18706 |
|
18707 | return [$T(line, withTransition, getRandom()).attr("d", drawFn).style("stroke", this.color).style("opacity", null)];
|
18708 | },
|
18709 |
|
18710 | |
18711 |
|
18712 |
|
18713 |
|
18714 |
|
18715 |
|
18716 | getCurve: function getCurve(d) {
|
18717 | var $$ = this,
|
18718 | isRotatedStepType = $$.config.axis_rotated && $$.isStepType(d);
|
18719 |
|
18720 |
|
18721 | return isRotatedStepType ? function (context) {
|
18722 | var step = $$.getInterpolate(d)(context);
|
18723 |
|
18724 | step.orgPoint = step.point;
|
18725 |
|
18726 | step.pointRotated = function (x, y) {
|
18727 | this._point === 1 && (this._point = 2);
|
18728 | var y1 = this._y * (1 - this._t) + y * this._t;
|
18729 |
|
18730 | this._context.lineTo(this._x, y1);
|
18731 |
|
18732 | this._context.lineTo(x, y1);
|
18733 |
|
18734 | this._x = x;
|
18735 | this._y = y;
|
18736 | };
|
18737 |
|
18738 | step.point = function (x, y) {
|
18739 | this._point === 0 ? this.orgPoint(x, y) : this.pointRotated(x, y);
|
18740 | };
|
18741 |
|
18742 | return step;
|
18743 | } : $$.getInterpolate(d);
|
18744 | },
|
18745 | generateDrawLine: function generateDrawLine(lineIndices, isSub) {
|
18746 | var $$ = this,
|
18747 | config = $$.config,
|
18748 | scale = $$.scale,
|
18749 | lineConnectNull = config.line_connectNull,
|
18750 | isRotated = config.axis_rotated,
|
18751 | getPoints = $$.generateGetLinePoints(lineIndices, isSub),
|
18752 | yScale = $$.getYScaleById.bind($$),
|
18753 | xValue = function (d) {
|
18754 | return (isSub ? $$.subxx : $$.xx).call($$, d);
|
18755 | },
|
18756 | yValue = function (d, i) {
|
18757 | return $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.getBaseValue(d));
|
18758 | },
|
18759 | line = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.line)();
|
18760 |
|
18761 | line = isRotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
|
18762 |
|
18763 | if (!lineConnectNull) {
|
18764 | line = line.defined(function (d) {
|
18765 | return $$.getBaseValue(d) !== null;
|
18766 | });
|
18767 | }
|
18768 |
|
18769 | var x = isSub ? scale.subX : scale.x;
|
18770 | return function (d) {
|
18771 | var y = yScale(d.id, isSub),
|
18772 | values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values,
|
18773 | x0 = 0,
|
18774 | y0 = 0,
|
18775 | path;
|
18776 |
|
18777 | if ($$.isLineType(d)) {
|
18778 | var regions = config.data_regions[d.id];
|
18779 |
|
18780 | if (regions) {
|
18781 | path = $$.lineWithRegions(values, scale.zoom || x, y, regions);
|
18782 | } else {
|
18783 | if ($$.isStepType(d)) {
|
18784 | values = $$.convertValuesToStep(values);
|
18785 | }
|
18786 |
|
18787 | path = line.curve($$.getCurve(d))(values);
|
18788 | }
|
18789 | } else {
|
18790 | if (values[0]) {
|
18791 | x0 = x(values[0].x);
|
18792 | y0 = y(values[0].value);
|
18793 | }
|
18794 |
|
18795 | path = isRotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0;
|
18796 | }
|
18797 |
|
18798 | return path || "M 0 0";
|
18799 | };
|
18800 | },
|
18801 | lineWithRegions: function lineWithRegions(d, x, y, _regions) {
|
18802 | var $$ = this,
|
18803 | config = $$.config,
|
18804 | isRotated = config.axis_rotated,
|
18805 | isTimeSeries = $$.axis.isTimeSeries(),
|
18806 | xOffset = $$.axis.isCategorized() ? .5 : 0,
|
18807 | regions = [],
|
18808 | dasharray = "2 2",
|
18809 | xp,
|
18810 | yp,
|
18811 | diff,
|
18812 | diffx2,
|
18813 | isWithinRegions = function (withinX, withinRegions) {
|
18814 | for (var i = 0, reg; reg = withinRegions[i]; i++) {
|
18815 | if (reg.start < withinX && withinX <= reg.end) {
|
18816 | return reg.style;
|
18817 | }
|
18818 | }
|
18819 |
|
18820 | return !1;
|
18821 | };
|
18822 |
|
18823 |
|
18824 | if (isDefined(_regions)) {
|
18825 | var getValue = function (v, def) {
|
18826 | return isUndefined(v) ? def : isTimeSeries ? parseDate.call($$, v) : v;
|
18827 | };
|
18828 |
|
18829 | for (var i = 0, reg; reg = _regions[i]; i++) {
|
18830 | var start = getValue(reg.start, d[0].x),
|
18831 | end = getValue(reg.end, d[d.length - 1].x),
|
18832 | style = reg.style || {
|
18833 | dasharray: dasharray
|
18834 | };
|
18835 | regions[i] = {
|
18836 | start: start,
|
18837 | end: end,
|
18838 | style: style
|
18839 | };
|
18840 | }
|
18841 | }
|
18842 |
|
18843 |
|
18844 | var xValue = isRotated ? function (dt) {
|
18845 | return y(dt.value);
|
18846 | } : function (dt) {
|
18847 | return x(dt.x);
|
18848 | },
|
18849 | yValue = isRotated ? function (dt) {
|
18850 | return x(dt.x);
|
18851 | } : function (dt) {
|
18852 | return y(dt.value);
|
18853 | },
|
18854 | generateM = function (points) {
|
18855 | return "M" + points[0][0] + "," + points[0][1] + "L" + points[1][0] + "," + points[1][1];
|
18856 | },
|
18857 | sWithRegion = isTimeSeries ? function (d0, d1, k, timeseriesDiff) {
|
18858 | var x0 = d0.x.getTime(),
|
18859 | xDiff = d1.x - d0.x,
|
18860 | xv0 = new Date(x0 + xDiff * k),
|
18861 | xv1 = new Date(x0 + xDiff * (k + timeseriesDiff)),
|
18862 | points = isRotated ? [[y(yp(k)), x(xv0)], [y(yp(k + diff)), x(xv1)]] : [[x(xv0), y(yp(k))], [x(xv1), y(yp(k + diff))]];
|
18863 | return generateM(points);
|
18864 | } : function (d0, d1, k, otherDiff) {
|
18865 | var points = isRotated ? [[y(yp(k), !0), x(xp(k))], [y(yp(k + otherDiff), !0), x(xp(k + otherDiff))]] : [[x(xp(k), !0), y(yp(k))], [x(xp(k + otherDiff), !0), y(yp(k + otherDiff))]];
|
18866 | return generateM(points);
|
18867 | },
|
18868 | axisType = {
|
18869 | x: $$.axis.getAxisType("x"),
|
18870 | y: $$.axis.getAxisType("y")
|
18871 | },
|
18872 | path = "";
|
18873 |
|
18874 | for (var _i = 0, data; data = d[_i]; _i++) {
|
18875 | var prevData = d[_i - 1],
|
18876 | hasPrevData = prevData && isValue(prevData.value),
|
18877 | style = isWithinRegions(data.x, regions);
|
18878 |
|
18879 |
|
18880 | if (!isValue(data.value)) {
|
18881 | continue;
|
18882 | }
|
18883 |
|
18884 |
|
18885 | if (isUndefined(regions) || !style || !hasPrevData) {
|
18886 | path += "" + (_i && hasPrevData ? "L" : "M") + xValue(data) + "," + yValue(data);
|
18887 | } else if (hasPrevData) {
|
18888 | try {
|
18889 | style = style.dasharray.split(" ");
|
18890 | } catch (e) {
|
18891 | style = dasharray.split(" ");
|
18892 | }
|
18893 |
|
18894 |
|
18895 | xp = getScale(axisType.x, prevData.x + xOffset, data.x + xOffset);
|
18896 | yp = getScale(axisType.y, prevData.value, data.value);
|
18897 | var dx = x(data.x) - x(prevData.x),
|
18898 | dy = y(data.value) - y(prevData.value),
|
18899 | dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
|
18900 | diff = style[0] / dd;
|
18901 | diffx2 = diff * style[1];
|
18902 |
|
18903 | for (var j = diff; j <= 1; j += diffx2) {
|
18904 | path += sWithRegion(prevData, data, j, diff);
|
18905 |
|
18906 | if (j + diffx2 >= 1) {
|
18907 | path += sWithRegion(prevData, data, 1, 0);
|
18908 | }
|
18909 | }
|
18910 | }
|
18911 | }
|
18912 |
|
18913 | return path;
|
18914 | },
|
18915 | isWithinStep: function isWithinStep(that, y) {
|
18916 | return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
|
18917 | },
|
18918 | shouldDrawPointsForLine: function shouldDrawPointsForLine(d) {
|
18919 | var linePoint = this.config.line_point;
|
18920 | return linePoint === !0 || isArray(linePoint) && linePoint.indexOf(d.id) !== -1;
|
18921 | }
|
18922 | });
|
18923 | ;
|
18924 |
|
18925 |
|
18926 |
|
18927 |
|
18928 |
|
18929 |
|
18930 |
|
18931 |
|
18932 |
|
18933 | var getTransitionName = function () {
|
18934 | return getRandom();
|
18935 | };
|
18936 |
|
18937 | var point = ({
|
18938 | hasValidPointType: function hasValidPointType(type) {
|
18939 | return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
|
18940 | },
|
18941 | hasValidPointDrawMethods: function hasValidPointDrawMethods(type) {
|
18942 | var pointType = type || this.config.point_type;
|
18943 | return isObjectType(pointType) && isFunction(pointType.create) && isFunction(pointType.update);
|
18944 | },
|
18945 | initialOpacityForCircle: function initialOpacityForCircle(d) {
|
18946 | var config = this.config,
|
18947 | withoutFadeIn = this.state.withoutFadeIn,
|
18948 | opacity = config.point_opacity;
|
18949 |
|
18950 | if (isUndefined(opacity)) {
|
18951 | opacity = this.getBaseValue(d) !== null && withoutFadeIn[d.id] ? this.opacityForCircle(d) : "0";
|
18952 | }
|
18953 |
|
18954 | return opacity;
|
18955 | },
|
18956 | opacityForCircle: function opacityForCircle(d) {
|
18957 | var config = this.config,
|
18958 | opacity = config.point_opacity;
|
18959 |
|
18960 | if (isUndefined(opacity)) {
|
18961 | opacity = config.point_show && !config.point_focus_only ? null : "0";
|
18962 | opacity = isValue(this.getBaseValue(d)) ? this.isBubbleType(d) || this.isScatterType(d) ? "0.5" : opacity : "0";
|
18963 | }
|
18964 |
|
18965 | return opacity;
|
18966 | },
|
18967 | initCircle: function initCircle() {
|
18968 | var $$ = this,
|
18969 | main = $$.$el.main;
|
18970 | $$.point = $$.generatePoint();
|
18971 |
|
18972 | if (($$.hasType("bubble") || $$.hasType("scatter")) && main.select("." + config_classes.chartCircles).empty()) {
|
18973 | main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartCircles);
|
18974 | }
|
18975 | },
|
18976 | updateTargetForCircle: function updateTargetForCircle(targetsValue, enterNodeValue) {
|
18977 | var _this = this,
|
18978 | $$ = this,
|
18979 | config = $$.config,
|
18980 | data = $$.data,
|
18981 | $el = $$.$el,
|
18982 | selectionEnabled = config.interaction_enabled && config.data_selection_enabled,
|
18983 | isSelectable = selectionEnabled && config.data_selection_isselectable,
|
18984 | classCircles = $$.getClass("circles", !0);
|
18985 |
|
18986 | if (!config.point_show) {
|
18987 | return;
|
18988 | }
|
18989 |
|
18990 | $el.circle || $$.initCircle();
|
18991 | var targets = targetsValue,
|
18992 | enterNode = enterNodeValue;
|
18993 |
|
18994 |
|
18995 | if (!targets) {
|
18996 | targets = data.targets.filter(function (d) {
|
18997 | return _this.isScatterType(d) || _this.isBubbleType(d);
|
18998 | });
|
18999 | var mainCircle = $el.main.select("." + config_classes.chartCircles).style("pointer-events", "none").selectAll("." + config_classes.circles).data(targets).attr("class", classCircles);
|
19000 | mainCircle.exit().remove();
|
19001 | enterNode = mainCircle.enter();
|
19002 | }
|
19003 |
|
19004 |
|
19005 | selectionEnabled && enterNode.append("g").attr("class", function (d) {
|
19006 | return $$.generateClass(config_classes.selectedCircles, d.id);
|
19007 | });
|
19008 | enterNode.append("g").attr("class", classCircles).style("cursor", function (d) {
|
19009 | return isFunction(isSelectable) && isSelectable(d) ? "pointer" : null;
|
19010 | });
|
19011 |
|
19012 | selectionEnabled && targets.forEach(function (t) {
|
19013 | $el.main.selectAll("." + config_classes.selectedCircles + $$.getTargetSelectorSuffix(t.id)).selectAll("" + config_classes.selectedCircle).each(function (d) {
|
19014 | d.value = t.values[d.index].value;
|
19015 | });
|
19016 | });
|
19017 | },
|
19018 | updateCircle: function updateCircle(isSub) {
|
19019 | if (isSub === void 0) {
|
19020 | isSub = !1;
|
19021 | }
|
19022 |
|
19023 | var $$ = this,
|
19024 | config = $$.config,
|
19025 | state = $$.state,
|
19026 | $el = $$.$el,
|
19027 | focusOnly = config.point_focus_only,
|
19028 | $root = isSub ? $el.subchart : $el;
|
19029 |
|
19030 | if (config.point_show && !state.toggling) {
|
19031 | var circles = $root.main.selectAll("." + config_classes.circles).selectAll("." + config_classes.circle).data(function (d) {
|
19032 | return $$.isLineType(d) && $$.shouldDrawPointsForLine(d) || $$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ? focusOnly ? [d.values[0]] : d.values : [];
|
19033 | });
|
19034 | circles.exit().remove();
|
19035 | circles.enter().filter(Boolean).append($$.point("create", this, $$.pointR.bind($$), $$.color));
|
19036 | $root.circle = $root.main.selectAll("." + config_classes.circles + " ." + config_classes.circle).style("stroke", $$.color).style("opacity", $$.initialOpacityForCircle.bind($$));
|
19037 | }
|
19038 | },
|
19039 | redrawCircle: function redrawCircle(cx, cy, withTransition, flow, isSub) {
|
19040 | if (isSub === void 0) {
|
19041 | isSub = !1;
|
19042 | }
|
19043 |
|
19044 | var $$ = this,
|
19045 | rendered = $$.state.rendered,
|
19046 | $el = $$.$el,
|
19047 | $T = $$.$T,
|
19048 | $root = isSub ? $el.subchart : $el,
|
19049 | selectedCircles = $root.main.selectAll("." + config_classes.selectedCircle);
|
19050 |
|
19051 | if (!$$.config.point_show) {
|
19052 | return [];
|
19053 | }
|
19054 |
|
19055 | var fn = $$.point("update", $$, cx, cy, $$.color, withTransition, flow, selectedCircles),
|
19056 | posAttr = $$.isCirclePoint() ? "c" : "",
|
19057 | t = getRandom(),
|
19058 | opacityStyleFn = $$.opacityForCircle.bind($$),
|
19059 | mainCircles = [];
|
19060 | $root.circle.each(function (d) {
|
19061 | var result = fn.bind(this)(d);
|
19062 | result = $T(result, withTransition || !rendered, t).style("opacity", opacityStyleFn);
|
19063 | mainCircles.push(result);
|
19064 | });
|
19065 | return [mainCircles, $T(selectedCircles, withTransition).attr(posAttr + "x", cx).attr(posAttr + "y", cy)];
|
19066 | },
|
19067 |
|
19068 | |
19069 |
|
19070 |
|
19071 |
|
19072 |
|
19073 | showCircleFocus: function showCircleFocus(d) {
|
19074 | var $$ = this,
|
19075 | config = $$.config,
|
19076 | _$$$state = $$.state,
|
19077 | hasRadar = _$$$state.hasRadar,
|
19078 | resizing = _$$$state.resizing,
|
19079 | toggling = _$$$state.toggling,
|
19080 | transiting = _$$$state.transiting,
|
19081 | $el = $$.$el,
|
19082 | circle = $el.circle;
|
19083 |
|
19084 | if (transiting === !1 && config.point_focus_only && circle) {
|
19085 | var cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$),
|
19086 | cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$),
|
19087 | withTransition = toggling || isUndefined(d),
|
19088 | fn = $$.point("update", $$, cx, cy, $$.color, resizing ? !1 : withTransition);
|
19089 |
|
19090 | if (d) {
|
19091 | circle = circle.filter(function (t) {
|
19092 | var data = d.filter(function (v) {
|
19093 | return v.id === t.id;
|
19094 | });
|
19095 | return data.length ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).datum(data[0]) : !1;
|
19096 | });
|
19097 | }
|
19098 |
|
19099 | circle.attr("class", this.updatePointClass.bind(this)).style("opacity", null).each(function (d) {
|
19100 | var id = d.id,
|
19101 | index = d.index,
|
19102 | value = d.value,
|
19103 | visibility = "hidden";
|
19104 |
|
19105 | if (isValue(value)) {
|
19106 | fn.bind(this)(d);
|
19107 | $$.expandCircles(index, id);
|
19108 | visibility = "";
|
19109 | }
|
19110 |
|
19111 | this.style.visibility = visibility;
|
19112 | });
|
19113 | }
|
19114 | },
|
19115 |
|
19116 | |
19117 |
|
19118 |
|
19119 |
|
19120 | hideCircleFocus: function hideCircleFocus() {
|
19121 | var $$ = this,
|
19122 | config = $$.config,
|
19123 | circle = $$.$el.circle;
|
19124 |
|
19125 | if (config.point_focus_only && circle) {
|
19126 | $$.unexpandCircles();
|
19127 | circle.style("visibility", "hidden");
|
19128 | }
|
19129 | },
|
19130 | circleX: function circleX(d) {
|
19131 | return this.xx(d);
|
19132 | },
|
19133 | updateCircleY: function updateCircleY(isSub) {
|
19134 | if (isSub === void 0) {
|
19135 | isSub = !1;
|
19136 | }
|
19137 |
|
19138 | var $$ = this,
|
19139 | getPoints = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType), isSub);
|
19140 | return function (d, i) {
|
19141 | var id = d.id;
|
19142 | return $$.isGrouped(id) ? getPoints(d, i)[0][1] : $$.getYScaleById(id, isSub)($$.getBaseValue(d));
|
19143 | };
|
19144 | },
|
19145 | expandCircles: function expandCircles(i, id, reset) {
|
19146 | var $$ = this,
|
19147 | r = $$.pointExpandedR.bind($$);
|
19148 | reset && $$.unexpandCircles();
|
19149 | var circles = $$.getShapeByIndex("circle", i, id).classed(config_classes.EXPANDED, !0),
|
19150 | scale = r(circles) / $$.config.point_r,
|
19151 | ratio = 1 - scale;
|
19152 |
|
19153 | if ($$.isCirclePoint()) {
|
19154 | circles.attr("r", r);
|
19155 | } else {
|
19156 |
|
19157 | circles.each(function () {
|
19158 | var point = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
19159 |
|
19160 | if (this.tagName === "circle") {
|
19161 | point.attr("r", r);
|
19162 | } else {
|
19163 | var _this$getBBox = this.getBBox(),
|
19164 | width = _this$getBBox.width,
|
19165 | height = _this$getBBox.height,
|
19166 | x = ratio * (+point.attr("x") + width / 2),
|
19167 | y = ratio * (+point.attr("y") + height / 2);
|
19168 |
|
19169 | point.attr("transform", "translate(" + x + " " + y + ") scale(" + scale + ")");
|
19170 | }
|
19171 | });
|
19172 | }
|
19173 | },
|
19174 | unexpandCircles: function unexpandCircles(i) {
|
19175 | var $$ = this,
|
19176 | r = $$.pointR.bind($$),
|
19177 | circles = $$.getShapeByIndex("circle", i).filter(function () {
|
19178 | return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.EXPANDED);
|
19179 | }).classed(config_classes.EXPANDED, !1);
|
19180 | circles.attr("r", r);
|
19181 | $$.isCirclePoint() || circles.attr("transform", "scale(" + r(circles) / $$.config.point_r + ")");
|
19182 | },
|
19183 | pointR: function (d) {
|
19184 | var $$ = this,
|
19185 | config = $$.config,
|
19186 | pointR = config.point_r,
|
19187 | r = pointR;
|
19188 |
|
19189 | if ($$.isBubbleType(d)) {
|
19190 | r = $$.getBubbleR(d);
|
19191 | } else if (isFunction(pointR)) {
|
19192 | r = pointR.bind($$.api)(d);
|
19193 | }
|
19194 |
|
19195 | return r;
|
19196 | },
|
19197 | pointExpandedR: function pointExpandedR(d) {
|
19198 | var $$ = this,
|
19199 | config = $$.config,
|
19200 | scale = $$.isBubbleType(d) ? 1.15 : 1.75;
|
19201 | return config.point_focus_expand_enabled ? config.point_focus_expand_r || $$.pointR(d) * scale : $$.pointR(d);
|
19202 | },
|
19203 | pointSelectR: function pointSelectR(d) {
|
19204 | var $$ = this,
|
19205 | selectR = $$.config.point_select_r;
|
19206 | return isFunction(selectR) ? selectR(d) : selectR || $$.pointR(d) * 4;
|
19207 | },
|
19208 | isWithinCircle: function isWithinCircle(node, r) {
|
19209 | var mouse = getPointer(this.state.event, node),
|
19210 | element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(node),
|
19211 | prefix = this.isCirclePoint(node) ? "c" : "",
|
19212 | cx = +element.attr(prefix + "x"),
|
19213 | cy = +element.attr(prefix + "y");
|
19214 |
|
19215 |
|
19216 | if (!(cx || cy) && node.nodeType === 1) {
|
19217 | var _getBoundingRect = getBoundingRect(node),
|
19218 | x = _getBoundingRect.x,
|
19219 | y = _getBoundingRect.y;
|
19220 |
|
19221 | cx = x;
|
19222 | cy = y;
|
19223 | }
|
19224 |
|
19225 | return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < (r || this.config.point_sensitivity);
|
19226 | },
|
19227 | insertPointInfoDefs: function insertPointInfoDefs(point, id) {
|
19228 | var _node$childNodes,
|
19229 | $$ = this,
|
19230 | copyAttr = function (from, target) {
|
19231 | for (var attribs = from.attributes, i = 0, name; name = attribs[i]; i++) {
|
19232 | name = name.name;
|
19233 | target.setAttribute(name, from.getAttribute(name));
|
19234 | }
|
19235 | },
|
19236 | doc = new DOMParser().parseFromString(point, "image/svg+xml"),
|
19237 | node = doc.documentElement,
|
19238 | clone = browser_doc.createElementNS(external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg, node.nodeName.toLowerCase());
|
19239 |
|
19240 | clone.id = id;
|
19241 | clone.style.fill = "inherit";
|
19242 | clone.style.stroke = "inherit";
|
19243 | copyAttr(node, clone);
|
19244 |
|
19245 | if ((_node$childNodes = node.childNodes) != null && _node$childNodes.length) {
|
19246 | var parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(clone);
|
19247 |
|
19248 | if ("innerHTML" in clone) {
|
19249 | parent.html(node.innerHTML);
|
19250 | } else {
|
19251 | toArray(node.childNodes).forEach(function (v) {
|
19252 | copyAttr(v, parent.append(v.tagName).node());
|
19253 | });
|
19254 | }
|
19255 | }
|
19256 |
|
19257 | $$.$el.defs.node().appendChild(clone);
|
19258 | },
|
19259 | pointFromDefs: function pointFromDefs(id) {
|
19260 | return this.$el.defs.select("#" + id);
|
19261 | },
|
19262 | updatePointClass: function updatePointClass(d) {
|
19263 | var $$ = this,
|
19264 | circle = $$.$el.circle,
|
19265 | pointClass = !1;
|
19266 |
|
19267 | if (isObject(d) || circle) {
|
19268 | pointClass = d === !0 ? circle.each(function (d) {
|
19269 | var className = $$.getClass("circle", !0)(d);
|
19270 |
|
19271 | if (this.getAttribute("class").indexOf(config_classes.EXPANDED) > -1) {
|
19272 | className += " " + config_classes.EXPANDED;
|
19273 | }
|
19274 |
|
19275 | this.setAttribute("class", className);
|
19276 | }) : $$.getClass("circle", !0)(d);
|
19277 | }
|
19278 |
|
19279 | return pointClass;
|
19280 | },
|
19281 | generateGetLinePoints: function generateGetLinePoints(lineIndices, isSub) {
|
19282 |
|
19283 | var $$ = this,
|
19284 | config = $$.config,
|
19285 | x = $$.getShapeX(0, lineIndices, isSub),
|
19286 | y = $$.getShapeY(isSub),
|
19287 | lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, isSub),
|
19288 | yScale = $$.getYScaleById.bind($$);
|
19289 | return function (d, i) {
|
19290 | var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
|
19291 | offset = lineOffset(d, i) || y0,
|
19292 | posX = x(d),
|
19293 | posY = y(d);
|
19294 |
|
19295 |
|
19296 | if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
|
19297 | posY = y0;
|
19298 | }
|
19299 |
|
19300 |
|
19301 | var point = [posX, posY - (y0 - offset)];
|
19302 | return [point, point,
|
19303 | point, point];
|
19304 | };
|
19305 | },
|
19306 | generatePoint: function generatePoint() {
|
19307 | var $$ = this,
|
19308 | config = $$.config,
|
19309 | datetimeId = $$.state.datetimeId,
|
19310 | ids = [],
|
19311 | pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
|
19312 | return function (method, context) {
|
19313 | for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
19314 | args[_key - 2] = arguments[_key];
|
19315 | }
|
19316 |
|
19317 | return function (d) {
|
19318 | var _d$data,
|
19319 | id = $$.getTargetSelectorSuffix(d.id || ((_d$data = d.data) == null ? void 0 : _d$data.id) || d),
|
19320 | element = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
19321 |
|
19322 | ids.indexOf(id) < 0 && ids.push(id);
|
19323 | var point = pattern[ids.indexOf(id) % pattern.length];
|
19324 |
|
19325 | if ($$.hasValidPointType(point)) {
|
19326 | point = $$[point];
|
19327 | } else if (!$$.hasValidPointDrawMethods(point)) {
|
19328 | var pointId = datetimeId + "-point" + id,
|
19329 | pointFromDefs = $$.pointFromDefs(pointId);
|
19330 |
|
19331 | if (pointFromDefs.size() < 1) {
|
19332 | $$.insertPointInfoDefs(point, pointId);
|
19333 | }
|
19334 |
|
19335 | if (method === "create") {
|
19336 | return $$.custom.create.bind(context).apply(void 0, [element, pointId].concat(args));
|
19337 | } else if (method === "update") {
|
19338 | return $$.custom.update.bind(context).apply(void 0, [element].concat(args));
|
19339 | }
|
19340 | }
|
19341 |
|
19342 | return point[method].bind(context).apply(void 0, [element].concat(args));
|
19343 | };
|
19344 | };
|
19345 | },
|
19346 | custom: {
|
19347 | create: function create(element, id, sizeFn, fillStyleFn) {
|
19348 | return element.append("use").attr("xlink:href", "#" + id).attr("class", this.updatePointClass.bind(this)).style("fill", fillStyleFn).node();
|
19349 | },
|
19350 | update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
19351 | var $$ = this,
|
19352 | _element$node$getBBox = element.node().getBBox(),
|
19353 | width = _element$node$getBBox.width,
|
19354 | height = _element$node$getBBox.height,
|
19355 | xPosFn2 = function (d) {
|
19356 | return isValue(d.value) ? xPosFn(d) - width / 2 : 0;
|
19357 | },
|
19358 | mainCircles = element;
|
19359 |
|
19360 | if (withTransition) {
|
19361 | flow && mainCircles.attr("x", xPosFn2);
|
19362 | mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
|
19363 | selectedCircles && $$.$T(selectedCircles, withTransition, getTransitionName());
|
19364 | }
|
19365 |
|
19366 | return mainCircles.attr("x", xPosFn2).attr("y", function yPosFn2(d) {
|
19367 | return isValue(d.value) ? yPosFn(d) - height / 2 : 0;
|
19368 | }).style("fill", fillStyleFn);
|
19369 | }
|
19370 | },
|
19371 |
|
19372 | circle: {
|
19373 | create: function create(element, sizeFn, fillStyleFn) {
|
19374 | return element.append("circle").attr("class", this.updatePointClass.bind(this)).attr("r", sizeFn).style("fill", fillStyleFn).node();
|
19375 | },
|
19376 | update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
19377 | var $$ = this,
|
19378 | mainCircles = element;
|
19379 |
|
19380 |
|
19381 | if ($$.hasType("bubble")) {
|
19382 | mainCircles.attr("r", $$.pointR.bind($$));
|
19383 | }
|
19384 |
|
19385 | if (withTransition) {
|
19386 | flow && mainCircles.attr("cx", xPosFn);
|
19387 |
|
19388 | if (mainCircles.attr("cx")) {
|
19389 | mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
|
19390 | }
|
19391 |
|
19392 | selectedCircles && $$.$T(mainCircles, withTransition, getTransitionName());
|
19393 | }
|
19394 |
|
19395 | return mainCircles.attr("cx", xPosFn).attr("cy", yPosFn).style("fill", fillStyleFn);
|
19396 | }
|
19397 | },
|
19398 |
|
19399 | rectangle: {
|
19400 | create: function create(element, sizeFn, fillStyleFn) {
|
19401 | var rectSizeFn = function (d) {
|
19402 | return sizeFn(d) * 2;
|
19403 | };
|
19404 |
|
19405 | return element.append("rect").attr("class", this.updatePointClass.bind(this)).attr("width", rectSizeFn).attr("height", rectSizeFn).style("fill", fillStyleFn).node();
|
19406 | },
|
19407 | update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
19408 | var $$ = this,
|
19409 | r = $$.config.point_r,
|
19410 | rectXPosFn = function (d) {
|
19411 | return xPosFn(d) - r;
|
19412 | },
|
19413 | mainCircles = element;
|
19414 |
|
19415 | if (withTransition) {
|
19416 | flow && mainCircles.attr("x", rectXPosFn);
|
19417 | mainCircles = $$.$T(mainCircles, withTransition, getTransitionName());
|
19418 | selectedCircles && $$.$T(selectedCircles, withTransition, getTransitionName());
|
19419 | }
|
19420 |
|
19421 | return mainCircles.attr("x", rectXPosFn).attr("y", function rectYPosFn(d) {
|
19422 | return yPosFn(d) - r;
|
19423 | }).style("fill", fillStyleFn);
|
19424 | }
|
19425 | }
|
19426 | });
|
19427 | ;
|
19428 |
|
19429 |
|
19430 |
|
19431 |
|
19432 |
|
19433 |
|
19434 |
|
19435 |
|
19436 |
|
19437 |
|
19438 |
|
19439 |
|
19440 |
|
19441 |
|
19442 |
|
19443 |
|
19444 |
|
19445 |
|
19446 |
|
19447 |
|
19448 | function getPosition(isClockwise, type, edge, pos, range, ratio) {
|
19449 | var index = isClockwise && pos > 0 ? edge - pos : pos,
|
19450 | r = 2 * Math.PI,
|
19451 | func = type === "x" ? Math.sin : Math.cos;
|
19452 | return range * (1 - ratio * func(index * r / edge));
|
19453 | }
|
19454 |
|
19455 |
|
19456 | var cacheKey = KEY.radarPoints;
|
19457 | var radar = ({
|
19458 | initRadar: function initRadar() {
|
19459 | var $$ = this,
|
19460 | config = $$.config,
|
19461 | current = $$.state.current,
|
19462 | $el = $$.$el;
|
19463 |
|
19464 | if ($$.hasType("radar")) {
|
19465 | $el.radar = $el.main.select("." + config_classes.chart).append("g").attr("class", config_classes.chartRadars);
|
19466 |
|
19467 | $el.radar.levels = $el.radar.append("g").attr("class", config_classes.levels);
|
19468 |
|
19469 | $el.radar.axes = $el.radar.append("g").attr("class", config_classes.axis);
|
19470 |
|
19471 | $el.radar.shapes = $el.radar.append("g").attr("class", config_classes.shapes);
|
19472 | current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value;
|
19473 | }
|
19474 | },
|
19475 | getRadarSize: function getRadarSize() {
|
19476 | var $$ = this,
|
19477 | config = $$.config,
|
19478 | _$$$state = $$.state,
|
19479 | arcWidth = _$$$state.arcWidth,
|
19480 | arcHeight = _$$$state.arcHeight,
|
19481 | padding = config.axis_x_categories.length < 4 ? -20 : 10,
|
19482 | size = (Math.min(arcWidth, arcHeight) - padding) / 2;
|
19483 | return [size, size];
|
19484 | },
|
19485 | updateTargetsForRadar: function updateTargetsForRadar(targets) {
|
19486 | var $$ = this,
|
19487 | config = $$.config;
|
19488 |
|
19489 | if (isEmpty(config.axis_x_categories)) {
|
19490 | config.axis_x_categories = getRange(0, getMinMax("max", targets.map(function (v) {
|
19491 | return v.values.length;
|
19492 | })));
|
19493 | }
|
19494 |
|
19495 | $$.generateRadarPoints();
|
19496 | },
|
19497 | getRadarPosition: function getRadarPosition(type, index, range, ratio) {
|
19498 | var $$ = this,
|
19499 | config = $$.config,
|
19500 | _$$$getRadarSize = $$.getRadarSize(),
|
19501 | width = _$$$getRadarSize[0],
|
19502 | height = _$$$getRadarSize[1],
|
19503 | edge = config.axis_x_categories.length,
|
19504 | isClockwise = config.radar_direction_clockwise,
|
19505 | pos = toArray(type).map(function (v) {
|
19506 | return getPosition(isClockwise, v, edge, index, isDefined(range) ? range : type === "x" ? width : height, isNumber(ratio) ? ratio : config.radar_size_ratio);
|
19507 | });
|
19508 |
|
19509 | return pos.length === 1 ? pos[0] : pos;
|
19510 | },
|
19511 |
|
19512 | |
19513 |
|
19514 |
|
19515 |
|
19516 | generateRadarPoints: function generateRadarPoints() {
|
19517 | var $$ = this,
|
19518 | targets = $$.data.targets,
|
19519 | _$$$getRadarSize2 = $$.getRadarSize(),
|
19520 | width = _$$$getRadarSize2[0],
|
19521 | height = _$$$getRadarSize2[1],
|
19522 | points = $$.cache.get(cacheKey) || {},
|
19523 | size = points._size;
|
19524 |
|
19525 |
|
19526 | if (!size || size.width !== width && size.height !== height) {
|
19527 | targets.forEach(function (d) {
|
19528 | points[d.id] = d.values.map(function (v, i) {
|
19529 | return $$.getRadarPosition(["x", "y"], i, undefined, $$.getRatio("radar", v));
|
19530 | });
|
19531 | });
|
19532 | points._size = {
|
19533 | width: width,
|
19534 | height: height
|
19535 | };
|
19536 | $$.cache.add(cacheKey, points);
|
19537 | }
|
19538 | },
|
19539 | redrawRadar: function redrawRadar() {
|
19540 | var $$ = this,
|
19541 | _$$$$el = $$.$el,
|
19542 | radar = _$$$$el.radar,
|
19543 | main = _$$$$el.main,
|
19544 | translate = $$.getTranslate("radar");
|
19545 |
|
19546 |
|
19547 | if (translate) {
|
19548 | radar.attr("transform", translate);
|
19549 | main.select("." + config_classes.chartTexts).attr("transform", translate);
|
19550 | $$.generateRadarPoints();
|
19551 | $$.updateRadarLevel();
|
19552 | $$.updateRadarAxes();
|
19553 | $$.updateRadarShape();
|
19554 | }
|
19555 | },
|
19556 | generateGetRadarPoints: function generateGetRadarPoints() {
|
19557 | var points = this.cache.get(cacheKey);
|
19558 | return function (d, i) {
|
19559 | var point = points[d.id][i];
|
19560 | return [point, point, point, point];
|
19561 | };
|
19562 | },
|
19563 | updateRadarLevel: function updateRadarLevel() {
|
19564 | var $$ = this,
|
19565 | config = $$.config,
|
19566 | state = $$.state,
|
19567 | radar = $$.$el.radar,
|
19568 | _$$$getRadarSize3 = $$.getRadarSize(),
|
19569 | width = _$$$getRadarSize3[0],
|
19570 | height = _$$$getRadarSize3[1],
|
19571 | depth = config.radar_level_depth,
|
19572 | edge = config.axis_x_categories.length,
|
19573 | showText = config.radar_level_text_show,
|
19574 | radarLevels = radar.levels,
|
19575 | levelData = getRange(0, depth),
|
19576 | radius = config.radar_size_ratio * Math.min(width, height),
|
19577 | levelRatio = levelData.map(function (l) {
|
19578 | return radius * ((l + 1) / depth);
|
19579 | }),
|
19580 | levelTextFormat = (config.radar_level_text_format || function () {}).bind($$.api),
|
19581 | points = levelData.map(function (v) {
|
19582 | var range = levelRatio[v],
|
19583 | pos = getRange(0, edge).map(function (i) {
|
19584 | return $$.getRadarPosition(["x", "y"], i, range, 1).join(",");
|
19585 | });
|
19586 | return pos.join(" ");
|
19587 | }),
|
19588 | level = radarLevels.selectAll("." + config_classes.level).data(levelData);
|
19589 |
|
19590 | level.exit().remove();
|
19591 | var levelEnter = level.enter().append("g").attr("class", function (d, i) {
|
19592 | return config_classes.level + " " + config_classes.level + "-" + i;
|
19593 | });
|
19594 | levelEnter.append("polygon").style("visibility", config.radar_level_show ? null : "hidden");
|
19595 |
|
19596 | if (showText) {
|
19597 | if (radarLevels.select("text").empty()) {
|
19598 | radarLevels.append("text").attr("dx", "-.5em").attr("dy", "-.7em").style("text-anchor", "end").text(function () {
|
19599 | return levelTextFormat(0);
|
19600 | });
|
19601 | }
|
19602 |
|
19603 | levelEnter.append("text").attr("dx", "-.5em").style("text-anchor", "end").text(function (d) {
|
19604 | return levelTextFormat(state.current.dataMax / levelData.length * (d + 1));
|
19605 | });
|
19606 | }
|
19607 |
|
19608 | levelEnter.merge(level).attr("transform", function (d) {
|
19609 | return "translate(" + (width - levelRatio[d]) + ", " + (height - levelRatio[d]) + ")";
|
19610 | }).selectAll("polygon").attr("points", function (d) {
|
19611 | return points[d];
|
19612 | });
|
19613 |
|
19614 | if (showText) {
|
19615 | radarLevels.selectAll("text").attr("x", function (d) {
|
19616 | return isUndefined(d) ? width : points[d].split(",")[0];
|
19617 | }).attr("y", function (d) {
|
19618 | return isUndefined(d) ? height : 0;
|
19619 | });
|
19620 | }
|
19621 | },
|
19622 | updateRadarAxes: function updateRadarAxes() {
|
19623 | var $$ = this,
|
19624 | config = $$.config,
|
19625 | radar = $$.$el.radar,
|
19626 | _$$$getRadarSize4 = $$.getRadarSize(),
|
19627 | width = _$$$getRadarSize4[0],
|
19628 | height = _$$$getRadarSize4[1],
|
19629 | categories = config.axis_x_categories,
|
19630 | axis = radar.axes.selectAll("g").data(categories);
|
19631 |
|
19632 | axis.exit().remove();
|
19633 | var axisEnter = axis.enter().append("g").attr("class", function (d, i) {
|
19634 | return config_classes.axis + "-" + i;
|
19635 | });
|
19636 | config.radar_axis_line_show && axisEnter.append("line");
|
19637 | config.radar_axis_text_show && axisEnter.append("text");
|
19638 | axis = axisEnter.merge(axis);
|
19639 |
|
19640 | if (config.radar_axis_line_show) {
|
19641 | axis.select("line").attr("x1", width).attr("y1", height).attr("x2", function (d, i) {
|
19642 | return $$.getRadarPosition("x", i);
|
19643 | }).attr("y2", function (d, i) {
|
19644 | return $$.getRadarPosition("y", i);
|
19645 | });
|
19646 | }
|
19647 |
|
19648 |
|
19649 | if (config.radar_axis_text_show) {
|
19650 | var _config$radar_axis_te = config.radar_axis_text_position,
|
19651 | _config$radar_axis_te2 = _config$radar_axis_te.x,
|
19652 | x = _config$radar_axis_te2 === void 0 ? 0 : _config$radar_axis_te2,
|
19653 | _config$radar_axis_te3 = _config$radar_axis_te.y,
|
19654 | y = _config$radar_axis_te3 === void 0 ? 0 : _config$radar_axis_te3;
|
19655 | axis.select("text").style("text-anchor", "middle").attr("dy", ".5em").call(function (selection) {
|
19656 | selection.each(function (d) {
|
19657 | setTextValue((0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this), d + "", [-.6, 1.2]);
|
19658 | });
|
19659 | }).datum(function (d, i) {
|
19660 | return {
|
19661 | index: i
|
19662 | };
|
19663 | }).attr("transform", function (d) {
|
19664 | if (isUndefined(this.width)) {
|
19665 |
|
19666 | this.width = this.getBoundingClientRect().width / 2;
|
19667 | }
|
19668 |
|
19669 | var posX = $$.getRadarPosition("x", d.index, undefined, 1),
|
19670 | posY = Math.round($$.getRadarPosition("y", d.index, undefined, 1));
|
19671 |
|
19672 | if (posX > width) {
|
19673 | posX += this.width + x;
|
19674 | } else if (Math.round(posX) < width) {
|
19675 | posX -= this.width + x;
|
19676 | }
|
19677 |
|
19678 | if (posY > height) {
|
19679 |
|
19680 | if (posY / 2 === height && this.firstChild.tagName === "tspan") {
|
19681 | this.firstChild.setAttribute("dy", "0em");
|
19682 | }
|
19683 |
|
19684 | posY += y;
|
19685 | } else if (posY < height) {
|
19686 | posY -= y;
|
19687 | }
|
19688 |
|
19689 | return "translate(" + posX + " " + posY + ")";
|
19690 | });
|
19691 | }
|
19692 |
|
19693 | $$.bindEvent();
|
19694 | },
|
19695 | bindEvent: function bindEvent() {
|
19696 | var $$ = this,
|
19697 | config = $$.config,
|
19698 | state = $$.state,
|
19699 | _$$$$el2 = $$.$el,
|
19700 | radar = _$$$$el2.radar,
|
19701 | svg = _$$$$el2.svg,
|
19702 | focusOnly = config.point_focus_only,
|
19703 | _state = state,
|
19704 | inputType = _state.inputType,
|
19705 | transiting = _state.transiting;
|
19706 |
|
19707 | if (config.interaction_enabled) {
|
19708 | var isMouse = inputType === "mouse",
|
19709 | getIndex = function (event) {
|
19710 | var target = event.target;
|
19711 |
|
19712 | if (/tspan/i.test(target.tagName)) {
|
19713 | target = target.parentNode;
|
19714 | }
|
19715 |
|
19716 | var d = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(target).datum();
|
19717 | return d && Object.keys(d).length === 1 ? d.index : undefined;
|
19718 | },
|
19719 | hide = function (event) {
|
19720 | var index = getIndex(event),
|
19721 | noIndex = isUndefined(index);
|
19722 |
|
19723 | if (isMouse || noIndex) {
|
19724 | $$.hideTooltip();
|
19725 | focusOnly ? $$.hideCircleFocus() : $$.unexpandCircles();
|
19726 |
|
19727 | if (isMouse) {
|
19728 | $$.setOverOut(!1, index);
|
19729 | } else if (noIndex) {
|
19730 | $$.callOverOutForTouch();
|
19731 | }
|
19732 | }
|
19733 | };
|
19734 |
|
19735 | radar.axes.selectAll("text").on(isMouse ? "mouseover " : "touchstart", function (event) {
|
19736 | if (transiting) {
|
19737 |
|
19738 | return;
|
19739 | }
|
19740 |
|
19741 | state.event = event;
|
19742 | var index = getIndex(event);
|
19743 | $$.selectRectForSingle(svg.node(), null, index);
|
19744 | isMouse ? $$.setOverOut(!0, index) : $$.callOverOutForTouch(index);
|
19745 | }).on("mouseout", isMouse ? hide : null);
|
19746 |
|
19747 | if (!isMouse) {
|
19748 | svg.on("touchstart", hide);
|
19749 | }
|
19750 | }
|
19751 | },
|
19752 | updateRadarShape: function updateRadarShape() {
|
19753 | var $$ = this,
|
19754 | targets = $$.data.targets.filter(function (d) {
|
19755 | return $$.isRadarType(d);
|
19756 | }),
|
19757 | points = $$.cache.get(cacheKey),
|
19758 | areas = $$.$el.radar.shapes.selectAll("polygon").data(targets),
|
19759 | areasEnter = areas.enter().append("g").attr("class", $$.getChartClass("Radar"));
|
19760 | $$.$T(areas.exit()).remove();
|
19761 | areasEnter.append("polygon").merge(areas).style("fill", $$.color).style("stroke", $$.color).attr("points", function (d) {
|
19762 | return points[d.id].join(" ");
|
19763 | });
|
19764 | $$.updateTargetForCircle(targets, areasEnter);
|
19765 | },
|
19766 |
|
19767 | |
19768 |
|
19769 |
|
19770 |
|
19771 |
|
19772 |
|
19773 | radarCircleX: function radarCircleX(d) {
|
19774 | return this.cache.get(cacheKey)[d.id][d.index][0];
|
19775 | },
|
19776 |
|
19777 | |
19778 |
|
19779 |
|
19780 |
|
19781 |
|
19782 |
|
19783 | radarCircleY: function radarCircleY(d) {
|
19784 | return this.cache.get(cacheKey)[d.id][d.index][1];
|
19785 | }
|
19786 | });
|
19787 | ;
|
19788 |
|
19789 |
|
19790 |
|
19791 |
|
19792 |
|
19793 |
|
19794 |
|
19795 |
|
19796 | var common_point = ({
|
19797 | |
19798 |
|
19799 |
|
19800 |
|
19801 |
|
19802 |
|
19803 |
|
19804 |
|
19805 |
|
19806 |
|
19807 |
|
19808 |
|
19809 |
|
19810 |
|
19811 |
|
19812 |
|
19813 |
|
19814 |
|
19815 |
|
19816 |
|
19817 |
|
19818 |
|
19819 |
|
19820 |
|
19821 |
|
19822 |
|
19823 |
|
19824 |
|
19825 |
|
19826 |
|
19827 |
|
19828 |
|
19829 |
|
19830 |
|
19831 |
|
19832 |
|
19833 |
|
19834 |
|
19835 |
|
19836 |
|
19837 |
|
19838 |
|
19839 |
|
19840 |
|
19841 |
|
19842 |
|
19843 |
|
19844 |
|
19845 |
|
19846 |
|
19847 |
|
19848 |
|
19849 |
|
19850 |
|
19851 |
|
19852 |
|
19853 |
|
19854 |
|
19855 |
|
19856 |
|
19857 |
|
19858 |
|
19859 |
|
19860 |
|
19861 |
|
19862 |
|
19863 |
|
19864 |
|
19865 |
|
19866 |
|
19867 |
|
19868 |
|
19869 |
|
19870 |
|
19871 |
|
19872 |
|
19873 |
|
19874 |
|
19875 |
|
19876 |
|
19877 |
|
19878 | point_show: !0,
|
19879 | point_r: 2.5,
|
19880 | point_sensitivity: 10,
|
19881 | point_focus_expand_enabled: !0,
|
19882 | point_focus_expand_r: undefined,
|
19883 | point_focus_only: !1,
|
19884 | point_opacity: undefined,
|
19885 | point_pattern: [],
|
19886 | point_select_r: undefined,
|
19887 | point_type: "circle"
|
19888 | });
|
19889 | ;
|
19890 |
|
19891 |
|
19892 |
|
19893 |
|
19894 |
|
19895 |
|
19896 |
|
19897 |
|
19898 | var Options_shape_area = ({
|
19899 | |
19900 |
|
19901 |
|
19902 |
|
19903 |
|
19904 |
|
19905 |
|
19906 |
|
19907 |
|
19908 |
|
19909 |
|
19910 |
|
19911 |
|
19912 |
|
19913 |
|
19914 |
|
19915 |
|
19916 |
|
19917 |
|
19918 |
|
19919 |
|
19920 |
|
19921 |
|
19922 |
|
19923 |
|
19924 |
|
19925 |
|
19926 |
|
19927 |
|
19928 |
|
19929 |
|
19930 |
|
19931 |
|
19932 |
|
19933 |
|
19934 |
|
19935 |
|
19936 |
|
19937 |
|
19938 |
|
19939 |
|
19940 |
|
19941 |
|
19942 |
|
19943 |
|
19944 |
|
19945 |
|
19946 |
|
19947 |
|
19948 |
|
19949 |
|
19950 | area_above: !1,
|
19951 | area_front: !0,
|
19952 | area_linearGradient: !1,
|
19953 | area_zerobased: !0
|
19954 | });
|
19955 | ;
|
19956 |
|
19957 |
|
19958 |
|
19959 |
|
19960 |
|
19961 |
|
19962 |
|
19963 |
|
19964 | var shape_bar = ({
|
19965 | |
19966 |
|
19967 |
|
19968 |
|
19969 |
|
19970 |
|
19971 |
|
19972 |
|
19973 |
|
19974 |
|
19975 |
|
19976 |
|
19977 |
|
19978 |
|
19979 |
|
19980 |
|
19981 |
|
19982 |
|
19983 |
|
19984 |
|
19985 |
|
19986 |
|
19987 |
|
19988 |
|
19989 |
|
19990 |
|
19991 |
|
19992 |
|
19993 |
|
19994 |
|
19995 |
|
19996 |
|
19997 |
|
19998 |
|
19999 |
|
20000 |
|
20001 |
|
20002 |
|
20003 |
|
20004 |
|
20005 |
|
20006 |
|
20007 |
|
20008 |
|
20009 |
|
20010 |
|
20011 |
|
20012 |
|
20013 |
|
20014 |
|
20015 |
|
20016 |
|
20017 |
|
20018 |
|
20019 |
|
20020 |
|
20021 |
|
20022 |
|
20023 |
|
20024 |
|
20025 |
|
20026 |
|
20027 |
|
20028 |
|
20029 |
|
20030 |
|
20031 | bar_label_threshold: 0,
|
20032 | bar_padding: 0,
|
20033 | bar_radius: undefined,
|
20034 | bar_radius_ratio: undefined,
|
20035 | bar_sensitivity: 2,
|
20036 | bar_width: undefined,
|
20037 | bar_width_ratio: .6,
|
20038 | bar_width_max: undefined,
|
20039 | bar_zerobased: !0
|
20040 | });
|
20041 | ;
|
20042 |
|
20043 |
|
20044 |
|
20045 |
|
20046 |
|
20047 |
|
20048 |
|
20049 |
|
20050 | var shape_bubble = ({
|
20051 | |
20052 |
|
20053 |
|
20054 |
|
20055 |
|
20056 |
|
20057 |
|
20058 |
|
20059 |
|
20060 |
|
20061 |
|
20062 |
|
20063 |
|
20064 |
|
20065 |
|
20066 |
|
20067 |
|
20068 |
|
20069 |
|
20070 |
|
20071 |
|
20072 |
|
20073 |
|
20074 | bubble_maxR: 35,
|
20075 | bubble_zerobased: !1
|
20076 | });
|
20077 | ;
|
20078 |
|
20079 |
|
20080 |
|
20081 |
|
20082 |
|
20083 |
|
20084 |
|
20085 |
|
20086 | var shape_candlestick = ({
|
20087 | |
20088 |
|
20089 |
|
20090 |
|
20091 |
|
20092 |
|
20093 |
|
20094 |
|
20095 |
|
20096 |
|
20097 |
|
20098 |
|
20099 |
|
20100 |
|
20101 |
|
20102 |
|
20103 |
|
20104 |
|
20105 |
|
20106 |
|
20107 |
|
20108 |
|
20109 |
|
20110 |
|
20111 |
|
20112 |
|
20113 |
|
20114 |
|
20115 |
|
20116 |
|
20117 |
|
20118 |
|
20119 |
|
20120 |
|
20121 |
|
20122 |
|
20123 |
|
20124 |
|
20125 |
|
20126 |
|
20127 |
|
20128 |
|
20129 |
|
20130 |
|
20131 |
|
20132 |
|
20133 |
|
20134 | candlestick_width: undefined,
|
20135 | candlestick_width_ratio: .6,
|
20136 | candlestick_width_max: undefined,
|
20137 | candlestick_color_down: "red"
|
20138 | });
|
20139 | ;
|
20140 |
|
20141 |
|
20142 |
|
20143 |
|
20144 |
|
20145 |
|
20146 |
|
20147 |
|
20148 | var shape_line = ({
|
20149 | |
20150 |
|
20151 |
|
20152 |
|
20153 |
|
20154 |
|
20155 |
|
20156 |
|
20157 |
|
20158 |
|
20159 |
|
20160 |
|
20161 |
|
20162 |
|
20163 |
|
20164 |
|
20165 |
|
20166 |
|
20167 |
|
20168 |
|
20169 |
|
20170 |
|
20171 |
|
20172 |
|
20173 |
|
20174 |
|
20175 |
|
20176 |
|
20177 |
|
20178 |
|
20179 |
|
20180 |
|
20181 |
|
20182 |
|
20183 |
|
20184 |
|
20185 |
|
20186 |
|
20187 |
|
20188 |
|
20189 |
|
20190 |
|
20191 | line_connectNull: !1,
|
20192 | line_step_type: "step",
|
20193 | line_step_tooltipMatch: !1,
|
20194 | line_zerobased: !1,
|
20195 | line_classes: undefined,
|
20196 | line_point: !0
|
20197 | });
|
20198 | ;
|
20199 |
|
20200 |
|
20201 |
|
20202 |
|
20203 |
|
20204 |
|
20205 |
|
20206 |
|
20207 | var scatter = ({
|
20208 | |
20209 |
|
20210 |
|
20211 |
|
20212 |
|
20213 |
|
20214 |
|
20215 |
|
20216 |
|
20217 |
|
20218 |
|
20219 |
|
20220 |
|
20221 |
|
20222 |
|
20223 |
|
20224 |
|
20225 |
|
20226 |
|
20227 |
|
20228 |
|
20229 |
|
20230 |
|
20231 |
|
20232 |
|
20233 | scatter_zerobased: !1
|
20234 | });
|
20235 | ;
|
20236 |
|
20237 |
|
20238 |
|
20239 |
|
20240 |
|
20241 |
|
20242 |
|
20243 |
|
20244 | var spline = ({
|
20245 | |
20246 |
|
20247 |
|
20248 |
|
20249 |
|
20250 |
|
20251 |
|
20252 |
|
20253 |
|
20254 |
|
20255 |
|
20256 |
|
20257 |
|
20258 |
|
20259 |
|
20260 |
|
20261 |
|
20262 |
|
20263 |
|
20264 |
|
20265 |
|
20266 |
|
20267 |
|
20268 |
|
20269 |
|
20270 |
|
20271 |
|
20272 |
|
20273 |
|
20274 |
|
20275 |
|
20276 |
|
20277 |
|
20278 |
|
20279 |
|
20280 | spline_interpolation_type: "cardinal"
|
20281 | });
|
20282 | ;
|
20283 |
|
20284 |
|
20285 |
|
20286 |
|
20287 |
|
20288 |
|
20289 |
|
20290 |
|
20291 | var donut = ({
|
20292 | |
20293 |
|
20294 |
|
20295 |
|
20296 |
|
20297 |
|
20298 |
|
20299 |
|
20300 |
|
20301 |
|
20302 |
|
20303 |
|
20304 |
|
20305 |
|
20306 |
|
20307 |
|
20308 |
|
20309 |
|
20310 |
|
20311 |
|
20312 |
|
20313 |
|
20314 |
|
20315 |
|
20316 |
|
20317 |
|
20318 |
|
20319 |
|
20320 |
|
20321 |
|
20322 |
|
20323 |
|
20324 |
|
20325 |
|
20326 |
|
20327 |
|
20328 |
|
20329 |
|
20330 |
|
20331 |
|
20332 |
|
20333 |
|
20334 |
|
20335 |
|
20336 |
|
20337 |
|
20338 |
|
20339 |
|
20340 |
|
20341 |
|
20342 |
|
20343 |
|
20344 |
|
20345 |
|
20346 |
|
20347 |
|
20348 |
|
20349 |
|
20350 |
|
20351 |
|
20352 |
|
20353 | donut_label_show: !0,
|
20354 | donut_label_format: undefined,
|
20355 | donut_label_threshold: .05,
|
20356 | donut_label_ratio: undefined,
|
20357 | donut_width: undefined,
|
20358 | donut_title: "",
|
20359 | donut_expand: {},
|
20360 | donut_expand_rate: .98,
|
20361 | donut_expand_duration: 50,
|
20362 | donut_padAngle: 0,
|
20363 | donut_startingAngle: 0
|
20364 | });
|
20365 | ;
|
20366 |
|
20367 |
|
20368 |
|
20369 |
|
20370 |
|
20371 |
|
20372 |
|
20373 |
|
20374 | var shape_gauge = ({
|
20375 | |
20376 |
|
20377 |
|
20378 |
|
20379 |
|
20380 |
|
20381 |
|
20382 |
|
20383 |
|
20384 |
|
20385 |
|
20386 |
|
20387 |
|
20388 |
|
20389 |
|
20390 |
|
20391 |
|
20392 |
|
20393 |
|
20394 |
|
20395 |
|
20396 |
|
20397 |
|
20398 |
|
20399 |
|
20400 |
|
20401 |
|
20402 |
|
20403 |
|
20404 |
|
20405 |
|
20406 |
|
20407 |
|
20408 |
|
20409 |
|
20410 |
|
20411 |
|
20412 |
|
20413 |
|
20414 |
|
20415 |
|
20416 |
|
20417 |
|
20418 |
|
20419 |
|
20420 |
|
20421 |
|
20422 |
|
20423 |
|
20424 |
|
20425 |
|
20426 |
|
20427 |
|
20428 |
|
20429 |
|
20430 |
|
20431 |
|
20432 |
|
20433 |
|
20434 |
|
20435 |
|
20436 |
|
20437 |
|
20438 |
|
20439 |
|
20440 |
|
20441 |
|
20442 |
|
20443 |
|
20444 |
|
20445 |
|
20446 |
|
20447 |
|
20448 |
|
20449 |
|
20450 |
|
20451 |
|
20452 |
|
20453 |
|
20454 |
|
20455 |
|
20456 |
|
20457 |
|
20458 |
|
20459 |
|
20460 |
|
20461 |
|
20462 |
|
20463 |
|
20464 |
|
20465 |
|
20466 |
|
20467 |
|
20468 |
|
20469 |
|
20470 | gauge_background: "",
|
20471 | gauge_fullCircle: !1,
|
20472 | gauge_label_show: !0,
|
20473 | gauge_label_format: undefined,
|
20474 | gauge_label_extents: undefined,
|
20475 | gauge_label_threshold: 0,
|
20476 | gauge_min: 0,
|
20477 | gauge_max: 100,
|
20478 | gauge_type: "single",
|
20479 | gauge_startingAngle: -1 * Math.PI / 2,
|
20480 | gauge_arcLength: 100,
|
20481 | gauge_title: "",
|
20482 | gauge_units: undefined,
|
20483 | gauge_width: undefined,
|
20484 | gauge_arcs_minWidth: 5,
|
20485 | gauge_expand: {},
|
20486 | gauge_expand_rate: .98,
|
20487 | gauge_expand_duration: 50
|
20488 | });
|
20489 | ;
|
20490 |
|
20491 |
|
20492 |
|
20493 |
|
20494 |
|
20495 |
|
20496 |
|
20497 |
|
20498 | var pie = ({
|
20499 | |
20500 |
|
20501 |
|
20502 |
|
20503 |
|
20504 |
|
20505 |
|
20506 |
|
20507 |
|
20508 |
|
20509 |
|
20510 |
|
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 | pie_label_show: !0,
|
20578 | pie_label_format: undefined,
|
20579 | pie_label_threshold: .05,
|
20580 | pie_label_ratio: undefined,
|
20581 | pie_expand: {},
|
20582 | pie_expand_rate: .98,
|
20583 | pie_expand_duration: 50,
|
20584 | pie_innerRadius: 0,
|
20585 | pie_outerRadius: undefined,
|
20586 | pie_padAngle: 0,
|
20587 | pie_padding: 0,
|
20588 | pie_startingAngle: 0
|
20589 | });
|
20590 | ;
|
20591 |
|
20592 |
|
20593 |
|
20594 |
|
20595 |
|
20596 |
|
20597 |
|
20598 |
|
20599 | var shape_radar = ({
|
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 |
|
20653 |
|
20654 |
|
20655 |
|
20656 | radar_axis_max: undefined,
|
20657 | radar_axis_line_show: !0,
|
20658 | radar_axis_text_show: !0,
|
20659 | radar_axis_text_position: {},
|
20660 | radar_level_depth: 3,
|
20661 | radar_level_show: !0,
|
20662 | radar_level_text_format: function radar_level_text_format(x) {
|
20663 | return x % 1 === 0 ? x : x.toFixed(2);
|
20664 | },
|
20665 | radar_level_text_show: !0,
|
20666 | radar_size_ratio: .87,
|
20667 | radar_direction_clockwise: !1
|
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 | function extendAxis(module, option) {
|
20714 | extend(ChartInternal.prototype, internal.concat(module));
|
20715 | extend(Chart.prototype, api);
|
20716 | Options.setOptions(options.concat(option || []));
|
20717 | }
|
20718 |
|
20719 |
|
20720 |
|
20721 |
|
20722 |
|
20723 |
|
20724 |
|
20725 |
|
20726 | function extendLine(module, option) {
|
20727 | extendAxis([point, line].concat(module || []));
|
20728 | Options.setOptions([common_point, shape_line].concat(option || []));
|
20729 | }
|
20730 |
|
20731 |
|
20732 |
|
20733 |
|
20734 |
|
20735 |
|
20736 |
|
20737 |
|
20738 | function extendArc(module, option) {
|
20739 | extend(ChartInternal.prototype, [arc].concat(module || []));
|
20740 | Options.setOptions(option);
|
20741 | }
|
20742 |
|
20743 |
|
20744 | var _area = function area() {
|
20745 | return extendLine(shape_area, [Options_shape_area]), (_area = function area() {
|
20746 | return TYPE.AREA;
|
20747 | })();
|
20748 | },
|
20749 | areaLineRange = function () {
|
20750 | return extendLine(shape_area, [Options_shape_area]), (areaLineRange = function () {
|
20751 | return TYPE.AREA_LINE_RANGE;
|
20752 | })();
|
20753 | },
|
20754 | areaSpline = function () {
|
20755 | return extendLine(shape_area, [Options_shape_area, spline]), (areaSpline = function () {
|
20756 | return TYPE.AREA_SPLINE;
|
20757 | })();
|
20758 | },
|
20759 | areaSplineRange = function () {
|
20760 | return extendLine(shape_area, [Options_shape_area, spline]), (areaSplineRange = function () {
|
20761 | return TYPE.AREA_SPLINE_RANGE;
|
20762 | })();
|
20763 | },
|
20764 | areaStep = function () {
|
20765 | return extendLine(shape_area, [Options_shape_area]), (areaStep = function () {
|
20766 | return TYPE.AREA_STEP;
|
20767 | })();
|
20768 | },
|
20769 | resolver_shape_line = function () {
|
20770 | return extendLine(), (resolver_shape_line = function () {
|
20771 | return TYPE.LINE;
|
20772 | })();
|
20773 | },
|
20774 | shape_spline = function () {
|
20775 | return extendLine(undefined, [spline]), (shape_spline = function () {
|
20776 | return TYPE.SPLINE;
|
20777 | })();
|
20778 | },
|
20779 | step = function () {
|
20780 | return extendLine(), (step = function () {
|
20781 | return TYPE.STEP;
|
20782 | })();
|
20783 | },
|
20784 | shape_donut = function () {
|
20785 | return extendArc(undefined, [donut]), (shape_donut = function () {
|
20786 | return TYPE.DONUT;
|
20787 | })();
|
20788 | },
|
20789 | resolver_shape_gauge = function () {
|
20790 | return extendArc([gauge], [shape_gauge]), (resolver_shape_gauge = function () {
|
20791 | return TYPE.GAUGE;
|
20792 | })();
|
20793 | },
|
20794 | shape_pie = function () {
|
20795 | return extendArc(undefined, [pie]), (shape_pie = function () {
|
20796 | return TYPE.PIE;
|
20797 | })();
|
20798 | },
|
20799 | resolver_shape_radar = function () {
|
20800 | return extendArc([point, radar], [common_point, shape_radar]), (resolver_shape_radar = function () {
|
20801 | return TYPE.RADAR;
|
20802 | })();
|
20803 | },
|
20804 | resolver_shape_bar = function () {
|
20805 | return extendAxis([bar], shape_bar), (resolver_shape_bar = function () {
|
20806 | return TYPE.BAR;
|
20807 | })();
|
20808 | },
|
20809 | resolver_shape_bubble = function () {
|
20810 | return extendAxis([point, bubble], [shape_bubble, common_point]), (resolver_shape_bubble = function () {
|
20811 | return TYPE.BUBBLE;
|
20812 | })();
|
20813 | },
|
20814 | resolver_shape_candlestick = function () {
|
20815 | return extendAxis([candlestick], [shape_candlestick]), (resolver_shape_candlestick = function () {
|
20816 | return TYPE.CANDLESTICK;
|
20817 | })();
|
20818 | },
|
20819 | shape_scatter = function () {
|
20820 | return extendAxis([point], [common_point, scatter]), (shape_scatter = function () {
|
20821 | return TYPE.SCATTER;
|
20822 | })();
|
20823 | };
|
20824 | ;
|
20825 |
|
20826 |
|
20827 |
|
20828 |
|
20829 |
|
20830 |
|
20831 |
|
20832 | var selection = ({
|
20833 | |
20834 |
|
20835 |
|
20836 |
|
20837 |
|
20838 |
|
20839 |
|
20840 |
|
20841 |
|
20842 |
|
20843 |
|
20844 |
|
20845 |
|
20846 |
|
20847 |
|
20848 |
|
20849 | selected: function selected(targetId) {
|
20850 | var $$ = this.internal,
|
20851 | dataPoint = [];
|
20852 | $$.$el.main.selectAll("." + (config_classes.shapes + $$.getTargetSelectorSuffix(targetId))).selectAll("." + config_classes.shape).filter(function () {
|
20853 | return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed(config_classes.SELECTED);
|
20854 | }).each(function (d) {
|
20855 | return dataPoint.push(d);
|
20856 | });
|
20857 | return dataPoint;
|
20858 | },
|
20859 |
|
20860 | |
20861 |
|
20862 |
|
20863 |
|
20864 |
|
20865 |
|
20866 |
|
20867 |
|
20868 |
|
20869 |
|
20870 |
|
20871 |
|
20872 |
|
20873 |
|
20874 |
|
20875 |
|
20876 |
|
20877 |
|
20878 |
|
20879 |
|
20880 |
|
20881 |
|
20882 |
|
20883 |
|
20884 | select: function select(ids, indices, resetOther) {
|
20885 | var $$ = this.internal,
|
20886 | config = $$.config,
|
20887 | $el = $$.$el;
|
20888 |
|
20889 | if (!config.data_selection_enabled) {
|
20890 | return;
|
20891 | }
|
20892 |
|
20893 | $el.main.selectAll("." + config_classes.shapes).selectAll("." + config_classes.shape).each(function (d, i) {
|
20894 | var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
20895 | id = d.data ? d.data.id : d.id,
|
20896 | toggle = $$.getToggle(this, d).bind($$),
|
20897 | isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
|
20898 | isTargetIndex = !indices || indices.indexOf(i) >= 0,
|
20899 | isSelected = shape.classed(config_classes.SELECTED);
|
20900 |
|
20901 |
|
20902 | if (shape.classed(config_classes.line) || shape.classed(config_classes.area)) {
|
20903 | return;
|
20904 | }
|
20905 |
|
20906 | if (isTargetId && isTargetIndex) {
|
20907 | if (config.data_selection_isselectable.bind($$.api)(d) && !isSelected) {
|
20908 | toggle(!0, shape.classed(config_classes.SELECTED, !0), d, i);
|
20909 | }
|
20910 | } else if (isDefined(resetOther) && resetOther && isSelected) {
|
20911 | toggle(!1, shape.classed(config_classes.SELECTED, !1), d, i);
|
20912 | }
|
20913 | });
|
20914 | },
|
20915 |
|
20916 | |
20917 |
|
20918 |
|
20919 |
|
20920 |
|
20921 |
|
20922 |
|
20923 |
|
20924 |
|
20925 |
|
20926 |
|
20927 |
|
20928 |
|
20929 |
|
20930 |
|
20931 |
|
20932 |
|
20933 | unselect: function unselect(ids, indices) {
|
20934 | var $$ = this.internal,
|
20935 | config = $$.config,
|
20936 | $el = $$.$el;
|
20937 |
|
20938 | if (!config.data_selection_enabled) {
|
20939 | return;
|
20940 | }
|
20941 |
|
20942 | $el.main.selectAll("." + config_classes.shapes).selectAll("." + config_classes.shape).each(function (d, i) {
|
20943 | var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
20944 | id = d.data ? d.data.id : d.id,
|
20945 | toggle = $$.getToggle(this, d).bind($$),
|
20946 | isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0,
|
20947 | isTargetIndex = !indices || indices.indexOf(i) >= 0,
|
20948 | isSelected = shape.classed(config_classes.SELECTED);
|
20949 |
|
20950 |
|
20951 | if (shape.classed(config_classes.line) || shape.classed(config_classes.area)) {
|
20952 | return;
|
20953 | }
|
20954 |
|
20955 | if (isTargetId && isTargetIndex && config.data_selection_isselectable.bind($$.api)(d) && isSelected) {
|
20956 | toggle(!1, shape.classed(config_classes.SELECTED, !1), d, i);
|
20957 | }
|
20958 | });
|
20959 | }
|
20960 | });
|
20961 | ;
|
20962 |
|
20963 |
|
20964 |
|
20965 |
|
20966 |
|
20967 | var subchart = ({
|
20968 | subchart: {
|
20969 | |
20970 |
|
20971 |
|
20972 |
|
20973 |
|
20974 |
|
20975 |
|
20976 |
|
20977 |
|
20978 |
|
20979 |
|
20980 |
|
20981 |
|
20982 |
|
20983 |
|
20984 |
|
20985 |
|
20986 |
|
20987 |
|
20988 |
|
20989 |
|
20990 |
|
20991 |
|
20992 | show: function () {
|
20993 | var $$ = this.internal,
|
20994 | subchart = $$.$el.subchart,
|
20995 | config = $$.config,
|
20996 | show = config.subchart_show;
|
20997 |
|
20998 | if (!show) {
|
20999 |
|
21000 | $$.unbindZoomEvent();
|
21001 | config.subchart_show = !show;
|
21002 | subchart.main || $$.initSubchart();
|
21003 | var $target = subchart.main.selectAll("." + config_classes.target);
|
21004 |
|
21005 | if ($$.data.targets.length !== $target.size()) {
|
21006 | $$.updateSizes();
|
21007 | $$.updateTargetsForSubchart($$.data.targets);
|
21008 | $target = subchart.main.selectAll("." + config_classes.target);
|
21009 | }
|
21010 |
|
21011 | $target.style("opacity", null);
|
21012 | subchart.main.style("display", null);
|
21013 | this.flush();
|
21014 | }
|
21015 | },
|
21016 |
|
21017 | |
21018 |
|
21019 |
|
21020 |
|
21021 |
|
21022 |
|
21023 |
|
21024 |
|
21025 |
|
21026 | hide: function hide() {
|
21027 | var $$ = this.internal,
|
21028 | subchart = $$.$el.subchart,
|
21029 | config = $$.config;
|
21030 |
|
21031 | if (config.subchart_show && subchart.main.style("display") !== "none") {
|
21032 | config.subchart_show = !1;
|
21033 | subchart.main.style("display", "none");
|
21034 | this.flush();
|
21035 | }
|
21036 | },
|
21037 |
|
21038 | |
21039 |
|
21040 |
|
21041 |
|
21042 |
|
21043 |
|
21044 |
|
21045 |
|
21046 |
|
21047 |
|
21048 |
|
21049 | toggle: function toggle() {
|
21050 | var $$ = this.internal,
|
21051 | config = $$.config;
|
21052 | this.subchart[config.subchart_show ? "hide" : "show"]();
|
21053 | }
|
21054 | }
|
21055 | });
|
21056 |
|
21057 | var external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_ = __webpack_require__(13);
|
21058 | ;
|
21059 |
|
21060 |
|
21061 |
|
21062 |
|
21063 |
|
21064 |
|
21065 |
|
21066 |
|
21067 |
|
21068 |
|
21069 |
|
21070 |
|
21071 |
|
21072 |
|
21073 |
|
21074 | function withinRange(domain, current, range) {
|
21075 | var min = range[0],
|
21076 | max = range[1];
|
21077 | return domain.every(function (v, i) {
|
21078 | return (i === 0 ? v >= min : v <= max) && !domain.every(function (v, i) {
|
21079 | return v === current[i];
|
21080 | });
|
21081 | });
|
21082 | }
|
21083 |
|
21084 |
|
21085 |
|
21086 |
|
21087 |
|
21088 |
|
21089 |
|
21090 |
|
21091 |
|
21092 |
|
21093 |
|
21094 |
|
21095 |
|
21096 |
|
21097 |
|
21098 |
|
21099 |
|
21100 |
|
21101 |
|
21102 |
|
21103 |
|
21104 |
|
21105 | var zoom = function (domainValue) {
|
21106 | var $$ = this.internal,
|
21107 | $el = $$.$el,
|
21108 | axis = $$.axis,
|
21109 | config = $$.config,
|
21110 | org = $$.org,
|
21111 | scale = $$.scale,
|
21112 | isRotated = config.axis_rotated,
|
21113 | isCategorized = axis.isCategorized(),
|
21114 | domain = domainValue;
|
21115 |
|
21116 | if (config.zoom_enabled && domain) {
|
21117 | if (axis.isTimeSeries()) {
|
21118 | domain = domain.map(function (x) {
|
21119 | return parseDate.bind($$)(x);
|
21120 | });
|
21121 | }
|
21122 |
|
21123 | if (withinRange(domain, $$.getZoomDomain(!0), $$.getZoomDomain())) {
|
21124 | if (isCategorized) {
|
21125 | domain = domain.map(function (v, i) {
|
21126 | return +v + (i === 0 ? 0 : 1);
|
21127 | });
|
21128 | }
|
21129 |
|
21130 |
|
21131 | $$.api.tooltip.hide();
|
21132 |
|
21133 | if (config.subchart_show) {
|
21134 | var x = scale.zoom || scale.x;
|
21135 | $$.brush.getSelection().call($$.brush.move, domain.map(x));
|
21136 | } else {
|
21137 | var _d3ZoomIdentity$scale,
|
21138 | _x = isCategorized ? scale.x.orgScale() : org.xScale || scale.x,
|
21139 | translate = [-_x(domain[0]), 0],
|
21140 | transform = (_d3ZoomIdentity$scale = external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.scale(_x.range()[1] / (_x(domain[1]) - _x(domain[0])))).translate.apply(_d3ZoomIdentity$scale, isRotated ? translate.reverse() : translate);
|
21141 |
|
21142 | $el.eventRect.call($$.zoom.transform, transform);
|
21143 | }
|
21144 |
|
21145 | $$.setZoomResetButton();
|
21146 | }
|
21147 | } else {
|
21148 | domain = scale.zoom ? scale.zoom.domain() : scale.x.orgDomain();
|
21149 | }
|
21150 |
|
21151 | return domain;
|
21152 | };
|
21153 |
|
21154 | extend(zoom, {
|
21155 | |
21156 |
|
21157 |
|
21158 |
|
21159 |
|
21160 |
|
21161 |
|
21162 |
|
21163 |
|
21164 |
|
21165 |
|
21166 |
|
21167 |
|
21168 |
|
21169 |
|
21170 |
|
21171 |
|
21172 |
|
21173 | enable: function enable(enabled) {
|
21174 | var $$ = this.internal,
|
21175 | config = $$.config;
|
21176 |
|
21177 | if (/^(drag|wheel)$/.test(enabled)) {
|
21178 | config.zoom_type = enabled;
|
21179 | }
|
21180 |
|
21181 | config.zoom_enabled = !!enabled;
|
21182 |
|
21183 | if (!$$.zoom) {
|
21184 | $$.initZoom();
|
21185 | $$.bindZoomEvent();
|
21186 | } else if (enabled === !1) {
|
21187 | $$.bindZoomEvent(!1);
|
21188 | }
|
21189 |
|
21190 | $$.updateAndRedraw();
|
21191 | },
|
21192 |
|
21193 | |
21194 |
|
21195 |
|
21196 |
|
21197 |
|
21198 |
|
21199 |
|
21200 |
|
21201 |
|
21202 |
|
21203 |
|
21204 | max: function max(_max) {
|
21205 | var $$ = this.internal,
|
21206 | config = $$.config,
|
21207 | xDomain = $$.org.xDomain;
|
21208 |
|
21209 | if (_max === 0 || _max) {
|
21210 | config.zoom_x_max = getMinMax("max", [xDomain[1], _max]);
|
21211 | }
|
21212 |
|
21213 | return config.zoom_x_max;
|
21214 | },
|
21215 |
|
21216 | |
21217 |
|
21218 |
|
21219 |
|
21220 |
|
21221 |
|
21222 |
|
21223 |
|
21224 |
|
21225 |
|
21226 |
|
21227 | min: function min(_min) {
|
21228 | var $$ = this.internal,
|
21229 | config = $$.config,
|
21230 | xDomain = $$.org.xDomain;
|
21231 |
|
21232 | if (_min === 0 || _min) {
|
21233 | config.zoom_x_min = getMinMax("min", [xDomain[0], _min]);
|
21234 | }
|
21235 |
|
21236 | return config.zoom_x_min;
|
21237 | },
|
21238 |
|
21239 | |
21240 |
|
21241 |
|
21242 |
|
21243 |
|
21244 |
|
21245 |
|
21246 |
|
21247 |
|
21248 |
|
21249 |
|
21250 |
|
21251 |
|
21252 |
|
21253 |
|
21254 |
|
21255 |
|
21256 | range: function range(_range) {
|
21257 | var zoom = this.zoom;
|
21258 |
|
21259 | if (isObject(_range)) {
|
21260 | var min = _range.min,
|
21261 | max = _range.max;
|
21262 | isDefined(min) && zoom.min(min);
|
21263 | isDefined(max) && zoom.max(max);
|
21264 | }
|
21265 |
|
21266 | return {
|
21267 | min: zoom.min(),
|
21268 | max: zoom.max()
|
21269 | };
|
21270 | }
|
21271 | });
|
21272 | var api_zoom = ({
|
21273 | zoom: zoom,
|
21274 |
|
21275 | |
21276 |
|
21277 |
|
21278 |
|
21279 |
|
21280 |
|
21281 |
|
21282 |
|
21283 |
|
21284 | unzoom: function unzoom() {
|
21285 | var $$ = this.internal,
|
21286 | config = $$.config,
|
21287 | _$$$$el = $$.$el,
|
21288 | eventRect = _$$$$el.eventRect,
|
21289 | zoomResetBtn = _$$$$el.zoomResetBtn;
|
21290 |
|
21291 | if ($$.scale.zoom) {
|
21292 | var _zoomResetBtn;
|
21293 |
|
21294 | config.subchart_show ? $$.brush.getSelection().call($$.brush.move, null) : $$.zoom.updateTransformScale(external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
|
21295 | $$.updateZoom(!0);
|
21296 | (_zoomResetBtn = zoomResetBtn) == null ? void 0 : _zoomResetBtn.style("display", "none");
|
21297 |
|
21298 | 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) {
|
21299 | $$.zoom.transform(eventRect, external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity);
|
21300 | }
|
21301 | }
|
21302 | }
|
21303 | });
|
21304 | ;
|
21305 |
|
21306 |
|
21307 |
|
21308 |
|
21309 |
|
21310 |
|
21311 |
|
21312 |
|
21313 |
|
21314 |
|
21315 |
|
21316 | var drag = ({
|
21317 | |
21318 |
|
21319 |
|
21320 |
|
21321 |
|
21322 |
|
21323 | drag: function drag(mouse) {
|
21324 | var $$ = this,
|
21325 | config = $$.config,
|
21326 | state = $$.state,
|
21327 | main = $$.$el.main,
|
21328 | isSelectionGrouped = config.data_selection_grouped,
|
21329 | isSelectable = config.interaction_enabled && config.data_selection_isselectable;
|
21330 |
|
21331 | if ($$.hasArcType() || !config.data_selection_enabled ||
|
21332 | config.zoom_enabled && !$$.zoom.altDomain ||
|
21333 | !config.data_selection_multiple
|
21334 | ) {
|
21335 | return;
|
21336 | }
|
21337 |
|
21338 | var _ref = state.dragStart || [0, 0],
|
21339 | sx = _ref[0],
|
21340 | sy = _ref[1],
|
21341 | mx = mouse[0],
|
21342 | my = mouse[1],
|
21343 | minX = Math.min(sx, mx),
|
21344 | maxX = Math.max(sx, mx),
|
21345 | minY = isSelectionGrouped ? state.margin.top : Math.min(sy, my),
|
21346 | maxY = isSelectionGrouped ? state.height : Math.max(sy, my);
|
21347 |
|
21348 | main.select("." + config_classes.dragarea).attr("x", minX).attr("y", minY).attr("width", maxX - minX).attr("height", maxY - minY);
|
21349 |
|
21350 | main.selectAll("." + config_classes.shapes).selectAll("." + config_classes.shape).filter(function (d) {
|
21351 | var _isSelectable;
|
21352 |
|
21353 | return (_isSelectable = isSelectable) == null ? void 0 : _isSelectable.bind($$.api)(d);
|
21354 | }).each(function (d, i) {
|
21355 | var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
|
21356 | isSelected = shape.classed(config_classes.SELECTED),
|
21357 | isIncluded = shape.classed(config_classes.INCLUDED),
|
21358 | isWithin = !1,
|
21359 | toggle;
|
21360 |
|
21361 | if (shape.classed(config_classes.circle)) {
|
21362 | var x = +shape.attr("cx") * 1,
|
21363 | y = +shape.attr("cy") * 1;
|
21364 | toggle = $$.togglePoint;
|
21365 | isWithin = minX < x && x < maxX && minY < y && y < maxY;
|
21366 | } else if (shape.classed(config_classes.bar)) {
|
21367 | var _getPathBox = getPathBox(this),
|
21368 | _x = _getPathBox.x,
|
21369 | y = _getPathBox.y,
|
21370 | width = _getPathBox.width,
|
21371 | height = _getPathBox.height;
|
21372 |
|
21373 | toggle = $$.togglePath;
|
21374 | isWithin = !(maxX < _x || _x + width < minX) && !(maxY < y || y + height < minY);
|
21375 | } else {
|
21376 |
|
21377 | return;
|
21378 | }
|
21379 |
|
21380 |
|
21381 | if (isWithin ^ isIncluded) {
|
21382 | shape.classed(config_classes.INCLUDED, !isIncluded);
|
21383 |
|
21384 | shape.classed(config_classes.SELECTED, !isSelected);
|
21385 | toggle.call($$, !isSelected, shape, d, i);
|
21386 | }
|
21387 | });
|
21388 | },
|
21389 |
|
21390 | |
21391 |
|
21392 |
|
21393 |
|
21394 |
|
21395 |
|
21396 | dragstart: function dragstart(mouse) {
|
21397 | var $$ = this,
|
21398 | config = $$.config,
|
21399 | state = $$.state,
|
21400 | main = $$.$el.main;
|
21401 |
|
21402 | if ($$.hasArcType() || !config.data_selection_enabled) {
|
21403 | return;
|
21404 | }
|
21405 |
|
21406 | state.dragStart = mouse;
|
21407 | main.select("." + config_classes.chart).append("rect").attr("class", config_classes.dragarea).style("opacity", "0.1");
|
21408 | $$.setDragStatus(!0);
|
21409 | },
|
21410 |
|
21411 | |
21412 |
|
21413 |
|
21414 |
|
21415 |
|
21416 | dragend: function dragend() {
|
21417 | var $$ = this,
|
21418 | config = $$.config,
|
21419 | main = $$.$el.main,
|
21420 | $T = $$.$T;
|
21421 |
|
21422 | if ($$.hasArcType() || !config.data_selection_enabled) {
|
21423 |
|
21424 | return;
|
21425 | }
|
21426 |
|
21427 | $T(main.select("." + config_classes.dragarea)).style("opacity", "0").remove();
|
21428 | main.selectAll("." + config_classes.shape).classed(config_classes.INCLUDED, !1);
|
21429 | $$.setDragStatus(!1);
|
21430 | }
|
21431 | });
|
21432 | ;
|
21433 |
|
21434 |
|
21435 | function selection_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
21436 |
|
21437 | function selection_objectSpread(target) { for (var i = 1, source; i < arguments.length; i++) { source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { selection_ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { selection_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
21438 |
|
21439 |
|
21440 |
|
21441 |
|
21442 |
|
21443 |
|
21444 |
|
21445 |
|
21446 |
|
21447 | var internals_selection = (selection_objectSpread(selection_objectSpread({}, drag), {}, {
|
21448 | |
21449 |
|
21450 |
|
21451 |
|
21452 |
|
21453 |
|
21454 |
|
21455 | selectPoint: function selectPoint(target, d, i) {
|
21456 | var $$ = this,
|
21457 | config = $$.config,
|
21458 | main = $$.$el.main,
|
21459 | $T = $$.$T,
|
21460 | isRotated = config.axis_rotated,
|
21461 | cx = (isRotated ? $$.circleY : $$.circleX).bind($$),
|
21462 | cy = (isRotated ? $$.circleX : $$.circleY).bind($$),
|
21463 | r = $$.pointSelectR.bind($$);
|
21464 | callFn(config.data_onselected, $$.api, d, target.node());
|
21465 |
|
21466 | $T(main.select("." + config_classes.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll("." + config_classes.selectedCircle + "-" + i).data([d]).enter().append("circle").attr("class", function () {
|
21467 | return $$.generateClass(config_classes.selectedCircle, i);
|
21468 | }).attr("cx", cx).attr("cy", cy).attr("stroke", $$.color).attr("r", function (d2) {
|
21469 | return $$.pointSelectR(d2) * 1.4;
|
21470 | })).attr("r", r);
|
21471 | },
|
21472 |
|
21473 | |
21474 |
|
21475 |
|
21476 |
|
21477 |
|
21478 |
|
21479 |
|
21480 | unselectPoint: function unselectPoint(target, d, i) {
|
21481 | var $$ = this,
|
21482 | config = $$.config,
|
21483 | main = $$.$el.main,
|
21484 | $T = $$.$T;
|
21485 | callFn(config.data_onunselected, $$.api, d, target.node());
|
21486 |
|
21487 | $T(main.select("." + config_classes.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll("." + config_classes.selectedCircle + "-" + i)).attr("r", 0).remove();
|
21488 | },
|
21489 |
|
21490 | |
21491 |
|
21492 |
|
21493 |
|
21494 |
|
21495 |
|
21496 |
|
21497 |
|
21498 | togglePoint: function togglePoint(selected, target, d, i) {
|
21499 | var method = (selected ? "" : "un") + "selectPoint";
|
21500 | this[method](target, d, i);
|
21501 | },
|
21502 |
|
21503 | |
21504 |
|
21505 |
|
21506 |
|
21507 |
|
21508 |
|
21509 | selectPath: function selectPath(target, d) {
|
21510 | var $$ = this,
|
21511 | config = $$.config;
|
21512 | callFn(config.data_onselected, $$.api, d, target.node());
|
21513 |
|
21514 | if (config.interaction_brighten) {
|
21515 | target.style("filter", "brightness(1.25)");
|
21516 | }
|
21517 | },
|
21518 |
|
21519 | |
21520 |
|
21521 |
|
21522 |
|
21523 |
|
21524 |
|
21525 | unselectPath: function unselectPath(target, d) {
|
21526 | var $$ = this,
|
21527 | config = $$.config;
|
21528 | callFn(config.data_onunselected, $$.api, d, target.node());
|
21529 |
|
21530 | if (config.interaction_brighten) {
|
21531 | target.style("filter", null);
|
21532 | }
|
21533 | },
|
21534 |
|
21535 | |
21536 |
|
21537 |
|
21538 |
|
21539 |
|
21540 |
|
21541 |
|
21542 |
|
21543 | togglePath: function togglePath(selected, target, d, i) {
|
21544 | this[(selected ? "" : "un") + "selectPath"](target, d, i);
|
21545 | },
|
21546 |
|
21547 | |
21548 |
|
21549 |
|
21550 |
|
21551 |
|
21552 |
|
21553 |
|
21554 | getToggle: function getToggle(that, d) {
|
21555 | var $$ = this;
|
21556 | return that.nodeName === "path" ? $$.togglePath : $$.isStepType(d) ? function () {} :
|
21557 | $$.togglePoint;
|
21558 | },
|
21559 |
|
21560 | |
21561 |
|
21562 |
|
21563 |
|
21564 |
|
21565 |
|
21566 |
|
21567 | toggleShape: function toggleShape(that, d, i) {
|
21568 | var $$ = this,
|
21569 | config = $$.config,
|
21570 | main = $$.$el.main,
|
21571 | shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(that),
|
21572 | isSelected = shape.classed(config_classes.SELECTED),
|
21573 | toggle = $$.getToggle(that, d).bind($$),
|
21574 | toggledShape;
|
21575 |
|
21576 | if (config.data_selection_enabled && config.data_selection_isselectable.bind($$.api)(d)) {
|
21577 | if (!config.data_selection_multiple) {
|
21578 | var selector = "." + config_classes.shapes;
|
21579 |
|
21580 | if (config.data_selection_grouped) {
|
21581 | selector += $$.getTargetSelectorSuffix(d.id);
|
21582 | }
|
21583 |
|
21584 | main.selectAll(selector).selectAll("." + config_classes.shape).each(function (d, i) {
|
21585 | var shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
21586 |
|
21587 | if (shape.classed(config_classes.SELECTED)) {
|
21588 | toggledShape = shape;
|
21589 | toggle(!1, shape.classed(config_classes.SELECTED, !1), d, i);
|
21590 | }
|
21591 | });
|
21592 | }
|
21593 |
|
21594 | if (!toggledShape || toggledShape.node() !== shape.node()) {
|
21595 | shape.classed(config_classes.SELECTED, !isSelected);
|
21596 | toggle(!isSelected, shape, d, i);
|
21597 | }
|
21598 | }
|
21599 | }
|
21600 | }));
|
21601 | ;
|
21602 |
|
21603 |
|
21604 |
|
21605 |
|
21606 |
|
21607 |
|
21608 |
|
21609 |
|
21610 | var interactions_subchart = ({
|
21611 | |
21612 |
|
21613 |
|
21614 |
|
21615 | initBrush: function initBrush() {
|
21616 | var $$ = this,
|
21617 | config = $$.config,
|
21618 | scale = $$.scale,
|
21619 | subchart = $$.$el.subchart,
|
21620 | isRotated = config.axis_rotated,
|
21621 | lastDomain,
|
21622 | timeout;
|
21623 |
|
21624 | $$.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);
|
21625 |
|
21626 | var getBrushSize = function () {
|
21627 | var brush = $$.$el.svg.select("." + config_classes.brush + " .overlay"),
|
21628 | brushSize = {
|
21629 | width: 0,
|
21630 | height: 0
|
21631 | };
|
21632 |
|
21633 | if (brush.size()) {
|
21634 | brushSize.width = +brush.attr("width");
|
21635 | brushSize.height = +brush.attr("height");
|
21636 | }
|
21637 |
|
21638 | return brushSize[isRotated ? "width" : "height"];
|
21639 | };
|
21640 |
|
21641 |
|
21642 | $$.brush.on("start brush end", function (event) {
|
21643 | var selection = event.selection,
|
21644 | target = event.target,
|
21645 | type = event.type;
|
21646 |
|
21647 | if (type === "start") {
|
21648 | $$.state.inputType === "touch" && $$.hideTooltip();
|
21649 | }
|
21650 |
|
21651 | if (/(start|brush)/.test(type)) {
|
21652 | $$.redrawForBrush();
|
21653 | }
|
21654 |
|
21655 | if (type === "end") {
|
21656 | lastDomain = scale.x.orgDomain();
|
21657 | }
|
21658 |
|
21659 |
|
21660 | if (target != null && target.handle) {
|
21661 | if (selection === null) {
|
21662 | $$.brush.handle.attr("display", "none");
|
21663 | } else {
|
21664 | $$.brush.handle.attr("display", null).attr("transform", function (d, i) {
|
21665 | var pos = isRotated ? [33, selection[i] - (i === 0 ? 30 : 24)] : [selection[i], 3];
|
21666 | return "translate(" + pos + ")";
|
21667 | });
|
21668 | }
|
21669 | }
|
21670 | });
|
21671 |
|
21672 | $$.brush.updateResize = function () {
|
21673 | var _this = this;
|
21674 |
|
21675 | timeout && clearTimeout(timeout);
|
21676 | timeout = setTimeout(function () {
|
21677 | var selection = _this.getSelection();
|
21678 |
|
21679 | 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()));
|
21680 | }, 0);
|
21681 | };
|
21682 |
|
21683 | $$.brush.update = function () {
|
21684 | var extent = this.extent()();
|
21685 |
|
21686 | if (extent[1].filter(function (v) {
|
21687 | return isNaN(v);
|
21688 | }).length === 0) {
|
21689 | var _subchart$main;
|
21690 |
|
21691 | (_subchart$main = subchart.main) == null ? void 0 : _subchart$main.select("." + config_classes.brush).call(this);
|
21692 | }
|
21693 |
|
21694 | return this;
|
21695 | };
|
21696 |
|
21697 |
|
21698 | $$.brush.scale = function (scale) {
|
21699 | var h = config.subchart_size_height || getBrushSize(),
|
21700 | extent = $$.getExtent();
|
21701 |
|
21702 | if (!extent && scale.range) {
|
21703 | extent = [[0, 0], [scale.range()[1], h]];
|
21704 | } else if (isArray(extent)) {
|
21705 | extent = extent.map(function (v, i) {
|
21706 | return [v, i > 0 ? h : i];
|
21707 | });
|
21708 | }
|
21709 |
|
21710 |
|
21711 | isRotated && extent[1].reverse();
|
21712 | this.extent(extent);
|
21713 |
|
21714 |
|
21715 | this.update();
|
21716 | };
|
21717 |
|
21718 | $$.brush.getSelection = function () {
|
21719 | return (
|
21720 | subchart.main ? subchart.main.select("." + config_classes.brush) : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)([])
|
21721 | );
|
21722 | };
|
21723 | },
|
21724 |
|
21725 | |
21726 |
|
21727 |
|
21728 |
|
21729 | initSubchart: function initSubchart() {
|
21730 | var $$ = this,
|
21731 | config = $$.config,
|
21732 | _$$$state = $$.state,
|
21733 | clip = _$$$state.clip,
|
21734 | hasAxis = _$$$state.hasAxis,
|
21735 | _$$$$el = $$.$el,
|
21736 | defs = _$$$$el.defs,
|
21737 | svg = _$$$$el.svg,
|
21738 | subchart = _$$$$el.subchart,
|
21739 | axis = _$$$$el.axis;
|
21740 |
|
21741 | if (!hasAxis) {
|
21742 | return;
|
21743 | }
|
21744 |
|
21745 | var visibility = config.subchart_show ? null : "hidden",
|
21746 | clipId = clip.id + "-subchart",
|
21747 | clipPath = $$.getClipPath(clipId);
|
21748 | clip.idSubchart = clipId;
|
21749 | $$.appendClip(defs, clipId);
|
21750 | $$.initBrush();
|
21751 | subchart.main = svg.append("g").classed(config_classes.subchart, !0).attr("transform", $$.getTranslate("context"));
|
21752 | var main = subchart.main;
|
21753 | main.style("visibility", visibility);
|
21754 |
|
21755 | main.append("g").attr("clip-path", clipPath).attr("class", config_classes.chart);
|
21756 |
|
21757 | ["bar", "line", "bubble", "candlestick", "scatter"].forEach(function (v) {
|
21758 | var type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
|
21759 |
|
21760 | if ($$.hasType(v) || $$.hasTypeOf(type)) {
|
21761 | var chart = main.select("." + config_classes.chart),
|
21762 | chartClassName = config_classes["chart" + type + "s"];
|
21763 |
|
21764 | if (chart.select("." + chartClassName).empty()) {
|
21765 | chart.append("g").attr("class", chartClassName);
|
21766 | }
|
21767 | }
|
21768 | });
|
21769 |
|
21770 | var brush = main.append("g").attr("clip-path", clipPath).attr("class", config_classes.brush).call($$.brush);
|
21771 | config.subchart_showHandle && $$.addBrushHandle(brush);
|
21772 |
|
21773 |
|
21774 | axis.subX = main.append("g").attr("class", config_classes.axisX).attr("transform", $$.getTranslate("subX")).attr("clip-path", config.axis_rotated ? "" : clip.pathXAxis).style("visibility", config.subchart_axis_x_show ? visibility : "hidden");
|
21775 | },
|
21776 |
|
21777 | |
21778 |
|
21779 |
|
21780 |
|
21781 |
|
21782 |
|
21783 | addBrushHandle: function addBrushHandle(brush) {
|
21784 | var $$ = this,
|
21785 | config = $$.config,
|
21786 | isRotated = config.axis_rotated,
|
21787 | initRange = config.subchart_init_range,
|
21788 | customHandleClass = "handle--custom",
|
21789 | path = isRotated ? ["M 5.2491724,29.749209 a 6,6 0 0 0 -5.50000003,-6.5 H -5.7508276 a 6,6 0 0 0 -6.0000004,6.5 z m -5.00000003,-2 H -6.7508276 m 6.99999997,-2 H -6.7508276Z", "M 5.2491724,23.249172 a 6,-6 0 0 1 -5.50000003,6.5 H -5.7508276 a 6,-6 0 0 1 -6.0000004,-6.5 z m -5.00000003,2 H -6.7508276 m 6.99999997,2 H -6.7508276Z"] : ["M 0 18 A 6 6 0 0 0 -6.5 23.5 V 29 A 6 6 0 0 0 0 35 Z M -2 23 V 30 M -4 23 V 30Z", "M 0 18 A 6 6 0 0 1 6.5 23.5 V 29 A 6 6 0 0 1 0 35 Z M 2 23 V 30 M 4 23 V 30Z"];
|
21790 | $$.brush.handle = brush.selectAll("." + customHandleClass).data(isRotated ? [{
|
21791 | type: "n"
|
21792 | }, {
|
21793 | type: "s"
|
21794 | }] : [{
|
21795 | type: "w"
|
21796 | }, {
|
21797 | type: "e"
|
21798 | }]).enter().append("path").attr("class", customHandleClass).attr("cursor", (isRotated ? "ns" : "ew") + "-resize").attr("d", function (d) {
|
21799 | return path[+/[se]/.test(d.type)];
|
21800 | }).attr("display", initRange ? null : "none");
|
21801 | },
|
21802 |
|
21803 | |
21804 |
|
21805 |
|
21806 |
|
21807 |
|
21808 | updateTargetsForSubchart: function updateTargetsForSubchart(targets) {
|
21809 | var $$ = this,
|
21810 | config = $$.config,
|
21811 | state = $$.state,
|
21812 | main = $$.$el.subchart.main;
|
21813 |
|
21814 | if (config.subchart_show) {
|
21815 | ["bar", "line", "bubble", "candlestick", "scatter"].filter(function (v) {
|
21816 | return $$.hasType(v) || $$.hasTypeOf(capitalize(v));
|
21817 | }).forEach(function (v) {
|
21818 | var isPointType = /^(bubble|scatter)$/.test(v),
|
21819 | name = capitalize(isPointType ? "circle" : v),
|
21820 | chartClass = $$.getChartClass(name, !0),
|
21821 | shapeClass = $$.getClass(isPointType ? "circles" : v + "s", !0),
|
21822 | shapeChart = main.select("." + config_classes["chart" + (name + "s")]);
|
21823 |
|
21824 | if (isPointType) {
|
21825 | var circle = shapeChart.selectAll("." + config_classes.circles).data(targets.filter($$["is" + capitalize(v) + "Type"].bind($$))).attr("class", shapeClass);
|
21826 | circle.exit().remove();
|
21827 | circle.enter().append("g").attr("class", shapeClass);
|
21828 | } else {
|
21829 | var shapeUpdate = shapeChart.selectAll("." + config_classes["chart" + name]).attr("class", chartClass).data(targets.filter($$["is" + name + "Type"].bind($$))),
|
21830 | shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
|
21831 | shapeUpdate.exit().remove();
|
21832 |
|
21833 | v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", !0));
|
21834 | }
|
21835 | });
|
21836 |
|
21837 | main.selectAll("." + config_classes.brush + " rect").attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? state.width2 : state.height2);
|
21838 | }
|
21839 | },
|
21840 |
|
21841 | |
21842 |
|
21843 |
|
21844 |
|
21845 |
|
21846 |
|
21847 |
|
21848 | redrawSubchart: function redrawSubchart(withSubchart, duration, shape) {
|
21849 | var $$ = this,
|
21850 | config = $$.config,
|
21851 | main = $$.$el.subchart.main,
|
21852 | state = $$.state,
|
21853 | withTransition = !!duration;
|
21854 | main.style("visibility", config.subchart_show ? null : "hidden");
|
21855 |
|
21856 | if (config.subchart_show) {
|
21857 | var _state$event;
|
21858 |
|
21859 |
|
21860 | if (((_state$event = state.event) == null ? void 0 : _state$event.type) === "zoom") {
|
21861 | $$.brush.update();
|
21862 | }
|
21863 |
|
21864 |
|
21865 | if (withSubchart) {
|
21866 | var initRange = config.subchart_init_range;
|
21867 |
|
21868 | brushEmpty($$) || $$.brush.update();
|
21869 | Object.keys(shape.type).forEach(function (v) {
|
21870 | var name = capitalize(v),
|
21871 | drawFn = $$["generateDraw" + name](shape.indices[v], !0);
|
21872 |
|
21873 | $$["update" + name](withTransition, !0);
|
21874 | $$["redraw" + name](drawFn, withTransition, !0);
|
21875 | });
|
21876 |
|
21877 | if ($$.hasType("bubble") || $$.hasType("scatter")) {
|
21878 | var cx = shape.pos.cx,
|
21879 | cy = $$.updateCircleY(!0);
|
21880 | $$.updateCircle(!0);
|
21881 | $$.redrawCircle(cx, cy, withTransition, undefined, !0);
|
21882 | }
|
21883 |
|
21884 | !state.rendered && initRange && $$.brush.move($$.brush.getSelection(), initRange.map($$.scale.x));
|
21885 | }
|
21886 | }
|
21887 | },
|
21888 |
|
21889 | |
21890 |
|
21891 |
|
21892 |
|
21893 | redrawForBrush: function redrawForBrush() {
|
21894 | var $$ = this,
|
21895 | _$$$config = $$.config,
|
21896 | onBrush = _$$$config.subchart_onbrush,
|
21897 | withY = _$$$config.zoom_rescale,
|
21898 | scale = $$.scale;
|
21899 | $$.redraw({
|
21900 | withTransition: !1,
|
21901 | withY: withY,
|
21902 | withSubchart: !1,
|
21903 | withUpdateXDomain: !0,
|
21904 | withDimension: !1
|
21905 | });
|
21906 | onBrush.bind($$.api)(scale.x.orgDomain());
|
21907 | },
|
21908 |
|
21909 | |
21910 |
|
21911 |
|
21912 |
|
21913 |
|
21914 |
|
21915 | transformContext: function transformContext(withTransition, transitions) {
|
21916 | var $$ = this,
|
21917 | subchart = $$.$el.subchart,
|
21918 | $T = $$.$T,
|
21919 | subXAxis = transitions != null && transitions.axisSubX ? transitions.axisSubX : $T(subchart.main.select("." + config_classes.axisX), withTransition);
|
21920 | subchart.main.attr("transform", $$.getTranslate("context"));
|
21921 | subXAxis.attr("transform", $$.getTranslate("subX"));
|
21922 | },
|
21923 |
|
21924 | |
21925 |
|
21926 |
|
21927 |
|
21928 |
|
21929 | getExtent: function getExtent() {
|
21930 | var $$ = this,
|
21931 | config = $$.config,
|
21932 | scale = $$.scale,
|
21933 | extent = config.axis_x_extent;
|
21934 |
|
21935 | if (extent) {
|
21936 | if (isFunction(extent)) {
|
21937 | extent = extent.bind($$.api)($$.getXDomain($$.data.targets), scale.subX);
|
21938 | } else if ($$.axis.isTimeSeries() && extent.every(isNaN)) {
|
21939 | var fn = parseDate.bind($$);
|
21940 | extent = extent.map(function (v) {
|
21941 | return scale.subX(fn(v));
|
21942 | });
|
21943 | }
|
21944 | }
|
21945 |
|
21946 | return extent;
|
21947 | }
|
21948 | });
|
21949 | ;
|
21950 |
|
21951 |
|
21952 |
|
21953 |
|
21954 |
|
21955 |
|
21956 |
|
21957 |
|
21958 | var interactions_zoom = ({
|
21959 | |
21960 |
|
21961 |
|
21962 |
|
21963 | initZoom: function initZoom() {
|
21964 | var $$ = this;
|
21965 | $$.scale.zoom = null;
|
21966 | $$.generateZoom();
|
21967 | $$.initZoomBehaviour();
|
21968 | },
|
21969 |
|
21970 | |
21971 |
|
21972 |
|
21973 |
|
21974 |
|
21975 | bindZoomEvent: function bindZoomEvent(bind) {
|
21976 | if (bind === void 0) {
|
21977 | bind = !0;
|
21978 | }
|
21979 |
|
21980 | var $$ = this,
|
21981 | config = $$.config,
|
21982 | zoomEnabled = config.zoom_enabled;
|
21983 |
|
21984 | if (zoomEnabled && bind) {
|
21985 |
|
21986 | config.subchart_show || $$.bindZoomOnEventRect();
|
21987 | } else if (bind === !1) {
|
21988 | $$.api.unzoom();
|
21989 | $$.unbindZoomEvent();
|
21990 | }
|
21991 | },
|
21992 |
|
21993 | |
21994 |
|
21995 |
|
21996 |
|
21997 | generateZoom: function generateZoom() {
|
21998 | var $$ = this,
|
21999 | config = $$.config,
|
22000 | org = $$.org,
|
22001 | scale = $$.scale,
|
22002 | 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($$));
|
22003 |
|
22004 |
|
22005 |
|
22006 | zoom.orgScaleExtent = function () {
|
22007 | var extent = config.zoom_extent || [1, 10];
|
22008 | return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])];
|
22009 | };
|
22010 |
|
22011 |
|
22012 | zoom.updateScaleExtent = function () {
|
22013 | var ratio = diffDomain($$.scale.x.orgDomain()) / diffDomain($$.getZoomDomain()),
|
22014 | extent = this.orgScaleExtent();
|
22015 | this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
|
22016 | return this;
|
22017 | };
|
22018 | |
22019 |
|
22020 |
|
22021 |
|
22022 |
|
22023 |
|
22024 |
|
22025 |
|
22026 | zoom.updateTransformScale = function (transform) {
|
22027 | var _org$xScale;
|
22028 |
|
22029 |
|
22030 | (_org$xScale = org.xScale) == null ? void 0 : _org$xScale.range(scale.x.range());
|
22031 |
|
22032 | var newScale = transform[config.axis_rotated ? "rescaleY" : "rescaleX"](org.xScale || scale.x),
|
22033 | domain = $$.trimXDomain(newScale.domain()),
|
22034 | rescale = config.zoom_rescale;
|
22035 | newScale.domain(domain, org.xDomain);
|
22036 |
|
22037 | if (!$$.state.xTickOffset) {
|
22038 | $$.state.xTickOffset = $$.axis.x.tickOffset();
|
22039 | }
|
22040 |
|
22041 | scale.zoom = $$.getCustomizedScale(newScale);
|
22042 | $$.axis.x.scale(scale.zoom);
|
22043 |
|
22044 | if (rescale) {
|
22045 |
|
22046 | org.xScale || (org.xScale = scale.x.copy());
|
22047 | scale.x.domain(domain);
|
22048 | }
|
22049 | };
|
22050 | |
22051 |
|
22052 |
|
22053 |
|
22054 |
|
22055 |
|
22056 |
|
22057 |
|
22058 | zoom.getDomain = function () {
|
22059 | var domain = scale[scale.zoom ? "zoom" : "subX"].domain(),
|
22060 | isCategorized = $$.axis.isCategorized();
|
22061 |
|
22062 | if (isCategorized) {
|
22063 | domain[1] -= 2;
|
22064 | }
|
22065 |
|
22066 | return domain;
|
22067 | };
|
22068 |
|
22069 | $$.zoom = zoom;
|
22070 | },
|
22071 |
|
22072 | |
22073 |
|
22074 |
|
22075 |
|
22076 |
|
22077 | onZoomStart: function onZoomStart(event) {
|
22078 | var $$ = this,
|
22079 | sourceEvent = event.sourceEvent;
|
22080 |
|
22081 | if (sourceEvent) {
|
22082 | $$.zoom.startEvent = sourceEvent;
|
22083 | $$.state.zooming = !0;
|
22084 | callFn($$.config.zoom_onzoomstart, $$.api, event);
|
22085 | }
|
22086 | },
|
22087 |
|
22088 | |
22089 |
|
22090 |
|
22091 |
|
22092 |
|
22093 | onZoom: function onZoom(event) {
|
22094 | var _sourceEvent,
|
22095 | _sourceEvent2,
|
22096 | _sourceEvent3,
|
22097 | _sourceEvent4,
|
22098 | $$ = this,
|
22099 | config = $$.config,
|
22100 | scale = $$.scale,
|
22101 | state = $$.state,
|
22102 | org = $$.org,
|
22103 | sourceEvent = event.sourceEvent,
|
22104 | isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
|
22105 |
|
22106 | if (!config.zoom_enabled || $$.filterTargetsToShow($$.data.targets).length === 0 || !scale.zoom && ((_sourceEvent = sourceEvent) == null ? void 0 : _sourceEvent.type.indexOf("touch")) > -1 && ((_sourceEvent2 = sourceEvent) == null ? void 0 : _sourceEvent2.touches.length) === 1) {
|
22107 | return;
|
22108 | }
|
22109 |
|
22110 | if (event.sourceEvent) {
|
22111 | state.zooming = !0;
|
22112 | }
|
22113 |
|
22114 | var isMousemove = ((_sourceEvent3 = sourceEvent) == null ? void 0 : _sourceEvent3.type) === "mousemove",
|
22115 | isZoomOut = ((_sourceEvent4 = sourceEvent) == null ? void 0 : _sourceEvent4.wheelDelta) < 0,
|
22116 | transform = event.transform;
|
22117 |
|
22118 | if (!isMousemove && isZoomOut && scale.x.domain().every(function (v, i) {
|
22119 | return v !== org.xDomain[i];
|
22120 | })) {
|
22121 | scale.x.domain(org.xDomain);
|
22122 | }
|
22123 |
|
22124 | $$.zoom.updateTransformScale(transform);
|
22125 |
|
22126 |
|
22127 |
|
22128 | var doTransition = config.transition_duration > 0 && !config.subchart_show && (state.dragging || isUnZoom || !event.sourceEvent);
|
22129 | $$.redraw({
|
22130 | withTransition: doTransition,
|
22131 | withY: config.zoom_rescale,
|
22132 | withSubchart: !1,
|
22133 | withEventRect: !1,
|
22134 | withDimension: !1
|
22135 | });
|
22136 | $$.state.cancelClick = isMousemove;
|
22137 |
|
22138 | isUnZoom || callFn(config.zoom_onzoom, $$.api, $$.zoom.getDomain());
|
22139 | },
|
22140 |
|
22141 | |
22142 |
|
22143 |
|
22144 |
|
22145 |
|
22146 | onZoomEnd: function onZoomEnd(event) {
|
22147 | var _startEvent,
|
22148 | $$ = this,
|
22149 | config = $$.config,
|
22150 | state = $$.state,
|
22151 | startEvent = $$.zoom.startEvent,
|
22152 | e = event == null ? void 0 : event.sourceEvent,
|
22153 | isUnZoom = (event == null ? void 0 : event.transform) === external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity;
|
22154 |
|
22155 | if (((_startEvent = startEvent) == null ? void 0 : _startEvent.type.indexOf("touch")) > -1) {
|
22156 | var _e, _e$changedTouches;
|
22157 |
|
22158 | startEvent = startEvent.changedTouches[0];
|
22159 | e = (_e = e) == null ? void 0 : (_e$changedTouches = _e.changedTouches) == null ? void 0 : _e$changedTouches[0];
|
22160 | }
|
22161 |
|
22162 |
|
22163 | if (config.zoom_type === "drag" && e && startEvent.clientX === e.clientX && startEvent.clientY === e.clientY) {
|
22164 | return;
|
22165 | }
|
22166 |
|
22167 | $$.redrawEventRect();
|
22168 | $$.updateZoom();
|
22169 | state.zooming = !1;
|
22170 |
|
22171 | !isUnZoom && (e || state.dragging) && callFn(config.zoom_onzoomend, $$.api, $$.zoom.getDomain());
|
22172 | },
|
22173 |
|
22174 | |
22175 |
|
22176 |
|
22177 |
|
22178 |
|
22179 | updateZoom: function updateZoom(force) {
|
22180 | var $$ = this,
|
22181 | _$$$scale = $$.scale,
|
22182 | subX = _$$$scale.subX,
|
22183 | x = _$$$scale.x,
|
22184 | zoom = _$$$scale.zoom;
|
22185 |
|
22186 | if (zoom) {
|
22187 | var zoomDomain = zoom.domain(),
|
22188 | xDomain = subX.domain(),
|
22189 | delta = .015,
|
22190 | isfullyShown = (zoomDomain[0] <= xDomain[0] || zoomDomain[0] - delta <= xDomain[0]) && (xDomain[1] <= zoomDomain[1] || xDomain[1] <= zoomDomain[1] - delta);
|
22191 |
|
22192 |
|
22193 | if (force || isfullyShown) {
|
22194 | $$.axis.x.scale(subX);
|
22195 | x.domain(subX.orgDomain());
|
22196 | $$.scale.zoom = null;
|
22197 | }
|
22198 | }
|
22199 | },
|
22200 |
|
22201 | |
22202 |
|
22203 |
|
22204 |
|
22205 | bindZoomOnEventRect: function bindZoomOnEventRect() {
|
22206 | var $$ = this,
|
22207 | config = $$.config,
|
22208 | eventRect = $$.$el.eventRect,
|
22209 | behaviour = config.zoom_type === "drag" ? $$.zoomBehaviour : $$.zoom;
|
22210 |
|
22211 |
|
22212 | $$.$el.svg.on("wheel", function () {});
|
22213 | eventRect.call(behaviour).on("dblclick.zoom", null);
|
22214 | },
|
22215 |
|
22216 | |
22217 |
|
22218 |
|
22219 |
|
22220 | initZoomBehaviour: function initZoomBehaviour() {
|
22221 | var $$ = this,
|
22222 | config = $$.config,
|
22223 | state = $$.state,
|
22224 | isRotated = config.axis_rotated,
|
22225 | start = 0,
|
22226 | end = 0,
|
22227 | zoomRect,
|
22228 | prop = {
|
22229 | axis: isRotated ? "y" : "x",
|
22230 | attr: isRotated ? "height" : "width",
|
22231 | index: isRotated ? 1 : 0
|
22232 | };
|
22233 | $$.zoomBehaviour = (0,external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_.drag)().clickDistance(4).on("start", function (event) {
|
22234 | state.event = event;
|
22235 | $$.setDragStatus(!0);
|
22236 | $$.unselectRect();
|
22237 |
|
22238 | if (!zoomRect) {
|
22239 | zoomRect = $$.$el.main.append("rect").attr("clip-path", state.clip.path).attr("class", config_classes.zoomBrush).attr("width", isRotated ? state.width : 0).attr("height", isRotated ? 0 : state.height);
|
22240 | }
|
22241 |
|
22242 | start = getPointer(event, this)[prop.index];
|
22243 | end = start;
|
22244 | zoomRect.attr(prop.axis, start).attr(prop.attr, 0);
|
22245 | $$.onZoomStart(event);
|
22246 | }).on("drag", function (event) {
|
22247 | end = getPointer(event, this)[prop.index];
|
22248 | zoomRect.attr(prop.axis, Math.min(start, end)).attr(prop.attr, Math.abs(end - start));
|
22249 | }).on("end", function (event) {
|
22250 | var scale = $$.scale.zoom || $$.scale.x;
|
22251 | state.event = event;
|
22252 | zoomRect.attr(prop.axis, 0).attr(prop.attr, 0);
|
22253 |
|
22254 | if (start > end) {
|
22255 | var _ref = [end, start];
|
22256 | start = _ref[0];
|
22257 | end = _ref[1];
|
22258 | }
|
22259 |
|
22260 | if (start < 0) {
|
22261 | end += Math.abs(start);
|
22262 | start = 0;
|
22263 | }
|
22264 |
|
22265 | if (start !== end) {
|
22266 | $$.api.zoom([start, end].map(function (v) {
|
22267 | return scale.invert(v);
|
22268 | }));
|
22269 | }
|
22270 |
|
22271 | $$.setDragStatus(!1);
|
22272 | });
|
22273 | },
|
22274 | setZoomResetButton: function setZoomResetButton() {
|
22275 | var $$ = this,
|
22276 | config = $$.config,
|
22277 | $el = $$.$el,
|
22278 | resetButton = config.zoom_resetButton;
|
22279 |
|
22280 | if (resetButton && config.zoom_type === "drag") {
|
22281 | if (!$el.zoomResetBtn) {
|
22282 | $el.zoomResetBtn = $$.$el.chart.append("div").classed(config_classes.button, !0).append("span").on("click", function () {
|
22283 | isFunction(resetButton.onclick) && resetButton.onclick.bind($$.api)(this);
|
22284 | $$.api.unzoom();
|
22285 | }).classed(config_classes.buttonZoomReset, !0).text(resetButton.text || "Reset Zoom");
|
22286 | } else {
|
22287 | $el.zoomResetBtn.style("display", null);
|
22288 | }
|
22289 | }
|
22290 | }
|
22291 | });
|
22292 | ;
|
22293 |
|
22294 |
|
22295 |
|
22296 |
|
22297 |
|
22298 |
|
22299 |
|
22300 |
|
22301 | var data_selection = ({
|
22302 | |
22303 |
|
22304 |
|
22305 |
|
22306 |
|
22307 |
|
22308 |
|
22309 |
|
22310 |
|
22311 |
|
22312 |
|
22313 |
|
22314 |
|
22315 |
|
22316 |
|
22317 |
|
22318 |
|
22319 |
|
22320 |
|
22321 |
|
22322 |
|
22323 |
|
22324 |
|
22325 |
|
22326 |
|
22327 |
|
22328 |
|
22329 | data_selection_enabled: !1,
|
22330 |
|
22331 | |
22332 |
|
22333 |
|
22334 |
|
22335 |
|
22336 |
|
22337 |
|
22338 |
|
22339 |
|
22340 |
|
22341 |
|
22342 |
|
22343 |
|
22344 |
|
22345 | data_selection_grouped: !1,
|
22346 |
|
22347 | |
22348 |
|
22349 |
|
22350 |
|
22351 |
|
22352 |
|
22353 |
|
22354 |
|
22355 |
|
22356 |
|
22357 |
|
22358 |
|
22359 |
|
22360 |
|
22361 | data_selection_isselectable: function data_selection_isselectable() {
|
22362 | return !0;
|
22363 | },
|
22364 |
|
22365 | |
22366 |
|
22367 |
|
22368 |
|
22369 |
|
22370 |
|
22371 |
|
22372 |
|
22373 |
|
22374 |
|
22375 |
|
22376 |
|
22377 |
|
22378 |
|
22379 | data_selection_multiple: !0,
|
22380 |
|
22381 | |
22382 |
|
22383 |
|
22384 |
|
22385 |
|
22386 |
|
22387 |
|
22388 |
|
22389 |
|
22390 |
|
22391 |
|
22392 |
|
22393 |
|
22394 |
|
22395 |
|
22396 | data_selection_draggable: !1,
|
22397 |
|
22398 | |
22399 |
|
22400 |
|
22401 |
|
22402 |
|
22403 |
|
22404 |
|
22405 |
|
22406 |
|
22407 |
|
22408 |
|
22409 |
|
22410 |
|
22411 |
|
22412 |
|
22413 | data_onselected: function data_onselected() {},
|
22414 |
|
22415 | |
22416 |
|
22417 |
|
22418 |
|
22419 |
|
22420 |
|
22421 |
|
22422 |
|
22423 |
|
22424 |
|
22425 |
|
22426 |
|
22427 |
|
22428 |
|
22429 |
|
22430 | data_onunselected: function data_onunselected() {}
|
22431 | });
|
22432 | ;
|
22433 |
|
22434 |
|
22435 |
|
22436 |
|
22437 |
|
22438 |
|
22439 |
|
22440 |
|
22441 | var interaction_subchart = ({
|
22442 | |
22443 |
|
22444 |
|
22445 |
|
22446 |
|
22447 |
|
22448 |
|
22449 |
|
22450 |
|
22451 |
|
22452 |
|
22453 |
|
22454 |
|
22455 |
|
22456 |
|
22457 |
|
22458 |
|
22459 |
|
22460 |
|
22461 |
|
22462 |
|
22463 |
|
22464 |
|
22465 |
|
22466 |
|
22467 |
|
22468 |
|
22469 |
|
22470 |
|
22471 |
|
22472 |
|
22473 |
|
22474 |
|
22475 |
|
22476 |
|
22477 |
|
22478 |
|
22479 |
|
22480 |
|
22481 |
|
22482 |
|
22483 |
|
22484 |
|
22485 |
|
22486 |
|
22487 |
|
22488 |
|
22489 |
|
22490 |
|
22491 |
|
22492 |
|
22493 |
|
22494 |
|
22495 |
|
22496 | subchart_show: !1,
|
22497 | subchart_showHandle: !1,
|
22498 | subchart_size_height: 60,
|
22499 | subchart_axis_x_show: !0,
|
22500 | subchart_axis_x_tick_show: !0,
|
22501 | subchart_axis_x_tick_format: undefined,
|
22502 | subchart_axis_x_tick_text_show: !0,
|
22503 | subchart_init_range: undefined,
|
22504 | subchart_onbrush: function subchart_onbrush() {}
|
22505 | });
|
22506 | ;
|
22507 |
|
22508 |
|
22509 |
|
22510 |
|
22511 |
|
22512 |
|
22513 |
|
22514 |
|
22515 | var interaction_zoom = ({
|
22516 | |
22517 |
|
22518 |
|
22519 |
|
22520 |
|
22521 |
|
22522 |
|
22523 |
|
22524 |
|
22525 |
|
22526 |
|
22527 |
|
22528 |
|
22529 |
|
22530 |
|
22531 |
|
22532 |
|
22533 |
|
22534 |
|
22535 |
|
22536 |
|
22537 |
|
22538 |
|
22539 |
|
22540 |
|
22541 |
|
22542 |
|
22543 |
|
22544 |
|
22545 |
|
22546 |
|
22547 |
|
22548 |
|
22549 |
|
22550 |
|
22551 |
|
22552 |
|
22553 |
|
22554 |
|
22555 |
|
22556 |
|
22557 |
|
22558 |
|
22559 |
|
22560 |
|
22561 |
|
22562 |
|
22563 |
|
22564 |
|
22565 |
|
22566 |
|
22567 |
|
22568 |
|
22569 |
|
22570 |
|
22571 |
|
22572 |
|
22573 |
|
22574 |
|
22575 |
|
22576 |
|
22577 |
|
22578 |
|
22579 |
|
22580 |
|
22581 |
|
22582 | zoom_enabled: !1,
|
22583 | zoom_type: "wheel",
|
22584 | zoom_extent: undefined,
|
22585 | zoom_privileged: !1,
|
22586 | zoom_rescale: !1,
|
22587 | zoom_onzoom: undefined,
|
22588 | zoom_onzoomstart: undefined,
|
22589 | zoom_onzoomend: undefined,
|
22590 | zoom_resetButton: !0,
|
22591 | zoom_x_min: undefined,
|
22592 | zoom_x_max: undefined
|
22593 | });
|
22594 | ;
|
22595 |
|
22596 |
|
22597 |
|
22598 |
|
22599 |
|
22600 |
|
22601 |
|
22602 |
|
22603 |
|
22604 |
|
22605 |
|
22606 |
|
22607 |
|
22608 |
|
22609 |
|
22610 |
|
22611 |
|
22612 |
|
22613 |
|
22614 |
|
22615 |
|
22616 |
|
22617 | var _selectionModule = function selectionModule() {
|
22618 | extend(ChartInternal.prototype, internals_selection);
|
22619 | extend(Chart.prototype, selection);
|
22620 | Options.setOptions([data_selection]);
|
22621 | return (_selectionModule = function selectionModule() {
|
22622 | return !0;
|
22623 | })();
|
22624 | },
|
22625 | subchartModule = function () {
|
22626 | extend(ChartInternal.prototype, interactions_subchart);
|
22627 | extend(Chart.prototype, subchart);
|
22628 | Options.setOptions([interaction_subchart]);
|
22629 | return (subchartModule = function () {
|
22630 | return !0;
|
22631 | })();
|
22632 | },
|
22633 | zoomModule = function () {
|
22634 | extend(ChartInternal.prototype, interactions_zoom);
|
22635 | extend(Chart.prototype, api_zoom);
|
22636 | Options.setOptions([interaction_zoom]);
|
22637 | return (zoomModule = function () {
|
22638 | return !0;
|
22639 | })();
|
22640 | };
|
22641 | ;
|
22642 |
|
22643 |
|
22644 |
|
22645 |
|
22646 |
|
22647 |
|
22648 |
|
22649 |
|
22650 | var _defaults = {},
|
22651 | bb = {
|
22652 | |
22653 |
|
22654 |
|
22655 |
|
22656 |
|
22657 |
|
22658 |
|
22659 | version: "3.2.1",
|
22660 |
|
22661 | |
22662 |
|
22663 |
|
22664 |
|
22665 |
|
22666 |
|
22667 |
|
22668 |
|
22669 |
|
22670 |
|
22671 |
|
22672 |
|
22673 |
|
22674 |
|
22675 |
|
22676 |
|
22677 |
|
22678 |
|
22679 |
|
22680 |
|
22681 |
|
22682 |
|
22683 |
|
22684 |
|
22685 |
|
22686 |
|
22687 |
|
22688 |
|
22689 |
|
22690 |
|
22691 |
|
22692 |
|
22693 |
|
22694 |
|
22695 |
|
22696 |
|
22697 |
|
22698 |
|
22699 |
|
22700 |
|
22701 |
|
22702 |
|
22703 |
|
22704 |
|
22705 |
|
22706 |
|
22707 |
|
22708 |
|
22709 |
|
22710 |
|
22711 |
|
22712 |
|
22713 |
|
22714 |
|
22715 |
|
22716 |
|
22717 |
|
22718 |
|
22719 |
|
22720 |
|
22721 |
|
22722 |
|
22723 |
|
22724 |
|
22725 |
|
22726 |
|
22727 |
|
22728 |
|
22729 |
|
22730 | generate: function generate(config) {
|
22731 | var options = mergeObj({}, _defaults, config),
|
22732 | inst = new Chart(options);
|
22733 | inst.internal.charts = this.instance;
|
22734 | this.instance.push(inst);
|
22735 | return inst;
|
22736 | },
|
22737 |
|
22738 | |
22739 |
|
22740 |
|
22741 |
|
22742 |
|
22743 |
|
22744 |
|
22745 |
|
22746 |
|
22747 |
|
22748 |
|
22749 |
|
22750 |
|
22751 |
|
22752 |
|
22753 |
|
22754 |
|
22755 |
|
22756 |
|
22757 |
|
22758 |
|
22759 |
|
22760 | defaults: function defaults(options) {
|
22761 | if (isObject(options)) {
|
22762 | _defaults = options;
|
22763 | }
|
22764 |
|
22765 | return _defaults;
|
22766 | },
|
22767 |
|
22768 | |
22769 |
|
22770 |
|
22771 |
|
22772 |
|
22773 |
|
22774 |
|
22775 |
|
22776 |
|
22777 |
|
22778 |
|
22779 | instance: [],
|
22780 |
|
22781 | |
22782 |
|
22783 |
|
22784 |
|
22785 |
|
22786 |
|
22787 |
|
22788 |
|
22789 | plugin: {}
|
22790 | };
|
22791 |
|
22792 |
|
22793 |
|
22794 |
|
22795 | ;
|
22796 |
|
22797 |
|
22798 |
|
22799 |
|
22800 |
|
22801 |
|
22802 |
|
22803 | Object.keys(resolver_shape_namespaceObject).forEach(function (v) {
|
22804 | return resolver_shape_namespaceObject[v]();
|
22805 | });
|
22806 |
|
22807 | Object.keys(resolver_interaction_namespaceObject).forEach(function (v) {
|
22808 | return resolver_interaction_namespaceObject[v]();
|
22809 | });
|
22810 |
|
22811 | }();
|
22812 | return __webpack_exports__;
|
22813 | })()
|
22814 | ;
|
22815 | }); |
\ | No newline at end of file |