Rap 原分销系统代码Web
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

4720ff9d662f4521f79ff1026983cda65ddbccf9.svn-base 2.6KB

hace 5 meses
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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: '300px'
  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. title: {
  50. text: '漏斗图',
  51. subtext: '纯属虚构'
  52. },
  53. tooltip: {
  54. trigger: 'item',
  55. formatter: '{a} <br/>{b} : {c}%'
  56. },
  57. toolbox: {
  58. feature: {
  59. dataView: { readOnly: false },
  60. restore: {},
  61. saveAsImage: {}
  62. }
  63. },
  64. legend: {
  65. data: ['展现', '点击', '访问', '咨询', '订单']
  66. },
  67. calculable: true,
  68. series: [
  69. {
  70. name: '漏斗图',
  71. type: 'funnel',
  72. left: '10%',
  73. top: 60,
  74. bottom: 60,
  75. width: '80%',
  76. // height: {totalHeight} - y - y2,
  77. min: 0,
  78. max: 100,
  79. minSize: '0%',
  80. maxSize: '100%',
  81. sort: 'descending',
  82. gap: 2,
  83. label: {
  84. show: true,
  85. position: 'inside'
  86. },
  87. labelLine: {
  88. length: 10,
  89. lineStyle: {
  90. width: 1,
  91. type: 'solid'
  92. }
  93. },
  94. itemStyle: {
  95. borderColor: '#fff',
  96. borderWidth: 1
  97. },
  98. emphasis: {
  99. label: {
  100. fontSize: 20
  101. }
  102. },
  103. data: [
  104. { value: 60, name: '访问' },
  105. { value: 40, name: '咨询' },
  106. { value: 20, name: '订单' },
  107. { value: 80, name: '点击' },
  108. { value: 100, name: '展现' }
  109. ]
  110. }
  111. ]
  112. })
  113. }
  114. }
  115. }
  116. </script>