1ed9e87066da8634fdf5575fe9d7a6c107879f24.svn-base 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div :class="className" :style="{height:height,width:width}" />
  3. </template>
  4. <script>
  5. import 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. tooltip: {
  47. trigger: 'axis',
  48. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  49. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  50. }
  51. },
  52. radar: {
  53. radius: '66%',
  54. center: ['50%', '42%'],
  55. splitNumber: 8,
  56. splitArea: {
  57. areaStyle: {
  58. color: 'rgba(127,95,132,.3)',
  59. opacity: 1,
  60. shadowBlur: 45,
  61. shadowColor: 'rgba(0,0,0,.5)',
  62. shadowOffsetX: 0,
  63. shadowOffsetY: 15
  64. }
  65. },
  66. indicator: [
  67. { name: 'Sales', max: 10000 },
  68. { name: 'Administration', max: 20000 },
  69. { name: 'Information Techology', max: 20000 },
  70. { name: 'Customer Support', max: 20000 },
  71. { name: 'Development', max: 20000 },
  72. { name: 'Marketing', max: 20000 }
  73. ]
  74. },
  75. legend: {
  76. left: 'center',
  77. bottom: '10',
  78. data: ['Allocated Budget', 'Expected Spending', 'Actual Spending']
  79. },
  80. series: [{
  81. type: 'radar',
  82. symbolSize: 0,
  83. areaStyle: {
  84. normal: {
  85. shadowBlur: 13,
  86. shadowColor: 'rgba(0,0,0,.2)',
  87. shadowOffsetX: 0,
  88. shadowOffsetY: 10,
  89. opacity: 1
  90. }
  91. },
  92. data: [
  93. {
  94. value: [5000, 7000, 12000, 11000, 15000, 14000],
  95. name: 'Allocated Budget'
  96. },
  97. {
  98. value: [4000, 9000, 15000, 15000, 13000, 11000],
  99. name: 'Expected Spending'
  100. },
  101. {
  102. value: [5500, 11000, 12000, 15000, 12000, 12000],
  103. name: 'Actual Spending'
  104. }
  105. ],
  106. animationDuration: animationDuration
  107. }]
  108. })
  109. }
  110. }
  111. }
  112. </script>