vendor: 9,969 bytes, lines 1-298
1/* * 2 * 3 * (c) 2010-2024 Torstein Honsi 4 * 5 * License: www.highcharts.com/license 6 * 7 * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!! 8 * 9 * */ 10'use strict'; 11import H from './Globals.js'; 12const { charts, doc, win } = H; 13/* * 14 * 15 * Functions 16 * 17 * */ 18/** 19 * Provide error messages for debugging, with links to online explanation. This 20 * function can be overridden to provide custom error handling. 21 * 22 * @sample highcharts/chart/highcharts-error/ 23 * Custom error handler 24 * 25 * @function Highcharts.error 26 * 27 * @param {number|string} code 28 * The error code. See 29 * [errors.xml](https://github.com/highcharts/highcharts/blob/master/errors/errors.xml) 30 * for available codes. If it is a string, the error message is printed 31 * directly in the console. 32 * 33 * @param {boolean} [stop=false] 34 * Whether to throw an error or just log a warning in the console. 35 * 36 * @param {Highcharts.Chart} [chart] 37 * Reference to the chart that causes the error. Used in 'debugger' 38 * module to display errors directly on the chart. 39 * Important note: This argument is undefined for errors that lack 40 * access to the Chart instance. In such case, the error will be 41 * displayed on the last created chart. 42 * 43 * @param {Highcharts.Dictionary<string>} [params] 44 * Additional parameters for the generated message. 45 * 46 * @return {void} 47 */ 48function error(code, stop, chart, params) { 49 const severity = stop ? 'Highcharts error' : 'Highcharts warning'; 50 if (code === 32) { 51 code = `${severity}: Deprecated member`; 52 } 53 const isCode = isNumber(code); 54 let message = isCode ? 55 `${severity} #${code}: www.highcharts.com/errors/${code}/` : 56 code.toString(); 57 const defaultHandler = function () { 58 if (stop) { 59 throw new Error(message); 60 } 61 // Else ... 62 if (win.console && 63 error.messages.indexOf(message) === -1 // Prevent console flooting 64 ) { 65 console.warn(message); // eslint-disable-line no-console 66 } 67 }; 68 if (typeof params !== 'undefined') { 69 let additionalMessages = ''; 70 if (isCode) { 71 message += '?'; 72 } 73 objectEach(params, function (value, key) { 74 additionalMessages += `\n - ${key}: ${value}`; 75 if (isCode) { 76 message += encodeURI(key) + '=' + encodeURI(value); 77 } 78 }); 79 message += additionalMessages; 80 } 81 fireEvent(H, 'displayError', { chart, code, message, params }, defaultHandler); 82 error.messages.push(message); 83} 84(function (error) { 85 error.messages = []; 86})(error || (error = {})); 87/** 88 * Utility function to deep merge two or more objects and return a third object. 89 * If the first argument is true, the contents of the second object is copied 90 * into the first object. The merge function can also be used with a single 91 * object argument to create a deep copy of an object. 92 * 93 * @function Highcharts.merge<T> 94 * 95 * @param {true | T} extendOrSource 96 * Whether to extend the left-side object, 97 * or the first object to merge as a deep copy. 98 * 99 * @param {...Array<object|undefined>} [sources] 100 * Object(s) to merge into the previous one. 101 * 102 * @return {T} 103 * The merged object. If the first argument is true, the return is the 104 * same as the second argument. 105 */ 106function merge(extendOrSource, ...sources) { 107 let i, args = [extendOrSource, ...sources], ret = {}; 108 const doCopy = function (copy, original) { 109 // An object is replacing a primitive 110 if (typeof copy !== 'object') { 111 copy = {}; 112 } 113 objectEach(original, function (value, key) { 114 // Prototype pollution (#14883) 115 if (key === '__proto__' || key === 'constructor') { 116 return; 117 } 118 // Copy the contents of objects, but not arrays or DOM nodes 119 if (isObject(value, true) && 120 !isClass(value) && 121 !isDOMElement(value)) { 122 copy[key] = doCopy(copy[key] || {}, value); 123 // Primitives and arrays are copied over directly 124 } 125 else { 126 copy[key] = original[key]; 127 } 128 }); 129 return copy; 130 }; 131 // If first argument is true, copy into the existing object. Used in 132 // setOptions. 133 if (extendOrSource === true) { 134 ret = args[1]; 135 args = Array.prototype.slice.call(args, 2); 136 } 137 // For each argument, extend the return 138 const len = args.length; 139 for (i = 0; i < len; i++) { 140 ret = doCopy(ret, args[i]); 141 } 142 return ret; 143} 144/** 145 * Constrain a value to within a lower and upper threshold. 146 * 147 * @private 148 * @param {number} value The initial value 149 * @param {number} min The lower threshold 150 * @param {number} max The upper threshold 151 * @return {number} Returns a number value within min and max. 152 */ 153function clamp(value, min, max) { 154 return value > min ? value < max ? value : max : min; 155} 156/** 157 * Utility for crisping a line position to the nearest full pixel depening on 158 * the line width 159 * @param {number} value The raw pixel position 160 * @param {number} lineWidth The line width 161 * @param {boolean} [inverted] Whether the containing group is inverted. 162 * Crisping round numbers on the y-scale need to go 163 * to the other side because the coordinate system 164 * is flipped (scaleY is -1) 165 * @return {number} The pixel position to use for a crisp display 166 */ 167function crisp(value, lineWidth = 0, inverted) { 168 const mod = lineWidth % 2 / 2, inverter = inverted ? -1 : 1; 169 return (Math.round(value * inverter - mod) + mod) * inverter; 170} 171// eslint-disable-next-line valid-jsdoc 172/** 173 * Return the deep difference between two objects. It can either return the new 174 * properties, or optionally return the old values of new properties. 175 * @private 176 */ 177function diffObjects(newer, older, keepOlder, collectionsWithUpdate) { 178 const ret = {}; 179 /** 180 * Recurse over a set of options and its current values, and store the 181 * current values in the ret object. 182 */ 183 function diff(newer, older, ret, depth) { 184 const keeper = keepOlder ? older : newer; 185 objectEach(newer, function (newerVal, key) { 186 if (!depth && 187 collectionsWithUpdate && 188 collectionsWithUpdate.indexOf(key) > -1 && 189 older[key]) { 190 newerVal = splat(newerVal); 191 ret[key] = []; 192 // Iterate over collections like series, xAxis or yAxis and map 193 // the items by index. 194 for (let i = 0; i < Math.max(newerVal.length, older[key].length); i++) { 195 // Item exists in current data (#6347) 196 if (older[key][i]) { 197 // If the item is missing from the new data, we need to 198 // save the whole config structure. Like when 199 // responsively updating from a dual axis layout to a 200 // single axis and back (#13544). 201 if (newerVal[i] === void 0) { 202 ret[key][i] = older[key][i]; 203 // Otherwise, proceed 204 } 205 else { 206 ret[key][i] = {}; 207 diff(newerVal[i], older[key][i], ret[key][i], depth + 1); 208 } 209 } 210 } 211 } 212 else if (isObject(newerVal, true) && 213 !newerVal.nodeType // #10044 214 ) { 215 ret[key] = isArray(newerVal) ? [] : {}; 216 diff(newerVal, older[key] || {}, ret[key], depth + 1); 217 // Delete empty nested objects 218 if (Object.keys(ret[key]).length === 0 && 219 // Except colorAxis which is a special case where the empty 220 // object means it is enabled. Which is unfortunate and we 221 // should try to find a better way. 222 !(key === 'colorAxis' && depth === 0)) { 223 delete ret[key]; 224 } 225 } 226 else if (newer[key] !== older[key] || 227 // If the newer key is explicitly undefined, keep it (#10525) 228 (key in newer && !(key in older))) { 229 if (key !== '__proto__' && key !== 'constructor') { 230 ret[key] = keeper[key]; 231 } 232 } 233 }); 234 } 235 diff(newer, older, ret, 0); 236 return ret; 237} 238/** 239 * Shortcut for parseInt 240 * 241 * @private 242 * @function Highcharts.pInt 243 * 244 * @param {*} s 245 * any 246 * 247 * @param {number} [mag] 248 * Magnitude 249 * 250 * @return {number} 251 * number 252 */ 253function pInt(s, mag) { 254 return parseInt(s, mag || 10); 255} 256/** 257 * Utility function to check for string type. 258 * 259 * @function Highcharts.isString 260 * 261 * @param {*} s 262 * The item to check. 263 * 264 * @return {boolean} 265 * True if the argument is a string. 266 */ 267function isString(s) { 268 return typeof s === 'string'; 269} 270/** 271 * Utility function to check if an item is an array. 272 * 273 * @function Highcharts.isArray 274 * 275 * @param {*} obj 276 * The item to check. 277 * 278 * @return {boolean} 279 * True if the argument is an array. 280 */ 281function isArray(obj) { 282 const str = Object.prototype.toString.call(obj); 283 return str === '[object Array]' || str === '[object Array Iterator]'; 284} 285/** 286 * Utility function to check if an item is of type object. 287 * 288 * @function Highcharts.isObject 289 * 290 * @param {*} obj 291 * The item to check. 292 * 293 * @param {boolean} [strict=false] 294 * Also checks that the object is not an array. 295 * 296 * @return {boolean} 297 * True if the argument is an object. 298 */
299function isObject(obj, strict) { 300 return (!!obj && 301 typeof obj === 'object' && 302 (!strict || !isArray(obj))); // eslint-disable-line @typescript-eslint/no-explicit-any 303} 304/** 305 * Utility function to check if an Object is a HTML Element. 306 * 307 * @function Highcharts.isDOMElement 308 * 309 * @param {*} obj 310 * The item to check. 311 * 312 * @return {boolean} 313 * True if the argument is a HTML Element. 314 */ 315function isDOMElement(obj) { 316 return isObject(obj) && typeof obj.nodeType === 'number'; 317} 318/** 319 * Utility function to check if an Object is a class. 320 * 321 * @function Highcharts.isClass 322 * 323 * @param {object|undefined} obj 324 * The item to check. 325 * 326 * @return {boolean} 327 * True if the argument is a class. 328 */ 329function isClass(obj) { 330 const c = obj && obj.constructor; 331 return !!(isObject(obj, true) && 332 !isDOMElement(obj) && 333 (c && c.name && c.name !== 'Object')); 334} 335/** 336 * Utility function to check if an item is a number and it is finite (not NaN, 337 * Infinity or -Infinity). 338 * 339 * @function Highcharts.isNumber 340 * 341 * @param {*} n 342 * The item to check. 343 * 344 * @return {boolean} 345 * True if the item is a finite number 346 */ 347function isNumber(n) { 348 return typeof n === 'number' && !isNaN(n) && n < Infinity && n > -Infinity; 349} 350/** 351 * Remove the last occurence of an item from an array. 352 * 353 * @function Highcharts.erase 354 * 355 * @param {Array<*>} arr 356 * The array. 357 * 358 * @param {*} item 359 * The item to remove. 360 * 361 * @return {void} 362 */ 363function erase(arr, item) { 364 let i = arr.length; 365 while (i--) { 366 if (arr[i] === item) { 367 arr.splice(i, 1); 368 break; 369 } 370 } 371} 372/** 373 * Insert a series or an axis in a collection with other items, either the 374 * chart series or yAxis series or axis collections, in the correct order 375 * according to the index option and whether it is internal. Used internally 376 * when adding series and axes. 377 * 378 * @private 379 * @function Highcharts.Chart#insertItem 380 * @param {Highcharts.Series|Highcharts.Axis} item 381 * The item to insert 382 * @param {Array<Highcharts.Series>|Array<Highcharts.Axis>} collection 383 * A collection of items, like `chart.series` or `xAxis.series`. 384 * @return {number} The index of the series in the collection. 385 */ 386function insertItem(item, collection) { 387 const indexOption = item.options.index, length = collection.length; 388 let i; 389 for ( 390 // Internal item (navigator) should always be pushed to the end 391 i = item.options.isInternal ? length : 0; i < length + 1; i++) { 392 if ( 393 // No index option, reached the end of the collection, 394 // equivalent to pushing 395 !collection[i] || 396 // Handle index option, the element to insert has lower index 397 (isNumber(indexOption) && 398 indexOption < pick(collection[i].options.index, collection[i]._i)) || 399 // Insert the new item before other internal items 400 // (navigator) 401 collection[i].options.isInternal) { 402 collection.splice(i, 0, item); 403 break; 404 } 405 } 406 return i; 407} 408/** 409 * Adds an item to an array, if it is not present in the array. 410 * 411 * @function Highcharts.pushUnique 412 * 413 * @param {Array<unknown>} array 414 * The array to add the item to. 415 * 416 * @param {unknown} item 417 * The item to add. 418 * 419 * @return {boolean} 420 * Returns true, if the item was not present and has been added. 421 */ 422function pushUnique(array, item) { 423 return array.indexOf(item) < 0 && !!array.push(item); 424} 425/** 426 * Check if an object is null or undefined. 427 * 428 * @function Highcharts.defined 429 * 430 * @param {*} obj 431 * The object to check. 432 * 433 * @return {boolean} 434 * False if the object is null or undefined, otherwise true. 435 */ 436function defined(obj) { 437 return typeof obj !== 'undefined' && obj !== null; 438} 439/** 440 * Set or get an attribute or an object of attributes. 441 * 442 * To use as a setter, pass a key and a value, or let the second argument be a 443 * collection of keys and values. When using a collection, passing a value of 444 * `null` or `undefined` will remove the attribute. 445 * 446 * To use as a getter, pass only a string as the second argument. 447 * 448 * @function Highcharts.attr 449 * 450 * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} elem 451 * The DOM element to receive the attribute(s). 452 * 453 * @param {string|Highcharts.HTMLAttributes|Highcharts.SVGAttributes} [keyOrAttribs]
454 * The property or an object of key-value pairs. 455 * 456 * @param {number|string} [value] 457 * The value if a single property is set. 458 * 459 * @return {string|null|undefined} 460 * When used as a getter, return the value. 461 */ 462function attr(elem, keyOrAttribs, value) { 463 const isGetter = isString(keyOrAttribs) && !defined(value); 464 let ret; 465 const attrSingle = (value, key) => { 466 // Set the value 467 if (defined(value)) { 468 elem.setAttribute(key, value); 469 // Get the value 470 } 471 else if (isGetter) { 472 ret = elem.getAttribute(key); 473 // IE7 and below cannot get class through getAttribute (#7850) 474 if (!ret && key === 'class') { 475 ret = elem.getAttribute(key + 'Name'); 476 } 477 // Remove the value 478 } 479 else { 480 elem.removeAttribute(key); 481 } 482 }; 483 // If keyOrAttribs is a string 484 if (isString(keyOrAttribs)) { 485 attrSingle(value, keyOrAttribs); 486 // Else if keyOrAttribs is defined, it is a hash of key/value pairs 487 } 488 else { 489 objectEach(keyOrAttribs, attrSingle); 490 } 491 return ret; 492} 493/** 494 * Check if an element is an array, and if not, make it into an array. 495 * 496 * @function Highcharts.splat 497 * 498 * @param {*} obj 499 * The object to splat. 500 * 501 * @return {Array} 502 * The produced or original array. 503 */ 504function splat(obj) { 505 return isArray(obj) ? obj : [obj]; 506} 507/** 508 * Set a timeout if the delay is given, otherwise perform the function 509 * synchronously. 510 * 511 * @function Highcharts.syncTimeout 512 * 513 * @param {Function} fn 514 * The function callback. 515 * 516 * @param {number} delay 517 * Delay in milliseconds. 518 * 519 * @param {*} [context] 520 * An optional context to send to the function callback. 521 * 522 * @return {number} 523 * An identifier for the timeout that can later be cleared with 524 * Highcharts.clearTimeout. Returns -1 if there is no timeout. 525 */ 526function syncTimeout(fn, delay, context) { 527 if (delay > 0) { 528 return setTimeout(fn, delay, context); 529 } 530 fn.call(0, context); 531 return -1; 532} 533/** 534 * Internal clear timeout. The function checks that the `id` was not removed 535 * (e.g. by `chart.destroy()`). For the details see 536 * [issue #7901](https://github.com/highcharts/highcharts/issues/7901). 537 * 538 * @function Highcharts.clearTimeout 539 * 540 * @param {number|undefined} id 541 * Id of a timeout. 542 */ 543function internalClearTimeout(id) { 544 if (defined(id)) { 545 clearTimeout(id); 546 } 547} 548/* eslint-disable valid-jsdoc */ 549/** 550 * Utility function to extend an object with the members of another. 551 * 552 * @function Highcharts.extend<T> 553 * 554 * @param {T|undefined} a 555 * The object to be extended. 556 * 557 * @param {Partial<T>} b 558 * The object to add to the first one. 559 * 560 * @return {T} 561 * Object a, the original object. 562 */ 563function extend(a, b) { 564 /* eslint-enable valid-jsdoc */ 565 let n; 566 if (!a) { 567 a = {}; 568 } 569 for (n in b) { // eslint-disable-line guard-for-in 570 a[n] = b[n]; 571 } 572 return a; 573} 574/* eslint-disable valid-jsdoc */ 575/** 576 * Return the first value that is not null or undefined. 577 * 578 * @function Highcharts.pick<T> 579 * 580 * @param {...Array<T|null|undefined>} items 581 * Variable number of arguments to inspect. 582 * 583 * @return {T} 584 * The value of the first argument that is not null or undefined. 585 */ 586function pick() { 587 const args = arguments; 588 const length = args.length; 589 for (let i = 0; i < length; i++) { 590 const arg = args[i]; 591 if (typeof arg !== 'undefined' && arg !== null) { 592 return arg; 593 } 594 } 595} 596/** 597 * Set CSS on a given element. 598 * 599 * @function Highcharts.css 600 * 601 * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el 602 * An HTML DOM element. 603 * 604 * @param {Highcharts.CSSObject} styles 605 * Style object with camel case property names. 606 * 607 * @return {void} 608 */ 609function css(el, styles) { 610 extend(el.style, styles); 611} 612/** 613 * Utility function to create an HTML element with attributes and styles. 614 * 615 * @function Highcharts.createElement 616 * 617 * @param {string} tag 618 * The HTML tag. 619 * 620 * @param {Highcharts.HTMLAttributes} [attribs]
621 * Attributes as an object of key-value pairs. 622 * 623 * @param {Highcharts.CSSObject} [styles] 624 * Styles as an object of key-value pairs. 625 * 626 * @param {Highcharts.HTMLDOMElement} [parent] 627 * The parent HTML object. 628 * 629 * @param {boolean} [nopad=false] 630 * If true, remove all padding, border and margin. 631 * 632 * @return {Highcharts.HTMLDOMElement} 633 * The created DOM element. 634 */ 635function createElement(tag, attribs, styles, parent, nopad) { 636 const el = doc.createElement(tag); 637 if (attribs) { 638 extend(el, attribs); 639 } 640 if (nopad) { 641 css(el, { padding: '0', border: 'none', margin: '0' }); 642 } 643 if (styles) { 644 css(el, styles); 645 } 646 if (parent) { 647 parent.appendChild(el); 648 } 649 return el; 650} 651// eslint-disable-next-line valid-jsdoc 652/** 653 * Extend a prototyped class by new members. 654 * 655 * @deprecated 656 * @function Highcharts.extendClass<T> 657 * 658 * @param {Highcharts.Class<T>} parent 659 * The parent prototype to inherit. 660 * 661 * @param {Highcharts.Dictionary<*>} members 662 * A collection of prototype members to add or override compared to the 663 * parent prototype. 664 * 665 * @return {Highcharts.Class<T>} 666 * A new prototype. 667 */ 668function extendClass(parent, members) { 669 const obj = (function () { }); 670 obj.prototype = new parent(); // eslint-disable-line new-cap 671 extend(obj.prototype, members); 672 return obj; 673} 674/** 675 * Left-pad a string to a given length by adding a character repetitively. 676 * 677 * @function Highcharts.pad 678 * 679 * @param {number} number 680 * The input string or number. 681 * 682 * @param {number} [length] 683 * The desired string length. 684 * 685 * @param {string} [padder=0] 686 * The character to pad with. 687 * 688 * @return {string} 689 * The padded string. 690 */ 691function pad(number, length, padder) { 692 return new Array((length || 2) + 693 1 - 694 String(number) 695 .replace('-', '') 696 .length).join(padder || '0') + number; 697} 698/** 699 * Return a length based on either the integer value, or a percentage of a base. 700 * 701 * @function Highcharts.relativeLength 702 * 703 * @param {Highcharts.RelativeSize} value 704 * A percentage string or a number. 705 * 706 * @param {number} base 707 * The full length that represents 100%. 708 * 709 * @param {number} [offset=0] 710 * A pixel offset to apply for percentage values. Used internally in 711 * axis positioning. 712 * 713 * @return {number} 714 * The computed length. 715 */ 716function relativeLength(value, base, offset) { 717 return (/%$/).test(value) ? 718 (base * parseFloat(value) / 100) + (offset || 0) : 719 parseFloat(value); 720} 721/** 722 * Replaces text in a string with a given replacement in a loop to catch nested 723 * matches after previous replacements. 724 * 725 * @function Highcharts.replaceNested 726 * 727 * @param {string} text 728 * Text to search and modify. 729 * 730 * @param {...Array<(RegExp|string)>} replacements 731 * One or multiple tuples with search pattern (`[0]: (string|RegExp)`) and 732 * replacement (`[1]: string`) for matching text. 733 * 734 * @return {string} 735 * Text with replacements. 736 */ 737function replaceNested(text, ...replacements) { 738 let previous, replacement; 739 do { 740 previous = text; 741 for (replacement of replacements) { 742 text = text.replace(replacement[0], replacement[1]); 743 } 744 } while (text !== previous); 745 return text; 746} 747/** 748 * Wrap a method with extended functionality, preserving the original function. 749 * 750 * @function Highcharts.wrap 751 * 752 * @param {*} obj 753 * The context object that the method belongs to. In real cases, this is 754 * often a prototype. 755 * 756 * @param {string} method 757 * The name of the method to extend. 758 * 759 * @param {Highcharts.WrapProceedFunction} func 760 * A wrapper function callback. This function is called with the same 761 * arguments as the original function, except that the original function 762 * is unshifted and passed as the first argument. 763 */ 764function wrap(obj, method, func) { 765 const proceed = obj[method]; 766 obj[method] = function () { 767 const outerArgs = arguments, scope = this; 768 return func.apply(this, [ 769 function () { 770 return proceed.apply(scope, arguments.length ? arguments : outerArgs); 771 } 772 ].concat([].slice.call(arguments))); 773 }; 774} 775/** 776 * Get the magnitude of a number. 777 * 778 * @function Highcharts.getMagnitude 779 * 780 * @param {number} num 781 * The number. 782 * 783 * @return {number} 784 * The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2 etc. 785 */ 786function getMagnitude(num) { 787 return Math.pow(10, Math.floor(Math.log(num) / Math.LN10)); 788} 789/** 790 * Take an interval and normalize it to multiples of round numbers. 791 * 792 * @deprecated 793 * @function Highcharts.normalizeTickInterval 794 * 795 * @param {number} interval 796 * The raw, un-rounded interval. 797 * 798 * @param {Array<*>} [multiples] 799 * Allowed multiples. 800 * 801 * @param {number} [magnitude] 802 * The magnitude of the number. 803 * 804 * @param {boolean} [allowDecimals] 805 * Whether to allow decimals. 806 * 807 * @param {boolean} [hasTickAmount]
vendor: 6,868 bytes, lines 808-1046
808 * If it has tickAmount, avoid landing on tick intervals lower than 809 * original. 810 * 811 * @return {number} 812 * The normalized interval. 813 * 814 * @todo 815 * Move this function to the Axis prototype. It is here only for historical 816 * reasons. 817 */ 818function normalizeTickInterval(interval, multiples, magnitude, allowDecimals, hasTickAmount) { 819 let i, retInterval = interval; 820 // Round to a tenfold of 1, 2, 2.5 or 5 821 magnitude = pick(magnitude, getMagnitude(interval)); 822 const normalized = interval / magnitude; 823 // Multiples for a linear scale 824 if (!multiples) { 825 multiples = hasTickAmount ? 826 // Finer grained ticks when the tick amount is hard set, including 827 // when alignTicks is true on multiple axes (#4580). 828 [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] : 829 // Else, let ticks fall on rounder numbers 830 [1, 2, 2.5, 5, 10]; 831 // The allowDecimals option 832 if (allowDecimals === false) { 833 if (magnitude === 1) { 834 multiples = multiples.filter(function (num) { 835 return num % 1 === 0; 836 }); 837 } 838 else if (magnitude <= 0.1) { 839 multiples = [1 / magnitude]; 840 } 841 } 842 } 843 // Normalize the interval to the nearest multiple 844 for (i = 0; i < multiples.length; i++) { 845 retInterval = multiples[i]; 846 // Only allow tick amounts smaller than natural 847 if ((hasTickAmount && 848 retInterval * magnitude >= interval) || 849 (!hasTickAmount && 850 (normalized <= 851 (multiples[i] + 852 (multiples[i + 1] || multiples[i])) / 2))) { 853 break; 854 } 855 } 856 // Multiply back to the correct magnitude. Correct floats to appropriate 857 // precision (#6085). 858 retInterval = correctFloat(retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10)); 859 return retInterval; 860} 861/** 862 * Sort an object array and keep the order of equal items. The ECMAScript 863 * standard does not specify the behaviour when items are equal. 864 * 865 * @function Highcharts.stableSort 866 * 867 * @param {Array<*>} arr 868 * The array to sort. 869 * 870 * @param {Function} sortFunction 871 * The function to sort it with, like with regular Array.prototype.sort. 872 */ 873function stableSort(arr, sortFunction) { 874 // @todo It seems like Chrome since v70 sorts in a stable way internally, 875 // plus all other browsers do it, so over time we may be able to remove this 876 // function 877 const length = arr.length; 878 let sortValue, i; 879 // Add index to each item 880 for (i = 0; i < length; i++) { 881 arr[i].safeI = i; // Stable sort index 882 } 883 arr.sort(function (a, b) { 884 sortValue = sortFunction(a, b); 885 return sortValue === 0 ? a.safeI - b.safeI : sortValue; 886 }); 887 // Remove index from items 888 for (i = 0; i < length; i++) { 889 delete arr[i].safeI; // Stable sort index 890 } 891} 892/** 893 * Non-recursive method to find the lowest member of an array. `Math.min` raises 894 * a maximum call stack size exceeded error in Chrome when trying to apply more 895 * than 150.000 points. This method is slightly slower, but safe. 896 * 897 * @function Highcharts.arrayMin 898 * 899 * @param {Array<*>} data 900 * An array of numbers. 901 * 902 * @return {number} 903 * The lowest number. 904 */ 905function arrayMin(data) { 906 let i = data.length, min = data[0]; 907 while (i--) { 908 if (data[i] < min) { 909 min = data[i]; 910 } 911 } 912 return min; 913} 914/** 915 * Non-recursive method to find the lowest member of an array. `Math.max` raises 916 * a maximum call stack size exceeded error in Chrome when trying to apply more 917 * than 150.000 points. This method is slightly slower, but safe. 918 * 919 * @function Highcharts.arrayMax 920 * 921 * @param {Array<*>} data 922 * An array of numbers. 923 * 924 * @return {number} 925 * The highest number. 926 */ 927function arrayMax(data) { 928 let i = data.length, max = data[0]; 929 while (i--) { 930 if (data[i] > max) { 931 max = data[i]; 932 } 933 } 934 return max; 935} 936/** 937 * Utility method that destroys any SVGElement instances that are properties on 938 * the given object. It loops all properties and invokes destroy if there is a 939 * destroy method. The property is then delete. 940 * 941 * @function Highcharts.destroyObjectProperties 942 * 943 * @param {*} obj 944 * The object to destroy properties on. 945 * 946 * @param {*} [except] 947 * Exception, do not destroy this property, only delete it. 948 */ 949function destroyObjectProperties(obj, except, destructablesOnly) { 950 objectEach(obj, function (val, n) { 951 // If the object is non-null and destroy is defined 952 if (val !== except && val?.destroy) { 953 // Invoke the destroy 954 val.destroy(); 955 } 956 // Delete the property from the object 957 if (val?.destroy || !destructablesOnly) { 958 delete obj[n]; 959 } 960 }); 961} 962/** 963 * Discard a HTML element 964 * 965 * @function Highcharts.discardElement 966 * 967 * @param {Highcharts.HTMLDOMElement} element 968 * The HTML node to discard. 969 */ 970function discardElement(element) { 971 if (element && element.parentElement) { 972 element.parentElement.removeChild(element); 973 } 974} 975/** 976 * Fix JS round off float errors. 977 * 978 * @function Highcharts.correctFloat 979 * 980 * @param {number} num 981 * A float number to fix. 982 * 983 * @param {number} [prec=14] 984 * The precision. 985 * 986 * @return {number} 987 * The corrected float number. 988 */ 989function correctFloat(num, prec) { 990 // When the number is higher than 1e14 use the number (#16275) 991 return num > 1e14 ? num : parseFloat(num.toPrecision(prec || 14)); 992} 993/** 994 * The time unit lookup 995 * 996 * @ignore 997 */ 998const timeUnits = { 999 millisecond: 1, 1000 second: 1000, 1001 minute: 60000, 1002 hour: 3600000, 1003 day: 24 * 3600000, 1004 week: 7 * 24 * 3600000, 1005 month: 28 * 24 * 3600000, 1006 year: 364 * 24 * 3600000 1007}; 1008/** 1009 * Easing definition 1010 * 1011 * @private 1012 * @function Math.easeInOutSine 1013 * 1014 * @param {number} pos 1015 * Current position, ranging from 0 to 1. 1016 * 1017 * @return {number} 1018 * Ease result 1019 */ 1020Math.easeInOutSine = function (pos) { 1021 return -0.5 * (Math.cos(Math.PI * pos) - 1); 1022}; 1023/** 1024 * Convenience function to get the align factor, used several places for 1025 * computing positions 1026 * @private 1027 */ 1028const getAlignFactor = (align = '') => ({ 1029 center: 0.5, 1030 right: 1, 1031 middle: 0.5, 1032 bottom: 1 1033}[align] || 0); 1034/** 1035 * Find the closest distance between two values of a two-dimensional array 1036 * @private 1037 * @function Highcharts.getClosestDistance 1038 * 1039 * @param {Array<Array<number>>} arrays 1040 * An array of arrays of numbers 1041 * 1042 * @return {number | undefined} 1043 * The closest distance between values 1044 */ 1045function getClosestDistance(arrays, onError) { 1046 const allowNegative = !onError;
vendor: 14,287 bytes, lines 1047-1474
1047 let closest, loopLength, distance, i; 1048 arrays.forEach((xData) => { 1049 if (xData.length > 1) { 1050 loopLength = xData.length - 1; 1051 for (i = loopLength; i > 0; i--) { 1052 distance = xData[i] - xData[i - 1]; 1053 if (distance < 0 && !allowNegative) { 1054 onError?.(); 1055 // Only one call 1056 onError = void 0; 1057 } 1058 else if (distance && (typeof closest === 'undefined' || distance < closest)) { 1059 closest = distance; 1060 } 1061 } 1062 } 1063 }); 1064 return closest; 1065} 1066/** 1067 * Returns the value of a property path on a given object. 1068 * 1069 * @private 1070 * @function getNestedProperty 1071 * 1072 * @param {string} path 1073 * Path to the property, for example `custom.myValue`. 1074 * 1075 * @param {unknown} obj 1076 * Instance containing the property on the specific path. 1077 * 1078 * @return {unknown} 1079 * The unknown property value. 1080 */ 1081function getNestedProperty(path, parent) { 1082 const pathElements = path.split('.'); 1083 while (pathElements.length && defined(parent)) { 1084 const pathElement = pathElements.shift(); 1085 // Filter on the key 1086 if (typeof pathElement === 'undefined' || 1087 pathElement === '__proto__') { 1088 return; // Undefined 1089 } 1090 if (pathElement === 'this') { 1091 let thisProp; 1092 if (isObject(parent)) { 1093 thisProp = parent['@this']; 1094 } 1095 return thisProp ?? parent; 1096 } 1097 const child = parent[pathElement.replace(/[\\'"]/g, '')]; 1098 // Filter on the child 1099 if (!defined(child) || 1100 typeof child === 'function' || 1101 typeof child.nodeType === 'number' || 1102 child === win) { 1103 return; // Undefined 1104 } 1105 // Else, proceed 1106 parent = child; 1107 } 1108 return parent; 1109} 1110/** 1111 * Get the computed CSS value for given element and property, only for numerical 1112 * properties. For width and height, the dimension of the inner box (excluding 1113 * padding) is returned. Used for fitting the chart within the container. 1114 * 1115 * @function Highcharts.getStyle 1116 * 1117 * @param {Highcharts.HTMLDOMElement} el 1118 * An HTML element. 1119 * 1120 * @param {string} prop 1121 * The property name. 1122 * 1123 * @param {boolean} [toInt=true] 1124 * Parse to integer. 1125 * 1126 * @return {number|string|undefined} 1127 * The style value. 1128 */ 1129function getStyle(el, prop, toInt) { 1130 let style; 1131 // For width and height, return the actual inner pixel size (#4913) 1132 if (prop === 'width') { 1133 let offsetWidth = Math.min(el.offsetWidth, el.scrollWidth); 1134 // In flex boxes, we need to use getBoundingClientRect and floor it, 1135 // because scrollWidth doesn't support subpixel precision (#6427) ... 1136 const boundingClientRectWidth = el.getBoundingClientRect && 1137 el.getBoundingClientRect().width; 1138 // ...unless if the containing div or its parents are transform-scaled 1139 // down, in which case the boundingClientRect can't be used as it is 1140 // also scaled down (#9871, #10498). 1141 if (boundingClientRectWidth < offsetWidth && 1142 boundingClientRectWidth >= offsetWidth - 1) { 1143 offsetWidth = Math.floor(boundingClientRectWidth); 1144 } 1145 return Math.max(0, // #8377 1146 (offsetWidth - 1147 (getStyle(el, 'padding-left', true) || 0) - 1148 (getStyle(el, 'padding-right', true) || 0))); 1149 } 1150 if (prop === 'height') { 1151 return Math.max(0, // #8377 1152 (Math.min(el.offsetHeight, el.scrollHeight) - 1153 (getStyle(el, 'padding-top', true) || 0) - 1154 (getStyle(el, 'padding-bottom', true) || 0))); 1155 } 1156 // Otherwise, get the computed style 1157 const css = win.getComputedStyle(el, void 0); // eslint-disable-line no-undefined 1158 if (css) { 1159 style = css.getPropertyValue(prop); 1160 if (pick(toInt, prop !== 'opacity')) { 1161 style = pInt(style); 1162 } 1163 } 1164 return style; 1165} 1166/** 1167 * Return the value of the first element in the array that satisfies the 1168 * provided testing function. 1169 * 1170 * @function Highcharts.find<T> 1171 * 1172 * @param {Array<T>} arr 1173 * The array to test. 1174 * 1175 * @param {Function} callback 1176 * The callback function. The function receives the item as the first 1177 * argument. Return `true` if this item satisfies the condition. 1178 * 1179 * @return {T|undefined} 1180 * The value of the element. 1181 */ 1182const find = Array.prototype.find ? 1183 function (arr, callback) { 1184 return arr.find(callback); 1185 } : 1186 // Legacy implementation. PhantomJS, IE <= 11 etc. #7223. 1187 function (arr, callback) { 1188 let i; 1189 const length = arr.length; 1190 for (i = 0; i < length; i++) { 1191 if (callback(arr[i], i)) { // eslint-disable-line node/callback-return 1192 return arr[i]; 1193 } 1194 } 1195 }; 1196/** 1197 * Get the element's offset position, corrected for `overflow: auto`. 1198 * 1199 * @function Highcharts.offset 1200 * 1201 * @param {global.Element} el 1202 * The DOM element. 1203 * 1204 * @return {Highcharts.OffsetObject} 1205 * An object containing `left` and `top` properties for the position in 1206 * the page. 1207 */ 1208function offset(el) { 1209 const docElem = doc.documentElement, box = (el.parentElement || el.parentNode) ? 1210 el.getBoundingClientRect() : 1211 { top: 0, left: 0, width: 0, height: 0 }; 1212 return { 1213 top: box.top + (win.pageYOffset || docElem.scrollTop) - 1214 (docElem.clientTop || 0), 1215 left: box.left + (win.pageXOffset || docElem.scrollLeft) - 1216 (docElem.clientLeft || 0), 1217 width: box.width, 1218 height: box.height 1219 }; 1220} 1221/* eslint-disable valid-jsdoc */ 1222/** 1223 * Iterate over object key pairs in an object. 1224 * 1225 * @function Highcharts.objectEach<T> 1226 * 1227 * @param {*} obj 1228 * The object to iterate over. 1229 * 1230 * @param {Highcharts.ObjectEachCallbackFunction<T>} fn 1231 * The iterator callback. It passes three arguments: 1232 * * value - The property value. 1233 * * key - The property key. 1234 * * obj - The object that objectEach is being applied to. 1235 * 1236 * @param {T} [ctx] 1237 * The context. 1238 */ 1239function objectEach(obj, fn, ctx) { 1240 /* eslint-enable valid-jsdoc */ 1241 for (const key in obj) { 1242 if (Object.hasOwnProperty.call(obj, key)) { 1243 fn.call(ctx || obj[key], obj[key], key, obj); 1244 } 1245 } 1246} 1247/* eslint-disable valid-jsdoc */ 1248/** 1249 * Add an event listener. 1250 * 1251 * @function Highcharts.addEvent<T> 1252 * 1253 * @param {Highcharts.Class<T>|T} el 1254 * The element or object to add a listener to. It can be a 1255 * {@link HTMLDOMElement}, an {@link SVGElement} or any other object. 1256 * 1257 * @param {string} type 1258 * The event type. 1259 * 1260 * @param {Highcharts.EventCallbackFunction<T>|Function} fn 1261 * The function callback to execute when the event is fired. 1262 * 1263 * @param {Highcharts.EventOptionsObject} [options] 1264 * Options for adding the event. 1265 * 1266 * @sample highcharts/members/addevent 1267 * Use a general `render` event to draw shapes on a chart 1268 * 1269 * @return {Function} 1270 * A callback function to remove the added event. 1271 */ 1272function addEvent(el, type, fn, options = {}) { 1273 /* eslint-enable valid-jsdoc */ 1274 // Add hcEvents to either the prototype (in case we're running addEvent on a 1275 // class) or the instance. If hasOwnProperty('hcEvents') is false, it is 1276 // inherited down the prototype chain, in which case we need to set the 1277 // property on this instance (which may itself be a prototype). 1278 const owner = typeof el === 'function' && el.prototype || el; 1279 if (!Object.hasOwnProperty.call(owner, 'hcEvents')) { 1280 owner.hcEvents = {}; 1281 } 1282 const events = owner.hcEvents; 1283 // Allow click events added to points, otherwise they will be prevented by 1284 // the TouchPointer.pinch function after a pinch zoom operation (#7091). 1285 if (H.Point && // Without H a dependency loop occurs 1286 el instanceof H.Point && 1287 el.series && 1288 el.series.chart) { 1289 el.series.chart.runTrackerClick = true; 1290 } 1291 // Handle DOM events 1292 // If the browser supports passive events, add it to improve performance 1293 // on touch events (#11353). 1294 const addEventListener = el.addEventListener; 1295 if (addEventListener) { 1296 addEventListener.call(el, type, fn, H.supportsPassiveEvents ? { 1297 passive: options.passive === void 0 ? 1298 type.indexOf('touch') !== -1 : options.passive, 1299 capture: false 1300 } : false); 1301 } 1302 if (!events[type]) { 1303 events[type] = []; 1304 } 1305 const eventObject = { 1306 fn, 1307 order: typeof options.order === 'number' ? options.order : Infinity 1308 }; 1309 events[type].push(eventObject); 1310 // Order the calls 1311 events[type].sort((a, b) => a.order - b.order); 1312 // Return a function that can be called to remove this event. 1313 return function () { 1314 removeEvent(el, type, fn); 1315 }; 1316} 1317/* eslint-disable valid-jsdoc */ 1318/** 1319 * Remove an event that was added with {@link Highcharts#addEvent}. 1320 * 1321 * @function Highcharts.removeEvent<T> 1322 * 1323 * @param {Highcharts.Class<T>|T} el 1324 * The element to remove events on. 1325 * 1326 * @param {string} [type] 1327 * The type of events to remove. If undefined, all events are removed 1328 * from the element. 1329 * 1330 * @param {Highcharts.EventCallbackFunction<T>} [fn] 1331 * The specific callback to remove. If undefined, all events that match 1332 * the element and optionally the type are removed. 1333 * 1334 * @return {void} 1335 */ 1336function removeEvent(el, type, fn) { 1337 /* eslint-enable valid-jsdoc */ 1338 /** 1339 * @private 1340 */ 1341 function removeOneEvent(type, fn) { 1342 const removeEventListener = el.removeEventListener; 1343 if (removeEventListener) { 1344 removeEventListener.call(el, type, fn, false); 1345 } 1346 } 1347 /** 1348 * @private 1349 */ 1350 function removeAllEvents(eventCollection) { 1351 let types, len; 1352 if (!el.nodeName) { 1353 return; // Break on non-DOM events 1354 } 1355 if (type) { 1356 types = {}; 1357 types[type] = true; 1358 } 1359 else { 1360 types = eventCollection; 1361 } 1362 objectEach(types, function (_val, n) { 1363 if (eventCollection[n]) { 1364 len = eventCollection[n].length; 1365 while (len--) { 1366 removeOneEvent(n, eventCollection[n][len].fn); 1367 } 1368 } 1369 }); 1370 } 1371 const owner = typeof el === 'function' && el.prototype || el; 1372 if (Object.hasOwnProperty.call(owner, 'hcEvents')) { 1373 const events = owner.hcEvents; 1374 if (type) { 1375 const typeEvents = (events[type] || []); 1376 if (fn) { 1377 events[type] = typeEvents.filter(function (obj) { 1378 return fn !== obj.fn; 1379 }); 1380 removeOneEvent(type, fn); 1381 } 1382 else { 1383 removeAllEvents(events); 1384 events[type] = []; 1385 } 1386 } 1387 else { 1388 removeAllEvents(events); 1389 delete owner.hcEvents; 1390 } 1391 } 1392} 1393/* eslint-disable valid-jsdoc */ 1394/** 1395 * Fire an event that was registered with {@link Highcharts#addEvent}. 1396 * 1397 * @function Highcharts.fireEvent<T> 1398 * 1399 * @param {T} el 1400 * The object to fire the event on. It can be a {@link HTMLDOMElement}, 1401 * an {@link SVGElement} or any other object. 1402 * 1403 * @param {string} type 1404 * The type of event. 1405 * 1406 * @param {Highcharts.Dictionary<*>|Event} [eventArguments] 1407 * Custom event arguments that are passed on as an argument to the event 1408 * handler. 1409 * 1410 * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction] 1411 * The default function to execute if the other listeners haven't 1412 * returned false. 1413 * 1414 * @return {void} 1415 */ 1416function fireEvent(el, type, eventArguments, defaultFunction) { 1417 /* eslint-enable valid-jsdoc */ 1418 eventArguments = eventArguments || {}; 1419 if (doc.createEvent && 1420 (el.dispatchEvent || 1421 (el.fireEvent && 1422 // Enable firing events on Highcharts instance. 1423 el !== H))) { 1424 const e = doc.createEvent('Events'); 1425 e.initEvent(type, true, true); 1426 eventArguments = extend(e, eventArguments); 1427 if (el.dispatchEvent) { 1428 el.dispatchEvent(eventArguments); 1429 } 1430 else { 1431 el.fireEvent(type, eventArguments); 1432 } 1433 } 1434 else if (el.hcEvents) { 1435 if (!eventArguments.target) { 1436 // We're running a custom event 1437 extend(eventArguments, { 1438 // Attach a simple preventDefault function to skip 1439 // default handler if called. The built-in 1440 // defaultPrevented property is not overwritable (#5112) 1441 preventDefault: function () { 1442 eventArguments.defaultPrevented = true; 1443 }, 1444 // Setting target to native events fails with clicking 1445 // the zoom-out button in Chrome. 1446 target: el, 1447 // If the type is not set, we're running a custom event 1448 // (#2297). If it is set, we're running a browser event. 1449 type: type 1450 }); 1451 } 1452 const events = []; 1453 let object = el; 1454 let multilevel = false; 1455 // Recurse up the inheritance chain and collect hcEvents set as own 1456 // objects on the prototypes. 1457 while (object.hcEvents) { 1458 if (Object.hasOwnProperty.call(object, 'hcEvents') && 1459 object.hcEvents[type]) { 1460 if (events.length) { 1461 multilevel = true; 1462 } 1463 events.unshift.apply(events, object.hcEvents[type]); 1464 } 1465 object = Object.getPrototypeOf(object); 1466 } 1467 // For performance reasons, only sort the event handlers in case we are 1468 // dealing with multiple levels in the prototype chain. Otherwise, the 1469 // events are already sorted in the addEvent function. 1470 if (multilevel) { 1471 // Order the calls 1472 events.sort((a, b) => a.order - b.order); 1473 } 1474 // Call the collected event handlers
1475 events.forEach((obj) => { 1476 // If the event handler returns false, prevent the default handler 1477 // from executing 1478 if (obj.fn.call(el, eventArguments) === false) { 1479 eventArguments.preventDefault(); 1480 } 1481 }); 1482 } 1483 // Run the default if not prevented 1484 if (defaultFunction && !eventArguments.defaultPrevented) { 1485 defaultFunction.call(el, eventArguments); 1486 } 1487} 1488let serialMode; 1489/** 1490 * Get a unique key for using in internal element id's and pointers. The key is 1491 * composed of a random hash specific to this Highcharts instance, and a 1492 * counter. 1493 * 1494 * @example 1495 * let id = uniqueKey(); // => 'highcharts-x45f6hp-0' 1496 * 1497 * @function Highcharts.uniqueKey 1498 * 1499 * @return {string} 1500 * A unique key. 1501 */ 1502const uniqueKey = (function () { 1503 const hash = Math.random().toString(36).substring(2, 9) + '-'; 1504 let id = 0; 1505 return function () { 1506 return 'highcharts-' + (serialMode ? '' : hash) + id++; 1507 }; 1508}()); 1509/** 1510 * Activates a serial mode for element IDs provided by 1511 * {@link Highcharts.uniqueKey}. This mode can be used in automated tests, where 1512 * a simple comparison of two rendered SVG graphics is needed. 1513 * 1514 * **Note:** This is only for testing purposes and will break functionality in 1515 * webpages with multiple charts. 1516 * 1517 * @example 1518 * if ( 1519 * process && 1520 * process.env.NODE_ENV === 'development' 1521 * ) { 1522 * Highcharts.useSerialIds(true); 1523 * } 1524 * 1525 * @function Highcharts.useSerialIds 1526 * 1527 * @param {boolean} [mode] 1528 * Changes the state of serial mode. 1529 * 1530 * @return {boolean|undefined} 1531 * State of the serial mode. 1532 */ 1533function useSerialIds(mode) { 1534 return (serialMode = pick(mode, serialMode)); 1535} 1536function isFunction(obj) { 1537 return typeof obj === 'function'; 1538} 1539function ucfirst(s) { 1540 return ((isString(s) ? 1541 s.substring(0, 1).toUpperCase() + s.substring(1) : 1542 String(s))); 1543} 1544/* * 1545 * 1546 * External 1547 * 1548 * */ 1549// Register Highcharts as a plugin in jQuery 1550if (win.jQuery) { 1551 /** 1552 * Highcharts-extended JQuery. 1553 * 1554 * @external JQuery 1555 */ 1556 /** 1557 * Helper function to return the chart of the current JQuery selector 1558 * element. 1559 * 1560 * @function external:JQuery#highcharts 1561 * 1562 * @return {Highcharts.Chart} 1563 * The chart that is linked to the JQuery selector element. 1564 */ /** 1565 * Factory function to create a chart in the current JQuery selector 1566 * element. 1567 * 1568 * @function external:JQuery#highcharts 1569 * 1570 * @param {'Chart'|'Map'|'StockChart'|string} [className] 1571 * Name of the factory class in the Highcharts namespace. 1572 * 1573 * @param {Highcharts.Options} [options] 1574 * The chart options structure. 1575 * 1576 * @param {Highcharts.ChartCallbackFunction} [callback] 1577 * Function to run when the chart has loaded and all external 1578 * images are loaded. Defining a 1579 * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load) 1580 * handler is equivalent. 1581 * 1582 * @return {JQuery} 1583 * The current JQuery selector. 1584 */ 1585 win.jQuery.fn.highcharts = function () { 1586 const args = [].slice.call(arguments); 1587 if (this[0]) { // `this[0]` is the renderTo div 1588 // Create the chart 1589 if (args[0]) { 1590 new H[ // eslint-disable-line computed-property-spacing, no-new 1591 // Constructor defaults to Chart 1592 isString(args[0]) ? args.shift() : 'Chart'](this[0], args[0], args[1]); 1593 return this; 1594 } 1595 // When called without parameters or with the return argument, 1596 // return an existing chart 1597 return charts[attr(this[0], 'data-highcharts-chart')]; 1598 } 1599 }; 1600} 1601/* * 1602 * 1603 * Default Export 1604 * 1605 * */ 1606// TODO use named exports when supported. 1607const Utilities = { 1608 addEvent, 1609 arrayMax, 1610 arrayMin, 1611 attr, 1612 clamp, 1613 clearTimeout: internalClearTimeout, 1614 correctFloat, 1615 createElement, 1616 crisp, 1617 css, 1618 defined, 1619 destroyObjectProperties, 1620 diffObjects, 1621 discardElement, 1622 erase, 1623 error, 1624 extend, 1625 extendClass, 1626 find, 1627 fireEvent, 1628 getAlignFactor, 1629 getClosestDistance, 1630 getMagnitude, 1631 getNestedProperty, 1632 getStyle, 1633 insertItem, 1634 isArray, 1635 isClass, 1636 isDOMElement, 1637 isFunction, 1638 isNumber, 1639 isObject, 1640 isString, 1641 merge, 1642 normalizeTickInterval, 1643 objectEach, 1644 offset, 1645 pad, 1646 pick, 1647 pInt, 1648 pushUnique, 1649 relativeLength, 1650 removeEvent, 1651 replaceNested, 1652 splat, 1653 stableSort, 1654 syncTimeout, 1655 timeUnits, 1656 ucfirst, 1657 uniqueKey, 1658 useSerialIds, 1659 wrap 1660}; 1661export default Utilities; 1662/* * 1663 * 1664 * API Declarations 1665 * 1666 * */ 1667/** 1668 * An animation configuration. Animation configurations can also be defined as 1669 * booleans, where `false` turns off animation and `true` defaults to a duration 1670 * of 500ms and defer of 0ms. 1671 * 1672 * @interface Highcharts.AnimationOptionsObject 1673 */ /** 1674* A callback function to execute when the animation finishes. 1675* @name Highcharts.AnimationOptionsObject#complete 1676* @type {Function|undefined} 1677*/ /** 1678* The animation defer in milliseconds. 1679* @name Highcharts.AnimationOptionsObject#defer 1680* @type {number|undefined} 1681*/ /** 1682* The animation duration in milliseconds. 1683* @name Highcharts.AnimationOptionsObject#duration 1684* @type {number|undefined} 1685*/ /** 1686* The name of an easing function as defined on the `Math` object. 1687* @name Highcharts.AnimationOptionsObject#easing 1688* @type {string|Function|undefined} 1689*/ /** 1690* A callback function to execute on each step of each attribute or CSS property 1691* that's being animated. The first argument contains information about the 1692* animation and progress. 1693* @name Highcharts.AnimationOptionsObject#step 1694* @type {Function|undefined} 1695*/ 1696/** 1697 * Creates a frame for the animated SVG element. 1698 * 1699 * @callback Highcharts.AnimationStepCallbackFunction 1700 * 1701 * @param {Highcharts.SVGElement} this 1702 * The SVG element to animate. 1703 * 1704 * @return {void} 1705 */ 1706/** 1707 * Interface description for a class. 1708 * 1709 * @interface Highcharts.Class<T> 1710 * @extends Function 1711 */ /** 1712* Class constructor. 1713* @function Highcharts.Class<T>#new 1714* @param {...Array<*>} args 1715* Constructor arguments. 1716* @return {T} 1717* Class instance. 1718*/ 1719/** 1720 * A style object with camel case property names to define visual appearance of 1721 * a SVG element or HTML element. The properties can be whatever styles are 1722 * supported on the given SVG or HTML element. 1723 * 1724 * @example 1725 * { 1726 * fontFamily: 'monospace', 1727 * fontSize: '1.2em' 1728 * } 1729 * 1730 * @interface Highcharts.CSSObject 1731 */ /** 1732* @name Highcharts.CSSObject#[key:string] 1733* @type {boolean|number|string|undefined} 1734*/ /**
1735* Background style for the element. 1736* @name Highcharts.CSSObject#background 1737* @type {string|undefined} 1738*/ /** 1739* Background color of the element. 1740* @name Highcharts.CSSObject#backgroundColor 1741* @type {Highcharts.ColorString|undefined} 1742*/ /** 1743* Border style for the element. 1744* @name Highcharts.CSSObject#border 1745* @type {string|undefined} 1746*/ /** 1747* Radius of the element border. 1748* @name Highcharts.CSSObject#borderRadius 1749* @type {number|undefined} 1750*/ /** 1751* Color used in the element. The 'contrast' option is a Highcharts custom 1752* property that results in black or white, depending on the background of the 1753* element. 1754* @name Highcharts.CSSObject#color 1755* @type {'contrast'|Highcharts.ColorString|undefined} 1756*/ /** 1757* Style of the mouse cursor when resting over the element. 1758* @name Highcharts.CSSObject#cursor 1759* @type {Highcharts.CursorValue|undefined} 1760*/ /** 1761* Font family of the element text. Multiple values have to be in decreasing 1762* preference order and separated by comma. 1763* @name Highcharts.CSSObject#fontFamily 1764* @type {string|undefined} 1765*/ /** 1766* Font size of the element text. 1767* @name Highcharts.CSSObject#fontSize 1768* @type {string|undefined} 1769*/ /** 1770* Font weight of the element text. 1771* @name Highcharts.CSSObject#fontWeight 1772* @type {string|undefined} 1773*/ /** 1774* Height of the element. 1775* @name Highcharts.CSSObject#height 1776* @type {number|undefined} 1777*/ /** 1778* The maximum number of lines. If lines are cropped away, an ellipsis will be 1779* added. 1780* @name Highcharts.CSSObject#lineClamp 1781* @type {number|undefined} 1782*/ /** 1783* Width of the element border. 1784* @name Highcharts.CSSObject#lineWidth 1785* @type {number|undefined} 1786*/ /** 1787* Opacity of the element. 1788* @name Highcharts.CSSObject#opacity 1789* @type {number|undefined} 1790*/ /** 1791* Space around the element content. 1792* @name Highcharts.CSSObject#padding 1793* @type {string|undefined} 1794*/ /**
1795* Behaviour of the element when the mouse cursor rests over it. 1796* @name Highcharts.CSSObject#pointerEvents 1797* @type {string|undefined} 1798*/ /** 1799* Positioning of the element. 1800* @name Highcharts.CSSObject#position 1801* @type {string|undefined} 1802*/ /** 1803* Alignment of the element text. 1804* @name Highcharts.CSSObject#textAlign 1805* @type {string|undefined} 1806*/ /** 1807* Additional decoration of the element text. 1808* @name Highcharts.CSSObject#textDecoration 1809* @type {string|undefined} 1810*/ /** 1811* Outline style of the element text. 1812* @name Highcharts.CSSObject#textOutline 1813* @type {string|undefined} 1814*/ /** 1815* Line break style of the element text. Highcharts SVG elements support 1816* `ellipsis` when a `width` is set. 1817* @name Highcharts.CSSObject#textOverflow 1818* @type {string|undefined} 1819*/ /** 1820* Top spacing of the element relative to the parent element. 1821* @name Highcharts.CSSObject#top 1822* @type {string|undefined} 1823*/ /** 1824* Animated transition of selected element properties. 1825* @name Highcharts.CSSObject#transition 1826* @type {string|undefined} 1827*/ /** 1828* Line break style of the element text. 1829* @name Highcharts.CSSObject#whiteSpace 1830* @type {string|undefined} 1831*/ /** 1832* Width of the element. 1833* @name Highcharts.CSSObject#width 1834* @type {number|undefined} 1835*/ 1836/** 1837 * All possible cursor styles. 1838 * 1839 * @typedef {'alias'|'all-scroll'|'auto'|'cell'|'col-resize'|'context-menu'|'copy'|'crosshair'|'default'|'e-resize'|'ew-resize'|'grab'|'grabbing'|'help'|'move'|'n-resize'|'ne-resize'|'nesw-resize'|'no-drop'|'none'|'not-allowed'|'ns-resize'|'nw-resize'|'nwse-resize'|'pointer'|'progress'|'row-resize'|'s-resize'|'se-resize'|'sw-resize'|'text'|'vertical-text'|'w-resize'|'wait'|'zoom-in'|'zoom-out'} Highcharts.CursorValue 1840 */ 1841/** 1842 * All possible dash styles. 1843 * 1844 * @typedef {'Dash'|'DashDot'|'Dot'|'LongDash'|'LongDashDot'|'LongDashDotDot'|'ShortDash'|'ShortDashDot'|'ShortDashDotDot'|'ShortDot'|'Solid'} Highcharts.DashStyleValue 1845 */ 1846/** 1847 * Generic dictionary in TypeScript notation. 1848 * Use the native `AnyRecord` instead. 1849 * 1850 * @deprecated 1851 * @interface Highcharts.Dictionary<T> 1852 */ /** 1853* @name Highcharts.Dictionary<T>#[key:string] 1854* @type {T} 1855*/ 1856/** 1857 * The function callback to execute when the event is fired. The `this` context 1858 * contains the instance, that fired the event. 1859 * 1860 * @callback Highcharts.EventCallbackFunction<T> 1861 * 1862 * @param {T} this 1863 * 1864 * @param {Highcharts.Dictionary<*>|Event} [eventArguments] 1865 * Event arguments. 1866 * 1867 * @return {boolean|void} 1868 */ 1869/** 1870 * The event options for adding function callback. 1871 * 1872 * @interface Highcharts.EventOptionsObject 1873 */ /** 1874* The order the event handler should be called. This opens for having one 1875* handler be called before another, independent of in which order they were 1876* added. 1877* @name Highcharts.EventOptionsObject#order 1878* @type {number} 1879*/ /** 1880* Whether an event should be passive or not. 1881* When set to `true`, the function specified by listener will never call 1882* `preventDefault()`. 1883* @name Highcharts.EventOptionsObject#passive 1884* @type boolean 1885*/ 1886/** 1887 * Formats data as a string. Usually the data is accessible through the `this` 1888 * keyword. 1889 * 1890 * @callback Highcharts.FormatterCallbackFunction<T> 1891 * 1892 * @param {T} this 1893 * Context to format 1894 * 1895 * @return {string} 1896 * Formatted text 1897 */ 1898/** 1899 * An object of key-value pairs for HTML attributes. 1900 * 1901 * @typedef {Highcharts.Dictionary<boolean|number|string|Function>} Highcharts.HTMLAttributes 1902 */ 1903/** 1904 * An HTML DOM element. The type is a reference to the regular HTMLElement in 1905 * the global scope. 1906 * 1907 * @typedef {global.HTMLElement} Highcharts.HTMLDOMElement 1908 * 1909 * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement 1910 */ 1911/** 1912 * The iterator callback. 1913 * 1914 * @callback Highcharts.ObjectEachCallbackFunction<T> 1915 * 1916 * @param {T} this 1917 * The context. 1918 * 1919 * @param {*} value 1920 * The property value. 1921 * 1922 * @param {string} key 1923 * The property key. 1924 * 1925 * @param {*} obj 1926 * The object that objectEach is being applied to. 1927 */ 1928/** 1929 * An object containing `left` and `top` properties for the position in the 1930 * page. 1931 * 1932 * @interface Highcharts.OffsetObject 1933 */ /** 1934* Left distance to the page border.
1935* @name Highcharts.OffsetObject#left 1936* @type {number} 1937*/ /** 1938* Top distance to the page border. 1939* @name Highcharts.OffsetObject#top 1940* @type {number} 1941*/ 1942/** 1943 * Describes a range. 1944 * 1945 * @interface Highcharts.RangeObject 1946 */ /** 1947* Maximum number of the range. 1948* @name Highcharts.RangeObject#max 1949* @type {number} 1950*/ /** 1951* Minimum number of the range. 1952* @name Highcharts.RangeObject#min 1953* @type {number} 1954*/ 1955/** 1956 * If a number is given, it defines the pixel length. If a percentage string is 1957 * given, like for example `'50%'`, the setting defines a length relative to a 1958 * base size, for example the size of a container. 1959 * 1960 * @typedef {number|string} Highcharts.RelativeSize 1961 */ 1962/** 1963 * Proceed function to call original (wrapped) function. 1964 * 1965 * @callback Highcharts.WrapProceedFunction 1966 * 1967 * @param {*} [arg1] 1968 * Optional argument. Without any arguments defaults to first argument of 1969 * the wrapping function. 1970 * 1971 * @param {*} [arg2] 1972 * Optional argument. Without any arguments defaults to second argument 1973 * of the wrapping function. 1974 * 1975 * @param {*} [arg3] 1976 * Optional argument. Without any arguments defaults to third argument of 1977 * the wrapping function. 1978 * 1979 * @return {*} 1980 * Return value of the original function. 1981 */ 1982/** 1983 * The Highcharts object is the placeholder for all other members, and various 1984 * utility functions. The most important member of the namespace would be the 1985 * chart constructor. 1986 * 1987 * @example 1988 * let chart = Highcharts.chart('container', { ... }); 1989 * 1990 * @namespace Highcharts 1991 */ 1992''; // Detach doclets above
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.