StatCard.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script setup lang="ts">
  2. import { computed } from 'vue'
  3. import type { KpiStat } from '../data'
  4. const props = defineProps<{ kpi: KpiStat }>()
  5. const option = computed(() => ({
  6. animationDuration: 1600,
  7. grid: { left: 0, right: 0, top: 1, bottom: 0 },
  8. xAxis: {
  9. show: false,
  10. type: 'category',
  11. data: props.kpi.chartData.map((_, j) => j),
  12. },
  13. yAxis: { show: false, type: 'value' },
  14. series: [
  15. {
  16. type: 'line',
  17. data: props.kpi.chartData,
  18. smooth: true,
  19. symbol: 'none',
  20. lineStyle: { color: props.kpi.chartColor, width: 2 },
  21. areaStyle: { color: props.kpi.chartColor, opacity: 0.15 },
  22. },
  23. ],
  24. }))
  25. </script>
  26. <template>
  27. <article
  28. class="relative overflow-hidden rounded-sm
  29. border border-[#7f4034] bg-[#351817]/75 p-3
  30. shadow-[inset_0_0_22px_rgba(194,77,54,.12)] "
  31. >
  32. <p class="flex items-center gap-1.5 text-xs text-[#d4b6a2]">
  33. <Icon :icon="kpi.icon" :class="kpi.iconColor" width="16" />
  34. {{ kpi.title }}
  35. </p>
  36. <div class="mt-1 flex items-end justify-between">
  37. <p class="text-2xl font-bold text-[#fae8b1]">
  38. {{ kpi.value }}<span class="ml-1 text-xs font-normal">{{ kpi.unit }}</span>
  39. </p>
  40. <span class="text-xs" :class="kpi.trendColor">{{ kpi.trend }}</span>
  41. </div>
  42. <div class="mt-2 h-25">
  43. <VChart :option="option" autoresize />
  44. </div>
  45. </article>
  46. </template>