ChartLine.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <script setup lang="ts">
  2. import { type PropType, ref, computed } from "vue";
  3. import { useDark, useECharts } from "@pureadmin/utils";
  4. const props = defineProps({
  5. data: {
  6. type: Array as PropType<Array<number>>,
  7. default: () => []
  8. },
  9. color: {
  10. type: String,
  11. default: "#41b6ff"
  12. }
  13. });
  14. const { isDark } = useDark();
  15. const theme = computed(() => (isDark.value ? "dark" : "light"));
  16. const chartRef = ref();
  17. const { setOptions } = useECharts(chartRef, {
  18. theme,
  19. renderer: "svg"
  20. });
  21. setOptions({
  22. container: ".line-card",
  23. xAxis: {
  24. type: "category",
  25. show: false,
  26. data: props.data
  27. },
  28. grid: {
  29. top: "15px",
  30. bottom: 0,
  31. left: 0,
  32. right: 0
  33. },
  34. yAxis: {
  35. show: false,
  36. type: "value"
  37. },
  38. series: [
  39. {
  40. data: props.data,
  41. type: "line",
  42. symbol: "none",
  43. smooth: true,
  44. color: props.color,
  45. lineStyle: {
  46. shadowOffsetY: 3,
  47. shadowBlur: 7,
  48. shadowColor: props.color
  49. }
  50. }
  51. ]
  52. });
  53. </script>
  54. <template>
  55. <div ref="chartRef" style="width: 100%; height: 60px" />
  56. </template>