解決echarts中餅圖標(biāo)簽重疊的問題
餅圖中的series有個(gè)avoidLabelOverlap屬性,
avoidLabelOverlap:是否啟用防止標(biāo)簽重疊策略,默認(rèn)開啟,在標(biāo)簽擁擠重疊的情況下會(huì)挪動(dòng)各個(gè)標(biāo)簽的位置,防止標(biāo)簽間的重疊。
當(dāng)avoidLabelOverlap設(shè)置為false時(shí)會(huì)出現(xiàn)以下情況

改為true之后就不會(huì)重疊

代碼如下
var option = {
tooltip: {
trigger: "item",
formatter: "{a} <br/> : {c} (vvxyksv9kd%)"
},
legend: {
//orient: "vertical",
x: "0%",
//y: "25%",
//y: "5%",
itemWidth: 14,
itemHeight: 14,
align: "left",
data: xData,
textStyle: {
color: "#fff"
}
},
series: [
{
name: "危險(xiǎn)源狀態(tài)",
type: "pie",
radius: ["25%", "45%"],
center: ["50%", "60%"],
avoidLabelOverlap: true,//對(duì),就是這里avoidLabelOverlap
label: {
normal: {
show: true,
position: "center"
},
emphasis: {
show: true,
textStyle: {
fontSize: "12",
fontWeight: "bold"
}
}
},
labelLine: {
normal: {
show: true
}
},
data: pieData
}
]
};
補(bǔ)充知識(shí):echarts柱狀圖輕松實(shí)現(xiàn)分別采用兩個(gè)不同單位的y軸
echarts柱狀圖輕松實(shí)現(xiàn)分別采用兩個(gè)不同單位的y軸:

秘籍:

代碼
// 基于準(zhǔn)備好的dom,初始化echarts實(shí)例
var colors = ['#0089FF','#B865DF',/*'#5ADF63','#FFDD00',*/'#224666', '#675bba'];
// 指定圖表的配置項(xiàng)和數(shù)據(jù)
option = {
/*grid:{
y:'25%'},*/
color: colors,
/* title: {
text: '各醫(yī)院指標(biāo)對(duì)比情況',
left: 16,
textStyle: {
fontSize: 18,
color:'#0089FF'
}
},*/
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
legend: {
data:['組數(shù)','CMI'],
x:'80%'
},
xAxis: [
{
type: 'category',
data: arr,
axisPointer: {
type: 'shadow'
},
axisLine: {
show: true,
/* lineStyle: {
color: '#05edfc'
}*/
},
axisLabel: {
show: true,
/* color: '#fff',*/
fontSize: 12,
interval: 0,
formatter:function(value)
{
return value;
}
//fontWeight: 'bold'
}
},
],
yAxis: [
{
type: 'value',
name: '組數(shù)整體指標(biāo)',
position: 'left',
splitLine:{show: true},
axisLine: {
show: false,
/* lineStyle: {
color: '#E7E7E7'
}*/
},
axisLabel: {
show:true,
showMinLabel:true,
showMaxLabel:true,
formatter: '{value}'
},
},
{
type: 'value',
name: 'CMI',
position: 'right',
splitLine:{show: true},
axisLine: {
show: false,
/* lineStyle: {
color: '#E7E7E7'
}*/
},
axisLabel: {
show:true,
showMinLabel:true,
showMaxLabel:true,
formatter: '{value}'
},
},
],
series: [
{
name:'組數(shù)',
type:'bar',
barWidth : 20,
data:arr2,
yAxisIndex: 0,
/* markPoint : {
data : [
{type : 'max', name: '最大值'},
{type : 'min', name: '最小值'}
]
}*/
},
{
name:'CMI',
type:'bar',
barWidth : 20,
data:arr3,
yAxisIndex: 1,
/* markPoint : {
data : [
{type : 'max', name: '最大值'},
{type : 'min', name: '最小值'}
]
}*/
}
]
};
以上這篇解決echarts中餅圖標(biāo)簽重疊的問題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- React項(xiàng)目搭建與Echarts工具使用詳解
- vue+echarts封裝氣泡圖的方法
- echarts 3D地圖為區(qū)域自定義顏色的解決方法
- 在vue中使用echarts實(shí)現(xiàn)上浮與下鉆效果
- 使用GetInvalidFileNameCharts生成文件名
- echarts餅圖扇區(qū)添加點(diǎn)擊事件的實(shí)例
- echarts餅圖指示器文字顏色設(shè)置不同實(shí)例詳解
- echarts餅圖各個(gè)板塊之間的空隙如何實(shí)現(xiàn)
- echarts實(shí)現(xiàn)餅圖與樣式設(shè)置
- echarts餅圖標(biāo)簽formatter使用及餅圖自定義標(biāo)簽
- 基于Echarts實(shí)現(xiàn)餅圖效果
- Vue ECharts餅圖實(shí)現(xiàn)方法詳解
- Echarts實(shí)現(xiàn)點(diǎn)擊列表聯(lián)動(dòng)餅圖的示例代碼
相關(guān)文章
python機(jī)器學(xué)習(xí)邏輯回歸隨機(jī)梯度下降法
這篇文章主要為大家介紹了python機(jī)器學(xué)習(xí)邏輯回歸隨機(jī)梯度下降法的詳細(xì)講解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步2021-11-11
mac使用python識(shí)別圖形驗(yàn)證碼功能
這篇文章主要介紹了mac使用python識(shí)別圖形驗(yàn)證碼功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-01-01
關(guān)于使用OpenCsv導(dǎo)入大數(shù)據(jù)量報(bào)錯(cuò)的問題
這篇文章主要介紹了使用OpenCsv導(dǎo)入大數(shù)據(jù)量報(bào)錯(cuò)的問題 ,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08
python 操作mysql數(shù)據(jù)中fetchone()和fetchall()方式
這篇文章主要介紹了python 操作mysql數(shù)據(jù)中fetchone()和fetchall()方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-05-05
Python中Parsel的兩種數(shù)據(jù)提取方式詳解
在網(wǎng)絡(luò)爬蟲的世界中,數(shù)據(jù)提取是至關(guān)重要的一環(huán),Python 提供了許多強(qiáng)大的工具,其中之一就是 parsel 庫,下面我們就來深入學(xué)習(xí)一下Parsel的兩種數(shù)據(jù)提取方式吧2023-12-12

