analytics-visits-source.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <script lang="ts" setup>
  2. import type { EchartsUIType } from '@vben/plugins/echarts';
  3. import { onMounted, ref } from 'vue';
  4. import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
  5. const chartRef = ref<EchartsUIType>();
  6. const { renderEcharts } = useEcharts(chartRef);
  7. onMounted(() => {
  8. renderEcharts({
  9. legend: {
  10. bottom: '2%',
  11. left: 'center',
  12. },
  13. series: [
  14. {
  15. animationDelay() {
  16. return Math.random() * 100;
  17. },
  18. animationEasing: 'exponentialInOut',
  19. animationType: 'scale',
  20. avoidLabelOverlap: false,
  21. color: ['#5ab1ef', '#b6a2de', '#67e0e3', '#2ec7c9'],
  22. data: [
  23. { name: '搜索引擎', value: 1048 },
  24. { name: '直接访问', value: 735 },
  25. { name: '邮件营销', value: 580 },
  26. { name: '联盟广告', value: 484 },
  27. ],
  28. emphasis: {
  29. label: {
  30. fontSize: '12',
  31. fontWeight: 'bold',
  32. show: true,
  33. },
  34. },
  35. itemStyle: {
  36. // borderColor: '#fff',
  37. borderRadius: 10,
  38. borderWidth: 2,
  39. },
  40. label: {
  41. position: 'center',
  42. show: false,
  43. },
  44. labelLine: {
  45. show: false,
  46. },
  47. name: '访问来源',
  48. radius: ['40%', '65%'],
  49. type: 'pie',
  50. },
  51. ],
  52. tooltip: {
  53. trigger: 'item',
  54. },
  55. });
  56. });
  57. </script>
  58. <template>
  59. <EchartsUI ref="chartRef" />
  60. </template>