Rap 原分销系统代码Web
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
3.8KB

  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 { debounce } from '@/utils'
  8. export default {
  9. props: {
  10. className: {
  11. type: String,
  12. default: 'chart'
  13. },
  14. width: {
  15. type: String,
  16. default: '100%'
  17. },
  18. height: {
  19. type: String,
  20. default: '500px'
  21. }
  22. },
  23. data() {
  24. return {
  25. chart: null
  26. }
  27. },
  28. mounted() {
  29. this.initChart()
  30. this.__resizeHandler = debounce(() => {
  31. if (this.chart) {
  32. this.chart.resize()
  33. }
  34. }, 100)
  35. window.addEventListener('resize', this.__resizeHandler)
  36. },
  37. beforeDestroy() {
  38. if (!this.chart) {
  39. return
  40. }
  41. window.removeEventListener('resize', this.__resizeHandler)
  42. this.chart.dispose()
  43. this.chart = null
  44. },
  45. methods: {
  46. initChart() {
  47. this.chart = echarts.init(this.$el, 'macarons')
  48. this.chart.setOption({
  49. tooltip: {
  50. trigger: 'item',
  51. formatter: '{a} <br/>{b}: {c} ({d}%)'
  52. },
  53. legend: {
  54. orient: 'vertical',
  55. x: 'left',
  56. data: ['直达', '营销广告', '搜索引擎', '邮件营销', '联盟广告', '视频广告', '百度', '谷歌', '必应', '其他']
  57. },
  58. series: [
  59. {
  60. name: '访问来源',
  61. type: 'pie',
  62. selectedMode: 'single',
  63. radius: [0, '30%'],
  64. label: {
  65. normal: {
  66. position: 'inner'
  67. }
  68. },
  69. labelLine: {
  70. normal: {
  71. show: false
  72. }
  73. },
  74. data: [
  75. { value: 335, name: '直达', selected: true },
  76. { value: 679, name: '营销广告' },
  77. { value: 1548, name: '搜索引擎' }
  78. ]
  79. },
  80. {
  81. name: '访问来源',
  82. type: 'pie',
  83. radius: ['40%', '55%'],
  84. label: {
  85. normal: {
  86. formatter: '{a|{a}}{abg|}\n{hr|}\n {b|{b}:}{c} {per|{d}%} ',
  87. backgroundColor: '#eee',
  88. borderColor: '#aaa',
  89. borderWidth: 1,
  90. borderRadius: 4,
  91. shadowBlur: 3,
  92. shadowOffsetX: 2,
  93. shadowOffsetY: 2,
  94. shadowColor: '#999',
  95. padding: [0, 7],
  96. rich: {
  97. a: {
  98. color: '#999',
  99. lineHeight: 22,
  100. align: 'center'
  101. },
  102. abg: {
  103. backgroundColor: '#333',
  104. width: '100%',
  105. align: 'right',
  106. height: 22,
  107. borderRadius: [4, 4, 0, 0]
  108. },
  109. hr: {
  110. borderColor: '#aaa',
  111. width: '100%',
  112. borderWidth: 0.5,
  113. height: 0
  114. },
  115. b: {
  116. fontSize: 16,
  117. lineHeight: 33
  118. },
  119. per: {
  120. color: '#eee',
  121. backgroundColor: '#334455',
  122. padding: [2, 4],
  123. borderRadius: 2
  124. }
  125. }
  126. }
  127. },
  128. data: [
  129. { value: 335, name: '直达' },
  130. { value: 310, name: '邮件营销' },
  131. { value: 234, name: '联盟广告' },
  132. { value: 135, name: '视频广告' },
  133. { value: 1048, name: '百度' },
  134. { value: 251, name: '谷歌' },
  135. { value: 147, name: '必应' },
  136. { value: 102, name: '其他' }
  137. ]
  138. }
  139. ]
  140. })
  141. }
  142. }
  143. }
  144. </script>