Sankey.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <div class="container">
  3. <div style="display: inline; float: left; width: 50%; border: #3b4151 solid 1px">
  4. <ve-sankey :data="chartData" :settings="chartSettings"></ve-sankey>
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. this.chartSettings = {
  12. links: [
  13. { source: '首页', target: '列表页a', value: 0.5 },
  14. { source: '首页', target: '列表页b', value: 0.5 },
  15. { source: '列表页a', target: '内容页a-1', value: 0.1 },
  16. { source: '列表页a', target: '内容页a-2', value: 0.4 },
  17. { source: '列表页b', target: '内容页b-1', value: 0.2 },
  18. { source: '列表页b', target: '内容页b-2', value: 0.3 }
  19. ]
  20. }
  21. return {
  22. days: 13,
  23. chartData: {
  24. columns: ['页面', '访问量'],
  25. rows: [
  26. { '页面': '首页', '访问量': 100000 },
  27. { '页面': '列表页a', '访问量': 20000 },
  28. { '页面': '列表页b', '访问量': 80000 },
  29. { '页面': '内容页a-1', '访问量': 10000 },
  30. { '页面': '内容页a-2', '访问量': 10000 },
  31. { '页面': '内容页b-1', '访问量': 60000 },
  32. { '页面': '内容页b-2', '访问量': 20000 }
  33. ]
  34. },
  35. chartExtend:{
  36. color:['#4ad2ff','#ad1453','#333333','#ffffff']
  37. }
  38. }
  39. },
  40. mounted() {
  41. let that = this;
  42. this.timer = setInterval(() => {
  43. that.getDate();
  44. }, 3300);
  45. },
  46. methods: {
  47. getDate() {
  48. let that = this;
  49. let newDate1 = that.getRandomInt(1000, 25000);
  50. let newDate2 = that.getRandomInt(1000, 2500);
  51. let newDate3 = that.getRandomInt(1000, 2500);
  52. let newDate4 = that.getRandomInt(1000, 2500);
  53. // this.chartData.rows = [
  54. // {'日期': '1/1', '访问用户': newDate1},
  55. // {'日期': '1/2', '访问用户': 2000},
  56. // {'日期': '1/3', '访问用户': 2000},
  57. // {'日期': '1/4', '访问用户': 2000}
  58. // ]
  59. },
  60. getRandomInt(min, max) {
  61. return Math.floor(Math.random() * (max - min + 1)) + min;
  62. }
  63. },
  64. }
  65. </script>
  66. <style scoped>
  67. </style>