chartSeting.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. import * as echarts from "echarts";
  2. export const galleryLine = {
  3. tooltip: {
  4. trigger: "axis",
  5. },
  6. grid: {
  7. top: 28,
  8. left: 10,
  9. right: 26,
  10. bottom: 0,
  11. containLabel: true,
  12. },
  13. xAxis: {
  14. name: "时间",
  15. nameLocation: "end",
  16. nameGap: 4,
  17. nameTextStyle: {
  18. fontSize: 10,
  19. color: "#9F9F9F"
  20. },
  21. type: 'category',
  22. // 分割线
  23. axisTick: {
  24. show: false,
  25. },
  26. splitLine: {
  27. show: false,
  28. },
  29. axisLabel: {
  30. // interval: 0,
  31. rotate: 15,
  32. margin: 14,
  33. textStyle: {
  34. color: "rgba(187, 187, 187, 0.36)",
  35. fontSize: 10
  36. },
  37. },
  38. data: ['9/1', '9/7', '9/13', '9/19', '9/25', '10/1', '10/7']
  39. },
  40. yAxis: {
  41. name: "xx指标",
  42. nameLocation: "end",
  43. type: 'value',
  44. nameTextStyle: {
  45. fontSize: 10,
  46. color: "#9F9F9F"
  47. },
  48. axisTick: {
  49. show: false,
  50. },
  51. axisLine: {
  52. show: true,
  53. lineStyle: {
  54. color: "rgba(187, 187, 187, 0.36)",
  55. },
  56. },
  57. axisLabel: {
  58. textStyle: {
  59. color: "#666666",
  60. fontSize: 10
  61. },
  62. },
  63. // 分割线
  64. splitLine: {
  65. show: false,
  66. lineStyle: {
  67. color: "rgba(255, 255, 255, 0.1)",
  68. },
  69. },
  70. },
  71. series: [
  72. {
  73. data: [40, 58, 62, 64, 68, 74, 80],
  74. type: 'line',
  75. symbolSize: 6,
  76. itemStyle: {
  77. color: '#FFD489' // 设置数据点颜色为红色
  78. },
  79. // itemStyle: {
  80. // color: '#CECECE' // 设置数据点颜色
  81. // },
  82. // lineStyle: {
  83. // type: 'dashed', // 设置线条为虚线
  84. // width: 2, // 设置线条宽度
  85. // color: '#CECECE' // 设置线条颜色
  86. // }
  87. }
  88. ],
  89. }
  90. export const galleryIndicatorLine = {
  91. tooltip: {
  92. trigger: "axis",
  93. },
  94. legend: {
  95. icon: 'roundRect',
  96. top: 0,
  97. left: 0,
  98. orient: 'horizontal',
  99. itemWidth: 6,
  100. itemHeight: 2,
  101. itemGap: 4,
  102. textStyle: {
  103. align: 'left',
  104. fontSize: 10,
  105. },
  106. data: [
  107. { name: '褪绿率', textStyle: { color: '#66B9FB' }, itemStyle: {color: "#66B9FB"} },
  108. { name: '花芽率', textStyle: { color: '#1B98FC' }, itemStyle: {color: "#1B98FC"} },
  109. { name: '花蕾率', textStyle: { color: '#036CC0' }, itemStyle: {color: "#036CC0"} },
  110. { name: '生长异常', textStyle: { color: '#F7BE5A' }, itemStyle: {color: "#F7BE5A"} },
  111. { name: '病虫异常', textStyle: { color: '#F99851' }, itemStyle: {color: "#F99851"} }
  112. ]
  113. },
  114. grid: {
  115. top: 30,
  116. left: 8,
  117. right: 18,
  118. bottom: 4,
  119. containLabel: true,
  120. },
  121. xAxis: {
  122. type: 'category',
  123. boundaryGap: false,
  124. // 分割线
  125. axisTick: {
  126. show: false,
  127. },
  128. splitLine: {
  129. show: false,
  130. },
  131. axisLabel: {
  132. // interval: 0,
  133. rotate: 15,
  134. margin: 14,
  135. textStyle: {
  136. color: "#999999",
  137. fontSize: 12
  138. },
  139. formatter: function (value) {
  140. // 获取后 5 位字符(假设日期格式始终为 'YYYY-MM-DD')
  141. let shortenedValue = value.slice(-5);
  142. // 自定义处理省略号(由于 ECharts 不直接支持,需手动处理)
  143. // 此处简单判断,若原长度超过 10(即 'YYYY-MM-DD' 格式),则添加省略号
  144. if (value.length > 10) {
  145. shortenedValue = '...' + shortenedValue;
  146. }
  147. return shortenedValue;
  148. }
  149. },
  150. axisLine: {
  151. lineStyle: {
  152. color: "#333333",
  153. }
  154. },
  155. data: ['9/1', '9/7', '9/13', '9/19', '9/25', '10/1', '10/7']
  156. },
  157. yAxis: [{
  158. type: 'value',
  159. offset: 6,
  160. axisTick: {
  161. show: false,
  162. },
  163. axisLine: {
  164. show: false,
  165. },
  166. axisLabel: {
  167. align: "center",
  168. textStyle: {
  169. color: "#999999",
  170. fontSize: 12
  171. },
  172. },
  173. // 分割线
  174. splitLine: {
  175. lineStyle: {
  176. type: [4, 3],
  177. dashOffset: 5,
  178. color: "#333333",
  179. },
  180. },
  181. // min: 0, // 最小值固定为0
  182. // max: 100, // 最大值固定为100
  183. // splitNumber: 5, // 设置5个分割段
  184. }],
  185. series: [
  186. {
  187. name: "病虫异常",
  188. data: [40, 28, 22, 64, 28, 24, 40],
  189. type: 'line',
  190. smooth: true,
  191. symbol: "none",
  192. itemStyle: { color: "#FF7219" },
  193. lineStyle: {
  194. color: "#FF7219", // 折线颜色为红色
  195. width: 2, // 线条宽度
  196. },
  197. },
  198. {
  199. name: "生长异常",
  200. data: [80, 88, 92, 84, 88, 74, 80],
  201. type: 'line',
  202. symbol: "none",
  203. smooth: true,
  204. itemStyle: { color: "#FFB82E" },
  205. lineStyle: {
  206. color: "#FFB82E", // 折线颜色为红色
  207. width: 2, // 线条宽度
  208. },
  209. },
  210. {
  211. name: "褪绿率",
  212. data: [
  213. ["9/1", 10],
  214. ["9/7", 30],
  215. ["9/13", 80],
  216. ],
  217. type: 'line',
  218. smooth: true,
  219. symbol: "none",
  220. itemStyle: { color: "#66B9FB" },
  221. lineStyle: {
  222. color: "#66B9FB", // 折线颜色为红色
  223. width: 2, // 线条宽度
  224. },
  225. },
  226. {
  227. name: "花芽率",
  228. data: [
  229. ["9/7", 8],
  230. ["9/19", 50],
  231. ["9/25", 80],
  232. ],
  233. type: 'line',
  234. smooth: true,
  235. symbol: "none",
  236. itemStyle: { color: "#1B98FC" },
  237. lineStyle: {
  238. color: "#1B98FC", // 折线颜色为红色
  239. width: 2, // 线条宽度
  240. },
  241. },
  242. {
  243. name: "花蕾率",
  244. data: [
  245. ["9/19", 12],
  246. ["9/25", 30],
  247. ["10/1", 60],
  248. ["10/7", 70],
  249. ],
  250. type: 'line',
  251. smooth: true,
  252. symbol: "none",
  253. itemStyle: { color: "#036CC0" },
  254. lineStyle: {
  255. color: "#036CC0", // 折线颜色为红色
  256. width: 2, // 线条宽度
  257. },
  258. },
  259. ],
  260. }