highcharts 7.1.1 → 7.1.2

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 (415) hide show
  1. package/bower.json +1 -1
  2. package/css/annotations/popup.css +3 -3
  3. package/css/annotations/popup.scss +1 -1
  4. package/css/stocktools/gui.css +5 -5
  5. package/css/stocktools/gui.scss +1 -1
  6. package/es-modules/annotations/ControlPoint.js +1 -1
  7. package/es-modules/annotations/MockPoint.js +45 -12
  8. package/es-modules/annotations/annotations.src.js +203 -166
  9. package/es-modules/annotations/controllable/ControllableCircle.js +2 -10
  10. package/es-modules/annotations/controllable/ControllableImage.js +2 -10
  11. package/es-modules/annotations/controllable/ControllableLabel.js +54 -9
  12. package/es-modules/annotations/controllable/ControllableRect.js +2 -10
  13. package/es-modules/annotations/controllable/controllableMixin.js +32 -4
  14. package/es-modules/annotations/controllable/markerMixin.js +1 -0
  15. package/es-modules/annotations/eventEmitterMixin.js +1 -0
  16. package/es-modules/annotations/navigationBindings.js +15 -11
  17. package/es-modules/annotations/popup.js +59 -81
  18. package/es-modules/annotations/types/CrookedLine.js +19 -7
  19. package/es-modules/annotations/types/ElliottWave.js +7 -6
  20. package/es-modules/annotations/types/Fibonacci.js +14 -14
  21. package/es-modules/annotations/types/InfinityLine.js +4 -4
  22. package/es-modules/annotations/types/Measure.js +41 -41
  23. package/es-modules/annotations/types/Pitchfork.js +5 -4
  24. package/es-modules/annotations/types/VerticalLine.js +6 -5
  25. package/es-modules/error-messages.js +6 -1
  26. package/es-modules/indicators/indicators.src.js +5 -3
  27. package/es-modules/mixins/nodes.js +16 -8
  28. package/es-modules/modules/accessibility/AccessibilityComponent.js +4 -4
  29. package/es-modules/modules/accessibility/KeyboardNavigation.js +17 -4
  30. package/es-modules/modules/accessibility/components/RangeSelectorComponent.js +3 -2
  31. package/es-modules/modules/accessibility/components/SeriesComponent.js +110 -2
  32. package/es-modules/modules/accessibility/components/ZoomComponent.js +1 -1
  33. package/es-modules/modules/accessibility/options.js +2 -1
  34. package/es-modules/modules/bellcurve.src.js +27 -29
  35. package/es-modules/modules/boost/boost-init.js +14 -0
  36. package/es-modules/modules/boost/boost-overrides.js +13 -3
  37. package/es-modules/modules/boost/wgl-renderer.js +30 -15
  38. package/es-modules/modules/boost/wgl-shader.js +33 -16
  39. package/es-modules/modules/boost/wgl-vbuffer.js +8 -4
  40. package/es-modules/modules/broken-axis.src.js +1 -1
  41. package/es-modules/modules/bullet.src.js +68 -68
  42. package/es-modules/modules/cylinder.src.js +3 -1
  43. package/es-modules/modules/data.src.js +9 -5
  44. package/es-modules/modules/draggable-points.src.js +1 -1
  45. package/es-modules/modules/drilldown.src.js +1 -1
  46. package/es-modules/modules/export-data.src.js +7 -8
  47. package/es-modules/modules/exporting.src.js +9 -1
  48. package/es-modules/modules/full-screen.src.js +1 -1
  49. package/es-modules/modules/funnel3d.src.js +10 -3
  50. package/es-modules/modules/histogram.src.js +162 -164
  51. package/es-modules/modules/item-series.src.js +10 -10
  52. package/es-modules/modules/networkgraph/layouts.js +16 -12
  53. package/es-modules/modules/networkgraph/networkgraph.src.js +147 -51
  54. package/es-modules/modules/offline-exporting.src.js +15 -2
  55. package/es-modules/modules/oldie-polyfills.src.js +1 -1
  56. package/es-modules/modules/organization.src.js +65 -20
  57. package/es-modules/modules/pareto.src.js +52 -51
  58. package/es-modules/modules/pattern-fill.src.js +1 -1
  59. package/es-modules/modules/price-indicator.src.js +1 -1
  60. package/es-modules/modules/pyramid3d.src.js +1 -1
  61. package/es-modules/modules/sankey.src.js +22 -10
  62. package/es-modules/modules/series-label.src.js +16 -8
  63. package/es-modules/modules/solid-gauge.src.js +128 -79
  64. package/es-modules/modules/static-scale.src.js +8 -1
  65. package/es-modules/modules/stock-tools-gui.js +1 -1
  66. package/es-modules/modules/streamgraph.src.js +11 -11
  67. package/es-modules/modules/sunburst.src.js +23 -2
  68. package/es-modules/modules/tilemap.src.js +58 -57
  69. package/es-modules/modules/timeline.src.js +17 -12
  70. package/es-modules/modules/treemap.src.js +6 -6
  71. package/es-modules/modules/variwide.src.js +39 -39
  72. package/es-modules/modules/vector.src.js +108 -107
  73. package/es-modules/modules/venn.src.js +4 -2
  74. package/es-modules/modules/windbarb.src.js +43 -43
  75. package/es-modules/modules/wordcloud.src.js +1 -0
  76. package/es-modules/modules/xrange.src.js +112 -104
  77. package/es-modules/parts/AreaSeries.js +4 -1
  78. package/es-modules/parts/Axis.js +809 -1870
  79. package/es-modules/parts/Chart.js +254 -743
  80. package/es-modules/parts/Color.js +160 -113
  81. package/es-modules/parts/ColumnSeries.js +9 -3
  82. package/es-modules/parts/DataLabels.js +31 -2
  83. package/es-modules/parts/Dynamics.js +73 -26
  84. package/es-modules/parts/FlagsSeries.js +6 -4
  85. package/es-modules/parts/Globals.js +20 -36
  86. package/es-modules/parts/Html.js +116 -235
  87. package/es-modules/parts/Interaction.js +17 -7
  88. package/es-modules/parts/Legend.js +277 -632
  89. package/es-modules/parts/MSPointer.js +62 -106
  90. package/es-modules/parts/Options.js +128 -367
  91. package/es-modules/parts/OrdinalAxis.js +12 -0
  92. package/es-modules/parts/PieSeries.js +61 -44
  93. package/es-modules/parts/PlotLineOrBand.js +38 -3
  94. package/es-modules/parts/Point.js +117 -227
  95. package/es-modules/parts/Pointer.js +273 -558
  96. package/es-modules/parts/RangeSelector.js +5 -3
  97. package/es-modules/parts/Responsive.js +8 -4
  98. package/es-modules/parts/ScrollablePlotArea.js +215 -81
  99. package/es-modules/parts/Scrollbar.js +38 -23
  100. package/es-modules/parts/Series.js +151 -47
  101. package/es-modules/parts/Stacking.js +8 -3
  102. package/es-modules/parts/StockChart.js +42 -29
  103. package/es-modules/parts/SvgRenderer.js +1080 -2100
  104. package/es-modules/parts/Tick.js +11 -4
  105. package/es-modules/parts/Time.js +179 -363
  106. package/es-modules/parts/Tooltip.js +23 -12
  107. package/es-modules/parts/TouchPointer.js +69 -187
  108. package/es-modules/parts/Utilities.js +593 -846
  109. package/es-modules/parts-3d/Axis.js +2 -2
  110. package/es-modules/parts-3d/Column.js +18 -8
  111. package/es-modules/parts-gantt/GanttSeries.js +17 -21
  112. package/es-modules/parts-gantt/GridAxis.js +183 -101
  113. package/es-modules/parts-gantt/PathfinderAlgorithms.js +2 -2
  114. package/es-modules/parts-gantt/TreeGrid.js +53 -36
  115. package/es-modules/parts-map/ColorAxis.js +35 -14
  116. package/es-modules/parts-map/MapBubbleSeries.js +2 -1
  117. package/es-modules/parts-map/MapSeries.js +29 -18
  118. package/es-modules/parts-more/AreaRangeSeries.js +13 -12
  119. package/es-modules/parts-more/ColumnRangeSeries.js +8 -2
  120. package/es-modules/parts-more/GaugeSeries.js +9 -9
  121. package/es-modules/parts-more/PackedBubbleSeries.js +152 -115
  122. package/es-modules/parts-more/RadialAxis.js +102 -8
  123. package/es-modules/parts-more/WaterfallSeries.js +148 -35
  124. package/highcharts-3d.js +68 -67
  125. package/highcharts-3d.js.map +1 -1
  126. package/highcharts-3d.src.js +21 -11
  127. package/highcharts-gantt.d.ts +5 -3
  128. package/highcharts-gantt.js +618 -610
  129. package/highcharts-gantt.js.map +1 -1
  130. package/highcharts-gantt.src.d.ts +5 -3
  131. package/highcharts-gantt.src.js +5185 -8892
  132. package/highcharts-more.js +144 -140
  133. package/highcharts-more.js.map +1 -1
  134. package/highcharts-more.src.js +449 -194
  135. package/highcharts.d.ts +3943 -5236
  136. package/highcharts.js +454 -449
  137. package/highcharts.js.map +1 -1
  138. package/highcharts.src.d.ts +3943 -5236
  139. package/highcharts.src.js +4767 -8601
  140. package/highmaps.d.ts +5 -3
  141. package/highmaps.js +498 -494
  142. package/highmaps.js.map +1 -1
  143. package/highmaps.src.d.ts +5 -3
  144. package/highmaps.src.js +4547 -8507
  145. package/highstock.d.ts +5 -3
  146. package/highstock.js +597 -590
  147. package/highstock.js.map +1 -1
  148. package/highstock.src.d.ts +5 -3
  149. package/highstock.src.js +4871 -8661
  150. package/indicators/acceleration-bands.js +1 -1
  151. package/indicators/acceleration-bands.src.js +1 -1
  152. package/indicators/accumulation-distribution.js +1 -1
  153. package/indicators/accumulation-distribution.src.js +1 -1
  154. package/indicators/ao.js +1 -1
  155. package/indicators/ao.src.js +1 -1
  156. package/indicators/apo.js +1 -1
  157. package/indicators/apo.src.js +1 -1
  158. package/indicators/aroon-oscillator.js +1 -1
  159. package/indicators/aroon-oscillator.src.js +1 -1
  160. package/indicators/aroon.js +1 -1
  161. package/indicators/aroon.src.js +1 -1
  162. package/indicators/atr.js +1 -1
  163. package/indicators/atr.src.js +1 -1
  164. package/indicators/bollinger-bands.js +1 -1
  165. package/indicators/bollinger-bands.src.js +1 -1
  166. package/indicators/cci.js +1 -1
  167. package/indicators/cci.src.js +1 -1
  168. package/indicators/chaikin.js +1 -1
  169. package/indicators/chaikin.src.js +1 -1
  170. package/indicators/cmf.js +1 -1
  171. package/indicators/cmf.src.js +1 -1
  172. package/indicators/dema.js +1 -1
  173. package/indicators/dema.src.js +1 -1
  174. package/indicators/dpo.js +1 -1
  175. package/indicators/dpo.src.js +1 -1
  176. package/indicators/ema.js +1 -1
  177. package/indicators/ema.src.js +1 -1
  178. package/indicators/ichimoku-kinko-hyo.js +1 -1
  179. package/indicators/ichimoku-kinko-hyo.src.js +1 -1
  180. package/indicators/indicators-all.js +105 -105
  181. package/indicators/indicators-all.js.map +1 -1
  182. package/indicators/indicators-all.src.js +6 -4
  183. package/indicators/indicators.js +9 -9
  184. package/indicators/indicators.js.map +1 -1
  185. package/indicators/indicators.src.js +6 -4
  186. package/indicators/keltner-channels.js +1 -1
  187. package/indicators/keltner-channels.src.js +1 -1
  188. package/indicators/macd.js +1 -1
  189. package/indicators/macd.src.js +1 -1
  190. package/indicators/mfi.js +1 -1
  191. package/indicators/mfi.src.js +1 -1
  192. package/indicators/momentum.js +1 -1
  193. package/indicators/momentum.src.js +1 -1
  194. package/indicators/natr.js +1 -1
  195. package/indicators/natr.src.js +1 -1
  196. package/indicators/pivot-points.js +1 -1
  197. package/indicators/pivot-points.src.js +1 -1
  198. package/indicators/ppo.js +1 -1
  199. package/indicators/ppo.src.js +1 -1
  200. package/indicators/price-channel.js +1 -1
  201. package/indicators/price-channel.src.js +1 -1
  202. package/indicators/price-envelopes.js +1 -1
  203. package/indicators/price-envelopes.src.js +1 -1
  204. package/indicators/psar.js +1 -1
  205. package/indicators/psar.src.js +1 -1
  206. package/indicators/regressions.js +1 -1
  207. package/indicators/regressions.src.js +1 -1
  208. package/indicators/roc.js +1 -1
  209. package/indicators/roc.src.js +1 -1
  210. package/indicators/rsi.js +1 -1
  211. package/indicators/rsi.src.js +1 -1
  212. package/indicators/stochastic.js +1 -1
  213. package/indicators/stochastic.src.js +1 -1
  214. package/indicators/supertrend.js +1 -1
  215. package/indicators/supertrend.src.js +1 -1
  216. package/indicators/tema.js +1 -1
  217. package/indicators/tema.src.js +1 -1
  218. package/indicators/trix.js +1 -1
  219. package/indicators/trix.src.js +1 -1
  220. package/indicators/volume-by-price.js +1 -1
  221. package/indicators/volume-by-price.src.js +1 -1
  222. package/indicators/vwap.js +1 -1
  223. package/indicators/vwap.src.js +1 -1
  224. package/indicators/williams-r.js +1 -1
  225. package/indicators/williams-r.src.js +1 -1
  226. package/indicators/wma.js +1 -1
  227. package/indicators/wma.src.js +1 -1
  228. package/indicators/zigzag.js +1 -1
  229. package/indicators/zigzag.src.js +1 -1
  230. package/modules/accessibility.js +92 -89
  231. package/modules/accessibility.js.map +1 -1
  232. package/modules/accessibility.src.js +138 -15
  233. package/modules/annotations-advanced.js +128 -127
  234. package/modules/annotations-advanced.js.map +1 -1
  235. package/modules/annotations-advanced.src.js +514 -396
  236. package/modules/annotations.d.ts +36 -0
  237. package/modules/annotations.js +81 -81
  238. package/modules/annotations.js.map +1 -1
  239. package/modules/annotations.src.d.ts +36 -0
  240. package/modules/annotations.src.js +418 -315
  241. package/modules/arrow-symbols.js +1 -1
  242. package/modules/arrow-symbols.src.js +1 -1
  243. package/modules/boost-canvas.js +1 -1
  244. package/modules/boost-canvas.src.js +1 -1
  245. package/modules/boost.js +63 -63
  246. package/modules/boost.js.map +1 -1
  247. package/modules/boost.src.js +99 -39
  248. package/modules/broken-axis.js +1 -1
  249. package/modules/broken-axis.src.js +2 -2
  250. package/modules/bullet.js +1 -1
  251. package/modules/bullet.src.js +69 -69
  252. package/modules/current-date-indicator.js +1 -1
  253. package/modules/current-date-indicator.src.js +1 -1
  254. package/modules/cylinder.js +1 -1
  255. package/modules/cylinder.js.map +1 -1
  256. package/modules/cylinder.src.js +4 -2
  257. package/modules/data.js +4 -4
  258. package/modules/data.js.map +1 -1
  259. package/modules/data.src.js +10 -6
  260. package/modules/datagrouping.js +1 -1
  261. package/modules/datagrouping.src.js +1 -1
  262. package/modules/debugger.js +4 -4
  263. package/modules/debugger.js.map +1 -1
  264. package/modules/debugger.src.js +7 -2
  265. package/modules/dependency-wheel.js +1 -1
  266. package/modules/dependency-wheel.src.js +1 -1
  267. package/modules/dotplot.js +1 -1
  268. package/modules/dotplot.src.js +1 -1
  269. package/modules/drag-panes.js +1 -1
  270. package/modules/drag-panes.src.js +1 -1
  271. package/modules/draggable-points.js +1 -1
  272. package/modules/draggable-points.src.js +2 -2
  273. package/modules/drilldown.js +1 -1
  274. package/modules/drilldown.src.js +2 -2
  275. package/modules/export-data.js +2 -2
  276. package/modules/export-data.js.map +1 -1
  277. package/modules/export-data.src.js +8 -9
  278. package/modules/exporting.js +25 -25
  279. package/modules/exporting.js.map +1 -1
  280. package/modules/exporting.src.js +11 -3
  281. package/modules/full-screen.js +1 -1
  282. package/modules/full-screen.src.js +2 -2
  283. package/modules/funnel.js +1 -1
  284. package/modules/funnel.src.js +1 -1
  285. package/modules/funnel3d.js +2 -2
  286. package/modules/funnel3d.js.map +1 -1
  287. package/modules/funnel3d.src.js +11 -4
  288. package/modules/gantt.js +166 -164
  289. package/modules/gantt.js.map +1 -1
  290. package/modules/gantt.src.js +422 -295
  291. package/modules/grid-axis.js +18 -16
  292. package/modules/grid-axis.js.map +1 -1
  293. package/modules/grid-axis.src.js +184 -102
  294. package/modules/heatmap.js +22 -22
  295. package/modules/heatmap.js.map +1 -1
  296. package/modules/heatmap.src.js +36 -15
  297. package/modules/histogram-bellcurve.js +1 -1
  298. package/modules/histogram-bellcurve.js.map +1 -1
  299. package/modules/histogram-bellcurve.src.js +186 -183
  300. package/modules/item-series.js +1 -1
  301. package/modules/item-series.src.js +11 -11
  302. package/modules/map-parser.js +1 -1
  303. package/modules/map-parser.src.js +1 -1
  304. package/modules/map.js +83 -83
  305. package/modules/map.js.map +1 -1
  306. package/modules/map.src.js +67 -34
  307. package/modules/networkgraph.js +10 -9
  308. package/modules/networkgraph.js.map +1 -1
  309. package/modules/networkgraph.src.js +180 -72
  310. package/modules/no-data-to-display.js +1 -1
  311. package/modules/no-data-to-display.src.js +1 -1
  312. package/modules/offline-exporting.js +15 -15
  313. package/modules/offline-exporting.js.map +1 -1
  314. package/modules/offline-exporting.src.js +17 -4
  315. package/modules/oldie-polyfills.js +1 -1
  316. package/modules/oldie-polyfills.src.js +2 -2
  317. package/modules/oldie.js +2 -2
  318. package/modules/oldie.src.js +2 -2
  319. package/modules/organization.js +1 -1
  320. package/modules/organization.js.map +1 -1
  321. package/modules/organization.src.js +66 -21
  322. package/modules/overlapping-datalabels.js +1 -1
  323. package/modules/overlapping-datalabels.src.js +1 -1
  324. package/modules/parallel-coordinates.js +1 -1
  325. package/modules/parallel-coordinates.src.js +1 -1
  326. package/modules/pareto.js +1 -1
  327. package/modules/pareto.js.map +1 -1
  328. package/modules/pareto.src.js +53 -52
  329. package/modules/pathfinder.js +3 -3
  330. package/modules/pathfinder.js.map +1 -1
  331. package/modules/pathfinder.src.js +3 -3
  332. package/modules/pattern-fill.js +1 -1
  333. package/modules/pattern-fill.src.js +2 -2
  334. package/modules/price-indicator.js +1 -1
  335. package/modules/price-indicator.src.js +2 -2
  336. package/modules/pyramid3d.js +1 -1
  337. package/modules/pyramid3d.src.js +2 -2
  338. package/modules/sankey.js +14 -14
  339. package/modules/sankey.js.map +1 -1
  340. package/modules/sankey.src.js +39 -19
  341. package/modules/series-label.js +16 -16
  342. package/modules/series-label.js.map +1 -1
  343. package/modules/series-label.src.js +17 -9
  344. package/modules/solid-gauge.js +5 -5
  345. package/modules/solid-gauge.js.map +1 -1
  346. package/modules/solid-gauge.src.js +129 -80
  347. package/modules/sonification.js +1 -1
  348. package/modules/sonification.src.js +1 -1
  349. package/modules/static-scale.js +4 -4
  350. package/modules/static-scale.js.map +1 -1
  351. package/modules/static-scale.src.js +9 -2
  352. package/modules/stock-tools.js +2 -2
  353. package/modules/stock-tools.src.js +3 -3
  354. package/modules/stock.js +146 -145
  355. package/modules/stock.js.map +1 -1
  356. package/modules/stock.src.js +105 -61
  357. package/modules/streamgraph.js +1 -1
  358. package/modules/streamgraph.src.js +12 -12
  359. package/modules/sunburst.js +40 -40
  360. package/modules/sunburst.js.map +1 -1
  361. package/modules/sunburst.src.js +30 -9
  362. package/modules/tilemap.js +1 -1
  363. package/modules/tilemap.js.map +1 -1
  364. package/modules/tilemap.src.js +59 -58
  365. package/modules/timeline.js +12 -11
  366. package/modules/timeline.js.map +1 -1
  367. package/modules/timeline.src.js +18 -13
  368. package/modules/treegrid.js +45 -43
  369. package/modules/treegrid.js.map +1 -1
  370. package/modules/treegrid.src.js +238 -139
  371. package/modules/treemap.js +1 -1
  372. package/modules/treemap.src.js +7 -7
  373. package/modules/variable-pie.js +1 -1
  374. package/modules/variable-pie.src.js +1 -1
  375. package/modules/variwide.js +1 -1
  376. package/modules/variwide.src.js +40 -40
  377. package/modules/vector.js +1 -1
  378. package/modules/vector.js.map +1 -1
  379. package/modules/vector.src.js +109 -108
  380. package/modules/venn.js +23 -23
  381. package/modules/venn.js.map +1 -1
  382. package/modules/venn.src.js +5 -3
  383. package/modules/windbarb.js +1 -1
  384. package/modules/windbarb.src.js +44 -44
  385. package/modules/wordcloud.js +10 -10
  386. package/modules/wordcloud.js.map +1 -1
  387. package/modules/wordcloud.src.js +2 -1
  388. package/modules/xrange.js +12 -12
  389. package/modules/xrange.js.map +1 -1
  390. package/modules/xrange.src.js +113 -105
  391. package/package.json +1 -1
  392. package/themes/avocado.js +21 -37
  393. package/themes/avocado.src.js +1 -1
  394. package/themes/dark-blue.js +1 -1
  395. package/themes/dark-blue.src.js +1 -1
  396. package/themes/dark-green.js +1 -1
  397. package/themes/dark-green.src.js +1 -1
  398. package/themes/dark-unica.js +1 -1
  399. package/themes/dark-unica.src.js +1 -1
  400. package/themes/gray.js +1 -1
  401. package/themes/gray.src.js +1 -1
  402. package/themes/grid-light.js +1 -1
  403. package/themes/grid-light.src.js +1 -1
  404. package/themes/grid.js +1 -1
  405. package/themes/grid.src.js +1 -1
  406. package/themes/sand-signika.js +1 -1
  407. package/themes/sand-signika.src.js +1 -1
  408. package/themes/skies.js +1 -1
  409. package/themes/skies.src.js +1 -1
  410. package/themes/sunset.js +21 -37
  411. package/themes/sunset.src.js +1 -1
  412. package/.DS_Store +0 -0
  413. package/es-modules/.DS_Store +0 -0
  414. package/es-modules/modules/annotations-legacy.src.js +0 -1977
  415. package/js/.DS_Store +0 -0
@@ -1,1977 +0,0 @@
1
- /* *
2
- * (c) 2009-2017 Highsoft, Black Label
3
- *
4
- * License: www.highcharts.com/license
5
- */
6
-
7
- /**
8
- * @interface Highcharts.AnnotationAnchorObject
9
- *//**
10
- * Relative to the plot area position
11
- * @name Highcharts.AnnotationAnchorObject#relativePosition
12
- * @type {Highcharts.AnnotationAnchorPositionObject}
13
- *//**
14
- * Absolute position
15
- * @name Highcharts.AnnotationAnchorObject#absolutePosition
16
- * @type {Highcharts.AnnotationAnchorPositionObject}
17
- */
18
-
19
- /**
20
- * An object which denotes an anchor position
21
- *
22
- * @interface Highcharts.AnnotationAnchorPositionObject
23
- *//**
24
- * @name Highcharts.AnnotationAnchorPositionObject#x
25
- * @property {number}
26
- *//**
27
- * @name Highcharts.AnnotationAnchorPositionObject#y
28
- * @property {number}
29
- *//**
30
- * @name Highcharts.AnnotationAnchorPositionObject#height
31
- * @property {number}
32
- *//**
33
- * @name Highcharts.AnnotationAnchorPositionObject#width
34
- * @property {number}
35
- */
36
-
37
- /**
38
- * A mock point label configuration.
39
- *
40
- * @private
41
- * @interface Highcharts.MockLabelOptionsObject
42
- *//**
43
- * X value translated to x axis scale
44
- * @name Highcharts.MockLabelOptionsObject#x
45
- * @type {number|undefined}
46
- *//**
47
- * Y value translated to y axis scale
48
- * @name Highcharts.MockLabelOptionsObject#y
49
- * @type {number|undefined}
50
- *//**
51
- * @name Highcharts.MockLabelOptionsObject#point
52
- * @type {Highcharts.Point}
53
- */
54
-
55
- /**
56
- * A mock point configuration.
57
- *
58
- * @todo Make official
59
- *
60
- * @private
61
- * @interface Highcharts.MockPointOptionsObject
62
- *//**
63
- * x value for the point in xAxis scale or pixels
64
- * @name Highcharts.MockPointOptionsObject#x
65
- * @type {number}
66
- *//**
67
- * y value for the point in yAxis scale or pixels
68
- * @name Highcharts.MockPointOptionsObject#y
69
- * @type {number}
70
- *//**
71
- * xAxis index or id
72
- * @name Highcharts.MockPointOptionsObject#xAxis
73
- * @type {number|string|undefined}
74
- *//**
75
- * yAxis index or id
76
- * @name Highcharts.MockPointOptionsObject#yAxis
77
- * @property {number|string|undefined}
78
- */
79
-
80
- 'use strict';
81
-
82
- import H from '../parts/Globals.js';
83
- import '../parts/Utilities.js';
84
- import '../parts/Chart.js';
85
- import '../parts/Series.js';
86
- import '../parts/Tooltip.js';
87
-
88
- var merge = H.merge,
89
- addEvent = H.addEvent,
90
- extend = H.extend,
91
- isString = H.isString,
92
- isNumber = H.isNumber,
93
- defined = H.defined,
94
- isObject = H.isObject,
95
- erase = H.erase,
96
- find = H.find,
97
- format = H.format,
98
- pick = H.pick,
99
- objectEach = H.objectEach,
100
- uniqueKey = H.uniqueKey,
101
- destroyObjectProperties = H.destroyObjectProperties,
102
- tooltipPrototype = H.Tooltip.prototype,
103
- seriesPrototype = H.Series.prototype,
104
- chartPrototype = H.Chart.prototype;
105
-
106
-
107
- /* ************************************************************************** *
108
- *
109
- * MARKER SECTION
110
- * Contains objects and functions for adding a marker element to a path
111
- * element
112
- *
113
- * ************************************************************************** */
114
-
115
- /**
116
- * Options for configuring markers for annotations.
117
- *
118
- * An example of the arrow marker:
119
- * ```
120
- * {
121
- * arrow: {
122
- * id: 'arrow',
123
- * tagName: 'marker',
124
- * refY: 5,
125
- * refX: 5,
126
- * markerWidth: 10,
127
- * markerHeight: 10,
128
- * children: [{
129
- * tagName: 'path',
130
- * attrs: {
131
- * d: 'M 0 0 L 10 5 L 0 10 Z',
132
- * strokeWidth: 0
133
- * }
134
- * }]
135
- * }
136
- * }
137
- * ```
138
- *
139
- * @sample highcharts/annotations/custom-markers/
140
- * Define a custom marker for annotations
141
- * @sample highcharts/css/annotations-markers/
142
- * Define markers in a styled mode
143
- *
144
- * @type {Highcharts.Dictionary<Highcharts.SVGAttributes>}
145
- * @since 6.0.0
146
- * @apioption defs
147
- */
148
- var defaultMarkers = {
149
- arrow: {
150
- tagName: 'marker',
151
- render: false,
152
- id: 'arrow',
153
- refY: 5,
154
- refX: 5,
155
- markerWidth: 10,
156
- markerHeight: 10,
157
- children: [{
158
- tagName: 'path',
159
- d: 'M 0 0 L 10 5 L 0 10 Z', // triangle (used as an arrow)
160
- strokeWidth: 0
161
- }]
162
- }
163
- };
164
-
165
- var MarkerMixin = {
166
- markerSetter: function (markerType) {
167
- return function (value) {
168
- this.attr(markerType, 'url(#' + value + ')');
169
- };
170
- }
171
- };
172
-
173
- extend(MarkerMixin, {
174
- markerEndSetter: MarkerMixin.markerSetter('marker-end'),
175
- markerStartSetter: MarkerMixin.markerSetter('marker-start')
176
- });
177
-
178
- H.SVGRenderer.prototype.addMarker = function (id, markerOptions) {
179
- var options = { id: id };
180
-
181
- if (!this.styledMode) {
182
- var attrs = {
183
- stroke: markerOptions.color || 'none',
184
- fill: markerOptions.color || 'rgba(0, 0, 0, 0.75)'
185
- };
186
-
187
- options.children = markerOptions.children.map(function (child) {
188
- return merge(attrs, child);
189
- });
190
- }
191
-
192
- var marker = this.definition(merge({
193
- markerWidth: 20,
194
- markerHeight: 20,
195
- refX: 0,
196
- refY: 0,
197
- orient: 'auto'
198
- }, markerOptions, options));
199
-
200
- marker.id = id;
201
-
202
- return marker;
203
- };
204
-
205
-
206
- /* ************************************************************************** *
207
- *
208
- * MOCK POINT
209
- *
210
- * ************************************************************************** */
211
-
212
- /**
213
- * A trimmed point object which imitates {@link Highchart.Point} class.
214
- * It is created when there is a need of pointing to some chart's position
215
- * using axis values or pixel values
216
- *
217
- * @private
218
- * @class
219
- * @name Highcharts.MockPoint
220
- *
221
- * @param {Highcharts.Chart} chart
222
- * The chart object
223
- *
224
- * @param {Highcharts.MockPointOptionsObject} options
225
- * The options object
226
- */
227
- var MockPoint = H.MockPoint = function (chart, options) {
228
- this.mock = true;
229
- this.series = {
230
- visible: true,
231
- chart: chart,
232
- getPlotBox: seriesPrototype.getPlotBox
233
- };
234
-
235
- // this.plotX
236
- // this.plotY
237
-
238
- /* Those might not exist if a specific axis was not found/defined */
239
- // this.x?
240
- // this.y?
241
-
242
- this.init(chart, options);
243
- };
244
-
245
- /**
246
- * A factory function for creating a mock point object
247
- *
248
- * @function Highcharts.MockPoint#mockPoint
249
- *
250
- * @param {Highcharts.MockPointOptionsObject} mockPointOptions
251
- *
252
- * @return {Highcharts.MockPoint}
253
- * A mock point
254
- */
255
- var mockPoint = H.mockPoint = function (chart, mockPointOptions) {
256
- return new MockPoint(chart, mockPointOptions);
257
- };
258
-
259
- /**
260
- * @private
261
- * @class
262
- * @name Highcharts.MockPoint
263
- */
264
- MockPoint.prototype = {
265
- /**
266
- * Initialisation of the mock point
267
- *
268
- * @function Highcharts.MockPoint#init
269
- *
270
- * @param {Highcharts.Chart} chart
271
- * A chart object to which the mock point is attached
272
- *
273
- * @param {Highcharts.MockPointOptionsObject} options
274
- * A config for the mock point
275
- */
276
- init: function (chart, options) {
277
- var xAxisId = options.xAxis,
278
- xAxis = defined(xAxisId) ?
279
- chart.xAxis[xAxisId] || chart.get(xAxisId) :
280
- null,
281
-
282
- yAxisId = options.yAxis,
283
- yAxis = defined(yAxisId) ?
284
- chart.yAxis[yAxisId] || chart.get(yAxisId) :
285
- null;
286
-
287
-
288
- if (xAxis) {
289
- this.x = options.x;
290
- this.series.xAxis = xAxis;
291
- } else {
292
- this.plotX = options.x;
293
- }
294
-
295
- if (yAxis) {
296
- this.y = options.y;
297
- this.series.yAxis = yAxis;
298
- } else {
299
- this.plotY = options.y;
300
- }
301
- },
302
-
303
- /**
304
- * Update of the point's coordinates (plotX/plotY)
305
- *
306
- * @function Highcharts.MockPoint#translate
307
- */
308
- translate: function () {
309
- var series = this.series,
310
- xAxis = series.xAxis,
311
- yAxis = series.yAxis;
312
-
313
- if (xAxis) {
314
- this.plotX = xAxis.toPixels(this.x, true);
315
- }
316
-
317
- if (yAxis) {
318
- this.plotY = yAxis.toPixels(this.y, true);
319
- }
320
-
321
- this.isInside = this.isInsidePane();
322
- },
323
-
324
- /**
325
- * Returns a box to which an item can be aligned to
326
- *
327
- * @function Highcharts.MockPoint#alignToBox
328
- *
329
- * @param {boolean} [forceTranslate=false]
330
- * Whether to update the point's coordinates
331
- *
332
- * @return {Array<number,number,number,number>}
333
- * A quadruple of numbers which denotes x, y, width and height of
334
- * the box
335
- **/
336
- alignToBox: function (forceTranslate) {
337
- if (forceTranslate) {
338
- this.translate();
339
- }
340
-
341
- var x = this.plotX,
342
- y = this.plotY,
343
- temp;
344
-
345
-
346
- if (this.series.chart.inverted) {
347
- temp = x;
348
- x = y;
349
- y = temp;
350
- }
351
-
352
- return [x, y, 0, 0];
353
- },
354
-
355
- /**
356
- * Returns a label config object -
357
- * the same as Highcharts.Point.prototype.getLabelConfig
358
- *
359
- * @function Highcharts.MockPoint#getLabelConfig
360
- *
361
- * @return {Highcharts.MockLabelOptionsObject}
362
- * Label config object
363
- */
364
- getLabelConfig: function () {
365
- return {
366
- x: this.x,
367
- y: this.y,
368
- point: this
369
- };
370
- },
371
-
372
- isInsidePane: function () {
373
- var plotX = this.plotX,
374
- plotY = this.plotY,
375
- xAxis = this.series.xAxis,
376
- yAxis = this.series.yAxis,
377
- isInside = true;
378
-
379
- if (xAxis) {
380
- isInside = defined(plotX) && plotX >= 0 && plotX <= xAxis.len;
381
- }
382
-
383
- if (yAxis) {
384
- isInside =
385
- isInside &&
386
- defined(plotY) &&
387
- plotY >= 0 && plotY <= yAxis.len;
388
- }
389
-
390
- return isInside;
391
- }
392
- };
393
-
394
-
395
- /* ************************************************************************** *
396
- *
397
- * ANNOTATION
398
- *
399
- * ************************************************************************** */
400
-
401
- H.defaultOptions.annotations = [];
402
-
403
- /**
404
- * An annotation class which serves as a container for items like labels or
405
- * shapes. Created items are positioned on the chart either by linking them to
406
- * existing points or created mock points
407
- *
408
- * @class
409
- * @name Highcharts.Annotation
410
- *
411
- * @param {Highcharts.Chart} chart
412
- * The chart object
413
- *
414
- * @param {Highcharts.AnnotationsOptions} userOptions
415
- * The options object
416
- */
417
- var Annotation = H.Annotation = function (chart, userOptions) {
418
-
419
- /**
420
- * The chart that the annotation belongs to.
421
- *
422
- * @name Highcharts.Annotation#chart
423
- * @type {Highcharts.Chart}
424
- */
425
- this.chart = chart;
426
-
427
- /**
428
- * The array of labels which belong to the annotation.
429
- *
430
- * @name Highcharts.Annotation#labels
431
- * @type {Array<Highcharts.SVGElement>}
432
- */
433
- this.labels = [];
434
-
435
- /**
436
- * The array of shapes which belong to the annotation.
437
- *
438
- * @name Highcharts.Annotation#shapes
439
- * @type {Array<Highcharts.SVGElement>}
440
- */
441
- this.shapes = [];
442
-
443
- /**
444
- * The user options for the annotations.
445
- *
446
- * @name Highcharts.Annotation#userOptions
447
- * @type {Highcharts.AnnotationsOptions}
448
- */
449
- this.userOptions = userOptions;
450
-
451
- /**
452
- * The options for the annotations. It contains user defined options
453
- * merged with the default options.
454
- *
455
- * @name Highcharts.Annotation#options
456
- * @type {Highcharts.AnnotationsOptions}
457
- */
458
- this.options = merge(this.defaultOptions, userOptions);
459
-
460
- /**
461
- * The callback that reports to the overlapping-labels module which
462
- * labels it should account for.
463
- *
464
- * @todo Needs more specific function interface
465
- *
466
- * @private
467
- * @name Highcharts.Annotation#labelCollector
468
- * @type {Function}
469
- */
470
-
471
- /**
472
- * The group element of the annotation.
473
- *
474
- * @private
475
- * @name Highcharts.Annotation#group
476
- * @type {Highcharts.SVGElement}
477
- */
478
-
479
- /**
480
- * The group element of the annotation's shapes.
481
- *
482
- * @private
483
- * @name Highcharts.Annotation#shapesGroup
484
- * @type {Highcharts.SVGElement}
485
- */
486
-
487
- /**
488
- * The group element of the annotation's labels.
489
- *
490
- * @private
491
- * @name Highcharts.Annotation#labelsGroup
492
- * @type {Highcharts.SVGElement}
493
- */
494
-
495
- this.init(chart, userOptions);
496
- };
497
-
498
- Annotation.prototype = {
499
- /**
500
- * Shapes which do not have background - the object is used for proper
501
- * setting of the contrast color
502
- *
503
- * @private
504
- * @name Highcharts.Annotations#shapesWithoutBackground
505
- * @type {Array<string>}
506
- */
507
- shapesWithoutBackground: ['connector'],
508
-
509
- /**
510
- * Returns a map object which allows to map options attributes to element
511
- * attributes.
512
- *
513
- * @private
514
- * @function Highcharts.Annotations#getAttrsMap
515
- *
516
- * @return {object}
517
- */
518
- getAttrsMap: function () {
519
-
520
- var attrsMap = {
521
- zIndex: 'zIndex',
522
- width: 'width',
523
- height: 'height',
524
- borderRadius: 'r',
525
- r: 'r',
526
- padding: 'padding'
527
- };
528
-
529
- if (!this.chart.styledMode) {
530
- extend(attrsMap, {
531
- backgroundColor: 'fill',
532
- borderColor: 'stroke',
533
- borderWidth: 'stroke-width',
534
- dashStyle: 'dashstyle',
535
- strokeWidth: 'stroke-width',
536
- stroke: 'stroke',
537
- fill: 'fill'
538
- });
539
- }
540
- return attrsMap;
541
- },
542
-
543
- /**
544
- * Options for configuring annotations, for example labels, arrows or
545
- * shapes. Annotations can be tied to points, axis coordinates or chart
546
- * pixel coordinates.
547
- *
548
- * @sample highcharts/annotations/basic/
549
- * Basic annotations
550
- * @sample highcharts/demo/annotations/
551
- * Advanced annotations
552
- * @sample highcharts/css/annotations
553
- * Styled mode
554
- * @sample {highstock} stock/annotations/fibonacci-retracements
555
- * Custom annotation, Fibonacci retracement
556
- *
557
- * @type {Array<*>}
558
- * @since 6.0.0
559
- * @optionparent annotations
560
- */
561
- defaultOptions: {
562
- /**
563
- * Sets an ID for an annotation. Can be user later when removing an
564
- * annotation in [Chart#removeAnnotation(id)](
565
- * /class-reference/Highcharts.Chart#removeAnnotation) method.
566
- *
567
- * @type {string}
568
- * @apioption annotations.id
569
- */
570
-
571
- /**
572
- * Whether the annotation is visible.
573
- *
574
- * @sample highcharts/annotations/visible/
575
- * Set annotation visibility
576
- */
577
- visible: true,
578
-
579
- /**
580
- * Allow an annotation to be draggable by a user. Possible
581
- * values are `"x"`, `"xy"`, `"y"` and `""` (disabled).
582
- *
583
- * @sample highcharts/annotations/draggable/
584
- * Annotations draggable: 'xy'
585
- */
586
- draggable: 'xy',
587
-
588
- /**
589
- * Options for annotation's labels. Each label inherits options
590
- * from the labelOptions object. An option from the labelOptions can be
591
- * overwritten by config for a specific label.
592
- */
593
- labelOptions: {
594
-
595
- /**
596
- * The alignment of the annotation's label. If right,
597
- * the right side of the label should be touching the point.
598
- *
599
- * @sample highcharts/annotations/label-position/
600
- * Set labels position
601
- *
602
- * @type {Highcharts.AlignValue}
603
- */
604
- align: 'center',
605
-
606
- /**
607
- * Whether to allow the annotation's labels to overlap.
608
- * To make the labels less sensitive for overlapping,
609
- * the can be set to 0.
610
- *
611
- * @sample highcharts/annotations/tooltip-like/
612
- * Hide overlapping labels
613
- */
614
- allowOverlap: false,
615
-
616
- /**
617
- * The background color or gradient for the annotation's label.
618
- *
619
- * @sample highcharts/annotations/label-presentation/
620
- * Set labels graphic options
621
- *
622
- * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
623
- */
624
- backgroundColor: 'rgba(0, 0, 0, 0.75)',
625
-
626
- /**
627
- * The border color for the annotation's label.
628
- *
629
- * @sample highcharts/annotations/label-presentation/
630
- * Set labels graphic options
631
- *
632
- * @type {Highcharts.ColorString}
633
- */
634
- borderColor: 'black',
635
-
636
- /**
637
- * The border radius in pixels for the annotaiton's label.
638
- *
639
- * @sample highcharts/annotations/label-presentation/
640
- * Set labels graphic options
641
- */
642
- borderRadius: 3,
643
-
644
- /**
645
- * The border width in pixels for the annotation's label
646
- *
647
- * @sample highcharts/annotations/label-presentation/
648
- * Set labels graphic options
649
- */
650
- borderWidth: 1,
651
-
652
- /**
653
- * A class name for styling by CSS.
654
- *
655
- * @sample highcharts/css/annotations
656
- * Styled mode annotations
657
- *
658
- * @since 6.0.5
659
- */
660
- className: '',
661
-
662
- /**
663
- * Whether to hide the annotation's label that is outside the plot
664
- * area.
665
- *
666
- * @sample highcharts/annotations/label-crop-overflow/
667
- * Crop or justify labels
668
- */
669
- crop: false,
670
-
671
- /**
672
- * The label's pixel distance from the point.
673
- *
674
- * @sample highcharts/annotations/label-position/
675
- * Set labels position
676
- *
677
- * @type {number}
678
- * @apioption annotations.labelOptions.distance
679
- */
680
-
681
- /**
682
- * A
683
- * [format](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
684
- * string for the data label.
685
- *
686
- * @see [plotOptions.series.dataLabels.format](plotOptions.series.dataLabels.format.html)
687
- *
688
- * @sample highcharts/annotations/label-text/
689
- * Set labels text
690
- *
691
- * @type {string}
692
- * @apioption annotations.labelOptions.format
693
- */
694
-
695
- /**
696
- * Alias for the format option.
697
- *
698
- * @see [format](annotations.labelOptions.format.html)
699
- *
700
- * @sample highcharts/annotations/label-text/
701
- * Set labels text
702
- *
703
- * @type {string}
704
- * @apioption annotations.labelOptions.text
705
- */
706
-
707
- /**
708
- * Callback JavaScript function to format the annotation's label.
709
- * Note that if a `format` or `text` are defined, the format or text
710
- * take precedence and the formatter is ignored. `This` refers to a
711
- * point object.
712
- *
713
- * @sample highcharts/annotations/label-text/
714
- * Set labels text
715
- *
716
- * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
717
- * @default function () { return defined(this.y) ? this.y : 'Annotation label'; }
718
- */
719
- formatter: function () {
720
- return defined(this.y) ? this.y : 'Annotation label';
721
- },
722
-
723
- /**
724
- * How to handle the annotation's label that flow outside the plot
725
- * area. The justify option aligns the label inside the plot area.
726
- *
727
- * @sample highcharts/annotations/label-crop-overflow/
728
- * Crop or justify labels
729
- *
730
- * @validvalue ["allow", "justify"]
731
- */
732
- overflow: 'justify',
733
-
734
- /**
735
- * When either the borderWidth or the backgroundColor is set,
736
- * this is the padding within the box.
737
- *
738
- * @sample highcharts/annotations/label-presentation/
739
- * Set labels graphic options
740
- */
741
- padding: 5,
742
-
743
- /**
744
- * The shadow of the box. The shadow can be an object configuration
745
- * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
746
- *
747
- * @sample highcharts/annotations/label-presentation/
748
- * Set labels graphic options
749
- *
750
- * @type {boolean|Highcharts.ShadowOptionsObject}
751
- */
752
- shadow: false,
753
-
754
- /**
755
- * The name of a symbol to use for the border around the label.
756
- * Symbols are predefined functions on the Renderer object.
757
- *
758
- * @sample highcharts/annotations/shapes/
759
- * Available shapes for labels
760
- *
761
- * @type {string}
762
- */
763
- shape: 'callout',
764
-
765
- /**
766
- * Styles for the annotation's label.
767
- *
768
- * @see [plotOptions.series.dataLabels.style](plotOptions.series.dataLabels.style.html)
769
- *
770
- * @sample highcharts/annotations/label-presentation/
771
- * Set labels graphic options
772
- *
773
- * @type {Highcharts.CSSObject}
774
- */
775
- style: {
776
- /** @ignore */
777
- fontSize: '11px',
778
- /** @ignore */
779
- fontWeight: 'normal',
780
- /** @ignore */
781
- color: 'contrast'
782
- },
783
-
784
- /**
785
- * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
786
- * to render the annotation's label.
787
- */
788
- useHTML: false,
789
-
790
- /**
791
- * The vertical alignment of the annotation's label.
792
- *
793
- * @sample highcharts/annotations/label-position/
794
- * Set labels position
795
- *
796
- * @type {Highcharts.VerticalAlignValue}
797
- */
798
- verticalAlign: 'bottom',
799
-
800
- /**
801
- * The x position offset of the label relative to the point.
802
- * Note that if a `distance` is defined, the distance takes
803
- * precedence over `x` and `y` options.
804
- *
805
- * @sample highcharts/annotations/label-position/
806
- * Set labels position
807
- */
808
- x: 0,
809
-
810
- /**
811
- * The y position offset of the label relative to the point.
812
- * Note that if a `distance` is defined, the distance takes
813
- * precedence over `x` and `y` options.
814
- *
815
- * @sample highcharts/annotations/label-position/
816
- * Set labels position
817
- */
818
- y: -16
819
- },
820
-
821
- /**
822
- * An array of labels for the annotation. For options that apply to
823
- * multiple labels, they can be added to the
824
- * [labelOptions](annotations.labelOptions.html).
825
- *
826
- * @type {Array<*>}
827
- * @extends annotations.labelOptions
828
- * @apioption annotations.labels
829
- */
830
-
831
- /**
832
- * This option defines the point to which the label will be connected.
833
- * It can be either the point which exists in the series - it is
834
- * referenced by the point's id - or a new point with defined x, y
835
- * properies and optionally axes.
836
- *
837
- * @sample highcharts/annotations/mock-point/
838
- * Attach annotation to a mock point
839
- *
840
- * @type {string|*}
841
- * @apioption annotations.labels.point
842
- */
843
-
844
- /**
845
- * The x position of the point. Units can be either in axis
846
- * or chart pixel coordinates.
847
- *
848
- * @type {number}
849
- * @apioption annotations.labels.point.x
850
- */
851
-
852
- /**
853
- * The y position of the point. Units can be either in axis
854
- * or chart pixel coordinates.
855
- *
856
- * @type {number}
857
- * @apioption annotations.labels.point.y
858
- */
859
-
860
- /**
861
- * This number defines which xAxis the point is connected to. It refers
862
- * to either the axis id or the index of the axis in the xAxis array.
863
- * If the option is not configured or the axis is not found the point's
864
- * x coordinate refers to the chart pixels.
865
- *
866
- * @type {number|string}
867
- * @apioption annotations.labels.point.xAxis
868
- */
869
-
870
- /**
871
- * This number defines which yAxis the point is connected to. It refers
872
- * to either the axis id or the index of the axis in the yAxis array.
873
- * If the option is not configured or the axis is not found the point's
874
- * y coordinate refers to the chart pixels.
875
- *
876
- * @type {number|string}
877
- * @apioption annotations.labels.point.yAxis
878
- */
879
-
880
-
881
- /**
882
- * An array of shapes for the annotation. For options that apply to
883
- * multiple shapes, then can be added to the
884
- * [shapeOptions](annotations.shapeOptions.html).
885
- *
886
- * @type {Array<*>}
887
- * @extends annotations.shapeOptions
888
- * @apioption annotations.shapes
889
- */
890
-
891
- /**
892
- * This option defines the point to which the shape will be connected.
893
- * It can be either the point which exists in the series - it is
894
- * referenced by the point's id - or a new point with defined x, y
895
- * properties and optionally axes.
896
- *
897
- * @extends annotations.labels.point
898
- * @apioption annotations.shapes.point
899
- */
900
-
901
- /**
902
- * An array of points for the shape. This option is available for shapes
903
- * which can use multiple points such as path. A point can be either
904
- * a point object or a point's id.
905
- *
906
- * @see [annotations.shapes.point](annotations.shapes.point.html)
907
- *
908
- * @type {Array<*>}
909
- * @extends annotations.labels.point
910
- * @apioption annotations.shapes.points
911
- */
912
-
913
- /**
914
- * Id of the marker which will be drawn at the final vertex of the path.
915
- * Custom markers can be defined in defs property.
916
- *
917
- * @see [defs.markers](defs.markers.html)
918
- *
919
- * @sample highcharts/annotations/custom-markers/
920
- * Define a custom marker for annotations
921
- *
922
- * @type {string}
923
- * @apioption annotations.shapes.markerEnd
924
- */
925
-
926
- /**
927
- * Id of the marker which will be drawn at the first vertex of the path.
928
- * Custom markers can be defined in defs property.
929
- *
930
- * @see [defs.markers](defs.markers.html)
931
- *
932
- * @sample {highcharts} highcharts/annotations/custom-markers/
933
- * Define a custom marker for annotations
934
- *
935
- * @type {string}
936
- * @apioption annotations.shapes.markerStart
937
- */
938
-
939
-
940
- /**
941
- * Options for annotation's shapes. Each shape inherits options
942
- * from the shapeOptions object. An option from the shapeOptions can be
943
- * overwritten by config for a specific shape.
944
- */
945
- shapeOptions: {
946
-
947
- /**
948
- * The width of the shape.
949
- *
950
- * @sample highcharts/annotations/shape/
951
- * Basic shape annotation
952
- *
953
- * @type {number}
954
- * @apioption annotations.shapeOptions.width
955
- **/
956
-
957
- /**
958
- * The height of the shape.
959
- *
960
- * @sample highcharts/annotations/shape/
961
- * Basic shape annotation
962
- *
963
- * @type {number}
964
- * @apioption annotations.shapeOptions.height
965
- */
966
-
967
- /**
968
- * The color of the shape's stroke.
969
- *
970
- * @sample highcharts/annotations/shape/
971
- * Basic shape annotation
972
- *
973
- * @type {Highcharts.ColorString}
974
- */
975
- stroke: 'rgba(0, 0, 0, 0.75)',
976
-
977
- /**
978
- * The pixel stroke width of the shape.
979
- *
980
- * @sample highcharts/annotations/shape/
981
- * Basic shape annotation
982
- */
983
- strokeWidth: 1,
984
-
985
- /**
986
- * The color of the shape's fill.
987
- *
988
- * @sample highcharts/annotations/shape/
989
- * Basic shape annotation
990
- *
991
- * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
992
- */
993
- fill: 'rgba(0, 0, 0, 0.75)',
994
-
995
- /**
996
- * The type of the shape, e.g. circle or rectangle.
997
- *
998
- * @sample highcharts/annotations/shape/
999
- * Basic shape annotation
1000
- *
1001
- * @type {string}
1002
- * @default 'rect'
1003
- * @apioption annotations.shapeOptions.type
1004
- */
1005
-
1006
- /**
1007
- * The radius of the shape.
1008
- *
1009
- * @sample highcharts/annotations/shape/
1010
- * Basic shape annotation
1011
- */
1012
- r: 0
1013
- },
1014
-
1015
- /**
1016
- * The Z index of the annotation.
1017
- */
1018
- zIndex: 6,
1019
-
1020
- /**
1021
- * Events available in annotations.
1022
- *
1023
- * @type {Object}
1024
- */
1025
- /**
1026
- * Event callback when annotation is added to the chart.
1027
- *
1028
- * @since 7.1.0
1029
- * @apioption annotations.events.add
1030
- */
1031
- /**
1032
- * Event callback when annotation is updated (e.g. drag and
1033
- * droppped or resized by control points).
1034
- *
1035
- * @since 7.1.0
1036
- * @apioption annotations.events.afterUpdate
1037
- */
1038
- /**
1039
- * Event callback when annotation is removed from the chart.
1040
- *
1041
- * @since 7.1.0
1042
- * @apioption annotations.events.remove
1043
- */
1044
- events: {}
1045
- },
1046
-
1047
- /**
1048
- * Initialize the annotation.
1049
- *
1050
- * @function Highcharts.Annotation#init
1051
- */
1052
- init: function () {
1053
- var anno = this;
1054
-
1055
- (this.options.labels || []).forEach(this.initLabel, this);
1056
- (this.options.shapes || []).forEach(this.initShape, this);
1057
-
1058
- this.labelCollector = function () {
1059
- return anno.labels.filter(function (label) {
1060
- return !label.options.allowOverlap;
1061
- });
1062
- };
1063
-
1064
- this.chart.labelCollectors.push(this.labelCollector);
1065
- },
1066
-
1067
- /**
1068
- * Main method for drawing an annotation.
1069
- *
1070
- * @function Highcharts.Annotation#redraw
1071
- */
1072
- redraw: function () {
1073
- if (!this.group) {
1074
- this.render();
1075
- }
1076
-
1077
- this.redrawItems(this.shapes);
1078
- this.redrawItems(this.labels);
1079
- },
1080
-
1081
- /**
1082
- * @private
1083
- * @function Highcharts.Annotation#redrawItems
1084
- *
1085
- * @param {Array<Highcharts.SVGElement>} items
1086
- */
1087
- redrawItems: function (items) {
1088
- var i = items.length;
1089
-
1090
- // needs a backward loop
1091
- // labels/shapes array might be modified due to destruction of the item
1092
- while (i--) {
1093
- this.redrawItem(items[i]);
1094
- }
1095
- },
1096
-
1097
- /**
1098
- * Render the annotation.
1099
- *
1100
- * @function Highcharts.Annotation#render
1101
- */
1102
- render: function () {
1103
- var renderer = this.chart.renderer;
1104
-
1105
- var group = this.group = renderer.g('annotation')
1106
- .attr({
1107
- zIndex: this.options.zIndex,
1108
- visibility: this.options.visible ? 'visible' : 'hidden'
1109
- })
1110
- .add();
1111
-
1112
- this.shapesGroup = renderer.g('annotation-shapes').add(group);
1113
-
1114
- this.labelsGroup = renderer.g('annotation-labels').attr({
1115
- // hideOverlappingLabels requires translation
1116
- translateX: 0,
1117
- translateY: 0
1118
- }).add(group);
1119
-
1120
- this.shapesGroup.clip(this.chart.plotBoxClip);
1121
- },
1122
-
1123
- /**
1124
- * Set the annotation's visibility.
1125
- *
1126
- * @function Highcharts.Annotation#setVisible
1127
- *
1128
- * @param {boolean} [visibility]
1129
- * Whether to show or hide an annotation. If the param is omitted,
1130
- * the annotation's visibility is toggled.
1131
- */
1132
- setVisible: function (visibility) {
1133
- var options = this.options,
1134
- visible = pick(visibility, !options.visible);
1135
-
1136
- this.group.attr({
1137
- visibility: visible ? 'visible' : 'hidden'
1138
- });
1139
-
1140
- options.visible = visible;
1141
- },
1142
-
1143
-
1144
- /**
1145
- * Destroy the annotation. This function does not touch the chart
1146
- * that the annotation belongs to (all annotations are kept in
1147
- * the chart.annotations array) - it is recommended to use
1148
- * {@link Highcharts.Chart#removeAnnotation} instead.
1149
- *
1150
- * @function Highcharts.Annotation#destroy
1151
- */
1152
- destroy: function () {
1153
- var chart = this.chart,
1154
- destroyItem = function (item) {
1155
- item.destroy();
1156
- };
1157
-
1158
- erase(this.chart.labelCollectors, this.labelCollector);
1159
-
1160
- this.labels.forEach(destroyItem);
1161
- this.shapes.forEach(destroyItem);
1162
-
1163
- destroyObjectProperties(this, chart);
1164
- },
1165
-
1166
-
1167
- /* ********************************************************************** *
1168
- *
1169
- * ITEM SECTION
1170
- * Contains methods for handling a single item in an annotation
1171
- *
1172
- * ********************************************************************** */
1173
-
1174
- /**
1175
- * Initialisation of a single shape
1176
- *
1177
- * @private
1178
- * @function Highcharts.Annotation#initShape
1179
- *
1180
- * @param {Highcharts.AnnotationsShapesOptions} shapeOptions
1181
- * A confg object for a single shape
1182
- */
1183
- initShape: function (shapeOptions) {
1184
- var renderer = this.chart.renderer,
1185
- options = merge(this.options.shapeOptions, shapeOptions),
1186
- attr = this.attrsFromOptions(options),
1187
-
1188
- type = renderer[options.type] ? options.type : 'rect',
1189
- shape = renderer[type](0, -9e9, 0, 0);
1190
-
1191
- shape.points = [];
1192
- shape.type = type;
1193
- shape.options = options;
1194
- shape.itemType = 'shape';
1195
-
1196
- if (type === 'path') {
1197
- extend(shape, {
1198
- markerStartSetter: MarkerMixin.markerStartSetter,
1199
- markerEndSetter: MarkerMixin.markerEndSetter,
1200
- markerStart: MarkerMixin.markerStart,
1201
- markerEnd: MarkerMixin.markerEnd
1202
- });
1203
- }
1204
-
1205
- shape.attr(attr);
1206
-
1207
-
1208
- if (options.className) {
1209
- shape.addClass(options.className);
1210
- }
1211
-
1212
- this.shapes.push(shape);
1213
- },
1214
-
1215
- /**
1216
- * Initialisation of a single label
1217
- *
1218
- * @private
1219
- * @function Highcharts.Annotation#initLabel
1220
- *
1221
- * @param {Highcharts.AnnotationsLabelsOptions} labelOptions
1222
- */
1223
- initLabel: function (labelOptions) {
1224
- var options = merge(this.options.labelOptions, labelOptions),
1225
- attr = this.attrsFromOptions(options),
1226
-
1227
- label = this.chart.renderer.label(
1228
- '',
1229
- 0, -9e9,
1230
- options.shape,
1231
- null,
1232
- null,
1233
- options.useHTML,
1234
- null,
1235
- 'annotation-label'
1236
- );
1237
-
1238
- label.points = [];
1239
- label.options = options;
1240
- label.itemType = 'label';
1241
-
1242
- // Labelrank required for hideOverlappingLabels()
1243
- label.labelrank = options.labelrank;
1244
- label.annotation = this;
1245
-
1246
- label.attr(attr);
1247
-
1248
- if (!this.chart.styledMode) {
1249
- var style = options.style;
1250
-
1251
- if (style.color === 'contrast') {
1252
- style.color = this.chart.renderer.getContrast(
1253
- this.shapesWithoutBackground.indexOf(options.shape) > -1 ?
1254
- '#FFFFFF' :
1255
- options.backgroundColor
1256
- );
1257
- }
1258
- label.css(style).shadow(options.shadow);
1259
- }
1260
-
1261
- if (options.className) {
1262
- label.addClass(options.className);
1263
- }
1264
-
1265
-
1266
- this.labels.push(label);
1267
- },
1268
-
1269
- /**
1270
- * Redrawing a single item
1271
- *
1272
- * @private
1273
- * @function Highcharts.Annotation#redrawItem
1274
- *
1275
- * @param {Highcharts.SVGElement} item
1276
- */
1277
- redrawItem: function (item) {
1278
- var points = this.linkPoints(item),
1279
- itemOptions = item.options,
1280
- text,
1281
- time = this.chart.time,
1282
- hasVisiblePoints = false;
1283
-
1284
- if (!points.length) {
1285
- this.destroyItem(item);
1286
-
1287
- } else {
1288
- if (!item.parentGroup) {
1289
- this.renderItem(item);
1290
- }
1291
-
1292
- if (item.itemType === 'label') {
1293
- text = itemOptions.format || itemOptions.text;
1294
- item.attr({
1295
- text: text ?
1296
- format(text, points[0].getLabelConfig(), time) :
1297
- itemOptions.formatter.call(points[0])
1298
- });
1299
- }
1300
-
1301
- // Hide or show annotaiton attached to points (#9481)
1302
- points.forEach(function (point) {
1303
- if (
1304
- point.series.visible !== false &&
1305
- point.visible !== false
1306
- ) {
1307
- hasVisiblePoints = true;
1308
- }
1309
- });
1310
-
1311
- if (!hasVisiblePoints) {
1312
- item.hide();
1313
-
1314
- } else if (item.visibility === 'hidden') {
1315
- item.show();
1316
- }
1317
-
1318
-
1319
- if (item.type === 'path') {
1320
- this.redrawPath(item);
1321
-
1322
- } else {
1323
- this.alignItem(item, !item.placed);
1324
- }
1325
- }
1326
- },
1327
-
1328
- /**
1329
- * Destroing a single item
1330
- *
1331
- * @private
1332
- * @function Highcharts.Annotation#destroyItem
1333
- *
1334
- * @param {Highcharts.SVGElement} item
1335
- */
1336
- destroyItem: function (item) {
1337
- // erase from shapes or labels array
1338
- erase(this[item.itemType + 's'], item);
1339
- item.destroy();
1340
- },
1341
-
1342
- /**
1343
- * Returns a point object
1344
- *
1345
- * @private
1346
- * @function Highcharts.Annotation#pointItem
1347
- *
1348
- * @param {object} pointOptions
1349
- *
1350
- * @param {Highcharts.MockPoint|Highcharts.Point} point
1351
- *
1352
- * @return {Highcharts.MockPoint|Highcharts.Point|null}
1353
- * If the point is found/exists returns this point, otherwise null
1354
- */
1355
- pointItem: function (pointOptions, point) {
1356
- if (!point || point.series === null) {
1357
- if (isObject(pointOptions)) {
1358
- point = mockPoint(this.chart, pointOptions);
1359
-
1360
- } else if (isString(pointOptions)) {
1361
- point = this.chart.get(pointOptions) || null;
1362
- }
1363
- }
1364
-
1365
- return point;
1366
- },
1367
-
1368
- /**
1369
- * Linking item with the point or points and returning an array of linked
1370
- * points.
1371
- *
1372
- * @private
1373
- * @function Highcharts.Annotation#linkPoints
1374
- *
1375
- * @param {Highcharts.SVGElement} item
1376
- *
1377
- * @return {Highcharts.MockPoint|Highcharts.Point|Array<Highcharts.MockPoint|Highcharts.Point>}
1378
- */
1379
- linkPoints: function (item) {
1380
- var pointsOptions = (
1381
- item.options.points ||
1382
- (item.options.point && H.splat(item.options.point))
1383
- ),
1384
- points = item.points,
1385
- len = pointsOptions && pointsOptions.length,
1386
- i,
1387
- point;
1388
-
1389
- for (i = 0; i < len; i++) {
1390
- point = this.pointItem(pointsOptions[i], points[i]);
1391
-
1392
- if (!point) {
1393
- return (item.points = []);
1394
- }
1395
-
1396
- points[i] = point;
1397
- }
1398
-
1399
- return points;
1400
- },
1401
-
1402
- /**
1403
- * Aligning the item and setting its anchor
1404
- *
1405
- * @private
1406
- * @function Highcharts.Annotation#alignItem
1407
- *
1408
- * @param {Highcharts.SVGElement} item
1409
- *
1410
- * @param {boolean} [isNew=false]
1411
- * If the label is re-positioned (is not new) it is animated
1412
- */
1413
- alignItem: function (item, isNew) {
1414
- var anchor = this.itemAnchor(item, item.points[0]),
1415
- attrs = this.itemPosition(item, anchor);
1416
-
1417
- if (attrs) {
1418
- item.alignAttr = attrs;
1419
- item.placed = true;
1420
-
1421
- attrs.anchorX = anchor.absolutePosition.x;
1422
- attrs.anchorY = anchor.absolutePosition.y;
1423
-
1424
- item[isNew ? 'attr' : 'animate'](attrs);
1425
-
1426
- } else {
1427
- item.placed = false;
1428
-
1429
- item.attr({
1430
- x: 0,
1431
- y: -9e9
1432
- });
1433
- }
1434
- },
1435
-
1436
- redrawPath: function (pathItem, isNew) {
1437
- var points = pathItem.points,
1438
- strokeWidth = pathItem['stroke-width'] || 1,
1439
- d = ['M'],
1440
- pointIndex = 0,
1441
- dIndex = 0,
1442
- len = points && points.length,
1443
- crispSegmentIndex,
1444
- anchor,
1445
- point,
1446
- showPath;
1447
-
1448
- if (len) {
1449
- do {
1450
- point = points[pointIndex];
1451
-
1452
- anchor = this.itemAnchor(pathItem, point).absolutePosition;
1453
- d[++dIndex] = anchor.x;
1454
- d[++dIndex] = anchor.y;
1455
-
1456
- // Crisping line, it might be replaced with
1457
- // Renderer.prototype.crispLine but it requires creating many
1458
- // temporary arrays
1459
- crispSegmentIndex = dIndex % 5;
1460
- if (crispSegmentIndex === 0) {
1461
- if (d[crispSegmentIndex + 1] === d[crispSegmentIndex + 4]) {
1462
- d[crispSegmentIndex + 1] = d[crispSegmentIndex + 4] =
1463
- Math.round(d[crispSegmentIndex + 1]) -
1464
- (strokeWidth % 2 / 2);
1465
- }
1466
-
1467
- if (d[crispSegmentIndex + 2] === d[crispSegmentIndex + 5]) {
1468
- d[crispSegmentIndex + 2] = d[crispSegmentIndex + 5] =
1469
- Math.round(d[crispSegmentIndex + 2]) +
1470
- (strokeWidth % 2 / 2);
1471
- }
1472
- }
1473
-
1474
- if (pointIndex < len - 1) {
1475
- d[++dIndex] = 'L';
1476
- }
1477
-
1478
- showPath = point.series.visible;
1479
-
1480
- } while (++pointIndex < len && showPath);
1481
- }
1482
-
1483
-
1484
- if (showPath) {
1485
- pathItem[isNew ? 'attr' : 'animate']({
1486
- d: d
1487
- });
1488
-
1489
- } else {
1490
- pathItem.attr({
1491
- d: 'M 0 ' + -9e9
1492
- });
1493
- }
1494
-
1495
- pathItem.placed = showPath;
1496
- },
1497
-
1498
- renderItem: function (item) {
1499
- item.add(
1500
- item.itemType === 'label' ?
1501
- this.labelsGroup :
1502
- this.shapesGroup
1503
- );
1504
-
1505
- this.setItemMarkers(item);
1506
- },
1507
-
1508
- setItemMarkers: function (item) {
1509
- var itemOptions = item.options,
1510
- chart = this.chart,
1511
- defs = chart.options.defs,
1512
- fill = itemOptions.fill,
1513
- color = defined(fill) && fill !== 'none' ?
1514
- fill :
1515
- itemOptions.stroke,
1516
-
1517
-
1518
- setMarker = function (markerType) {
1519
- var markerId = itemOptions[markerType],
1520
- def,
1521
- predefinedMarker,
1522
- key,
1523
- marker;
1524
-
1525
- if (markerId) {
1526
- for (key in defs) {
1527
- def = defs[key];
1528
- if (markerId === def.id && def.tagName === 'marker') {
1529
- predefinedMarker = def;
1530
- break;
1531
- }
1532
- }
1533
-
1534
- if (predefinedMarker) {
1535
- marker = item[markerType] = chart.renderer.addMarker(
1536
- (itemOptions.id || uniqueKey()) + '-' +
1537
- predefinedMarker.id,
1538
- merge(predefinedMarker, { color: color })
1539
- );
1540
-
1541
- item.attr(markerType, marker.attr('id'));
1542
- }
1543
- }
1544
- };
1545
-
1546
- ['markerStart', 'markerEnd'].forEach(setMarker);
1547
- },
1548
-
1549
- /**
1550
- * Returns object which denotes anchor position - relative and absolute
1551
- *
1552
- * @private
1553
- * @function Highcharts.Annotation#itemAnchor
1554
- *
1555
- * @param {Highcharts.SVGElement} item
1556
- *
1557
- * @param {Highcharts.MockPoint|Highcharts.Point} point
1558
- *
1559
- * @return {Highcharts.AnnotationAnchorObject}
1560
- */
1561
- itemAnchor: function (item, point) {
1562
- var plotBox = point.series.getPlotBox(),
1563
-
1564
- box = point.mock ?
1565
- point.alignToBox(true) :
1566
- tooltipPrototype.getAnchor.call({
1567
- chart: this.chart
1568
- }, point),
1569
-
1570
- anchor = {
1571
- x: box[0],
1572
- y: box[1],
1573
- height: box[2] || 0,
1574
- width: box[3] || 0
1575
- };
1576
-
1577
- return {
1578
- relativePosition: anchor,
1579
- absolutePosition: merge(anchor, {
1580
- x: anchor.x + plotBox.translateX,
1581
- y: anchor.y + plotBox.translateY
1582
- })
1583
- };
1584
- },
1585
-
1586
- /**
1587
- * Returns the item position
1588
- *
1589
- * @private
1590
- * @function Highcharts.Annotation#itemPosition
1591
- *
1592
- * @param {Highcharts.SVGElement} item
1593
- *
1594
- * @param {Highcharts.AnnotationAnchorObject} anchor
1595
- *
1596
- * @return {Highcharts.AnnotationAnchorPositionObject}
1597
- */
1598
- itemPosition: function (item, anchor) {
1599
- var chart = this.chart,
1600
- point = item.points[0],
1601
- itemOptions = item.options,
1602
- anchorAbsolutePosition = anchor.absolutePosition,
1603
- anchorRelativePosition = anchor.relativePosition,
1604
- itemPosition,
1605
- alignTo,
1606
- itemPosRelativeX,
1607
- itemPosRelativeY,
1608
-
1609
- showItem =
1610
- point.series.visible &&
1611
- MockPoint.prototype.isInsidePane.call(point);
1612
-
1613
- if (showItem) {
1614
-
1615
- if (defined(itemOptions.distance) || itemOptions.positioner) {
1616
- itemPosition = (
1617
- itemOptions.positioner ||
1618
- tooltipPrototype.getPosition
1619
- ).call(
1620
- {
1621
- chart: chart,
1622
- distance: pick(itemOptions.distance, 16)
1623
- },
1624
- item.width,
1625
- item.height,
1626
- {
1627
- plotX: anchorRelativePosition.x,
1628
- plotY: anchorRelativePosition.y,
1629
- negative: point.negative,
1630
- ttBelow: point.ttBelow,
1631
- h: anchorRelativePosition.height ||
1632
- anchorRelativePosition.width
1633
- }
1634
- );
1635
-
1636
- } else {
1637
- alignTo = {
1638
- x: anchorAbsolutePosition.x,
1639
- y: anchorAbsolutePosition.y,
1640
- width: 0,
1641
- height: 0
1642
- };
1643
-
1644
- itemPosition = this.alignedPosition(
1645
- extend(itemOptions, {
1646
- width: item.width,
1647
- height: item.height
1648
- }),
1649
- alignTo
1650
- );
1651
-
1652
- if (item.options.overflow === 'justify') {
1653
- itemPosition = this.alignedPosition(
1654
- this.justifiedOptions(item, itemOptions, itemPosition),
1655
- alignTo
1656
- );
1657
- }
1658
- }
1659
-
1660
-
1661
- if (itemOptions.crop) {
1662
- itemPosRelativeX = itemPosition.x - chart.plotLeft;
1663
- itemPosRelativeY = itemPosition.y - chart.plotTop;
1664
-
1665
- showItem =
1666
- chart.isInsidePlot(itemPosRelativeX, itemPosRelativeY) &&
1667
- chart.isInsidePlot(
1668
- itemPosRelativeX + item.width,
1669
- itemPosRelativeY + item.height
1670
- );
1671
- }
1672
- }
1673
-
1674
- return showItem ? itemPosition : null;
1675
- },
1676
-
1677
- /**
1678
- * Returns new aligned position based alignment options and box to align to.
1679
- * It is almost a one-to-one copy from SVGElement.prototype.align
1680
- * except it does not use and mutate an element
1681
- *
1682
- * @private
1683
- * @function Highcharts.Annotation#alignedPosition
1684
- *
1685
- * @param {Highcharts.AlignObject} alignOptions
1686
- *
1687
- * @param {Highcharts.BBoxObject} box
1688
- *
1689
- * @return {Highcharts.AlignObject}
1690
- */
1691
- alignedPosition: function (alignOptions, box) {
1692
- var align = alignOptions.align,
1693
- vAlign = alignOptions.verticalAlign,
1694
- x = (box.x || 0) + (alignOptions.x || 0),
1695
- y = (box.y || 0) + (alignOptions.y || 0),
1696
-
1697
- alignFactor,
1698
- vAlignFactor;
1699
-
1700
- if (align === 'right') {
1701
- alignFactor = 1;
1702
- } else if (align === 'center') {
1703
- alignFactor = 2;
1704
- }
1705
- if (alignFactor) {
1706
- x += (box.width - (alignOptions.width || 0)) / alignFactor;
1707
- }
1708
-
1709
- if (vAlign === 'bottom') {
1710
- vAlignFactor = 1;
1711
- } else if (vAlign === 'middle') {
1712
- vAlignFactor = 2;
1713
- }
1714
- if (vAlignFactor) {
1715
- y += (box.height - (alignOptions.height || 0)) / vAlignFactor;
1716
- }
1717
-
1718
- return {
1719
- x: Math.round(x),
1720
- y: Math.round(y)
1721
- };
1722
- },
1723
-
1724
- /**
1725
- * Returns new alignment options for a label if the label is outside the
1726
- * plot area. It is almost a one-to-one copy from
1727
- * Series.prototype.justifyDataLabel except it does not mutate the label and
1728
- * it works with absolute instead of relative position.
1729
- *
1730
- * @private
1731
- * @function Highcharts.Annotation#justifiedOptions
1732
- *
1733
- * @param {Highcharts.SVGElement} label
1734
- *
1735
- * @param {Highcharts.AlignObject} alignOptions
1736
- *
1737
- * @param {Highcharts.SVGAttributes} alignAttr
1738
- *
1739
- * @return {Highcharts.AlignObject}
1740
- */
1741
- justifiedOptions: function (label, alignOptions, alignAttr) {
1742
- var chart = this.chart,
1743
- align = alignOptions.align,
1744
- verticalAlign = alignOptions.verticalAlign,
1745
- padding = label.box ? 0 : (label.padding || 0),
1746
- bBox = label.getBBox(),
1747
- off,
1748
-
1749
- options = {
1750
- align: align,
1751
- verticalAlign: verticalAlign,
1752
- x: alignOptions.x,
1753
- y: alignOptions.y,
1754
- width: label.width,
1755
- height: label.height
1756
- },
1757
-
1758
- x = alignAttr.x - chart.plotLeft,
1759
- y = alignAttr.y - chart.plotTop;
1760
-
1761
- // Off left
1762
- off = x + padding;
1763
- if (off < 0) {
1764
- if (align === 'right') {
1765
- options.align = 'left';
1766
- } else {
1767
- options.x = -off;
1768
- }
1769
- }
1770
-
1771
- // Off right
1772
- off = x + bBox.width - padding;
1773
- if (off > chart.plotWidth) {
1774
- if (align === 'left') {
1775
- options.align = 'right';
1776
- } else {
1777
- options.x = chart.plotWidth - off;
1778
- }
1779
- }
1780
-
1781
- // Off top
1782
- off = y + padding;
1783
- if (off < 0) {
1784
- if (verticalAlign === 'bottom') {
1785
- options.verticalAlign = 'top';
1786
- } else {
1787
- options.y = -off;
1788
- }
1789
- }
1790
-
1791
- // Off bottom
1792
- off = y + bBox.height - padding;
1793
- if (off > chart.plotHeight) {
1794
- if (verticalAlign === 'top') {
1795
- options.verticalAlign = 'bottom';
1796
- } else {
1797
- options.y = chart.plotHeight - off;
1798
- }
1799
- }
1800
-
1801
- return options;
1802
- },
1803
-
1804
-
1805
- /**
1806
- * Utility function for mapping item's options to element's attribute
1807
- *
1808
- * @private
1809
- * @function Highcharts.Annotation#attrsFromOptions
1810
- *
1811
- * @param {object} options
1812
- *
1813
- * @return {object}
1814
- * Mapped options
1815
- */
1816
- attrsFromOptions: function (options) {
1817
- var map = this.getAttrsMap(),
1818
- attrs = {},
1819
- key,
1820
- mappedKey;
1821
-
1822
- for (key in options) {
1823
- mappedKey = map[key];
1824
- if (mappedKey) {
1825
- attrs[mappedKey] = options[key];
1826
- }
1827
- }
1828
-
1829
- return attrs;
1830
- }
1831
- };
1832
-
1833
- /* ************************************************************************** *
1834
- *
1835
- * EXTENDING CHART PROTOTYPE
1836
- *
1837
- * ************************************************************************** */
1838
-
1839
- H.extend(chartPrototype, {
1840
- /**
1841
- * Add an annotation to the chart after render time.
1842
- *
1843
- * @function Highcharts.Chart#addAnnotation
1844
- *
1845
- * @param {Highcharts.AnnotationsOptions} options
1846
- * The series options for the new, detailed series.
1847
- *
1848
- * @return {Highcharts.Annotation}
1849
- * The newly generated annotation.
1850
- */
1851
- addAnnotation: function (userOptions, redraw) {
1852
- var annotation = new Annotation(this, userOptions);
1853
-
1854
- this.annotations.push(annotation);
1855
- this.options.annotations.push(userOptions);
1856
-
1857
- if (pick(redraw, true)) {
1858
- annotation.redraw();
1859
- }
1860
-
1861
- return annotation;
1862
- },
1863
-
1864
- /**
1865
- * Remove an annotation from the chart.
1866
- *
1867
- * @function Highcharts.Chart#removeAnnotation
1868
- *
1869
- * @param {string} id
1870
- * The annotation's id.
1871
- */
1872
- removeAnnotation: function (id) {
1873
- var annotations = this.annotations,
1874
- annotation = find(annotations, function (annotation) {
1875
- return annotation.options.id === id;
1876
- });
1877
-
1878
- if (annotation) {
1879
- erase(this.options.annotations, annotation.userOptions);
1880
- erase(annotations, annotation);
1881
- annotation.destroy();
1882
- }
1883
- },
1884
-
1885
- drawAnnotations: function () {
1886
- var clip = this.plotBoxClip,
1887
- plotBox = this.plotBox;
1888
-
1889
- if (clip) {
1890
- clip.attr(plotBox);
1891
- } else {
1892
- this.plotBoxClip = this.renderer.clipRect(plotBox);
1893
- }
1894
-
1895
- this.annotations.forEach(function (annotation) {
1896
- annotation.redraw();
1897
- });
1898
- }
1899
- });
1900
-
1901
-
1902
- chartPrototype.callbacks.push(function (chart) {
1903
- chart.annotations = [];
1904
-
1905
- chart.options.annotations.forEach(function (annotationOptions) {
1906
- chart.annotations.push(
1907
- new Annotation(chart, annotationOptions)
1908
- );
1909
- });
1910
-
1911
- chart.drawAnnotations();
1912
- addEvent(chart, 'redraw', chart.drawAnnotations);
1913
- addEvent(chart, 'destroy', function () {
1914
- var plotBoxClip = chart.plotBoxClip;
1915
-
1916
- if (plotBoxClip && plotBoxClip.destroy) {
1917
- plotBoxClip.destroy();
1918
- }
1919
- });
1920
- });
1921
-
1922
-
1923
- addEvent(H.Chart, 'afterGetContainer', function () {
1924
- this.options.defs = merge(defaultMarkers, this.options.defs || {});
1925
-
1926
- if (!this.styledMode) {
1927
- objectEach(this.options.defs, function (def) {
1928
- if (def.tagName === 'marker' && def.render !== false) {
1929
- this.renderer.addMarker(def.id, def);
1930
- }
1931
- }, this);
1932
- }
1933
- });
1934
-
1935
-
1936
- /* ************************************************************************** */
1937
-
1938
- // General symbol definition for labels with connector
1939
- H.SVGRenderer.prototype.symbols.connector = function (x, y, w, h, options) {
1940
- var anchorX = options && options.anchorX,
1941
- anchorY = options && options.anchorY,
1942
- path,
1943
- yOffset,
1944
- lateral = w / 2;
1945
-
1946
- if (isNumber(anchorX) && isNumber(anchorY)) {
1947
-
1948
- path = ['M', anchorX, anchorY];
1949
-
1950
- // Prefer 45 deg connectors
1951
- yOffset = y - anchorY;
1952
- if (yOffset < 0) {
1953
- yOffset = -h - yOffset;
1954
- }
1955
- if (yOffset < w) {
1956
- lateral = anchorX < x + (w / 2) ? yOffset : w - yOffset;
1957
- }
1958
-
1959
- // Anchor below label
1960
- if (anchorY > y + h) {
1961
- path.push('L', x + lateral, y + h);
1962
-
1963
- // Anchor above label
1964
- } else if (anchorY < y) {
1965
- path.push('L', x + lateral, y);
1966
-
1967
- // Anchor left of label
1968
- } else if (anchorX < x) {
1969
- path.push('L', x, y + h / 2);
1970
-
1971
- // Anchor right of label
1972
- } else if (anchorX > x + w) {
1973
- path.push('L', x + w, y + h / 2);
1974
- }
1975
- }
1976
- return path || [];
1977
- };