dotplot.src.js 6.1 KB

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