echarts.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view style="height: 350upx">
  3. <l-echart ref="detailedChart"></l-echart>
  4. </view>
  5. </template>
  6. <script setup>
  7. import * as echarts from "echarts";
  8. import { onLoad, onShow, onHide, onLaunch, onResize } from "@dcloudio/uni-app";
  9. import { defineComponent, ref, onMounted, nextTick } from "vue";
  10. const props = defineProps({
  11. xAxisDataList: {
  12. type: Object,
  13. default: null,
  14. },
  15. seriesDataList: {
  16. type: Object,
  17. default: null,
  18. },
  19. });
  20. let myChart;
  21. const detailedChart = ref(null);
  22. let option = {
  23. tooltip: {
  24. trigger: "axis",
  25. },
  26. legend: {
  27. show: false,
  28. // data: ["邮件营销"],
  29. },
  30. grid: {
  31. top: "8%",
  32. left: "3%",
  33. right: "4%",
  34. bottom: "3%",
  35. containLabel: true,
  36. },
  37. xAxis: {
  38. type: "category",
  39. boundaryGap: false,
  40. axisLabel: {
  41. color: "rgba(0,0,0,0.2)",
  42. },
  43. axisLine: {
  44. show: true,
  45. lineStyle: {
  46. color: "rgba(0,0,0,0.1)",
  47. },
  48. },
  49. axisTick: {
  50. show: false,
  51. },
  52. data: props.xAxisDataList,
  53. },
  54. yAxis: {
  55. type: "value",
  56. axisLabel: {
  57. color: "rgba(0,0,0,0.2)",
  58. },
  59. axisLine: {
  60. show: true,
  61. lineStyle: {
  62. color: "rgba(0,0,0,0.1)",
  63. },
  64. },
  65. splitLine: {
  66. lineStyle: {
  67. color: "rgba(0,0,0,0.1)",
  68. },
  69. },
  70. },
  71. series: [
  72. {
  73. name: "指数",
  74. type: "line",
  75. stack: "总量",
  76. smooth: true,
  77. itemStyle: {
  78. color: "rgba(73, 185, 245, 1)",
  79. },
  80. areaStyle: {
  81. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  82. {
  83. offset: 0,
  84. color: "rgba(73, 185, 245, 1)",
  85. },
  86. {
  87. offset: 1,
  88. color: "rgba(73, 185, 245, 0.3)",
  89. },
  90. ]),
  91. },
  92. data: props.seriesDataList,
  93. },
  94. ],
  95. };
  96. function initEcharts() {
  97. myChart = detailedChart.value;
  98. myChart.init(echarts, (myChart) => {
  99. myChart.setOption(option);
  100. });
  101. }
  102. onLoad(() => {
  103. nextTick(() => {
  104. initEcharts();
  105. });
  106. });
  107. onResize(() => {
  108. myChart.resize();
  109. });
  110. </script>