TrendLine.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div ref="chartRef" :style="{ height, width }"></div>
  3. </template>
  4. <script lang="ts">
  5. import { defineComponent, onMounted, ref, Ref } from 'vue';
  6. import { useECharts } from '/@/hooks/web/useECharts';
  7. import { basicProps } from './props';
  8. export default defineComponent({
  9. props: basicProps,
  10. setup() {
  11. const chartRef = ref<HTMLDivElement | null>(null);
  12. const { setOptions, echarts } = useECharts(chartRef as Ref<HTMLDivElement>);
  13. onMounted(() => {
  14. setOptions({
  15. tooltip: {
  16. trigger: 'axis',
  17. padding: 3,
  18. borderColor: '#777',
  19. borderWidth: 1,
  20. },
  21. legend: {
  22. show: false,
  23. },
  24. grid: {
  25. left: '3%',
  26. right: '4%',
  27. bottom: '3%',
  28. containLabel: true,
  29. },
  30. xAxis: {
  31. type: 'category',
  32. boundaryGap: false,
  33. axisTick: {
  34. inside: true,
  35. },
  36. data: [
  37. '一月',
  38. '二月',
  39. '三月',
  40. '四月',
  41. '五月',
  42. '六月',
  43. '七月',
  44. '八月',
  45. '九月',
  46. '十月',
  47. '十一月',
  48. '十二月',
  49. ],
  50. },
  51. yAxis: {
  52. type: 'value',
  53. axisTick: {
  54. inside: true,
  55. },
  56. },
  57. series: [
  58. {
  59. name: '产品一',
  60. type: 'line',
  61. itemStyle: {
  62. color: '#5B8FF9',
  63. },
  64. areaStyle: {
  65. color: new echarts.graphic.LinearGradient(
  66. 0,
  67. 0,
  68. 0,
  69. 1,
  70. [
  71. {
  72. offset: 0,
  73. color: '#5B8FF9',
  74. },
  75. {
  76. offset: 1,
  77. color: 'rgba(118,168,248, 0)',
  78. },
  79. ],
  80. false
  81. ),
  82. shadowColor: 'rgba(118,168,248, 0.9)',
  83. shadowBlur: 20,
  84. },
  85. data: [134, 330, 132, 101, 90, 230, 210, 150, 230, 400, 232, 234],
  86. animationDuration: 3000,
  87. },
  88. ],
  89. });
  90. });
  91. return { chartRef };
  92. },
  93. });
  94. </script>