identity.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2. var Base = require('./base');
  3. var isNumber = require('@antv/util/lib/type/is-number');
  4. var Identity =
  5. /*#__PURE__*/
  6. function (_Base) {
  7. _inheritsLoose(Identity, _Base);
  8. function Identity() {
  9. return _Base.apply(this, arguments) || this;
  10. }
  11. var _proto = Identity.prototype;
  12. _proto._initDefaultCfg = function _initDefaultCfg() {
  13. _Base.prototype._initDefaultCfg.call(this);
  14. this.isIdentity = true;
  15. this.type = 'identity';
  16. /**
  17. * 常量值
  18. * @type {*}
  19. */
  20. this.value = null;
  21. };
  22. /**
  23. * @override
  24. */
  25. _proto.getText = function getText() {
  26. return this.value.toString();
  27. };
  28. /**
  29. * @override
  30. */
  31. _proto.scale = function scale(value) {
  32. if (this.value !== value && isNumber(value)) {
  33. return value;
  34. }
  35. return this.range[0];
  36. };
  37. /**
  38. * @override
  39. */
  40. _proto.invert = function invert() {
  41. return this.value;
  42. };
  43. return Identity;
  44. }(Base);
  45. Base.Identity = Identity;
  46. module.exports = Identity;