HeatmapSeries.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  1. /* *
  2. *
  3. * (c) 2010-2020 Torstein Honsi
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. import BaseSeries from '../Core/Series/Series.js';
  11. import ColorMapMixin from '../Mixins/ColorMapSeries.js';
  12. var colorMapPointMixin = ColorMapMixin.colorMapPointMixin, colorMapSeriesMixin = ColorMapMixin.colorMapSeriesMixin;
  13. import H from '../Core/Globals.js';
  14. var noop = H.noop;
  15. import LegendSymbolMixin from '../Mixins/LegendSymbol.js';
  16. import SVGRenderer from '../Core/Renderer/SVG/SVGRenderer.js';
  17. import U from '../Core/Utilities.js';
  18. var clamp = U.clamp, extend = U.extend, fireEvent = U.fireEvent, isNumber = U.isNumber, merge = U.merge, pick = U.pick;
  19. import '../Core/Options.js';
  20. import '../Series/LineSeries.js';
  21. var Series = H.Series, seriesTypes = BaseSeries.seriesTypes, symbols = SVGRenderer.prototype.symbols;
  22. /* *
  23. * @interface Highcharts.PointOptionsObject in parts/Point.ts
  24. */ /**
  25. * Heatmap series only. Point padding for a single point.
  26. * @name Highcharts.PointOptionsObject#pointPadding
  27. * @type {number|undefined}
  28. */ /**
  29. * Heatmap series only. The value of the point, resulting in a color controled
  30. * by options as set in the colorAxis configuration.
  31. * @name Highcharts.PointOptionsObject#value
  32. * @type {number|null|undefined}
  33. */
  34. ''; // detach doclets above
  35. /**
  36. * @private
  37. * @class
  38. * @name Highcharts.seriesTypes.heatmap
  39. *
  40. * @augments Highcharts.Series
  41. */
  42. BaseSeries.seriesType('heatmap', 'scatter',
  43. /**
  44. * A heatmap is a graphical representation of data where the individual
  45. * values contained in a matrix are represented as colors.
  46. *
  47. * @productdesc {highcharts}
  48. * Requires `modules/heatmap`.
  49. *
  50. * @sample highcharts/demo/heatmap/
  51. * Simple heatmap
  52. * @sample highcharts/demo/heatmap-canvas/
  53. * Heavy heatmap
  54. *
  55. * @extends plotOptions.scatter
  56. * @excluding animationLimit, connectEnds, connectNulls, cropThreshold,
  57. * dashStyle, findNearestPointBy, getExtremesFromAll, jitter,
  58. * linecap, lineWidth, pointInterval, pointIntervalUnit,
  59. * pointRange, pointStart, shadow, softThreshold, stacking,
  60. * step, threshold, cluster
  61. * @product highcharts highmaps
  62. * @optionparent plotOptions.heatmap
  63. */
  64. {
  65. /**
  66. * Animation is disabled by default on the heatmap series.
  67. */
  68. animation: false,
  69. /**
  70. * The border width for each heat map item.
  71. */
  72. borderWidth: 0,
  73. /**
  74. * Padding between the points in the heatmap.
  75. *
  76. * @type {number}
  77. * @default 0
  78. * @since 6.0
  79. * @apioption plotOptions.heatmap.pointPadding
  80. */
  81. /**
  82. * @default value
  83. * @apioption plotOptions.heatmap.colorKey
  84. */
  85. /**
  86. * The main color of the series. In heat maps this color is rarely used,
  87. * as we mostly use the color to denote the value of each point. Unless
  88. * options are set in the [colorAxis](#colorAxis), the default value
  89. * is pulled from the [options.colors](#colors) array.
  90. *
  91. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  92. * @since 4.0
  93. * @product highcharts
  94. * @apioption plotOptions.heatmap.color
  95. */
  96. /**
  97. * The column size - how many X axis units each column in the heatmap
  98. * should span.
  99. *
  100. * @sample {highcharts} maps/demo/heatmap/
  101. * One day
  102. * @sample {highmaps} maps/demo/heatmap/
  103. * One day
  104. *
  105. * @type {number}
  106. * @default 1
  107. * @since 4.0
  108. * @product highcharts highmaps
  109. * @apioption plotOptions.heatmap.colsize
  110. */
  111. /**
  112. * The row size - how many Y axis units each heatmap row should span.
  113. *
  114. * @sample {highcharts} maps/demo/heatmap/
  115. * 1 by default
  116. * @sample {highmaps} maps/demo/heatmap/
  117. * 1 by default
  118. *
  119. * @type {number}
  120. * @default 1
  121. * @since 4.0
  122. * @product highcharts highmaps
  123. * @apioption plotOptions.heatmap.rowsize
  124. */
  125. /**
  126. * The color applied to null points. In styled mode, a general CSS class
  127. * is applied instead.
  128. *
  129. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  130. */
  131. nullColor: '#f7f7f7',
  132. dataLabels: {
  133. formatter: function () {
  134. return this.point.value;
  135. },
  136. inside: true,
  137. verticalAlign: 'middle',
  138. crop: false,
  139. overflow: false,
  140. padding: 0 // #3837
  141. },
  142. /**
  143. * @excluding radius, enabledThreshold
  144. * @since 8.1
  145. */
  146. marker: {
  147. /**
  148. * A predefined shape or symbol for the marker. When undefined, the
  149. * symbol is pulled from options.symbols. Other possible values are
  150. * `'circle'`, `'square'`,`'diamond'`, `'triangle'`,
  151. * `'triangle-down'`, `'rect'`, and `'ellipse'`.
  152. *
  153. * Additionally, the URL to a graphic can be given on this form:
  154. * `'url(graphic.png)'`. Note that for the image to be applied to
  155. * exported charts, its URL needs to be accessible by the export
  156. * server.
  157. *
  158. * Custom callbacks for symbol path generation can also be added to
  159. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  160. * used by its method name, as shown in the demo.
  161. *
  162. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  163. * Predefined, graphic and custom markers
  164. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  165. * Predefined, graphic and custom markers
  166. */
  167. symbol: 'rect',
  168. /** @ignore-option */
  169. radius: 0,
  170. lineColor: void 0,
  171. states: {
  172. /**
  173. * @excluding radius, radiusPlus
  174. */
  175. hover: {
  176. /**
  177. * Set the marker's fixed width on hover state.
  178. *
  179. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  180. * 70px fixed marker's width and height on hover
  181. *
  182. * @type {number|undefined}
  183. * @default undefined
  184. * @product highcharts highmaps
  185. * @apioption plotOptions.heatmap.marker.states.hover.width
  186. */
  187. /**
  188. * Set the marker's fixed height on hover state.
  189. *
  190. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  191. * 70px fixed marker's width and height on hover
  192. *
  193. * @type {number|undefined}
  194. * @default undefined
  195. * @product highcharts highmaps
  196. * @apioption plotOptions.heatmap.marker.states.hover.height
  197. */
  198. /**
  199. * The number of pixels to increase the width of the
  200. * selected point.
  201. *
  202. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  203. * 20px greater width and height on hover
  204. *
  205. * @type {number|undefined}
  206. * @default undefined
  207. * @product highcharts highmaps
  208. * @apioption plotOptions.heatmap.marker.states.hover.widthPlus
  209. */
  210. /**
  211. * The number of pixels to increase the height of the
  212. * selected point.
  213. *
  214. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  215. * 20px greater width and height on hover
  216. *
  217. * @type {number|undefined}
  218. * @default undefined
  219. * @product highcharts highmaps
  220. * @apioption plotOptions.heatmap.marker.states.hover.heightPlus
  221. */
  222. /**
  223. * The additional line width for a hovered point.
  224. *
  225. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  226. * 5 pixels wider lineWidth on hover
  227. * @sample {highmaps} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  228. * 5 pixels wider lineWidth on hover
  229. */
  230. lineWidthPlus: 0
  231. },
  232. /**
  233. * @excluding radius
  234. */
  235. select: {
  236. /**
  237. * Set the marker's fixed width on select state.
  238. *
  239. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  240. * 70px fixed marker's width and height on hover
  241. *
  242. * @type {number|undefined}
  243. * @default undefined
  244. * @product highcharts highmaps
  245. * @apioption plotOptions.heatmap.marker.states.select.width
  246. */
  247. /**
  248. * Set the marker's fixed height on select state.
  249. *
  250. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  251. * 70px fixed marker's width and height on hover
  252. *
  253. * @type {number|undefined}
  254. * @default undefined
  255. * @product highcharts highmaps
  256. * @apioption plotOptions.heatmap.marker.states.select.height
  257. */
  258. /**
  259. * The number of pixels to increase the width of the
  260. * selected point.
  261. *
  262. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  263. * 20px greater width and height on hover
  264. *
  265. * @type {number|undefined}
  266. * @default undefined
  267. * @product highcharts highmaps
  268. * @apioption plotOptions.heatmap.marker.states.select.widthPlus
  269. */
  270. /**
  271. * The number of pixels to increase the height of the
  272. * selected point.
  273. *
  274. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  275. * 20px greater width and height on hover
  276. *
  277. * @type {number|undefined}
  278. * @default undefined
  279. * @product highcharts highmaps
  280. * @apioption plotOptions.heatmap.marker.states.select.heightPlus
  281. */
  282. }
  283. }
  284. },
  285. clip: true,
  286. /** @ignore-option */
  287. pointRange: null,
  288. tooltip: {
  289. pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
  290. },
  291. states: {
  292. hover: {
  293. /** @ignore-option */
  294. halo: false,
  295. /**
  296. * How much to brighten the point on interaction. Requires the
  297. * main color to be defined in hex or rgb(a) format.
  298. *
  299. * In styled mode, the hover brightening is by default replaced
  300. * with a fill-opacity set in the `.highcharts-point:hover`
  301. * rule.
  302. */
  303. brightness: 0.2
  304. }
  305. }
  306. }, merge(colorMapSeriesMixin, {
  307. pointArrayMap: ['y', 'value'],
  308. hasPointSpecificOptions: true,
  309. getExtremesFromAll: true,
  310. directTouch: true,
  311. /* eslint-disable valid-jsdoc */
  312. /**
  313. * Override the init method to add point ranges on both axes.
  314. *
  315. * @private
  316. * @function Highcharts.seriesTypes.heatmap#init
  317. * @return {void}
  318. */
  319. init: function () {
  320. var options;
  321. Series.prototype.init.apply(this, arguments);
  322. options = this.options;
  323. // #3758, prevent resetting in setData
  324. options.pointRange = pick(options.pointRange, options.colsize || 1);
  325. // general point range
  326. this.yAxis.axisPointRange = options.rowsize || 1;
  327. // Bind new symbol names
  328. extend(symbols, {
  329. ellipse: symbols.circle,
  330. rect: symbols.square
  331. });
  332. },
  333. getSymbol: Series.prototype.getSymbol,
  334. /**
  335. * @private
  336. * @function Highcharts.seriesTypes.heatmap#setClip
  337. * @return {void}
  338. */
  339. setClip: function (animation) {
  340. var series = this, chart = series.chart;
  341. Series.prototype.setClip.apply(series, arguments);
  342. if (series.options.clip !== false || animation) {
  343. series.markerGroup
  344. .clip((animation || series.clipBox) && series.sharedClipKey ?
  345. chart[series.sharedClipKey] :
  346. chart.clipRect);
  347. }
  348. },
  349. /**
  350. * @private
  351. * @function Highcharts.seriesTypes.heatmap#translate
  352. * @return {void}
  353. */
  354. translate: function () {
  355. 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;
  356. series.generatePoints();
  357. series.points.forEach(function (point) {
  358. var pointAttr, sizeDiff, hasImage, cellAttr = point.getCellAttributes(), shapeArgs = {
  359. x: Math.min(cellAttr.x1, cellAttr.x2),
  360. y: Math.min(cellAttr.y1, cellAttr.y2),
  361. width: Math.max(Math.abs(cellAttr.x2 - cellAttr.x1), 0),
  362. height: Math.max(Math.abs(cellAttr.y2 - cellAttr.y1), 0)
  363. };
  364. hasImage = point.hasImage =
  365. (point.marker && point.marker.symbol || symbol || '')
  366. .indexOf('url') === 0;
  367. // If marker shape is regular (symetric), find shorter
  368. // cell's side.
  369. if (hasRegularShape) {
  370. sizeDiff = Math.abs(shapeArgs.width - shapeArgs.height);
  371. shapeArgs.x = Math.min(cellAttr.x1, cellAttr.x2) +
  372. (shapeArgs.width < shapeArgs.height ? 0 : sizeDiff / 2);
  373. shapeArgs.y = Math.min(cellAttr.y1, cellAttr.y2) +
  374. (shapeArgs.width < shapeArgs.height ? sizeDiff / 2 : 0);
  375. shapeArgs.width = shapeArgs.height =
  376. Math.min(shapeArgs.width, shapeArgs.height);
  377. }
  378. pointAttr = {
  379. plotX: (cellAttr.x1 + cellAttr.x2) / 2,
  380. plotY: (cellAttr.y1 + cellAttr.y2) / 2,
  381. clientX: (cellAttr.x1 + cellAttr.x2) / 2,
  382. shapeType: 'path',
  383. shapeArgs: merge(true, shapeArgs, {
  384. d: symbols[shape](shapeArgs.x, shapeArgs.y, shapeArgs.width, shapeArgs.height)
  385. })
  386. };
  387. if (hasImage) {
  388. point.marker = {
  389. width: shapeArgs.width,
  390. height: shapeArgs.height
  391. };
  392. }
  393. extend(point, pointAttr);
  394. });
  395. fireEvent(series, 'afterTranslate');
  396. },
  397. /**
  398. * @private
  399. * @function Highcharts.seriesTypes.heatmap#pointAttribs
  400. * @param {Highcharts.HeatmapPoint} point
  401. * @param {string} state
  402. * @return {Highcharts.SVGAttributes}
  403. */
  404. pointAttribs: function (point, state) {
  405. var series = this, attr = Series.prototype.pointAttribs
  406. .call(series, point, state), seriesOptions = series.options || {}, plotOptions = series.chart.options.plotOptions || {}, seriesPlotOptions = plotOptions.series || {}, heatmapPlotOptions = plotOptions.heatmap || {}, stateOptions, brightness,
  407. // Get old properties in order to keep backward compatibility
  408. borderColor = seriesOptions.borderColor ||
  409. heatmapPlotOptions.borderColor ||
  410. seriesPlotOptions.borderColor, borderWidth = seriesOptions.borderWidth ||
  411. heatmapPlotOptions.borderWidth ||
  412. seriesPlotOptions.borderWidth ||
  413. attr['stroke-width'];
  414. // Apply lineColor, or set it to default series color.
  415. attr.stroke = ((point && point.marker && point.marker.lineColor) ||
  416. (seriesOptions.marker && seriesOptions.marker.lineColor) ||
  417. borderColor ||
  418. this.color);
  419. // Apply old borderWidth property if exists.
  420. attr['stroke-width'] = borderWidth;
  421. if (state) {
  422. stateOptions =
  423. merge(seriesOptions.states[state], seriesOptions.marker &&
  424. seriesOptions.marker.states[state], point.options.states &&
  425. point.options.states[state] || {});
  426. brightness = stateOptions.brightness;
  427. attr.fill =
  428. stateOptions.color ||
  429. H.color(attr.fill).brighten(brightness || 0).get();
  430. attr.stroke = stateOptions.lineColor;
  431. }
  432. return attr;
  433. },
  434. /**
  435. * @private
  436. * @function Highcharts.seriesTypes.heatmap#markerAttribs
  437. * @param {Highcharts.HeatmapPoint} point
  438. * @return {Highcharts.SVGAttributes}
  439. */
  440. markerAttribs: function (point, state) {
  441. var pointMarkerOptions = point.marker || {}, seriesMarkerOptions = this.options.marker || {}, seriesStateOptions, pointStateOptions, shapeArgs = point.shapeArgs || {}, hasImage = point.hasImage, attribs = {};
  442. if (hasImage) {
  443. return {
  444. x: point.plotX,
  445. y: point.plotY
  446. };
  447. }
  448. // Setting width and height attributes on image does not affect
  449. // on its dimensions.
  450. if (state) {
  451. seriesStateOptions = seriesMarkerOptions.states[state] || {};
  452. pointStateOptions = pointMarkerOptions.states &&
  453. pointMarkerOptions.states[state] || {};
  454. [['width', 'x'], ['height', 'y']].forEach(function (dimension) {
  455. // Set new width and height basing on state options.
  456. attribs[dimension[0]] = (pointStateOptions[dimension[0]] ||
  457. seriesStateOptions[dimension[0]] ||
  458. shapeArgs[dimension[0]]) + (pointStateOptions[dimension[0] + 'Plus'] ||
  459. seriesStateOptions[dimension[0] + 'Plus'] || 0);
  460. // Align marker by a new size.
  461. attribs[dimension[1]] = shapeArgs[dimension[1]] +
  462. (shapeArgs[dimension[0]] - attribs[dimension[0]]) / 2;
  463. });
  464. }
  465. return state ? attribs : shapeArgs;
  466. },
  467. /**
  468. * @private
  469. * @function Highcharts.seriesTypes.heatmap#drawPoints
  470. * @return {void}
  471. */
  472. drawPoints: function () {
  473. var _this = this;
  474. // In styled mode, use CSS, otherwise the fill used in the style
  475. // sheet will take precedence over the fill attribute.
  476. var seriesMarkerOptions = this.options.marker || {};
  477. if (seriesMarkerOptions.enabled || this._hasPointMarkers) {
  478. Series.prototype.drawPoints.call(this);
  479. this.points.forEach(function (point) {
  480. point.graphic &&
  481. point.graphic[_this.chart.styledMode ? 'css' : 'animate'](_this.colorAttribs(point));
  482. });
  483. }
  484. },
  485. // Define hasData function for non-cartesian series.
  486. // Returns true if the series has points at all.
  487. hasData: function () {
  488. return !!this.processedXData.length; // != 0
  489. },
  490. // Override to also allow null points, used when building the k-d-tree
  491. // for tooltips in boost mode.
  492. getValidPoints: function (points, insideOnly) {
  493. return Series.prototype.getValidPoints.call(this, points, insideOnly, true);
  494. },
  495. /**
  496. * @ignore
  497. * @deprecated
  498. * @function Highcharts.seriesTypes.heatmap#getBox
  499. */
  500. getBox: noop,
  501. /**
  502. * @private
  503. * @borrows Highcharts.LegendSymbolMixin.drawRectangle as Highcharts.seriesTypes.heatmap#drawLegendSymbol
  504. */
  505. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  506. /**
  507. * @private
  508. * @borrows Highcharts.seriesTypes.column#alignDataLabel as Highcharts.seriesTypes.heatmap#alignDataLabel
  509. */
  510. alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
  511. /**
  512. * @private
  513. * @function Highcharts.seriesTypes.heatmap#getExtremes
  514. * @return {void}
  515. */
  516. getExtremes: function () {
  517. // Get the extremes from the value data
  518. var _a = Series.prototype.getExtremes
  519. .call(this, this.valueData), dataMin = _a.dataMin, dataMax = _a.dataMax;
  520. if (isNumber(dataMin)) {
  521. this.valueMin = dataMin;
  522. }
  523. if (isNumber(dataMax)) {
  524. this.valueMax = dataMax;
  525. }
  526. // Get the extremes from the y data
  527. return Series.prototype.getExtremes.call(this);
  528. }
  529. /* eslint-enable valid-jsdoc */
  530. }), merge(colorMapPointMixin, {
  531. /**
  532. * Heatmap series only. Padding between the points in the heatmap.
  533. * @name Highcharts.Point#pointPadding
  534. * @type {number|undefined}
  535. */
  536. /**
  537. * Heatmap series only. The value of the point, resulting in a color
  538. * controled by options as set in the colorAxis configuration.
  539. * @name Highcharts.Point#value
  540. * @type {number|null|undefined}
  541. */
  542. /* eslint-disable valid-jsdoc */
  543. /**
  544. * @private
  545. * @function Highcharts.Point#applyOptions
  546. * @param {Highcharts.HeatmapPointOptions} options
  547. * @param {number} x
  548. * @return {Highcharts.SVGPathArray}
  549. */
  550. applyOptions: function (options, x) {
  551. var point = H.Point.prototype
  552. .applyOptions.call(this, options, x);
  553. point.formatPrefix =
  554. point.isNull || point.value === null ?
  555. 'null' : 'point';
  556. return point;
  557. },
  558. /**
  559. * Color points have a value option that determines whether or not it is
  560. * a null point
  561. * @private
  562. * @function Highcharts.HeatmapPoint.isValid
  563. * @return {boolean}
  564. */
  565. isValid: function () {
  566. // undefined is allowed
  567. return (this.value !== Infinity &&
  568. this.value !== -Infinity);
  569. },
  570. /**
  571. * @private
  572. * @function Highcharts.Point#haloPath
  573. * @param {number} size
  574. * @return {Highcharts.SVGPathArray}
  575. */
  576. haloPath: function (size) {
  577. if (!size) {
  578. return [];
  579. }
  580. var rect = this.shapeArgs;
  581. return [
  582. 'M',
  583. rect.x - size,
  584. rect.y - size,
  585. 'L',
  586. rect.x - size,
  587. rect.y + rect.height + size,
  588. rect.x + rect.width + size,
  589. rect.y + rect.height + size,
  590. rect.x + rect.width + size,
  591. rect.y - size,
  592. 'Z'
  593. ];
  594. },
  595. getCellAttributes: function () {
  596. 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
  597. pointPadding = pick(point.pointPadding, seriesOptions.pointPadding, 0), cellAttr = {
  598. x1: clamp(Math.round(xAxis.len -
  599. (xAxis.translate(point.x - xPad, false, true, false, true, -pointPlacement) || 0)), -xAxis.len, 2 * xAxis.len),
  600. x2: clamp(Math.round(xAxis.len -
  601. (xAxis.translate(point.x + xPad, false, true, false, true, -pointPlacement) || 0)), -xAxis.len, 2 * xAxis.len),
  602. y1: clamp(Math.round((yAxis.translate(point.y - yPad, false, true, false, true) || 0)), -yAxis.len, 2 * yAxis.len),
  603. y2: clamp(Math.round((yAxis.translate(point.y + yPad, false, true, false, true) || 0)), -yAxis.len, 2 * yAxis.len)
  604. };
  605. // Handle marker's fixed width, and height values including border
  606. // and pointPadding while calculating cell attributes.
  607. [['width', 'x'], ['height', 'y']].forEach(function (dimension) {
  608. var prop = dimension[0], direction = dimension[1];
  609. var start = direction + '1', end = direction + '2';
  610. var side = Math.abs(cellAttr[start] - cellAttr[end]), borderWidth = markerOptions &&
  611. markerOptions.lineWidth || 0, plotPos = Math.abs(cellAttr[start] + cellAttr[end]) / 2;
  612. if (markerOptions[prop] &&
  613. markerOptions[prop] < side) {
  614. cellAttr[start] = plotPos - (markerOptions[prop] / 2) -
  615. (borderWidth / 2);
  616. cellAttr[end] = plotPos + (markerOptions[prop] / 2) +
  617. (borderWidth / 2);
  618. }
  619. // Handle pointPadding
  620. if (pointPadding) {
  621. if (direction === 'y') {
  622. start = end;
  623. end = direction + '1';
  624. }
  625. cellAttr[start] += pointPadding;
  626. cellAttr[end] -= pointPadding;
  627. }
  628. });
  629. return cellAttr;
  630. }
  631. /* eslint-enable valid-jsdoc */
  632. }));
  633. /**
  634. * A `heatmap` series. If the [type](#series.heatmap.type) option is
  635. * not specified, it is inherited from [chart.type](#chart.type).
  636. *
  637. * @productdesc {highcharts}
  638. * Requires `modules/heatmap`.
  639. *
  640. * @extends series,plotOptions.heatmap
  641. * @excluding cropThreshold, dataParser, dataURL, pointRange, stack,
  642. * @product highcharts highmaps
  643. * @apioption series.heatmap
  644. */
  645. /**
  646. * An array of data points for the series. For the `heatmap` series
  647. * type, points can be given in the following ways:
  648. *
  649. * 1. An array of arrays with 3 or 2 values. In this case, the values
  650. * correspond to `x,y,value`. If the first value is a string, it is
  651. * applied as the name of the point, and the `x` value is inferred.
  652. * The `x` value can also be omitted, in which case the inner arrays
  653. * should be of length 2\. Then the `x` value is automatically calculated,
  654. * either starting at 0 and incremented by 1, or from `pointStart`
  655. * and `pointInterval` given in the series options.
  656. *
  657. * ```js
  658. * data: [
  659. * [0, 9, 7],
  660. * [1, 10, 4],
  661. * [2, 6, 3]
  662. * ]
  663. * ```
  664. *
  665. * 2. An array of objects with named values. The following snippet shows only a
  666. * few settings, see the complete options set below. If the total number of data
  667. * points exceeds the series' [turboThreshold](#series.heatmap.turboThreshold),
  668. * this option is not available.
  669. *
  670. * ```js
  671. * data: [{
  672. * x: 1,
  673. * y: 3,
  674. * value: 10,
  675. * name: "Point2",
  676. * color: "#00FF00"
  677. * }, {
  678. * x: 1,
  679. * y: 7,
  680. * value: 10,
  681. * name: "Point1",
  682. * color: "#FF00FF"
  683. * }]
  684. * ```
  685. *
  686. * @sample {highcharts} highcharts/chart/reflow-true/
  687. * Numerical values
  688. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  689. * Arrays of numeric x and y
  690. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  691. * Arrays of datetime x and y
  692. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  693. * Arrays of point.name and y
  694. * @sample {highcharts} highcharts/series/data-array-of-objects/
  695. * Config objects
  696. *
  697. * @type {Array<Array<number>|*>}
  698. * @extends series.line.data
  699. * @product highcharts highmaps
  700. * @apioption series.heatmap.data
  701. */
  702. /**
  703. * The color of the point. In heat maps the point color is rarely set
  704. * explicitly, as we use the color to denote the `value`. Options for
  705. * this are set in the [colorAxis](#colorAxis) configuration.
  706. *
  707. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  708. * @product highcharts highmaps
  709. * @apioption series.heatmap.data.color
  710. */
  711. /**
  712. * The value of the point, resulting in a color controled by options
  713. * as set in the [colorAxis](#colorAxis) configuration.
  714. *
  715. * @type {number}
  716. * @product highcharts highmaps
  717. * @apioption series.heatmap.data.value
  718. */
  719. /**
  720. * The x value of the point. For datetime axes,
  721. * the X value is the timestamp in milliseconds since 1970.
  722. *
  723. * @type {number}
  724. * @product highcharts highmaps
  725. * @apioption series.heatmap.data.x
  726. */
  727. /**
  728. * The y value of the point.
  729. *
  730. * @type {number}
  731. * @product highcharts highmaps
  732. * @apioption series.heatmap.data.y
  733. */
  734. /**
  735. * Point padding for a single point.
  736. *
  737. * @sample maps/plotoptions/tilemap-pointpadding
  738. * Point padding on tiles
  739. *
  740. * @type {number}
  741. * @product highcharts highmaps
  742. * @apioption series.heatmap.data.pointPadding
  743. */
  744. /**
  745. * @excluding radius, enabledThreshold
  746. * @product highcharts highmaps
  747. * @since 8.1
  748. * @apioption series.heatmap.data.marker
  749. */
  750. /**
  751. * @excluding radius, enabledThreshold
  752. * @product highcharts highmaps
  753. * @since 8.1
  754. * @apioption series.heatmap.marker
  755. */
  756. /**
  757. * @excluding radius, radiusPlus
  758. * @product highcharts highmaps
  759. * @apioption series.heatmap.marker.states.hover
  760. */
  761. /**
  762. * @excluding radius
  763. * @product highcharts highmaps
  764. * @apioption series.heatmap.marker.states.select
  765. */
  766. /**
  767. * @excluding radius, radiusPlus
  768. * @product highcharts highmaps
  769. * @apioption series.heatmap.data.marker.states.hover
  770. */
  771. /**
  772. * @excluding radius
  773. * @product highcharts highmaps
  774. * @apioption series.heatmap.data.marker.states.select
  775. */
  776. /**
  777. * Set the marker's fixed width on hover state.
  778. *
  779. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  780. * 5 pixels wider lineWidth on hover
  781. *
  782. * @type {number|undefined}
  783. * @default 0
  784. * @product highcharts highmaps
  785. * @apioption series.heatmap.marker.states.hover.lineWidthPlus
  786. */
  787. /**
  788. * Set the marker's fixed width on hover state.
  789. *
  790. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  791. * 70px fixed marker's width and height on hover
  792. *
  793. * @type {number|undefined}
  794. * @default undefined
  795. * @product highcharts highmaps
  796. * @apioption series.heatmap.marker.states.hover.width
  797. */
  798. /**
  799. * Set the marker's fixed height on hover state.
  800. *
  801. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  802. * 70px fixed marker's width and height on hover
  803. *
  804. * @type {number|undefined}
  805. * @default undefined
  806. * @product highcharts highmaps
  807. * @apioption series.heatmap.marker.states.hover.height
  808. */
  809. /**
  810. * The number of pixels to increase the width of the
  811. * hovered point.
  812. *
  813. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  814. * One day
  815. *
  816. * @type {number|undefined}
  817. * @default undefined
  818. * @product highcharts highmaps
  819. * @apioption series.heatmap.marker.states.hover.widthPlus
  820. */
  821. /**
  822. * The number of pixels to increase the height of the
  823. * hovered point.
  824. *
  825. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  826. * One day
  827. *
  828. * @type {number|undefined}
  829. * @default undefined
  830. * @product highcharts highmaps
  831. * @apioption series.heatmap.marker.states.hover.heightPlus
  832. */
  833. /**
  834. * The number of pixels to increase the width of the
  835. * hovered point.
  836. *
  837. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  838. * One day
  839. *
  840. * @type {number|undefined}
  841. * @default undefined
  842. * @product highcharts highmaps
  843. * @apioption series.heatmap.marker.states.select.widthPlus
  844. */
  845. /**
  846. * The number of pixels to increase the height of the
  847. * hovered point.
  848. *
  849. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  850. * One day
  851. *
  852. * @type {number|undefined}
  853. * @default undefined
  854. * @product highcharts highmaps
  855. * @apioption series.heatmap.marker.states.select.heightPlus
  856. */
  857. /**
  858. * Set the marker's fixed width on hover state.
  859. *
  860. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  861. * 5 pixels wider lineWidth on hover
  862. *
  863. * @type {number|undefined}
  864. * @default 0
  865. * @product highcharts highmaps
  866. * @apioption series.heatmap.data.marker.states.hover.lineWidthPlus
  867. */
  868. /**
  869. * Set the marker's fixed width on hover state.
  870. *
  871. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  872. * 70px fixed marker's width and height on hover
  873. *
  874. * @type {number|undefined}
  875. * @default undefined
  876. * @product highcharts highmaps
  877. * @apioption series.heatmap.data.marker.states.hover.width
  878. */
  879. /**
  880. * Set the marker's fixed height on hover state.
  881. *
  882. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  883. * 70px fixed marker's width and height on hover
  884. *
  885. * @type {number|undefined}
  886. * @default undefined
  887. * @product highcharts highmaps
  888. * @apioption series.heatmap.data.marker.states.hover.height
  889. */
  890. /**
  891. * The number of pixels to increase the width of the
  892. * hovered point.
  893. *
  894. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  895. * One day
  896. *
  897. * @type {number|undefined}
  898. * @default undefined
  899. * @product highcharts highstock
  900. * @apioption series.heatmap.data.marker.states.hover.widthPlus
  901. */
  902. /**
  903. * The number of pixels to increase the height of the
  904. * hovered point.
  905. *
  906. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  907. * One day
  908. *
  909. * @type {number|undefined}
  910. * @default undefined
  911. * @product highcharts highstock
  912. * @apioption series.heatmap.data.marker.states.hover.heightPlus
  913. */
  914. /**
  915. * Set the marker's fixed width on select state.
  916. *
  917. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  918. * 70px fixed marker's width and height on hover
  919. *
  920. * @type {number|undefined}
  921. * @default undefined
  922. * @product highcharts highmaps
  923. * @apioption series.heatmap.data.marker.states.select.width
  924. */
  925. /**
  926. * Set the marker's fixed height on select state.
  927. *
  928. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  929. * 70px fixed marker's width and height on hover
  930. *
  931. * @type {number|undefined}
  932. * @default undefined
  933. * @product highcharts highmaps
  934. * @apioption series.heatmap.data.marker.states.select.height
  935. */
  936. /**
  937. * The number of pixels to increase the width of the
  938. * hovered point.
  939. *
  940. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  941. * One day
  942. *
  943. * @type {number|undefined}
  944. * @default undefined
  945. * @product highcharts highstock
  946. * @apioption series.heatmap.data.marker.states.select.widthPlus
  947. */
  948. /**
  949. * The number of pixels to increase the height of the
  950. * hovered point.
  951. *
  952. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  953. * One day
  954. *
  955. * @type {number|undefined}
  956. * @default undefined
  957. * @product highcharts highstock
  958. * @apioption series.heatmap.data.marker.states.select.heightPlus
  959. */
  960. ''; // adds doclets above to transpiled file