base.js 588 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @fileOverview Base class of chart and geometry
  3. * @author dxq613@gmail.com
  4. */
  5. import Emit from './graphic/event/emit';
  6. import { mix } from './util/common';
  7. class Base extends Emit {
  8. getDefaultCfg() {
  9. return {};
  10. }
  11. constructor(cfg) {
  12. super();
  13. var attrs = {};
  14. var defaultCfg = this.getDefaultCfg();
  15. this._attrs = attrs;
  16. 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. export default Base;