dotplot.src.js 8.6 KB

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