uniapp点击切换echarts数据

该内容展示了一个用户与设备统计的界面,包括资产设备、用户数量、部门数量和岗位数量的统计。同时,提到了物联设备和测点情况的统计以及报警数量的图表,使用ECharts库进行数据可视化,根据选择的时间范围(近七天或近半年)动态更新报警数量统计图表。
摘要由CSDN通过智能技术生成
<template>
	<view class="wrap">
		<view class="content-box">
			<text class="title">用户与设备统计</text>
			<view class="">
				<view class="userbox">
					<img src="../../static/index/zichan.png" alt="" srcset="">
					<view class="user_content">
						<view class="userbox_num">
							{{userinfo.assetCount}}
						</view>
						<view class="userbox_name">
							资产设备统计
						</view>
					</view>
				</view>
				<view class="userbox">
					<img src="../../static/index/yonghu.png" alt="" srcset="">
					<view class="user_content">
						<view class="userbox_num">
							{{userinfo.userCount}}
						</view>
						<view class="userbox_name">
							用户数量统计
						</view>
					</view>
				</view>
				<view class="userbox">
					<img src="../../static/index/bumen.png" alt="" srcset="">
					<view class="user_content">
						<view class="userbox_num">
							{{userinfo.deptCount}}
						</view>
						<view class="userbox_name">
							部门数量统计
						</view>
					</view>
				</view>
				<view class="userbox">
					<img src="../../static/index/gangwei.png" alt="" srcset="">
					<view class="user_content">
						<view class="userbox_num">
							{{userinfo.postCount}}
						</view>
						<view class="userbox_name">
							岗位数量统计
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="content-box">
			<text class="title">物联设备与测点情况统计</text>
		</view>
		<view class="content-box baojing">
			<text class="title">报警数量统计</text>
			<my-radio ref="radio1" :list="radioList1" @change="radioChange($event)" style="top: 30rpx;left: 430rpx;z-index: 99;"></my-radio>
			<view class="" ref="alarmbar" id="alarmbar" style="height:400px;"></view>
		</view>
		<view class="content-box">
			<text class="title">设备负载率统计</text>
			
		</view>
	</view>
  
</template>

<script >
	import { ref, reactive, getCurrentInstance } from 'vue'
	import * as echarts from 'echarts'
	
	export default {
		setup() {
			const { proxy } = getCurrentInstance()
			const userinfo = reactive({})
			proxy.$request('/rexel-api/tenant/detail/user/asset', {
			},"GET").then(res => {
				Object.assign(userinfo, res.data)
			})
			const radioList1 = ['近七天','近半年']
			const warnTypeActive = ref(0)
			const radioChange = (e) => {
				warnTypeActive.value = e
				gainWarnList()
			}
			const gainWarnList = () => {
				let url = ''
				if (warnTypeActive.value === 0) {
					url = '/rexel-api/tenant/detail/alarm/chart/1'
				} else {
					url = '/rexel-api/tenant/detail/alarm/chart/2'
				}
				proxy.$request(url, {
				},"GET").then(res => {
					console.log(res.data)
					let baojingxAxis=res.data.xaxis
					let baojingyAxis=res.data.yaxis
					var myChart = echarts.init(document.getElementById('alarmbar'));
					  // 指定图表的配置项和数据
					var option = {
						tooltip: {
							trigger: 'axis',
						},
						color:'#8CBDEE',
						xAxis: {
							data: baojingxAxis
							// data: ['2022/1', '2022/2', '2022/3', '2022/4', '2022/5', '2022/6']
						},
						 yAxis: {
							// type: 'log',
							type: 'value',
							// 单位颜色
							name: "条",
							nameTextStyle: {
							  color: "#333",
							  nameLocation: "start",
							},
							// 坐标值颜色
							"axisLabel":{
							  color: '#333'
							  // textStyle: { color: '#333'}
							},
							splitLine: {
							  show: false,
							  // 网格线颜色
								lineStyle:{
								color: ['#8E8E8E'],
								width: 0.5,
								type: 'solid'
							  }
							},
						  },
						series: [
						  {
							  
							  name: "报警数",
							  type: "bar",//柱状图
							  // itemStyle: {
								 //  normal: {
									//   barBorderRadius:[5, 5, 0, 0]
								 //  }
							  // },
							  barWidth: 20, // 柱子宽度
							  stack:"Search Engine",
							  emphasis: {//折线图的高亮状态。
								focus: "series",//聚焦当前高亮的数据所在的系列的所有图形。
							  },
							  data:baojingyAxis
							  // data: [5, 20, 36, 10, 10, 20]
						  }
						]
					};
					// 使用刚指定的配置项和数据显示图表。
					myChart.setOption(option);
					
				})
			}
			const alarmbar = ref(null)
			return {
				userinfo,
				alarmbar,
				radioChange,
				gainWarnList,
				radioList1,
			}
		},
		methods:{
			drawalarm() {
				var myChart = echarts.init(this.$refs.alarmbar.$el);
				  // 指定图表的配置项和数据
				var option = {
					tooltip: {
						trigger: 'axis',
					},
					color:'#8CBDEE',
					xAxis: {
						data: this.baojingxAxis
						// data: ['2022/1', '2022/2', '2022/3', '2022/4', '2022/5', '2022/6']
					},
					 yAxis: {
						// type: 'log',
						type: 'value',
						// 单位颜色
						name: "条",
						nameTextStyle: {
						  color: "#333",
						  nameLocation: "start",
						},
						// 坐标值颜色
						"axisLabel":{
						  color: '#333'
						  // textStyle: { color: '#333'}
						},
						splitLine: {
						  show: false,
						  // 网格线颜色
							lineStyle:{
							color: ['#8E8E8E'],
							width: 0.5,
							type: 'solid'
						  }
						},
					  },
					series: [
					  {
						  
						  name: "报警数",
						  type: "bar",//柱状图
						  // itemStyle: {
							 //  normal: {
								//   barBorderRadius:[5, 5, 0, 0]
							 //  }
						  // },
						  barWidth: 20, // 柱子宽度
						  stack:"Search Engine",
						  emphasis: {//折线图的高亮状态。
							focus: "series",//聚焦当前高亮的数据所在的系列的所有图形。
						  },
						  data:this.baojingyAxis
						  // data: [5, 20, 36, 10, 10, 20]
					  }
					]
				};
				// 使用刚指定的配置项和数据显示图表。
				myChart.setOption(option);
			},
		},
		onShow() {
			this.gainWarnList()
		}
	}
		
   
</script>

<style lang="scss" scoped>
	.wrap{
		min-height: 130vh;
	}
	.baojing{
		position: relative;
	}
	.content-box{
		margin: 30rpx;
		padding: 15rpx;
		background: #fff;
		.title{
			padding: 0px 15rpx ;
			font-weight: bold;
			color: #333333;
		}
		.userbox{
			display: inline-block;
			width: 46%;
			margin: 30rpx 10rpx 0rpx 15rpx;
			padding: 15rpx;
			box-shadow: 0px 0px 6px 1px rgba(0,0,0,0.1);
			border-radius: 4px 4px 4px 4px;
			opacity: 1;
			img{
				width: 50rpx;
				height: 50rpx;
				display: inline-block;
				vertical-align: middle;
			}
			.user_content{
				vertical-align: middle;
				display: inline-block;
				margin-left: 30rpx;
			}
			.userbox_num{
				color: #333;
				font-size: 16rpx;
				padding-bottom: 5rpx;
			}
			.userbox_name{
				color: #999;
				font-size: 16rpx;
			}
		}
	}
  .charts-box {
    width: 100%;
    height: 360rpx;
    position: relative;
    .unit {
      color: #9E9EA6;
      position: absolute;
      font-size: 22rpx;
      &:nth-child(1) {
        left: 40rpx;
        top: 43rpx;
      }
      &:nth-child(2) {
        right: 40rpx;
        top: 43rpx;
      }
    }
  }
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值