chart.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div ref="chartTop" style="height: 300px;width: 50%"/>
  3. </template>
  4. <script setup lang="ts">
  5. import * as echarts from "echarts"
  6. const chartTop = ref(null)
  7. function initChart(data){
  8. const myChart = echarts.init(chartTop.value)
  9. const option = {
  10. tooltip: {
  11. trigger: 'axis'
  12. },
  13. grid: {
  14. left: '1%',
  15. right: '1%',
  16. bottom: '1%',
  17. top: '5%',
  18. containLabel: true
  19. },
  20. xAxis: {
  21. type: 'category',
  22. boundaryGap: false,
  23. data:data.time,
  24. axisLine: {
  25. show: true,
  26. lineStyle: {
  27. color: "#849ac4",
  28. width: 0,
  29. }
  30. },
  31. axisTick: {
  32. show: false,
  33. },
  34. },
  35. yAxis: {
  36. type: 'value',
  37. axisLine: {
  38. show: true,
  39. lineStyle: {
  40. color: "#849ac4",
  41. width: 0,
  42. }
  43. },
  44. splitLine: {
  45. lineStyle: {
  46. color: "#849ac480",
  47. type: 'dashed',
  48. }
  49. },
  50. },
  51. series: [
  52. {
  53. data: data.data,
  54. type: 'line',
  55. }
  56. ]
  57. };
  58. myChart.setOption(option)
  59. }
  60. defineExpose({initChart})
  61. </script>