adaptor.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { __assign } from "tslib";
  2. import { get, isNil } from '@antv/util';
  3. import { animation, annotation, scale, theme } from '../../adaptor/common';
  4. import { deepAssign, flow, renderStatistic } from '../../utils';
  5. import { geometry } from '../progress/adaptor';
  6. /**
  7. * coordinate 配置
  8. * @param params
  9. */
  10. function coordinate(params) {
  11. var chart = params.chart, options = params.options;
  12. var innerRadius = options.innerRadius, radius = options.radius;
  13. // coordinate
  14. chart.coordinate('theta', {
  15. innerRadius: innerRadius,
  16. radius: radius,
  17. });
  18. return params;
  19. }
  20. /**
  21. * statistic 配置
  22. * @param params
  23. */
  24. export function statistic(params, updated) {
  25. var chart = params.chart, options = params.options;
  26. var innerRadius = options.innerRadius, statistic = options.statistic, percent = options.percent, meta = options.meta;
  27. // 先清空标注,再重新渲染
  28. chart.getController('annotation').clear(true);
  29. /** 中心文本 指标卡 */
  30. if (innerRadius && statistic) {
  31. var metaFormatter = get(meta, ['percent', 'formatter']) || (function (v) { return "".concat((v * 100).toFixed(2), "%"); });
  32. var contentOpt = statistic.content;
  33. if (contentOpt) {
  34. contentOpt = deepAssign({}, contentOpt, {
  35. content: !isNil(contentOpt.content) ? contentOpt.content : metaFormatter(percent),
  36. });
  37. }
  38. renderStatistic(chart, { statistic: __assign(__assign({}, statistic), { content: contentOpt }), plotType: 'ring-progress' }, { percent: percent });
  39. }
  40. if (updated) {
  41. chart.render(true);
  42. }
  43. return params;
  44. }
  45. /**
  46. * 环形进度图适配器
  47. * @param chart
  48. * @param options
  49. */
  50. export function adaptor(params) {
  51. return flow(geometry, scale({}), coordinate, statistic, animation, theme, annotation())(params);
  52. }
  53. //# sourceMappingURL=adaptor.js.map