SoilMoisture.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <!-- <template>
  2. <div style="display: inline-block;float:right ;height: 190rem;width: 340rem;">
  3. <jt-echarts style="width: 100%;height: 100%;margin-top:20rem" :chartData="option"></jt-echarts>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. option: {}
  11. }
  12. },
  13. created() {},
  14. mounted() {
  15. this.typeCharts()
  16. let _this = this
  17. var t1=setTimeout(function() {
  18. _this.option.series = [{
  19. data: [200, 600, 219, 264, 500, 340, 250]
  20. },
  21. {
  22. data: [320, 400, 201, 334, 190, 350, 220]
  23. },
  24. {
  25. data: [120, 400, 350, 500, 220, 340, 310]
  26. },
  27. {
  28. data: [220, 402, 231, 134, 190, 230, 120]
  29. },
  30. {
  31. data: [220, 302, 181, 234, 210, 290, 150]
  32. },
  33. ]
  34. }, 1000);
  35. },
  36. methods: {
  37. typeCharts() {
  38. this.option = this.getOption();
  39. // var chartDom = document.getElementById('echarts');
  40. // var myChart = echarts.init(chartDom);
  41. // myChart.setOption(option, true);
  42. },
  43. getOption(data) {
  44. let option = {
  45. color: ['#39e07f', '#1581ff', '#2ed0e7', '#ff9a9a', '#ffad31'],
  46. /* title: {
  47. text: 'Gradient Stacked Area Chart'
  48. }, */
  49. tooltip: {
  50. trigger: 'axis',
  51. axisPointer: {
  52. type: 'cross',
  53. label: {
  54. backgroundColor: '#6a7985'
  55. }
  56. }
  57. },
  58. legend: {
  59. data: ['土壤温度(℃)', '土壤湿度(%RH)', '土壤PH', '土壤水势(kpa)', '电导率(us/cm)'],
  60. // 图例
  61. textStyle: {
  62. color: 'rgb(200,255,255)' //字体颜色
  63. },
  64. padding: 0,
  65. },
  66. toolbox: {
  67. },
  68. grid: {
  69. left: '3%',
  70. right: '4%',
  71. bottom: '3%',
  72. containLabel: true
  73. },
  74. xAxis: [{
  75. type: 'category',
  76. boundaryGap: false,
  77. axisLabel: {
  78. formatter: "{value}",
  79. color: "#e2e9ff",
  80. },
  81. axisLine: {
  82. lineStyle: {
  83. color: "lightgray",
  84. width: 1
  85. }
  86. },
  87. data: ['1:00', '5:00', '9:00', '13:00', '17:00', '21:00', '24:00']
  88. },
  89. ],
  90. yAxis: [{
  91. type: 'value',
  92. splitLine: {
  93. lineStyle: {
  94. color: "rgba(255,255,255,0.12)",
  95. },
  96. },
  97. axisLabel: {
  98. formatter: "{value}",
  99. color: "#e2e9ff",
  100. },
  101. axisLine: {
  102. show: true,
  103. lineStyle: {
  104. color: "lightgray",
  105. width: 1
  106. }
  107. },
  108. axisTick: {
  109. show: true
  110. }, //隐藏纵坐标刻度小线条
  111. }],
  112. series: [{
  113. name: '土壤温度(℃)',
  114. type: 'line',
  115. smooth: true,
  116. lineStyle: {
  117. width: 2
  118. },
  119. lable: {
  120. show: true,
  121. position: 'top'
  122. },
  123. showSymbol: false,
  124. areaStyle: {
  125. opacity: 0.4,
  126. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  127. offset: 0,
  128. color: 'rgb(128, 255, 165)'
  129. },
  130. {
  131. offset: 1,
  132. color: 'rgb(1, 191, 236)'
  133. }
  134. ])
  135. },
  136. emphasis: {
  137. focus: 'series'
  138. },
  139. data: [200, 2000, 219, 264, 500, 340, 250]
  140. },
  141. {
  142. name: '土壤湿度(%RH)',
  143. type: 'line',
  144. smooth: true,
  145. lineStyle: {
  146. width: 2
  147. },
  148. lable: {
  149. show: true,
  150. position: 'top'
  151. },
  152. showSymbol: false,
  153. areaStyle: {
  154. opacity: 0.4,
  155. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  156. offset: 0,
  157. color: 'rgb(0, 221, 255)'
  158. },
  159. {
  160. offset: 1,
  161. color: 'rgb(77, 119, 255)'
  162. }
  163. ])
  164. },
  165. emphasis: {
  166. focus: 'series'
  167. },
  168. data: [120, 400, 350, 500, 220, 340, 310]
  169. },
  170. {
  171. name: '土壤水势(kpa)',
  172. type: 'line',
  173. smooth: true,
  174. lable: {
  175. show: true,
  176. position: 'top'
  177. },
  178. lineStyle: {
  179. width: 2
  180. },
  181. showSymbol: false,
  182. areaStyle: {
  183. opacity: 0.4,
  184. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  185. offset: 0,
  186. color: 'rgb(55, 162, 255)'
  187. },
  188. {
  189. offset: 1,
  190. color: 'rgb(116, 21, 219)'
  191. }
  192. ])
  193. },
  194. emphasis: {
  195. focus: 'series'
  196. },
  197. data: [320, 400, 201, 334, 190, 350, 220]
  198. },
  199. {
  200. name: '土壤PH',
  201. type: 'line',
  202. smooth: true,
  203. lable: {
  204. show: true,
  205. position: 'top'
  206. },
  207. lineStyle: {
  208. width: 2
  209. },
  210. showSymbol: false,
  211. areaStyle: {
  212. opacity: 0.4,
  213. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  214. offset: 0,
  215. color: '#ff9a9a'
  216. },
  217. {
  218. offset: 1,
  219. color: '#ff9a9a'
  220. }
  221. ])
  222. },
  223. emphasis: {
  224. focus: 'series'
  225. },
  226. data: [220, 402, 231, 134, 190, 230, 120]
  227. },
  228. {
  229. name: '电导率(us/cm)',
  230. type: 'line',
  231. lable: {
  232. show: true,
  233. position: 'top'
  234. },
  235. smooth: true,
  236. lineStyle: {
  237. width: 2
  238. },
  239. showSymbol: false,
  240. label: {
  241. show: true,
  242. position: 'top'
  243. },
  244. areaStyle: {
  245. opacity: 0.4,
  246. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  247. offset: 0,
  248. color: 'rgb(255, 191, 0)'
  249. },
  250. {
  251. offset: 1,
  252. color: 'rgb(255, 191, 0)'
  253. }
  254. ])
  255. },
  256. emphasis: {
  257. focus: 'series'
  258. },
  259. data: [220, 302, 181, 234, 210, 290, 150]
  260. }
  261. ]
  262. };
  263. return option;
  264. }
  265. },
  266. }
  267. </script>
  268. <style>
  269. </style> -->
  270. <template>
  271. <div id="mains" style="height: 200rem;width: 320rem;margin-top:20rem;margin-left: 30rem;"></div>
  272. </template>
  273. <script>
  274. export default {
  275. data() {
  276. return {
  277. }
  278. },
  279. mounted() {
  280. var chartDom = document.getElementById('mains');
  281. var myChart = this.$echarts.init(chartDom);
  282. let option = {
  283. color: ['#39e07f', '#1581ff', '#2ed0e7', '#ff9a9a', '#ffad31'],
  284. /* title: {
  285. text: 'Gradient Stacked Area Chart'
  286. }, */
  287. tooltip: {
  288. trigger: 'axis',
  289. backgroundColor: "rgba(255,255,255,0.6)",
  290. borderColor: "rgba(255,255,255,0.6)", //设置边框颜色
  291. textStyle: {
  292. color: "rgba(0,0,0,0.8)" //设置文字颜色
  293. },
  294. axisPointer: {
  295. type: 'cross',
  296. label: {
  297. backgroundColor: '#6a7985'
  298. }
  299. }
  300. },
  301. legend: {
  302. data: ['土壤温度(℃)', '土壤湿度(%RH)', '土壤PH', '土壤水势(kpa)', '电导率(us/cm)'],
  303. // 图例
  304. textStyle: {
  305. color: 'rgb(200,255,255)' //字体颜色
  306. },
  307. padding: 0,
  308. },
  309. toolbox: {
  310. },
  311. grid: {
  312. left: '3%',
  313. right: '4%',
  314. bottom: '3%',
  315. containLabel: true
  316. },
  317. xAxis: [{
  318. type: 'category',
  319. boundaryGap: false,
  320. axisLabel: {
  321. formatter: "{value}",
  322. color: "#e2e9ff",
  323. },
  324. axisLine: {
  325. lineStyle: {
  326. color: "lightgray",
  327. width: 1
  328. }
  329. },
  330. data: ['1:00', '5:00', '9:00', '13:00', '17:00', '21:00', '24:00']
  331. },
  332. ],
  333. yAxis: [{
  334. type: 'value',
  335. splitLine: {
  336. lineStyle: {
  337. color: "rgba(255,255,255,0.12)",
  338. },
  339. },
  340. axisLabel: {
  341. show:false
  342. },
  343. axisLine: {
  344. show: true,
  345. lineStyle: {
  346. color: "lightgray",
  347. width: 1
  348. }
  349. },
  350. axisTick: {
  351. show: true
  352. }, //隐藏纵坐标刻度小线条
  353. }],
  354. series: [{
  355. name: '土壤温度(℃)',
  356. type: 'line',
  357. smooth: true,
  358. lineStyle: {
  359. width: 2
  360. },
  361. lable: {
  362. show: true,
  363. position: 'top'
  364. },
  365. showSymbol: false,
  366. areaStyle: {
  367. opacity: 0.4,
  368. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  369. offset: 0,
  370. color: 'rgb(128, 255, 165)'
  371. },
  372. {
  373. offset: 1,
  374. color: 'rgb(1, 191, 236)'
  375. }
  376. ])
  377. },
  378. emphasis: {
  379. focus: 'series'
  380. },
  381. data: [200, 600, 219, 264, 500, 340, 250]
  382. },
  383. {
  384. name: '土壤湿度(%RH)',
  385. type: 'line',
  386. smooth: true,
  387. lineStyle: {
  388. width: 2
  389. },
  390. lable: {
  391. show: true,
  392. position: 'top'
  393. },
  394. showSymbol: false,
  395. areaStyle: {
  396. opacity: 0.4,
  397. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  398. offset: 0,
  399. color: 'rgb(0, 221, 255)'
  400. },
  401. {
  402. offset: 1,
  403. color: 'rgb(77, 119, 255)'
  404. }
  405. ])
  406. },
  407. emphasis: {
  408. focus: 'series'
  409. },
  410. data: [120, 400, 350, 500, 220, 340, 310]
  411. },
  412. {
  413. name: '土壤水势(kpa)',
  414. type: 'line',
  415. smooth: true,
  416. lable: {
  417. show: true,
  418. position: 'top'
  419. },
  420. lineStyle: {
  421. width: 2
  422. },
  423. showSymbol: false,
  424. areaStyle: {
  425. opacity: 0.4,
  426. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  427. offset: 0,
  428. color: 'rgb(55, 162, 255)'
  429. },
  430. {
  431. offset: 1,
  432. color: 'rgb(116, 21, 219)'
  433. }
  434. ])
  435. },
  436. emphasis: {
  437. focus: 'series'
  438. },
  439. data: [220, 402, 231, 134, 190, 230, 120]
  440. },
  441. {
  442. name: '土壤PH',
  443. type: 'line',
  444. smooth: true,
  445. lable: {
  446. show: true,
  447. position: 'top'
  448. },
  449. lineStyle: {
  450. width: 2
  451. },
  452. showSymbol: false,
  453. areaStyle: {
  454. opacity: 0.4,
  455. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  456. offset: 0,
  457. color: '#ff9a9a'
  458. },
  459. {
  460. offset: 1,
  461. color: '#ff9a9a'
  462. }
  463. ])
  464. },
  465. emphasis: {
  466. focus: 'series'
  467. },
  468. data: [220, 302, 181, 234, 210, 290, 150]
  469. },
  470. {
  471. name: '电导率(us/cm)',
  472. type: 'line',
  473. lable: {
  474. show: true,
  475. position: 'top'
  476. },
  477. smooth: true,
  478. lineStyle: {
  479. width: 2
  480. },
  481. showSymbol: false,
  482. label: {
  483. show: true,
  484. position: 'top'
  485. },
  486. areaStyle: {
  487. opacity: 0.4,
  488. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  489. offset: 0,
  490. color: 'rgb(255, 191, 0)'
  491. },
  492. {
  493. offset: 1,
  494. color: 'rgb(255, 191, 0)'
  495. }
  496. ])
  497. },
  498. emphasis: {
  499. focus: 'series'
  500. },
  501. data: [220, 302, 181, 234, 210, 290, 150]
  502. }
  503. ]
  504. }
  505. myChart.setOption(option);
  506. }
  507. }
  508. </script>
  509. <style scoped>
  510. .mains {
  511. width: 100%;
  512. height: 220rem;
  513. margin-top: 15rem;
  514. }
  515. </style>