DependencyWheelPoint.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* *
  2. *
  3. * Dependency wheel module
  4. *
  5. * (c) 2018-2021 Torstein Honsi
  6. *
  7. * License: www.highcharts.com/license
  8. *
  9. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10. *
  11. * */
  12. 'use strict';
  13. var __extends = (this && this.__extends) || (function () {
  14. var extendStatics = function (d, b) {
  15. extendStatics = Object.setPrototypeOf ||
  16. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  17. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  18. return extendStatics(d, b);
  19. };
  20. return function (d, b) {
  21. extendStatics(d, b);
  22. function __() { this.constructor = d; }
  23. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24. };
  25. })();
  26. import NodesMixin from '../../Mixins/Nodes.js';
  27. import SeriesRegistry from '../../Core/Series/SeriesRegistry.js';
  28. var SankeySeries = SeriesRegistry.seriesTypes.sankey;
  29. import U from '../../Core/Utilities.js';
  30. var extend = U.extend;
  31. /* *
  32. *
  33. * Class
  34. *
  35. * */
  36. var DependencyWheelPoint = /** @class */ (function (_super) {
  37. __extends(DependencyWheelPoint, _super);
  38. function DependencyWheelPoint() {
  39. /* *
  40. *
  41. * Properties
  42. *
  43. * */
  44. var _this = _super !== null && _super.apply(this, arguments) || this;
  45. _this.angle = void 0;
  46. _this.fromNode = void 0;
  47. _this.index = void 0;
  48. _this.linksFrom = void 0;
  49. _this.linksTo = void 0;
  50. _this.options = void 0;
  51. _this.series = void 0;
  52. _this.shapeArgs = void 0;
  53. _this.toNode = void 0;
  54. return _this;
  55. /* eslint-enable valid-jsdoc */
  56. }
  57. /* *
  58. *
  59. * Functions
  60. *
  61. * */
  62. /* eslint-disable valid-jsdoc */
  63. /**
  64. * Return a text path that the data label uses.
  65. * @private
  66. */
  67. DependencyWheelPoint.prototype.getDataLabelPath = function (label) {
  68. var renderer = this.series.chart.renderer, shapeArgs = this.shapeArgs, upperHalf = this.angle < 0 || this.angle > Math.PI, start = shapeArgs.start, end = shapeArgs.end;
  69. if (!this.dataLabelPath) {
  70. this.dataLabelPath = renderer
  71. .arc({
  72. open: true,
  73. longArc: Math.abs(Math.abs(start) - Math.abs(end)) < Math.PI ? 0 : 1
  74. })
  75. // Add it inside the data label group so it gets destroyed
  76. // with the label
  77. .add(label);
  78. }
  79. this.dataLabelPath.attr({
  80. x: shapeArgs.x,
  81. y: shapeArgs.y,
  82. r: (shapeArgs.r +
  83. (this.dataLabel.options.distance || 0)),
  84. start: (upperHalf ? start : end),
  85. end: (upperHalf ? end : start),
  86. clockwise: +upperHalf
  87. });
  88. return this.dataLabelPath;
  89. };
  90. DependencyWheelPoint.prototype.isValid = function () {
  91. // No null points here
  92. return true;
  93. };
  94. return DependencyWheelPoint;
  95. }(SankeySeries.prototype.pointClass));
  96. extend(DependencyWheelPoint.prototype, {
  97. setState: NodesMixin.setNodeState
  98. });
  99. /* *
  100. *
  101. * Default Export
  102. *
  103. * */
  104. export default DependencyWheelPoint;