adaptor.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { isString } from '@antv/util';
  2. import { animation, annotation, scale, theme } from '../../adaptor/common';
  3. import { interval } from '../../adaptor/geometries';
  4. import { deepAssign, flow } from '../../utils';
  5. import { DEFAULT_COLOR } from './constants';
  6. import { getProgressData } from './utils';
  7. /**
  8. * 字段
  9. * @param params
  10. */
  11. export function geometry(params) {
  12. var chart = params.chart, options = params.options;
  13. var percent = options.percent, progressStyle = options.progressStyle, color = options.color, barWidthRatio = options.barWidthRatio;
  14. chart.data(getProgressData(percent));
  15. var p = deepAssign({}, params, {
  16. options: {
  17. xField: 'current',
  18. yField: 'percent',
  19. seriesField: 'type',
  20. widthRatio: barWidthRatio,
  21. interval: {
  22. style: progressStyle,
  23. color: isString(color) ? [color, DEFAULT_COLOR[1]] : color,
  24. },
  25. args: {
  26. zIndexReversed: true,
  27. sortZIndex: true,
  28. },
  29. },
  30. });
  31. interval(p);
  32. // 关闭组件
  33. chart.tooltip(false);
  34. chart.axis(false);
  35. chart.legend(false);
  36. return params;
  37. }
  38. /**
  39. * other 配置
  40. * @param params
  41. */
  42. function coordinate(params) {
  43. var chart = params.chart;
  44. chart.coordinate('rect').transpose();
  45. return params;
  46. }
  47. /**
  48. * 进度图适配器
  49. * @param chart
  50. * @param options
  51. */
  52. export function adaptor(params) {
  53. // @ts-ignore
  54. return flow(geometry, scale({}), coordinate, animation, theme, annotation())(params);
  55. }
  56. //# sourceMappingURL=adaptor.js.map