FullCurve.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <div class="data-curve-module">
  3. <common-title title="全程曲线"></common-title>
  4. <!-- <div style="height: 22.5px;"></div> -->
  5. <div class="visualization-common-border">
  6. <div ref="dataCurve" class="h100"></div>
  7. </div>
  8. </div>
  9. </template>
  10. <script>
  11. import * as echarts from "echarts"
  12. import commonTitle from '../components/commonTitle.vue'
  13. import { setMax } from "../components/common.js";
  14. export default {
  15. components: { commonTitle },
  16. name: '',
  17. props: {
  18. data: {
  19. type: Array,
  20. default: function(){
  21. return [] // 使用工厂函数返回默认值
  22. }
  23. }
  24. },
  25. data () {
  26. return {
  27. uEcharts: null,
  28. uOption: null,
  29. legendData: [
  30. { name: '辐射强度值', value: 9000 },
  31. { name: '温度实值', value: 50 },
  32. { name: '湿度实值', value: 60.3 },
  33. ],
  34. fusheData: [],
  35. wenduData: [],
  36. shiduData: [],
  37. timeData: [],
  38. // fusheData: [150, 230, 224, 218, 135, 147, 260],
  39. // wenduData: [120, 132, 101, 134, 90, 230, 210],
  40. // shiduData: [220, 182, 191, 234, 290, 330, 310],
  41. // timeData: ['8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00']
  42. }
  43. },
  44. watch: {
  45. data: {
  46. handler(newValue, oldValue){
  47. console.log('全程曲线', newValue, oldValue)
  48. this.refreshData(newValue)
  49. },
  50. // immediate: true,
  51. deep: true
  52. }
  53. },
  54. created () {
  55. },
  56. mounted () {
  57. this.$nextTick(() => {
  58. this.initDataCurve()
  59. })
  60. },
  61. methods: {
  62. initDataCurve(){
  63. var _this = this
  64. var maxa = Math.max.apply(null, this.fusheData)
  65. var maxb = Math.max.apply(null, [...this.wenduData, ...this.shiduData])
  66. this.uEcharts = echarts.init(this.$refs.dataCurve);
  67. this.uOption = {
  68. color: ['#07D626', '#E30106', '#E39106'], // legend对应颜色
  69. grid: {
  70. top: '80',
  71. left: '46',
  72. bottom: '45'
  73. },
  74. tooltip: {
  75. trigger: 'axis',
  76. },
  77. // dataZoom: [
  78. // {
  79. // type: 'inside',
  80. // start: 0,
  81. // end: 100,
  82. // },
  83. // {
  84. // start: 0,
  85. // end: 100,
  86. // height: 10,
  87. // bottom: 16,
  88. // }
  89. // ],
  90. dataZoom: [
  91. {
  92. show: true,
  93. moveHandleSize: 0, // 隐藏上面那那层
  94. height: 12,
  95. xAxisIndex: [
  96. 0
  97. ],
  98. bottom: 12,
  99. start: 0,
  100. end: 100,
  101. handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
  102. handleSize: '110%',
  103. handleStyle:{
  104. color:"#d3dee5",
  105. },
  106. textStyle:{ color:"#fff" },
  107. borderColor:"#90979c"
  108. }, {
  109. type: "inside",
  110. show: true,
  111. height: 15,
  112. start: 0,
  113. end: 100
  114. }
  115. ],
  116. xAxis: {
  117. type: 'category',
  118. axisTick: { show: false }, // 横坐标刻度
  119. boundaryGap: false, // 坐标轴两边留白(刻度跟数据对应)
  120. axisLine: { // 横坐标线样式
  121. lineStyle: {
  122. color: 'rgba(255,255,255,.1)',
  123. },
  124. },
  125. axisLabel: {
  126. textStyle: { // 坐标轴文字
  127. color: '#fff'
  128. }
  129. },
  130. data: _this.timeData
  131. },
  132. yAxis: [
  133. {
  134. type: 'value',
  135. axisLabel: { // 纵坐标样式
  136. textStyle: {
  137. color: '#fff',
  138. }
  139. },
  140. splitLine: { // 网格线
  141. show: true, // 是否显示
  142. lineStyle: { // 网格线样式
  143. color: 'rgba(255,255,255,.1)', // 网格线颜色
  144. width: 1, //网格线的加粗程度
  145. // type: 'dashed' // 网格线类型 dashed:虚线
  146. }
  147. },
  148. name: '光照强度W/㎡', // 刻度
  149. nameTextStyle: {
  150. color: '#fff',
  151. padding: [0, 0, 0, 20],
  152. },
  153. alignTicks: true,
  154. // min: 0,
  155. // max: setMax(maxa),
  156. // interval: setMax(maxa) / 5,
  157. },
  158. {
  159. type: 'value',
  160. axisLabel: { // 纵坐标样式
  161. textStyle: {
  162. color: '#fff',
  163. }
  164. },
  165. splitLine: { // 网格线
  166. show: true, // 是否显示
  167. lineStyle: { // 网格线样式
  168. color: 'rgba(255,255,255,.1)', // 网格线颜色
  169. width: 1, //网格线的加粗程度
  170. // type: 'dashed' // 网格线类型 dashed:虚线
  171. }
  172. },
  173. name: '温湿度值/℃/%', // 刻度
  174. nameTextStyle: {
  175. color: '#fff',
  176. // padding: [0, 0, 0, 20],
  177. },
  178. alignTicks: true,
  179. // min: 0,
  180. // max: setMax(maxb),
  181. // interval: setMax(maxb) / 5,
  182. },
  183. ],
  184. legend: {
  185. icon: "roundRect", // 样式改为方形rect,改为圆角方形roundRect
  186. itemWidth: 14, // 宽度
  187. itemHeight: 6, // 高度
  188. textStyle: {
  189. color: '#fff',
  190. fontSize: 11
  191. },
  192. top: '15',
  193. // 使用回调函数:加上数值方法
  194. // formatter: function (name) {
  195. // console.log(name)
  196. // var currentObj = _this.legendData.find(item => item.name === name)
  197. // return name + ':' + currentObj.value;
  198. // },
  199. data: _this.legendData.map(item => item.name),
  200. },
  201. series: [
  202. {
  203. name: '辐射强度值',
  204. type: 'line',
  205. // symbol: 'circle',
  206. // symbolSize: 2,
  207. showSymbol: false, // 只有在 tooltip hover 的时候显示symbol
  208. // itemStyle: { // symbol样式
  209. // normal: {
  210. // color: 'rgb(255, 255, 255)',
  211. // borderColor: 'rgba(255, 255, 255, 0.2)', // symbol边框颜色
  212. // borderWidth: 12 // symbol边框宽度
  213. // }
  214. // },
  215. lineStyle: { // 线条样式
  216. normal: {
  217. width: 2,
  218. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [ // 颜色渐变
  219. {
  220. offset: 0,
  221. color: 'rgb(7, 214, 38, 0)'
  222. },
  223. {
  224. offset: 0.5,
  225. color: 'rgb(7, 214, 38)'
  226. },
  227. {
  228. offset: 1,
  229. color: 'rgb(7, 214, 38, 0)'
  230. }
  231. ])
  232. }
  233. },
  234. data: _this.fusheData,
  235. },
  236. {
  237. name: '温度实值',
  238. type: 'line',
  239. yAxisIndex: 1, // 关联第几个y轴
  240. showSymbol: false,
  241. lineStyle: { // 线条样式
  242. normal: {
  243. width: 2,
  244. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [ // 颜色渐变
  245. {
  246. offset: 0,
  247. color: 'rgba(227, 1, 6, .5)'
  248. },
  249. {
  250. offset: 0.5,
  251. color: 'rgb(227, 1, 6)'
  252. },
  253. {
  254. offset: 1,
  255. color: 'rgba(227, 1, 6, 0.5)'
  256. }
  257. ])
  258. }
  259. },
  260. data: _this.wenduData,
  261. },
  262. {
  263. name: '湿度实值',
  264. type: 'line',
  265. yAxisIndex: 1, // 关联第几个y轴
  266. showSymbol: false,
  267. lineStyle: { // 线条样式
  268. normal: {
  269. width: 2,
  270. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [ // 颜色渐变
  271. {
  272. offset: 0,
  273. color: 'rgba(227, 145, 6, .5)'
  274. },
  275. {
  276. offset: 0.5,
  277. color: 'rgb(227, 145, 6)'
  278. },
  279. {
  280. offset: 1,
  281. color: 'rgba(227, 145, 6, .5)'
  282. }
  283. ])
  284. }
  285. },
  286. data: _this.shiduData,
  287. }
  288. ]
  289. };
  290. this.uOption && this.uEcharts.setOption(this.uOption)
  291. window.addEventListener("resize", ()=>{
  292. this.uEcharts.resize();
  293. });
  294. },
  295. refreshData(data){
  296. if(data.length === 0){
  297. return
  298. }
  299. var wendu = data.find(item => item.Name === '温度实值-全程')
  300. var shidu = data.find(item => item.Name === '湿度实值-全程')
  301. var fushe = data.find(item => item.Name === '辐射强度值-全程')
  302. var time = data.find(item => item.Name === '全程曲线-时间分布')
  303. this.wenduData = wendu ? wendu.Values : []
  304. this.shiduData = shidu ? shidu.Values : []
  305. this.fusheData = fushe ? fushe.Values : []
  306. this.timeData = time ? time.Values : []
  307. // console.log(this.shiduData)
  308. var _this = this
  309. this.uEcharts.setOption({
  310. xAxis: {
  311. data: this.timeData
  312. },
  313. series: [
  314. {
  315. name: '辐射强度值',
  316. data: _this.fusheData
  317. },
  318. {
  319. name: '温度实值',
  320. data: _this.wenduData
  321. },
  322. {
  323. name: '湿度实值',
  324. data: _this.shiduData
  325. },
  326. ]
  327. });
  328. },
  329. }
  330. }
  331. </script>
  332. <style scoped>
  333. @import '~@/assets/less/uStyle.less';
  334. </style>
  335. <style lang="less">
  336. .data-curve-module{
  337. width: 100%;
  338. height: 100%;
  339. }
  340. </style>