config.ts 1.5 KB

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