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,9 +1,14 @@
1
1
  /* *
2
- * (c) 2010-2019 Torstein Honsi
3
2
  *
4
- * License: www.highcharts.com/license
5
- */
6
-
3
+ * (c) 2010-2019 Torstein Honsi
4
+ *
5
+ * License: www.highcharts.com/license
6
+ *
7
+ * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
8
+ *
9
+ * */
10
+ 'use strict';
11
+ import Highcharts from './Globals.js';
7
12
  /**
8
13
  * Gets fired when the legend item belonging to a point is clicked. The default
9
14
  * action is to toggle the visibility of the point. This can be prevented by
@@ -17,29 +22,27 @@
17
22
  * @param {Highcharts.PointLegendItemClickEventObject} event
18
23
  * The event that occured.
19
24
  */
20
-
21
25
  /**
22
26
  * Information about the legend click event.
23
27
  *
24
28
  * @interface Highcharts.PointLegendItemClickEventObject
25
- *//**
26
- * Related browser event.
27
- * @name Highcharts.PointLegendItemClickEventObject#browserEvent
28
- * @type {Highcharts.PointerEvent}
29
- *//**
30
- * Prevent the default action of toggle the visibility of the point.
31
- * @name Highcharts.PointLegendItemClickEventObject#preventDefault
32
- * @type {Function}
33
- *//**
34
- * Related point.
35
- * @name Highcharts.PointLegendItemClickEventObject#target
36
- * @type {Highcharts.Point}
37
- *//**
38
- * Event type.
39
- * @name Highcharts.PointLegendItemClickEventObject#type
40
- * @type {"legendItemClick"}
41
- */
42
-
29
+ */ /**
30
+ * Related browser event.
31
+ * @name Highcharts.PointLegendItemClickEventObject#browserEvent
32
+ * @type {Highcharts.PointerEvent}
33
+ */ /**
34
+ * Prevent the default action of toggle the visibility of the point.
35
+ * @name Highcharts.PointLegendItemClickEventObject#preventDefault
36
+ * @type {Function}
37
+ */ /**
38
+ * Related point.
39
+ * @name Highcharts.PointLegendItemClickEventObject#target
40
+ * @type {Highcharts.Point}
41
+ */ /**
42
+ * Event type.
43
+ * @name Highcharts.PointLegendItemClickEventObject#type
44
+ * @type {"legendItemClick"}
45
+ */
43
46
  /**
44
47
  * Gets fired when the legend item belonging to a series is clicked. The default
45
48
  * action is to toggle the visibility of the series. This can be prevented by
@@ -53,50 +56,30 @@
53
56
  * @param {Highcharts.SeriesLegendItemClickEventObject} event
54
57
  * The event that occured.
55
58
  */
56
-
57
59
  /**
58
60
  * Information about the legend click event.
59
61
  *
60
62
  * @interface Highcharts.SeriesLegendItemClickEventObject
61
- *//**
62
- * Related browser event.
63
- * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
64
- * @type {Highcharts.PointerEvent}
65
- *//**
66
- * Prevent the default action of toggle the visibility of the series.
67
- * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
68
- * @type {Function}
69
- *//**
70
- * Related series.
71
- * @name Highcharts.SeriesLegendItemClickEventObject#target
72
- * @type {Highcharts.Series}
73
- *//**
74
- * Event type.
75
- * @name Highcharts.SeriesLegendItemClickEventObject#type
76
- * @type {"legendItemClick"}
77
- */
78
-
79
- 'use strict';
80
-
81
- import Highcharts from './Globals.js';
63
+ */ /**
64
+ * Related browser event.
65
+ * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
66
+ * @type {Highcharts.PointerEvent}
67
+ */ /**
68
+ * Prevent the default action of toggle the visibility of the series.
69
+ * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
70
+ * @type {Function}
71
+ */ /**
72
+ * Related series.
73
+ * @name Highcharts.SeriesLegendItemClickEventObject#target
74
+ * @type {Highcharts.Series}
75
+ */ /**
76
+ * Event type.
77
+ * @name Highcharts.SeriesLegendItemClickEventObject#type
78
+ * @type {"legendItemClick"}
79
+ */
82
80
  import './Utilities.js';
83
-
84
- var H = Highcharts,
85
-
86
- addEvent = H.addEvent,
87
- css = H.css,
88
- discardElement = H.discardElement,
89
- defined = H.defined,
90
- fireEvent = H.fireEvent,
91
- isFirefox = H.isFirefox,
92
- marginNames = H.marginNames,
93
- merge = H.merge,
94
- pick = H.pick,
95
- setAnimation = H.setAnimation,
96
- stableSort = H.stableSort,
97
- win = H.win,
98
- wrap = H.wrap;
99
-
81
+ var H = Highcharts, addEvent = H.addEvent, css = H.css, discardElement = H.discardElement, defined = H.defined, fireEvent = H.fireEvent, isFirefox = H.isFirefox, marginNames = H.marginNames, merge = H.merge, pick = H.pick, setAnimation = H.setAnimation, stableSort = H.stableSort, win = H.win, wrap = H.wrap;
82
+ /* eslint-disable no-invalid-this, valid-jsdoc */
100
83
  /**
101
84
  * The overview of the chart's series. The legend object is instanciated
102
85
  * internally in the chart constructor, and is available from the `chart.legend`
@@ -114,9 +97,7 @@ var H = Highcharts,
114
97
  Highcharts.Legend = function (chart, options) {
115
98
  this.init(chart, options);
116
99
  };
117
-
118
100
  Highcharts.Legend.prototype = {
119
-
120
101
  /**
121
102
  * Initialize the legend.
122
103
  *
@@ -128,9 +109,10 @@ Highcharts.Legend.prototype = {
128
109
  *
129
110
  * @param {Highcharts.LegendOptions} options
130
111
  * Legend options.
112
+ *
113
+ * @return {void}
131
114
  */
132
115
  init: function (chart, options) {
133
-
134
116
  /**
135
117
  * Chart of this legend.
136
118
  *
@@ -139,44 +121,33 @@ Highcharts.Legend.prototype = {
139
121
  * @type {Highcharts.Chart}
140
122
  */
141
123
  this.chart = chart;
142
-
143
124
  this.setOptions(options);
144
-
145
125
  if (options.enabled) {
146
-
147
126
  // Render it
148
127
  this.render();
149
-
150
128
  // move checkboxes
151
129
  addEvent(this.chart, 'endResize', function () {
152
130
  this.legend.positionCheckboxes();
153
131
  });
154
-
155
132
  if (this.proximate) {
156
- this.unchartrender = addEvent(
157
- this.chart,
158
- 'render',
159
- function () {
160
- this.legend.proximatePositions();
161
- this.legend.positionItems();
162
- }
163
- );
164
- } else if (this.unchartrender) {
133
+ this.unchartrender = addEvent(this.chart, 'render', function () {
134
+ this.legend.proximatePositions();
135
+ this.legend.positionItems();
136
+ });
137
+ }
138
+ else if (this.unchartrender) {
165
139
  this.unchartrender();
166
140
  }
167
141
  }
168
142
  },
169
-
170
143
  /**
171
144
  * @private
172
145
  * @function Highcharts.Legend#setOptions
173
- *
174
146
  * @param {Highcharts.LegendOptions} options
147
+ * @return {void}
175
148
  */
176
149
  setOptions: function (options) {
177
-
178
150
  var padding = pick(options.padding, 8);
179
-
180
151
  /**
181
152
  * Legend options.
182
153
  *
@@ -185,24 +156,17 @@ Highcharts.Legend.prototype = {
185
156
  * @type {Highcharts.LegendOptions}
186
157
  */
187
158
  this.options = options;
188
-
189
159
  if (!this.chart.styledMode) {
190
160
  this.itemStyle = options.itemStyle;
191
- this.itemHiddenStyle = merge(
192
- this.itemStyle,
193
- options.itemHiddenStyle
194
- );
161
+ this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
195
162
  }
196
-
197
163
  this.itemMarginTop = options.itemMarginTop || 0;
198
164
  this.padding = padding;
199
165
  this.initialItemY = padding - 5; // 5 is pixels above the text
200
166
  this.symbolWidth = pick(options.symbolWidth, 16);
201
167
  this.pages = [];
202
168
  this.proximate = options.layout === 'proximate' && !this.chart.inverted;
203
-
204
169
  },
205
-
206
170
  /**
207
171
  * Update the legend with new options. Equivalent to running `chart.update`
208
172
  * with a legend configuration option.
@@ -221,21 +185,20 @@ Highcharts.Legend.prototype = {
221
185
  * false and call {@link Chart#redraw} after.
222
186
  * Whether to redraw the chart.
223
187
  *
188
+ * @return {void}
189
+ *
224
190
  * @fires Highcharts.Legends#event:afterUpdate
225
191
  */
226
192
  update: function (options, redraw) {
227
193
  var chart = this.chart;
228
-
229
194
  this.setOptions(merge(true, this.options, options));
230
195
  this.destroy();
231
196
  chart.isDirtyLegend = chart.isDirtyBox = true;
232
197
  if (pick(redraw, true)) {
233
198
  chart.redraw();
234
199
  }
235
-
236
200
  fireEvent(this, 'afterUpdate');
237
201
  },
238
-
239
202
  /**
240
203
  * Set the colors for the legend item.
241
204
  *
@@ -248,28 +211,19 @@ Highcharts.Legend.prototype = {
248
211
  * @param {boolean} [visible=false]
249
212
  * Dimmed or colored
250
213
  *
214
+ * @return {void}
215
+ *
251
216
  * @todo
252
217
  * Make events official: Fires the event `afterColorizeItem`.
253
218
  */
254
219
  colorizeItem: function (item, visible) {
255
- item.legendGroup[visible ? 'removeClass' : 'addClass'](
256
- 'highcharts-legend-item-hidden'
257
- );
258
-
220
+ item.legendGroup[visible ? 'removeClass' : 'addClass']('highcharts-legend-item-hidden');
259
221
  if (!this.chart.styledMode) {
260
- var legend = this,
261
- options = legend.options,
262
- legendItem = item.legendItem,
263
- legendLine = item.legendLine,
264
- legendSymbol = item.legendSymbol,
265
- hiddenColor = legend.itemHiddenStyle.color,
266
- textColor = visible ? options.itemStyle.color : hiddenColor,
267
- symbolColor = visible ?
268
- (item.color || hiddenColor) :
269
- hiddenColor,
270
- markerOptions = item.options && item.options.marker,
271
- symbolAttr = { fill: symbolColor };
272
-
222
+ var legend = this, options = legend.options, legendItem = item.legendItem, legendLine = item.legendLine, legendSymbol = item.legendSymbol, hiddenColor = legend.itemHiddenStyle.color, textColor = visible ?
223
+ options.itemStyle.color :
224
+ hiddenColor, symbolColor = visible ?
225
+ (item.color || hiddenColor) :
226
+ hiddenColor, markerOptions = item.options && item.options.marker, symbolAttr = { fill: symbolColor };
273
227
  if (legendItem) {
274
228
  legendItem.css({
275
229
  fill: textColor,
@@ -279,9 +233,7 @@ Highcharts.Legend.prototype = {
279
233
  if (legendLine) {
280
234
  legendLine.attr({ stroke: symbolColor });
281
235
  }
282
-
283
236
  if (legendSymbol) {
284
-
285
237
  // Apply marker options
286
238
  if (markerOptions && legendSymbol.isMarker) { // #585
287
239
  symbolAttr = item.pointAttribs();
@@ -290,29 +242,24 @@ Highcharts.Legend.prototype = {
290
242
  symbolAttr.stroke = symbolAttr.fill = hiddenColor;
291
243
  }
292
244
  }
293
-
294
245
  legendSymbol.attr(symbolAttr);
295
246
  }
296
247
  }
297
-
298
248
  fireEvent(this, 'afterColorizeItem', { item: item, visible: visible });
299
249
  },
300
-
301
250
  /**
302
251
  * @private
303
252
  * @function Highcharts.Legend#positionItems
253
+ * @return {void}
304
254
  */
305
255
  positionItems: function () {
306
-
307
256
  // Now that the legend width and height are established, put the items
308
257
  // in the final position
309
258
  this.allItems.forEach(this.positionItem, this);
310
-
311
259
  if (!this.chart.isResizing) {
312
260
  this.positionCheckboxes();
313
261
  }
314
262
  },
315
-
316
263
  /**
317
264
  * Position the legend item.
318
265
  *
@@ -321,18 +268,11 @@ Highcharts.Legend.prototype = {
321
268
  *
322
269
  * @param {Highcharts.Point|Highcharts.Series} item
323
270
  * The item to position
271
+ *
272
+ * @return {void}
324
273
  */
325
274
  positionItem: function (item) {
326
- var legend = this,
327
- options = legend.options,
328
- symbolPadding = options.symbolPadding,
329
- ltr = !options.rtl,
330
- legendItemPos = item._legendItemPos,
331
- itemX = legendItemPos[0],
332
- itemY = legendItemPos[1],
333
- checkbox = item.checkbox,
334
- legendGroup = item.legendGroup;
335
-
275
+ var legend = this, options = legend.options, symbolPadding = options.symbolPadding, ltr = !options.rtl, legendItemPos = item._legendItemPos, itemX = legendItemPos[0], itemY = legendItemPos[1], checkbox = item.checkbox, legendGroup = item.legendGroup;
336
276
  if (legendGroup && legendGroup.element) {
337
277
  legendGroup[defined(legendGroup.translateY) ? 'animate' : 'attr']({
338
278
  translateX: ltr ?
@@ -341,13 +281,11 @@ Highcharts.Legend.prototype = {
341
281
  translateY: itemY
342
282
  });
343
283
  }
344
-
345
284
  if (checkbox) {
346
285
  checkbox.x = itemX;
347
286
  checkbox.y = itemY;
348
287
  }
349
288
  },
350
-
351
289
  /**
352
290
  * Destroy a single legend item, used internally on removing series items.
353
291
  *
@@ -359,40 +297,39 @@ Highcharts.Legend.prototype = {
359
297
  */
360
298
  destroyItem: function (item) {
361
299
  var checkbox = item.checkbox;
362
-
363
300
  // destroy SVG elements
364
- ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(
365
- function (key) {
366
- if (item[key]) {
367
- item[key] = item[key].destroy();
368
- }
301
+ ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(function (key) {
302
+ if (item[key]) {
303
+ item[key] = item[key].destroy();
369
304
  }
370
- );
371
-
305
+ });
372
306
  if (checkbox) {
373
307
  discardElement(item.checkbox);
374
308
  }
375
309
  },
376
-
377
310
  /**
378
311
  * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
379
312
  * must be called after destruction.
380
313
  *
381
314
  * @private
382
315
  * @function Highcharts.Legend#destroy
316
+ * @return {void}
383
317
  */
384
318
  destroy: function () {
319
+ /**
320
+ * @private
321
+ * @param {string} key
322
+ * @return {void}
323
+ */
385
324
  function destroyItems(key) {
386
325
  if (this[key]) {
387
326
  this[key] = this[key].destroy();
388
327
  }
389
328
  }
390
-
391
329
  // Destroy items
392
330
  this.getAllItems().forEach(function (item) {
393
331
  ['legendItem', 'legendGroup'].forEach(destroyItems, item);
394
332
  });
395
-
396
333
  // Destroy legend elements
397
334
  [
398
335
  'clipRect',
@@ -406,25 +343,19 @@ Highcharts.Legend.prototype = {
406
343
  ].forEach(destroyItems, this);
407
344
  this.display = null; // Reset in .render on update.
408
345
  },
409
-
410
346
  /**
411
347
  * Position the checkboxes after the width is determined.
412
348
  *
413
349
  * @private
414
350
  * @function Highcharts.Legend#positionCheckboxes
351
+ * @return {void}
415
352
  */
416
353
  positionCheckboxes: function () {
417
- var alignAttr = this.group && this.group.alignAttr,
418
- translateY,
419
- clipHeight = this.clipHeight || this.legendHeight,
420
- titleHeight = this.titleHeight;
421
-
354
+ var alignAttr = this.group && this.group.alignAttr, translateY, clipHeight = this.clipHeight || this.legendHeight, titleHeight = this.titleHeight;
422
355
  if (alignAttr) {
423
356
  translateY = alignAttr.translateY;
424
357
  this.allItems.forEach(function (item) {
425
- var checkbox = item.checkbox,
426
- top;
427
-
358
+ var checkbox = item.checkbox, top;
428
359
  if (checkbox) {
429
360
  top = translateY + titleHeight + checkbox.y +
430
361
  (this.scrollOffset || 0) + 3;
@@ -432,10 +363,8 @@ Highcharts.Legend.prototype = {
432
363
  left: (alignAttr.translateX + item.checkboxOffset +
433
364
  checkbox.x - 20) + 'px',
434
365
  top: top + 'px',
435
- display: this.proximate || (
436
- top > translateY - 6 &&
437
- top < translateY + clipHeight - 6
438
- ) ?
366
+ display: this.proximate || (top > translateY - 6 &&
367
+ top < translateY + clipHeight - 6) ?
439
368
  '' :
440
369
  'none'
441
370
  });
@@ -443,20 +372,15 @@ Highcharts.Legend.prototype = {
443
372
  }, this);
444
373
  }
445
374
  },
446
-
447
375
  /**
448
376
  * Render the legend title on top of the legend.
449
377
  *
450
378
  * @private
451
379
  * @function Highcharts.Legend#renderTitle
380
+ * @return {void}
452
381
  */
453
382
  renderTitle: function () {
454
- var options = this.options,
455
- padding = this.padding,
456
- titleOptions = options.title,
457
- titleHeight = 0,
458
- bBox;
459
-
383
+ var options = this.options, padding = this.padding, titleOptions = options.title, titleHeight = 0, bBox;
460
384
  if (titleOptions.text) {
461
385
  if (!this.title) {
462
386
  /**
@@ -466,33 +390,19 @@ Highcharts.Legend.prototype = {
466
390
  * @name Highcharts.Legend#title
467
391
  * @type {Highcharts.SVGElement}
468
392
  */
469
- this.title = this.chart.renderer.label(
470
- titleOptions.text,
471
- padding - 3,
472
- padding - 4,
473
- null,
474
- null,
475
- null,
476
- options.useHTML,
477
- null,
478
- 'legend-title'
479
- )
393
+ this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, options.useHTML, null, 'legend-title')
480
394
  .attr({ zIndex: 1 });
481
-
482
395
  if (!this.chart.styledMode) {
483
396
  this.title.css(titleOptions.style);
484
397
  }
485
-
486
398
  this.title.add(this.group);
487
399
  }
488
-
489
400
  // Set the max title width (#7253)
490
401
  if (!titleOptions.width) {
491
402
  this.title.css({
492
403
  width: this.maxLegendWidth + 'px'
493
404
  });
494
405
  }
495
-
496
406
  bBox = this.title.getBBox();
497
407
  titleHeight = bBox.height;
498
408
  this.offsetWidth = bBox.width; // #1717
@@ -500,7 +410,6 @@ Highcharts.Legend.prototype = {
500
410
  }
501
411
  this.titleHeight = titleHeight;
502
412
  },
503
-
504
413
  /**
505
414
  * Set the legend item text.
506
415
  *
@@ -508,17 +417,17 @@ Highcharts.Legend.prototype = {
508
417
  *
509
418
  * @param {Highcharts.Point|Highcharts.Series} item
510
419
  * The item for which to update the text in the legend.
420
+ *
421
+ * @return {void}
511
422
  */
512
423
  setText: function (item) {
513
424
  var options = this.options;
514
-
515
425
  item.legendItem.attr({
516
426
  text: options.labelFormat ?
517
427
  H.format(options.labelFormat, item, this.chart.time) :
518
428
  options.labelFormatter.call(item)
519
429
  });
520
430
  },
521
-
522
431
  /**
523
432
  * Render a single specific legend item. Called internally from the `render`
524
433
  * function.
@@ -528,126 +437,88 @@ Highcharts.Legend.prototype = {
528
437
  *
529
438
  * @param {Highcharts.Point|Highcharts.Series} item
530
439
  * The item to render.
440
+ *
441
+ * @return {void}
531
442
  */
532
443
  renderItem: function (item) {
533
- var legend = this,
534
- chart = legend.chart,
535
- renderer = chart.renderer,
536
- options = legend.options,
537
- horizontal = options.layout === 'horizontal',
538
- symbolWidth = legend.symbolWidth,
539
- symbolPadding = options.symbolPadding,
540
- itemStyle = legend.itemStyle,
541
- itemHiddenStyle = legend.itemHiddenStyle,
542
- itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
543
- ltr = !options.rtl,
544
- bBox,
545
- li = item.legendItem,
546
- isSeries = !item.series,
547
- series = !isSeries && item.series.drawLegendSymbol ?
548
- item.series :
549
- item,
550
- seriesOptions = series.options,
551
- showCheckbox = legend.createCheckboxForItem &&
552
- seriesOptions &&
553
- seriesOptions.showCheckbox,
554
- // full width minus text width
555
- itemExtraWidth = symbolWidth + symbolPadding + itemDistance +
556
- (showCheckbox ? 20 : 0),
557
- useHTML = options.useHTML,
558
- itemClassName = item.options.className;
559
-
444
+ var legend = this, chart = legend.chart, renderer = chart.renderer, options = legend.options, horizontal = options.layout === 'horizontal', symbolWidth = legend.symbolWidth, symbolPadding = options.symbolPadding, itemStyle = legend.itemStyle, itemHiddenStyle = legend.itemHiddenStyle, itemDistance = horizontal ? pick(options.itemDistance, 20) : 0, ltr = !options.rtl, bBox, li = item.legendItem, isSeries = !item.series, series = !isSeries && item.series.drawLegendSymbol ?
445
+ item.series :
446
+ item, seriesOptions = series.options, showCheckbox = legend.createCheckboxForItem &&
447
+ seriesOptions &&
448
+ seriesOptions.showCheckbox,
449
+ // full width minus text width
450
+ itemExtraWidth = symbolWidth + symbolPadding +
451
+ itemDistance + (showCheckbox ? 20 : 0), useHTML = options.useHTML, itemClassName = item.options.className;
560
452
  if (!li) { // generate it once, later move it
561
-
562
453
  // Generate the group box, a group to hold the symbol and text. Text
563
454
  // is to be appended in Legend class.
564
455
  item.legendGroup = renderer.g('legend-item')
565
- .addClass(
566
- 'highcharts-' + series.type + '-series ' +
567
- 'highcharts-color-' + item.colorIndex +
568
- (itemClassName ? ' ' + itemClassName : '') +
569
- (isSeries ? ' highcharts-series-' + item.index : '')
570
- )
456
+ .addClass('highcharts-' + series.type + '-series ' +
457
+ 'highcharts-color-' + item.colorIndex +
458
+ (itemClassName ? ' ' + itemClassName : '') +
459
+ (isSeries ?
460
+ ' highcharts-series-' + item.index :
461
+ ''))
571
462
  .attr({ zIndex: 1 })
572
463
  .add(legend.scrollGroup);
573
-
574
464
  // Generate the list item text and add it to the group
575
- item.legendItem = li = renderer.text(
576
- '',
577
- ltr ? symbolWidth + symbolPadding : -symbolPadding,
578
- legend.baseline || 0,
579
- useHTML
580
- );
581
-
465
+ item.legendItem = li = renderer.text('', ltr ?
466
+ symbolWidth + symbolPadding :
467
+ -symbolPadding, legend.baseline || 0, useHTML);
582
468
  if (!chart.styledMode) {
583
469
  // merge to prevent modifying original (#1021)
584
- li.css(merge(item.visible ? itemStyle : itemHiddenStyle));
470
+ li.css(merge(item.visible ?
471
+ itemStyle :
472
+ itemHiddenStyle));
585
473
  }
586
-
587
- li.attr({
474
+ li
475
+ .attr({
588
476
  align: ltr ? 'left' : 'right',
589
477
  zIndex: 2
590
478
  })
591
479
  .add(item.legendGroup);
592
-
593
480
  // Get the baseline for the first item - the font size is equal for
594
481
  // all
595
482
  if (!legend.baseline) {
596
- legend.fontMetrics = renderer.fontMetrics(
597
- chart.styledMode ? 12 : itemStyle.fontSize,
598
- li
599
- );
483
+ legend.fontMetrics = renderer.fontMetrics(chart.styledMode ? 12 : itemStyle.fontSize, li);
600
484
  legend.baseline =
601
485
  legend.fontMetrics.f + 3 + legend.itemMarginTop;
602
486
  li.attr('y', legend.baseline);
603
487
  }
604
-
605
488
  // Draw the legend symbol inside the group box
606
- legend.symbolHeight = options.symbolHeight || legend.fontMetrics.f;
489
+ legend.symbolHeight =
490
+ options.symbolHeight || legend.fontMetrics.f;
607
491
  series.drawLegendSymbol(legend, item);
608
-
609
492
  if (legend.setItemEvents) {
610
493
  legend.setItemEvents(item, li, useHTML);
611
494
  }
612
-
613
495
  }
614
-
615
496
  // Add the HTML checkbox on top
616
497
  if (showCheckbox && !item.checkbox) {
617
498
  legend.createCheckboxForItem(item);
618
499
  }
619
-
620
500
  // Colorize the items
621
501
  legend.colorizeItem(item, item.visible);
622
-
623
502
  // Take care of max width and text overflow (#6659)
624
503
  if (chart.styledMode || !itemStyle.width) {
625
504
  li.css({
626
- width: (
627
- options.itemWidth ||
505
+ width: (options.itemWidth ||
628
506
  legend.widthOption ||
629
- chart.spacingBox.width
630
- ) - itemExtraWidth
507
+ chart.spacingBox.width) - itemExtraWidth
631
508
  });
632
509
  }
633
-
634
510
  // Always update the text
635
511
  legend.setText(item);
636
-
637
512
  // calculate the positions for the next line
638
513
  bBox = li.getBBox();
639
-
640
514
  item.itemWidth = item.checkboxOffset =
641
515
  options.itemWidth ||
642
- item.legendItemWidth ||
643
- bBox.width + itemExtraWidth;
516
+ item.legendItemWidth ||
517
+ bBox.width + itemExtraWidth;
644
518
  legend.maxItemWidth = Math.max(legend.maxItemWidth, item.itemWidth);
645
519
  legend.totalItemWidth += item.itemWidth;
646
- legend.itemHeight = item.itemHeight = Math.round(
647
- item.legendItemHeight || bBox.height || legend.symbolHeight
648
- );
520
+ legend.itemHeight = item.itemHeight = Math.round(item.legendItemHeight || bBox.height || legend.symbolHeight);
649
521
  },
650
-
651
522
  /**
652
523
  * Get the position of the item in the layout. We now know the
653
524
  * maxItemWidth from the previous loop.
@@ -656,72 +527,46 @@ Highcharts.Legend.prototype = {
656
527
  * @function Highcharts.Legend#layoutItem
657
528
  *
658
529
  * @param {Highcharts.Point|Highcharts.Series} item
530
+ *
531
+ * @return {void}
659
532
  */
660
533
  layoutItem: function (item) {
661
-
662
- var options = this.options,
663
- padding = this.padding,
664
- horizontal = options.layout === 'horizontal',
665
- itemHeight = item.itemHeight,
666
- itemMarginBottom = options.itemMarginBottom || 0,
667
- itemMarginTop = this.itemMarginTop,
668
- itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
669
- maxLegendWidth = this.maxLegendWidth,
670
- itemWidth = (
671
- options.alignColumns &&
672
- this.totalItemWidth > maxLegendWidth
673
- ) ?
674
- this.maxItemWidth :
675
- item.itemWidth;
676
-
534
+ var options = this.options, padding = this.padding, horizontal = options.layout === 'horizontal', itemHeight = item.itemHeight, itemMarginBottom = options.itemMarginBottom || 0, itemMarginTop = this.itemMarginTop, itemDistance = horizontal ? pick(options.itemDistance, 20) : 0, maxLegendWidth = this.maxLegendWidth, itemWidth = (options.alignColumns &&
535
+ this.totalItemWidth > maxLegendWidth) ?
536
+ this.maxItemWidth :
537
+ item.itemWidth;
677
538
  // If the item exceeds the width, start a new line
678
- if (
679
- horizontal &&
680
- this.itemX - padding + itemWidth > maxLegendWidth
681
- ) {
539
+ if (horizontal &&
540
+ this.itemX - padding + itemWidth > maxLegendWidth) {
682
541
  this.itemX = padding;
683
542
  if (this.lastLineHeight) { // Not for the first line (#10167)
684
- this.itemY += (
685
- itemMarginTop +
543
+ this.itemY += (itemMarginTop +
686
544
  this.lastLineHeight +
687
- itemMarginBottom
688
- );
545
+ itemMarginBottom);
689
546
  }
690
547
  this.lastLineHeight = 0; // reset for next line (#915, #3976)
691
548
  }
692
-
693
549
  // Set the edge positions
694
550
  this.lastItemY = itemMarginTop + this.itemY + itemMarginBottom;
695
- this.lastLineHeight = Math.max( // #915
696
- itemHeight,
697
- this.lastLineHeight
698
- );
699
-
551
+ this.lastLineHeight = Math.max(// #915
552
+ itemHeight, this.lastLineHeight);
700
553
  // cache the position of the newly generated or reordered items
701
554
  item._legendItemPos = [this.itemX, this.itemY];
702
-
703
555
  // advance
704
556
  if (horizontal) {
705
557
  this.itemX += itemWidth;
706
-
707
- } else {
708
- this.itemY += itemMarginTop + itemHeight + itemMarginBottom;
558
+ }
559
+ else {
560
+ this.itemY +=
561
+ itemMarginTop + itemHeight + itemMarginBottom;
709
562
  this.lastLineHeight = itemHeight;
710
563
  }
711
-
712
564
  // the width of the widest item
713
- this.offsetWidth = this.widthOption || Math.max(
714
- (
715
- horizontal ? this.itemX - padding - (item.checkbox ?
716
- // decrease by itemDistance only when no checkbox #4853
717
- 0 :
718
- itemDistance
719
- ) : itemWidth
720
- ) + padding,
721
- this.offsetWidth
722
- );
565
+ this.offsetWidth = this.widthOption || Math.max((horizontal ? this.itemX - padding - (item.checkbox ?
566
+ // decrease by itemDistance only when no checkbox #4853
567
+ 0 :
568
+ itemDistance) : itemWidth) + padding, this.offsetWidth);
723
569
  },
724
-
725
570
  /**
726
571
  * Get all items, which is one item per series for most series and one
727
572
  * item per point for pie series and its derivatives.
@@ -729,7 +574,7 @@ Highcharts.Legend.prototype = {
729
574
  * @private
730
575
  * @function Highcharts.Legend#getAllItems
731
576
  *
732
- * @return {Array<Highcharts.Point|Highcharts.Series>}
577
+ * @return {Array<(Highcharts.Point|Highcharts.Series)>}
733
578
  * The current items in the legend.
734
579
  *
735
580
  * @fires Highcharts.Legend#event:afterGetAllItems
@@ -739,35 +584,22 @@ Highcharts.Legend.prototype = {
739
584
  */
740
585
  getAllItems: function () {
741
586
  var allItems = [];
742
-
743
587
  this.chart.series.forEach(function (series) {
744
588
  var seriesOptions = series && series.options;
745
-
746
589
  // Handle showInLegend. If the series is linked to another series,
747
590
  // defaults to false.
748
- if (series && pick(
749
- seriesOptions.showInLegend,
750
- !defined(seriesOptions.linkedTo) ? undefined : false, true
751
- )) {
752
-
591
+ if (series && pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? undefined : false, true)) {
753
592
  // Use points or series for the legend item depending on
754
593
  // legendType
755
- allItems = allItems.concat(
756
- series.legendItems ||
757
- (
758
- seriesOptions.legendType === 'point' ?
759
- series.data :
760
- series
761
- )
762
- );
594
+ allItems = allItems.concat(series.legendItems ||
595
+ (seriesOptions.legendType === 'point' ?
596
+ series.data :
597
+ series));
763
598
  }
764
599
  });
765
-
766
600
  fireEvent(this, 'afterGetAllItems', { allItems: allItems });
767
-
768
601
  return allItems;
769
602
  },
770
-
771
603
  /**
772
604
  * Get a short, three letter string reflecting the alignment and layout.
773
605
  *
@@ -779,19 +611,15 @@ Highcharts.Legend.prototype = {
779
611
  */
780
612
  getAlignment: function () {
781
613
  var options = this.options;
782
-
783
614
  // Use the first letter of each alignment option in order to detect
784
615
  // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
785
616
  if (this.proximate) {
786
617
  return options.align.charAt(0) + 'tv';
787
618
  }
788
- return options.floating ? '' : (
789
- options.align.charAt(0) +
619
+ return options.floating ? '' : (options.align.charAt(0) +
790
620
  options.verticalAlign.charAt(0) +
791
- options.layout.charAt(0)
792
- );
621
+ options.layout.charAt(0));
793
622
  },
794
-
795
623
  /**
796
624
  * Adjust the chart margins by reserving space for the legend on only one
797
625
  * side of the chart. If the position is set to a corner, top or bottom is
@@ -799,22 +627,16 @@ Highcharts.Legend.prototype = {
799
627
  *
800
628
  * @private
801
629
  * @function Highcharts.Legend#adjustMargins
802
- *
803
630
  * @param {Array<number>} margin
804
- *
805
- * @param {number} spacing
631
+ * @param {Array<number>} spacing
632
+ * @return {void}
806
633
  */
807
634
  adjustMargins: function (margin, spacing) {
808
- var chart = this.chart,
809
- options = this.options,
810
- alignment = this.getAlignment(),
811
- titleMargin = chart.options.title.margin !== undefined ?
812
- chart.titleOffset +
813
- chart.options.title.margin :
814
- 0;
815
-
635
+ var chart = this.chart, options = this.options, alignment = this.getAlignment(), titleMargin = chart.options.title.margin !== undefined ?
636
+ chart.titleOffset +
637
+ chart.options.title.margin :
638
+ 0;
816
639
  if (alignment) {
817
-
818
640
  ([
819
641
  /(lth|ct|rth)/,
820
642
  /(rtv|rm|rbv)/,
@@ -822,70 +644,46 @@ Highcharts.Legend.prototype = {
822
644
  /(lbv|lm|ltv)/
823
645
  ]).forEach(function (alignments, side) {
824
646
  if (alignments.test(alignment) && !defined(margin[side])) {
825
-
826
647
  // Now we have detected on which side of the chart we should
827
648
  // reserve space for the legend
828
- chart[marginNames[side]] = Math.max(
829
- chart[marginNames[side]],
830
- (
831
- chart.legend[
832
- (side + 1) % 2 ? 'legendHeight' : 'legendWidth'
833
- ] +
834
- [1, -1, -1, 1][side] * options[
835
- (side % 2) ? 'x' : 'y'
836
- ] +
837
- pick(options.margin, 12) +
838
- spacing[side] +
839
- (
840
- side === 0 &&
841
- (chart.titleOffset === 0 ? 0 : titleMargin)
842
- ) // #7428, #7894
843
- )
844
- );
649
+ chart[marginNames[side]] = Math.max(chart[marginNames[side]], (chart.legend[(side + 1) % 2 ? 'legendHeight' : 'legendWidth'] +
650
+ [1, -1, -1, 1][side] * options[(side % 2) ? 'x' : 'y'] +
651
+ pick(options.margin, 12) +
652
+ spacing[side] +
653
+ (side === 0 &&
654
+ (chart.titleOffset === 0 ? 0 : titleMargin)) // #7428, #7894
655
+ ));
845
656
  }
846
657
  });
847
658
  }
848
659
  },
849
-
850
660
  /**
851
661
  * @private
852
662
  * @function Highcharts.Legend#proximatePositions
663
+ * @return {void}
853
664
  */
854
665
  proximatePositions: function () {
855
- var chart = this.chart,
856
- boxes = [],
857
- alignLeft = this.options.align === 'left';
858
-
666
+ var chart = this.chart, boxes = [], alignLeft = this.options.align === 'left';
859
667
  this.allItems.forEach(function (item) {
860
- var lastPoint,
861
- height,
862
- useFirstPoint = alignLeft,
863
- target,
864
- top;
865
-
668
+ var lastPoint, height, useFirstPoint = alignLeft, target, top;
866
669
  if (item.yAxis && item.points) {
867
-
868
670
  if (item.xAxis.options.reversed) {
869
671
  useFirstPoint = !useFirstPoint;
870
672
  }
871
- lastPoint = H.find(
872
- useFirstPoint ?
873
- item.points :
874
- item.points.slice(0).reverse(),
875
- function (item) {
876
- return H.isNumber(item.plotY);
877
- }
878
- );
673
+ lastPoint = H.find(useFirstPoint ?
674
+ item.points :
675
+ item.points.slice(0).reverse(), function (item) {
676
+ return H.isNumber(item.plotY);
677
+ });
879
678
  height = item.legendGroup.getBBox().height;
880
-
881
679
  top = item.yAxis.top - chart.plotTop;
882
680
  if (item.visible) {
883
681
  target = lastPoint ? lastPoint.plotY : item.yAxis.height;
884
682
  target += top - 0.3 * height;
885
- } else {
683
+ }
684
+ else {
886
685
  target = top + item.yAxis.height;
887
686
  }
888
-
889
687
  boxes.push({
890
688
  target: target,
891
689
  size: height,
@@ -898,9 +696,7 @@ Highcharts.Legend.prototype = {
898
696
  box.item._legendItemPos[1] =
899
697
  chart.plotTop - chart.spacing[0] + box.pos;
900
698
  });
901
-
902
699
  },
903
-
904
700
  /**
905
701
  * Render the legend. This method can be called both before and after
906
702
  * `chart.render`. If called after, it will only rearrange items instead
@@ -909,39 +705,22 @@ Highcharts.Legend.prototype = {
909
705
  *
910
706
  * @private
911
707
  * @function Highcharts.Legend#render
708
+ * @return {void}
912
709
  */
913
710
  render: function () {
914
- var legend = this,
915
- chart = legend.chart,
916
- renderer = chart.renderer,
917
- legendGroup = legend.group,
918
- allItems,
919
- display,
920
- legendWidth,
921
- legendHeight,
922
- box = legend.box,
923
- options = legend.options,
924
- padding = legend.padding,
925
- alignTo,
926
- allowedWidth,
927
- y;
928
-
711
+ var legend = this, chart = legend.chart, renderer = chart.renderer, legendGroup = legend.group, allItems, display, legendWidth, legendHeight, box = legend.box, options = legend.options, padding = legend.padding, alignTo, allowedWidth, y;
929
712
  legend.itemX = padding;
930
713
  legend.itemY = legend.initialItemY;
931
714
  legend.offsetWidth = 0;
932
715
  legend.lastItemY = 0;
933
- legend.widthOption = H.relativeLength(
934
- options.width,
935
- chart.spacingBox.width - padding
936
- );
937
-
716
+ legend.widthOption = H.relativeLength(options.width, chart.spacingBox.width - padding);
938
717
  // Compute how wide the legend is allowed to be
939
- allowedWidth = chart.spacingBox.width - 2 * padding - options.x;
718
+ allowedWidth =
719
+ chart.spacingBox.width - 2 * padding - options.x;
940
720
  if (['rm', 'lm'].indexOf(legend.getAlignment().substring(0, 2)) > -1) {
941
721
  allowedWidth /= 2;
942
722
  }
943
723
  legend.maxLegendWidth = legend.widthOption || allowedWidth;
944
-
945
724
  if (!legendGroup) {
946
725
  /**
947
726
  * SVG group of the legend.
@@ -959,34 +738,28 @@ Highcharts.Legend.prototype = {
959
738
  legend.scrollGroup = renderer.g()
960
739
  .add(legend.contentGroup);
961
740
  }
962
-
963
741
  legend.renderTitle();
964
-
965
742
  // add each series or point
966
743
  allItems = legend.getAllItems();
967
-
968
744
  // sort by legendIndex
969
745
  stableSort(allItems, function (a, b) {
970
746
  return ((a.options && a.options.legendIndex) || 0) -
971
747
  ((b.options && b.options.legendIndex) || 0);
972
748
  });
973
-
974
749
  // reversed legend
975
750
  if (options.reversed) {
976
751
  allItems.reverse();
977
752
  }
978
-
979
753
  /**
980
754
  * All items for the legend, which is an array of series for most series
981
755
  * and an array of points for pie series and its derivatives.
982
756
  *
983
757
  * @readonly
984
758
  * @name Highcharts.Legend#allItems
985
- * @type {Array<Highcharts.Point|Highcharts.Series>}
759
+ * @type {Array<(Highcharts.Point|Highcharts.Series)>}
986
760
  */
987
761
  legend.allItems = allItems;
988
762
  legend.display = display = !!allItems.length;
989
-
990
763
  // Render the items. First we run a loop to set the text and properties
991
764
  // and read all the bounding boxes. The next loop computes the item
992
765
  // positions based on the bounding boxes.
@@ -996,14 +769,12 @@ Highcharts.Legend.prototype = {
996
769
  legend.itemHeight = 0;
997
770
  allItems.forEach(legend.renderItem, legend);
998
771
  allItems.forEach(legend.layoutItem, legend);
999
-
1000
772
  // Get the box
1001
773
  legendWidth = (legend.widthOption || legend.offsetWidth) + padding;
1002
774
  legendHeight = legend.lastItemY + legend.lastLineHeight +
1003
775
  legend.titleHeight;
1004
776
  legendHeight = legend.handleOverflow(legendHeight);
1005
777
  legendHeight += padding;
1006
-
1007
778
  // Draw the border and/or background
1008
779
  if (!box) {
1009
780
  /**
@@ -1016,189 +787,140 @@ Highcharts.Legend.prototype = {
1016
787
  legend.box = box = renderer.rect()
1017
788
  .addClass('highcharts-legend-box')
1018
789
  .attr({
1019
- r: options.borderRadius
1020
- })
790
+ r: options.borderRadius
791
+ })
1021
792
  .add(legendGroup);
1022
793
  box.isNew = true;
1023
794
  }
1024
-
1025
795
  // Presentational
1026
796
  if (!chart.styledMode) {
1027
797
  box
1028
798
  .attr({
1029
- stroke: options.borderColor,
1030
- 'stroke-width': options.borderWidth || 0,
1031
- fill: options.backgroundColor || 'none'
1032
- })
799
+ stroke: options.borderColor,
800
+ 'stroke-width': options.borderWidth || 0,
801
+ fill: options.backgroundColor || 'none'
802
+ })
1033
803
  .shadow(options.shadow);
1034
804
  }
1035
-
1036
805
  if (legendWidth > 0 && legendHeight > 0) {
1037
- box[box.isNew ? 'attr' : 'animate'](
1038
- box.crisp.call({}, { // #7260
1039
- x: 0,
1040
- y: 0,
1041
- width: legendWidth,
1042
- height: legendHeight
1043
- }, box.strokeWidth())
1044
- );
806
+ box[box.isNew ? 'attr' : 'animate'](box.crisp.call({}, {
807
+ x: 0,
808
+ y: 0,
809
+ width: legendWidth,
810
+ height: legendHeight
811
+ }, box.strokeWidth()));
1045
812
  box.isNew = false;
1046
813
  }
1047
-
1048
814
  // hide the border if no items
1049
815
  box[display ? 'show' : 'hide']();
1050
-
1051
816
  // Open for responsiveness
1052
817
  if (chart.styledMode && legendGroup.getStyle('display') === 'none') {
1053
818
  legendWidth = legendHeight = 0;
1054
819
  }
1055
-
1056
820
  legend.legendWidth = legendWidth;
1057
821
  legend.legendHeight = legendHeight;
1058
-
1059
822
  if (display) {
1060
823
  // If aligning to the top and the layout is horizontal, adjust for
1061
824
  // the title (#7428)
1062
825
  alignTo = chart.spacingBox;
1063
826
  if (/(lth|ct|rth)/.test(legend.getAlignment())) {
1064
-
1065
827
  y = alignTo.y + chart.titleOffset;
1066
-
1067
828
  alignTo = merge(alignTo, {
1068
829
  y: chart.titleOffset > 0 ?
1069
830
  y += chart.options.title.margin : y
1070
831
  });
1071
832
  }
1072
-
1073
833
  legendGroup.align(merge(options, {
1074
834
  width: legendWidth,
1075
835
  height: legendHeight,
1076
836
  verticalAlign: this.proximate ? 'top' : options.verticalAlign
1077
837
  }), true, alignTo);
1078
838
  }
1079
-
1080
839
  if (!this.proximate) {
1081
840
  this.positionItems();
1082
841
  }
1083
-
1084
842
  fireEvent(this, 'afterRender');
1085
843
  },
1086
-
1087
844
  /**
1088
845
  * Set up the overflow handling by adding navigation with up and down arrows
1089
846
  * below the legend.
1090
847
  *
1091
848
  * @private
1092
849
  * @function Highcharts.Legend#handleOverflow
1093
- *
1094
850
  * @param {number} legendHeight
1095
- *
1096
851
  * @return {number}
1097
852
  */
1098
853
  handleOverflow: function (legendHeight) {
1099
- var legend = this,
1100
- chart = this.chart,
1101
- renderer = chart.renderer,
1102
- options = this.options,
1103
- optionsY = options.y,
1104
- alignTop = options.verticalAlign === 'top',
1105
- padding = this.padding,
1106
- spaceHeight = chart.spacingBox.height +
1107
- (alignTop ? -optionsY : optionsY) - padding,
1108
- maxHeight = options.maxHeight,
1109
- clipHeight,
1110
- clipRect = this.clipRect,
1111
- navOptions = options.navigation,
1112
- animation = pick(navOptions.animation, true),
1113
- arrowSize = navOptions.arrowSize || 12,
1114
- nav = this.nav,
1115
- pages = this.pages,
1116
- lastY,
1117
- allItems = this.allItems,
1118
- clipToHeight = function (height) {
1119
- if (typeof height === 'number') {
1120
- clipRect.attr({
1121
- height: height
1122
- });
1123
- } else if (clipRect) { // Reset (#5912)
1124
- legend.clipRect = clipRect.destroy();
1125
- legend.contentGroup.clip();
1126
- }
1127
-
1128
- // useHTML
1129
- if (legend.contentGroup.div) {
1130
- legend.contentGroup.div.style.clip = height ?
1131
- 'rect(' + padding + 'px,9999px,' +
1132
- (padding + height) + 'px,0)' :
1133
- 'auto';
1134
- }
1135
- },
1136
- addTracker = function (key) {
1137
- legend[key] = renderer
1138
- .circle(0, 0, arrowSize * 1.3)
1139
- .translate(arrowSize / 2, arrowSize / 2)
1140
- .add(nav);
1141
- if (!chart.styledMode) {
1142
- legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
1143
- }
1144
- return legend[key];
1145
- };
1146
-
1147
-
854
+ var legend = this, chart = this.chart, renderer = chart.renderer, options = this.options, optionsY = options.y, alignTop = options.verticalAlign === 'top', padding = this.padding, spaceHeight = (chart.spacingBox.height +
855
+ (alignTop ? -optionsY : optionsY) - padding), maxHeight = options.maxHeight, clipHeight, clipRect = this.clipRect, navOptions = options.navigation, animation = pick(navOptions.animation, true), arrowSize = navOptions.arrowSize || 12, nav = this.nav, pages = this.pages, lastY, allItems = this.allItems, clipToHeight = function (height) {
856
+ if (typeof height === 'number') {
857
+ clipRect.attr({
858
+ height: height
859
+ });
860
+ }
861
+ else if (clipRect) { // Reset (#5912)
862
+ legend.clipRect = clipRect.destroy();
863
+ legend.contentGroup.clip();
864
+ }
865
+ // useHTML
866
+ if (legend.contentGroup.div) {
867
+ legend.contentGroup.div.style.clip = height ?
868
+ 'rect(' + padding + 'px,9999px,' +
869
+ (padding + height) + 'px,0)' :
870
+ 'auto';
871
+ }
872
+ }, addTracker = function (key) {
873
+ legend[key] = renderer
874
+ .circle(0, 0, arrowSize * 1.3)
875
+ .translate(arrowSize / 2, arrowSize / 2)
876
+ .add(nav);
877
+ if (!chart.styledMode) {
878
+ legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
879
+ }
880
+ return legend[key];
881
+ };
1148
882
  // Adjust the height
1149
- if (
1150
- options.layout === 'horizontal' &&
883
+ if (options.layout === 'horizontal' &&
1151
884
  options.verticalAlign !== 'middle' &&
1152
- !options.floating
1153
- ) {
885
+ !options.floating) {
1154
886
  spaceHeight /= 2;
1155
887
  }
1156
888
  if (maxHeight) {
1157
889
  spaceHeight = Math.min(spaceHeight, maxHeight);
1158
890
  }
1159
-
1160
891
  // Reset the legend height and adjust the clipping rectangle
1161
892
  pages.length = 0;
1162
- if (legendHeight > spaceHeight && navOptions.enabled !== false) {
1163
-
893
+ if (legendHeight > spaceHeight &&
894
+ navOptions.enabled !== false) {
1164
895
  this.clipHeight = clipHeight =
1165
896
  Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
1166
897
  this.currentPage = pick(this.currentPage, 1);
1167
898
  this.fullHeight = legendHeight;
1168
-
1169
899
  // Fill pages with Y positions so that the top of each a legend item
1170
900
  // defines the scroll top for each page (#2098)
1171
901
  allItems.forEach(function (item, i) {
1172
- var y = item._legendItemPos[1],
1173
- h = Math.round(item.legendItem.getBBox().height),
1174
- len = pages.length;
1175
-
902
+ var y = item._legendItemPos[1], h = Math.round(item.legendItem.getBBox().height), len = pages.length;
1176
903
  if (!len || (y - pages[len - 1] > clipHeight &&
1177
- (lastY || y) !== pages[len - 1])) {
904
+ (lastY || y) !== pages[len - 1])) {
1178
905
  pages.push(lastY || y);
1179
906
  len++;
1180
907
  }
1181
-
1182
908
  // Keep track of which page each item is on
1183
909
  item.pageIx = len - 1;
1184
910
  if (lastY) {
1185
911
  allItems[i - 1].pageIx = len - 1;
1186
912
  }
1187
-
1188
- if (
1189
- i === allItems.length - 1 &&
913
+ if (i === allItems.length - 1 &&
1190
914
  y + h - pages[len - 1] > clipHeight &&
1191
915
  y !== lastY // #2617
1192
916
  ) {
1193
917
  pages.push(y);
1194
918
  item.pageIx = len;
1195
919
  }
1196
-
1197
920
  if (y !== lastY) {
1198
921
  lastY = y;
1199
922
  }
1200
923
  });
1201
-
1202
924
  // Only apply clipping if needed. Clipping causes blurred legend in
1203
925
  // PDF export (#1787)
1204
926
  if (!clipRect) {
@@ -1206,60 +928,39 @@ Highcharts.Legend.prototype = {
1206
928
  renderer.clipRect(0, padding, 9999, 0);
1207
929
  legend.contentGroup.clip(clipRect);
1208
930
  }
1209
-
1210
931
  clipToHeight(clipHeight);
1211
-
1212
932
  // Add navigation elements
1213
933
  if (!nav) {
1214
934
  this.nav = nav = renderer.g()
1215
935
  .attr({ zIndex: 1 })
1216
936
  .add(this.group);
1217
-
1218
937
  this.up = renderer
1219
- .symbol(
1220
- 'triangle',
1221
- 0,
1222
- 0,
1223
- arrowSize,
1224
- arrowSize
1225
- )
938
+ .symbol('triangle', 0, 0, arrowSize, arrowSize)
1226
939
  .add(nav);
1227
940
  addTracker('upTracker')
1228
941
  .on('click', function () {
1229
- legend.scroll(-1, animation);
1230
- });
1231
-
942
+ legend.scroll(-1, animation);
943
+ });
1232
944
  this.pager = renderer.text('', 15, 10)
1233
945
  .addClass('highcharts-legend-navigation');
1234
-
1235
946
  if (!chart.styledMode) {
1236
947
  this.pager.css(navOptions.style);
1237
948
  }
1238
949
  this.pager.add(nav);
1239
-
1240
950
  this.down = renderer
1241
- .symbol(
1242
- 'triangle-down',
1243
- 0,
1244
- 0,
1245
- arrowSize,
1246
- arrowSize
1247
- )
951
+ .symbol('triangle-down', 0, 0, arrowSize, arrowSize)
1248
952
  .add(nav);
1249
953
  addTracker('downTracker')
1250
954
  .on('click', function () {
1251
- legend.scroll(1, animation);
1252
- });
1253
-
955
+ legend.scroll(1, animation);
956
+ });
1254
957
  }
1255
-
1256
958
  // Set initial position
1257
959
  legend.scroll(0);
1258
-
1259
960
  legendHeight = spaceHeight;
1260
-
1261
- // Reset
1262
- } else if (nav) {
961
+ // Reset
962
+ }
963
+ else if (nav) {
1263
964
  clipToHeight();
1264
965
  this.nav = nav.destroy(); // #6322
1265
966
  this.scrollGroup.attr({
@@ -1267,10 +968,8 @@ Highcharts.Legend.prototype = {
1267
968
  });
1268
969
  this.clipHeight = 0; // #1379
1269
970
  }
1270
-
1271
971
  return legendHeight;
1272
972
  },
1273
-
1274
973
  /**
1275
974
  * Scroll the legend by a number of pages.
1276
975
  *
@@ -1280,29 +979,21 @@ Highcharts.Legend.prototype = {
1280
979
  * @param {number} scrollBy
1281
980
  * The number of pages to scroll.
1282
981
  *
1283
- * @param {Highcharts.AnimationOptionsObject} animation
982
+ * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
1284
983
  * Whether and how to apply animation.
984
+ *
985
+ * @return {void}
1285
986
  */
1286
987
  scroll: function (scrollBy, animation) {
1287
- var pages = this.pages,
1288
- pageCount = pages.length,
1289
- currentPage = this.currentPage + scrollBy,
1290
- clipHeight = this.clipHeight,
1291
- navOptions = this.options.navigation,
1292
- pager = this.pager,
1293
- padding = this.padding;
1294
-
988
+ var pages = this.pages, pageCount = pages.length, currentPage = this.currentPage + scrollBy, clipHeight = this.clipHeight, navOptions = this.options.navigation, pager = this.pager, padding = this.padding;
1295
989
  // When resizing while looking at the last page
1296
990
  if (currentPage > pageCount) {
1297
991
  currentPage = pageCount;
1298
992
  }
1299
-
1300
993
  if (currentPage > 0) {
1301
-
1302
994
  if (animation !== undefined) {
1303
995
  setAnimation(animation, this.chart);
1304
996
  }
1305
-
1306
997
  this.nav.attr({
1307
998
  translateX: padding,
1308
999
  translateY: clipHeight + this.padding + 7 + this.titleHeight,
@@ -1321,52 +1012,45 @@ Highcharts.Legend.prototype = {
1321
1012
  [this.down, this.downTracker].forEach(function (elem) {
1322
1013
  elem.attr({
1323
1014
  // adjust to text width
1324
- 'x': 18 + this.pager.getBBox().width,
1015
+ x: 18 + this.pager.getBBox().width,
1325
1016
  'class': currentPage === pageCount ?
1326
1017
  'highcharts-legend-nav-inactive' :
1327
1018
  'highcharts-legend-nav-active'
1328
1019
  });
1329
1020
  }, this);
1330
-
1331
1021
  if (!this.chart.styledMode) {
1332
1022
  this.up
1333
1023
  .attr({
1334
- fill: currentPage === 1 ?
1335
- navOptions.inactiveColor :
1336
- navOptions.activeColor
1337
- });
1024
+ fill: currentPage === 1 ?
1025
+ navOptions.inactiveColor :
1026
+ navOptions.activeColor
1027
+ });
1338
1028
  this.upTracker
1339
1029
  .css({
1340
- cursor: currentPage === 1 ? 'default' : 'pointer'
1341
- });
1030
+ cursor: currentPage === 1 ? 'default' : 'pointer'
1031
+ });
1342
1032
  this.down
1343
1033
  .attr({
1344
- fill: currentPage === pageCount ?
1345
- navOptions.inactiveColor :
1346
- navOptions.activeColor
1347
- });
1034
+ fill: currentPage === pageCount ?
1035
+ navOptions.inactiveColor :
1036
+ navOptions.activeColor
1037
+ });
1348
1038
  this.downTracker
1349
1039
  .css({
1350
- cursor: currentPage === pageCount ?
1351
- 'default' :
1352
- 'pointer'
1353
- });
1040
+ cursor: currentPage === pageCount ?
1041
+ 'default' :
1042
+ 'pointer'
1043
+ });
1354
1044
  }
1355
-
1356
1045
  this.scrollOffset = -pages[currentPage - 1] + this.initialItemY;
1357
-
1358
1046
  this.scrollGroup.animate({
1359
1047
  translateY: this.scrollOffset
1360
1048
  });
1361
-
1362
1049
  this.currentPage = currentPage;
1363
1050
  this.positionCheckboxes();
1364
1051
  }
1365
-
1366
1052
  }
1367
-
1368
1053
  };
1369
-
1370
1054
  /**
1371
1055
  * Legend symbol mixin.
1372
1056
  *
@@ -1374,7 +1058,6 @@ Highcharts.Legend.prototype = {
1374
1058
  * @mixin Highcharts.LegendSymbolMixin
1375
1059
  */
1376
1060
  H.LegendSymbolMixin = {
1377
-
1378
1061
  /**
1379
1062
  * Get the series' symbol in the legend
1380
1063
  *
@@ -1386,27 +1069,18 @@ H.LegendSymbolMixin = {
1386
1069
  *
1387
1070
  * @param {Highcharts.Point|Highcharts.Series} item
1388
1071
  * The series (this) or point
1072
+ *
1073
+ * @return {void}
1389
1074
  */
1390
1075
  drawRectangle: function (legend, item) {
1391
- var options = legend.options,
1392
- symbolHeight = legend.symbolHeight,
1393
- square = options.squareSymbol,
1394
- symbolWidth = square ? symbolHeight : legend.symbolWidth;
1395
-
1396
- item.legendSymbol = this.chart.renderer.rect(
1397
- square ? (legend.symbolWidth - symbolHeight) / 2 : 0,
1398
- legend.baseline - symbolHeight + 1, // #3988
1399
- symbolWidth,
1400
- symbolHeight,
1401
- pick(legend.options.symbolRadius, symbolHeight / 2)
1402
- )
1076
+ var options = legend.options, symbolHeight = legend.symbolHeight, square = options.squareSymbol, symbolWidth = square ? symbolHeight : legend.symbolWidth;
1077
+ item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, // #3988
1078
+ symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2))
1403
1079
  .addClass('highcharts-point')
1404
1080
  .attr({
1405
- zIndex: 3
1406
- }).add(item.legendGroup);
1407
-
1081
+ zIndex: 3
1082
+ }).add(item.legendGroup);
1408
1083
  },
1409
-
1410
1084
  /**
1411
1085
  * Get the series' symbol in the legend. This method should be overridable
1412
1086
  * to create custom symbols through
@@ -1417,22 +1091,12 @@ H.LegendSymbolMixin = {
1417
1091
  *
1418
1092
  * @param {Highcharts.Legend} legend
1419
1093
  * The legend object.
1094
+ *
1095
+ * @return {void}
1420
1096
  */
1421
1097
  drawLineMarker: function (legend) {
1422
-
1423
- var options = this.options,
1424
- markerOptions = options.marker,
1425
- radius,
1426
- legendSymbol,
1427
- symbolWidth = legend.symbolWidth,
1428
- symbolHeight = legend.symbolHeight,
1429
- generalRadius = symbolHeight / 2,
1430
- renderer = this.chart.renderer,
1431
- legendItemGroup = this.legendGroup,
1432
- verticalCenter = legend.baseline -
1433
- Math.round(legend.fontMetrics.b * 0.3),
1434
- attr = {};
1435
-
1098
+ var options = this.options, markerOptions = options.marker, radius, legendSymbol, symbolWidth = legend.symbolWidth, symbolHeight = legend.symbolHeight, generalRadius = symbolHeight / 2, renderer = this.chart.renderer, legendItemGroup = this.legendGroup, verticalCenter = legend.baseline -
1099
+ Math.round(legend.fontMetrics.b * 0.3), attr = {};
1436
1100
  // Draw the line
1437
1101
  if (!this.chart.styledMode) {
1438
1102
  attr = {
@@ -1442,8 +1106,8 @@ H.LegendSymbolMixin = {
1442
1106
  attr.dashstyle = options.dashStyle;
1443
1107
  }
1444
1108
  }
1445
-
1446
- this.legendLine = renderer.path([
1109
+ this.legendLine = renderer
1110
+ .path([
1447
1111
  'M',
1448
1112
  0,
1449
1113
  verticalCenter,
@@ -1454,16 +1118,10 @@ H.LegendSymbolMixin = {
1454
1118
  .addClass('highcharts-graph')
1455
1119
  .attr(attr)
1456
1120
  .add(legendItemGroup);
1457
-
1458
1121
  // Draw the marker
1459
1122
  if (markerOptions && markerOptions.enabled !== false && symbolWidth) {
1460
-
1461
1123
  // Do not allow the marker to be larger than the symbolHeight
1462
- radius = Math.min(
1463
- pick(markerOptions.radius, generalRadius),
1464
- generalRadius
1465
- );
1466
-
1124
+ radius = Math.min(pick(markerOptions.radius, generalRadius), generalRadius);
1467
1125
  // Restrict symbol markers size
1468
1126
  if (this.symbol.indexOf('url') === 0) {
1469
1127
  markerOptions = merge(markerOptions, {
@@ -1472,43 +1130,30 @@ H.LegendSymbolMixin = {
1472
1130
  });
1473
1131
  radius = 0;
1474
1132
  }
1475
-
1476
- this.legendSymbol = legendSymbol = renderer.symbol(
1477
- this.symbol,
1478
- (symbolWidth / 2) - radius,
1479
- verticalCenter - radius,
1480
- 2 * radius,
1481
- 2 * radius,
1482
- markerOptions
1483
- )
1133
+ this.legendSymbol = legendSymbol = renderer.symbol(this.symbol, (symbolWidth / 2) - radius, verticalCenter - radius, 2 * radius, 2 * radius, markerOptions)
1484
1134
  .addClass('highcharts-point')
1485
1135
  .add(legendItemGroup);
1486
1136
  legendSymbol.isMarker = true;
1487
1137
  }
1488
1138
  }
1489
1139
  };
1490
-
1491
1140
  // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
1492
1141
  // and for #2580, a similar drawing flaw in Firefox 26.
1493
1142
  // Explore if there's a general cause for this. The problem may be related
1494
1143
  // to nested group elements, as the legend item texts are within 4 group
1495
1144
  // elements.
1496
- if (
1497
- /Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
1498
- isFirefox
1499
- ) {
1145
+ if (/Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
1146
+ isFirefox) {
1500
1147
  wrap(Highcharts.Legend.prototype, 'positionItem', function (proceed, item) {
1501
- var legend = this,
1502
- // If chart destroyed in sync, this is undefined (#2030)
1503
- runPositionItem = function () {
1504
- if (item._legendItemPos) {
1505
- proceed.call(legend, item);
1506
- }
1507
- };
1508
-
1148
+ var legend = this,
1149
+ // If chart destroyed in sync, this is undefined (#2030)
1150
+ runPositionItem = function () {
1151
+ if (item._legendItemPos) {
1152
+ proceed.call(legend, item);
1153
+ }
1154
+ };
1509
1155
  // Do it now, for export and to get checkbox placement
1510
1156
  runPositionItem();
1511
-
1512
1157
  // Do it after to work around the core issue
1513
1158
  if (!legend.bubbleLegend) {
1514
1159
  setTimeout(runPositionItem);