index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template >
  2. <div class="lsyj">
  3. <div class="title">历史预警趋势</div>
  4. <div class="lsyj-right">
  5. <div class="right-top">
  6. <div style="font-size: 14px">最高温度:{{maxTemp}}</div>
  7. <div style="font-size: 14px">最低温度:{{minTemp}}</div>
  8. </div>
  9. <div class="right-bottom" style="height: calc(100% - 30px)">
  10. <div id="lsyjCharts" style="height: 100%"></div>
  11. </div>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import * as echarts from "echarts";
  17. import api from "@/api";
  18. export default {
  19. data(){
  20. return{
  21. lsyjData:[],
  22. maxTemp:null,
  23. minTemp:null,
  24. }
  25. },
  26. methods:{
  27. //历史月趋势
  28. getHisWarning() {
  29. let params = {
  30. labelCode: "307038864601222",
  31. orgCode: localStorage.getItem("orgCode"),
  32. round: 2,
  33. };
  34. api.hisWarning(params).then((res) => {
  35. console.log(res, "月趋势");
  36. if(res.code==200){
  37. this.lsyjData=res.data.avgTemp
  38. this.maxTemp=res.data.maxTemp
  39. this.minTemp=res.data.minTemp
  40. this.drawLsyj()
  41. }
  42. });
  43. },
  44. // 历史预警
  45. drawLsyj() {
  46. var myChart2 = this.$echarts.init(document.getElementById("lsyjCharts"));
  47. myChart2.setOption({
  48. title: {
  49. text: "",
  50. },
  51. tooltip: {
  52. trigger: "axis",
  53. axisPointer: {
  54. type: "cross",
  55. label: {
  56. backgroundColor: "#6a7985",
  57. },
  58. },
  59. },
  60. // legend: {
  61. // data: ['温度', '湿度'],
  62. // left:'middle',
  63. // top:"6%",
  64. // textStyle:{
  65. // color:'#fff'
  66. // }
  67. // },
  68. toolbox: {
  69. // feature: {
  70. // saveAsImage: {}
  71. // }
  72. },
  73. grid: {
  74. left: "3%",
  75. right: "4%",
  76. bottom: "3%",
  77. top: "7%",
  78. containLabel: true,
  79. },
  80. xAxis: [
  81. {
  82. name: "月",
  83. nameTextStyle: {
  84. //关键代码
  85. padding: [50, 0, 10, -13],
  86. },
  87. type: "category",
  88. // boundaryGap: false,
  89. data: [
  90. "1",
  91. "2",
  92. "3",
  93. "4",
  94. "5",
  95. "6",
  96. "7",
  97. "8",
  98. "9",
  99. "10",
  100. "11",
  101. "12",
  102. ],
  103. axisLabel: {
  104. color: "white",
  105. },
  106. },
  107. ],
  108. yAxis: [
  109. {
  110. type: "value",
  111. axisLabel: {
  112. color: "white",
  113. },
  114. splitLine: {
  115. lineStyle: {
  116. color: "#011F13",
  117. },
  118. },
  119. },
  120. ],
  121. series: [
  122. {
  123. name: "温度",
  124. itemStyle: {
  125. normal: {
  126. // barBorderRadius: [10, 10, 0, 0],
  127. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
  128. { offset: 0, color: "#00ffa7" },
  129. { offset: 1, color: "#00caae" },
  130. ]),
  131. },
  132. },
  133. type: "bar",
  134. smooth: true,
  135. lineStyle: {
  136. color: "#2496ef",
  137. },
  138. stack: "Total",
  139. areaStyle: {
  140. opacity: 0.3,
  141. },
  142. emphasis: {
  143. focus: "series",
  144. },
  145. data: this.lsyjData,
  146. },
  147. ],
  148. });
  149. window.addEventListener("resize", () => {
  150. setTimeout(() => {
  151. myChart2.resize();
  152. }, 1000);
  153. });
  154. }
  155. },
  156. created(){
  157. this.getHisWarning()
  158. }
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. .lsyj{
  163. height: 100%;
  164. width: 21%;
  165. background: url("../../../../assets/images/bigScreen/tempBorder.png")
  166. no-repeat;
  167. background-size: 100% 100%;
  168. .title {
  169. height: 37px;
  170. line-height: 37px;
  171. margin-left: 10px;
  172. color: #fff;
  173. font-weight: 600;
  174. }
  175. }
  176. .lsyj {
  177. .lsyj-right {
  178. height: calc(100% - 37px);
  179. .right-top {
  180. height: 30px;
  181. display: flex;
  182. justify-content: space-around;
  183. align-items: center;
  184. color: #fff;
  185. }
  186. }
  187. }
  188. </style>