FullCurveModel.vue 9.8 KB

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