Line.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <script setup lang="ts">
  2. import { ref, computed, type Ref } from "vue";
  3. import { useDark, useECharts, type EchartOptions } from "@pureadmin/utils";
  4. const { isDark } = useDark();
  5. let theme: EchartOptions["theme"] = computed(() => {
  6. return isDark.value ? "dark" : "light";
  7. });
  8. const lineChartRef = ref<HTMLDivElement | null>(null);
  9. const { setOptions } = useECharts(lineChartRef as Ref<HTMLDivElement>, {
  10. theme
  11. });
  12. setOptions(
  13. {
  14. grid: {
  15. bottom: "20%",
  16. height: "68%",
  17. containLabel: true
  18. },
  19. tooltip: {
  20. trigger: "item"
  21. },
  22. xAxis: {
  23. type: "category",
  24. axisLabel: {
  25. interval: 0
  26. },
  27. data: ["open_issues", "forks", "watchers", "star"]
  28. },
  29. yAxis: {
  30. type: "value"
  31. },
  32. series: [
  33. {
  34. data: [3, 204, 1079, 1079],
  35. type: "line",
  36. areaStyle: {}
  37. }
  38. ]
  39. },
  40. {
  41. name: "click",
  42. callback: params => {
  43. console.log("click", params);
  44. }
  45. }
  46. );
  47. </script>
  48. <template>
  49. <div ref="lineChartRef" style="width: 100%; height: 35vh" />
  50. </template>