zhaoyun 1 месяц назад
Родитель
Сommit
2f707b420f
2 измененных файлов с 78 добавлено и 4 удалено
  1. 1 4
      src/views/modules/load-data/index.vue
  2. 77 0
      src/views/modules/weather/list.vue

+ 1 - 4
src/views/modules/load-data/index.vue

@@ -49,10 +49,7 @@
 
 
 					
 					
 					
 					
-					<el-button class="btn18"  type="success" @click="chartDialog5()">
-						<span class="icon iconfont icon-xihuan" :style='{"margin":"0 2px","fontSize":"14px","color":"#fff","display":"none","height":"34px"}'></span>
-						温度统计
-					</el-button>
+				
 				
 				
 				</el-row>
 				</el-row>
 			</el-form>
 			</el-form>

+ 77 - 0
src/views/modules/weather/list.vue

@@ -32,6 +32,10 @@
 						<span class="icon iconfont icon-xihuan" :style='{"margin":"0 2px","fontSize":"14px","color":"#fff","display":"none","height":"34px"}'></span>
 						<span class="icon iconfont icon-xihuan" :style='{"margin":"0 2px","fontSize":"14px","color":"#fff","display":"none","height":"34px"}'></span>
 						导入
 						导入
 					</el-button>
 					</el-button>
+					<el-button class="btn18"  type="success" @click="chartDialog5()">
+						<span class="icon iconfont icon-xihuan" :style='{"margin":"0 2px","fontSize":"14px","color":"#fff","display":"none","height":"34px"}'></span>
+						温度统计
+					</el-button>
 				</el-row>
 				</el-row>
 			</el-form>
 			</el-form>
 			<div :style='{"border":"0px solid #fff","width":"100%","padding":"0 20px 20px","fontSize":"14px","color":"#000","background":"#fff"}'>
 			<div :style='{"border":"0px solid #fff","width":"100%","padding":"0 20px 20px","fontSize":"14px","color":"#000","background":"#fff"}'>
@@ -451,7 +455,80 @@
 					});
 					});
 				});
 				});
 			},
 			},
+// 统计接口
+			chartDialog5() {
+				this.chartVisiable5 = !this.chartVisiable5;
+				this.$nextTick(()=>{
 
 
+					var temperatureChart5 = echarts.init(document.getElementById("temperatureChart5"),'carp');
+					this.$http({
+						url: "regionWeather/sectionStat/temperature",
+						method: "get",
+					}).then(({ data }) => {
+						if (data && data.code === 0) {
+							let res = data.data;
+							let xAxis = [];
+							let yAxis = [];
+							let pArray = []
+							for(let i=0;i<res.length;i++){
+								if(this.boardBase&&i==this.boardBase.barNum){
+									break;
+								}
+								xAxis.push(res[i].temperature);
+								yAxis.push(parseFloat((res[i].total)));
+								pArray.push({
+									value: parseFloat((res[i].total)),
+									name: res[i].temperature
+								})
+							}
+							var option = {};
+							let titleObj = this.bar.title
+							titleObj.text = '温度统计'
+							
+							const legendObj = this.bar.legend
+							
+							let tooltipObj = {trigger: 'item',formatter: '{b} : {c}'}
+							tooltipObj = Object.assign(tooltipObj , this.bar.tooltip?this.bar.tooltip:{})
+							let xAxisObj = this.bar.xAxis
+							xAxisObj.type = 'category'
+							xAxisObj.data = xAxis
+							
+							let yAxisObj = this.bar.yAxis
+							yAxisObj.type = 'value'
+				
+							let seriesObj = {
+								data: yAxis,
+								type: 'bar',
+							}
+							seriesObj = Object.assign(seriesObj , this.bar.series)
+							const gridObj = this.bar.grid
+							option = {
+								backgroundColor: this.bar.backgroundColor,
+								color: this.bar.color,
+								title: titleObj,
+								legend: legendObj,
+								tooltip: tooltipObj,
+								xAxis: xAxisObj,
+								yAxis: yAxisObj,
+								series: [seriesObj],
+								grid: gridObj
+							};
+							// 使用刚指定的配置项和数据显示图表。
+							temperatureChart5.setOption(option);
+							//根据窗口的大小变动图表
+							window.onresize = function() {
+								temperatureChart5.resize();
+							};
+						}else{
+							this.$message({
+								message: data.msg,
+								type: "warning",
+								duration: 1500,
+							})
+						}
+					});
+				})
+			},
 
 
 		}
 		}