TreemapPoint.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* *
  2. *
  3. * (c) 2014-2021 Highsoft AS
  4. *
  5. * Authors: Jon Arild Nygard / Oystein Moseng
  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 DrawPointMixin from '../../Mixins/DrawPoint.js';
  27. import SeriesRegistry from '../../Core/Series/SeriesRegistry.js';
  28. var Point = SeriesRegistry.series.prototype.pointClass, _a = SeriesRegistry.seriesTypes, PiePoint = _a.pie.prototype.pointClass, ScatterPoint = _a.scatter.prototype.pointClass;
  29. import U from '../../Core/Utilities.js';
  30. var extend = U.extend, isNumber = U.isNumber, pick = U.pick;
  31. /* *
  32. *
  33. * Class
  34. *
  35. * */
  36. var TreemapPoint = /** @class */ (function (_super) {
  37. __extends(TreemapPoint, _super);
  38. function TreemapPoint() {
  39. /* *
  40. *
  41. * Properties
  42. *
  43. * */
  44. var _this = _super !== null && _super.apply(this, arguments) || this;
  45. _this.name = void 0;
  46. _this.node = void 0;
  47. _this.options = void 0;
  48. _this.series = void 0;
  49. _this.value = void 0;
  50. return _this;
  51. /* eslint-enable valid-jsdoc */
  52. }
  53. /* *
  54. *
  55. * Functions
  56. *
  57. * */
  58. /* eslint-disable valid-jsdoc */
  59. TreemapPoint.prototype.getClassName = function () {
  60. var className = Point.prototype.getClassName.call(this), series = this.series, options = series.options;
  61. // Above the current level
  62. if (this.node.level <= series.nodeMap[series.rootNode].level) {
  63. className += ' highcharts-above-level';
  64. }
  65. else if (!this.node.isLeaf &&
  66. !pick(options.interactByLeaf, !options.allowTraversingTree)) {
  67. className += ' highcharts-internal-node-interactive';
  68. }
  69. else if (!this.node.isLeaf) {
  70. className += ' highcharts-internal-node';
  71. }
  72. return className;
  73. };
  74. /**
  75. * A tree point is valid if it has han id too, assume it may be a parent
  76. * item.
  77. *
  78. * @private
  79. * @function Highcharts.Point#isValid
  80. */
  81. TreemapPoint.prototype.isValid = function () {
  82. return Boolean(this.id || isNumber(this.value));
  83. };
  84. TreemapPoint.prototype.setState = function (state) {
  85. Point.prototype.setState.call(this, state);
  86. // Graphic does not exist when point is not visible.
  87. if (this.graphic) {
  88. this.graphic.attr({
  89. zIndex: state === 'hover' ? 1 : 0
  90. });
  91. }
  92. };
  93. TreemapPoint.prototype.shouldDraw = function () {
  94. return isNumber(this.plotY) && this.y !== null;
  95. };
  96. return TreemapPoint;
  97. }(ScatterPoint));
  98. extend(TreemapPoint.prototype, {
  99. draw: DrawPointMixin.drawPoint,
  100. setVisible: PiePoint.prototype.setVisible
  101. });
  102. /* *
  103. *
  104. * Default Export
  105. *
  106. * */
  107. export default TreemapPoint;