config.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
  2. import { PieCommonConfig } from './index'
  3. import { CreateComponentType } from '@/packages/index.d'
  4. import cloneDeep from 'lodash/cloneDeep'
  5. import dataJson from './data.json'
  6. export const includes = ['legend']
  7. export enum PieTypeEnum {
  8. NORMAL = '常规图',
  9. RING = '环形图',
  10. ROSE = '玫瑰图'
  11. }
  12. export const PieTypeObject = {
  13. [PieTypeEnum.NORMAL]: 'nomal',
  14. [PieTypeEnum.RING]: 'ring',
  15. [PieTypeEnum.ROSE]: 'rose'
  16. }
  17. const option = {
  18. type: 'ring',
  19. tooltip: {
  20. show: true,
  21. trigger: 'item'
  22. },
  23. legend: {
  24. show: true
  25. },
  26. dataset: { ...dataJson },
  27. series: [
  28. {
  29. type: 'pie',
  30. radius: ['40%', '65%'],
  31. center: ['50%', '60%'],
  32. roseType: false,
  33. avoidLabelOverlap: false,
  34. itemStyle: {
  35. show: true,
  36. borderRadius: 10,
  37. borderColor: '#fff',
  38. borderWidth: 2
  39. },
  40. label: {
  41. show: false,
  42. position: 'center',
  43. formatter: '{b}',
  44. fontSize:12
  45. },
  46. emphasis: {
  47. label: {
  48. show: true,
  49. fontSize: '40',
  50. fontWeight: 'bold'
  51. }
  52. },
  53. labelLine: {
  54. show: false
  55. }
  56. }
  57. ]
  58. }
  59. export default class Config extends PublicConfigClass implements CreateComponentType {
  60. public key: string = PieCommonConfig.key
  61. public chartConfig = cloneDeep(PieCommonConfig)
  62. // 图表配置项
  63. public option = echartOptionProfixHandle(option, includes)
  64. }