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

改為true之后就不會重疊

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

秘籍:

代碼
// 基于準(zhǔn)備好的dom,初始化echarts實例
var colors = ['#0089FF','#B865DF',/*'#5ADF63','#FFDD00',*/'#224666', '#675bba'];
// 指定圖表的配置項和數(shù)據(jù)
option = {
/*grid:{
y:'25%'},*/
color: colors,
/* title: {
text: '各醫(yī)院指標(biāo)對比情況',
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)簽重疊的問題就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
- React項目搭建與Echarts工具使用詳解
- vue+echarts封裝氣泡圖的方法
- echarts 3D地圖為區(qū)域自定義顏色的解決方法
- 在vue中使用echarts實現(xiàn)上浮與下鉆效果
- 使用GetInvalidFileNameCharts生成文件名
- echarts餅圖扇區(qū)添加點擊事件的實例
- echarts餅圖指示器文字顏色設(shè)置不同實例詳解
- echarts餅圖各個板塊之間的空隙如何實現(xiàn)
- echarts實現(xiàn)餅圖與樣式設(shè)置
- echarts餅圖標(biāo)簽formatter使用及餅圖自定義標(biāo)簽
- 基于Echarts實現(xiàn)餅圖效果
- Vue ECharts餅圖實現(xiàn)方法詳解
- Echarts實現(xiàn)點擊列表聯(lián)動餅圖的示例代碼
相關(guān)文章
Python的Twisted框架上手前所必須了解的異步編程思想
Twisted是Python世界中人氣最高的framework之一,異步的工作模式使其名揚天下,這里為大家總結(jié)了Python的Twisted框架上手前所必須了解的異步編程思想,需要的朋友可以參考下2016-05-05
使用Python開發(fā)Excel表格數(shù)據(jù)對比工具
這篇文章主要為大家詳細介紹了如何通過 Python 和 PyQt5 結(jié)合 pandas 庫,快速實現(xiàn)一個高效、自動化的 Excel 數(shù)據(jù)對比工具,感興趣的小伙伴可以了解下2025-03-03
將本地Python項目打包成docker鏡像上傳到服務(wù)器并在docker中運行
Docker是一個開源項目,為開發(fā)人員和系統(tǒng)管理員提供了一個開放平臺,可以將應(yīng)用程序構(gòu)建、打包為一個輕量級容器,并在任何地方運行,這篇文章主要給大家介紹了關(guān)于將本地Python項目打包成docker鏡像上傳到服務(wù)器并在docker中運行的相關(guān)資料,需要的朋友可以參考下2023-12-12
Pytorch實現(xiàn)將label變成one hot編碼的兩種方式
這篇文章主要介紹了Pytorch實現(xiàn)將label變成one hot編碼的兩種方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02
python實現(xiàn)簡單溫度轉(zhuǎn)換的方法
這篇文章主要介紹了python實現(xiàn)簡單溫度轉(zhuǎn)換的方法,涉及Python操作字符串的技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-03-03

