@highcharts/grid-pro 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +15 -9
  3. package/css/grid-pro.css +1262 -1122
  4. package/css/modules/grid-base-variables.css +131 -0
  5. package/css/modules/grid-button-variables.css +140 -0
  6. package/css/modules/grid-caption-variables.css +11 -0
  7. package/css/modules/grid-description-variables.css +11 -0
  8. package/css/modules/grid-input-variables.css +114 -0
  9. package/css/modules/grid-link-variables.css +18 -0
  10. package/css/modules/grid-menu-variables.css +50 -0
  11. package/css/modules/grid-pagination-variables.css +12 -0
  12. package/css/modules/grid-popup-variables.css +24 -0
  13. package/css/modules/grid-pro.css +234 -0
  14. package/css/modules/grid-table-variables.css +385 -0
  15. package/css/modules/grid-theme-default.css +55 -0
  16. package/es-modules/Accessibility/A11yI18n.js +1 -2
  17. package/es-modules/Accessibility/Accessibility.js +1 -2
  18. package/es-modules/Accessibility/AccessibilityComponent.d.ts +2 -2
  19. package/es-modules/Accessibility/Components/InfoRegionsComponent.js +5 -6
  20. package/es-modules/Accessibility/Components/LegendComponent.js +1 -2
  21. package/es-modules/Accessibility/Components/MenuComponent.js +1 -2
  22. package/es-modules/Accessibility/Components/NavigatorComponent.js +3 -4
  23. package/es-modules/Accessibility/Components/RangeSelectorComponent.js +1 -2
  24. package/es-modules/Accessibility/Components/SeriesComponent/ForcedMarkers.js +1 -2
  25. package/es-modules/Accessibility/Components/SeriesComponent/NewDataAnnouncer.js +3 -4
  26. package/es-modules/Accessibility/Components/SeriesComponent/SeriesDescriber.js +3 -4
  27. package/es-modules/Accessibility/Components/SeriesComponent/SeriesKeyboardNavigation.js +1 -2
  28. package/es-modules/Accessibility/Components/ZoomComponent.js +1 -2
  29. package/es-modules/Accessibility/FocusBorder.js +1 -2
  30. package/es-modules/Accessibility/KeyboardNavigation.js +1 -2
  31. package/es-modules/Accessibility/KeyboardNavigationHandler.js +1 -2
  32. package/es-modules/Accessibility/Options/A11yDefaults.d.ts +11 -0
  33. package/es-modules/Accessibility/Options/A11yDefaults.js +11 -0
  34. package/es-modules/Accessibility/Options/DeprecatedOptions.d.ts +58 -0
  35. package/es-modules/Accessibility/Options/DeprecatedOptions.js +7 -2
  36. package/es-modules/Accessibility/Options/LangDefaults.js +9 -0
  37. package/es-modules/Accessibility/ProxyElement.js +2 -5
  38. package/es-modules/Accessibility/ProxyProvider.js +1 -2
  39. package/es-modules/Accessibility/Utils/Announcer.js +2 -3
  40. package/es-modules/Accessibility/Utils/ChartUtilities.js +1 -2
  41. package/es-modules/Accessibility/Utils/EventProvider.d.ts +2 -2
  42. package/es-modules/Accessibility/Utils/EventProvider.js +6 -2
  43. package/es-modules/Accessibility/Utils/HTMLUtilities.js +1 -2
  44. package/es-modules/Core/Animation/AnimationUtilities.js +1 -2
  45. package/es-modules/Core/Animation/Fx.js +1 -2
  46. package/es-modules/Core/Callback.d.ts +9 -2
  47. package/es-modules/Core/Chart/Chart.js +48 -41
  48. package/es-modules/Core/Chart/Chart3D.js +1 -2
  49. package/es-modules/Core/Chart/ChartDefaults.js +11 -0
  50. package/es-modules/Core/Chart/ChartOptions.d.ts +8 -0
  51. package/es-modules/Core/Chart/GanttChart.js +1 -2
  52. package/es-modules/Core/Chart/MapChart.js +1 -2
  53. package/es-modules/Core/Chart/StockChart.js +2 -3
  54. package/es-modules/Core/Color/Color.js +1 -2
  55. package/es-modules/Core/Defaults.js +36 -9
  56. package/es-modules/Core/Delaunay.d.ts +52 -0
  57. package/es-modules/Core/Delaunay.js +310 -0
  58. package/es-modules/Core/Foundation.js +1 -2
  59. package/es-modules/Core/Geometry/CircleUtilities.js +1 -2
  60. package/es-modules/Core/Globals.js +1 -1
  61. package/es-modules/Core/HttpUtilities.js +1 -2
  62. package/es-modules/Core/MSPointer.js +1 -2
  63. package/es-modules/Core/Math3D.js +1 -2
  64. package/es-modules/Core/Options.d.ts +6 -2
  65. package/es-modules/Core/Pointer.js +23 -4
  66. package/es-modules/Core/PointerEvent.d.ts +2 -0
  67. package/es-modules/Core/Renderer/HTML/AST.js +2 -2
  68. package/es-modules/Core/Renderer/HTML/HTMLElement.js +1 -2
  69. package/es-modules/Core/Renderer/RendererUtilities.js +34 -19
  70. package/es-modules/Core/Responsive.d.ts +4 -2
  71. package/es-modules/Core/Responsive.js +10 -4
  72. package/es-modules/Core/Templating.d.ts +1 -1
  73. package/es-modules/Core/Templating.js +3 -4
  74. package/es-modules/Core/Time.d.ts +8 -0
  75. package/es-modules/Core/Time.js +2 -2
  76. package/es-modules/Core/Tooltip.d.ts +4 -8
  77. package/es-modules/Core/Tooltip.js +100 -81
  78. package/es-modules/Core/TooltipOptions.d.ts +44 -1
  79. package/es-modules/Core/Utilities.d.ts +25 -665
  80. package/es-modules/Core/Utilities.js +17 -1398
  81. package/es-modules/Data/ColumnUtils.d.ts +83 -80
  82. package/es-modules/Data/ColumnUtils.js +103 -113
  83. package/es-modules/Data/Connectors/CSVConnector.d.ts +9 -14
  84. package/es-modules/Data/Connectors/CSVConnector.js +3 -4
  85. package/es-modules/Data/Connectors/DataConnector.d.ts +52 -54
  86. package/es-modules/Data/Connectors/DataConnector.js +33 -52
  87. package/es-modules/Data/Connectors/GoogleSheetsConnector.d.ts +40 -42
  88. package/es-modules/Data/Connectors/GoogleSheetsConnector.js +73 -88
  89. package/es-modules/Data/Connectors/GoogleSheetsConnectorOptions.d.ts +4 -2
  90. package/es-modules/Data/Connectors/HTMLTableConnector.d.ts +23 -28
  91. package/es-modules/Data/Connectors/HTMLTableConnector.js +3 -4
  92. package/es-modules/Data/Connectors/JSONConnector.d.ts +9 -14
  93. package/es-modules/Data/Connectors/JSONConnector.js +3 -4
  94. package/es-modules/Data/Converters/CSVConverter.d.ts +5 -5
  95. package/es-modules/Data/Converters/CSVConverter.js +3 -4
  96. package/es-modules/Data/Converters/CSVConverterOptions.d.ts +2 -2
  97. package/es-modules/Data/Converters/DataConverter.d.ts +76 -78
  98. package/es-modules/Data/Converters/DataConverter.js +26 -53
  99. package/es-modules/Data/Converters/DataConverterUtils.d.ts +88 -81
  100. package/es-modules/Data/Converters/DataConverterUtils.js +169 -181
  101. package/es-modules/Data/Converters/GoogleSheetsConverter.d.ts +4 -4
  102. package/es-modules/Data/Converters/GoogleSheetsConverter.js +3 -3
  103. package/es-modules/Data/Converters/GoogleSheetsConverterOptions.d.ts +2 -2
  104. package/es-modules/Data/Converters/HTMLTableConverter.d.ts +4 -4
  105. package/es-modules/Data/Converters/HTMLTableConverter.js +2 -3
  106. package/es-modules/Data/Converters/HTMLTableConverterOptions.d.ts +2 -2
  107. package/es-modules/Data/Converters/JSONConverter.d.ts +7 -7
  108. package/es-modules/Data/Converters/JSONConverter.js +6 -6
  109. package/es-modules/Data/Converters/JSONConverterOptions.d.ts +2 -2
  110. package/es-modules/Data/DataCursor.d.ts +65 -70
  111. package/es-modules/Data/DataCursor.js +119 -139
  112. package/es-modules/Data/DataEvent.d.ts +55 -57
  113. package/es-modules/Data/DataPool.d.ts +10 -17
  114. package/es-modules/Data/DataPool.js +20 -9
  115. package/es-modules/Data/DataTable.d.ts +111 -113
  116. package/es-modules/Data/DataTable.js +3 -3
  117. package/es-modules/Data/DataTableCore.d.ts +9 -9
  118. package/es-modules/Data/DataTableCore.js +2 -2
  119. package/es-modules/Data/Formula/FormulaParser.js +1 -2
  120. package/es-modules/Data/Formula/FormulaProcessor.js +1 -2
  121. package/es-modules/Data/Modifiers/ChainModifier.d.ts +29 -34
  122. package/es-modules/Data/Modifiers/ChainModifier.js +7 -8
  123. package/es-modules/Data/Modifiers/DataModifier.d.ts +36 -41
  124. package/es-modules/Data/Modifiers/DataModifier.js +31 -53
  125. package/es-modules/Data/Modifiers/FilterModifier.d.ts +4 -4
  126. package/es-modules/Data/Modifiers/FilterModifier.js +3 -4
  127. package/es-modules/Data/Modifiers/FilterModifierOptions.d.ts +3 -2
  128. package/es-modules/Data/Modifiers/InvertModifier.d.ts +4 -4
  129. package/es-modules/Data/Modifiers/InvertModifier.js +3 -4
  130. package/es-modules/Data/Modifiers/MathModifier.d.ts +5 -4
  131. package/es-modules/Data/Modifiers/RangeModifier.d.ts +4 -4
  132. package/es-modules/Data/Modifiers/RangeModifier.js +3 -4
  133. package/es-modules/Data/Modifiers/SortModifier.d.ts +6 -11
  134. package/es-modules/Data/Modifiers/SortModifier.js +3 -4
  135. package/es-modules/Data/Modifiers/SortModifierOptions.d.ts +3 -3
  136. package/es-modules/Grid/Core/Accessibility/Accessibility.d.ts +1 -1
  137. package/es-modules/Grid/Core/Accessibility/Accessibility.js +5 -6
  138. package/es-modules/Grid/Core/Data/DataProvider.d.ts +97 -0
  139. package/es-modules/Grid/Core/Data/DataProvider.js +89 -0
  140. package/es-modules/Grid/Core/Data/DataProviderRegistry.d.ts +20 -0
  141. package/es-modules/Grid/Core/Data/DataProviderRegistry.js +52 -0
  142. package/es-modules/Grid/Core/Data/DataProviderType.d.ts +19 -0
  143. package/es-modules/Grid/Core/Data/DataProviderType.js +15 -0
  144. package/es-modules/Grid/Core/Data/LocalDataProvider.d.ts +165 -0
  145. package/es-modules/Grid/Core/Data/LocalDataProvider.js +341 -0
  146. package/es-modules/Grid/Core/Defaults.js +4 -2
  147. package/es-modules/Grid/Core/Globals.d.ts +20 -16
  148. package/es-modules/Grid/Core/Globals.js +10 -8
  149. package/es-modules/Grid/Core/Grid.d.ts +31 -22
  150. package/es-modules/Grid/Core/Grid.js +214 -136
  151. package/es-modules/Grid/Core/GridUtils.d.ts +33 -0
  152. package/es-modules/Grid/Core/GridUtils.js +50 -3
  153. package/es-modules/Grid/Core/Options.d.ts +145 -4
  154. package/es-modules/Grid/Core/Pagination/Pagination.d.ts +3 -0
  155. package/es-modules/Grid/Core/Pagination/Pagination.js +63 -23
  156. package/es-modules/Grid/Core/Pagination/PaginationOptions.d.ts +4 -0
  157. package/es-modules/Grid/Core/Querying/FilteringController.js +1 -2
  158. package/es-modules/Grid/Core/Querying/PaginationController.d.ts +2 -2
  159. package/es-modules/Grid/Core/Querying/PaginationController.js +3 -3
  160. package/es-modules/Grid/Core/Querying/QueryingController.d.ts +1 -1
  161. package/es-modules/Grid/Core/Querying/QueryingController.js +2 -26
  162. package/es-modules/Grid/Core/Responsive/ResponsiveComposition.d.ts +53 -0
  163. package/es-modules/Grid/Core/Responsive/ResponsiveComposition.js +229 -0
  164. package/es-modules/Grid/Core/Responsive/ResponsiveOptions.d.ts +58 -0
  165. package/es-modules/Grid/Core/Responsive/ResponsiveOptions.js +15 -0
  166. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/ColumnFiltering.js +2 -3
  167. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterCell.d.ts +1 -1
  168. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterCell.js +3 -4
  169. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterRow.d.ts +1 -1
  170. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterRow.js +2 -2
  171. package/es-modules/Grid/Core/Table/Actions/ColumnSorting.d.ts +17 -1
  172. package/es-modules/Grid/Core/Table/Actions/ColumnSorting.js +58 -15
  173. package/es-modules/Grid/Core/Table/Actions/ColumnsResizer.js +1 -3
  174. package/es-modules/Grid/Core/Table/Actions/RowsVirtualizer.d.ts +57 -3
  175. package/es-modules/Grid/Core/Table/Actions/RowsVirtualizer.js +397 -118
  176. package/es-modules/Grid/Core/Table/Body/CellContextMenu.d.ts +11 -0
  177. package/es-modules/Grid/Core/Table/Body/CellContextMenu.js +84 -0
  178. package/es-modules/Grid/Core/Table/Body/TableCell.d.ts +27 -13
  179. package/es-modules/Grid/Core/Table/Body/TableCell.js +74 -25
  180. package/es-modules/Grid/Core/Table/Body/TableRow.d.ts +7 -15
  181. package/es-modules/Grid/Core/Table/Body/TableRow.js +24 -19
  182. package/es-modules/Grid/Core/Table/Cell.d.ts +16 -3
  183. package/es-modules/Grid/Core/Table/Cell.js +36 -3
  184. package/es-modules/Grid/Core/Table/CellContent/TextContent.js +3 -8
  185. package/es-modules/Grid/Core/Table/Column.d.ts +10 -4
  186. package/es-modules/Grid/Core/Table/Column.js +23 -34
  187. package/es-modules/Grid/Core/Table/ColumnResizing/IndependentResizingMode.js +9 -8
  188. package/es-modules/Grid/Core/Table/ColumnResizing/ResizingMode.js +4 -3
  189. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ColumnToolbar.d.ts +5 -0
  190. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ColumnToolbar.js +7 -2
  191. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/FilterPopup.js +1 -2
  192. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/MenuButtons/FilterMenuButton.js +1 -2
  193. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/MenuButtons/SortMenuButton.js +2 -3
  194. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/FilterToolbarButton.js +1 -2
  195. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/MenuToolbarButton.js +1 -2
  196. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/SortToolbarButton.d.ts +0 -1
  197. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/SortToolbarButton.js +4 -14
  198. package/es-modules/Grid/Core/Table/Header/HeaderCell.d.ts +6 -1
  199. package/es-modules/Grid/Core/Table/Header/HeaderCell.js +33 -13
  200. package/es-modules/Grid/Core/Table/Header/HeaderRow.js +4 -5
  201. package/es-modules/Grid/Core/Table/Header/TableHeader.d.ts +1 -1
  202. package/es-modules/Grid/Core/Table/Header/TableHeader.js +3 -3
  203. package/es-modules/Grid/Core/Table/Row.d.ts +1 -1
  204. package/es-modules/Grid/Core/Table/Row.js +2 -2
  205. package/es-modules/Grid/Core/Table/Table.d.ts +38 -12
  206. package/es-modules/Grid/Core/Table/Table.js +184 -91
  207. package/es-modules/Grid/Core/UI/ContextMenuButton.d.ts +6 -7
  208. package/es-modules/Grid/Core/UI/ContextMenuButton.js +5 -3
  209. package/es-modules/Grid/Core/UI/Popup.js +7 -9
  210. package/es-modules/Grid/Core/UI/SvgIcons.d.ts +42 -7
  211. package/es-modules/Grid/Core/UI/SvgIcons.js +206 -33
  212. package/es-modules/Grid/Core/UI/Toolbar.d.ts +5 -0
  213. package/es-modules/Grid/Core/UI/ToolbarButton.d.ts +4 -12
  214. package/es-modules/Grid/Core/UI/ToolbarButton.js +8 -26
  215. package/es-modules/Grid/Pro/CellEditing/CellEditMode.d.ts +2 -2
  216. package/es-modules/Grid/Pro/CellEditing/CellEditing.js +10 -10
  217. package/es-modules/Grid/Pro/CellEditing/CellEditingComposition.js +1 -2
  218. package/es-modules/Grid/Pro/CellRendering/CellRenderersComposition.d.ts +1 -1
  219. package/es-modules/Grid/Pro/CellRendering/CellRenderersComposition.js +4 -2
  220. package/es-modules/Grid/Pro/CellRendering/ContentTypes/CheckboxContent.d.ts +2 -2
  221. package/es-modules/Grid/Pro/CellRendering/ContentTypes/NumberInputContent.js +1 -2
  222. package/es-modules/Grid/Pro/CellRendering/ContentTypes/SelectContent.d.ts +2 -2
  223. package/es-modules/Grid/Pro/CellRendering/ContentTypes/SparklineContent.js +1 -2
  224. package/es-modules/Grid/Pro/CellRendering/ContentTypes/TextInputContent.d.ts +2 -2
  225. package/es-modules/Grid/Pro/CellRendering/ContentTypes/TextInputContent.js +1 -2
  226. package/es-modules/Grid/Pro/CellRendering/Renderers/CheckboxRenderer.js +1 -2
  227. package/es-modules/Grid/Pro/CellRendering/Renderers/DateInputRenderer.js +1 -2
  228. package/es-modules/Grid/Pro/CellRendering/Renderers/DateTimeInputRenderer.js +1 -2
  229. package/es-modules/Grid/Pro/CellRendering/Renderers/NumberInputRenderer.js +1 -2
  230. package/es-modules/Grid/Pro/CellRendering/Renderers/SelectRenderer.js +1 -2
  231. package/es-modules/Grid/Pro/CellRendering/Renderers/SparklineRenderer.d.ts +2 -2
  232. package/es-modules/Grid/Pro/CellRendering/Renderers/SparklineRenderer.js +1 -2
  233. package/es-modules/Grid/Pro/CellRendering/Renderers/TextInputRenderer.js +1 -2
  234. package/es-modules/Grid/Pro/CellRendering/Renderers/TextRenderer.js +1 -2
  235. package/es-modules/Grid/Pro/CellRendering/Renderers/TimeInputRenderer.js +1 -2
  236. package/es-modules/Grid/Pro/ColumnTypes/Validator.js +34 -32
  237. package/es-modules/Grid/Pro/ColumnTypes/ValidatorComposition.d.ts +1 -1
  238. package/es-modules/Grid/Pro/ColumnTypes/ValidatorComposition.js +3 -4
  239. package/es-modules/Grid/Pro/Credits/CreditsProComposition.js +1 -3
  240. package/es-modules/Grid/Pro/Data/DataSourceHelper.d.ts +74 -0
  241. package/es-modules/Grid/Pro/Data/DataSourceHelper.js +246 -0
  242. package/es-modules/Grid/Pro/Data/QuerySerializer.d.ts +46 -0
  243. package/es-modules/Grid/Pro/Data/QuerySerializer.js +169 -0
  244. package/es-modules/Grid/Pro/Data/RemoteDataProvider.d.ts +187 -0
  245. package/es-modules/Grid/Pro/Data/RemoteDataProvider.js +500 -0
  246. package/es-modules/Grid/Pro/Export/Exporting.js +1 -2
  247. package/es-modules/Grid/Pro/Export/ExportingComposition.js +1 -2
  248. package/es-modules/Grid/Pro/GridEvents.js +1 -2
  249. package/es-modules/Grid/Pro/Pagination/PaginationComposition.d.ts +0 -1
  250. package/es-modules/Grid/Pro/Pagination/PaginationComposition.js +1 -2
  251. package/es-modules/Shared/BaseForm.js +1 -2
  252. package/es-modules/Shared/DownloadURL.js +1 -2
  253. package/es-modules/Shared/TimeBase.js +3 -3
  254. package/es-modules/Shared/Types.d.ts +7 -0
  255. package/es-modules/Shared/Utilities.d.ts +576 -0
  256. package/es-modules/Shared/Utilities.js +1368 -0
  257. package/es-modules/masters/grid-pro.src.d.ts +15 -11
  258. package/es-modules/masters/grid-pro.src.js +12 -5
  259. package/grid-pro.d.ts +15 -11
  260. package/grid-pro.js +3 -3
  261. package/grid-pro.js.map +1 -1
  262. package/grid-pro.src.d.ts +15 -11
  263. package/grid-pro.src.js +10408 -8009
  264. package/package.json +1 -1
  265. package/es-modules/Grid/Core/Pagination/Icons.d.ts +0 -7
  266. package/es-modules/Grid/Core/Pagination/Icons.js +0 -7
@@ -9,8 +9,9 @@
9
9
  *
10
10
  * */
11
11
  'use strict';
12
+ import { attr, fireEvent, isNumber, isString, objectEach, pick } from '../Shared/Utilities.js';
12
13
  import H from './Globals.js';
13
- const { charts, doc, win } = H;
14
+ const { charts, win } = H;
14
15
  /* *
15
16
  *
16
17
  * Functions
@@ -46,7 +47,7 @@ const { charts, doc, win } = H;
46
47
  *
47
48
  * @return {void}
48
49
  */
49
- function error(code, stop, chart, params) {
50
+ export function error(code, stop, chart, params) {
50
51
  const severity = stop ? 'Highcharts error' : 'Highcharts warning';
51
52
  if (code === 32) {
52
53
  code = `${severity}: Deprecated member`;
@@ -85,291 +86,6 @@ function error(code, stop, chart, params) {
85
86
  (function (error) {
86
87
  error.messages = [];
87
88
  })(error || (error = {}));
88
- /**
89
- * Utility function to deep merge two or more objects and return a third object.
90
- * If the first argument is true, the contents of the second object is copied
91
- * into the first object. The merge function can also be used with a single
92
- * object argument to create a deep copy of an object.
93
- *
94
- * @function Highcharts.merge<T>
95
- *
96
- * @param {true | T} extendOrSource
97
- * Whether to extend the left-side object,
98
- * or the first object to merge as a deep copy.
99
- *
100
- * @param {...Array<object|undefined>} [sources]
101
- * Object(s) to merge into the previous one.
102
- *
103
- * @return {T}
104
- * The merged object. If the first argument is true, the return is the
105
- * same as the second argument.
106
- */
107
- function merge(extendOrSource, ...sources) {
108
- let i, args = [extendOrSource, ...sources], ret = {};
109
- const doCopy = function (copy, original) {
110
- // An object is replacing a primitive
111
- if (typeof copy !== 'object') {
112
- copy = {};
113
- }
114
- objectEach(original, function (value, key) {
115
- // Prototype pollution (#14883)
116
- if (key === '__proto__' || key === 'constructor') {
117
- return;
118
- }
119
- // Copy the contents of objects, but not arrays or DOM nodes
120
- if (isObject(value, true) &&
121
- !isClass(value) &&
122
- !isDOMElement(value)) {
123
- copy[key] = doCopy(copy[key] || {}, value);
124
- // Primitives and arrays are copied over directly
125
- }
126
- else {
127
- copy[key] = original[key];
128
- }
129
- });
130
- return copy;
131
- };
132
- // If first argument is true, copy into the existing object. Used in
133
- // setOptions.
134
- if (extendOrSource === true) {
135
- ret = args[1];
136
- args = Array.prototype.slice.call(args, 2);
137
- }
138
- // For each argument, extend the return
139
- const len = args.length;
140
- for (i = 0; i < len; i++) {
141
- ret = doCopy(ret, args[i]);
142
- }
143
- return ret;
144
- }
145
- /**
146
- * Constrain a value to within a lower and upper threshold.
147
- *
148
- * @internal
149
- * @param {number} value The initial value
150
- * @param {number} min The lower threshold
151
- * @param {number} max The upper threshold
152
- * @return {number} Returns a number value within min and max.
153
- */
154
- function clamp(value, min, max) {
155
- return value > min ? value < max ? value : max : min;
156
- }
157
- /**
158
- * Utility for crisping a line position to the nearest full pixel depening on
159
- * the line width
160
- * @param {number} value The raw pixel position
161
- * @param {number} lineWidth The line width
162
- * @param {boolean} [inverted] Whether the containing group is inverted.
163
- * Crisping round numbers on the y-scale need to go
164
- * to the other side because the coordinate system
165
- * is flipped (scaleY is -1)
166
- * @return {number} The pixel position to use for a crisp display
167
- */
168
- function crisp(value, lineWidth = 0, inverted) {
169
- const mod = lineWidth % 2 / 2, inverter = inverted ? -1 : 1;
170
- return (Math.round(value * inverter - mod) + mod) * inverter;
171
- }
172
- // eslint-disable-next-line valid-jsdoc
173
- /**
174
- * Return the deep difference between two objects. It can either return the new
175
- * properties, or optionally return the old values of new properties.
176
- * @internal
177
- */
178
- function diffObjects(newer, older, keepOlder, collectionsWithUpdate) {
179
- const ret = {};
180
- /**
181
- * Recurse over a set of options and its current values, and store the
182
- * current values in the ret object.
183
- */
184
- function diff(newer, older, ret, depth) {
185
- const keeper = keepOlder ? older : newer;
186
- objectEach(newer, function (newerVal, key) {
187
- if (!depth &&
188
- collectionsWithUpdate &&
189
- collectionsWithUpdate.indexOf(key) > -1 &&
190
- older[key]) {
191
- newerVal = splat(newerVal);
192
- ret[key] = [];
193
- // Iterate over collections like series, xAxis or yAxis and map
194
- // the items by index.
195
- for (let i = 0; i < Math.max(newerVal.length, older[key].length); i++) {
196
- // Item exists in current data (#6347)
197
- if (older[key][i]) {
198
- // If the item is missing from the new data, we need to
199
- // save the whole config structure. Like when
200
- // responsively updating from a dual axis layout to a
201
- // single axis and back (#13544).
202
- if (newerVal[i] === void 0) {
203
- ret[key][i] = older[key][i];
204
- // Otherwise, proceed
205
- }
206
- else {
207
- ret[key][i] = {};
208
- diff(newerVal[i], older[key][i], ret[key][i], depth + 1);
209
- }
210
- }
211
- }
212
- }
213
- else if (isObject(newerVal, true) &&
214
- !newerVal.nodeType // #10044
215
- ) {
216
- ret[key] = isArray(newerVal) ? [] : {};
217
- diff(newerVal, older[key] || {}, ret[key], depth + 1);
218
- // Delete empty nested objects
219
- if (Object.keys(ret[key]).length === 0 &&
220
- // Except colorAxis which is a special case where the empty
221
- // object means it is enabled. Which is unfortunate and we
222
- // should try to find a better way.
223
- !(key === 'colorAxis' && depth === 0)) {
224
- delete ret[key];
225
- }
226
- }
227
- else if (newer[key] !== older[key] ||
228
- // If the newer key is explicitly undefined, keep it (#10525)
229
- (key in newer && !(key in older))) {
230
- if (key !== '__proto__' && key !== 'constructor') {
231
- ret[key] = keeper[key];
232
- }
233
- }
234
- });
235
- }
236
- diff(newer, older, ret, 0);
237
- return ret;
238
- }
239
- /**
240
- * Shortcut for parseInt
241
- *
242
- * @internal
243
- * @function Highcharts.pInt
244
- *
245
- * @param {*} s
246
- * any
247
- *
248
- * @param {number} [mag]
249
- * Magnitude
250
- *
251
- * @return {number}
252
- * number
253
- */
254
- function pInt(s, mag) {
255
- return parseInt(s, mag || 10);
256
- }
257
- /**
258
- * Utility function to check for string type.
259
- *
260
- * @function Highcharts.isString
261
- *
262
- * @param {*} s
263
- * The item to check.
264
- *
265
- * @return {boolean}
266
- * True if the argument is a string.
267
- */
268
- function isString(s) {
269
- return typeof s === 'string';
270
- }
271
- /**
272
- * Utility function to check if an item is an array.
273
- *
274
- * @function Highcharts.isArray
275
- *
276
- * @param {*} obj
277
- * The item to check.
278
- *
279
- * @return {boolean}
280
- * True if the argument is an array.
281
- */
282
- function isArray(obj) {
283
- const str = Object.prototype.toString.call(obj);
284
- return str === '[object Array]' || str === '[object Array Iterator]';
285
- }
286
- /**
287
- * Utility function to check if an item is of type object.
288
- *
289
- * @function Highcharts.isObject
290
- *
291
- * @param {*} obj
292
- * The item to check.
293
- *
294
- * @param {boolean} [strict=false]
295
- * Also checks that the object is not an array.
296
- *
297
- * @return {boolean}
298
- * True if the argument is an object.
299
- */
300
- function isObject(obj, strict) {
301
- return (!!obj &&
302
- typeof obj === 'object' &&
303
- (!strict || !isArray(obj))); // eslint-disable-line @typescript-eslint/no-explicit-any
304
- }
305
- /**
306
- * Utility function to check if an Object is a HTML Element.
307
- *
308
- * @function Highcharts.isDOMElement
309
- *
310
- * @param {*} obj
311
- * The item to check.
312
- *
313
- * @return {boolean}
314
- * True if the argument is a HTML Element.
315
- */
316
- function isDOMElement(obj) {
317
- return isObject(obj) && typeof obj.nodeType === 'number';
318
- }
319
- /**
320
- * Utility function to check if an Object is a class.
321
- *
322
- * @function Highcharts.isClass
323
- *
324
- * @param {object|undefined} obj
325
- * The item to check.
326
- *
327
- * @return {boolean}
328
- * True if the argument is a class.
329
- */
330
- function isClass(obj) {
331
- const c = obj?.constructor;
332
- return !!(isObject(obj, true) &&
333
- !isDOMElement(obj) &&
334
- (c?.name && c.name !== 'Object'));
335
- }
336
- /**
337
- * Utility function to check if an item is a number and it is finite (not NaN,
338
- * Infinity or -Infinity).
339
- *
340
- * @function Highcharts.isNumber
341
- *
342
- * @param {*} n
343
- * The item to check.
344
- *
345
- * @return {boolean}
346
- * True if the item is a finite number
347
- */
348
- function isNumber(n) {
349
- return typeof n === 'number' && !isNaN(n) && n < Infinity && n > -Infinity;
350
- }
351
- /**
352
- * Remove the last occurence of an item from an array.
353
- *
354
- * @function Highcharts.erase
355
- *
356
- * @param {Array<*>} arr
357
- * The array.
358
- *
359
- * @param {*} item
360
- * The item to remove.
361
- *
362
- * @return {void}
363
- */
364
- function erase(arr, item) {
365
- let i = arr.length;
366
- while (i--) {
367
- if (arr[i] === item) {
368
- arr.splice(i, 1);
369
- break;
370
- }
371
- }
372
- }
373
89
  /**
374
90
  * Insert a series or an axis in a collection with other items, either the
375
91
  * chart series or yAxis series or axis collections, in the correct order
@@ -384,7 +100,7 @@ function erase(arr, item) {
384
100
  * A collection of items, like `chart.series` or `xAxis.series`.
385
101
  * @return {number} The index of the series in the collection.
386
102
  */
387
- function insertItem(item, collection) {
103
+ export function insertItem(item, collection) {
388
104
  const indexOption = item.options.index, length = collection.length;
389
105
  let i;
390
106
  for (
@@ -406,595 +122,12 @@ function insertItem(item, collection) {
406
122
  }
407
123
  return i;
408
124
  }
409
- /**
410
- * Adds an item to an array, if it is not present in the array.
411
- *
412
- * @function Highcharts.pushUnique
413
- *
414
- * @param {Array<unknown>} array
415
- * The array to add the item to.
416
- *
417
- * @param {unknown} item
418
- * The item to add.
419
- *
420
- * @return {boolean}
421
- * Returns true, if the item was not present and has been added.
422
- */
423
- function pushUnique(array, item) {
424
- return array.indexOf(item) < 0 && !!array.push(item);
425
- }
426
- /**
427
- * Check if an object is null or undefined.
428
- *
429
- * @function Highcharts.defined
430
- *
431
- * @param {*} obj
432
- * The object to check.
433
- *
434
- * @return {boolean}
435
- * False if the object is null or undefined, otherwise true.
436
- */
437
- function defined(obj) {
438
- return typeof obj !== 'undefined' && obj !== null;
439
- }
440
- /**
441
- * Set or get an attribute or an object of attributes.
442
- *
443
- * To use as a setter, pass a key and a value, or let the second argument be a
444
- * collection of keys and values. When using a collection, passing a value of
445
- * `null` or `undefined` will remove the attribute.
446
- *
447
- * To use as a getter, pass only a string as the second argument.
448
- *
449
- * @function Highcharts.attr
450
- *
451
- * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} elem
452
- * The DOM element to receive the attribute(s).
453
- *
454
- * @param {string|Highcharts.HTMLAttributes|Highcharts.SVGAttributes} [keyOrAttribs]
455
- * The property or an object of key-value pairs.
456
- *
457
- * @param {number|string} [value]
458
- * The value if a single property is set.
459
- *
460
- * @return {string|null|undefined}
461
- * When used as a getter, return the value.
462
- */
463
- function attr(elem, keyOrAttribs, value) {
464
- const isGetter = isString(keyOrAttribs) && !defined(value);
465
- let ret;
466
- const attrSingle = (value, key) => {
467
- // Set the value
468
- if (defined(value)) {
469
- elem.setAttribute(key, value);
470
- // Get the value
471
- }
472
- else if (isGetter) {
473
- ret = elem.getAttribute(key);
474
- // IE7 and below cannot get class through getAttribute (#7850)
475
- if (!ret && key === 'class') {
476
- ret = elem.getAttribute(key + 'Name');
477
- }
478
- // Remove the value
479
- }
480
- else {
481
- elem.removeAttribute(key);
482
- }
483
- };
484
- // If keyOrAttribs is a string
485
- if (isString(keyOrAttribs)) {
486
- attrSingle(value, keyOrAttribs);
487
- // Else if keyOrAttribs is defined, it is a hash of key/value pairs
488
- }
489
- else {
490
- objectEach(keyOrAttribs, attrSingle);
491
- }
492
- return ret;
493
- }
494
- /**
495
- * Check if an element is an array, and if not, make it into an array.
496
- *
497
- * @function Highcharts.splat
498
- *
499
- * @param {*} obj
500
- * The object to splat.
501
- *
502
- * @return {Array}
503
- * The produced or original array.
504
- */
505
- function splat(obj) {
506
- return isArray(obj) ? obj : [obj];
507
- }
508
- /**
509
- * Set a timeout if the delay is given, otherwise perform the function
510
- * synchronously.
511
- *
512
- * @function Highcharts.syncTimeout
513
- *
514
- * @param {Function} fn
515
- * The function callback.
516
- *
517
- * @param {number} delay
518
- * Delay in milliseconds.
519
- *
520
- * @param {*} [context]
521
- * An optional context to send to the function callback.
522
- *
523
- * @return {number}
524
- * An identifier for the timeout that can later be cleared with
525
- * Highcharts.clearTimeout. Returns -1 if there is no timeout.
526
- */
527
- function syncTimeout(fn, delay, context) {
528
- if (delay > 0) {
529
- return setTimeout(fn, delay, context);
530
- }
531
- fn.call(0, context);
532
- return -1;
533
- }
534
- /**
535
- * Internal clear timeout. The function checks that the `id` was not removed
536
- * (e.g. by `chart.destroy()`). For the details see
537
- * [issue #7901](https://github.com/highcharts/highcharts/issues/7901).
538
- *
539
- * @function Highcharts.clearTimeout
540
- *
541
- * @param {number|undefined} id
542
- * Id of a timeout.
543
- */
544
- function internalClearTimeout(id) {
545
- if (defined(id)) {
546
- clearTimeout(id);
547
- }
548
- }
549
- /* eslint-disable valid-jsdoc */
550
- /**
551
- * Utility function to extend an object with the members of another.
552
- *
553
- * @function Highcharts.extend<T>
554
- *
555
- * @param {T|undefined} a
556
- * The object to be extended.
557
- *
558
- * @param {Partial<T>} b
559
- * The object to add to the first one.
560
- *
561
- * @return {T}
562
- * Object a, the original object.
563
- */
564
- function extend(a, b) {
565
- /* eslint-enable valid-jsdoc */
566
- let n;
567
- if (!a) {
568
- a = {};
569
- }
570
- for (n in b) { // eslint-disable-line guard-for-in
571
- a[n] = b[n];
572
- }
573
- return a;
574
- }
575
- /* eslint-disable valid-jsdoc */
576
- /**
577
- * Return the first value that is not null or undefined.
578
- *
579
- * @function Highcharts.pick<T>
580
- *
581
- * @param {...Array<T|null|undefined>} items
582
- * Variable number of arguments to inspect.
583
- *
584
- * @return {T}
585
- * The value of the first argument that is not null or undefined.
586
- */
587
- function pick() {
588
- const args = arguments;
589
- const length = args.length;
590
- for (let i = 0; i < length; i++) {
591
- const arg = args[i];
592
- if (typeof arg !== 'undefined' && arg !== null) {
593
- return arg;
594
- }
595
- }
596
- }
597
- /**
598
- * Set CSS on a given element.
599
- *
600
- * @function Highcharts.css
601
- *
602
- * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
603
- * An HTML DOM element.
604
- *
605
- * @param {Highcharts.CSSObject} styles
606
- * Style object with camel case property names.
607
- *
608
- * @return {void}
609
- */
610
- function css(el, styles) {
611
- extend(el.style, styles);
612
- }
613
- /**
614
- * Utility function to create an HTML element with attributes and styles.
615
- *
616
- * @function Highcharts.createElement
617
- *
618
- * @param {string} tag
619
- * The HTML tag.
620
- *
621
- * @param {Highcharts.HTMLAttributes} [attribs]
622
- * Attributes as an object of key-value pairs.
623
- *
624
- * @param {Highcharts.CSSObject} [styles]
625
- * Styles as an object of key-value pairs.
626
- *
627
- * @param {Highcharts.HTMLDOMElement} [parent]
628
- * The parent HTML object.
629
- *
630
- * @param {boolean} [nopad=false]
631
- * If true, remove all padding, border and margin.
632
- *
633
- * @return {Highcharts.HTMLDOMElement}
634
- * The created DOM element.
635
- */
636
- function createElement(tag, attribs, styles, parent, nopad) {
637
- const el = doc.createElement(tag);
638
- if (attribs) {
639
- extend(el, attribs);
640
- }
641
- if (nopad) {
642
- css(el, { padding: '0', border: 'none', margin: '0' });
643
- }
644
- if (styles) {
645
- css(el, styles);
646
- }
647
- if (parent) {
648
- parent.appendChild(el);
649
- }
650
- return el;
651
- }
652
- // eslint-disable-next-line valid-jsdoc
653
- /**
654
- * Extend a prototyped class by new members.
655
- *
656
- * @deprecated
657
- * @function Highcharts.extendClass<T>
658
- *
659
- * @param {Highcharts.Class<T>} parent
660
- * The parent prototype to inherit.
661
- *
662
- * @param {Highcharts.Dictionary<*>} members
663
- * A collection of prototype members to add or override compared to the
664
- * parent prototype.
665
- *
666
- * @return {Highcharts.Class<T>}
667
- * A new prototype.
668
- */
669
- function extendClass(parent, members) {
670
- const obj = (function () { });
671
- obj.prototype = new parent(); // eslint-disable-line new-cap
672
- extend(obj.prototype, members);
673
- return obj;
674
- }
675
- /**
676
- * Left-pad a string to a given length by adding a character repetitively.
677
- *
678
- * @function Highcharts.pad
679
- *
680
- * @param {number} number
681
- * The input string or number.
682
- *
683
- * @param {number} [length]
684
- * The desired string length.
685
- *
686
- * @param {string} [padder=0]
687
- * The character to pad with.
688
- *
689
- * @return {string}
690
- * The padded string.
691
- */
692
- function pad(number, length, padder) {
693
- return new Array((length || 2) +
694
- 1 -
695
- String(number)
696
- .replace('-', '')
697
- .length).join(padder || '0') + number;
698
- }
699
- /**
700
- * Return a length based on either the integer value, or a percentage of a base.
701
- *
702
- * @function Highcharts.relativeLength
703
- *
704
- * @param {Highcharts.RelativeSize} value
705
- * A percentage string or a number.
706
- *
707
- * @param {number} base
708
- * The full length that represents 100%.
709
- *
710
- * @param {number} [offset=0]
711
- * A pixel offset to apply for percentage values. Used internally in
712
- * axis positioning.
713
- *
714
- * @return {number}
715
- * The computed length.
716
- */
717
- function relativeLength(value, base, offset) {
718
- return (/%$/).test(value) ?
719
- (base * parseFloat(value) / 100) + (offset || 0) :
720
- parseFloat(value);
721
- }
722
- /**
723
- * Replaces text in a string with a given replacement in a loop to catch nested
724
- * matches after previous replacements.
725
- *
726
- * @function Highcharts.replaceNested
727
- *
728
- * @param {string} text
729
- * Text to search and modify.
730
- *
731
- * @param {...Array<(RegExp|string)>} replacements
732
- * One or multiple tuples with search pattern (`[0]: (string|RegExp)`) and
733
- * replacement (`[1]: string`) for matching text.
734
- *
735
- * @return {string}
736
- * Text with replacements.
737
- */
738
- function replaceNested(text, ...replacements) {
739
- let previous, replacement;
740
- do {
741
- previous = text;
742
- for (replacement of replacements) {
743
- text = text.replace(replacement[0], replacement[1]);
744
- }
745
- } while (text !== previous);
746
- return text;
747
- }
748
- /**
749
- * Wrap a method with extended functionality, preserving the original function.
750
- *
751
- * @function Highcharts.wrap
752
- *
753
- * @param {*} obj
754
- * The context object that the method belongs to. In real cases, this is
755
- * often a prototype.
756
- *
757
- * @param {string} method
758
- * The name of the method to extend.
759
- *
760
- * @param {Highcharts.WrapProceedFunction} func
761
- * A wrapper function callback. This function is called with the same
762
- * arguments as the original function, except that the original function
763
- * is unshifted and passed as the first argument.
764
- */
765
- function wrap(obj, method, func) {
766
- const proceed = obj[method];
767
- obj[method] = function () {
768
- const outerArgs = arguments, scope = this;
769
- return func.apply(this, [
770
- function () {
771
- return proceed.apply(scope, arguments.length ? arguments : outerArgs);
772
- }
773
- ].concat([].slice.call(arguments)));
774
- };
775
- }
776
- /**
777
- * Get the magnitude of a number.
778
- *
779
- * @function Highcharts.getMagnitude
780
- *
781
- * @param {number} num
782
- * The number.
783
- *
784
- * @return {number}
785
- * The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2 etc.
786
- */
787
- function getMagnitude(num) {
788
- return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
789
- }
790
- /**
791
- * Take an interval and normalize it to multiples of round numbers.
792
- *
793
- * @deprecated
794
- * @function Highcharts.normalizeTickInterval
795
- *
796
- * @param {number} interval
797
- * The raw, un-rounded interval.
798
- *
799
- * @param {Array<*>} [multiples]
800
- * Allowed multiples.
801
- *
802
- * @param {number} [magnitude]
803
- * The magnitude of the number.
804
- *
805
- * @param {boolean} [allowDecimals]
806
- * Whether to allow decimals.
807
- *
808
- * @param {boolean} [hasTickAmount]
809
- * If it has tickAmount, avoid landing on tick intervals lower than
810
- * original.
811
- *
812
- * @return {number}
813
- * The normalized interval.
814
- *
815
- * @todo
816
- * Move this function to the Axis prototype. It is here only for historical
817
- * reasons.
818
- */
819
- function normalizeTickInterval(interval, multiples, magnitude, allowDecimals, hasTickAmount) {
820
- let i, retInterval = interval;
821
- // Round to a tenfold of 1, 2, 2.5 or 5
822
- magnitude = pick(magnitude, getMagnitude(interval));
823
- const normalized = interval / magnitude;
824
- // Multiples for a linear scale
825
- if (!multiples) {
826
- multiples = hasTickAmount ?
827
- // Finer grained ticks when the tick amount is hard set, including
828
- // when alignTicks is true on multiple axes (#4580).
829
- [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
830
- // Else, let ticks fall on rounder numbers
831
- [1, 2, 2.5, 5, 10];
832
- // The allowDecimals option
833
- if (allowDecimals === false) {
834
- if (magnitude === 1) {
835
- multiples = multiples.filter(function (num) {
836
- return num % 1 === 0;
837
- });
838
- }
839
- else if (magnitude <= 0.1) {
840
- multiples = [1 / magnitude];
841
- }
842
- }
843
- }
844
- // Normalize the interval to the nearest multiple
845
- for (i = 0; i < multiples.length; i++) {
846
- retInterval = multiples[i];
847
- // Only allow tick amounts smaller than natural
848
- if ((hasTickAmount &&
849
- retInterval * magnitude >= interval) ||
850
- (!hasTickAmount &&
851
- (normalized <=
852
- (multiples[i] +
853
- (multiples[i + 1] || multiples[i])) / 2))) {
854
- break;
855
- }
856
- }
857
- // Multiply back to the correct magnitude. Correct floats to appropriate
858
- // precision (#6085).
859
- retInterval = correctFloat(retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10));
860
- return retInterval;
861
- }
862
- /**
863
- * Sort an object array and keep the order of equal items. The ECMAScript
864
- * standard does not specify the behaviour when items are equal.
865
- *
866
- * @function Highcharts.stableSort
867
- *
868
- * @param {Array<*>} arr
869
- * The array to sort.
870
- *
871
- * @param {Function} sortFunction
872
- * The function to sort it with, like with regular Array.prototype.sort.
873
- */
874
- function stableSort(arr, sortFunction) {
875
- // @todo It seems like Chrome since v70 sorts in a stable way internally,
876
- // plus all other browsers do it, so over time we may be able to remove this
877
- // function
878
- const length = arr.length;
879
- let sortValue, i;
880
- // Add index to each item
881
- for (i = 0; i < length; i++) {
882
- arr[i].safeI = i; // Stable sort index
883
- }
884
- arr.sort(function (a, b) {
885
- sortValue = sortFunction(a, b);
886
- return sortValue === 0 ? a.safeI - b.safeI : sortValue;
887
- });
888
- // Remove index from items
889
- for (i = 0; i < length; i++) {
890
- delete arr[i].safeI; // Stable sort index
891
- }
892
- }
893
- /**
894
- * Non-recursive method to find the lowest member of an array. `Math.min` raises
895
- * a maximum call stack size exceeded error in Chrome when trying to apply more
896
- * than 150.000 points. This method is slightly slower, but safe.
897
- *
898
- * @function Highcharts.arrayMin
899
- *
900
- * @param {Array<*>} data
901
- * An array of numbers.
902
- *
903
- * @return {number}
904
- * The lowest number.
905
- */
906
- function arrayMin(data) {
907
- let i = data.length, min = data[0];
908
- while (i--) {
909
- if (data[i] < min) {
910
- min = data[i];
911
- }
912
- }
913
- return min;
914
- }
915
- /**
916
- * Non-recursive method to find the lowest member of an array. `Math.max` raises
917
- * a maximum call stack size exceeded error in Chrome when trying to apply more
918
- * than 150.000 points. This method is slightly slower, but safe.
919
- *
920
- * @function Highcharts.arrayMax
921
- *
922
- * @param {Array<*>} data
923
- * An array of numbers.
924
- *
925
- * @return {number}
926
- * The highest number.
927
- */
928
- function arrayMax(data) {
929
- let i = data.length, max = data[0];
930
- while (i--) {
931
- if (data[i] > max) {
932
- max = data[i];
933
- }
934
- }
935
- return max;
936
- }
937
- /**
938
- * Utility method that destroys any SVGElement instances that are properties on
939
- * the given object. It loops all properties and invokes destroy if there is a
940
- * destroy method. The property is then delete.
941
- *
942
- * @function Highcharts.destroyObjectProperties
943
- *
944
- * @param {*} obj
945
- * The object to destroy properties on.
946
- *
947
- * @param {*} [except]
948
- * Exception, do not destroy this property, only delete it.
949
- */
950
- function destroyObjectProperties(obj, except, destructablesOnly) {
951
- objectEach(obj, function (val, n) {
952
- // If the object is non-null and destroy is defined
953
- if (val !== except && val?.destroy) {
954
- // Invoke the destroy
955
- val.destroy();
956
- }
957
- // Delete the property from the object
958
- if (val?.destroy || !destructablesOnly) {
959
- delete obj[n];
960
- }
961
- });
962
- }
963
- /**
964
- * Discard a HTML element
965
- *
966
- * @function Highcharts.discardElement
967
- *
968
- * @param {Highcharts.HTMLDOMElement} element
969
- * The HTML node to discard.
970
- */
971
- function discardElement(element) {
972
- element?.parentElement?.removeChild(element);
973
- }
974
- /**
975
- * Fix JS round off float errors.
976
- *
977
- * @function Highcharts.correctFloat
978
- *
979
- * @param {number} num
980
- * A float number to fix.
981
- *
982
- * @param {number} [prec=14]
983
- * The precision.
984
- *
985
- * @return {number}
986
- * The corrected float number.
987
- */
988
- function correctFloat(num, prec) {
989
- // When the number is higher than 1e14 use the number (#16275)
990
- return num > 1e14 ? num : parseFloat(num.toPrecision(prec || 14));
991
- }
992
125
  /**
993
126
  * The time unit lookup
994
127
  *
995
128
  * @ignore
996
129
  */
997
- const timeUnits = {
130
+ export const timeUnits = {
998
131
  millisecond: 1,
999
132
  second: 1000,
1000
133
  minute: 60000,
@@ -1019,466 +152,6 @@ const timeUnits = {
1019
152
  Math.easeInOutSine = function (pos) {
1020
153
  return -0.5 * (Math.cos(Math.PI * pos) - 1);
1021
154
  };
1022
- /**
1023
- * Convenience function to get the align factor, used several places for
1024
- * computing positions
1025
- * @internal
1026
- */
1027
- const getAlignFactor = (align = '') => ({
1028
- center: 0.5,
1029
- right: 1,
1030
- middle: 0.5,
1031
- bottom: 1
1032
- }[align] || 0);
1033
- /**
1034
- * Find the closest distance between two values of a two-dimensional array
1035
- * @internal
1036
- * @function Highcharts.getClosestDistance
1037
- *
1038
- * @param {Array<Array<number>>} arrays
1039
- * An array of arrays of numbers
1040
- *
1041
- * @return {number | undefined}
1042
- * The closest distance between values
1043
- */
1044
- function getClosestDistance(arrays, onError) {
1045
- const allowNegative = !onError;
1046
- let closest, loopLength, distance, i;
1047
- arrays.forEach((xData) => {
1048
- if (xData.length > 1) {
1049
- loopLength = xData.length - 1;
1050
- for (i = loopLength; i > 0; i--) {
1051
- distance = xData[i] - xData[i - 1];
1052
- if (distance < 0 && !allowNegative) {
1053
- onError?.();
1054
- // Only one call
1055
- onError = void 0;
1056
- }
1057
- else if (distance && (typeof closest === 'undefined' || distance < closest)) {
1058
- closest = distance;
1059
- }
1060
- }
1061
- }
1062
- });
1063
- return closest;
1064
- }
1065
- /**
1066
- * Returns the value of a property path on a given object.
1067
- *
1068
- * @internal
1069
- * @function getNestedProperty
1070
- *
1071
- * @param {string} path
1072
- * Path to the property, for example `custom.myValue`.
1073
- *
1074
- * @param {unknown} obj
1075
- * Instance containing the property on the specific path.
1076
- *
1077
- * @return {unknown}
1078
- * The unknown property value.
1079
- */
1080
- function getNestedProperty(path, parent) {
1081
- const pathElements = path.split('.');
1082
- while (pathElements.length && defined(parent)) {
1083
- const pathElement = pathElements.shift();
1084
- // Filter on the key
1085
- if (typeof pathElement === 'undefined' ||
1086
- pathElement === '__proto__') {
1087
- return; // Undefined
1088
- }
1089
- if (pathElement === 'this') {
1090
- let thisProp;
1091
- if (isObject(parent)) {
1092
- thisProp = parent['@this'];
1093
- }
1094
- return thisProp ?? parent;
1095
- }
1096
- const child = parent[pathElement.replace(/[\\'"]/g, '')];
1097
- // Filter on the child
1098
- if (!defined(child) ||
1099
- typeof child === 'function' ||
1100
- typeof child.nodeType === 'number' ||
1101
- child === win) {
1102
- return; // Undefined
1103
- }
1104
- // Else, proceed
1105
- parent = child;
1106
- }
1107
- return parent;
1108
- }
1109
- /**
1110
- * Get the computed CSS value for given element and property, only for numerical
1111
- * properties. For width and height, the dimension of the inner box (excluding
1112
- * padding) is returned. Used for fitting the chart within the container.
1113
- *
1114
- * @function Highcharts.getStyle
1115
- *
1116
- * @param {Highcharts.HTMLDOMElement} el
1117
- * An HTML element.
1118
- *
1119
- * @param {string} prop
1120
- * The property name.
1121
- *
1122
- * @param {boolean} [toInt=true]
1123
- * Parse to integer.
1124
- *
1125
- * @return {number|string|undefined}
1126
- * The style value.
1127
- */
1128
- function getStyle(el, prop, toInt) {
1129
- let style;
1130
- // For width and height, return the actual inner pixel size (#4913)
1131
- if (prop === 'width') {
1132
- let offsetWidth = Math.min(el.offsetWidth, el.scrollWidth);
1133
- // In flex boxes, we need to use getBoundingClientRect and floor it,
1134
- // because scrollWidth doesn't support subpixel precision (#6427) ...
1135
- const boundingClientRectWidth = el.getBoundingClientRect?.().width;
1136
- // ...unless if the containing div or its parents are transform-scaled
1137
- // down, in which case the boundingClientRect can't be used as it is
1138
- // also scaled down (#9871, #10498).
1139
- if (boundingClientRectWidth < offsetWidth &&
1140
- boundingClientRectWidth >= offsetWidth - 1) {
1141
- offsetWidth = Math.floor(boundingClientRectWidth);
1142
- }
1143
- return Math.max(0, // #8377
1144
- (offsetWidth -
1145
- (getStyle(el, 'padding-left', true) || 0) -
1146
- (getStyle(el, 'padding-right', true) || 0)));
1147
- }
1148
- if (prop === 'height') {
1149
- return Math.max(0, // #8377
1150
- (Math.min(el.offsetHeight, el.scrollHeight) -
1151
- (getStyle(el, 'padding-top', true) || 0) -
1152
- (getStyle(el, 'padding-bottom', true) || 0)));
1153
- }
1154
- // Otherwise, get the computed style
1155
- const css = win.getComputedStyle(el, void 0); // eslint-disable-line no-undefined
1156
- if (css) {
1157
- style = css.getPropertyValue(prop);
1158
- if (pick(toInt, prop !== 'opacity')) {
1159
- style = pInt(style);
1160
- }
1161
- }
1162
- return style;
1163
- }
1164
- /**
1165
- * Return the value of the first element in the array that satisfies the
1166
- * provided testing function.
1167
- *
1168
- * @function Highcharts.find<T>
1169
- *
1170
- * @param {Array<T>} arr
1171
- * The array to test.
1172
- *
1173
- * @param {Function} callback
1174
- * The callback function. The function receives the item as the first
1175
- * argument. Return `true` if this item satisfies the condition.
1176
- *
1177
- * @return {T|undefined}
1178
- * The value of the element.
1179
- */
1180
- const find = Array.prototype.find ?
1181
- function (arr, callback) {
1182
- return arr.find(callback);
1183
- } :
1184
- // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
1185
- function (arr, callback) {
1186
- let i;
1187
- const length = arr.length;
1188
- for (i = 0; i < length; i++) {
1189
- if (callback(arr[i], i)) { // eslint-disable-line node/callback-return
1190
- return arr[i];
1191
- }
1192
- }
1193
- };
1194
- /**
1195
- * Get the element's offset position, corrected for `overflow: auto`.
1196
- *
1197
- * @function Highcharts.offset
1198
- *
1199
- * @param {global.Element} el
1200
- * The DOM element.
1201
- *
1202
- * @return {Highcharts.OffsetObject}
1203
- * An object containing `left` and `top` properties for the position in
1204
- * the page.
1205
- */
1206
- function offset(el) {
1207
- const docElem = doc.documentElement, box = (el.parentElement || el.parentNode) ?
1208
- el.getBoundingClientRect() :
1209
- { top: 0, left: 0, width: 0, height: 0 };
1210
- return {
1211
- top: box.top + (win.pageYOffset || docElem.scrollTop) -
1212
- (docElem.clientTop || 0),
1213
- left: box.left + (win.pageXOffset || docElem.scrollLeft) -
1214
- (docElem.clientLeft || 0),
1215
- width: box.width,
1216
- height: box.height
1217
- };
1218
- }
1219
- /* eslint-disable valid-jsdoc */
1220
- /**
1221
- * Iterate over object key pairs in an object.
1222
- *
1223
- * @function Highcharts.objectEach<T>
1224
- *
1225
- * @param {*} obj
1226
- * The object to iterate over.
1227
- *
1228
- * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
1229
- * The iterator callback. It passes three arguments:
1230
- * * value - The property value.
1231
- * * key - The property key.
1232
- * * obj - The object that objectEach is being applied to.
1233
- *
1234
- * @param {T} [ctx]
1235
- * The context.
1236
- */
1237
- function objectEach(obj, fn, ctx) {
1238
- /* eslint-enable valid-jsdoc */
1239
- for (const key in obj) {
1240
- if (Object.hasOwnProperty.call(obj, key)) {
1241
- fn.call(ctx || obj[key], obj[key], key, obj);
1242
- }
1243
- }
1244
- }
1245
- /* eslint-disable valid-jsdoc */
1246
- /**
1247
- * Add an event listener.
1248
- *
1249
- * @function Highcharts.addEvent<T>
1250
- *
1251
- * @param {Highcharts.Class<T>|T} el
1252
- * The element or object to add a listener to. It can be a
1253
- * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
1254
- *
1255
- * @param {string} type
1256
- * The event type.
1257
- *
1258
- * @param {Highcharts.EventCallbackFunction<T>|Function} fn
1259
- * The function callback to execute when the event is fired.
1260
- *
1261
- * @param {Highcharts.EventOptionsObject} [options]
1262
- * Options for adding the event.
1263
- *
1264
- * @sample highcharts/members/addevent
1265
- * Use a general `render` event to draw shapes on a chart
1266
- *
1267
- * @return {Function}
1268
- * A callback function to remove the added event.
1269
- */
1270
- function addEvent(el, type, fn, options = {}) {
1271
- /* eslint-enable valid-jsdoc */
1272
- // Add hcEvents to either the prototype (in case we're running addEvent on a
1273
- // class) or the instance. If hasOwnProperty('hcEvents') is false, it is
1274
- // inherited down the prototype chain, in which case we need to set the
1275
- // property on this instance (which may itself be a prototype).
1276
- const owner = typeof el === 'function' && el.prototype || el;
1277
- if (!Object.hasOwnProperty.call(owner, 'hcEvents')) {
1278
- owner.hcEvents = {};
1279
- }
1280
- const events = owner.hcEvents;
1281
- // Allow click events added to points, otherwise they will be prevented by
1282
- // the TouchPointer.pinch function after a pinch zoom operation (#7091).
1283
- if (H.Point && // Without H a dependency loop occurs
1284
- el instanceof H.Point &&
1285
- el.series &&
1286
- el.series.chart) {
1287
- el.series.chart.runTrackerClick = true;
1288
- }
1289
- // Handle DOM events
1290
- // If the browser supports passive events, add it to improve performance
1291
- // on touch events (#11353).
1292
- const addEventListener = el.addEventListener;
1293
- if (addEventListener) {
1294
- addEventListener.call(el, type, fn, H.supportsPassiveEvents ? {
1295
- passive: options.passive === void 0 ?
1296
- type.indexOf('touch') !== -1 : options.passive,
1297
- capture: false
1298
- } : false);
1299
- }
1300
- if (!events[type]) {
1301
- events[type] = [];
1302
- }
1303
- const eventObject = {
1304
- fn,
1305
- order: typeof options.order === 'number' ? options.order : Infinity
1306
- };
1307
- events[type].push(eventObject);
1308
- // Order the calls
1309
- events[type].sort((a, b) => a.order - b.order);
1310
- // Return a function that can be called to remove this event.
1311
- return function () {
1312
- removeEvent(el, type, fn);
1313
- };
1314
- }
1315
- /* eslint-disable valid-jsdoc */
1316
- /**
1317
- * Remove an event that was added with {@link Highcharts#addEvent}.
1318
- *
1319
- * @function Highcharts.removeEvent<T>
1320
- *
1321
- * @param {Highcharts.Class<T>|T} el
1322
- * The element to remove events on.
1323
- *
1324
- * @param {string} [type]
1325
- * The type of events to remove. If undefined, all events are removed
1326
- * from the element.
1327
- *
1328
- * @param {Highcharts.EventCallbackFunction<T>} [fn]
1329
- * The specific callback to remove. If undefined, all events that match
1330
- * the element and optionally the type are removed.
1331
- *
1332
- * @return {void}
1333
- */
1334
- function removeEvent(el, type, fn) {
1335
- /* eslint-enable valid-jsdoc */
1336
- /** @internal */
1337
- function removeOneEvent(type, fn) {
1338
- const removeEventListener = el.removeEventListener;
1339
- if (removeEventListener) {
1340
- removeEventListener.call(el, type, fn, false);
1341
- }
1342
- }
1343
- /** @internal */
1344
- function removeAllEvents(eventCollection) {
1345
- let types, len;
1346
- if (!el.nodeName) {
1347
- return; // Break on non-DOM events
1348
- }
1349
- if (type) {
1350
- types = {};
1351
- types[type] = true;
1352
- }
1353
- else {
1354
- types = eventCollection;
1355
- }
1356
- objectEach(types, function (_val, n) {
1357
- if (eventCollection[n]) {
1358
- len = eventCollection[n].length;
1359
- while (len--) {
1360
- removeOneEvent(n, eventCollection[n][len].fn);
1361
- }
1362
- }
1363
- });
1364
- }
1365
- const owner = typeof el === 'function' && el.prototype || el;
1366
- if (Object.hasOwnProperty.call(owner, 'hcEvents')) {
1367
- const events = owner.hcEvents;
1368
- if (type) {
1369
- const typeEvents = (events[type] || []);
1370
- if (fn) {
1371
- events[type] = typeEvents.filter(function (obj) {
1372
- return fn !== obj.fn;
1373
- });
1374
- removeOneEvent(type, fn);
1375
- }
1376
- else {
1377
- removeAllEvents(events);
1378
- events[type] = [];
1379
- }
1380
- }
1381
- else {
1382
- removeAllEvents(events);
1383
- delete owner.hcEvents;
1384
- }
1385
- }
1386
- }
1387
- /* eslint-disable valid-jsdoc */
1388
- /**
1389
- * Fire an event that was registered with {@link Highcharts#addEvent}.
1390
- *
1391
- * @function Highcharts.fireEvent<T>
1392
- *
1393
- * @param {T} el
1394
- * The object to fire the event on. It can be a {@link HTMLDOMElement},
1395
- * an {@link SVGElement} or any other object.
1396
- *
1397
- * @param {string} type
1398
- * The type of event.
1399
- *
1400
- * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
1401
- * Custom event arguments that are passed on as an argument to the event
1402
- * handler.
1403
- *
1404
- * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
1405
- * The default function to execute if the other listeners haven't
1406
- * returned false.
1407
- *
1408
- * @return {void}
1409
- */
1410
- function fireEvent(el, type, eventArguments, defaultFunction) {
1411
- /* eslint-enable valid-jsdoc */
1412
- eventArguments = eventArguments || {};
1413
- if (doc?.createEvent &&
1414
- (el.dispatchEvent ||
1415
- (el.fireEvent &&
1416
- // Enable firing events on Highcharts instance.
1417
- el !== H))) {
1418
- const e = doc.createEvent('Events');
1419
- e.initEvent(type, true, true);
1420
- eventArguments = extend(e, eventArguments);
1421
- if (el.dispatchEvent) {
1422
- el.dispatchEvent(eventArguments);
1423
- }
1424
- else {
1425
- el.fireEvent(type, eventArguments);
1426
- }
1427
- }
1428
- else if (el.hcEvents) {
1429
- if (!eventArguments.target) {
1430
- // We're running a custom event
1431
- extend(eventArguments, {
1432
- // Attach a simple preventDefault function to skip
1433
- // default handler if called. The built-in
1434
- // defaultPrevented property is not overwritable (#5112)
1435
- preventDefault: function () {
1436
- eventArguments.defaultPrevented = true;
1437
- },
1438
- // Setting target to native events fails with clicking
1439
- // the zoom-out button in Chrome.
1440
- target: el,
1441
- // If the type is not set, we're running a custom event
1442
- // (#2297). If it is set, we're running a browser event.
1443
- type: type
1444
- });
1445
- }
1446
- const events = [];
1447
- let object = el;
1448
- let multilevel = false;
1449
- // Recurse up the inheritance chain and collect hcEvents set as own
1450
- // objects on the prototypes.
1451
- while (object.hcEvents) {
1452
- if (Object.hasOwnProperty.call(object, 'hcEvents') &&
1453
- object.hcEvents[type]) {
1454
- if (events.length) {
1455
- multilevel = true;
1456
- }
1457
- events.unshift.apply(events, object.hcEvents[type]);
1458
- }
1459
- object = Object.getPrototypeOf(object);
1460
- }
1461
- // For performance reasons, only sort the event handlers in case we are
1462
- // dealing with multiple levels in the prototype chain. Otherwise, the
1463
- // events are already sorted in the addEvent function.
1464
- if (multilevel) {
1465
- // Order the calls
1466
- events.sort((a, b) => a.order - b.order);
1467
- }
1468
- // Call the collected event handlers
1469
- events.forEach((obj) => {
1470
- // If the event handler returns false, prevent the default handler
1471
- // from executing
1472
- if (obj.fn.call(el, eventArguments) === false) {
1473
- eventArguments.preventDefault();
1474
- }
1475
- });
1476
- }
1477
- // Run the default if not prevented
1478
- if (defaultFunction && !eventArguments.defaultPrevented) {
1479
- defaultFunction.call(el, eventArguments);
1480
- }
1481
- }
1482
155
  let serialMode;
1483
156
  /**
1484
157
  * Get a unique key for using in internal element id's and pointers. The key is
@@ -1493,7 +166,7 @@ let serialMode;
1493
166
  * @return {string}
1494
167
  * A unique key.
1495
168
  */
1496
- const uniqueKey = (function () {
169
+ export const uniqueKey = (function () {
1497
170
  const hash = Math.random().toString(36).substring(2, 9) + '-';
1498
171
  let id = 0;
1499
172
  return function () {
@@ -1524,17 +197,9 @@ const uniqueKey = (function () {
1524
197
  * @return {boolean|undefined}
1525
198
  * State of the serial mode.
1526
199
  */
1527
- function useSerialIds(mode) {
200
+ export function useSerialIds(mode) {
1528
201
  return (serialMode = pick(mode, serialMode));
1529
202
  }
1530
- function isFunction(obj) {
1531
- return typeof obj === 'function';
1532
- }
1533
- function ucfirst(s) {
1534
- return ((isString(s) ?
1535
- s.substring(0, 1).toUpperCase() + s.substring(1) :
1536
- String(s)));
1537
- }
1538
203
  /* *
1539
204
  *
1540
205
  * External
@@ -1592,62 +257,6 @@ if (win.jQuery) {
1592
257
  }
1593
258
  };
1594
259
  }
1595
- // TODO use named exports when supported.
1596
- const Utilities = {
1597
- addEvent,
1598
- arrayMax,
1599
- arrayMin,
1600
- attr,
1601
- clamp,
1602
- clearTimeout: internalClearTimeout,
1603
- correctFloat,
1604
- createElement,
1605
- crisp,
1606
- css,
1607
- defined,
1608
- destroyObjectProperties,
1609
- diffObjects,
1610
- discardElement,
1611
- erase,
1612
- error,
1613
- extend,
1614
- extendClass,
1615
- find,
1616
- fireEvent,
1617
- getAlignFactor,
1618
- getClosestDistance,
1619
- getMagnitude,
1620
- getNestedProperty,
1621
- getStyle,
1622
- insertItem,
1623
- isArray,
1624
- isClass,
1625
- isDOMElement,
1626
- isFunction,
1627
- isNumber,
1628
- isObject,
1629
- isString,
1630
- merge,
1631
- normalizeTickInterval,
1632
- objectEach,
1633
- offset,
1634
- pad,
1635
- pick,
1636
- pInt,
1637
- pushUnique,
1638
- relativeLength,
1639
- removeEvent,
1640
- replaceNested,
1641
- splat,
1642
- stableSort,
1643
- syncTimeout,
1644
- timeUnits,
1645
- ucfirst,
1646
- uniqueKey,
1647
- useSerialIds,
1648
- wrap
1649
- };
1650
- export default Utilities;
1651
260
  /* *
1652
261
  *
1653
262
  * API Declarations
@@ -1827,6 +436,11 @@ export default Utilities;
1827
436
  * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
1828
437
  * Event arguments.
1829
438
  *
439
+ * @param {T} [ctx]
440
+ * Since v12.5.0, the callback context is passed as the last argument,
441
+ * so arrow functions can access the same context as regular functions
442
+ * using `this`.
443
+ *
1830
444
  * @return {boolean|void}
1831
445
  */
1832
446
  /**
@@ -1855,6 +469,11 @@ export default Utilities;
1855
469
  * @param {T} this
1856
470
  * Context to format
1857
471
  *
472
+ * @param {T} [ctx]
473
+ * Since v12.5.0, the callback context is passed as an extra argument,
474
+ * so arrow functions can access the same context as regular functions
475
+ * using `this`.
476
+ *
1858
477
  * @return {string}
1859
478
  * Formatted text
1860
479
  */