dotplot.src.js 5.8 KB

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