index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { __extends } from "tslib";
  2. import { Event, VIEW_LIFE_CIRCLE } from '@antv/g2';
  3. import { Plot } from '../../core/plot';
  4. import { getProgressData } from '../progress/utils';
  5. import { adaptor, statistic } from './adaptor';
  6. import { DEFAULT_OPTIONS } from './constants';
  7. var RingProgress = /** @class */ (function (_super) {
  8. __extends(RingProgress, _super);
  9. function RingProgress() {
  10. var _this = _super !== null && _super.apply(this, arguments) || this;
  11. /** 图表类型 */
  12. _this.type = 'ring-process';
  13. return _this;
  14. }
  15. /**
  16. * 获取默认配置项
  17. * 供外部使用
  18. */
  19. RingProgress.getDefaultOptions = function () {
  20. return DEFAULT_OPTIONS;
  21. };
  22. /**
  23. * 更新数据
  24. * @param percent
  25. */
  26. RingProgress.prototype.changeData = function (percent) {
  27. this.chart.emit(VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA, Event.fromData(this.chart, VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA, null));
  28. this.updateOption({ percent: percent });
  29. this.chart.data(getProgressData(percent));
  30. // todo 后续让 G2 层在 afterrender 之后,来重绘 annotations
  31. statistic({ chart: this.chart, options: this.options }, true);
  32. this.chart.emit(VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA, Event.fromData(this.chart, VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA, null));
  33. };
  34. RingProgress.prototype.getDefaultOptions = function () {
  35. return RingProgress.getDefaultOptions();
  36. };
  37. /**
  38. * 获取 环形进度图 的适配器
  39. */
  40. RingProgress.prototype.getSchemaAdaptor = function () {
  41. return adaptor;
  42. };
  43. return RingProgress;
  44. }(Plot));
  45. export { RingProgress };
  46. //# sourceMappingURL=index.js.map