userFlow.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div style="width: 100%; height: 100%" id="user_flow"></div>
  3. </template>
  4. <script>
  5. import echarts from "echarts";
  6. const option = {
  7. tooltip: {
  8. formatter: "{a} <br/>{b} : {c}%",
  9. },
  10. series: [
  11. {
  12. name: "入流量",
  13. type: "gauge",
  14. min: 0,
  15. max: 1000,
  16. detail: {
  17. formatter: "{value}Mb+",
  18. fontSize: 18,
  19. offsetCenter: [0, "50px"],
  20. },
  21. data: [{ value: 50, name: "当前入流量" }],
  22. center: ["25%", "50%"],
  23. radius: "80%",
  24. title: {
  25. offsetCenter: [0, "80px"],
  26. },
  27. axisLine: {
  28. lineStyle: {
  29. // color: [],
  30. width: 20,
  31. },
  32. },
  33. splitLine: {
  34. length: 20,
  35. },
  36. },
  37. {
  38. name: "出流量",
  39. type: "gauge",
  40. min: 0,
  41. max: 1000,
  42. detail: {
  43. formatter: "{value}Mb+",
  44. fontSize: 18,
  45. offsetCenter: [0, "50px"],
  46. },
  47. data: [{ value: 50, name: "当前出流量" }],
  48. center: ["75%", "50%"],
  49. radius: "80%",
  50. title: {
  51. offsetCenter: [0, "80px"],
  52. },
  53. axisLine: {
  54. lineStyle: {
  55. // color: [],
  56. width: 20,
  57. },
  58. },
  59. splitLine: {
  60. length: 20,
  61. },
  62. },
  63. ],
  64. };
  65. export default {
  66. name: "userFlow",
  67. mounted() {
  68. let userFlow = echarts.init(document.getElementById("user_flow"));
  69. option.series[0].data[0].value = (Math.random() * 1000).toFixed(2) - 0;
  70. option.series[1].data[0].value = (Math.random() * 1000).toFixed(2) - 0;
  71. userFlow.setOption(option);
  72. window.addEventListener("resize", function () {
  73. userFlow.resize();
  74. });
  75. },
  76. };
  77. </script>