chart-weatherTrends.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <!-- **************************************NO.9 散养户、养殖场养殖种类*************************************** -->
  2. <template>
  3. <div class="chart-container">
  4. <div id="farmtype" style="width: 100%; height:24vh;">
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import * as echarts from 'echarts';
  10. export default {
  11. name: 'farmtype',
  12. data() {
  13. return {
  14. count: 0
  15. }
  16. },
  17. mounted() {
  18. this.myEcharts()
  19. },
  20. methods: {
  21. // 出处 http://192.144.199.210:8080/editor/index.html?chart_id=smh2KYnoCMWnT1IN
  22. myEcharts() {
  23. var chartDom = document.getElementById('farmtype');
  24. var myChart = echarts.init(chartDom);
  25. var xData = ['2022年1月','2022年2月','2022年3月','2022年4月','2022年5月','2022年6月','2022年7月','2022年8月','2022年9月','2022年10月','2022年11月','2022年12月'];
  26. var option;
  27. option = {
  28. backgroundColor:'#232d36',
  29. tooltip: {
  30. trigger: 'axis',
  31. axisPointer: {
  32. lineStyle: {
  33. color: {
  34. type: 'linear',
  35. x: 0,
  36. y: 0,
  37. x2: 0,
  38. y2: 1,
  39. colorStops: [{
  40. offset: 0,
  41. color: 'rgba(0, 255, 233,0)'
  42. }, {
  43. offset: 0.5,
  44. color: 'rgba(255, 255, 255,1)',
  45. }, {
  46. offset: 1,
  47. color: 'rgba(0, 255, 233,0)'
  48. }],
  49. global: false
  50. }
  51. },
  52. },
  53. },
  54. grid: {
  55. top: '15%',
  56. left: '10%',
  57. right: '5%',
  58. bottom: '15%',
  59. },
  60. legend:{
  61. data:['最高气温','最低气温'],
  62. textStyle:{
  63. color:'#fff',
  64. align: 'center',
  65. fontSize: 16
  66. },
  67. x:'center'
  68. },
  69. xAxis: [{
  70. type: 'category',
  71. // 轴线
  72. axisLine: {
  73. show: true,
  74. lineStyle:{
  75. color: '#85B1B4',
  76. }
  77. },
  78. // 轴刻度线
  79. axisTick:{
  80. show:false,
  81. },
  82. // 坐标轴名称
  83. axisLabel: {
  84. color: '#fff',
  85. margin:6,
  86. },
  87. // 轴分隔线
  88. splitLine: {
  89. show: false
  90. },
  91. // 轴两侧留白
  92. boundaryGap: ['5%','5%'],
  93. data: xData
  94. }],
  95. yAxis: [{
  96. type: 'value',
  97. min: 0,
  98. // max: 140,
  99. splitNumber: 4,
  100. splitLine: {
  101. show: false,
  102. },
  103. axisLine: {
  104. show: true,
  105. lineStyle:{
  106. color: '#85B1B4'
  107. }
  108. },
  109. axisLabel: {
  110. show: true,
  111. margin: 10,
  112. textStyle: {
  113. color: '#fff',
  114. },
  115. },
  116. axisTick: {
  117. show: false,
  118. },
  119. }],
  120. series: [
  121. {
  122. name:'最高气温',
  123. type: 'line',
  124. showAllSymbol: true,
  125. symbol: 'circle',
  126. symbolSize: 4,
  127. lineStyle: {
  128. normal: {
  129. color: "#FF8736",
  130. },
  131. },
  132. label: {
  133. show: false,
  134. },
  135. itemStyle: {
  136. color: "#FF8736",
  137. borderColor: "#FF8736",
  138. borderWidth: 2,
  139. },
  140. // areaStyle: {
  141. // normal: {
  142. // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  143. // {
  144. // offset: 0,
  145. // color: 'rgba(43,193,145,0.3)'
  146. // },
  147. // {
  148. // offset: 1,
  149. // color: 'rgba(43,193,145,0)'
  150. // }
  151. // ], false),
  152. // }
  153. // },
  154. data: [4,7,8,12,15,23,24,24,25,28,27,24,21,23]//data.values
  155. },
  156. {
  157. name:'最低气温',
  158. type: 'line',
  159. showAllSymbol: true,
  160. symbol: 'circle',
  161. symbolSize:4,
  162. lineStyle: {
  163. normal: {
  164. color: "#13EFB7",
  165. },
  166. },
  167. label: {
  168. show: false,
  169. },
  170. itemStyle: {
  171. color: "#13EFB7",
  172. borderColor: "#13EFB7",
  173. borderWidth: 2,
  174. },
  175. areaStyle: {
  176. normal: {
  177. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  178. {
  179. offset: 0,
  180. color: 'rgba(81,150,164,0.3)'
  181. },
  182. {
  183. offset: 1,
  184. color: 'rgba(81,150,164,0)'
  185. }
  186. ], false),
  187. }
  188. },
  189. data: [3,5,4,2,1,7,6,3,4,5,6,7,1,2]//data.values
  190. },
  191. ]
  192. };
  193. option && myChart.setOption(option);
  194. },
  195. },
  196. }
  197. </script>
  198. <style rel="stylesheet/scss" lang="scss" scoped>
  199. .chart-container {
  200. width: 100%;
  201. height: auto;
  202. position: relative;
  203. padding-bottom: 10px;
  204. display: flex;
  205. }
  206. </style>