天气预报echarts

ops/2024/10/18 1:24:20/

如上图,可以切换温度,降水量,风力风向和空气质量 

javascript"><template><el-radio-group v-model="selectedData" @change="updateChart"><el-radio-button label="temperature">温度</el-radio-button><el-radio-button label="precipitation">降水量</el-radio-button><el-radio-button label="wind">风力风向</el-radio-button><el-radio-button label="airQuality">空气质量</el-radio-button></el-radio-group><div id="temp3day"></div>
</template><script setup>
import * as echarts from "echarts";
const props = defineProps({echartList: {default: [{ temp: 47, date: '2023-01-01' },{ temp: 44, date: '2023-01-02' },{ temp: 41, date: '2023-01-03' },{ temp: 38, date: '2023-01-04' },{ temp: 35, date: '2023-01-05' },{ temp: 32, date: '2023-01-06' },{ temp: 29, date: '2023-01-07' },],},
});
const selectedData = ref('temperature');
const temperatureData = ref(['12.3', '15.5', '12.7', '13.9', '13.1', '12.3', '13.5'])
const precipitationData = ref(['12','19','0','1','22','0','0'])
const windData = ref([])
const airQualityData = ref([])
const initNet = async () => {//   const res2 = await proxy.$get("/oneNetwork/getSourceInfo", {//     netId: props.netWorkId,//   }); //热源initChart('温度 (°C)', temperatureData.value)};
const initChart = (yAxisName, seriesData) => {let timeData = ['现在', '12:30', '15:00', '18:00', '21:00', '24:00', '27:00'];const machart = echarts.init(document.getElementById("temp3day"));var option = {title: {text: "",},tooltip: {trigger: "axis",},grid: {left: "3%",right: "3%",bottom: "12%",top: "17%",containLabel: true,},xAxis: {type: "category",boundaryGap: false,data: timeData,},yAxis: [{type: "value",// name: '负荷 (MW)',position: 'left',// axisLabel: {//     formatter: '{value} MW'// }axisTick: {show: false // 隐藏刻度线},splitLine: {show: false // 隐藏网格线}}],series: [{name: yAxisName,type: "line",stack: 'Total',areaStyle: {// 添加渐变色color: {type: 'linear',x: 0,y: 0,x2: 0,y2: 1,colorStops: [{ offset: 0, color: '#B0C4DE' }, // 上方颜色{ offset: 1, color: '#F0F8FF' } // 下方颜色],global: false // 缺省为 false}},emphasis: {focus: 'series'},lineStyle: {color: '#B0C4DE' // 折线颜色设置为蓝灰色},data: seriesData,},],};machart.setOption(option);
};
const updateChart = () => {let yAxisName = '';let seriesData = [];switch (selectedData.value) {case 'temperature':yAxisName = '温度 (°C)';seriesData = temperatureData.value;break;case 'precipitation':yAxisName = '降水量 (mm)';seriesData = precipitationData.value;break;case 'wind':yAxisName = '风速 (m/s)';seriesData = windData.value;break;case 'airQuality':yAxisName = '空气质量指数';seriesData = airQualityData.value;break;default:break;}initChart(yAxisName, seriesData)
}
setTimeout(() => {initNet()
}, 800);
</script><style scoped>
#temp3day {width: 100%;height: 32vh;
}
</style>


http://www.ppmy.cn/ops/124309.html

相关文章

R中线性回归及其权重和截距的计算

以下是您提供的代码的总结和解析&#xff0c;主要聚焦于线性回归及其权重和截距的计算。 代码解析 数据准备&#xff1a; data women使用内置的 women 数据集&#xff0c;该数据集包含了身高和体重的信息。 绘制散点图&#xff1a; plot(women$height, women$weight,xlab &…

【MySQL】CRUD增删改查操作

文章目录 CRUD简介一、Creat 新增1.单行数据全列插入2.单行数据全指定列插入3.多行数据指定列插入 二、Retrieve 检索1.全列查询 --练习阶段最简单的查询&#xff1a;&#xff08;在生产环境最好不要用&#xff01;&#xff01;&#xff09;2.指定列查询3.结果去重查询4.where条…

Linux——软件包管理

目录 rpm 包管理 基本介绍 rpm 包的查询指令 ​编辑 rpm 包的卸载和安装 yum rpm 包管理 基本介绍 rpm 包的查询指令 rpm 包的卸载和安装 yum

ElasticsearchClient入门指南

在本教程中,我们将探讨如何使用Elasticsearch的官方Java客户端 - ElasticsearchClient。这个强大的工具允许您的Java应用程序与Elasticsearch集群进行交互,执行各种操作,如索引文档、执行搜索查询等。 前提条件 在开始之前,确保您的项目中已经包含了必要的依赖。您可以通过Ma…

Windows 部署 ollama

1.安装 官方地址&#xff1a;https://ollama.com/ 1.1 下载ollama 1.2 安装 1.3 运行 Ollama 1.4 测试ollama运行状态 http://localhost:11434 curl http://localhost:11434/api/generate -d "{ \"model\": \"qwen2:0.5b\", \"prompt\":…

极狐GitLab 发布安全补丁版本 17.4.1、17.3.4、17.2.8

GitLab 是一个全球知名的一体化 DevOps 平台&#xff0c;很多人都通过私有化部署 GitLab 来进行源代码托管。极狐GitLab 是 GitLab 在中国的发行版&#xff0c;专门为中国程序员服务。可以一键式部署极狐GitLab。 学习极狐GitLab 的相关资料&#xff1a; 极狐GitLab 官网极狐…

鸿蒙面试题库收集(三):网络请求线程相关

二. 网络请求&线程相关 1. 数据通信 *** eventHub : 普通事件发布&#xff0c;订阅 eventHub&#xff1a;提供了事件中心&#xff0c;提供订阅&#xff0c;取消订阅&#xff0c;触发事件的能力&#xff0c;同hap内通信&#xff0c;不跨线程eventHub.emit(数据标记&#xff…

tpcms-master.zip

网盘&#xff1a;https://pan.notestore.cn/s.html?id34https://pan.notestore.cn/s.html?id34