right-top.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <v-chart
  3. class="chart"
  4. :option="option"
  5. v-if="JSON.stringify(option) != '{}'"
  6. />
  7. </template>
  8. <script setup lang="ts">
  9. import { ref, onMounted } from "vue";
  10. import { graphic } from "echarts/core";
  11. import Mock from "mockjs";
  12. const option = ref({});
  13. const getData = () => {
  14. // window["$message"]({
  15. // text: res.msg,
  16. // type: "warning",
  17. // });
  18. const data = Mock.mock({
  19. xdata: ['2023-07', '2023-08', '2023-09', '2023-10', '2023-11', "2023-12"],
  20. "yData|6": ["@integer(0, 1000)"],
  21. "yData2|6": ["@integer(0, 1000)"],
  22. })
  23. setTimeout(() => {
  24. setOption(data);
  25. }, 100);
  26. }
  27. const setOption = async (data:any) => {
  28. option.value = {
  29. xAxis: {
  30. type: "category",
  31. data: data.xdata,
  32. boundaryGap: false, // 不留白,从原点开始
  33. splitLine: {
  34. show: true,
  35. lineStyle: {
  36. color: "rgba(31,99,163,.2)",
  37. },
  38. },
  39. axisLine: {
  40. // show:false,
  41. lineStyle: {
  42. color: "rgba(31,99,163,.1)",
  43. },
  44. },
  45. axisLabel: {
  46. color: "#7EB7FD",
  47. fontWeight: "500",
  48. },
  49. },
  50. yAxis: {
  51. type: "value",
  52. splitLine: {
  53. show: true,
  54. lineStyle: {
  55. color: "rgba(31,99,163,.2)",
  56. },
  57. },
  58. axisLine: {
  59. lineStyle: {
  60. color: "rgba(31,99,163,.1)",
  61. },
  62. },
  63. axisLabel: {
  64. color: "#7EB7FD",
  65. fontWeight: "500",
  66. },
  67. },
  68. tooltip: {
  69. trigger: "axis",
  70. backgroundColor: "rgba(0,0,0,.6)",
  71. borderColor: "rgba(147, 235, 248, .8)",
  72. textStyle: {
  73. color: "#FFF",
  74. },
  75. },
  76. grid: {
  77. //布局
  78. show: true,
  79. left: "10px",
  80. right: "30px",
  81. bottom: "10px",
  82. top: "32px",
  83. containLabel: true,
  84. borderColor: "#1F63A3",
  85. },
  86. series: [
  87. {
  88. data: data.yData,
  89. type: "line",
  90. smooth: true,
  91. symbol: "none", //去除点
  92. name: "最高1次数",
  93. color: "rgba(252,144,16,.7)",
  94. areaStyle: {
  95. //右,下,左,上
  96. color: new graphic.LinearGradient(
  97. 0,
  98. 0,
  99. 0,
  100. 1,
  101. [
  102. {
  103. offset: 0,
  104. color: "rgba(252,144,16,.7)",
  105. },
  106. {
  107. offset: 1,
  108. color: "rgba(252,144,16,.0)",
  109. },
  110. ],
  111. false
  112. ),
  113. },
  114. markPoint: {
  115. data: [
  116. {
  117. name: "最大值",
  118. type: "max",
  119. valueDim: "y",
  120. symbol: "rect",
  121. symbolSize: [60, 26],
  122. symbolOffset: [0, -20],
  123. itemStyle: {
  124. color: "rgba(0,0,0,0)",
  125. },
  126. label: {
  127. color: "#FC9010",
  128. backgroundColor: "rgba(252,144,16,0.1)",
  129. borderRadius: 6,
  130. padding: [7, 14],
  131. borderWidth: 0.5,
  132. borderColor: "rgba(252,144,16,.5)",
  133. formatter: "峰值1:{c}",
  134. },
  135. },
  136. {
  137. name: "最大值",
  138. type: "max",
  139. valueDim: "y",
  140. symbol: "circle",
  141. symbolSize: 6,
  142. itemStyle: {
  143. color: "#FC9010",
  144. shadowColor: "#FC9010",
  145. shadowBlur: 8,
  146. },
  147. label: {
  148. formatter: "",
  149. },
  150. },
  151. ],
  152. },
  153. },
  154. {
  155. data: data.yData2,
  156. type: "line",
  157. smooth: true,
  158. symbol: "none", //去除点
  159. name: "最高2次数",
  160. color: "rgba(9,202,243,.7)",
  161. areaStyle: {
  162. //右,下,左,上
  163. color: new graphic.LinearGradient(
  164. 0,
  165. 0,
  166. 0,
  167. 1,
  168. [
  169. {
  170. offset: 0,
  171. color: "rgba(9,202,243,.7)",
  172. },
  173. {
  174. offset: 1,
  175. color: "rgba(9,202,243,.0)",
  176. },
  177. ],
  178. false
  179. ),
  180. },
  181. markPoint: {
  182. data: [
  183. {
  184. name: "最大值",
  185. type: "max",
  186. valueDim: "y",
  187. symbol: "rect",
  188. symbolSize: [60, 26],
  189. symbolOffset: [0, -20],
  190. itemStyle: {
  191. color: "rgba(0,0,0,0)",
  192. },
  193. label: {
  194. color: "#09CAF3",
  195. backgroundColor: "rgba(9,202,243,0.1)",
  196. borderRadius: 6,
  197. borderColor: "rgba(9,202,243,.5)",
  198. padding: [7, 14],
  199. formatter: "峰值2:{c}",
  200. borderWidth: 0.5,
  201. },
  202. },
  203. {
  204. name: "最大值",
  205. type: "max",
  206. valueDim: "y",
  207. symbol: "circle",
  208. symbolSize: 6,
  209. itemStyle: {
  210. color: "#09CAF3",
  211. shadowColor: "#09CAF3",
  212. shadowBlur: 8,
  213. },
  214. label: {
  215. formatter: "",
  216. },
  217. },
  218. ],
  219. },
  220. },
  221. ],
  222. };
  223. };
  224. onMounted(() => {
  225. getData();
  226. });
  227. </script>
  228. <style scoped lang="scss"></style>