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.

67fa807034eed9ba83cb54610c85202a61c3d1c8.svn-base 3.2KB

пре 5 месеци
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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: 'Graph 简单示例'
  51. },
  52. tooltip: {},
  53. animationDurationUpdate: 1500,
  54. animationEasingUpdate: 'quinticInOut',
  55. series: [
  56. {
  57. type: 'graph',
  58. layout: 'none',
  59. symbolSize: 50,
  60. roam: true,
  61. label: {
  62. normal: {
  63. show: true
  64. }
  65. },
  66. edgeSymbol: ['circle', 'arrow'],
  67. edgeSymbolSize: [4, 10],
  68. edgeLabel: {
  69. normal: {
  70. textStyle: {
  71. fontSize: 20
  72. }
  73. }
  74. },
  75. data: [{
  76. name: '节点1',
  77. x: 100,
  78. y: 300
  79. }, {
  80. name: '节点2',
  81. x: 1000,
  82. y: 300
  83. }, {
  84. name: '节点3',
  85. x: 550,
  86. y: 100
  87. }, {
  88. name: '节点4',
  89. x: 550,
  90. y: 500
  91. }],
  92. // links: [],
  93. links: [{
  94. source: 0,
  95. target: 1,
  96. symbolSize: [5, 20],
  97. label: {
  98. normal: {
  99. show: true
  100. }
  101. },
  102. lineStyle: {
  103. normal: {
  104. width: 5,
  105. curveness: 0.2
  106. }
  107. }
  108. }, {
  109. source: '节点2',
  110. target: '节点1',
  111. label: {
  112. normal: {
  113. show: true
  114. }
  115. },
  116. lineStyle: {
  117. normal: { curveness: 0.2 }
  118. }
  119. }, {
  120. source: '节点1',
  121. target: '节点3'
  122. }, {
  123. source: '节点2',
  124. target: '节点3'
  125. }, {
  126. source: '节点2',
  127. target: '节点4'
  128. }, {
  129. source: '节点1',
  130. target: '节点4'
  131. }],
  132. lineStyle: {
  133. normal: {
  134. opacity: 0.9,
  135. width: 2,
  136. curveness: 0
  137. }
  138. }
  139. }
  140. ]
  141. })
  142. }
  143. }
  144. }
  145. </script>