heatmap.src.js 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  1. /**
  2. * @license Highmaps JS v8.0.0 (2019-12-10)
  3. *
  4. * (c) 2009-2019 Torstein Honsi
  5. *
  6. * License: www.highcharts.com/license
  7. */
  8. 'use strict';
  9. (function (factory) {
  10. if (typeof module === 'object' && module.exports) {
  11. factory['default'] = factory;
  12. module.exports = factory;
  13. } else if (typeof define === 'function' && define.amd) {
  14. define('highcharts/modules/heatmap', ['highcharts'], function (Highcharts) {
  15. factory(Highcharts);
  16. factory.Highcharts = Highcharts;
  17. return factory;
  18. });
  19. } else {
  20. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  21. }
  22. }(function (Highcharts) {
  23. var _modules = Highcharts ? Highcharts._modules : {};
  24. function _registerModule(obj, path, args, fn) {
  25. if (!obj.hasOwnProperty(path)) {
  26. obj[path] = fn.apply(null, args);
  27. }
  28. }
  29. _registerModule(_modules, 'parts-map/ColorSeriesMixin.js', [_modules['parts/Globals.js']], function (H) {
  30. /* *
  31. *
  32. * (c) 2010-2019 Torstein Honsi
  33. *
  34. * License: www.highcharts.com/license
  35. *
  36. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37. *
  38. * */
  39. /**
  40. * Mixin for maps and heatmaps
  41. *
  42. * @private
  43. * @mixin Highcharts.colorPointMixin
  44. */
  45. H.colorPointMixin = {
  46. /* eslint-disable valid-jsdoc */
  47. /**
  48. * Set the visibility of a single point
  49. * @private
  50. * @function Highcharts.colorPointMixin.setVisible
  51. * @param {boolean} visible
  52. * @return {void}
  53. */
  54. setVisible: function (vis) {
  55. var point = this, method = vis ? 'show' : 'hide';
  56. point.visible = point.options.visible = Boolean(vis);
  57. // Show and hide associated elements
  58. ['graphic', 'dataLabel'].forEach(function (key) {
  59. if (point[key]) {
  60. point[key][method]();
  61. }
  62. });
  63. }
  64. /* eslint-enable valid-jsdoc */
  65. };
  66. /**
  67. * @private
  68. * @mixin Highcharts.colorSeriesMixin
  69. */
  70. H.colorSeriesMixin = {
  71. optionalAxis: 'colorAxis',
  72. colorAxis: 0,
  73. /* eslint-disable valid-jsdoc */
  74. /**
  75. * In choropleth maps, the color is a result of the value, so this needs
  76. * translation too
  77. * @private
  78. * @function Highcharts.colorSeriesMixin.translateColors
  79. * @return {void}
  80. */
  81. translateColors: function () {
  82. var series = this, points = this.data.length ? this.data : this.points, nullColor = this.options.nullColor, colorAxis = this.colorAxis, colorKey = this.colorKey;
  83. points.forEach(function (point) {
  84. var value = point[colorKey], color;
  85. color = point.options.color ||
  86. (point.isNull ?
  87. nullColor :
  88. (colorAxis && typeof value !== 'undefined') ?
  89. colorAxis.toColor(value, point) :
  90. point.color || series.color);
  91. if (color) {
  92. point.color = color;
  93. }
  94. });
  95. }
  96. /* eslint-enable valid-jsdoc */
  97. };
  98. });
  99. _registerModule(_modules, 'parts-map/ColorAxis.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  100. /* *
  101. *
  102. * (c) 2010-2019 Torstein Honsi
  103. *
  104. * License: www.highcharts.com/license
  105. *
  106. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  107. *
  108. * */
  109. /**
  110. * Color axis types
  111. *
  112. * @typedef {"linear"|"logarithmic"} Highcharts.ColorAxisTypeValue
  113. */
  114. var erase = U.erase, extend = U.extend, isNumber = U.isNumber, pick = U.pick, splat = U.splat;
  115. var addEvent = H.addEvent, Axis = H.Axis, Chart = H.Chart, Series = H.Series, Point = H.Point, color = H.color, ColorAxis, Legend = H.Legend, LegendSymbolMixin = H.LegendSymbolMixin, colorPointMixin = H.colorPointMixin, colorSeriesMixin = H.colorSeriesMixin, noop = H.noop, merge = H.merge;
  116. extend(Series.prototype, colorSeriesMixin);
  117. extend(Point.prototype, colorPointMixin);
  118. Chart.prototype.collectionsWithUpdate.push('colorAxis');
  119. Chart.prototype.collectionsWithInit.colorAxis = [Chart.prototype.addColorAxis];
  120. /* eslint-disable no-invalid-this, valid-jsdoc */
  121. /**
  122. * The ColorAxis object for inclusion in gradient legends.
  123. *
  124. * @class
  125. * @name Highcharts.ColorAxis
  126. * @augments Highcharts.Axis
  127. *
  128. * @param {Highcharts.Chart} chart
  129. * The related chart of the color axis.
  130. *
  131. * @param {Highcharts.ColorAxisOptions} userOptions
  132. * The color axis options for initialization.
  133. */
  134. ColorAxis = H.ColorAxis = function () {
  135. this.init.apply(this, arguments);
  136. };
  137. /* eslint-enable no-invalid-this, valid-jsdoc */
  138. extend(ColorAxis.prototype, Axis.prototype);
  139. extend(ColorAxis.prototype, {
  140. /**
  141. * A color axis for series. Visually, the color
  142. * axis will appear as a gradient or as separate items inside the
  143. * legend, depending on whether the axis is scalar or based on data
  144. * classes.
  145. *
  146. * For supported color formats, see the
  147. * [docs article about colors](https://www.highcharts.com/docs/chart-design-and-style/colors).
  148. *
  149. * A scalar color axis is represented by a gradient. The colors either
  150. * range between the [minColor](#colorAxis.minColor) and the
  151. * [maxColor](#colorAxis.maxColor), or for more fine grained control the
  152. * colors can be defined in [stops](#colorAxis.stops). Often times, the
  153. * color axis needs to be adjusted to get the right color spread for the
  154. * data. In addition to stops, consider using a logarithmic
  155. * [axis type](#colorAxis.type), or setting [min](#colorAxis.min) and
  156. * [max](#colorAxis.max) to avoid the colors being determined by
  157. * outliers.
  158. *
  159. * When [dataClasses](#colorAxis.dataClasses) are used, the ranges are
  160. * subdivided into separate classes like categories based on their
  161. * values. This can be used for ranges between two values, but also for
  162. * a true category. However, when your data is categorized, it may be as
  163. * convenient to add each category to a separate series.
  164. *
  165. * Color axis does not work with: `sankey`, `sunburst`, `dependencywheel`,
  166. * `networkgraph`, `wordcloud`, `venn`, `gauge` and `solidgauge` series
  167. * types.
  168. *
  169. * Since v7.2.0 `colorAxis` can also be an array of options objects.
  170. *
  171. * See [the Axis object](/class-reference/Highcharts.Axis) for
  172. * programmatic access to the axis.
  173. *
  174. * @sample {highcharts} highcharts/coloraxis/custom-color-key
  175. * Column chart with color axis
  176. * @sample {highcharts} highcharts/coloraxis/horizontal-layout
  177. * Horizontal layout
  178. * @sample {highmaps} maps/coloraxis/dataclasscolor
  179. * With data classes
  180. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor
  181. * Min color and max color
  182. *
  183. * @extends xAxis
  184. * @excluding alignTicks, allowDecimals, alternateGridColor, breaks,
  185. * categories, crosshair, dateTimeLabelFormats, height, left,
  186. * lineWidth, linkedTo, maxZoom, minRange, minTickInterval,
  187. * offset, opposite, pane, plotBands, plotLines,
  188. * reversedStacks, showEmpty, title, top, width, zoomEnabled
  189. * @product highcharts highstock highmaps
  190. * @type {*|Array<*>}
  191. * @optionparent colorAxis
  192. * @ignore
  193. */
  194. defaultColorAxisOptions: {
  195. /**
  196. * Whether to allow decimals on the color axis.
  197. * @type {boolean}
  198. * @default true
  199. * @product highcharts highstock highmaps
  200. * @apioption colorAxis.allowDecimals
  201. */
  202. /**
  203. * Determines how to set each data class' color if no individual
  204. * color is set. The default value, `tween`, computes intermediate
  205. * colors between `minColor` and `maxColor`. The other possible
  206. * value, `category`, pulls colors from the global or chart specific
  207. * [colors](#colors) array.
  208. *
  209. * @sample {highmaps} maps/coloraxis/dataclasscolor/
  210. * Category colors
  211. *
  212. * @type {string}
  213. * @default tween
  214. * @product highcharts highstock highmaps
  215. * @validvalue ["tween", "category"]
  216. * @apioption colorAxis.dataClassColor
  217. */
  218. /**
  219. * An array of data classes or ranges for the choropleth map. If
  220. * none given, the color axis is scalar and values are distributed
  221. * as a gradient between the minimum and maximum colors.
  222. *
  223. * @sample {highmaps} maps/demo/data-class-ranges/
  224. * Multiple ranges
  225. *
  226. * @sample {highmaps} maps/demo/data-class-two-ranges/
  227. * Two ranges
  228. *
  229. * @type {Array<*>}
  230. * @product highcharts highstock highmaps
  231. * @apioption colorAxis.dataClasses
  232. */
  233. /**
  234. * The layout of the color axis. Can be `'horizontal'` or `'vertical'`.
  235. * If none given, the color axis has the same layout as the legend.
  236. *
  237. * @sample highcharts/coloraxis/horizontal-layout/
  238. * Horizontal color axis layout with vertical legend
  239. *
  240. * @type {string|undefined}
  241. * @since 7.2.0
  242. * @product highcharts highstock highmaps
  243. * @apioption colorAxis.layout
  244. */
  245. /**
  246. * The color of each data class. If not set, the color is pulled
  247. * from the global or chart-specific [colors](#colors) array. In
  248. * styled mode, this option is ignored. Instead, use colors defined
  249. * in CSS.
  250. *
  251. * @sample {highmaps} maps/demo/data-class-two-ranges/
  252. * Explicit colors
  253. *
  254. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  255. * @product highcharts highstock highmaps
  256. * @apioption colorAxis.dataClasses.color
  257. */
  258. /**
  259. * The start of the value range that the data class represents,
  260. * relating to the point value.
  261. *
  262. * The range of each `dataClass` is closed in both ends, but can be
  263. * overridden by the next `dataClass`.
  264. *
  265. * @type {number}
  266. * @product highcharts highstock highmaps
  267. * @apioption colorAxis.dataClasses.from
  268. */
  269. /**
  270. * The name of the data class as it appears in the legend.
  271. * If no name is given, it is automatically created based on the
  272. * `from` and `to` values. For full programmatic control,
  273. * [legend.labelFormatter](#legend.labelFormatter) can be used.
  274. * In the formatter, `this.from` and `this.to` can be accessed.
  275. *
  276. * @sample {highmaps} maps/coloraxis/dataclasses-name/
  277. * Named data classes
  278. *
  279. * @sample {highmaps} maps/coloraxis/dataclasses-labelformatter/
  280. * Formatted data classes
  281. *
  282. * @type {string}
  283. * @product highcharts highstock highmaps
  284. * @apioption colorAxis.dataClasses.name
  285. */
  286. /**
  287. * The end of the value range that the data class represents,
  288. * relating to the point value.
  289. *
  290. * The range of each `dataClass` is closed in both ends, but can be
  291. * overridden by the next `dataClass`.
  292. *
  293. * @type {number}
  294. * @product highcharts highstock highmaps
  295. * @apioption colorAxis.dataClasses.to
  296. */
  297. /** @ignore-option */
  298. lineWidth: 0,
  299. /**
  300. * Padding of the min value relative to the length of the axis. A
  301. * padding of 0.05 will make a 100px axis 5px longer.
  302. *
  303. * @product highcharts highstock highmaps
  304. */
  305. minPadding: 0,
  306. /**
  307. * The maximum value of the axis in terms of map point values. If
  308. * `null`, the max value is automatically calculated. If the
  309. * `endOnTick` option is true, the max value might be rounded up.
  310. *
  311. * @sample {highmaps} maps/coloraxis/gridlines/
  312. * Explicit min and max to reduce the effect of outliers
  313. *
  314. * @type {number}
  315. * @product highcharts highstock highmaps
  316. * @apioption colorAxis.max
  317. */
  318. /**
  319. * The minimum value of the axis in terms of map point values. If
  320. * `null`, the min value is automatically calculated. If the
  321. * `startOnTick` option is true, the min value might be rounded
  322. * down.
  323. *
  324. * @sample {highmaps} maps/coloraxis/gridlines/
  325. * Explicit min and max to reduce the effect of outliers
  326. *
  327. * @type {number}
  328. * @product highcharts highstock highmaps
  329. * @apioption colorAxis.min
  330. */
  331. /**
  332. * Padding of the max value relative to the length of the axis. A
  333. * padding of 0.05 will make a 100px axis 5px longer.
  334. *
  335. * @product highcharts highstock highmaps
  336. */
  337. maxPadding: 0,
  338. /**
  339. * Color of the grid lines extending from the axis across the
  340. * gradient.
  341. *
  342. * @sample {highmaps} maps/coloraxis/gridlines/
  343. * Grid lines demonstrated
  344. *
  345. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  346. * @default #e6e6e6
  347. * @product highcharts highstock highmaps
  348. * @apioption colorAxis.gridLineColor
  349. */
  350. /**
  351. * The width of the grid lines extending from the axis across the
  352. * gradient of a scalar color axis.
  353. *
  354. * @sample {highmaps} maps/coloraxis/gridlines/
  355. * Grid lines demonstrated
  356. *
  357. * @product highcharts highstock highmaps
  358. */
  359. gridLineWidth: 1,
  360. /**
  361. * The interval of the tick marks in axis units. When `null`, the
  362. * tick interval is computed to approximately follow the
  363. * `tickPixelInterval`.
  364. *
  365. * @type {number}
  366. * @product highcharts highstock highmaps
  367. * @apioption colorAxis.tickInterval
  368. */
  369. /**
  370. * If [tickInterval](#colorAxis.tickInterval) is `null` this option
  371. * sets the approximate pixel interval of the tick marks.
  372. *
  373. * @product highcharts highstock highmaps
  374. */
  375. tickPixelInterval: 72,
  376. /**
  377. * Whether to force the axis to start on a tick. Use this option
  378. * with the `maxPadding` option to control the axis start.
  379. *
  380. * @product highcharts highstock highmaps
  381. */
  382. startOnTick: true,
  383. /**
  384. * Whether to force the axis to end on a tick. Use this option with
  385. * the [maxPadding](#colorAxis.maxPadding) option to control the
  386. * axis end.
  387. *
  388. * @product highcharts highstock highmaps
  389. */
  390. endOnTick: true,
  391. /** @ignore */
  392. offset: 0,
  393. /**
  394. * The triangular marker on a scalar color axis that points to the
  395. * value of the hovered area. To disable the marker, set
  396. * `marker: null`.
  397. *
  398. * @sample {highmaps} maps/coloraxis/marker/
  399. * Black marker
  400. *
  401. * @declare Highcharts.PointMarkerOptionsObject
  402. * @product highcharts highstock highmaps
  403. */
  404. marker: {
  405. /**
  406. * Animation for the marker as it moves between values. Set to
  407. * `false` to disable animation. Defaults to `{ duration: 50 }`.
  408. *
  409. * @type {boolean|Highcharts.AnimationOptionsObject}
  410. * @product highcharts highstock highmaps
  411. */
  412. animation: {
  413. /** @internal */
  414. duration: 50
  415. },
  416. /** @internal */
  417. width: 0.01,
  418. /**
  419. * The color of the marker.
  420. *
  421. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  422. * @product highcharts highstock highmaps
  423. */
  424. color: '#999999'
  425. },
  426. /**
  427. * The axis labels show the number for each tick.
  428. *
  429. * For more live examples on label options, see [xAxis.labels in the
  430. * Highcharts API.](/highcharts#xAxis.labels)
  431. *
  432. * @extends xAxis.labels
  433. * @product highcharts highstock highmaps
  434. */
  435. labels: {
  436. /**
  437. * How to handle overflowing labels on horizontal color axis. If set
  438. * to `"allow"`, it will not be aligned at all. By default it
  439. * `"justify"` labels inside the chart area. If there is room to
  440. * move it, it will be aligned to the edge, else it will be removed.
  441. *
  442. * @validvalue ["allow", "justify"]
  443. * @product highcharts highstock highmaps
  444. */
  445. overflow: 'justify',
  446. rotation: 0
  447. },
  448. /**
  449. * The color to represent the minimum of the color axis. Unless
  450. * [dataClasses](#colorAxis.dataClasses) or
  451. * [stops](#colorAxis.stops) are set, the gradient starts at this
  452. * value.
  453. *
  454. * If dataClasses are set, the color is based on minColor and
  455. * maxColor unless a color is set for each data class, or the
  456. * [dataClassColor](#colorAxis.dataClassColor) is set.
  457. *
  458. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor/
  459. * Min and max colors on scalar (gradient) axis
  460. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor-dataclasses/
  461. * On data classes
  462. *
  463. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  464. * @product highcharts highstock highmaps
  465. */
  466. minColor: '#e6ebf5',
  467. /**
  468. * The color to represent the maximum of the color axis. Unless
  469. * [dataClasses](#colorAxis.dataClasses) or
  470. * [stops](#colorAxis.stops) are set, the gradient ends at this
  471. * value.
  472. *
  473. * If dataClasses are set, the color is based on minColor and
  474. * maxColor unless a color is set for each data class, or the
  475. * [dataClassColor](#colorAxis.dataClassColor) is set.
  476. *
  477. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor/
  478. * Min and max colors on scalar (gradient) axis
  479. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor-dataclasses/
  480. * On data classes
  481. *
  482. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  483. * @product highcharts highstock highmaps
  484. */
  485. maxColor: '#003399',
  486. /**
  487. * Color stops for the gradient of a scalar color axis. Use this in
  488. * cases where a linear gradient between a `minColor` and `maxColor`
  489. * is not sufficient. The stops is an array of tuples, where the
  490. * first item is a float between 0 and 1 assigning the relative
  491. * position in the gradient, and the second item is the color.
  492. *
  493. * @sample {highmaps} maps/demo/heatmap/
  494. * Heatmap with three color stops
  495. *
  496. * @type {Array<Array<number,Highcharts.ColorString>>}
  497. * @product highcharts highstock highmaps
  498. * @apioption colorAxis.stops
  499. */
  500. /**
  501. * The pixel length of the main tick marks on the color axis.
  502. */
  503. tickLength: 5,
  504. /**
  505. * The type of interpolation to use for the color axis. Can be
  506. * `linear` or `logarithmic`.
  507. *
  508. * @sample highcharts/coloraxis/logarithmic-with-emulate-negative-values/
  509. * Logarithmic color axis with extension to emulate negative
  510. * values
  511. *
  512. * @type {Highcharts.ColorAxisTypeValue}
  513. * @default linear
  514. * @product highcharts highstock highmaps
  515. * @apioption colorAxis.type
  516. */
  517. /**
  518. * Whether to reverse the axis so that the highest number is closest
  519. * to the origin. Defaults to `false` in a horizontal legend and
  520. * `true` in a vertical legend, where the smallest value starts on
  521. * top.
  522. *
  523. * @type {boolean}
  524. * @product highcharts highstock highmaps
  525. * @apioption colorAxis.reversed
  526. */
  527. /**
  528. * @product highcharts highstock highmaps
  529. * @excluding afterBreaks, pointBreak, pointInBreak
  530. * @apioption colorAxis.events
  531. */
  532. /**
  533. * Fires when the legend item belonging to the colorAxis is clicked.
  534. * One parameter, `event`, is passed to the function.
  535. *
  536. * @type {Function}
  537. * @product highcharts highstock highmaps
  538. * @apioption colorAxis.events.legendItemClick
  539. */
  540. /**
  541. * Whether to display the colorAxis in the legend.
  542. *
  543. * @sample highcharts/coloraxis/hidden-coloraxis-with-3d-chart/
  544. * Hidden color axis with 3d chart
  545. *
  546. * @see [heatmap.showInLegend](#series.heatmap.showInLegend)
  547. *
  548. * @since 4.2.7
  549. * @product highcharts highstock highmaps
  550. */
  551. showInLegend: true
  552. },
  553. // Properties to preserve after destroy, for Axis.update (#5881, #6025)
  554. keepProps: [
  555. 'legendGroup',
  556. 'legendItemHeight',
  557. 'legendItemWidth',
  558. 'legendItem',
  559. 'legendSymbol'
  560. ].concat(Axis.prototype.keepProps),
  561. /* eslint-disable no-invalid-this, valid-jsdoc */
  562. /**
  563. * Initializes the color axis.
  564. *
  565. * @function Highcharts.ColorAxis#init
  566. *
  567. * @param {Highcharts.Chart} chart
  568. * The related chart of the color axis.
  569. *
  570. * @param {Highcharts.ColorAxisOptions} userOptions
  571. * The color axis options for initialization.
  572. *
  573. * @return {void}
  574. */
  575. init: function (chart, userOptions) {
  576. var options;
  577. this.coll = 'colorAxis';
  578. // Build the options
  579. options = this.buildOptions.call(chart, this.defaultColorAxisOptions, userOptions);
  580. Axis.prototype.init.call(this, chart, options);
  581. // Base init() pushes it to the xAxis array, now pop it again
  582. // chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop();
  583. // Prepare data classes
  584. if (userOptions.dataClasses) {
  585. this.initDataClasses(userOptions);
  586. }
  587. this.initStops();
  588. // Override original axis properties
  589. this.horiz = !options.opposite;
  590. this.zoomEnabled = false;
  591. // Add default values
  592. this.defaultLegendLength = 200;
  593. },
  594. /**
  595. * @private
  596. */
  597. initDataClasses: function (userOptions) {
  598. var chart = this.chart, dataClasses, colorCounter = 0, colorCount = chart.options.chart.colorCount, options = this.options, len = userOptions.dataClasses.length;
  599. this.dataClasses = dataClasses =
  600. [];
  601. this.legendItems = [];
  602. userOptions.dataClasses.forEach(function (dataClass, i) {
  603. var colors;
  604. dataClass = merge(dataClass);
  605. dataClasses.push(dataClass);
  606. if (!chart.styledMode && dataClass.color) {
  607. return;
  608. }
  609. if (options.dataClassColor === 'category') {
  610. if (!chart.styledMode) {
  611. colors = chart.options.colors;
  612. colorCount = colors.length;
  613. dataClass.color = colors[colorCounter];
  614. }
  615. dataClass.colorIndex = colorCounter;
  616. // increase and loop back to zero
  617. colorCounter++;
  618. if (colorCounter === colorCount) {
  619. colorCounter = 0;
  620. }
  621. }
  622. else {
  623. dataClass.color = color(options.minColor).tweenTo(color(options.maxColor), len < 2 ? 0.5 : i / (len - 1) // #3219
  624. );
  625. }
  626. });
  627. },
  628. /**
  629. * Returns true if the series has points at all.
  630. *
  631. * @function Highcharts.ColorAxis#hasData
  632. *
  633. * @return {boolean}
  634. * True, if the series has points, otherwise false.
  635. */
  636. hasData: function () {
  637. return !!(this.tickPositions && this.tickPositions.length);
  638. },
  639. /**
  640. * Override so that ticks are not added in data class axes (#6914)
  641. *
  642. * @private
  643. * @function Highcharts.ColorAxis#setTickPositions
  644. * @return {void}
  645. */
  646. setTickPositions: function () {
  647. if (!this.dataClasses) {
  648. return Axis.prototype.setTickPositions.call(this);
  649. }
  650. },
  651. /**
  652. * @private
  653. */
  654. initStops: function () {
  655. this.stops = this.options.stops || [
  656. [0, this.options.minColor],
  657. [1, this.options.maxColor]
  658. ];
  659. this.stops.forEach(function (stop) {
  660. stop.color = color(stop[1]);
  661. });
  662. },
  663. /**
  664. * Build options to keep layout params on init and update.
  665. *
  666. * @private
  667. * @param {Highcharts.ColorAxisOptions} options
  668. * @param {Highcharts.ColorAxisOptions} [userOptions]
  669. * @return {Highcharts.ColorAxisOptions}
  670. */
  671. buildOptions: function (options, userOptions) {
  672. var legend = this.options.legend, horiz = userOptions.layout ?
  673. userOptions.layout !== 'vertical' :
  674. legend.layout !== 'vertical';
  675. return merge(options, {
  676. side: horiz ? 2 : 1,
  677. reversed: !horiz
  678. }, userOptions, {
  679. opposite: !horiz,
  680. showEmpty: false,
  681. title: null,
  682. visible: legend.enabled &&
  683. (userOptions ? userOptions.visible !== false : true)
  684. });
  685. },
  686. /**
  687. * Extend the setOptions method to process extreme colors and color
  688. * stops.
  689. *
  690. * @private
  691. * @function Highcharts.ColorAxis#setOptions
  692. * @param {Highcharts.ColorAxisOptions} userOptions
  693. * @return {void}
  694. */
  695. setOptions: function (userOptions) {
  696. Axis.prototype.setOptions.call(this, userOptions);
  697. this.options.crosshair = this.options.marker;
  698. },
  699. /**
  700. * @private
  701. */
  702. setAxisSize: function () {
  703. var symbol = this.legendSymbol, chart = this.chart, legendOptions = chart.options.legend || {}, x, y, width, height;
  704. if (symbol) {
  705. this.left = x = symbol.attr('x');
  706. this.top = y = symbol.attr('y');
  707. this.width = width = symbol.attr('width');
  708. this.height = height = symbol.attr('height');
  709. this.right = chart.chartWidth - x - width;
  710. this.bottom = chart.chartHeight - y - height;
  711. this.len = this.horiz ? width : height;
  712. this.pos = this.horiz ? x : y;
  713. }
  714. else {
  715. // Fake length for disabled legend to avoid tick issues
  716. // and such (#5205)
  717. this.len = (this.horiz ?
  718. legendOptions.symbolWidth :
  719. legendOptions.symbolHeight) || this.defaultLegendLength;
  720. }
  721. },
  722. /**
  723. * @private
  724. */
  725. normalizedValue: function (value) {
  726. if (this.isLog) {
  727. value = this.val2lin(value);
  728. }
  729. return 1 - ((this.max - value) /
  730. ((this.max - this.min) || 1));
  731. },
  732. /**
  733. * Translate from a value to a color.
  734. *
  735. * @private
  736. * @function Highcharts.ColorAxis#toColor
  737. * @param {number} value
  738. * @param {Highcharts.Point} point
  739. * @return {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  740. */
  741. toColor: function (value, point) {
  742. var pos, stops = this.stops, from, to, color, dataClasses = this.dataClasses, dataClass, i;
  743. if (dataClasses) {
  744. i = dataClasses.length;
  745. while (i--) {
  746. dataClass = dataClasses[i];
  747. from = dataClass.from;
  748. to = dataClass.to;
  749. if ((typeof from === 'undefined' || value >= from) &&
  750. (typeof to === 'undefined' || value <= to)) {
  751. color = dataClass.color;
  752. if (point) {
  753. point.dataClass = i;
  754. point.colorIndex = dataClass.colorIndex;
  755. }
  756. break;
  757. }
  758. }
  759. }
  760. else {
  761. pos = this.normalizedValue(value);
  762. i = stops.length;
  763. while (i--) {
  764. if (pos > stops[i][0]) {
  765. break;
  766. }
  767. }
  768. from = stops[i] || stops[i + 1];
  769. to = stops[i + 1] || from;
  770. // The position within the gradient
  771. pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
  772. color = from.color.tweenTo(to.color, pos);
  773. }
  774. return color;
  775. },
  776. /**
  777. * Override the getOffset method to add the whole axis groups inside
  778. * the legend.
  779. *
  780. * @private
  781. * @function Highcharts.ColorAxis#getOffset
  782. * @return {void}
  783. */
  784. getOffset: function () {
  785. var group = this.legendGroup, sideOffset = this.chart.axisOffset[this.side];
  786. if (group) {
  787. // Hook for the getOffset method to add groups to this parent
  788. // group
  789. this.axisParent = group;
  790. // Call the base
  791. Axis.prototype.getOffset.call(this);
  792. // First time only
  793. if (!this.added) {
  794. this.added = true;
  795. this.labelLeft = 0;
  796. this.labelRight = this.width;
  797. }
  798. // Reset it to avoid color axis reserving space
  799. this.chart.axisOffset[this.side] = sideOffset;
  800. }
  801. },
  802. /**
  803. * Create the color gradient.
  804. *
  805. * @private
  806. * @function Highcharts.ColorAxis#setLegendColor
  807. */
  808. setLegendColor: function () {
  809. var grad, horiz = this.horiz, reversed = this.reversed, one = reversed ? 1 : 0, zero = reversed ? 0 : 1;
  810. grad = horiz ? [one, 0, zero, 0] : [0, zero, 0, one]; // #3190
  811. this.legendColor = {
  812. linearGradient: {
  813. x1: grad[0],
  814. y1: grad[1],
  815. x2: grad[2],
  816. y2: grad[3]
  817. },
  818. stops: this.stops
  819. };
  820. },
  821. /**
  822. * The color axis appears inside the legend and has its own legend
  823. * symbol.
  824. *
  825. * @private
  826. * @function Highcharts.ColorAxis#drawLegendSymbol
  827. * @param {Highcharts.Legend} legend
  828. * @param {Highcharts.ColorAxis} item
  829. * @return {void}
  830. */
  831. drawLegendSymbol: function (legend, item) {
  832. var padding = legend.padding, legendOptions = legend.options, horiz = this.horiz, width = pick(legendOptions.symbolWidth, horiz ? this.defaultLegendLength : 12), height = pick(legendOptions.symbolHeight, horiz ? 12 : this.defaultLegendLength), labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30), itemDistance = pick(legendOptions.itemDistance, 10);
  833. this.setLegendColor();
  834. // Create the gradient
  835. item.legendSymbol = this.chart.renderer.rect(0, legend.baseline - 11, width, height).attr({
  836. zIndex: 1
  837. }).add(item.legendGroup);
  838. // Set how much space this legend item takes up
  839. this.legendItemWidth = width + padding +
  840. (horiz ? itemDistance : labelPadding);
  841. this.legendItemHeight = height + padding +
  842. (horiz ? labelPadding : 0);
  843. },
  844. /**
  845. * Fool the legend
  846. *
  847. * @private
  848. * @function Highcharts.ColorAxis#setState
  849. * @param {string} [state]
  850. * @return {void}
  851. */
  852. setState: function (state) {
  853. this.series.forEach(function (series) {
  854. series.setState(state);
  855. });
  856. },
  857. visible: true,
  858. setVisible: noop,
  859. /**
  860. * @private
  861. */
  862. getSeriesExtremes: function () {
  863. var series = this.series, colorValArray, colorKey, colorValIndex, pointArrayMap, calculatedExtremes, cSeries, i = series.length, yData, j;
  864. this.dataMin = Infinity;
  865. this.dataMax = -Infinity;
  866. while (i--) { // x, y, value, other
  867. cSeries = series[i];
  868. colorKey = cSeries.colorKey = pick(cSeries.options.colorKey, cSeries.colorKey, cSeries.pointValKey, cSeries.zoneAxis, 'y');
  869. pointArrayMap = cSeries.pointArrayMap;
  870. calculatedExtremes = cSeries[colorKey + 'Min'] &&
  871. cSeries[colorKey + 'Max'];
  872. if (cSeries[colorKey + 'Data']) {
  873. colorValArray = cSeries[colorKey + 'Data'];
  874. }
  875. else {
  876. if (!pointArrayMap) {
  877. colorValArray = cSeries.yData;
  878. }
  879. else {
  880. colorValArray = [];
  881. colorValIndex = pointArrayMap.indexOf(colorKey);
  882. yData = cSeries.yData;
  883. if (colorValIndex >= 0 && yData) {
  884. for (j = 0; j < yData.length; j++) {
  885. colorValArray.push(pick(yData[j][colorValIndex], yData[j]));
  886. }
  887. }
  888. }
  889. }
  890. // If color key extremes are already calculated, use them.
  891. if (calculatedExtremes) {
  892. cSeries.minColorValue = cSeries[colorKey + 'Min'];
  893. cSeries.maxColorValue = cSeries[colorKey + 'Max'];
  894. }
  895. else {
  896. Series.prototype.getExtremes.call(cSeries, colorValArray);
  897. cSeries.minColorValue = cSeries.dataMin;
  898. cSeries.maxColorValue = cSeries.dataMax;
  899. }
  900. if (typeof cSeries.minColorValue !== 'undefined') {
  901. this.dataMin =
  902. Math.min(this.dataMin, cSeries.minColorValue);
  903. this.dataMax =
  904. Math.max(this.dataMax, cSeries.maxColorValue);
  905. }
  906. if (!calculatedExtremes) {
  907. Series.prototype.getExtremes.call(cSeries);
  908. }
  909. }
  910. },
  911. /**
  912. * Internal function to draw a crosshair.
  913. *
  914. * @function Highcharts.ColorAxis#drawCrosshair
  915. *
  916. * @param {Highcharts.PointerEventObject} [e]
  917. * The event arguments from the modified pointer event, extended with
  918. * `chartX` and `chartY`
  919. *
  920. * @param {Highcharts.Point} [point]
  921. * The Point object if the crosshair snaps to points.
  922. *
  923. * @return {void}
  924. *
  925. * @fires Highcharts.ColorAxis#event:afterDrawCrosshair
  926. * @fires Highcharts.ColorAxis#event:drawCrosshair
  927. */
  928. drawCrosshair: function (e, point) {
  929. var plotX = point && point.plotX, plotY = point && point.plotY, crossPos, axisPos = this.pos, axisLen = this.len;
  930. if (point) {
  931. crossPos = this.toPixels(point[point.series.colorKey]);
  932. if (crossPos < axisPos) {
  933. crossPos = axisPos - 2;
  934. }
  935. else if (crossPos > axisPos + axisLen) {
  936. crossPos = axisPos + axisLen + 2;
  937. }
  938. point.plotX = crossPos;
  939. point.plotY = this.len - crossPos;
  940. Axis.prototype.drawCrosshair.call(this, e, point);
  941. point.plotX = plotX;
  942. point.plotY = plotY;
  943. if (this.cross &&
  944. !this.cross.addedToColorAxis &&
  945. this.legendGroup) {
  946. this.cross
  947. .addClass('highcharts-coloraxis-marker')
  948. .add(this.legendGroup);
  949. this.cross.addedToColorAxis = true;
  950. if (!this.chart.styledMode) {
  951. this.cross.attr({
  952. fill: this.crosshair.color
  953. });
  954. }
  955. }
  956. }
  957. },
  958. /**
  959. * @private
  960. */
  961. getPlotLinePath: function (options) {
  962. var pos = options.translatedValue;
  963. // crosshairs only
  964. return isNumber(pos) ? // pos can be 0 (#3969)
  965. (this.horiz ? [
  966. 'M',
  967. pos - 4, this.top - 6,
  968. 'L',
  969. pos + 4, this.top - 6,
  970. pos, this.top,
  971. 'Z'
  972. ] : [
  973. 'M',
  974. this.left, pos,
  975. 'L',
  976. this.left - 6, pos + 6,
  977. this.left - 6, pos - 6,
  978. 'Z'
  979. ]) :
  980. Axis.prototype.getPlotLinePath.apply(this, arguments);
  981. },
  982. /**
  983. * Updates a color axis instance with a new set of options. The options are
  984. * merged with the existing options, so only new or altered options need to
  985. * be specified.
  986. *
  987. * @function Highcharts.ColorAxis#update
  988. *
  989. * @param {Highcharts.ColorAxisOptions} newOptions
  990. * The new options that will be merged in with existing options on the color
  991. * axis.
  992. *
  993. * @param {boolean} [redraw]
  994. * Whether to redraw the chart after the color axis is altered. If doing
  995. * more operations on the chart, it is a good idea to set redraw to `false`
  996. * and call {@link Highcharts.Chart#redraw} after.
  997. *
  998. * @return {void}
  999. */
  1000. update: function (newOptions, redraw) {
  1001. var chart = this.chart, legend = chart.legend, updatedOptions = this.buildOptions.call(chart, {}, newOptions);
  1002. this.series.forEach(function (series) {
  1003. // Needed for Axis.update when choropleth colors change
  1004. series.isDirtyData = true;
  1005. });
  1006. // When updating data classes, destroy old items and make sure new
  1007. // ones are created (#3207)
  1008. if (newOptions.dataClasses && legend.allItems || this.dataClasses) {
  1009. this.destroyItems();
  1010. }
  1011. // Keep the options structure updated for export. Unlike xAxis and
  1012. // yAxis, the colorAxis is not an array. (#3207)
  1013. chart.options[this.coll] =
  1014. merge(this.userOptions, updatedOptions);
  1015. Axis.prototype.update.call(this, updatedOptions, redraw);
  1016. if (this.legendItem) {
  1017. this.setLegendColor();
  1018. legend.colorizeItem(this, true);
  1019. }
  1020. },
  1021. /**
  1022. * Destroy color axis legend items.
  1023. *
  1024. * @private
  1025. * @function Highcharts.ColorAxis#destroyItems
  1026. * @return {void}
  1027. */
  1028. destroyItems: function () {
  1029. var chart = this.chart;
  1030. if (this.legendItem) {
  1031. chart.legend.destroyItem(this);
  1032. }
  1033. else if (this.legendItems) {
  1034. this.legendItems.forEach(function (item) {
  1035. chart.legend.destroyItem(item);
  1036. });
  1037. }
  1038. chart.isDirtyLegend = true;
  1039. },
  1040. /**
  1041. * Removes the color axis and the related legend item.
  1042. *
  1043. * @function Highcharts.ColorAxis#remove
  1044. *
  1045. * @param {boolean} [redraw=true]
  1046. * Whether to redraw the chart following the remove.
  1047. *
  1048. * @return {void}
  1049. */
  1050. remove: function (redraw) {
  1051. this.destroyItems();
  1052. Axis.prototype.remove.call(this, redraw);
  1053. },
  1054. /**
  1055. * Get the legend item symbols for data classes.
  1056. *
  1057. * @private
  1058. * @function Highcharts.ColorAxis#getDataClassLegendSymbols
  1059. * @return {Array<Highcharts.ColorAxisLegendItemObject>}
  1060. */
  1061. getDataClassLegendSymbols: function () {
  1062. var axis = this, chart = this.chart, legendItems = this.legendItems, legendOptions = chart.options.legend, valueDecimals = legendOptions.valueDecimals, valueSuffix = legendOptions.valueSuffix || '', name;
  1063. if (!legendItems.length) {
  1064. this.dataClasses.forEach(function (dataClass, i) {
  1065. var vis = true, from = dataClass.from, to = dataClass.to;
  1066. var numberFormatter = chart.numberFormatter;
  1067. // Assemble the default name. This can be overridden
  1068. // by legend.options.labelFormatter
  1069. name = '';
  1070. if (typeof from === 'undefined') {
  1071. name = '< ';
  1072. }
  1073. else if (typeof to === 'undefined') {
  1074. name = '> ';
  1075. }
  1076. if (typeof from !== 'undefined') {
  1077. name += numberFormatter(from, valueDecimals) + valueSuffix;
  1078. }
  1079. if (typeof from !== 'undefined' && typeof to !== 'undefined') {
  1080. name += ' - ';
  1081. }
  1082. if (typeof to !== 'undefined') {
  1083. name += numberFormatter(to, valueDecimals) + valueSuffix;
  1084. }
  1085. // Add a mock object to the legend items
  1086. legendItems.push(extend({
  1087. chart: chart,
  1088. name: name,
  1089. options: {},
  1090. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  1091. visible: true,
  1092. setState: noop,
  1093. isDataClass: true,
  1094. setVisible: function () {
  1095. vis = this.visible = !vis;
  1096. axis.series.forEach(function (series) {
  1097. series.points.forEach(function (point) {
  1098. if (point.dataClass === i) {
  1099. point.setVisible(vis);
  1100. }
  1101. });
  1102. });
  1103. chart.legend.colorizeItem(this, vis);
  1104. }
  1105. }, dataClass));
  1106. });
  1107. }
  1108. return legendItems;
  1109. },
  1110. beforePadding: false,
  1111. name: '' // Prevents 'undefined' in legend in IE8
  1112. });
  1113. /**
  1114. * Handle animation of the color attributes directly
  1115. *
  1116. * @private
  1117. * @function Highcharts.Fx#fillSetter
  1118. */ /**
  1119. * Handle animation of the color attributes directly
  1120. *
  1121. * @private
  1122. * @function Highcharts.Fx#strokeSetter
  1123. */
  1124. ['fill', 'stroke'].forEach(function (prop) {
  1125. H.Fx.prototype[prop + 'Setter'] = function () {
  1126. this.elem.attr(prop, color(this.start).tweenTo(color(this.end), this.pos), null, true);
  1127. };
  1128. });
  1129. // Extend the chart getAxes method to also get the color axis
  1130. addEvent(Chart, 'afterGetAxes', function () {
  1131. var chart = this, options = chart.options;
  1132. this.colorAxis = [];
  1133. if (options.colorAxis) {
  1134. options.colorAxis = splat(options.colorAxis);
  1135. options.colorAxis.forEach(function (axisOptions, i) {
  1136. axisOptions.index = i;
  1137. new ColorAxis(chart, axisOptions); // eslint-disable-line no-new
  1138. });
  1139. }
  1140. });
  1141. // Add colorAxis to series axisTypes
  1142. addEvent(Series, 'bindAxes', function () {
  1143. var axisTypes = this.axisTypes;
  1144. if (!axisTypes) {
  1145. this.axisTypes = ['colorAxis'];
  1146. }
  1147. else if (axisTypes.indexOf('colorAxis') === -1) {
  1148. axisTypes.push('colorAxis');
  1149. }
  1150. });
  1151. // Add the color axis. This also removes the axis' own series to prevent
  1152. // them from showing up individually.
  1153. addEvent(Legend, 'afterGetAllItems', function (e) {
  1154. var colorAxisItems = [], colorAxes = this.chart.colorAxis || [], options, i;
  1155. colorAxes.forEach(function (colorAxis) {
  1156. options = colorAxis.options;
  1157. if (options && options.showInLegend) {
  1158. // Data classes
  1159. if (options.dataClasses && options.visible) {
  1160. colorAxisItems = colorAxisItems.concat(colorAxis.getDataClassLegendSymbols());
  1161. // Gradient legend
  1162. }
  1163. else if (options.visible) {
  1164. // Add this axis on top
  1165. colorAxisItems.push(colorAxis);
  1166. }
  1167. // If dataClasses are defined or showInLegend option is not set to
  1168. // true, do not add color axis' series to legend.
  1169. colorAxis.series.forEach(function (series) {
  1170. if (!series.options.showInLegend || options.dataClasses) {
  1171. if (series.options.legendType === 'point') {
  1172. series.points.forEach(function (point) {
  1173. erase(e.allItems, point);
  1174. });
  1175. }
  1176. else {
  1177. erase(e.allItems, series);
  1178. }
  1179. }
  1180. });
  1181. }
  1182. });
  1183. i = colorAxisItems.length;
  1184. while (i--) {
  1185. e.allItems.unshift(colorAxisItems[i]);
  1186. }
  1187. });
  1188. addEvent(Legend, 'afterColorizeItem', function (e) {
  1189. if (e.visible && e.item.legendColor) {
  1190. e.item.legendSymbol.attr({
  1191. fill: e.item.legendColor
  1192. });
  1193. }
  1194. });
  1195. // Updates in the legend need to be reflected in the color axis (6888)
  1196. addEvent(Legend, 'afterUpdate', function () {
  1197. var colorAxes = this.chart.colorAxis;
  1198. if (colorAxes) {
  1199. colorAxes.forEach(function (colorAxis) {
  1200. colorAxis.update({}, arguments[2]);
  1201. });
  1202. }
  1203. });
  1204. // Calculate and set colors for points
  1205. addEvent(Series, 'afterTranslate', function () {
  1206. if (this.chart.colorAxis &&
  1207. this.chart.colorAxis.length ||
  1208. this.colorAttribs) {
  1209. this.translateColors();
  1210. }
  1211. });
  1212. });
  1213. _registerModule(_modules, 'parts-map/ColorMapSeriesMixin.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  1214. /* *
  1215. *
  1216. * (c) 2010-2019 Torstein Honsi
  1217. *
  1218. * License: www.highcharts.com/license
  1219. *
  1220. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1221. *
  1222. * */
  1223. var defined = U.defined;
  1224. var noop = H.noop, seriesTypes = H.seriesTypes;
  1225. /**
  1226. * Mixin for maps and heatmaps
  1227. *
  1228. * @private
  1229. * @mixin Highcharts.colorMapPointMixin
  1230. */
  1231. H.colorMapPointMixin = {
  1232. dataLabelOnNull: true,
  1233. /* eslint-disable valid-jsdoc */
  1234. /**
  1235. * Color points have a value option that determines whether or not it is
  1236. * a null point
  1237. * @private
  1238. * @function Highcharts.colorMapPointMixin.isValid
  1239. * @return {boolean}
  1240. */
  1241. isValid: function () {
  1242. // undefined is allowed
  1243. return (this.value !== null &&
  1244. this.value !== Infinity &&
  1245. this.value !== -Infinity);
  1246. },
  1247. /**
  1248. * @private
  1249. * @function Highcharts.colorMapPointMixin.setState
  1250. * @param {string} state
  1251. * @return {void}
  1252. */
  1253. setState: function (state) {
  1254. H.Point.prototype.setState.call(this, state);
  1255. if (this.graphic) {
  1256. this.graphic.attr({
  1257. zIndex: state === 'hover' ? 1 : 0
  1258. });
  1259. }
  1260. }
  1261. /* eslint-enable valid-jsdoc */
  1262. };
  1263. /**
  1264. * @private
  1265. * @mixin Highcharts.colorMapSeriesMixin
  1266. */
  1267. H.colorMapSeriesMixin = {
  1268. pointArrayMap: ['value'],
  1269. axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
  1270. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  1271. getSymbol: noop,
  1272. parallelArrays: ['x', 'y', 'value'],
  1273. colorKey: 'value',
  1274. pointAttribs: seriesTypes.column.prototype.pointAttribs,
  1275. /* eslint-disable valid-jsdoc */
  1276. /**
  1277. * Get the color attibutes to apply on the graphic
  1278. * @private
  1279. * @function Highcharts.colorMapSeriesMixin.colorAttribs
  1280. * @param {Highcharts.Point} point
  1281. * @return {Highcharts.SVGAttributes}
  1282. */
  1283. colorAttribs: function (point) {
  1284. var ret = {};
  1285. if (defined(point.color)) {
  1286. ret[this.colorProp || 'fill'] = point.color;
  1287. }
  1288. return ret;
  1289. }
  1290. };
  1291. });
  1292. _registerModule(_modules, 'parts-map/HeatmapSeries.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  1293. /* *
  1294. *
  1295. * (c) 2010-2019 Torstein Honsi
  1296. *
  1297. * License: www.highcharts.com/license
  1298. *
  1299. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1300. *
  1301. * */
  1302. /* *
  1303. * @interface Highcharts.PointOptionsObject in parts/Point.ts
  1304. */ /**
  1305. * Heatmap series only. Point padding for a single point.
  1306. * @name Highcharts.PointOptionsObject#pointPadding
  1307. * @type {number|undefined}
  1308. */ /**
  1309. * Heatmap series only. The value of the point, resulting in a color controled
  1310. * by options as set in the colorAxis configuration.
  1311. * @name Highcharts.PointOptionsObject#value
  1312. * @type {number|null|undefined}
  1313. */
  1314. var clamp = U.clamp, extend = U.extend, pick = U.pick;
  1315. var colorMapPointMixin = H.colorMapPointMixin, colorMapSeriesMixin = H.colorMapSeriesMixin, LegendSymbolMixin = H.LegendSymbolMixin, merge = H.merge, noop = H.noop, fireEvent = H.fireEvent, Series = H.Series, seriesType = H.seriesType, seriesTypes = H.seriesTypes;
  1316. /**
  1317. * @private
  1318. * @class
  1319. * @name Highcharts.seriesTypes.heatmap
  1320. *
  1321. * @augments Highcharts.Series
  1322. */
  1323. seriesType('heatmap', 'scatter',
  1324. /**
  1325. * A heatmap is a graphical representation of data where the individual
  1326. * values contained in a matrix are represented as colors.
  1327. *
  1328. * @productdesc {highcharts}
  1329. * Requires `modules/heatmap`.
  1330. *
  1331. * @sample highcharts/demo/heatmap/
  1332. * Simple heatmap
  1333. * @sample highcharts/demo/heatmap-canvas/
  1334. * Heavy heatmap
  1335. *
  1336. * @extends plotOptions.scatter
  1337. * @excluding animationLimit, connectEnds, connectNulls, dashStyle,
  1338. * findNearestPointBy, getExtremesFromAll, jitter, linecap,
  1339. * lineWidth, marker, pointInterval, pointIntervalUnit,
  1340. * pointRange, pointStart, shadow, softThreshold, stacking,
  1341. * step, threshold, cluster
  1342. * @product highcharts highmaps
  1343. * @optionparent plotOptions.heatmap
  1344. */
  1345. {
  1346. /**
  1347. * Animation is disabled by default on the heatmap series.
  1348. */
  1349. animation: false,
  1350. /**
  1351. * The border width for each heat map item.
  1352. */
  1353. borderWidth: 0,
  1354. /**
  1355. * Padding between the points in the heatmap.
  1356. *
  1357. * @type {number}
  1358. * @default 0
  1359. * @since 6.0
  1360. * @apioption plotOptions.heatmap.pointPadding
  1361. */
  1362. /**
  1363. * @default value
  1364. * @apioption plotOptions.heatmap.colorKey
  1365. */
  1366. /**
  1367. * The main color of the series. In heat maps this color is rarely used,
  1368. * as we mostly use the color to denote the value of each point. Unless
  1369. * options are set in the [colorAxis](#colorAxis), the default value
  1370. * is pulled from the [options.colors](#colors) array.
  1371. *
  1372. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1373. * @since 4.0
  1374. * @product highcharts
  1375. * @apioption plotOptions.heatmap.color
  1376. */
  1377. /**
  1378. * The column size - how many X axis units each column in the heatmap
  1379. * should span.
  1380. *
  1381. * @sample {highcharts} maps/demo/heatmap/
  1382. * One day
  1383. * @sample {highmaps} maps/demo/heatmap/
  1384. * One day
  1385. *
  1386. * @type {number}
  1387. * @default 1
  1388. * @since 4.0
  1389. * @product highcharts highmaps
  1390. * @apioption plotOptions.heatmap.colsize
  1391. */
  1392. /**
  1393. * The row size - how many Y axis units each heatmap row should span.
  1394. *
  1395. * @sample {highcharts} maps/demo/heatmap/
  1396. * 1 by default
  1397. * @sample {highmaps} maps/demo/heatmap/
  1398. * 1 by default
  1399. *
  1400. * @type {number}
  1401. * @default 1
  1402. * @since 4.0
  1403. * @product highcharts highmaps
  1404. * @apioption plotOptions.heatmap.rowsize
  1405. */
  1406. /**
  1407. * The color applied to null points. In styled mode, a general CSS class
  1408. * is applied instead.
  1409. *
  1410. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1411. */
  1412. nullColor: '#f7f7f7',
  1413. dataLabels: {
  1414. formatter: function () {
  1415. return this.point.value;
  1416. },
  1417. inside: true,
  1418. verticalAlign: 'middle',
  1419. crop: false,
  1420. overflow: false,
  1421. padding: 0 // #3837
  1422. },
  1423. /** @ignore-option */
  1424. marker: null,
  1425. /** @ignore-option */
  1426. pointRange: null,
  1427. tooltip: {
  1428. pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
  1429. },
  1430. states: {
  1431. hover: {
  1432. /** @ignore-option */
  1433. halo: false,
  1434. /**
  1435. * How much to brighten the point on interaction. Requires the
  1436. * main color to be defined in hex or rgb(a) format.
  1437. *
  1438. * In styled mode, the hover brightening is by default replaced
  1439. * with a fill-opacity set in the `.highcharts-point:hover`
  1440. * rule.
  1441. */
  1442. brightness: 0.2
  1443. }
  1444. }
  1445. }, merge(colorMapSeriesMixin, {
  1446. pointArrayMap: ['y', 'value'],
  1447. hasPointSpecificOptions: true,
  1448. getExtremesFromAll: true,
  1449. directTouch: true,
  1450. /* eslint-disable valid-jsdoc */
  1451. /**
  1452. * Override the init method to add point ranges on both axes.
  1453. *
  1454. * @private
  1455. * @function Highcharts.seriesTypes.heatmap#init
  1456. * @return {void}
  1457. */
  1458. init: function () {
  1459. var options;
  1460. seriesTypes.scatter.prototype.init.apply(this, arguments);
  1461. options = this.options;
  1462. // #3758, prevent resetting in setData
  1463. options.pointRange = pick(options.pointRange, options.colsize || 1);
  1464. // general point range
  1465. this.yAxis.axisPointRange = options.rowsize || 1;
  1466. },
  1467. /**
  1468. * @private
  1469. * @function Highcharts.seriesTypes.heatmap#translate
  1470. * @return {void}
  1471. */
  1472. translate: function () {
  1473. var series = this, options = series.options, xAxis = series.xAxis, yAxis = series.yAxis, seriesPointPadding = options.pointPadding || 0, pointPlacement = series.pointPlacementToXValue(); // #7860
  1474. series.generatePoints();
  1475. series.points.forEach(function (point) {
  1476. var xPad = (options.colsize || 1) / 2, yPad = (options.rowsize || 1) / 2, x1 = clamp(Math.round(xAxis.len -
  1477. xAxis.translate(point.x - xPad, 0, 1, 0, 1, -pointPlacement)), -xAxis.len, 2 * xAxis.len), x2 = clamp(Math.round(xAxis.len -
  1478. xAxis.translate(point.x + xPad, 0, 1, 0, 1, -pointPlacement)), -xAxis.len, 2 * xAxis.len), y1 = clamp(Math.round(yAxis.translate(point.y - yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len), y2 = clamp(Math.round(yAxis.translate(point.y + yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len), pointPadding = pick(point.pointPadding, seriesPointPadding);
  1479. // Set plotX and plotY for use in K-D-Tree and more
  1480. point.plotX = point.clientX = (x1 + x2) / 2;
  1481. point.plotY = (y1 + y2) / 2;
  1482. point.shapeType = 'rect';
  1483. point.shapeArgs = {
  1484. x: Math.min(x1, x2) + pointPadding,
  1485. y: Math.min(y1, y2) + pointPadding,
  1486. width: Math.max(Math.abs(x2 - x1) - pointPadding * 2, 0),
  1487. height: Math.max(Math.abs(y2 - y1) - pointPadding * 2, 0)
  1488. };
  1489. });
  1490. fireEvent(series, 'afterTranslate');
  1491. },
  1492. /**
  1493. * @private
  1494. * @function Highcharts.seriesTypes.heatmap#drawPoints
  1495. * @return {void}
  1496. */
  1497. drawPoints: function () {
  1498. // In styled mode, use CSS, otherwise the fill used in the style
  1499. // sheet will take precedence over the fill attribute.
  1500. var func = this.chart.styledMode ? 'css' : 'animate';
  1501. seriesTypes.column.prototype.drawPoints.call(this);
  1502. this.points.forEach(function (point) {
  1503. point.graphic[func](this.colorAttribs(point));
  1504. }, this);
  1505. },
  1506. // Define hasData function for non-cartesian series.
  1507. // Returns true if the series has points at all.
  1508. hasData: function () {
  1509. return !!this.processedXData.length; // != 0
  1510. },
  1511. // Override to also allow null points, used when building the k-d-tree
  1512. // for tooltips in boost mode.
  1513. getValidPoints: function (points, insideOnly) {
  1514. return Series.prototype.getValidPoints.call(this, points, insideOnly, true);
  1515. },
  1516. /**
  1517. * @ignore
  1518. * @deprecated
  1519. * @function Highcharts.seriesTypes.heatmap#animate
  1520. */
  1521. animate: noop,
  1522. /**
  1523. * @ignore
  1524. * @deprecated
  1525. * @function Highcharts.seriesTypes.heatmap#getBox
  1526. */
  1527. getBox: noop,
  1528. /**
  1529. * @private
  1530. * @borrows Highcharts.LegendSymbolMixin.drawRectangle as Highcharts.seriesTypes.heatmap#drawLegendSymbol
  1531. */
  1532. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  1533. /**
  1534. * @private
  1535. * @borrows Highcharts.seriesTypes.column#alignDataLabel as Highcharts.seriesTypes.heatmap#alignDataLabel
  1536. */
  1537. alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
  1538. /**
  1539. * @private
  1540. * @function Highcharts.seriesTypes.heatmap#getExtremes
  1541. * @return {void}
  1542. */
  1543. getExtremes: function () {
  1544. // Get the extremes from the value data
  1545. Series.prototype.getExtremes.call(this, this.valueData);
  1546. this.valueMin = this.dataMin;
  1547. this.valueMax = this.dataMax;
  1548. // Get the extremes from the y data
  1549. Series.prototype.getExtremes.call(this);
  1550. }
  1551. /* eslint-enable valid-jsdoc */
  1552. }), extend({
  1553. /**
  1554. * Heatmap series only. Padding between the points in the heatmap.
  1555. * @name Highcharts.Point#pointPadding
  1556. * @type {number|undefined}
  1557. */
  1558. /**
  1559. * Heatmap series only. The value of the point, resulting in a color
  1560. * controled by options as set in the colorAxis configuration.
  1561. * @name Highcharts.Point#value
  1562. * @type {number|null|undefined}
  1563. */
  1564. /* eslint-disable valid-jsdoc */
  1565. /**
  1566. * @private
  1567. * @function Highcharts.Point#haloPath
  1568. * @param {number} size
  1569. * @return {Highcharts.SVGPathArray}
  1570. */
  1571. haloPath: function (size) {
  1572. if (!size) {
  1573. return [];
  1574. }
  1575. var rect = this.shapeArgs;
  1576. return [
  1577. 'M',
  1578. rect.x - size,
  1579. rect.y - size,
  1580. 'L',
  1581. rect.x - size,
  1582. rect.y + rect.height + size,
  1583. rect.x + rect.width + size,
  1584. rect.y + rect.height + size,
  1585. rect.x + rect.width + size,
  1586. rect.y - size,
  1587. 'Z'
  1588. ];
  1589. }
  1590. /* eslint-enable valid-jsdoc */
  1591. }, colorMapPointMixin));
  1592. /**
  1593. * A `heatmap` series. If the [type](#series.heatmap.type) option is
  1594. * not specified, it is inherited from [chart.type](#chart.type).
  1595. *
  1596. * @productdesc {highcharts}
  1597. * Requires `modules/heatmap`.
  1598. *
  1599. * @extends series,plotOptions.heatmap
  1600. * @excluding dataParser, dataURL, marker, pointRange, stack
  1601. * @product highcharts highmaps
  1602. * @apioption series.heatmap
  1603. */
  1604. /**
  1605. * An array of data points for the series. For the `heatmap` series
  1606. * type, points can be given in the following ways:
  1607. *
  1608. * 1. An array of arrays with 3 or 2 values. In this case, the values
  1609. * correspond to `x,y,value`. If the first value is a string, it is
  1610. * applied as the name of the point, and the `x` value is inferred.
  1611. * The `x` value can also be omitted, in which case the inner arrays
  1612. * should be of length 2\. Then the `x` value is automatically calculated,
  1613. * either starting at 0 and incremented by 1, or from `pointStart`
  1614. * and `pointInterval` given in the series options.
  1615. *
  1616. * ```js
  1617. * data: [
  1618. * [0, 9, 7],
  1619. * [1, 10, 4],
  1620. * [2, 6, 3]
  1621. * ]
  1622. * ```
  1623. *
  1624. * 2. An array of objects with named values. The following snippet shows only a
  1625. * few settings, see the complete options set below. If the total number of data
  1626. * points exceeds the series' [turboThreshold](#series.heatmap.turboThreshold),
  1627. * this option is not available.
  1628. *
  1629. * ```js
  1630. * data: [{
  1631. * x: 1,
  1632. * y: 3,
  1633. * value: 10,
  1634. * name: "Point2",
  1635. * color: "#00FF00"
  1636. * }, {
  1637. * x: 1,
  1638. * y: 7,
  1639. * value: 10,
  1640. * name: "Point1",
  1641. * color: "#FF00FF"
  1642. * }]
  1643. * ```
  1644. *
  1645. * @sample {highcharts} highcharts/chart/reflow-true/
  1646. * Numerical values
  1647. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  1648. * Arrays of numeric x and y
  1649. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  1650. * Arrays of datetime x and y
  1651. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  1652. * Arrays of point.name and y
  1653. * @sample {highcharts} highcharts/series/data-array-of-objects/
  1654. * Config objects
  1655. *
  1656. * @type {Array<Array<number>|*>}
  1657. * @extends series.line.data
  1658. * @excluding marker
  1659. * @product highcharts highmaps
  1660. * @apioption series.heatmap.data
  1661. */
  1662. /**
  1663. * The color of the point. In heat maps the point color is rarely set
  1664. * explicitly, as we use the color to denote the `value`. Options for
  1665. * this are set in the [colorAxis](#colorAxis) configuration.
  1666. *
  1667. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1668. * @product highcharts highmaps
  1669. * @apioption series.heatmap.data.color
  1670. */
  1671. /**
  1672. * The value of the point, resulting in a color controled by options
  1673. * as set in the [colorAxis](#colorAxis) configuration.
  1674. *
  1675. * @type {number}
  1676. * @product highcharts highmaps
  1677. * @apioption series.heatmap.data.value
  1678. */
  1679. /**
  1680. * The x value of the point. For datetime axes,
  1681. * the X value is the timestamp in milliseconds since 1970.
  1682. *
  1683. * @type {number}
  1684. * @product highcharts highmaps
  1685. * @apioption series.heatmap.data.x
  1686. */
  1687. /**
  1688. * The y value of the point.
  1689. *
  1690. * @type {number}
  1691. * @product highcharts highmaps
  1692. * @apioption series.heatmap.data.y
  1693. */
  1694. /**
  1695. * Point padding for a single point.
  1696. *
  1697. * @sample maps/plotoptions/tilemap-pointpadding
  1698. * Point padding on tiles
  1699. *
  1700. * @type {number}
  1701. * @product highcharts highmaps
  1702. * @apioption series.heatmap.data.pointPadding
  1703. */
  1704. ''; // adds doclets above to transpiled file
  1705. });
  1706. _registerModule(_modules, 'masters/modules/heatmap.src.js', [], function () {
  1707. });
  1708. }));