Scale.js 3.4 KB

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