oneLineOption.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import * as echarts from "echarts";
  2. function formatDateToMMDD(date) {
  3. const month = String(date.getMonth() + 1).padStart(2, "0"); // 月份从0开始,需要加1,并确保是两位数
  4. const day = String(date.getDate()).padStart(2, "0"); // 确保日期是两位数
  5. return `${month}/${day}`;
  6. }
  7. function getCurrentDateAndNextSixDaysMMDD() {
  8. const currentDate = new Date();
  9. const dates = [];
  10. for (let i = 0; i <= 6; i++) {
  11. const newDate = new Date(currentDate);
  12. newDate.setDate(currentDate.getDate() + i);
  13. const formattedDate = formatDateToMMDD(newDate);
  14. dates.push(formattedDate);
  15. }
  16. return dates;
  17. }
  18. const list = getCurrentDateAndNextSixDaysMMDD();
  19. export const oneLine = {
  20. // tooltip: {
  21. // trigger: "axis",
  22. // },
  23. grid: {
  24. top: 14,
  25. left: 6,
  26. right: 6,
  27. bottom: 6,
  28. containLabel: true,
  29. },
  30. xAxis: {
  31. type: 'category',
  32. // 分割线
  33. axisTick: {
  34. show: false,
  35. },
  36. splitLine: {
  37. show: false,
  38. },
  39. axisLabel: {
  40. // interval: 8,
  41. rotate: 15,
  42. margin: 14,
  43. color: "#9F9F9F",
  44. fontSize: 10
  45. },
  46. axisLine: {
  47. lineStyle: {
  48. color: "rgba(185, 185, 185, 0.12)",
  49. }
  50. },
  51. data: list
  52. },
  53. yAxis: [{
  54. type: 'value',
  55. offset: 10,
  56. interval: 10,
  57. axisTick: {
  58. show: false,
  59. },
  60. axisLine: {
  61. show: false,
  62. },
  63. axisLabel: {
  64. align: "center",
  65. formatter: '{value} °',
  66. color: "#fff",
  67. fontSize: 10
  68. },
  69. // 分割线
  70. splitLine: {
  71. lineStyle: {
  72. type: [4, 3],
  73. dashOffset: 5,
  74. color: "#333333",
  75. },
  76. },
  77. splitNumber: 4, // 设置5个分割段
  78. }],
  79. series: [
  80. {
  81. name: "温度",
  82. data: [],
  83. type: 'line',
  84. smooth: true,
  85. symbol: "none",
  86. itemStyle: { color: "#FF7219" },
  87. lineStyle: {
  88. color: "#FF7219", // 折线颜色为红色
  89. width: 2, // 线条宽度
  90. },
  91. areaStyle: {
  92. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  93. { offset: 0, color: "#F0AC37" }, // 渐变起始颜色
  94. { offset: 1, color: "rgba(35, 35, 35, 0)" }, // 渐变结束颜色
  95. ]),
  96. },
  97. markPoint: {
  98. // symbol: 'path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z',
  99. symbolSize: [0, 0],
  100. data: [
  101. {
  102. name: "text",
  103. value: "10°",
  104. xAxis: list[0],
  105. yAxis: '',
  106. symbolOffset: [0, "-50%"],
  107. label: {
  108. offset: [0, -15],
  109. backgroundColor: "#FF7219",
  110. padding: [0, 8, 0, 8],
  111. color: "#fff",
  112. height: 18,
  113. borderRadius: 10,
  114. },
  115. },
  116. {
  117. name: "mark",
  118. xAxis: list[0],
  119. yAxis: '',
  120. value: "",
  121. label: {
  122. backgroundColor: "#fff",
  123. borderWidth: 2,
  124. borderColor: "rgba(255, 255, 255, 0.5)",
  125. borderRadius: 8,
  126. width: 4,
  127. height: 4,
  128. },
  129. },
  130. ]
  131. },
  132. },
  133. {
  134. name: "低温",
  135. data: [],
  136. type: "line",
  137. symbol: "none",
  138. smooth: true,
  139. lineStyle: {
  140. color: "#2199F8", // 折线颜色为红色
  141. width: 2, // 线条宽度
  142. },
  143. itemStyle: {
  144. color: "#368ACD"
  145. },
  146. areaStyle: {
  147. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  148. { offset: 0, color: "rgba(33, 153, 248, 0.4)" }, // 渐变起始颜色
  149. { offset: 1, color: "rgba(138, 203, 255, 0.02)" }, // 渐变结束颜色
  150. ]),
  151. },
  152. markPoint: {
  153. symbolSize: [0, 0],
  154. data: [
  155. {
  156. name: "text",
  157. value: "最低",
  158. xAxis: list[0],
  159. yAxis: '',
  160. symbolOffset: [0, "-50%"],
  161. label: {
  162. offset: [0, 15],
  163. color: "#fff",
  164. backgroundColor: "#4993e8",
  165. padding: [0, 8, 0, 8],
  166. height: 20,
  167. borderRadius: 10,
  168. },
  169. },
  170. {
  171. name: "mark",
  172. xAxis: list[0],
  173. yAxis: '',
  174. value: "",
  175. label: {
  176. backgroundColor: "#fff",
  177. borderWidth: 2,
  178. borderColor: "rgba(255, 255, 255, 0.5)",
  179. borderRadius: 8,
  180. width: 4,
  181. height: 4,
  182. },
  183. },
  184. ]
  185. },
  186. }
  187. ],
  188. }