dotplot.src.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /**
  2. * @license Highcharts JS v8.2.0 (2020-08-20)
  3. *
  4. * Dot plot series type for Highcharts
  5. *
  6. * (c) 2010-2019 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/DotplotSeries.js', [_modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (SVGRenderer, U) {
  32. /* *
  33. *
  34. * (c) 2009-2020 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 extend = U.extend,
  51. objectEach = U.objectEach,
  52. pick = U.pick,
  53. seriesType = U.seriesType;
  54. /**
  55. * @private
  56. * @class
  57. * @name Highcharts.seriesTypes.dotplot
  58. *
  59. * @augments Highcharts.Series
  60. */
  61. seriesType('dotplot', 'column', {
  62. itemPadding: 0.2,
  63. marker: {
  64. symbol: 'circle',
  65. states: {
  66. hover: {},
  67. select: {}
  68. }
  69. }
  70. }, {
  71. markerAttribs: void 0,
  72. drawPoints: function () {
  73. var series = this,
  74. renderer = series.chart.renderer,
  75. seriesMarkerOptions = this.options.marker,
  76. itemPaddingTranslated = this.yAxis.transA *
  77. series.options.itemPadding,
  78. borderWidth = this.borderWidth,
  79. crisp = borderWidth % 2 ? 0.5 : 1;
  80. this.points.forEach(function (point) {
  81. var yPos,
  82. attr,
  83. graphics,
  84. itemY,
  85. pointAttr,
  86. pointMarkerOptions = point.marker || {},
  87. symbol = (pointMarkerOptions.symbol ||
  88. seriesMarkerOptions.symbol),
  89. radius = pick(pointMarkerOptions.radius,
  90. seriesMarkerOptions.radius),
  91. size,
  92. yTop,
  93. isSquare = symbol !== 'rect',
  94. x,
  95. y;
  96. point.graphics = graphics = point.graphics || {};
  97. pointAttr = point.pointAttr ?
  98. (point.pointAttr[point.selected ? 'selected' : ''] ||
  99. series.pointAttr['']) :
  100. series.pointAttribs(point, point.selected && 'select');
  101. delete pointAttr.r;
  102. if (series.chart.styledMode) {
  103. delete pointAttr.stroke;
  104. delete pointAttr['stroke-width'];
  105. }
  106. if (point.y !== null) {
  107. if (!point.graphic) {
  108. point.graphic = renderer.g('point').add(series.group);
  109. }
  110. itemY = point.y;
  111. yTop = pick(point.stackY, point.y);
  112. size = Math.min(point.pointWidth, series.yAxis.transA - itemPaddingTranslated);
  113. for (yPos = yTop; yPos > yTop - point.y; yPos--) {
  114. x = point.barX + (isSquare ?
  115. point.pointWidth / 2 - size / 2 :
  116. 0);
  117. y = series.yAxis.toPixels(yPos, true) +
  118. itemPaddingTranslated / 2;
  119. if (series.options.crisp) {
  120. x = Math.round(x) - crisp;
  121. y = Math.round(y) + crisp;
  122. }
  123. attr = {
  124. x: x,
  125. y: y,
  126. width: Math.round(isSquare ? size : point.pointWidth),
  127. height: Math.round(size),
  128. r: radius
  129. };
  130. if (graphics[itemY]) {
  131. graphics[itemY].animate(attr);
  132. }
  133. else {
  134. graphics[itemY] = renderer.symbol(symbol)
  135. .attr(extend(attr, pointAttr))
  136. .add(point.graphic);
  137. }
  138. graphics[itemY].isActive = true;
  139. itemY--;
  140. }
  141. }
  142. objectEach(graphics, function (graphic, key) {
  143. if (!graphic.isActive) {
  144. graphic.destroy();
  145. delete graphic[key];
  146. }
  147. else {
  148. graphic.isActive = false;
  149. }
  150. });
  151. });
  152. }
  153. });
  154. SVGRenderer.prototype.symbols.rect = function (x, y, w, h, options) {
  155. return SVGRenderer.prototype.symbols.callout(x, y, w, h, options);
  156. };
  157. });
  158. _registerModule(_modules, 'masters/modules/dotplot.src.js', [], function () {
  159. });
  160. }));