SoilMoisture.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div style="display: inline-block;float:right ;height: 190rem;width: 350rem;">
  3. <jt-echarts style="width: 100%;height: 100%;margin-top:20rem" :chartData="option"></jt-echarts>
  4. </div>
  5. </template>
  6. <script>
  7. // import echarts from 'echarts' 这种方式高版本不支持
  8. import * as echarts from 'echarts'
  9. export default {
  10. data() {
  11. return {
  12. option: {}
  13. }
  14. },
  15. created() {},
  16. mounted() {
  17. this.typeCharts()
  18. let _this = this
  19. var t1=setTimeout(function() {
  20. _this.option.series = [{
  21. data: [200, 600, 219, 264, 500, 340, 250]
  22. },
  23. {
  24. data: [320, 400, 201, 334, 190, 350, 220]
  25. },
  26. {
  27. data: [120, 400, 350, 500, 220, 340, 310]
  28. },
  29. {
  30. data: [220, 402, 231, 134, 190, 230, 120]
  31. },
  32. {
  33. data: [220, 302, 181, 234, 210, 290, 150]
  34. },
  35. ]
  36. }, 1000);
  37. },
  38. methods: {
  39. typeCharts() {
  40. this.option = this.getOption();
  41. // var chartDom = document.getElementById('echarts');
  42. // var myChart = echarts.init(chartDom);
  43. // myChart.setOption(option, true);
  44. },
  45. getOption(data) {
  46. let option = {
  47. color: ['#39e07f', '#1581ff', '#2ed0e7', '#ff9a9a', '#ffad31'],
  48. /* title: {
  49. text: 'Gradient Stacked Area Chart'
  50. }, */
  51. tooltip: {
  52. trigger: 'axis',
  53. axisPointer: {
  54. type: 'cross',
  55. label: {
  56. backgroundColor: '#6a7985'
  57. }
  58. }
  59. },
  60. legend: {
  61. data: ['土壤温度(℃)', '土壤湿度(%RH)', '土壤PH', '土壤水势(kpa)', '电导率(us/cm)'],
  62. // 图例
  63. textStyle: {
  64. color: 'rgb(200,255,255)' //字体颜色
  65. },
  66. padding: 0,
  67. },
  68. toolbox: {
  69. },
  70. grid: {
  71. left: '3%',
  72. right: '4%',
  73. bottom: '3%',
  74. containLabel: true
  75. },
  76. xAxis: [{
  77. type: 'category',
  78. boundaryGap: false,
  79. axisLabel: {
  80. formatter: "{value}",
  81. color: "#e2e9ff",
  82. },
  83. data: ['1:00', '5:00', '9:00', '13:00', '17:00', '21:00', '24:00']
  84. },
  85. ],
  86. yAxis: [{
  87. type: 'value',
  88. splitLine: {
  89. lineStyle: {
  90. color: "rgba(255,255,255,0.12)",
  91. },
  92. },
  93. axisLabel: {
  94. formatter: "{value}",
  95. color: "#e2e9ff",
  96. },
  97. }],
  98. series: [{
  99. name: '土壤温度(℃)',
  100. type: 'line',
  101. smooth: true,
  102. lineStyle: {
  103. width: 2
  104. },
  105. lable: {
  106. show: true,
  107. position: 'top'
  108. },
  109. showSymbol: false,
  110. areaStyle: {
  111. opacity: 0.4,
  112. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  113. offset: 0,
  114. color: 'rgb(128, 255, 165)'
  115. },
  116. {
  117. offset: 1,
  118. color: 'rgb(1, 191, 236)'
  119. }
  120. ])
  121. },
  122. emphasis: {
  123. focus: 'series'
  124. },
  125. data: [200, 2000, 219, 264, 500, 340, 250]
  126. },
  127. {
  128. name: '土壤湿度(%RH)',
  129. type: 'line',
  130. smooth: true,
  131. lineStyle: {
  132. width: 2
  133. },
  134. lable: {
  135. show: true,
  136. position: 'top'
  137. },
  138. showSymbol: false,
  139. areaStyle: {
  140. opacity: 0.4,
  141. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  142. offset: 0,
  143. color: 'rgb(0, 221, 255)'
  144. },
  145. {
  146. offset: 1,
  147. color: 'rgb(77, 119, 255)'
  148. }
  149. ])
  150. },
  151. emphasis: {
  152. focus: 'series'
  153. },
  154. data: [120, 400, 350, 500, 220, 340, 310]
  155. },
  156. {
  157. name: '土壤水势(kpa)',
  158. type: 'line',
  159. smooth: true,
  160. lable: {
  161. show: true,
  162. position: 'top'
  163. },
  164. lineStyle: {
  165. width: 2
  166. },
  167. showSymbol: false,
  168. areaStyle: {
  169. opacity: 0.4,
  170. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  171. offset: 0,
  172. color: 'rgb(55, 162, 255)'
  173. },
  174. {
  175. offset: 1,
  176. color: 'rgb(116, 21, 219)'
  177. }
  178. ])
  179. },
  180. emphasis: {
  181. focus: 'series'
  182. },
  183. data: [320, 400, 201, 334, 190, 350, 220]
  184. },
  185. {
  186. name: '土壤PH',
  187. type: 'line',
  188. smooth: true,
  189. lable: {
  190. show: true,
  191. position: 'top'
  192. },
  193. lineStyle: {
  194. width: 2
  195. },
  196. showSymbol: false,
  197. areaStyle: {
  198. opacity: 0.4,
  199. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  200. offset: 0,
  201. color: '#ff9a9a'
  202. },
  203. {
  204. offset: 1,
  205. color: '#ff9a9a'
  206. }
  207. ])
  208. },
  209. emphasis: {
  210. focus: 'series'
  211. },
  212. data: [220, 402, 231, 134, 190, 230, 120]
  213. },
  214. {
  215. name: '电导率(us/cm)',
  216. type: 'line',
  217. lable: {
  218. show: true,
  219. position: 'top'
  220. },
  221. smooth: true,
  222. lineStyle: {
  223. width: 2
  224. },
  225. showSymbol: false,
  226. label: {
  227. show: true,
  228. position: 'top'
  229. },
  230. areaStyle: {
  231. opacity: 0.4,
  232. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  233. offset: 0,
  234. color: 'rgb(255, 191, 0)'
  235. },
  236. {
  237. offset: 1,
  238. color: 'rgb(255, 191, 0)'
  239. }
  240. ])
  241. },
  242. emphasis: {
  243. focus: 'series'
  244. },
  245. data: [220, 302, 181, 234, 210, 290, 150]
  246. }
  247. ]
  248. };
  249. return option;
  250. }
  251. },
  252. }
  253. </script>
  254. <style>
  255. </style>