Scale.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 * as clazzUtil from '../util/clazz.js';
  41. var Scale = /** @class */function () {
  42. function Scale(setting) {
  43. this._setting = setting || {};
  44. this._extent = [Infinity, -Infinity];
  45. }
  46. Scale.prototype.getSetting = function (name) {
  47. return this._setting[name];
  48. };
  49. /**
  50. * Set extent from data
  51. */
  52. Scale.prototype.unionExtent = function (other) {
  53. var extent = this._extent;
  54. other[0] < extent[0] && (extent[0] = other[0]);
  55. other[1] > extent[1] && (extent[1] = other[1]);
  56. // not setExtent because in log axis it may transformed to power
  57. // this.setExtent(extent[0], extent[1]);
  58. };
  59. /**
  60. * Set extent from data
  61. */
  62. Scale.prototype.unionExtentFromData = function (data, dim) {
  63. this.unionExtent(data.getApproximateExtent(dim));
  64. };
  65. /**
  66. * Get extent
  67. *
  68. * Extent is always in increase order.
  69. */
  70. Scale.prototype.getExtent = function () {
  71. return this._extent.slice();
  72. };
  73. /**
  74. * Set extent
  75. */
  76. Scale.prototype.setExtent = function (start, end) {
  77. var thisExtent = this._extent;
  78. if (!isNaN(start)) {
  79. thisExtent[0] = start;
  80. }
  81. if (!isNaN(end)) {
  82. thisExtent[1] = end;
  83. }
  84. };
  85. /**
  86. * If value is in extent range
  87. */
  88. Scale.prototype.isInExtentRange = function (value) {
  89. return this._extent[0] <= value && this._extent[1] >= value;
  90. };
  91. /**
  92. * When axis extent depends on data and no data exists,
  93. * axis ticks should not be drawn, which is named 'blank'.
  94. */
  95. Scale.prototype.isBlank = function () {
  96. return this._isBlank;
  97. };
  98. /**
  99. * When axis extent depends on data and no data exists,
  100. * axis ticks should not be drawn, which is named 'blank'.
  101. */
  102. Scale.prototype.setBlank = function (isBlank) {
  103. this._isBlank = isBlank;
  104. };
  105. return Scale;
  106. }();
  107. clazzUtil.enableClassManagement(Scale);
  108. export default Scale;