Vue3Echarts写关于温湿度统计的好看折线图

在项目统计界面,我们离不开对Echarts的使用,接下来是我在做项目过程中做的一个关于温湿度统计的好看折线图,统计的是温度蓝色和湿度绿色,它们还会有告警和断电,分别用橘黄色和红色区分,以下是示例:

下载Echarts

//npm
npm install echarts --save

//淘宝镜像cnpm(安装速度快)
cnpm install echarts --save

//yarn
yarn add echarts

代码案例

<template>
    <div id="echartsOne" style="width: 100%;height: 100%;"></div>
</template>

<script setup>
    import * as echarts from 'echarts';
    import { onMounted,ref } from 'vue';
    onMounted(()=>{
        getEcharts();
    })
    const getEcharts = () => {
        let chartDom = document.getElementById("echartsOne");
        let myChart = echarts.init(chartDom);
        let wsdList = [{
      	createTime: "10:20",
      	humStatus: 0,
      	humidity: "59.4",
      	isOff: 0,
      	tempStatus: 0,
      	temperature: "28.8",
      }, {
      	createTime: "10:21",
      	humStatus: 0,
      	humidity: "59.4",
      	isOff: 1,
      	tempStatus: 0,
      	temperature: "28.8",
      }, {
      	createTime: "10:22",
      	humStatus: 0,
      	humidity: "59.4",
      	isOff: 0,
      	tempStatus: 1,
      	temperature: "28.8",
      }, {
      	createTime: "10:23",
      	humStatus: 0,
      	humidity: "59.4",
      	isOff: 0,
      	tempStatus: 0,
      	temperature: "28.8",
      }, {
      	createTime: "10:24",
      	humStatus: 1,
      	humidity: "59.4",
      	isOff: 0,
      	tempStatus: 0,
      	temperature: "28.8",
      }, {
      	createTime: "10:25",
      	humStatus: 0,
      	humidity: "59.4",
      	isOff: 1,
      	tempStatus: 0,
      	temperature: "28.8",
      }, {
      	createTime: "10:26",
      	humStatus: 1,
      	humidity: "59.4",
      	isOff: 0,
      	tempStatus: 0,
      	temperature: "28.8",
      },]
      let rq = []
      rq = wsdList.map(val => {
      	return val.createTime
      })
      let seriesArr = []
      let list = [{
      		name: "温度",
      		children: wsdList.map(val => {
      			let temp0 = val.tempStatus == 0 ? `rgb(68, 247, 227)` : `rgb(240, 128, 19)`;
      			return {
      				name: val.createTime,
      				value: val.isOff == 1 ? 6 : val.temperature,
      				isOff: val.isOff,
      				offTime: val.offTime ? val.offTime : "",
      				itemStyle: {
      					color: {
      						type: 'radial',
      						x: 0.5,
      						y: 0.5,
      						r: 0.5,
      						colorS
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陈琦鹏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值