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

85 lines
1.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: '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. tooltip: {
  50. trigger: 'item',
  51. formatter: '{a} <br/>{b} : {c} ({d}%)'
  52. },
  53. legend: {
  54. left: 'center',
  55. bottom: '10',
  56. data: ['Industries', 'Technology', 'Forex', 'Gold', 'Forecasts']
  57. },
  58. calculable: true,
  59. series: [
  60. {
  61. name: 'WEEKLY WRITE ARTICLES',
  62. type: 'pie',
  63. roseType: 'radius',
  64. radius: [15, 95],
  65. center: ['50%', '38%'],
  66. data: [
  67. { value: 320, name: 'Industries' },
  68. { value: 240, name: 'Technology' },
  69. { value: 149, name: 'Forex' },
  70. { value: 100, name: 'Gold' },
  71. { value: 59, name: 'Forecasts' }
  72. ],
  73. animationEasing: 'cubicInOut',
  74. animationDuration: 2600
  75. }
  76. ]
  77. })
  78. }
  79. }
  80. }
  81. </script>