dotplot.src.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /**
  2. * @license Highcharts JS v9.1.1 (2021-06-04)
  3. *
  4. * Dot plot series type for Highcharts
  5. *
  6. * (c) 2010-2021 Torstein Honsi
  7. *
  8. * License: www.highcharts.com/license
  9. */
  10. 'use strict';
  11. (function (factory) {
  12. if (typeof module === 'object' && module.exports) {
  13. factory['default'] = factory;
  14. module.exports = factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/modules/dotplot', ['highcharts'], function (Highcharts) {
  17. factory(Highcharts);
  18. factory.Highcharts = Highcharts;
  19. return factory;
  20. });
  21. } else {
  22. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  23. }
  24. }(function (Highcharts) {
  25. var _modules = Highcharts ? Highcharts._modules : {};
  26. function _registerModule(obj, path, args, fn) {
  27. if (!obj.hasOwnProperty(path)) {
  28. obj[path] = fn.apply(null, args);
  29. }
  30. }
  31. _registerModule(_modules, 'Series/DotPlot/DotPlotSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColumnSeries, SeriesRegistry, U) {
  32. /* *
  33. *
  34. * (c) 2009-2021 Torstein Honsi
  35. *
  36. * Dot plot series type for Highcharts
  37. *
  38. * License: www.highcharts.com/license
  39. *
  40. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41. *
  42. * */
  43. /**
  44. * @private
  45. * @todo
  46. * - Check update, remove etc.
  47. * - Custom icons like persons, carts etc. Either as images, font icons or
  48. * Highcharts symbols.
  49. */
  50. var __extends = (this && this.__extends) || (function () {
  51. var extendStatics = function (d,
  52. b) {
  53. extendStatics = Object.setPrototypeOf ||
  54. ({ __proto__: [] } instanceof Array && function (d,
  55. b) { d.__proto__ = b; }) ||
  56. function (d,
  57. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  58. return extendStatics(d, b);
  59. };
  60. return function (d, b) {
  61. extendStatics(d, b);
  62. function __() { this.constructor = d; }
  63. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  64. };
  65. })();
  66. var extend = U.extend,
  67. merge = U.merge,
  68. objectEach = U.objectEach,
  69. pick = U.pick;
  70. /* *
  71. *
  72. * Class
  73. *
  74. * */
  75. /**
  76. * @private
  77. * @class
  78. * @name Highcharts.seriesTypes.dotplot
  79. *
  80. * @augments Highcharts.Series
  81. */
  82. var DotPlotSeries = /** @class */ (function (_super) {
  83. __extends(DotPlotSeries, _super);
  84. function DotPlotSeries() {
  85. /* *
  86. *
  87. * Static Properties
  88. *
  89. * */
  90. var _this = _super !== null && _super.apply(this,
  91. arguments) || this;
  92. /* *
  93. *
  94. * Properties
  95. *
  96. * */
  97. _this.data = void 0;
  98. _this.options = void 0;
  99. _this.points = void 0;
  100. return _this;
  101. }
  102. /* *
  103. *
  104. * Functions
  105. *
  106. * */
  107. DotPlotSeries.prototype.drawPoints = function () {
  108. var series = this,
  109. renderer = series.chart.renderer,
  110. seriesMarkerOptions = this.options.marker,
  111. itemPaddingTranslated = this.yAxis.transA *
  112. series.options.itemPadding,
  113. borderWidth = this.borderWidth,
  114. crisp = borderWidth % 2 ? 0.5 : 1;
  115. this.points.forEach(function (point) {
  116. var yPos,
  117. attr,
  118. graphics,
  119. itemY,
  120. pointAttr,
  121. pointMarkerOptions = point.marker || {},
  122. symbol = (pointMarkerOptions.symbol ||
  123. seriesMarkerOptions.symbol),
  124. radius = pick(pointMarkerOptions.radius,
  125. seriesMarkerOptions.radius),
  126. size,
  127. yTop,
  128. isSquare = symbol !== 'rect',
  129. x,
  130. y;
  131. point.graphics = graphics = point.graphics || {};
  132. pointAttr = point.pointAttr ?
  133. (point.pointAttr[point.selected ? 'selected' : ''] ||
  134. series.pointAttr['']) :
  135. series.pointAttribs(point, point.selected && 'select');
  136. delete pointAttr.r;
  137. if (series.chart.styledMode) {
  138. delete pointAttr.stroke;
  139. delete pointAttr['stroke-width'];
  140. }
  141. if (point.y !== null) {
  142. if (!point.graphic) {
  143. point.graphic = renderer.g('point').add(series.group);
  144. }
  145. itemY = point.y;
  146. yTop = pick(point.stackY, point.y);
  147. size = Math.min(point.pointWidth, series.yAxis.transA - itemPaddingTranslated);
  148. for (yPos = yTop; yPos > yTop - point.y; yPos--) {
  149. x = point.barX + (isSquare ?
  150. point.pointWidth / 2 - size / 2 :
  151. 0);
  152. y = series.yAxis.toPixels(yPos, true) +
  153. itemPaddingTranslated / 2;
  154. if (series.options.crisp) {
  155. x = Math.round(x) - crisp;
  156. y = Math.round(y) + crisp;
  157. }
  158. attr = {
  159. x: x,
  160. y: y,
  161. width: Math.round(isSquare ? size : point.pointWidth),
  162. height: Math.round(size),
  163. r: radius
  164. };
  165. if (graphics[itemY]) {
  166. graphics[itemY].animate(attr);
  167. }
  168. else {
  169. graphics[itemY] = renderer.symbol(symbol)
  170. .attr(extend(attr, pointAttr))
  171. .add(point.graphic);
  172. }
  173. graphics[itemY].isActive = true;
  174. itemY--;
  175. }
  176. }
  177. objectEach(graphics, function (graphic, key) {
  178. if (!graphic.isActive) {
  179. graphic.destroy();
  180. delete graphic[key];
  181. }
  182. else {
  183. graphic.isActive = false;
  184. }
  185. });
  186. });
  187. };
  188. DotPlotSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  189. itemPadding: 0.2,
  190. marker: {
  191. symbol: 'circle',
  192. states: {
  193. hover: {},
  194. select: {}
  195. }
  196. }
  197. });
  198. return DotPlotSeries;
  199. }(ColumnSeries));
  200. extend(DotPlotSeries.prototype, {
  201. markerAttribs: void 0
  202. });
  203. SeriesRegistry.registerSeriesType('dotplot', DotPlotSeries);
  204. /* *
  205. *
  206. * Default Export
  207. *
  208. * */
  209. return DotPlotSeries;
  210. });
  211. _registerModule(_modules, 'masters/modules/dotplot.src.js', [], function () {
  212. });
  213. }));