RaddarChart.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div :class="className" :style="{height:height,width:width}" />
  3. </template>
  4. <script>
  5. import * as echarts from 'echarts'
  6. require('echarts/theme/macarons') // echarts theme
  7. import resize from './mixins/resize'
  8. const animationDuration = 3000
  9. export default {
  10. mixins: [resize],
  11. props: {
  12. className: {
  13. type: String,
  14. default: 'chart'
  15. },
  16. width: {
  17. type: String,
  18. default: '100%'
  19. },
  20. height: {
  21. type: String,
  22. default: '300px'
  23. }
  24. },
  25. data() {
  26. return {
  27. chart: null
  28. }
  29. },
  30. mounted() {
  31. this.$nextTick(() => {
  32. this.initChart()
  33. })
  34. },
  35. beforeDestroy() {
  36. if (!this.chart) {
  37. return
  38. }
  39. this.chart.dispose()
  40. this.chart = null
  41. },
  42. methods: {
  43. initChart() {
  44. this.chart = echarts.init(this.$el, 'macarons')
  45. this.chart.setOption({
  46. title: {
  47. text: ''
  48. },
  49. tooltip:{trigger:'item',backgroundColor:'#f2f2f2'},
  50. legend: {
  51. data:[]
  52. },
  53. splitArea : {
  54. show : false,
  55. areaStyle : {
  56. color: 'rgba(255,0,0,0)', // 图表背景的颜色
  57. },
  58. },
  59. // 设置雷达图中间射线的颜色
  60. axisLine: {
  61. lineStyle: {
  62. color: 'rgba(131,141,158,.1)',
  63. },
  64. },
  65. splitLine : {
  66. show : true,
  67. lineStyle : {
  68. width : 1,
  69. color : 'rgba(131,141,158,.1)', // 设置网格的颜色
  70. },
  71. },
  72. radar: {
  73. // shape: 'circle',
  74. indicator: [
  75. { name: 'Sales', max: 6500 },
  76. { name: 'Administration', max: 16000 },
  77. { name: 'Information Technology', max: 30000 },
  78. { name: 'Customer Support', max: 38000 },
  79. { name: 'Development', max: 52000 },
  80. { name: 'Marketing', max: 25000 }
  81. ]
  82. },
  83. series: [
  84. {
  85. name: 'Budget vs spending',
  86. type: 'radar',
  87. areaStyle: {
  88. normal: {
  89. width: 1,
  90. opacity: 0.2,
  91. },
  92. },
  93. data: [
  94. {
  95. value: [4200, 3000, 20000, 35000, 50000, 18000],
  96. name: 'Allocated Budget',
  97. // 设置区域边框和区域的颜色
  98. itemStyle: {
  99. normal: {
  100. color: 'rgba(255,171,43,1)',
  101. lineStyle: {
  102. color: 'rgba(255,171,43,0.17)',
  103. },
  104. },
  105. },
  106. areaStyle: {
  107. color: 'rgba(255,171,43,1)'
  108. }
  109. },
  110. ]
  111. }
  112. ]
  113. })
  114. }
  115. }
  116. }
  117. </script>