index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <TechCard>
  3. <div class="card-title">历史跌倒统计</div>
  4. <BaseChart :option="chartOption" :height="175" />
  5. </TechCard>
  6. </template>
  7. <script setup lang="ts">
  8. import { computed, ref } from 'vue'
  9. import * as echarts from 'echarts'
  10. import TechCard from '../TechCard/index.vue'
  11. defineOptions({ name: 'FallingHistoryCard' })
  12. const fallingHistoryData = ref({
  13. dates: ['2024-07-01', '2024-07-02', '2024-07-03', '2024-07-04', '2024-07-05'],
  14. values: [5, 8, 6, 10, 7],
  15. })
  16. const chartOption = computed(() => ({
  17. grid: { top: 10, right: 20, bottom: 30, left: 30 },
  18. tooltip: {
  19. trigger: 'axis',
  20. axisPointer: { type: 'shadow' },
  21. },
  22. xAxis: {
  23. type: 'category',
  24. data: fallingHistoryData.value.dates,
  25. axisLine: { lineStyle: { color: '#2a3b5a' } },
  26. axisLabel: { color: '#9cc5e0', fontSize: 12 },
  27. },
  28. yAxis: {
  29. type: 'value',
  30. axisLine: { lineStyle: { color: '#2a3b5a' } },
  31. axisLabel: { color: '#9cc5e0', fontSize: 12 },
  32. splitLine: { lineStyle: { color: 'rgba(42, 59, 90, 0.3)' } },
  33. },
  34. series: [
  35. {
  36. name: '跌倒次数',
  37. type: 'line',
  38. smooth: true,
  39. symbol: 'circle',
  40. symbolSize: 8,
  41. data: fallingHistoryData.value.values,
  42. itemStyle: { color: '#e74c3c' },
  43. lineStyle: {
  44. width: 3,
  45. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
  46. { offset: 0, color: '#e74c3c' },
  47. { offset: 1, color: '#c0392b' },
  48. ]),
  49. },
  50. areaStyle: {
  51. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  52. { offset: 0, color: 'rgba(231, 76, 60, 0.3)' },
  53. { offset: 1, color: 'rgba(231, 76, 60, 0.1)' },
  54. ]),
  55. },
  56. },
  57. ],
  58. }))
  59. </script>
  60. <style scoped lang="less">
  61. .card-title {
  62. font-size: 16px;
  63. font-weight: bold;
  64. color: #e74c3c;
  65. margin-bottom: 12px;
  66. text-align: center;
  67. }
  68. </style>