Rap 原分销系统代码Web
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

191d4e623681237307cc91b29c4b69ed9bcd2da0.svn-base 2.1KB

5 miesięcy temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. const axisData = ['周一', '周二', '周三', '很长很长的周四', '周五', '周六', '周日']
  49. const data = axisData.map(function(item, i) {
  50. return Math.round(Math.random() * 1000 * (i + 1))
  51. })
  52. const links = data.map(function(item, i) {
  53. return {
  54. source: i,
  55. target: i + 1
  56. }
  57. })
  58. links.pop()
  59. this.chart.setOption({
  60. title: {
  61. text: '笛卡尔坐标系上的 Graph'
  62. },
  63. tooltip: {},
  64. xAxis: {
  65. type: 'category',
  66. boundaryGap: false,
  67. data: axisData
  68. },
  69. yAxis: {
  70. type: 'value'
  71. },
  72. series: [
  73. {
  74. type: 'graph',
  75. layout: 'none',
  76. coordinateSystem: 'cartesian2d',
  77. symbolSize: 40,
  78. label: {
  79. normal: {
  80. show: true
  81. }
  82. },
  83. edgeSymbol: ['circle', 'arrow'],
  84. edgeSymbolSize: [4, 10],
  85. data: data,
  86. links: links,
  87. lineStyle: {
  88. normal: {
  89. color: '#2f4554'
  90. }
  91. }
  92. }
  93. ]
  94. })
  95. }
  96. }
  97. }
  98. </script>