heatmap.src.js 57 KB

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