2024-06-07 12:15:48 +00:00
|
|
|
|
function echarts_33() {
|
|
|
|
|
// 基于准备好的dom,初始化echarts实例
|
|
|
|
|
var myChart = echarts.init(document.getElementById('fb3'));
|
|
|
|
|
var data = Chart33_Data;
|
|
|
|
|
|
|
|
|
|
// 指定图表的配置项和数据
|
|
|
|
|
option = {
|
|
|
|
|
title: {
|
2024-06-07 12:54:53 +00:00
|
|
|
|
text: '风速地区排行',
|
2024-06-07 12:15:48 +00:00
|
|
|
|
// subtext: '数据来源:环保局',
|
|
|
|
|
left: 'center',
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#fff',
|
|
|
|
|
fontSize: '16'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
tooltip: {
|
|
|
|
|
trigger: 'item',
|
|
|
|
|
position: function (p) { //其中p为当前鼠标的位置
|
2024-06-07 14:11:11 +00:00
|
|
|
|
return [p[0] + 60, p[1] - 100];
|
2024-06-07 12:15:48 +00:00
|
|
|
|
},
|
|
|
|
|
formatter: function (params) {
|
|
|
|
|
var dataItem = data.find(item => item.name === params.name);
|
|
|
|
|
var value = `${dataItem.name}: ${params.value} (${params.percent}%) <br>`;
|
|
|
|
|
|
2024-06-07 12:54:53 +00:00
|
|
|
|
dataItem.degree.forEach((v, index) => {
|
|
|
|
|
var detail = dataItem.detail[index];
|
2024-06-07 14:11:11 +00:00
|
|
|
|
value += `${v}: ${detail} m/s `;
|
|
|
|
|
if (index % 2 === 1) {
|
|
|
|
|
value += '<br>';
|
|
|
|
|
}
|
2024-06-07 12:15:48 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return value; // 动态遍历数据显示地区、天气和百分比
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
legend: {
|
|
|
|
|
orient: 'vertical',
|
|
|
|
|
left: 'left',
|
|
|
|
|
top: '70%',
|
|
|
|
|
itemWidth: 10,
|
|
|
|
|
itemHeight: 10,
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: 'rgba(255,255,255,.5)',
|
|
|
|
|
fontSize: '12',
|
|
|
|
|
},
|
|
|
|
|
// data: ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染'],
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
name: '空气质量',
|
|
|
|
|
type: 'pie',
|
|
|
|
|
center: ['50%', '42%'],
|
|
|
|
|
radius: ['40%', '60%'],
|
|
|
|
|
|
|
|
|
|
data: data.map(item => ({
|
|
|
|
|
value: item.value,
|
|
|
|
|
name: item.name,
|
|
|
|
|
itemStyle: {color: item.color},
|
|
|
|
|
label: {
|
|
|
|
|
show: false,
|
|
|
|
|
position: 'center',
|
|
|
|
|
formatter: '{b}: {c}' // 显示地区名称和天气数据
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
})),
|
|
|
|
|
emphasis: {
|
|
|
|
|
itemStyle: {
|
|
|
|
|
show: true,
|
|
|
|
|
fontSize: '30',
|
|
|
|
|
fontWeight: 'bold'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
labelLine: {
|
|
|
|
|
show: false
|
|
|
|
|
}
|
|
|
|
|
// itemStyle: {
|
|
|
|
|
// color: ['#0f63d6', '#0f78d6', '#0f8cd6', '#0fa0d6', '#0fb4d6', '#0fc8d6'] // 添加更多的颜色
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 使用刚指定的配置项和数据显示图表。
|
|
|
|
|
myChart.setOption(option);
|
|
|
|
|
window.addEventListener("resize", function () {
|
|
|
|
|
myChart.resize();
|
|
|
|
|
});
|
|
|
|
|
}
|