SoilMoisture.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div style="display: inline-block;float:left ;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. data: ['1:00', '5:00', '9:00', '13:00', '17:00', '21:00', '24:00']
  80. },
  81. ],
  82. yAxis: [{
  83. type: 'value'
  84. }],
  85. series: [{
  86. name: '土壤温度(℃)',
  87. type: 'line',
  88. smooth: true,
  89. lineStyle: {
  90. width: 2
  91. },
  92. lable: {
  93. show: true,
  94. position: 'top'
  95. },
  96. showSymbol: false,
  97. areaStyle: {
  98. opacity: 0.4,
  99. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  100. offset: 0,
  101. color: 'rgb(128, 255, 165)'
  102. },
  103. {
  104. offset: 1,
  105. color: 'rgb(1, 191, 236)'
  106. }
  107. ])
  108. },
  109. emphasis: {
  110. focus: 'series'
  111. },
  112. data: [200, 2000, 219, 264, 500, 340, 250]
  113. },
  114. {
  115. name: '土壤湿度(%RH)',
  116. type: 'line',
  117. smooth: true,
  118. lineStyle: {
  119. width: 2
  120. },
  121. lable: {
  122. show: true,
  123. position: 'top'
  124. },
  125. showSymbol: false,
  126. areaStyle: {
  127. opacity: 0.4,
  128. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  129. offset: 0,
  130. color: 'rgb(0, 221, 255)'
  131. },
  132. {
  133. offset: 1,
  134. color: 'rgb(77, 119, 255)'
  135. }
  136. ])
  137. },
  138. emphasis: {
  139. focus: 'series'
  140. },
  141. data: [120, 400, 350, 500, 220, 340, 310]
  142. },
  143. {
  144. name: '土壤水势(kpa)',
  145. type: 'line',
  146. smooth: true,
  147. lable: {
  148. show: true,
  149. position: 'top'
  150. },
  151. lineStyle: {
  152. width: 2
  153. },
  154. showSymbol: false,
  155. areaStyle: {
  156. opacity: 0.4,
  157. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  158. offset: 0,
  159. color: 'rgb(55, 162, 255)'
  160. },
  161. {
  162. offset: 1,
  163. color: 'rgb(116, 21, 219)'
  164. }
  165. ])
  166. },
  167. emphasis: {
  168. focus: 'series'
  169. },
  170. data: [320, 400, 201, 334, 190, 350, 220]
  171. },
  172. {
  173. name: '土壤PH',
  174. type: 'line',
  175. smooth: true,
  176. lable: {
  177. show: true,
  178. position: 'top'
  179. },
  180. lineStyle: {
  181. width: 2
  182. },
  183. showSymbol: false,
  184. areaStyle: {
  185. opacity: 0.4,
  186. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  187. offset: 0,
  188. color: '#ff9a9a'
  189. },
  190. {
  191. offset: 1,
  192. color: '#ff9a9a'
  193. }
  194. ])
  195. },
  196. emphasis: {
  197. focus: 'series'
  198. },
  199. data: [220, 402, 231, 134, 190, 230, 120]
  200. },
  201. {
  202. name: '电导率(us/cm)',
  203. type: 'line',
  204. lable: {
  205. show: true,
  206. position: 'top'
  207. },
  208. smooth: true,
  209. lineStyle: {
  210. width: 2
  211. },
  212. showSymbol: false,
  213. label: {
  214. show: true,
  215. position: 'top'
  216. },
  217. areaStyle: {
  218. opacity: 0.4,
  219. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  220. offset: 0,
  221. color: 'rgb(255, 191, 0)'
  222. },
  223. {
  224. offset: 1,
  225. color: 'rgb(255, 191, 0)'
  226. }
  227. ])
  228. },
  229. emphasis: {
  230. focus: 'series'
  231. },
  232. data: [220, 302, 181, 234, 210, 290, 150]
  233. }
  234. ]
  235. };
  236. return option;
  237. }
  238. },
  239. }
  240. </script>
  241. <style>
  242. </style>