heatmap.src.js 99 KB

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