ZAxis.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* *
  2. *
  3. * (c) 2010-2020 Torstein Honsi
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. var __extends = (this && this.__extends) || (function () {
  11. var extendStatics = function (d, b) {
  12. extendStatics = Object.setPrototypeOf ||
  13. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  14. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  15. return extendStatics(d, b);
  16. };
  17. return function (d, b) {
  18. extendStatics(d, b);
  19. function __() { this.constructor = d; }
  20. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21. };
  22. })();
  23. import Axis from './Axis.js';
  24. import U from '../Utilities.js';
  25. var addEvent = U.addEvent, merge = U.merge, pick = U.pick, splat = U.splat;
  26. /* eslint-disable valid-jsdoc */
  27. /**
  28. * 3D chart with support of z coordinates.
  29. * @private
  30. * @class
  31. */
  32. var ZChart = /** @class */ (function () {
  33. function ZChart() {
  34. }
  35. /* *
  36. *
  37. * Static Functions
  38. *
  39. * */
  40. ZChart.compose = function (ChartClass) {
  41. addEvent(ChartClass, 'afterGetAxes', ZChart.onAfterGetAxes);
  42. var chartProto = ChartClass.prototype;
  43. chartProto.addZAxis = ZChart.wrapAddZAxis;
  44. chartProto.collectionsWithInit.zAxis = [chartProto.addZAxis];
  45. chartProto.collectionsWithUpdate.push('zAxis');
  46. };
  47. /**
  48. * Get the Z axis in addition to the default X and Y.
  49. * @private
  50. */
  51. ZChart.onAfterGetAxes = function () {
  52. var chart = this;
  53. var options = this.options;
  54. var zAxisOptions = options.zAxis = splat(options.zAxis || {});
  55. if (!chart.is3d()) {
  56. return;
  57. }
  58. chart.zAxis = [];
  59. zAxisOptions.forEach(function (axisOptions, i) {
  60. axisOptions.index = i;
  61. // Z-Axis is shown horizontally, so it's kind of a X-Axis
  62. axisOptions.isX = true;
  63. chart
  64. .addZAxis(axisOptions)
  65. .setScale();
  66. });
  67. };
  68. /**
  69. * @private
  70. */
  71. ZChart.wrapAddZAxis = function (options) {
  72. return new ZAxis(this, options);
  73. };
  74. return ZChart;
  75. }());
  76. /**
  77. * 3D axis for z coordinates.
  78. */
  79. var ZAxis = /** @class */ (function (_super) {
  80. __extends(ZAxis, _super);
  81. /* *
  82. *
  83. * Constructors
  84. *
  85. * */
  86. function ZAxis(chart, userOptions) {
  87. var _this = _super.call(this, chart, userOptions) || this;
  88. _this.isZAxis = true;
  89. return _this;
  90. }
  91. /* *
  92. *
  93. * Functions
  94. *
  95. * */
  96. ZAxis.prototype.getSeriesExtremes = function () {
  97. var axis = this;
  98. var chart = axis.chart;
  99. axis.hasVisibleSeries = false;
  100. // Reset properties in case we're redrawing (#3353)
  101. axis.dataMin = axis.dataMax = axis.ignoreMinPadding = axis.ignoreMaxPadding = void 0;
  102. if (axis.stacking) {
  103. axis.stacking.buildStacks();
  104. }
  105. // loop through this axis' series
  106. axis.series.forEach(function (series) {
  107. if (series.visible ||
  108. !(chart.options.chart &&
  109. chart.options.chart.ignoreHiddenSeries)) {
  110. var seriesOptions = series.options, zData, threshold = seriesOptions.threshold;
  111. axis.hasVisibleSeries = true;
  112. // Validate threshold in logarithmic axes
  113. if (axis.positiveValuesOnly && threshold <= 0) {
  114. threshold = void 0;
  115. }
  116. zData = series.zData;
  117. if (zData.length) {
  118. axis.dataMin = Math.min(pick(axis.dataMin, zData[0]), Math.min.apply(null, zData));
  119. axis.dataMax = Math.max(pick(axis.dataMax, zData[0]), Math.max.apply(null, zData));
  120. }
  121. }
  122. });
  123. };
  124. /**
  125. * @private
  126. */
  127. ZAxis.prototype.setAxisSize = function () {
  128. var axis = this;
  129. var chart = axis.chart;
  130. _super.prototype.setAxisSize.call(this);
  131. axis.width = axis.len = (chart.options.chart &&
  132. chart.options.chart.options3d &&
  133. chart.options.chart.options3d.depth) || 0;
  134. axis.right = chart.chartWidth - axis.width - axis.left;
  135. };
  136. /**
  137. * @private
  138. */
  139. ZAxis.prototype.setOptions = function (userOptions) {
  140. userOptions = merge({
  141. offset: 0,
  142. lineWidth: 0
  143. }, userOptions);
  144. _super.prototype.setOptions.call(this, userOptions);
  145. this.coll = 'zAxis';
  146. };
  147. /* *
  148. *
  149. * Static Properties
  150. *
  151. * */
  152. ZAxis.ZChartComposition = ZChart;
  153. return ZAxis;
  154. }(Axis));
  155. export default ZAxis;