const roundFun=()=>{
let myChart = echarts.init(document.getElementById('round'));
let option=({
legend: {
orient: 'vertical',
left: 10,
data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎'],
selectedMode: false,
show: false
},
series: [
{
name: '访问来源',
type: 'pie',
radius: ['50%', '70%'],
avoidLabelOverlap: false,
label: {
show: false,
position: 'center',
formatter:'{b}\n{c}',
color:"black",
lineHeight:30,
},
emphasis: {
label: {
show: true,
fontSize: '30',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
data: [
{value: 335, name: '直接访问'},
{value: 310, name: '邮件营销'},
{value: 234, name: '联盟广告'},
{value: 135, name: '视频广告'},
{value: 1548, name: '搜索引擎'}
]
}
]
})
myChart.setOption(option)
myChart.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: 0
}); //中心默认显示内容
myChart.on('mouseover', (v) => { //清空第一次选中
if (v.dataIndex != 0) {
myChart.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: 0
});
}
});
myChart.on('mouseout', (v) => { //鼠标离开圆环默认选第一次
myChart.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: 0
});
});
}
其中显示中心区数据 主要是使用 label 将postion:center, formatter:'{b}\n{c}' ,最后效果