Initial commit: weather demo
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html><html><head><meta charset="utf-8"><title>北京·中国 未来3天温度变化</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.0/dist/echarts.min.js"></script>
|
||||
<style>body{margin:0;background:#0f172a;color:#e2e8f0;font-family:system-ui,sans-serif}#c{width:100vw;height:100vh}</style></head>
|
||||
<body><div id="c"></div><script>
|
||||
const rows=[{"t":"2026-10-24 00:00","temp":10.2,"hum":82,"precip":0},{"t":"2026-10-24 01:00","temp":9.9,"hum":83,"precip":0},{"t":"2026-10-24 02:00","temp":9.1,"hum":88,"precip":0},{"t":"2026-10-24 03:00","temp":8.9,"hum":88,"precip":0},{"t":"2026-10-24 04:00","temp":8.7,"hum":89,"precip":0},{"t":"2026-10-24 05:00","temp":8.9,"hum":87,"precip":0},{"t":"2026-10-24 06:00","temp":9,"hum":86,"precip":0},{"t":"2026-10-24 07:00","temp":8.9,"hum":84,"precip":0},{"t":"2026-10-24 08:00","temp":10.2,"hum":83,"precip":0},{"t":"2026-10-24 09:00","temp":11.7,"hum":76,"precip":0},{"t":"2026-10-24 10:00","temp":13.1,"hum":73,"precip":0},{"t":"2026-10-24 11:00","temp":13.9,"hum":69,"precip":0},{"t":"2026-10-24 12:00","temp":14.6,"hum":68,"precip":0},{"t":"2026-10-24 13:00","temp":15.3,"hum":67,"precip":0},{"t":"2026-10-24 14:00","temp":15.6,"hum":66,"precip":0},{"t":"2026-10-24 15:00","temp":15.8,"hum":66,"precip":0},{"t":"2026-10-24 16:00","temp":15.8,"hum":68,"precip":0},{"t":"2026-10-24 17:00","temp":15.5,"hum":75,"precip":0},{"t":"2026-10-24 18:00","temp":15.1,"hum":76,"precip":0},{"t":"2026-10-24 19:00","temp":15,"hum":76,"precip":1},{"t":"2026-10-24 20:00","temp":14.5,"hum":80,"precip":2},{"t":"2026-10-24 21:00","temp":14.1,"hum":83,"precip":4},{"t":"2026-10-24 22:00","temp":13.7,"hum":84,"precip":7},{"t":"2026-10-24 23:00","temp":13.5,"hum":84,"precip":10},{"t":"2026-10-25 00:00","temp":13.3,"hum":86,"precip":14},{"t":"2026-10-25 01:00","temp":13.2,"hum":87,"precip":19},{"t":"2026-10-25 02:00","temp":13.1,"hum":90,"precip":25},{"t":"2026-10-25 03:00","temp":12.9,"hum":92,"precip":34},{"t":"2026-10-25 04:00","temp":12.7,"hum":94,"precip":44},{"t":"2026-10-25 05:00","temp":12.4,"hum":93,"precip":49},{"t":"2026-10-25 06:00","temp":12.1,"hum":93,"precip":43},{"t":"2026-10-25 07:00","temp":12.1,"hum":91,"precip":32},{"t":"2026-10-25 08:00","temp":12.3,"hum":89,"precip":22},{"t":"2026-10-25 09:00","temp":12.5,"hum":88,"precip":16},{"t":"2026-10-25 10:00","temp":12.7,"hum":88,"precip":12},{"t":"2026-10-25 11:00","temp":13,"hum":86,"precip":10},{"t":"2026-10-25 12:00","temp":13.1,"hum":83,"precip":9},{"t":"2026-10-25 13:00","temp":12.9,"hum":81,"precip":9},{"t":"2026-10-25 14:00","temp":12.9,"hum":79,"precip":12},{"t":"2026-10-25 15:00","temp":12.7,"hum":77,"precip":20},{"t":"2026-10-25 16:00","temp":12.3,"hum":78,"precip":32},{"t":"2026-10-25 17:00","temp":11.8,"hum":80,"precip":43},{"t":"2026-10-25 18:00","temp":11.3,"hum":83,"precip":54},{"t":"2026-10-25 19:00","temp":11.1,"hum":84,"precip":65},{"t":"2026-10-25 20:00","temp":10.8,"hum":86,"precip":71},{"t":"2026-10-25 21:00","temp":10.5,"hum":88,"precip":67},{"t":"2026-10-25 22:00","temp":10.3,"hum":87,"precip":58},{"t":"2026-10-25 23:00","temp":10.2,"hum":88,"precip":49},{"t":"2026-10-26 00:00","temp":10,"hum":89,"precip":43},{"t":"2026-10-26 01:00","temp":9.9,"hum":92,"precip":38},{"t":"2026-10-26 02:00","temp":9.8,"hum":93,"precip":33},{"t":"2026-10-26 03:00","temp":9.7,"hum":93,"precip":29},{"t":"2026-10-26 04:00","temp":9.6,"hum":93,"precip":25},{"t":"2026-10-26 05:00","temp":9.8,"hum":92,"precip":22},{"t":"2026-10-26 06:00","temp":9.8,"hum":92,"precip":21},{"t":"2026-10-26 07:00","temp":9.4,"hum":94,"precip":20},{"t":"2026-10-26 08:00","temp":9.9,"hum":92,"precip":18},{"t":"2026-10-26 09:00","temp":10.7,"hum":87,"precip":13},{"t":"2026-10-26 10:00","temp":11.8,"hum":80,"precip":7},{"t":"2026-10-26 11:00","temp":12.7,"hum":76,"precip":2},{"t":"2026-10-26 12:00","temp":13.9,"hum":71,"precip":0},{"t":"2026-10-26 13:00","temp":14.5,"hum":69,"precip":0},{"t":"2026-10-26 14:00","temp":14.9,"hum":68,"precip":0},{"t":"2026-10-26 15:00","temp":15.2,"hum":67,"precip":0},{"t":"2026-10-26 16:00","temp":14.9,"hum":71,"precip":0},{"t":"2026-10-26 17:00","temp":14,"hum":76,"precip":0},{"t":"2026-10-26 18:00","temp":13,"hum":80,"precip":0},{"t":"2026-10-26 19:00","temp":12.8,"hum":81,"precip":0},{"t":"2026-10-26 20:00","temp":12.6,"hum":70,"precip":0},{"t":"2026-10-26 21:00","temp":13.1,"hum":35,"precip":0},{"t":"2026-10-26 22:00","temp":13,"hum":30,"precip":0},{"t":"2026-10-26 23:00","temp":12.6,"hum":28,"precip":0}];
|
||||
const ch=echarts.init(document.getElementById('c'));
|
||||
ch.setOption({title:{text:"北京·中国 未来3天温度变化",left:'center',textStyle:{color:'#e2e8f0'}},
|
||||
tooltip:{trigger:'axis',formatter:p=>{const r=rows[p[0].dataIndex];return r.t+'<br>温度 '+r.temp+'°C<br>湿度 '+r.hum+'%<br>降水概率 '+r.precip+'%';}},
|
||||
grid:{left:55,right:40,top:80,bottom:55},
|
||||
xAxis:{type:'category',data:rows.map(r=>r.t),axisLabel:{color:'#94a3b8',interval:5}},
|
||||
yAxis:{type:'value',name:'°C',axisLabel:{color:'#94a3b8'}},
|
||||
series:[{name:'温度',type:'line',smooth:true,data:rows.map(r=>r.temp),lineStyle:{width:3,color:'#38bdf8'},itemStyle:{color:'#38bdf8'},areaStyle:{color:'rgba(56,189,248,.2)'}}]});
|
||||
window.addEventListener('resize',()=>ch.resize());
|
||||
</script></body></html>
|
||||
Reference in New Issue
Block a user