base.js 712 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @fileOverview Base class of chart and geometry
  3. * @author dxq613@gmail.com
  4. */
  5. var Util = require('./util/common');
  6. var Base =
  7. /*#__PURE__*/
  8. function () {
  9. var _proto = Base.prototype;
  10. _proto.getDefaultCfg = function getDefaultCfg() {
  11. return {};
  12. };
  13. function Base(cfg) {
  14. var attrs = {};
  15. var defaultCfg = this.getDefaultCfg();
  16. this._attrs = attrs;
  17. Util.mix(attrs, defaultCfg, cfg);
  18. }
  19. _proto.get = function get(name) {
  20. return this._attrs[name];
  21. };
  22. _proto.set = function set(name, value) {
  23. this._attrs[name] = value;
  24. };
  25. _proto.destroy = function destroy() {
  26. this._attrs = {};
  27. this.destroyed = true;
  28. };
  29. return Base;
  30. }();
  31. module.exports = Base;