GanttPoint.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* *
  2. *
  3. * (c) 2016-2021 Highsoft AS
  4. *
  5. * Author: Lars A. V. Cabrera
  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 SeriesRegistry from '../../Core/Series/SeriesRegistry.js';
  27. var XRangePoint = SeriesRegistry.seriesTypes.xrange.prototype.pointClass;
  28. import U from '../../Core/Utilities.js';
  29. var pick = U.pick;
  30. /* *
  31. *
  32. * Class
  33. *
  34. * */
  35. var GanttPoint = /** @class */ (function (_super) {
  36. __extends(GanttPoint, _super);
  37. function GanttPoint() {
  38. /* *
  39. *
  40. * Static Functions
  41. *
  42. * */
  43. var _this = _super !== null && _super.apply(this, arguments) || this;
  44. _this.options = void 0;
  45. _this.series = void 0;
  46. return _this;
  47. /* eslint-enable valid-jsdoc */
  48. }
  49. /* eslint-disable valid-jsdoc */
  50. /**
  51. * @private
  52. */
  53. GanttPoint.setGanttPointAliases = function (options) {
  54. /**
  55. * Add a value to options if the value exists.
  56. * @private
  57. */
  58. function addIfExists(prop, val) {
  59. if (typeof val !== 'undefined') {
  60. options[prop] = val;
  61. }
  62. }
  63. addIfExists('x', pick(options.start, options.x));
  64. addIfExists('x2', pick(options.end, options.x2));
  65. addIfExists('partialFill', pick(options.completed, options.partialFill));
  66. };
  67. /* *
  68. *
  69. * Functions
  70. *
  71. * */
  72. /* eslint-disable valid-jsdoc */
  73. /**
  74. * Applies the options containing the x and y data and possible some
  75. * extra properties. This is called on point init or from point.update.
  76. *
  77. * @private
  78. * @function Highcharts.Point#applyOptions
  79. *
  80. * @param {object} options
  81. * The point options
  82. *
  83. * @param {number} x
  84. * The x value
  85. *
  86. * @return {Highcharts.Point}
  87. * The Point instance
  88. */
  89. GanttPoint.prototype.applyOptions = function (options, x) {
  90. var point = this, ganttPoint;
  91. ganttPoint = _super.prototype.applyOptions.call(point, options, x);
  92. GanttPoint.setGanttPointAliases(ganttPoint);
  93. return ganttPoint;
  94. };
  95. GanttPoint.prototype.isValid = function () {
  96. return ((typeof this.start === 'number' ||
  97. typeof this.x === 'number') &&
  98. (typeof this.end === 'number' ||
  99. typeof this.x2 === 'number' ||
  100. this.milestone));
  101. };
  102. return GanttPoint;
  103. }(XRangePoint));
  104. /* *
  105. *
  106. * Default Export
  107. *
  108. * */
  109. export default GanttPoint;