heatmap.src.js 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431
  1. /**
  2. * @license Highmaps JS v8.2.0 (2020-08-20)
  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, 'Mixins/ColorSeries.js', [_modules['Core/Globals.js']], function (H) {
  30. /* *
  31. *
  32. * (c) 2010-2020 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,
  56. method = vis ? 'show' : 'hide';
  57. point.visible = point.options.visible = Boolean(vis);
  58. // Show and hide associated elements
  59. ['graphic', 'dataLabel'].forEach(function (key) {
  60. if (point[key]) {
  61. point[key][method]();
  62. }
  63. });
  64. this.series.buildKDTree(); // rebuild kdtree #13195
  65. }
  66. /* eslint-enable valid-jsdoc */
  67. };
  68. /**
  69. * @private
  70. * @mixin Highcharts.colorSeriesMixin
  71. */
  72. H.colorSeriesMixin = {
  73. optionalAxis: 'colorAxis',
  74. colorAxis: 0,
  75. /* eslint-disable valid-jsdoc */
  76. /**
  77. * In choropleth maps, the color is a result of the value, so this needs
  78. * translation too
  79. * @private
  80. * @function Highcharts.colorSeriesMixin.translateColors
  81. * @return {void}
  82. */
  83. translateColors: function () {
  84. var series = this,
  85. points = this.data.length ? this.data : this.points,
  86. nullColor = this.options.nullColor,
  87. colorAxis = this.colorAxis,
  88. colorKey = this.colorKey;
  89. points.forEach(function (point) {
  90. var value = point.getNestedProperty(colorKey),
  91. color;
  92. color = point.options.color ||
  93. (point.isNull || point.value === null ?
  94. nullColor :
  95. (colorAxis && typeof value !== 'undefined') ?
  96. colorAxis.toColor(value, point) :
  97. point.color || series.color);
  98. if (color && point.color !== color) {
  99. point.color = color;
  100. if (series.options.legendType === 'point' && point.legendItem) {
  101. series.chart.legend.colorizeItem(point, point.visible);
  102. }
  103. }
  104. });
  105. }
  106. /* eslint-enable valid-jsdoc */
  107. };
  108. });
  109. _registerModule(_modules, 'Core/Axis/ColorAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Color.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (Axis, Chart, Color, H, Legend, LegendSymbolMixin, Point, U) {
  110. /* *
  111. *
  112. * (c) 2010-2020 Torstein Honsi
  113. *
  114. * License: www.highcharts.com/license
  115. *
  116. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  117. *
  118. * */
  119. var __extends = (this && this.__extends) || (function () {
  120. var extendStatics = function (d,
  121. b) {
  122. extendStatics = Object.setPrototypeOf ||
  123. ({ __proto__: [] } instanceof Array && function (d,
  124. b) { d.__proto__ = b; }) ||
  125. function (d,
  126. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  127. return extendStatics(d, b);
  128. };
  129. return function (d, b) {
  130. extendStatics(d, b);
  131. function __() { this.constructor = d; }
  132. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  133. };
  134. })();
  135. var color = Color.parse;
  136. var noop = H.noop;
  137. var addEvent = U.addEvent,
  138. erase = U.erase,
  139. extend = U.extend,
  140. Fx = U.Fx,
  141. isNumber = U.isNumber,
  142. merge = U.merge,
  143. pick = U.pick,
  144. splat = U.splat;
  145. /**
  146. * Color axis types
  147. *
  148. * @typedef {"linear"|"logarithmic"} Highcharts.ColorAxisTypeValue
  149. */
  150. ''; // detach doclet above
  151. var Series = H.Series,
  152. colorPointMixin = H.colorPointMixin,
  153. colorSeriesMixin = H.colorSeriesMixin;
  154. extend(Series.prototype, colorSeriesMixin);
  155. extend(Point.prototype, colorPointMixin);
  156. Chart.prototype.collectionsWithUpdate.push('colorAxis');
  157. Chart.prototype.collectionsWithInit.colorAxis = [Chart.prototype.addColorAxis];
  158. /* eslint-disable no-invalid-this, valid-jsdoc */
  159. /**
  160. * The ColorAxis object for inclusion in gradient legends.
  161. *
  162. * @class
  163. * @name Highcharts.ColorAxis
  164. * @augments Highcharts.Axis
  165. *
  166. * @param {Highcharts.Chart} chart
  167. * The related chart of the color axis.
  168. *
  169. * @param {Highcharts.ColorAxisOptions} userOptions
  170. * The color axis options for initialization.
  171. */
  172. var ColorAxis = /** @class */ (function (_super) {
  173. __extends(ColorAxis, _super);
  174. /* *
  175. *
  176. * Constructors
  177. *
  178. * */
  179. /**
  180. * @private
  181. */
  182. function ColorAxis(chart, userOptions) {
  183. var _this = _super.call(this,
  184. chart,
  185. userOptions) || this;
  186. _this.beforePadding = false; // Prevents unnecessary padding with `hc-more`
  187. _this.chart = void 0;
  188. _this.coll = 'colorAxis';
  189. _this.dataClasses = void 0;
  190. _this.legendItem = void 0;
  191. _this.legendItems = void 0;
  192. _this.name = ''; // Prevents 'undefined' in legend in IE8
  193. _this.options = void 0;
  194. _this.stops = void 0;
  195. _this.visible = true;
  196. _this.init(chart, userOptions);
  197. return _this;
  198. }
  199. /* *
  200. *
  201. * Static Functions
  202. *
  203. * */
  204. /**
  205. * Build options to keep layout params on init and update.
  206. * @private
  207. */
  208. ColorAxis.buildOptions = function (chart, options, userOptions) {
  209. var legend = chart.options.legend || {},
  210. horiz = userOptions.layout ?
  211. userOptions.layout !== 'vertical' :
  212. legend.layout !== 'vertical';
  213. return merge(options, {
  214. side: horiz ? 2 : 1,
  215. reversed: !horiz
  216. }, userOptions, {
  217. opposite: !horiz,
  218. showEmpty: false,
  219. title: null,
  220. visible: legend.enabled &&
  221. (userOptions ? userOptions.visible !== false : true)
  222. });
  223. };
  224. /* *
  225. *
  226. * Functions
  227. *
  228. * */
  229. /**
  230. * Initializes the color axis.
  231. *
  232. * @function Highcharts.ColorAxis#init
  233. *
  234. * @param {Highcharts.Chart} chart
  235. * The related chart of the color axis.
  236. *
  237. * @param {Highcharts.ColorAxisOptions} userOptions
  238. * The color axis options for initialization.
  239. */
  240. ColorAxis.prototype.init = function (chart, userOptions) {
  241. var axis = this;
  242. var options = ColorAxis.buildOptions(// Build the options
  243. chart,
  244. ColorAxis.defaultOptions,
  245. userOptions);
  246. axis.coll = 'colorAxis';
  247. _super.prototype.init.call(this, chart, options);
  248. // Base init() pushes it to the xAxis array, now pop it again
  249. // chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop();
  250. // Prepare data classes
  251. if (userOptions.dataClasses) {
  252. axis.initDataClasses(userOptions);
  253. }
  254. axis.initStops();
  255. // Override original axis properties
  256. axis.horiz = !options.opposite;
  257. axis.zoomEnabled = false;
  258. };
  259. /**
  260. * @private
  261. */
  262. ColorAxis.prototype.initDataClasses = function (userOptions) {
  263. var axis = this;
  264. var chart = axis.chart,
  265. dataClasses,
  266. colorCounter = 0,
  267. colorCount = chart.options.chart.colorCount,
  268. options = axis.options,
  269. len = userOptions.dataClasses.length;
  270. axis.dataClasses = dataClasses = [];
  271. axis.legendItems = [];
  272. userOptions.dataClasses.forEach(function (dataClass, i) {
  273. var colors;
  274. dataClass = merge(dataClass);
  275. dataClasses.push(dataClass);
  276. if (!chart.styledMode && dataClass.color) {
  277. return;
  278. }
  279. if (options.dataClassColor === 'category') {
  280. if (!chart.styledMode) {
  281. colors = chart.options.colors;
  282. colorCount = colors.length;
  283. dataClass.color = colors[colorCounter];
  284. }
  285. dataClass.colorIndex = colorCounter;
  286. // increase and loop back to zero
  287. colorCounter++;
  288. if (colorCounter === colorCount) {
  289. colorCounter = 0;
  290. }
  291. }
  292. else {
  293. dataClass.color = color(options.minColor).tweenTo(color(options.maxColor), len < 2 ? 0.5 : i / (len - 1) // #3219
  294. );
  295. }
  296. });
  297. };
  298. /**
  299. * Returns true if the series has points at all.
  300. *
  301. * @function Highcharts.ColorAxis#hasData
  302. *
  303. * @return {boolean}
  304. * True, if the series has points, otherwise false.
  305. */
  306. ColorAxis.prototype.hasData = function () {
  307. return !!(this.tickPositions || []).length;
  308. };
  309. /**
  310. * Override so that ticks are not added in data class axes (#6914)
  311. * @private
  312. */
  313. ColorAxis.prototype.setTickPositions = function () {
  314. if (!this.dataClasses) {
  315. return _super.prototype.setTickPositions.call(this);
  316. }
  317. };
  318. /**
  319. * @private
  320. */
  321. ColorAxis.prototype.initStops = function () {
  322. var axis = this;
  323. axis.stops = axis.options.stops || [
  324. [0, axis.options.minColor],
  325. [1, axis.options.maxColor]
  326. ];
  327. axis.stops.forEach(function (stop) {
  328. stop.color = color(stop[1]);
  329. });
  330. };
  331. /**
  332. * Extend the setOptions method to process extreme colors and color stops.
  333. * @private
  334. */
  335. ColorAxis.prototype.setOptions = function (userOptions) {
  336. var axis = this;
  337. _super.prototype.setOptions.call(this, userOptions);
  338. axis.options.crosshair = axis.options.marker;
  339. };
  340. /**
  341. * @private
  342. */
  343. ColorAxis.prototype.setAxisSize = function () {
  344. var axis = this;
  345. var symbol = axis.legendSymbol;
  346. var chart = axis.chart;
  347. var legendOptions = chart.options.legend || {};
  348. var x,
  349. y,
  350. width,
  351. height;
  352. if (symbol) {
  353. this.left = x = symbol.attr('x');
  354. this.top = y = symbol.attr('y');
  355. this.width = width = symbol.attr('width');
  356. this.height = height = symbol.attr('height');
  357. this.right = chart.chartWidth - x - width;
  358. this.bottom = chart.chartHeight - y - height;
  359. this.len = this.horiz ? width : height;
  360. this.pos = this.horiz ? x : y;
  361. }
  362. else {
  363. // Fake length for disabled legend to avoid tick issues
  364. // and such (#5205)
  365. this.len = (this.horiz ?
  366. legendOptions.symbolWidth :
  367. legendOptions.symbolHeight) || ColorAxis.defaultLegendLength;
  368. }
  369. };
  370. /**
  371. * @private
  372. */
  373. ColorAxis.prototype.normalizedValue = function (value) {
  374. var axis = this;
  375. if (axis.logarithmic) {
  376. value = axis.logarithmic.log2lin(value);
  377. }
  378. return 1 - ((axis.max - value) /
  379. ((axis.max - axis.min) || 1));
  380. };
  381. /**
  382. * Translate from a value to a color.
  383. * @private
  384. */
  385. ColorAxis.prototype.toColor = function (value, point) {
  386. var axis = this;
  387. var dataClasses = axis.dataClasses;
  388. var stops = axis.stops;
  389. var pos,
  390. from,
  391. to,
  392. color,
  393. dataClass,
  394. i;
  395. if (dataClasses) {
  396. i = dataClasses.length;
  397. while (i--) {
  398. dataClass = dataClasses[i];
  399. from = dataClass.from;
  400. to = dataClass.to;
  401. if ((typeof from === 'undefined' || value >= from) &&
  402. (typeof to === 'undefined' || value <= to)) {
  403. color = dataClass.color;
  404. if (point) {
  405. point.dataClass = i;
  406. point.colorIndex = dataClass.colorIndex;
  407. }
  408. break;
  409. }
  410. }
  411. }
  412. else {
  413. pos = axis.normalizedValue(value);
  414. i = stops.length;
  415. while (i--) {
  416. if (pos > stops[i][0]) {
  417. break;
  418. }
  419. }
  420. from = stops[i] || stops[i + 1];
  421. to = stops[i + 1] || from;
  422. // The position within the gradient
  423. pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
  424. color = from.color.tweenTo(to.color, pos);
  425. }
  426. return color;
  427. };
  428. /**
  429. * Override the getOffset method to add the whole axis groups inside the
  430. * legend.
  431. * @private
  432. */
  433. ColorAxis.prototype.getOffset = function () {
  434. var axis = this;
  435. var group = axis.legendGroup;
  436. var sideOffset = axis.chart.axisOffset[axis.side];
  437. if (group) {
  438. // Hook for the getOffset method to add groups to this parent
  439. // group
  440. axis.axisParent = group;
  441. // Call the base
  442. _super.prototype.getOffset.call(this);
  443. // First time only
  444. if (!axis.added) {
  445. axis.added = true;
  446. axis.labelLeft = 0;
  447. axis.labelRight = axis.width;
  448. }
  449. // Reset it to avoid color axis reserving space
  450. axis.chart.axisOffset[axis.side] = sideOffset;
  451. }
  452. };
  453. /**
  454. * Create the color gradient.
  455. * @private
  456. */
  457. ColorAxis.prototype.setLegendColor = function () {
  458. var axis = this;
  459. var horiz = axis.horiz;
  460. var reversed = axis.reversed;
  461. var one = reversed ? 1 : 0;
  462. var zero = reversed ? 0 : 1;
  463. var grad = horiz ? [one, 0,
  464. zero, 0] : [0,
  465. zero, 0,
  466. one]; // #3190
  467. axis.legendColor = {
  468. linearGradient: {
  469. x1: grad[0],
  470. y1: grad[1],
  471. x2: grad[2],
  472. y2: grad[3]
  473. },
  474. stops: axis.stops
  475. };
  476. };
  477. /**
  478. * The color axis appears inside the legend and has its own legend symbol.
  479. * @private
  480. */
  481. ColorAxis.prototype.drawLegendSymbol = function (legend, item) {
  482. var axis = this;
  483. var padding = legend.padding;
  484. var legendOptions = legend.options;
  485. var horiz = axis.horiz;
  486. var width = pick(legendOptions.symbolWidth,
  487. horiz ? ColorAxis.defaultLegendLength : 12);
  488. var height = pick(legendOptions.symbolHeight,
  489. horiz ? 12 : ColorAxis.defaultLegendLength);
  490. var labelPadding = pick(legendOptions.labelPadding,
  491. horiz ? 16 : 30);
  492. var itemDistance = pick(legendOptions.itemDistance, 10);
  493. this.setLegendColor();
  494. // Create the gradient
  495. item.legendSymbol = this.chart.renderer.rect(0, legend.baseline - 11, width, height).attr({
  496. zIndex: 1
  497. }).add(item.legendGroup);
  498. // Set how much space this legend item takes up
  499. axis.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding);
  500. axis.legendItemHeight = height + padding + (horiz ? labelPadding : 0);
  501. };
  502. /**
  503. * Fool the legend.
  504. * @private
  505. */
  506. ColorAxis.prototype.setState = function (state) {
  507. this.series.forEach(function (series) {
  508. series.setState(state);
  509. });
  510. };
  511. /**
  512. * @private
  513. */
  514. ColorAxis.prototype.setVisible = function () {
  515. };
  516. /**
  517. * @private
  518. */
  519. ColorAxis.prototype.getSeriesExtremes = function () {
  520. var axis = this;
  521. var series = axis.series;
  522. var colorValArray,
  523. colorKey,
  524. colorValIndex,
  525. pointArrayMap,
  526. calculatedExtremes,
  527. cSeries,
  528. i = series.length,
  529. yData,
  530. j;
  531. this.dataMin = Infinity;
  532. this.dataMax = -Infinity;
  533. while (i--) { // x, y, value, other
  534. cSeries = series[i];
  535. colorKey = cSeries.colorKey = pick(cSeries.options.colorKey, cSeries.colorKey, cSeries.pointValKey, cSeries.zoneAxis, 'y');
  536. pointArrayMap = cSeries.pointArrayMap;
  537. calculatedExtremes = cSeries[colorKey + 'Min'] &&
  538. cSeries[colorKey + 'Max'];
  539. if (cSeries[colorKey + 'Data']) {
  540. colorValArray = cSeries[colorKey + 'Data'];
  541. }
  542. else {
  543. if (!pointArrayMap) {
  544. colorValArray = cSeries.yData;
  545. }
  546. else {
  547. colorValArray = [];
  548. colorValIndex = pointArrayMap.indexOf(colorKey);
  549. yData = cSeries.yData;
  550. if (colorValIndex >= 0 && yData) {
  551. for (j = 0; j < yData.length; j++) {
  552. colorValArray.push(pick(yData[j][colorValIndex], yData[j]));
  553. }
  554. }
  555. }
  556. }
  557. // If color key extremes are already calculated, use them.
  558. if (calculatedExtremes) {
  559. cSeries.minColorValue = cSeries[colorKey + 'Min'];
  560. cSeries.maxColorValue = cSeries[colorKey + 'Max'];
  561. }
  562. else {
  563. var cExtremes = Series.prototype.getExtremes.call(cSeries,
  564. colorValArray);
  565. cSeries.minColorValue = cExtremes.dataMin;
  566. cSeries.maxColorValue = cExtremes.dataMax;
  567. }
  568. if (typeof cSeries.minColorValue !== 'undefined') {
  569. this.dataMin =
  570. Math.min(this.dataMin, cSeries.minColorValue);
  571. this.dataMax =
  572. Math.max(this.dataMax, cSeries.maxColorValue);
  573. }
  574. if (!calculatedExtremes) {
  575. Series.prototype.applyExtremes.call(cSeries);
  576. }
  577. }
  578. };
  579. /**
  580. * Internal function to draw a crosshair.
  581. *
  582. * @function Highcharts.ColorAxis#drawCrosshair
  583. *
  584. * @param {Highcharts.PointerEventObject} [e]
  585. * The event arguments from the modified pointer event, extended with
  586. * `chartX` and `chartY`
  587. *
  588. * @param {Highcharts.Point} [point]
  589. * The Point object if the crosshair snaps to points.
  590. *
  591. * @fires Highcharts.ColorAxis#event:afterDrawCrosshair
  592. * @fires Highcharts.ColorAxis#event:drawCrosshair
  593. */
  594. ColorAxis.prototype.drawCrosshair = function (e, point) {
  595. var axis = this;
  596. var plotX = point && point.plotX;
  597. var plotY = point && point.plotY;
  598. var axisPos = axis.pos;
  599. var axisLen = axis.len;
  600. var crossPos;
  601. if (point) {
  602. crossPos = axis.toPixels(point.getNestedProperty(point.series.colorKey));
  603. if (crossPos < axisPos) {
  604. crossPos = axisPos - 2;
  605. }
  606. else if (crossPos > axisPos + axisLen) {
  607. crossPos = axisPos + axisLen + 2;
  608. }
  609. point.plotX = crossPos;
  610. point.plotY = axis.len - crossPos;
  611. _super.prototype.drawCrosshair.call(this, e, point);
  612. point.plotX = plotX;
  613. point.plotY = plotY;
  614. if (axis.cross &&
  615. !axis.cross.addedToColorAxis &&
  616. axis.legendGroup) {
  617. axis.cross
  618. .addClass('highcharts-coloraxis-marker')
  619. .add(axis.legendGroup);
  620. axis.cross.addedToColorAxis = true;
  621. if (!axis.chart.styledMode &&
  622. axis.crosshair) {
  623. axis.cross.attr({
  624. fill: axis.crosshair.color
  625. });
  626. }
  627. }
  628. }
  629. };
  630. /**
  631. * @private
  632. */
  633. ColorAxis.prototype.getPlotLinePath = function (options) {
  634. var axis = this,
  635. left = axis.left,
  636. pos = options.translatedValue,
  637. top = axis.top;
  638. // crosshairs only
  639. return isNumber(pos) ? // pos can be 0 (#3969)
  640. (axis.horiz ? [
  641. ['M', pos - 4, top - 6],
  642. ['L', pos + 4, top - 6],
  643. ['L', pos, top],
  644. ['Z']
  645. ] : [
  646. ['M', left, pos],
  647. ['L', left - 6, pos + 6],
  648. ['L', left - 6, pos - 6],
  649. ['Z']
  650. ]) :
  651. _super.prototype.getPlotLinePath.call(this, options);
  652. };
  653. /**
  654. * Updates a color axis instance with a new set of options. The options are
  655. * merged with the existing options, so only new or altered options need to
  656. * be specified.
  657. *
  658. * @function Highcharts.ColorAxis#update
  659. *
  660. * @param {Highcharts.ColorAxisOptions} newOptions
  661. * The new options that will be merged in with existing options on the color
  662. * axis.
  663. *
  664. * @param {boolean} [redraw]
  665. * Whether to redraw the chart after the color axis is altered. If doing
  666. * more operations on the chart, it is a good idea to set redraw to `false`
  667. * and call {@link Highcharts.Chart#redraw} after.
  668. */
  669. ColorAxis.prototype.update = function (newOptions, redraw) {
  670. var axis = this,
  671. chart = axis.chart,
  672. legend = chart.legend,
  673. updatedOptions = ColorAxis.buildOptions(chart, {},
  674. newOptions);
  675. this.series.forEach(function (series) {
  676. // Needed for Axis.update when choropleth colors change
  677. series.isDirtyData = true;
  678. });
  679. // When updating data classes, destroy old items and make sure new
  680. // ones are created (#3207)
  681. if (newOptions.dataClasses && legend.allItems || axis.dataClasses) {
  682. axis.destroyItems();
  683. }
  684. // Keep the options structure updated for export. Unlike xAxis and
  685. // yAxis, the colorAxis is not an array. (#3207)
  686. chart.options[axis.coll] =
  687. merge(axis.userOptions, updatedOptions);
  688. _super.prototype.update.call(this, updatedOptions, redraw);
  689. if (axis.legendItem) {
  690. axis.setLegendColor();
  691. legend.colorizeItem(this, true);
  692. }
  693. };
  694. /**
  695. * Destroy color axis legend items.
  696. * @private
  697. */
  698. ColorAxis.prototype.destroyItems = function () {
  699. var axis = this;
  700. var chart = axis.chart;
  701. if (axis.legendItem) {
  702. chart.legend.destroyItem(axis);
  703. }
  704. else if (axis.legendItems) {
  705. axis.legendItems.forEach(function (item) {
  706. chart.legend.destroyItem(item);
  707. });
  708. }
  709. chart.isDirtyLegend = true;
  710. };
  711. /**
  712. * Removes the color axis and the related legend item.
  713. *
  714. * @function Highcharts.ColorAxis#remove
  715. *
  716. * @param {boolean} [redraw=true]
  717. * Whether to redraw the chart following the remove.
  718. */
  719. ColorAxis.prototype.remove = function (redraw) {
  720. this.destroyItems();
  721. _super.prototype.remove.call(this, redraw);
  722. };
  723. /**
  724. * Get the legend item symbols for data classes.
  725. * @private
  726. */
  727. ColorAxis.prototype.getDataClassLegendSymbols = function () {
  728. var axis = this;
  729. var chart = axis.chart;
  730. var legendItems = axis.legendItems;
  731. var legendOptions = chart.options.legend;
  732. var valueDecimals = legendOptions.valueDecimals;
  733. var valueSuffix = legendOptions.valueSuffix || '';
  734. var name;
  735. if (!legendItems.length) {
  736. axis.dataClasses.forEach(function (dataClass, i) {
  737. var vis = true,
  738. from = dataClass.from,
  739. to = dataClass.to;
  740. var numberFormatter = chart.numberFormatter;
  741. // Assemble the default name. This can be overridden
  742. // by legend.options.labelFormatter
  743. name = '';
  744. if (typeof from === 'undefined') {
  745. name = '< ';
  746. }
  747. else if (typeof to === 'undefined') {
  748. name = '> ';
  749. }
  750. if (typeof from !== 'undefined') {
  751. name += numberFormatter(from, valueDecimals) + valueSuffix;
  752. }
  753. if (typeof from !== 'undefined' && typeof to !== 'undefined') {
  754. name += ' - ';
  755. }
  756. if (typeof to !== 'undefined') {
  757. name += numberFormatter(to, valueDecimals) + valueSuffix;
  758. }
  759. // Add a mock object to the legend items
  760. legendItems.push(extend({
  761. chart: chart,
  762. name: name,
  763. options: {},
  764. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  765. visible: true,
  766. setState: noop,
  767. isDataClass: true,
  768. setVisible: function () {
  769. vis = axis.visible = !vis;
  770. axis.series.forEach(function (series) {
  771. series.points.forEach(function (point) {
  772. if (point.dataClass === i) {
  773. point.setVisible(vis);
  774. }
  775. });
  776. });
  777. chart.legend.colorizeItem(this, vis);
  778. }
  779. }, dataClass));
  780. });
  781. }
  782. return legendItems;
  783. };
  784. /* *
  785. *
  786. * Static Functions
  787. *
  788. * */
  789. ColorAxis.defaultLegendLength = 200;
  790. /**
  791. * A color axis for series. Visually, the color
  792. * axis will appear as a gradient or as separate items inside the
  793. * legend, depending on whether the axis is scalar or based on data
  794. * classes.
  795. *
  796. * For supported color formats, see the
  797. * [docs article about colors](https://www.highcharts.com/docs/chart-design-and-style/colors).
  798. *
  799. * A scalar color axis is represented by a gradient. The colors either
  800. * range between the [minColor](#colorAxis.minColor) and the
  801. * [maxColor](#colorAxis.maxColor), or for more fine grained control the
  802. * colors can be defined in [stops](#colorAxis.stops). Often times, the
  803. * color axis needs to be adjusted to get the right color spread for the
  804. * data. In addition to stops, consider using a logarithmic
  805. * [axis type](#colorAxis.type), or setting [min](#colorAxis.min) and
  806. * [max](#colorAxis.max) to avoid the colors being determined by
  807. * outliers.
  808. *
  809. * When [dataClasses](#colorAxis.dataClasses) are used, the ranges are
  810. * subdivided into separate classes like categories based on their
  811. * values. This can be used for ranges between two values, but also for
  812. * a true category. However, when your data is categorized, it may be as
  813. * convenient to add each category to a separate series.
  814. *
  815. * Color axis does not work with: `sankey`, `sunburst`, `dependencywheel`,
  816. * `networkgraph`, `wordcloud`, `venn`, `gauge` and `solidgauge` series
  817. * types.
  818. *
  819. * Since v7.2.0 `colorAxis` can also be an array of options objects.
  820. *
  821. * See [the Axis object](/class-reference/Highcharts.Axis) for
  822. * programmatic access to the axis.
  823. *
  824. * @sample {highcharts} highcharts/coloraxis/custom-color-key
  825. * Column chart with color axis
  826. * @sample {highcharts} highcharts/coloraxis/horizontal-layout
  827. * Horizontal layout
  828. * @sample {highmaps} maps/coloraxis/dataclasscolor
  829. * With data classes
  830. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor
  831. * Min color and max color
  832. *
  833. * @extends xAxis
  834. * @excluding alignTicks, allowDecimals, alternateGridColor, breaks,
  835. * categories, crosshair, dateTimeLabelFormats, height, left,
  836. * lineWidth, linkedTo, maxZoom, minRange, minTickInterval,
  837. * offset, opposite, pane, plotBands, plotLines,
  838. * reversedStacks, showEmpty, title, top, width, zoomEnabled
  839. * @product highcharts highstock highmaps
  840. * @type {*|Array<*>}
  841. * @optionparent colorAxis
  842. * @ignore
  843. */
  844. ColorAxis.defaultOptions = {
  845. /**
  846. * Whether to allow decimals on the color axis.
  847. * @type {boolean}
  848. * @default true
  849. * @product highcharts highstock highmaps
  850. * @apioption colorAxis.allowDecimals
  851. */
  852. /**
  853. * Determines how to set each data class' color if no individual
  854. * color is set. The default value, `tween`, computes intermediate
  855. * colors between `minColor` and `maxColor`. The other possible
  856. * value, `category`, pulls colors from the global or chart specific
  857. * [colors](#colors) array.
  858. *
  859. * @sample {highmaps} maps/coloraxis/dataclasscolor/
  860. * Category colors
  861. *
  862. * @type {string}
  863. * @default tween
  864. * @product highcharts highstock highmaps
  865. * @validvalue ["tween", "category"]
  866. * @apioption colorAxis.dataClassColor
  867. */
  868. /**
  869. * An array of data classes or ranges for the choropleth map. If
  870. * none given, the color axis is scalar and values are distributed
  871. * as a gradient between the minimum and maximum colors.
  872. *
  873. * @sample {highmaps} maps/demo/data-class-ranges/
  874. * Multiple ranges
  875. *
  876. * @sample {highmaps} maps/demo/data-class-two-ranges/
  877. * Two ranges
  878. *
  879. * @type {Array<*>}
  880. * @product highcharts highstock highmaps
  881. * @apioption colorAxis.dataClasses
  882. */
  883. /**
  884. * The layout of the color axis. Can be `'horizontal'` or `'vertical'`.
  885. * If none given, the color axis has the same layout as the legend.
  886. *
  887. * @sample highcharts/coloraxis/horizontal-layout/
  888. * Horizontal color axis layout with vertical legend
  889. *
  890. * @type {string|undefined}
  891. * @since 7.2.0
  892. * @product highcharts highstock highmaps
  893. * @apioption colorAxis.layout
  894. */
  895. /**
  896. * The color of each data class. If not set, the color is pulled
  897. * from the global or chart-specific [colors](#colors) array. In
  898. * styled mode, this option is ignored. Instead, use colors defined
  899. * in CSS.
  900. *
  901. * @sample {highmaps} maps/demo/data-class-two-ranges/
  902. * Explicit colors
  903. *
  904. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  905. * @product highcharts highstock highmaps
  906. * @apioption colorAxis.dataClasses.color
  907. */
  908. /**
  909. * The start of the value range that the data class represents,
  910. * relating to the point value.
  911. *
  912. * The range of each `dataClass` is closed in both ends, but can be
  913. * overridden by the next `dataClass`.
  914. *
  915. * @type {number}
  916. * @product highcharts highstock highmaps
  917. * @apioption colorAxis.dataClasses.from
  918. */
  919. /**
  920. * The name of the data class as it appears in the legend.
  921. * If no name is given, it is automatically created based on the
  922. * `from` and `to` values. For full programmatic control,
  923. * [legend.labelFormatter](#legend.labelFormatter) can be used.
  924. * In the formatter, `this.from` and `this.to` can be accessed.
  925. *
  926. * @sample {highmaps} maps/coloraxis/dataclasses-name/
  927. * Named data classes
  928. *
  929. * @sample {highmaps} maps/coloraxis/dataclasses-labelformatter/
  930. * Formatted data classes
  931. *
  932. * @type {string}
  933. * @product highcharts highstock highmaps
  934. * @apioption colorAxis.dataClasses.name
  935. */
  936. /**
  937. * The end of the value range that the data class represents,
  938. * relating to the point value.
  939. *
  940. * The range of each `dataClass` is closed in both ends, but can be
  941. * overridden by the next `dataClass`.
  942. *
  943. * @type {number}
  944. * @product highcharts highstock highmaps
  945. * @apioption colorAxis.dataClasses.to
  946. */
  947. /** @ignore-option */
  948. lineWidth: 0,
  949. /**
  950. * Padding of the min value relative to the length of the axis. A
  951. * padding of 0.05 will make a 100px axis 5px longer.
  952. *
  953. * @product highcharts highstock highmaps
  954. */
  955. minPadding: 0,
  956. /**
  957. * The maximum value of the axis in terms of map point values. If
  958. * `null`, the max value is automatically calculated. If the
  959. * `endOnTick` option is true, the max value might be rounded up.
  960. *
  961. * @sample {highmaps} maps/coloraxis/gridlines/
  962. * Explicit min and max to reduce the effect of outliers
  963. *
  964. * @type {number}
  965. * @product highcharts highstock highmaps
  966. * @apioption colorAxis.max
  967. */
  968. /**
  969. * The minimum value of the axis in terms of map point values. If
  970. * `null`, the min value is automatically calculated. If the
  971. * `startOnTick` option is true, the min value might be rounded
  972. * down.
  973. *
  974. * @sample {highmaps} maps/coloraxis/gridlines/
  975. * Explicit min and max to reduce the effect of outliers
  976. *
  977. * @type {number}
  978. * @product highcharts highstock highmaps
  979. * @apioption colorAxis.min
  980. */
  981. /**
  982. * Padding of the max value relative to the length of the axis. A
  983. * padding of 0.05 will make a 100px axis 5px longer.
  984. *
  985. * @product highcharts highstock highmaps
  986. */
  987. maxPadding: 0,
  988. /**
  989. * Color of the grid lines extending from the axis across the
  990. * gradient.
  991. *
  992. * @sample {highmaps} maps/coloraxis/gridlines/
  993. * Grid lines demonstrated
  994. *
  995. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  996. * @default #e6e6e6
  997. * @product highcharts highstock highmaps
  998. * @apioption colorAxis.gridLineColor
  999. */
  1000. /**
  1001. * The width of the grid lines extending from the axis across the
  1002. * gradient of a scalar color axis.
  1003. *
  1004. * @sample {highmaps} maps/coloraxis/gridlines/
  1005. * Grid lines demonstrated
  1006. *
  1007. * @product highcharts highstock highmaps
  1008. */
  1009. gridLineWidth: 1,
  1010. /**
  1011. * The interval of the tick marks in axis units. When `null`, the
  1012. * tick interval is computed to approximately follow the
  1013. * `tickPixelInterval`.
  1014. *
  1015. * @type {number}
  1016. * @product highcharts highstock highmaps
  1017. * @apioption colorAxis.tickInterval
  1018. */
  1019. /**
  1020. * If [tickInterval](#colorAxis.tickInterval) is `null` this option
  1021. * sets the approximate pixel interval of the tick marks.
  1022. *
  1023. * @product highcharts highstock highmaps
  1024. */
  1025. tickPixelInterval: 72,
  1026. /**
  1027. * Whether to force the axis to start on a tick. Use this option
  1028. * with the `maxPadding` option to control the axis start.
  1029. *
  1030. * @product highcharts highstock highmaps
  1031. */
  1032. startOnTick: true,
  1033. /**
  1034. * Whether to force the axis to end on a tick. Use this option with
  1035. * the [maxPadding](#colorAxis.maxPadding) option to control the
  1036. * axis end.
  1037. *
  1038. * @product highcharts highstock highmaps
  1039. */
  1040. endOnTick: true,
  1041. /** @ignore */
  1042. offset: 0,
  1043. /**
  1044. * The triangular marker on a scalar color axis that points to the
  1045. * value of the hovered area. To disable the marker, set
  1046. * `marker: null`.
  1047. *
  1048. * @sample {highmaps} maps/coloraxis/marker/
  1049. * Black marker
  1050. *
  1051. * @declare Highcharts.PointMarkerOptionsObject
  1052. * @product highcharts highstock highmaps
  1053. */
  1054. marker: {
  1055. /**
  1056. * Animation for the marker as it moves between values. Set to
  1057. * `false` to disable animation. Defaults to `{ duration: 50 }`.
  1058. *
  1059. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  1060. * @product highcharts highstock highmaps
  1061. */
  1062. animation: {
  1063. /** @internal */
  1064. duration: 50
  1065. },
  1066. /** @internal */
  1067. width: 0.01,
  1068. /**
  1069. * The color of the marker.
  1070. *
  1071. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1072. * @product highcharts highstock highmaps
  1073. */
  1074. color: '#999999'
  1075. },
  1076. /**
  1077. * The axis labels show the number for each tick.
  1078. *
  1079. * For more live examples on label options, see [xAxis.labels in the
  1080. * Highcharts API.](/highcharts#xAxis.labels)
  1081. *
  1082. * @extends xAxis.labels
  1083. * @product highcharts highstock highmaps
  1084. */
  1085. labels: {
  1086. /**
  1087. * How to handle overflowing labels on horizontal color axis. If set
  1088. * to `"allow"`, it will not be aligned at all. By default it
  1089. * `"justify"` labels inside the chart area. If there is room to
  1090. * move it, it will be aligned to the edge, else it will be removed.
  1091. *
  1092. * @validvalue ["allow", "justify"]
  1093. * @product highcharts highstock highmaps
  1094. */
  1095. overflow: 'justify',
  1096. rotation: 0
  1097. },
  1098. /**
  1099. * The color to represent the minimum of the color axis. Unless
  1100. * [dataClasses](#colorAxis.dataClasses) or
  1101. * [stops](#colorAxis.stops) are set, the gradient starts at this
  1102. * value.
  1103. *
  1104. * If dataClasses are set, the color is based on minColor and
  1105. * maxColor unless a color is set for each data class, or the
  1106. * [dataClassColor](#colorAxis.dataClassColor) is set.
  1107. *
  1108. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor/
  1109. * Min and max colors on scalar (gradient) axis
  1110. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor-dataclasses/
  1111. * On data classes
  1112. *
  1113. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1114. * @product highcharts highstock highmaps
  1115. */
  1116. minColor: '#e6ebf5',
  1117. /**
  1118. * The color to represent the maximum of the color axis. Unless
  1119. * [dataClasses](#colorAxis.dataClasses) or
  1120. * [stops](#colorAxis.stops) are set, the gradient ends at this
  1121. * value.
  1122. *
  1123. * If dataClasses are set, the color is based on minColor and
  1124. * maxColor unless a color is set for each data class, or the
  1125. * [dataClassColor](#colorAxis.dataClassColor) is set.
  1126. *
  1127. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor/
  1128. * Min and max colors on scalar (gradient) axis
  1129. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor-dataclasses/
  1130. * On data classes
  1131. *
  1132. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1133. * @product highcharts highstock highmaps
  1134. */
  1135. maxColor: '#003399',
  1136. /**
  1137. * Color stops for the gradient of a scalar color axis. Use this in
  1138. * cases where a linear gradient between a `minColor` and `maxColor`
  1139. * is not sufficient. The stops is an array of tuples, where the
  1140. * first item is a float between 0 and 1 assigning the relative
  1141. * position in the gradient, and the second item is the color.
  1142. *
  1143. * @sample {highmaps} maps/demo/heatmap/
  1144. * Heatmap with three color stops
  1145. *
  1146. * @type {Array<Array<number,Highcharts.ColorString>>}
  1147. * @product highcharts highstock highmaps
  1148. * @apioption colorAxis.stops
  1149. */
  1150. /**
  1151. * The pixel length of the main tick marks on the color axis.
  1152. */
  1153. tickLength: 5,
  1154. /**
  1155. * The type of interpolation to use for the color axis. Can be
  1156. * `linear` or `logarithmic`.
  1157. *
  1158. * @sample highcharts/coloraxis/logarithmic-with-emulate-negative-values/
  1159. * Logarithmic color axis with extension to emulate negative
  1160. * values
  1161. *
  1162. * @type {Highcharts.ColorAxisTypeValue}
  1163. * @default linear
  1164. * @product highcharts highstock highmaps
  1165. * @apioption colorAxis.type
  1166. */
  1167. /**
  1168. * Whether to reverse the axis so that the highest number is closest
  1169. * to the origin. Defaults to `false` in a horizontal legend and
  1170. * `true` in a vertical legend, where the smallest value starts on
  1171. * top.
  1172. *
  1173. * @type {boolean}
  1174. * @product highcharts highstock highmaps
  1175. * @apioption colorAxis.reversed
  1176. */
  1177. /**
  1178. * @product highcharts highstock highmaps
  1179. * @excluding afterBreaks, pointBreak, pointInBreak
  1180. * @apioption colorAxis.events
  1181. */
  1182. /**
  1183. * Fires when the legend item belonging to the colorAxis is clicked.
  1184. * One parameter, `event`, is passed to the function.
  1185. *
  1186. * @type {Function}
  1187. * @product highcharts highstock highmaps
  1188. * @apioption colorAxis.events.legendItemClick
  1189. */
  1190. /**
  1191. * Whether to display the colorAxis in the legend.
  1192. *
  1193. * @sample highcharts/coloraxis/hidden-coloraxis-with-3d-chart/
  1194. * Hidden color axis with 3d chart
  1195. *
  1196. * @see [heatmap.showInLegend](#series.heatmap.showInLegend)
  1197. *
  1198. * @since 4.2.7
  1199. * @product highcharts highstock highmaps
  1200. */
  1201. showInLegend: true
  1202. };
  1203. /**
  1204. * @private
  1205. */
  1206. ColorAxis.keepProps = [
  1207. 'legendGroup',
  1208. 'legendItemHeight',
  1209. 'legendItemWidth',
  1210. 'legendItem',
  1211. 'legendSymbol'
  1212. ];
  1213. return ColorAxis;
  1214. }(Axis));
  1215. // Properties to preserve after destroy, for Axis.update (#5881, #6025).
  1216. Array.prototype.push.apply(Axis.keepProps, ColorAxis.keepProps);
  1217. H.ColorAxis = ColorAxis;
  1218. /**
  1219. * Handle animation of the color attributes directly
  1220. *
  1221. * @private
  1222. * @function Highcharts.Fx#fillSetter
  1223. */ /**
  1224. * Handle animation of the color attributes directly
  1225. *
  1226. * @private
  1227. * @function Highcharts.Fx#strokeSetter
  1228. */
  1229. ['fill', 'stroke'].forEach(function (prop) {
  1230. Fx.prototype[prop + 'Setter'] = function () {
  1231. this.elem.attr(prop, color(this.start).tweenTo(color(this.end), this.pos), null, true);
  1232. };
  1233. });
  1234. // Extend the chart getAxes method to also get the color axis
  1235. addEvent(Chart, 'afterGetAxes', function () {
  1236. var chart = this,
  1237. options = chart.options;
  1238. this.colorAxis = [];
  1239. if (options.colorAxis) {
  1240. options.colorAxis = splat(options.colorAxis);
  1241. options.colorAxis.forEach(function (axisOptions, i) {
  1242. axisOptions.index = i;
  1243. new ColorAxis(chart, axisOptions); // eslint-disable-line no-new
  1244. });
  1245. }
  1246. });
  1247. // Add colorAxis to series axisTypes
  1248. addEvent(Series, 'bindAxes', function () {
  1249. var axisTypes = this.axisTypes;
  1250. if (!axisTypes) {
  1251. this.axisTypes = ['colorAxis'];
  1252. }
  1253. else if (axisTypes.indexOf('colorAxis') === -1) {
  1254. axisTypes.push('colorAxis');
  1255. }
  1256. });
  1257. // Add the color axis. This also removes the axis' own series to prevent
  1258. // them from showing up individually.
  1259. addEvent(Legend, 'afterGetAllItems', function (e) {
  1260. var colorAxisItems = [],
  1261. colorAxes = this.chart.colorAxis || [],
  1262. options,
  1263. i;
  1264. colorAxes.forEach(function (colorAxis) {
  1265. options = colorAxis.options;
  1266. if (options && options.showInLegend) {
  1267. // Data classes
  1268. if (options.dataClasses && options.visible) {
  1269. colorAxisItems = colorAxisItems.concat(colorAxis.getDataClassLegendSymbols());
  1270. // Gradient legend
  1271. }
  1272. else if (options.visible) {
  1273. // Add this axis on top
  1274. colorAxisItems.push(colorAxis);
  1275. }
  1276. // If dataClasses are defined or showInLegend option is not set to
  1277. // true, do not add color axis' series to legend.
  1278. colorAxis.series.forEach(function (series) {
  1279. if (!series.options.showInLegend || options.dataClasses) {
  1280. if (series.options.legendType === 'point') {
  1281. series.points.forEach(function (point) {
  1282. erase(e.allItems, point);
  1283. });
  1284. }
  1285. else {
  1286. erase(e.allItems, series);
  1287. }
  1288. }
  1289. });
  1290. }
  1291. });
  1292. i = colorAxisItems.length;
  1293. while (i--) {
  1294. e.allItems.unshift(colorAxisItems[i]);
  1295. }
  1296. });
  1297. addEvent(Legend, 'afterColorizeItem', function (e) {
  1298. if (e.visible && e.item.legendColor) {
  1299. e.item.legendSymbol.attr({
  1300. fill: e.item.legendColor
  1301. });
  1302. }
  1303. });
  1304. // Updates in the legend need to be reflected in the color axis (6888)
  1305. addEvent(Legend, 'afterUpdate', function () {
  1306. var colorAxes = this.chart.colorAxis;
  1307. if (colorAxes) {
  1308. colorAxes.forEach(function (colorAxis) {
  1309. colorAxis.update({}, arguments[2]);
  1310. });
  1311. }
  1312. });
  1313. // Calculate and set colors for points
  1314. addEvent(Series, 'afterTranslate', function () {
  1315. if (this.chart.colorAxis &&
  1316. this.chart.colorAxis.length ||
  1317. this.colorAttribs) {
  1318. this.translateColors();
  1319. }
  1320. });
  1321. return ColorAxis;
  1322. });
  1323. _registerModule(_modules, 'Mixins/ColorMapSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, Point, U) {
  1324. /* *
  1325. *
  1326. * (c) 2010-2020 Torstein Honsi
  1327. *
  1328. * License: www.highcharts.com/license
  1329. *
  1330. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1331. *
  1332. * */
  1333. var defined = U.defined;
  1334. var noop = H.noop,
  1335. seriesTypes = H.seriesTypes;
  1336. /**
  1337. * Mixin for maps and heatmaps
  1338. *
  1339. * @private
  1340. * @mixin Highcharts.colorMapPointMixin
  1341. */
  1342. H.colorMapPointMixin = {
  1343. dataLabelOnNull: true,
  1344. /* eslint-disable valid-jsdoc */
  1345. /**
  1346. * Color points have a value option that determines whether or not it is
  1347. * a null point
  1348. * @private
  1349. * @function Highcharts.colorMapPointMixin.isValid
  1350. * @return {boolean}
  1351. */
  1352. isValid: function () {
  1353. // undefined is allowed
  1354. return (this.value !== null &&
  1355. this.value !== Infinity &&
  1356. this.value !== -Infinity);
  1357. },
  1358. /**
  1359. * @private
  1360. * @function Highcharts.colorMapPointMixin.setState
  1361. * @param {string} state
  1362. * @return {void}
  1363. */
  1364. setState: function (state) {
  1365. Point.prototype.setState.call(this, state);
  1366. if (this.graphic) {
  1367. this.graphic.attr({
  1368. zIndex: state === 'hover' ? 1 : 0
  1369. });
  1370. }
  1371. }
  1372. /* eslint-enable valid-jsdoc */
  1373. };
  1374. /**
  1375. * @private
  1376. * @mixin Highcharts.colorMapSeriesMixin
  1377. */
  1378. H.colorMapSeriesMixin = {
  1379. pointArrayMap: ['value'],
  1380. axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
  1381. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  1382. getSymbol: noop,
  1383. parallelArrays: ['x', 'y', 'value'],
  1384. colorKey: 'value',
  1385. pointAttribs: seriesTypes.column.prototype.pointAttribs,
  1386. /* eslint-disable valid-jsdoc */
  1387. /**
  1388. * Get the color attibutes to apply on the graphic
  1389. * @private
  1390. * @function Highcharts.colorMapSeriesMixin.colorAttribs
  1391. * @param {Highcharts.Point} point
  1392. * @return {Highcharts.SVGAttributes}
  1393. */
  1394. colorAttribs: function (point) {
  1395. var ret = {};
  1396. if (defined(point.color)) {
  1397. ret[this.colorProp || 'fill'] = point.color;
  1398. }
  1399. return ret;
  1400. }
  1401. };
  1402. });
  1403. _registerModule(_modules, 'Series/HeatmapSeries.js', [_modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (H, LegendSymbolMixin, SVGRenderer, U) {
  1404. /* *
  1405. *
  1406. * (c) 2010-2020 Torstein Honsi
  1407. *
  1408. * License: www.highcharts.com/license
  1409. *
  1410. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1411. *
  1412. * */
  1413. var clamp = U.clamp,
  1414. extend = U.extend,
  1415. fireEvent = U.fireEvent,
  1416. isNumber = U.isNumber,
  1417. merge = U.merge,
  1418. pick = U.pick,
  1419. seriesType = U.seriesType;
  1420. /* *
  1421. * @interface Highcharts.PointOptionsObject in parts/Point.ts
  1422. */ /**
  1423. * Heatmap series only. Point padding for a single point.
  1424. * @name Highcharts.PointOptionsObject#pointPadding
  1425. * @type {number|undefined}
  1426. */ /**
  1427. * Heatmap series only. The value of the point, resulting in a color controled
  1428. * by options as set in the colorAxis configuration.
  1429. * @name Highcharts.PointOptionsObject#value
  1430. * @type {number|null|undefined}
  1431. */
  1432. ''; // detach doclets above
  1433. var colorMapPointMixin = H.colorMapPointMixin,
  1434. colorMapSeriesMixin = H.colorMapSeriesMixin,
  1435. noop = H.noop,
  1436. Series = H.Series,
  1437. seriesTypes = H.seriesTypes,
  1438. symbols = SVGRenderer.prototype.symbols;
  1439. /**
  1440. * @private
  1441. * @class
  1442. * @name Highcharts.seriesTypes.heatmap
  1443. *
  1444. * @augments Highcharts.Series
  1445. */
  1446. seriesType('heatmap', 'scatter',
  1447. /**
  1448. * A heatmap is a graphical representation of data where the individual
  1449. * values contained in a matrix are represented as colors.
  1450. *
  1451. * @productdesc {highcharts}
  1452. * Requires `modules/heatmap`.
  1453. *
  1454. * @sample highcharts/demo/heatmap/
  1455. * Simple heatmap
  1456. * @sample highcharts/demo/heatmap-canvas/
  1457. * Heavy heatmap
  1458. *
  1459. * @extends plotOptions.scatter
  1460. * @excluding animationLimit, connectEnds, connectNulls, cropThreshold,
  1461. * dashStyle, findNearestPointBy, getExtremesFromAll, jitter,
  1462. * linecap, lineWidth, pointInterval, pointIntervalUnit,
  1463. * pointRange, pointStart, shadow, softThreshold, stacking,
  1464. * step, threshold, cluster
  1465. * @product highcharts highmaps
  1466. * @optionparent plotOptions.heatmap
  1467. */
  1468. {
  1469. /**
  1470. * Animation is disabled by default on the heatmap series.
  1471. */
  1472. animation: false,
  1473. /**
  1474. * The border width for each heat map item.
  1475. */
  1476. borderWidth: 0,
  1477. /**
  1478. * Padding between the points in the heatmap.
  1479. *
  1480. * @type {number}
  1481. * @default 0
  1482. * @since 6.0
  1483. * @apioption plotOptions.heatmap.pointPadding
  1484. */
  1485. /**
  1486. * @default value
  1487. * @apioption plotOptions.heatmap.colorKey
  1488. */
  1489. /**
  1490. * The main color of the series. In heat maps this color is rarely used,
  1491. * as we mostly use the color to denote the value of each point. Unless
  1492. * options are set in the [colorAxis](#colorAxis), the default value
  1493. * is pulled from the [options.colors](#colors) array.
  1494. *
  1495. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1496. * @since 4.0
  1497. * @product highcharts
  1498. * @apioption plotOptions.heatmap.color
  1499. */
  1500. /**
  1501. * The column size - how many X axis units each column in the heatmap
  1502. * should span.
  1503. *
  1504. * @sample {highcharts} maps/demo/heatmap/
  1505. * One day
  1506. * @sample {highmaps} maps/demo/heatmap/
  1507. * One day
  1508. *
  1509. * @type {number}
  1510. * @default 1
  1511. * @since 4.0
  1512. * @product highcharts highmaps
  1513. * @apioption plotOptions.heatmap.colsize
  1514. */
  1515. /**
  1516. * The row size - how many Y axis units each heatmap row should span.
  1517. *
  1518. * @sample {highcharts} maps/demo/heatmap/
  1519. * 1 by default
  1520. * @sample {highmaps} maps/demo/heatmap/
  1521. * 1 by default
  1522. *
  1523. * @type {number}
  1524. * @default 1
  1525. * @since 4.0
  1526. * @product highcharts highmaps
  1527. * @apioption plotOptions.heatmap.rowsize
  1528. */
  1529. /**
  1530. * The color applied to null points. In styled mode, a general CSS class
  1531. * is applied instead.
  1532. *
  1533. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1534. */
  1535. nullColor: '#f7f7f7',
  1536. dataLabels: {
  1537. formatter: function () {
  1538. return this.point.value;
  1539. },
  1540. inside: true,
  1541. verticalAlign: 'middle',
  1542. crop: false,
  1543. overflow: false,
  1544. padding: 0 // #3837
  1545. },
  1546. /**
  1547. * @excluding radius, enabledThreshold
  1548. * @since 8.1
  1549. */
  1550. marker: {
  1551. /**
  1552. * A predefined shape or symbol for the marker. When undefined, the
  1553. * symbol is pulled from options.symbols. Other possible values are
  1554. * `'circle'`, `'square'`,`'diamond'`, `'triangle'`,
  1555. * `'triangle-down'`, `'rect'`, and `'ellipse'`.
  1556. *
  1557. * Additionally, the URL to a graphic can be given on this form:
  1558. * `'url(graphic.png)'`. Note that for the image to be applied to
  1559. * exported charts, its URL needs to be accessible by the export
  1560. * server.
  1561. *
  1562. * Custom callbacks for symbol path generation can also be added to
  1563. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  1564. * used by its method name, as shown in the demo.
  1565. *
  1566. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  1567. * Predefined, graphic and custom markers
  1568. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  1569. * Predefined, graphic and custom markers
  1570. */
  1571. symbol: 'rect',
  1572. /** @ignore-option */
  1573. radius: 0,
  1574. lineColor: void 0,
  1575. states: {
  1576. /**
  1577. * @excluding radius, radiusPlus
  1578. */
  1579. hover: {
  1580. /**
  1581. * Set the marker's fixed width on hover state.
  1582. *
  1583. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  1584. * 70px fixed marker's width and height on hover
  1585. *
  1586. * @type {number|undefined}
  1587. * @default undefined
  1588. * @product highcharts highmaps
  1589. * @apioption plotOptions.heatmap.marker.states.hover.width
  1590. */
  1591. /**
  1592. * Set the marker's fixed height on hover state.
  1593. *
  1594. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  1595. * 70px fixed marker's width and height on hover
  1596. *
  1597. * @type {number|undefined}
  1598. * @default undefined
  1599. * @product highcharts highmaps
  1600. * @apioption plotOptions.heatmap.marker.states.hover.height
  1601. */
  1602. /**
  1603. * The number of pixels to increase the width of the
  1604. * selected point.
  1605. *
  1606. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  1607. * 20px greater width and height on hover
  1608. *
  1609. * @type {number|undefined}
  1610. * @default undefined
  1611. * @product highcharts highmaps
  1612. * @apioption plotOptions.heatmap.marker.states.hover.widthPlus
  1613. */
  1614. /**
  1615. * The number of pixels to increase the height of the
  1616. * selected point.
  1617. *
  1618. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  1619. * 20px greater width and height on hover
  1620. *
  1621. * @type {number|undefined}
  1622. * @default undefined
  1623. * @product highcharts highmaps
  1624. * @apioption plotOptions.heatmap.marker.states.hover.heightPlus
  1625. */
  1626. /**
  1627. * The additional line width for a hovered point.
  1628. *
  1629. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  1630. * 5 pixels wider lineWidth on hover
  1631. * @sample {highmaps} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  1632. * 5 pixels wider lineWidth on hover
  1633. */
  1634. lineWidthPlus: 0
  1635. },
  1636. /**
  1637. * @excluding radius
  1638. */
  1639. select: {
  1640. /**
  1641. * Set the marker's fixed width on select state.
  1642. *
  1643. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  1644. * 70px fixed marker's width and height on hover
  1645. *
  1646. * @type {number|undefined}
  1647. * @default undefined
  1648. * @product highcharts highmaps
  1649. * @apioption plotOptions.heatmap.marker.states.select.width
  1650. */
  1651. /**
  1652. * Set the marker's fixed height on select state.
  1653. *
  1654. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  1655. * 70px fixed marker's width and height on hover
  1656. *
  1657. * @type {number|undefined}
  1658. * @default undefined
  1659. * @product highcharts highmaps
  1660. * @apioption plotOptions.heatmap.marker.states.select.height
  1661. */
  1662. /**
  1663. * The number of pixels to increase the width of the
  1664. * selected point.
  1665. *
  1666. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  1667. * 20px greater width and height on hover
  1668. *
  1669. * @type {number|undefined}
  1670. * @default undefined
  1671. * @product highcharts highmaps
  1672. * @apioption plotOptions.heatmap.marker.states.select.widthPlus
  1673. */
  1674. /**
  1675. * The number of pixels to increase the height of the
  1676. * selected point.
  1677. *
  1678. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  1679. * 20px greater width and height on hover
  1680. *
  1681. * @type {number|undefined}
  1682. * @default undefined
  1683. * @product highcharts highmaps
  1684. * @apioption plotOptions.heatmap.marker.states.select.heightPlus
  1685. */
  1686. }
  1687. }
  1688. },
  1689. clip: true,
  1690. /** @ignore-option */
  1691. pointRange: null,
  1692. tooltip: {
  1693. pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
  1694. },
  1695. states: {
  1696. hover: {
  1697. /** @ignore-option */
  1698. halo: false,
  1699. /**
  1700. * How much to brighten the point on interaction. Requires the
  1701. * main color to be defined in hex or rgb(a) format.
  1702. *
  1703. * In styled mode, the hover brightening is by default replaced
  1704. * with a fill-opacity set in the `.highcharts-point:hover`
  1705. * rule.
  1706. */
  1707. brightness: 0.2
  1708. }
  1709. }
  1710. }, merge(colorMapSeriesMixin, {
  1711. pointArrayMap: ['y', 'value'],
  1712. hasPointSpecificOptions: true,
  1713. getExtremesFromAll: true,
  1714. directTouch: true,
  1715. /* eslint-disable valid-jsdoc */
  1716. /**
  1717. * Override the init method to add point ranges on both axes.
  1718. *
  1719. * @private
  1720. * @function Highcharts.seriesTypes.heatmap#init
  1721. * @return {void}
  1722. */
  1723. init: function () {
  1724. var options;
  1725. Series.prototype.init.apply(this, arguments);
  1726. options = this.options;
  1727. // #3758, prevent resetting in setData
  1728. options.pointRange = pick(options.pointRange, options.colsize || 1);
  1729. // general point range
  1730. this.yAxis.axisPointRange = options.rowsize || 1;
  1731. // Bind new symbol names
  1732. extend(symbols, {
  1733. ellipse: symbols.circle,
  1734. rect: symbols.square
  1735. });
  1736. },
  1737. getSymbol: Series.prototype.getSymbol,
  1738. /**
  1739. * @private
  1740. * @function Highcharts.seriesTypes.heatmap#setClip
  1741. * @return {void}
  1742. */
  1743. setClip: function (animation) {
  1744. var series = this,
  1745. chart = series.chart;
  1746. Series.prototype.setClip.apply(series, arguments);
  1747. if (series.options.clip !== false || animation) {
  1748. series.markerGroup
  1749. .clip((animation || series.clipBox) && series.sharedClipKey ?
  1750. chart[series.sharedClipKey] :
  1751. chart.clipRect);
  1752. }
  1753. },
  1754. /**
  1755. * @private
  1756. * @function Highcharts.seriesTypes.heatmap#translate
  1757. * @return {void}
  1758. */
  1759. translate: function () {
  1760. var series = this, options = series.options, symbol = options.marker && options.marker.symbol || '', shape = symbols[symbol] ? symbol : 'rect', options = series.options, hasRegularShape = ['circle', 'square'].indexOf(shape) !== -1;
  1761. series.generatePoints();
  1762. series.points.forEach(function (point) {
  1763. var pointAttr,
  1764. sizeDiff,
  1765. hasImage,
  1766. cellAttr = point.getCellAttributes(),
  1767. shapeArgs = {
  1768. x: Math.min(cellAttr.x1,
  1769. cellAttr.x2),
  1770. y: Math.min(cellAttr.y1,
  1771. cellAttr.y2),
  1772. width: Math.max(Math.abs(cellAttr.x2 - cellAttr.x1), 0),
  1773. height: Math.max(Math.abs(cellAttr.y2 - cellAttr.y1), 0)
  1774. };
  1775. hasImage = point.hasImage =
  1776. (point.marker && point.marker.symbol || symbol || '')
  1777. .indexOf('url') === 0;
  1778. // If marker shape is regular (symetric), find shorter
  1779. // cell's side.
  1780. if (hasRegularShape) {
  1781. sizeDiff = Math.abs(shapeArgs.width - shapeArgs.height);
  1782. shapeArgs.x = Math.min(cellAttr.x1, cellAttr.x2) +
  1783. (shapeArgs.width < shapeArgs.height ? 0 : sizeDiff / 2);
  1784. shapeArgs.y = Math.min(cellAttr.y1, cellAttr.y2) +
  1785. (shapeArgs.width < shapeArgs.height ? sizeDiff / 2 : 0);
  1786. shapeArgs.width = shapeArgs.height =
  1787. Math.min(shapeArgs.width, shapeArgs.height);
  1788. }
  1789. pointAttr = {
  1790. plotX: (cellAttr.x1 + cellAttr.x2) / 2,
  1791. plotY: (cellAttr.y1 + cellAttr.y2) / 2,
  1792. clientX: (cellAttr.x1 + cellAttr.x2) / 2,
  1793. shapeType: 'path',
  1794. shapeArgs: merge(true, shapeArgs, {
  1795. d: symbols[shape](shapeArgs.x, shapeArgs.y, shapeArgs.width, shapeArgs.height)
  1796. })
  1797. };
  1798. if (hasImage) {
  1799. point.marker = {
  1800. width: shapeArgs.width,
  1801. height: shapeArgs.height
  1802. };
  1803. }
  1804. extend(point, pointAttr);
  1805. });
  1806. fireEvent(series, 'afterTranslate');
  1807. },
  1808. /**
  1809. * @private
  1810. * @function Highcharts.seriesTypes.heatmap#pointAttribs
  1811. * @param {Highcharts.HeatmapPoint} point
  1812. * @param {string} state
  1813. * @return {Highcharts.SVGAttributes}
  1814. */
  1815. pointAttribs: function (point, state) {
  1816. var series = this,
  1817. attr = Series.prototype.pointAttribs
  1818. .call(series,
  1819. point,
  1820. state),
  1821. seriesOptions = series.options || {},
  1822. plotOptions = series.chart.options.plotOptions || {},
  1823. seriesPlotOptions = plotOptions.series || {},
  1824. heatmapPlotOptions = plotOptions.heatmap || {},
  1825. stateOptions,
  1826. brightness,
  1827. // Get old properties in order to keep backward compatibility
  1828. borderColor = seriesOptions.borderColor ||
  1829. heatmapPlotOptions.borderColor ||
  1830. seriesPlotOptions.borderColor,
  1831. borderWidth = seriesOptions.borderWidth ||
  1832. heatmapPlotOptions.borderWidth ||
  1833. seriesPlotOptions.borderWidth ||
  1834. attr['stroke-width'];
  1835. // Apply lineColor, or set it to default series color.
  1836. attr.stroke = ((point && point.marker && point.marker.lineColor) ||
  1837. (seriesOptions.marker && seriesOptions.marker.lineColor) ||
  1838. borderColor ||
  1839. this.color);
  1840. // Apply old borderWidth property if exists.
  1841. attr['stroke-width'] = borderWidth;
  1842. if (state) {
  1843. stateOptions =
  1844. merge(seriesOptions.states[state], seriesOptions.marker &&
  1845. seriesOptions.marker.states[state], point.options.states &&
  1846. point.options.states[state] || {});
  1847. brightness = stateOptions.brightness;
  1848. attr.fill =
  1849. stateOptions.color ||
  1850. H.color(attr.fill).brighten(brightness || 0).get();
  1851. attr.stroke = stateOptions.lineColor;
  1852. }
  1853. return attr;
  1854. },
  1855. /**
  1856. * @private
  1857. * @function Highcharts.seriesTypes.heatmap#markerAttribs
  1858. * @param {Highcharts.HeatmapPoint} point
  1859. * @return {Highcharts.SVGAttributes}
  1860. */
  1861. markerAttribs: function (point, state) {
  1862. var pointMarkerOptions = point.marker || {},
  1863. seriesMarkerOptions = this.options.marker || {},
  1864. seriesStateOptions,
  1865. pointStateOptions,
  1866. shapeArgs = point.shapeArgs || {},
  1867. hasImage = point.hasImage,
  1868. attribs = {};
  1869. if (hasImage) {
  1870. return {
  1871. x: point.plotX,
  1872. y: point.plotY
  1873. };
  1874. }
  1875. // Setting width and height attributes on image does not affect
  1876. // on its dimensions.
  1877. if (state) {
  1878. seriesStateOptions = seriesMarkerOptions.states[state] || {};
  1879. pointStateOptions = pointMarkerOptions.states &&
  1880. pointMarkerOptions.states[state] || {};
  1881. [['width', 'x'], ['height', 'y']].forEach(function (dimension) {
  1882. // Set new width and height basing on state options.
  1883. attribs[dimension[0]] = (pointStateOptions[dimension[0]] ||
  1884. seriesStateOptions[dimension[0]] ||
  1885. shapeArgs[dimension[0]]) + (pointStateOptions[dimension[0] + 'Plus'] ||
  1886. seriesStateOptions[dimension[0] + 'Plus'] || 0);
  1887. // Align marker by a new size.
  1888. attribs[dimension[1]] = shapeArgs[dimension[1]] +
  1889. (shapeArgs[dimension[0]] - attribs[dimension[0]]) / 2;
  1890. });
  1891. }
  1892. return state ? attribs : shapeArgs;
  1893. },
  1894. /**
  1895. * @private
  1896. * @function Highcharts.seriesTypes.heatmap#drawPoints
  1897. * @return {void}
  1898. */
  1899. drawPoints: function () {
  1900. var _this = this;
  1901. // In styled mode, use CSS, otherwise the fill used in the style
  1902. // sheet will take precedence over the fill attribute.
  1903. var seriesMarkerOptions = this.options.marker || {};
  1904. if (seriesMarkerOptions.enabled || this._hasPointMarkers) {
  1905. Series.prototype.drawPoints.call(this);
  1906. this.points.forEach(function (point) {
  1907. point.graphic &&
  1908. point.graphic[_this.chart.styledMode ? 'css' : 'animate'](_this.colorAttribs(point));
  1909. });
  1910. }
  1911. },
  1912. // Define hasData function for non-cartesian series.
  1913. // Returns true if the series has points at all.
  1914. hasData: function () {
  1915. return !!this.processedXData.length; // != 0
  1916. },
  1917. // Override to also allow null points, used when building the k-d-tree
  1918. // for tooltips in boost mode.
  1919. getValidPoints: function (points, insideOnly) {
  1920. return Series.prototype.getValidPoints.call(this, points, insideOnly, true);
  1921. },
  1922. /**
  1923. * @ignore
  1924. * @deprecated
  1925. * @function Highcharts.seriesTypes.heatmap#getBox
  1926. */
  1927. getBox: noop,
  1928. /**
  1929. * @private
  1930. * @borrows Highcharts.LegendSymbolMixin.drawRectangle as Highcharts.seriesTypes.heatmap#drawLegendSymbol
  1931. */
  1932. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  1933. /**
  1934. * @private
  1935. * @borrows Highcharts.seriesTypes.column#alignDataLabel as Highcharts.seriesTypes.heatmap#alignDataLabel
  1936. */
  1937. alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
  1938. /**
  1939. * @private
  1940. * @function Highcharts.seriesTypes.heatmap#getExtremes
  1941. * @return {void}
  1942. */
  1943. getExtremes: function () {
  1944. // Get the extremes from the value data
  1945. var _a = Series.prototype.getExtremes
  1946. .call(this,
  1947. this.valueData),
  1948. dataMin = _a.dataMin,
  1949. dataMax = _a.dataMax;
  1950. if (isNumber(dataMin)) {
  1951. this.valueMin = dataMin;
  1952. }
  1953. if (isNumber(dataMax)) {
  1954. this.valueMax = dataMax;
  1955. }
  1956. // Get the extremes from the y data
  1957. return Series.prototype.getExtremes.call(this);
  1958. }
  1959. /* eslint-enable valid-jsdoc */
  1960. }), merge(colorMapPointMixin, {
  1961. /**
  1962. * Heatmap series only. Padding between the points in the heatmap.
  1963. * @name Highcharts.Point#pointPadding
  1964. * @type {number|undefined}
  1965. */
  1966. /**
  1967. * Heatmap series only. The value of the point, resulting in a color
  1968. * controled by options as set in the colorAxis configuration.
  1969. * @name Highcharts.Point#value
  1970. * @type {number|null|undefined}
  1971. */
  1972. /* eslint-disable valid-jsdoc */
  1973. /**
  1974. * @private
  1975. * @function Highcharts.Point#applyOptions
  1976. * @param {Highcharts.HeatmapPointOptions} options
  1977. * @param {number} x
  1978. * @return {Highcharts.SVGPathArray}
  1979. */
  1980. applyOptions: function (options, x) {
  1981. var point = H.Point.prototype
  1982. .applyOptions.call(this,
  1983. options,
  1984. x);
  1985. point.formatPrefix =
  1986. point.isNull || point.value === null ?
  1987. 'null' : 'point';
  1988. return point;
  1989. },
  1990. /**
  1991. * Color points have a value option that determines whether or not it is
  1992. * a null point
  1993. * @private
  1994. * @function Highcharts.HeatmapPoint.isValid
  1995. * @return {boolean}
  1996. */
  1997. isValid: function () {
  1998. // undefined is allowed
  1999. return (this.value !== Infinity &&
  2000. this.value !== -Infinity);
  2001. },
  2002. /**
  2003. * @private
  2004. * @function Highcharts.Point#haloPath
  2005. * @param {number} size
  2006. * @return {Highcharts.SVGPathArray}
  2007. */
  2008. haloPath: function (size) {
  2009. if (!size) {
  2010. return [];
  2011. }
  2012. var rect = this.shapeArgs;
  2013. return [
  2014. 'M',
  2015. rect.x - size,
  2016. rect.y - size,
  2017. 'L',
  2018. rect.x - size,
  2019. rect.y + rect.height + size,
  2020. rect.x + rect.width + size,
  2021. rect.y + rect.height + size,
  2022. rect.x + rect.width + size,
  2023. rect.y - size,
  2024. 'Z'
  2025. ];
  2026. },
  2027. getCellAttributes: function () {
  2028. var point = this,
  2029. series = point.series,
  2030. seriesOptions = series.options,
  2031. xPad = (seriesOptions.colsize || 1) / 2,
  2032. yPad = (seriesOptions.rowsize || 1) / 2,
  2033. xAxis = series.xAxis,
  2034. yAxis = series.yAxis,
  2035. markerOptions = point.options.marker || series.options.marker,
  2036. pointPlacement = series.pointPlacementToXValue(), // #7860
  2037. pointPadding = pick(point.pointPadding,
  2038. seriesOptions.pointPadding, 0),
  2039. cellAttr = {
  2040. x1: clamp(Math.round(xAxis.len -
  2041. (xAxis.translate(point.x - xPad,
  2042. false,
  2043. true,
  2044. false,
  2045. true, -pointPlacement) || 0)), -xAxis.len, 2 * xAxis.len),
  2046. x2: clamp(Math.round(xAxis.len -
  2047. (xAxis.translate(point.x + xPad,
  2048. false,
  2049. true,
  2050. false,
  2051. true, -pointPlacement) || 0)), -xAxis.len, 2 * xAxis.len),
  2052. y1: clamp(Math.round((yAxis.translate(point.y - yPad,
  2053. false,
  2054. true,
  2055. false,
  2056. true) || 0)), -yAxis.len, 2 * yAxis.len),
  2057. y2: clamp(Math.round((yAxis.translate(point.y + yPad,
  2058. false,
  2059. true,
  2060. false,
  2061. true) || 0)), -yAxis.len, 2 * yAxis.len)
  2062. };
  2063. // Handle marker's fixed width, and height values including border
  2064. // and pointPadding while calculating cell attributes.
  2065. [['width', 'x'], ['height', 'y']].forEach(function (dimension) {
  2066. var prop = dimension[0],
  2067. direction = dimension[1];
  2068. var start = direction + '1', end = direction + '2';
  2069. var side = Math.abs(cellAttr[start] - cellAttr[end]),
  2070. borderWidth = markerOptions &&
  2071. markerOptions.lineWidth || 0,
  2072. plotPos = Math.abs(cellAttr[start] + cellAttr[end]) / 2;
  2073. if (markerOptions[prop] &&
  2074. markerOptions[prop] < side) {
  2075. cellAttr[start] = plotPos - (markerOptions[prop] / 2) -
  2076. (borderWidth / 2);
  2077. cellAttr[end] = plotPos + (markerOptions[prop] / 2) +
  2078. (borderWidth / 2);
  2079. }
  2080. // Handle pointPadding
  2081. if (pointPadding) {
  2082. if (direction === 'y') {
  2083. start = end;
  2084. end = direction + '1';
  2085. }
  2086. cellAttr[start] += pointPadding;
  2087. cellAttr[end] -= pointPadding;
  2088. }
  2089. });
  2090. return cellAttr;
  2091. }
  2092. /* eslint-enable valid-jsdoc */
  2093. }));
  2094. /**
  2095. * A `heatmap` series. If the [type](#series.heatmap.type) option is
  2096. * not specified, it is inherited from [chart.type](#chart.type).
  2097. *
  2098. * @productdesc {highcharts}
  2099. * Requires `modules/heatmap`.
  2100. *
  2101. * @extends series,plotOptions.heatmap
  2102. * @excluding cropThreshold, dataParser, dataURL, pointRange, stack,
  2103. * @product highcharts highmaps
  2104. * @apioption series.heatmap
  2105. */
  2106. /**
  2107. * An array of data points for the series. For the `heatmap` series
  2108. * type, points can be given in the following ways:
  2109. *
  2110. * 1. An array of arrays with 3 or 2 values. In this case, the values
  2111. * correspond to `x,y,value`. If the first value is a string, it is
  2112. * applied as the name of the point, and the `x` value is inferred.
  2113. * The `x` value can also be omitted, in which case the inner arrays
  2114. * should be of length 2\. Then the `x` value is automatically calculated,
  2115. * either starting at 0 and incremented by 1, or from `pointStart`
  2116. * and `pointInterval` given in the series options.
  2117. *
  2118. * ```js
  2119. * data: [
  2120. * [0, 9, 7],
  2121. * [1, 10, 4],
  2122. * [2, 6, 3]
  2123. * ]
  2124. * ```
  2125. *
  2126. * 2. An array of objects with named values. The following snippet shows only a
  2127. * few settings, see the complete options set below. If the total number of data
  2128. * points exceeds the series' [turboThreshold](#series.heatmap.turboThreshold),
  2129. * this option is not available.
  2130. *
  2131. * ```js
  2132. * data: [{
  2133. * x: 1,
  2134. * y: 3,
  2135. * value: 10,
  2136. * name: "Point2",
  2137. * color: "#00FF00"
  2138. * }, {
  2139. * x: 1,
  2140. * y: 7,
  2141. * value: 10,
  2142. * name: "Point1",
  2143. * color: "#FF00FF"
  2144. * }]
  2145. * ```
  2146. *
  2147. * @sample {highcharts} highcharts/chart/reflow-true/
  2148. * Numerical values
  2149. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  2150. * Arrays of numeric x and y
  2151. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  2152. * Arrays of datetime x and y
  2153. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  2154. * Arrays of point.name and y
  2155. * @sample {highcharts} highcharts/series/data-array-of-objects/
  2156. * Config objects
  2157. *
  2158. * @type {Array<Array<number>|*>}
  2159. * @extends series.line.data
  2160. * @product highcharts highmaps
  2161. * @apioption series.heatmap.data
  2162. */
  2163. /**
  2164. * The color of the point. In heat maps the point color is rarely set
  2165. * explicitly, as we use the color to denote the `value`. Options for
  2166. * this are set in the [colorAxis](#colorAxis) configuration.
  2167. *
  2168. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2169. * @product highcharts highmaps
  2170. * @apioption series.heatmap.data.color
  2171. */
  2172. /**
  2173. * The value of the point, resulting in a color controled by options
  2174. * as set in the [colorAxis](#colorAxis) configuration.
  2175. *
  2176. * @type {number}
  2177. * @product highcharts highmaps
  2178. * @apioption series.heatmap.data.value
  2179. */
  2180. /**
  2181. * The x value of the point. For datetime axes,
  2182. * the X value is the timestamp in milliseconds since 1970.
  2183. *
  2184. * @type {number}
  2185. * @product highcharts highmaps
  2186. * @apioption series.heatmap.data.x
  2187. */
  2188. /**
  2189. * The y value of the point.
  2190. *
  2191. * @type {number}
  2192. * @product highcharts highmaps
  2193. * @apioption series.heatmap.data.y
  2194. */
  2195. /**
  2196. * Point padding for a single point.
  2197. *
  2198. * @sample maps/plotoptions/tilemap-pointpadding
  2199. * Point padding on tiles
  2200. *
  2201. * @type {number}
  2202. * @product highcharts highmaps
  2203. * @apioption series.heatmap.data.pointPadding
  2204. */
  2205. /**
  2206. * @excluding radius, enabledThreshold
  2207. * @product highcharts highmaps
  2208. * @since 8.1
  2209. * @apioption series.heatmap.data.marker
  2210. */
  2211. /**
  2212. * @excluding radius, enabledThreshold
  2213. * @product highcharts highmaps
  2214. * @since 8.1
  2215. * @apioption series.heatmap.marker
  2216. */
  2217. /**
  2218. * @excluding radius, radiusPlus
  2219. * @product highcharts highmaps
  2220. * @apioption series.heatmap.marker.states.hover
  2221. */
  2222. /**
  2223. * @excluding radius
  2224. * @product highcharts highmaps
  2225. * @apioption series.heatmap.marker.states.select
  2226. */
  2227. /**
  2228. * @excluding radius, radiusPlus
  2229. * @product highcharts highmaps
  2230. * @apioption series.heatmap.data.marker.states.hover
  2231. */
  2232. /**
  2233. * @excluding radius
  2234. * @product highcharts highmaps
  2235. * @apioption series.heatmap.data.marker.states.select
  2236. */
  2237. /**
  2238. * Set the marker's fixed width on hover state.
  2239. *
  2240. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  2241. * 5 pixels wider lineWidth on hover
  2242. *
  2243. * @type {number|undefined}
  2244. * @default 0
  2245. * @product highcharts highmaps
  2246. * @apioption series.heatmap.marker.states.hover.lineWidthPlus
  2247. */
  2248. /**
  2249. * Set the marker's fixed width on hover state.
  2250. *
  2251. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  2252. * 70px fixed marker's width and height on hover
  2253. *
  2254. * @type {number|undefined}
  2255. * @default undefined
  2256. * @product highcharts highmaps
  2257. * @apioption series.heatmap.marker.states.hover.width
  2258. */
  2259. /**
  2260. * Set the marker's fixed height on hover state.
  2261. *
  2262. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  2263. * 70px fixed marker's width and height on hover
  2264. *
  2265. * @type {number|undefined}
  2266. * @default undefined
  2267. * @product highcharts highmaps
  2268. * @apioption series.heatmap.marker.states.hover.height
  2269. */
  2270. /**
  2271. * The number of pixels to increase the width of the
  2272. * hovered point.
  2273. *
  2274. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  2275. * One day
  2276. *
  2277. * @type {number|undefined}
  2278. * @default undefined
  2279. * @product highcharts highmaps
  2280. * @apioption series.heatmap.marker.states.hover.widthPlus
  2281. */
  2282. /**
  2283. * The number of pixels to increase the height of the
  2284. * hovered point.
  2285. *
  2286. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  2287. * One day
  2288. *
  2289. * @type {number|undefined}
  2290. * @default undefined
  2291. * @product highcharts highmaps
  2292. * @apioption series.heatmap.marker.states.hover.heightPlus
  2293. */
  2294. /**
  2295. * The number of pixels to increase the width of the
  2296. * hovered point.
  2297. *
  2298. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  2299. * One day
  2300. *
  2301. * @type {number|undefined}
  2302. * @default undefined
  2303. * @product highcharts highmaps
  2304. * @apioption series.heatmap.marker.states.select.widthPlus
  2305. */
  2306. /**
  2307. * The number of pixels to increase the height of the
  2308. * hovered point.
  2309. *
  2310. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  2311. * One day
  2312. *
  2313. * @type {number|undefined}
  2314. * @default undefined
  2315. * @product highcharts highmaps
  2316. * @apioption series.heatmap.marker.states.select.heightPlus
  2317. */
  2318. /**
  2319. * Set the marker's fixed width on hover state.
  2320. *
  2321. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  2322. * 5 pixels wider lineWidth on hover
  2323. *
  2324. * @type {number|undefined}
  2325. * @default 0
  2326. * @product highcharts highmaps
  2327. * @apioption series.heatmap.data.marker.states.hover.lineWidthPlus
  2328. */
  2329. /**
  2330. * Set the marker's fixed width on hover state.
  2331. *
  2332. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  2333. * 70px fixed marker's width and height on hover
  2334. *
  2335. * @type {number|undefined}
  2336. * @default undefined
  2337. * @product highcharts highmaps
  2338. * @apioption series.heatmap.data.marker.states.hover.width
  2339. */
  2340. /**
  2341. * Set the marker's fixed height on hover state.
  2342. *
  2343. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  2344. * 70px fixed marker's width and height on hover
  2345. *
  2346. * @type {number|undefined}
  2347. * @default undefined
  2348. * @product highcharts highmaps
  2349. * @apioption series.heatmap.data.marker.states.hover.height
  2350. */
  2351. /**
  2352. * The number of pixels to increase the width of the
  2353. * hovered point.
  2354. *
  2355. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  2356. * One day
  2357. *
  2358. * @type {number|undefined}
  2359. * @default undefined
  2360. * @product highcharts highstock
  2361. * @apioption series.heatmap.data.marker.states.hover.widthPlus
  2362. */
  2363. /**
  2364. * The number of pixels to increase the height of the
  2365. * hovered point.
  2366. *
  2367. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  2368. * One day
  2369. *
  2370. * @type {number|undefined}
  2371. * @default undefined
  2372. * @product highcharts highstock
  2373. * @apioption series.heatmap.data.marker.states.hover.heightPlus
  2374. */
  2375. /**
  2376. * Set the marker's fixed width on select state.
  2377. *
  2378. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  2379. * 70px fixed marker's width and height on hover
  2380. *
  2381. * @type {number|undefined}
  2382. * @default undefined
  2383. * @product highcharts highmaps
  2384. * @apioption series.heatmap.data.marker.states.select.width
  2385. */
  2386. /**
  2387. * Set the marker's fixed height on select state.
  2388. *
  2389. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  2390. * 70px fixed marker's width and height on hover
  2391. *
  2392. * @type {number|undefined}
  2393. * @default undefined
  2394. * @product highcharts highmaps
  2395. * @apioption series.heatmap.data.marker.states.select.height
  2396. */
  2397. /**
  2398. * The number of pixels to increase the width of the
  2399. * hovered point.
  2400. *
  2401. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  2402. * One day
  2403. *
  2404. * @type {number|undefined}
  2405. * @default undefined
  2406. * @product highcharts highstock
  2407. * @apioption series.heatmap.data.marker.states.select.widthPlus
  2408. */
  2409. /**
  2410. * The number of pixels to increase the height of the
  2411. * hovered point.
  2412. *
  2413. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  2414. * One day
  2415. *
  2416. * @type {number|undefined}
  2417. * @default undefined
  2418. * @product highcharts highstock
  2419. * @apioption series.heatmap.data.marker.states.select.heightPlus
  2420. */
  2421. ''; // adds doclets above to transpiled file
  2422. });
  2423. _registerModule(_modules, 'masters/modules/heatmap.src.js', [], function () {
  2424. });
  2425. }));