base.js 604 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @fileOverview Base class of chart and geometry
  3. * @author dxq613@gmail.com
  4. */
  5. import Emit from './graphic/event/emit';
  6. const Util = require('./util/common');
  7. class Base extends Emit {
  8. getDefaultCfg() {
  9. return {};
  10. }
  11. constructor(cfg) {
  12. super();
  13. const attrs = {};
  14. const defaultCfg = this.getDefaultCfg();
  15. this._attrs = attrs;
  16. Util.mix(attrs, defaultCfg, cfg);
  17. }
  18. get(name) {
  19. return this._attrs[name];
  20. }
  21. set(name, value) {
  22. this._attrs[name] = value;
  23. }
  24. destroy() {
  25. this._attrs = {};
  26. this.destroyed = true;
  27. }
  28. }
  29. module.exports = Base;