count-views.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="count-views">
  3. <div class="card">
  4. <div class="card__header">
  5. <span class="label">总访问量</span>
  6. <span class="value">8846</span>
  7. </div>
  8. <div class="card__container">
  9. <v-chart :option="chartOption" autoresize />
  10. </div>
  11. <div class="card__footer">
  12. <span class="label">日访问量</span>
  13. <span class="value">1351</span>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script lang="ts" setup>
  19. import { reactive } from 'vue';
  20. import * as echarts from 'echarts';
  21. const chartOption = reactive({
  22. grid: {
  23. left: 0,
  24. top: 1,
  25. right: 0,
  26. bottom: 1
  27. },
  28. xAxis: {
  29. type: 'category',
  30. boundaryGap: false,
  31. axisLine: {
  32. show: false
  33. },
  34. data: [
  35. '00:00',
  36. '2:00',
  37. '4:00',
  38. '6:00',
  39. '8:00',
  40. '10:00',
  41. '12:00',
  42. '14:00',
  43. '16:00',
  44. '18:00',
  45. '20:00',
  46. '22:00'
  47. ]
  48. },
  49. yAxis: {
  50. type: 'value',
  51. splitLine: {
  52. show: false
  53. },
  54. axisTick: {
  55. show: false
  56. },
  57. axisLine: {
  58. show: false
  59. },
  60. axisLabel: {
  61. show: false
  62. }
  63. },
  64. series: [
  65. {
  66. type: 'line',
  67. smooth: true,
  68. showSymbol: false,
  69. symbol: 'circle',
  70. symbolSize: 6,
  71. data: new Array(12)
  72. .fill(1)
  73. .map(() => parseInt((Math.random() * 1000).toFixed(0)) + 500),
  74. areaStyle: {
  75. color: new echarts.graphic.LinearGradient(
  76. 0,
  77. 0,
  78. 0,
  79. 1,
  80. [
  81. {
  82. offset: 0,
  83. color: '#D1E5FF'
  84. },
  85. {
  86. offset: 1,
  87. color: '#FFFFFF'
  88. }
  89. ],
  90. false
  91. )
  92. },
  93. itemStyle: {
  94. color: '#4165d7'
  95. },
  96. lineStyle: {
  97. width: 2
  98. }
  99. }
  100. ]
  101. });
  102. </script>
  103. <style lang="scss" scoped>
  104. .count-views {
  105. .card {
  106. .echarts {
  107. height: 50px;
  108. width: 100%;
  109. }
  110. &__container {
  111. padding: 0;
  112. }
  113. &__footer {
  114. border-top: 0;
  115. }
  116. }
  117. }
  118. </style>