Axis2D.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. import { __extends } from "tslib";
  41. import Axis from '../Axis.js';
  42. var Axis2D =
  43. /** @class */
  44. function (_super) {
  45. __extends(Axis2D, _super);
  46. function Axis2D(dim, scale, coordExtent, axisType, position) {
  47. var _this = _super.call(this, dim, scale, coordExtent) || this;
  48. /**
  49. * Index of axis, can be used as key
  50. * Injected outside.
  51. */
  52. _this.index = 0;
  53. _this.type = axisType || 'value';
  54. _this.position = position || 'bottom';
  55. return _this;
  56. }
  57. Axis2D.prototype.isHorizontal = function () {
  58. var position = this.position;
  59. return position === 'top' || position === 'bottom';
  60. };
  61. /**
  62. * Each item cooresponds to this.getExtent(), which
  63. * means globalExtent[0] may greater than globalExtent[1],
  64. * unless `asc` is input.
  65. *
  66. * @param {boolean} [asc]
  67. * @return {Array.<number>}
  68. */
  69. Axis2D.prototype.getGlobalExtent = function (asc) {
  70. var ret = this.getExtent();
  71. ret[0] = this.toGlobalCoord(ret[0]);
  72. ret[1] = this.toGlobalCoord(ret[1]);
  73. asc && ret[0] > ret[1] && ret.reverse();
  74. return ret;
  75. };
  76. Axis2D.prototype.pointToData = function (point, clamp) {
  77. return this.coordToData(this.toLocalCoord(point[this.dim === 'x' ? 0 : 1]), clamp);
  78. };
  79. /**
  80. * Set ordinalSortInfo
  81. * @param info new OrdinalSortInfo
  82. */
  83. Axis2D.prototype.setCategorySortInfo = function (info) {
  84. if (this.type !== 'category') {
  85. return false;
  86. }
  87. this.model.option.categorySortInfo = info;
  88. this.scale.setSortInfo(info);
  89. };
  90. return Axis2D;
  91. }(Axis);
  92. export default Axis2D;