identity.js 1.2 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. ;
  26. _proto.getText = function getText() {
  27. return this.value.toString();
  28. }
  29. /**
  30. * @override
  31. */
  32. ;
  33. _proto.scale = function scale(value) {
  34. if (this.value !== value && isNumber(value)) {
  35. return value;
  36. }
  37. return this.range[0];
  38. }
  39. /**
  40. * @override
  41. */
  42. ;
  43. _proto.invert = function invert() {
  44. return this.value;
  45. };
  46. return Identity;
  47. }(Base);
  48. Base.Identity = Identity;
  49. module.exports = Identity;