config.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { getUUID } from '@/utils'
  2. import { echartOptionProfixHandle } from '@/packages/utils/chart'
  3. import { PieCommonConfig } from './index'
  4. import { ConfigType, CreateComponentType } from '@/packages/index.d'
  5. import omit from 'lodash/omit'
  6. export default class Config implements CreateComponentType {
  7. public id: string = getUUID()
  8. public key: string = PieCommonConfig.key
  9. public chartData: Exclude<ConfigType, ['node']> = omit(PieCommonConfig, ['node'])
  10. public attr = { x: 0, y: 0, w: 500, h: 300 }
  11. // 图表配置项
  12. public option = echartOptionProfixHandle({
  13. tooltip: {
  14. trigger: 'item'
  15. },
  16. legend: {
  17. top: '5%',
  18. left: 'center'
  19. },
  20. series: [
  21. {
  22. name: 'Access From',
  23. type: 'pie',
  24. radius: ['40%', '70%'],
  25. avoidLabelOverlap: false,
  26. itemStyle: {
  27. borderRadius: 10,
  28. borderColor: '#fff',
  29. borderWidth: 2
  30. },
  31. label: {
  32. show: false,
  33. position: 'center'
  34. },
  35. emphasis: {
  36. label: {
  37. show: true,
  38. fontSize: '40',
  39. fontWeight: 'bold'
  40. }
  41. },
  42. labelLine: {
  43. show: false
  44. },
  45. data: [
  46. { value: 1048, name: 'Search Engine' },
  47. { value: 735, name: 'Direct' },
  48. { value: 580, name: 'Email' },
  49. { value: 484, name: 'Union Ads' },
  50. { value: 300, name: 'Video Ads' }
  51. ]
  52. }
  53. ]
  54. })
  55. // 设置坐标
  56. public setPosition(x: number, y: number): void {
  57. this.attr.x = x
  58. this.attr.y = y
  59. }
  60. }