Rap 原分销系统代码Web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ff515087522aa3b837a1bf7b7aec180906db6084.svn-base 1.9KB

преди 5 месеца
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. series: {
  50. type: 'sankey',
  51. layout: 'none',
  52. focusNodeAdjacency: 'allEdges',
  53. data: [{
  54. name: 'a'
  55. }, {
  56. name: 'b'
  57. }, {
  58. name: 'a1'
  59. }, {
  60. name: 'a2'
  61. }, {
  62. name: 'b1'
  63. }, {
  64. name: 'c'
  65. }],
  66. links: [{
  67. source: 'a',
  68. target: 'a1',
  69. value: 5
  70. }, {
  71. source: 'a',
  72. target: 'a2',
  73. value: 3
  74. }, {
  75. source: 'b',
  76. target: 'b1',
  77. value: 8
  78. }, {
  79. source: 'a',
  80. target: 'b1',
  81. value: 3
  82. }, {
  83. source: 'b1',
  84. target: 'a1',
  85. value: 1
  86. }, {
  87. source: 'b1',
  88. target: 'c',
  89. value: 2
  90. }]
  91. }
  92. })
  93. }
  94. }
  95. }
  96. </script>