Globals.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* *
  2. *
  3. * (c) 2010-2020 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';
  11. /* globals Image, window */
  12. /**
  13. * Reference to the global SVGElement class as a workaround for a name conflict
  14. * in the Highcharts namespace.
  15. *
  16. * @global
  17. * @typedef {global.SVGElement} GlobalSVGElement
  18. *
  19. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  20. */
  21. // glob is a temporary fix to allow our es-modules to work.
  22. var glob = ( // @todo UMD variable named `window`, and glob named `win`
  23. typeof win !== 'undefined' ?
  24. win :
  25. typeof window !== 'undefined' ?
  26. window :
  27. {}), doc = glob.document, SVG_NS = 'http://www.w3.org/2000/svg', userAgent = (glob.navigator && glob.navigator.userAgent) || '', svg = (doc &&
  28. doc.createElementNS &&
  29. !!doc.createElementNS(SVG_NS, 'svg').createSVGRect), isMS = /(edge|msie|trident)/i.test(userAgent) && !glob.opera, isFirefox = userAgent.indexOf('Firefox') !== -1, isChrome = userAgent.indexOf('Chrome') !== -1, hasBidiBug = (isFirefox &&
  30. parseInt(userAgent.split('Firefox/')[1], 10) < 4 // issue #38
  31. );
  32. var H = {
  33. product: 'Highcharts',
  34. version: '8.2.0',
  35. deg2rad: Math.PI * 2 / 360,
  36. doc: doc,
  37. hasBidiBug: hasBidiBug,
  38. hasTouch: !!glob.TouchEvent,
  39. isMS: isMS,
  40. isWebKit: userAgent.indexOf('AppleWebKit') !== -1,
  41. isFirefox: isFirefox,
  42. isChrome: isChrome,
  43. isSafari: !isChrome && userAgent.indexOf('Safari') !== -1,
  44. isTouchDevice: /(Mobile|Android|Windows Phone)/.test(userAgent),
  45. SVG_NS: SVG_NS,
  46. chartCount: 0,
  47. seriesTypes: {},
  48. symbolSizes: {},
  49. svg: svg,
  50. win: glob,
  51. marginNames: ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
  52. noop: function () { },
  53. /**
  54. * Theme options that should get applied to the chart. In module mode it
  55. * might not be possible to change this property because of read-only
  56. * restrictions, instead use {@link Highcharts.setOptions}.
  57. *
  58. * @name Highcharts.theme
  59. * @type {Highcharts.Options}
  60. */
  61. /**
  62. * An array containing the current chart objects in the page. A chart's
  63. * position in the array is preserved throughout the page's lifetime. When
  64. * a chart is destroyed, the array item becomes `undefined`.
  65. *
  66. * @name Highcharts.charts
  67. * @type {Array<Highcharts.Chart|undefined>}
  68. */
  69. charts: [],
  70. /**
  71. * A hook for defining additional date format specifiers. New
  72. * specifiers are defined as key-value pairs by using the
  73. * specifier as key, and a function which takes the timestamp as
  74. * value. This function returns the formatted portion of the
  75. * date.
  76. *
  77. * @sample highcharts/global/dateformats/
  78. * Adding support for week number
  79. *
  80. * @name Highcharts.dateFormats
  81. * @type {Highcharts.Dictionary<Highcharts.TimeFormatCallbackFunction>}
  82. */
  83. dateFormats: {}
  84. };
  85. export default H;