Echarts 环形图多层嵌套如何实现?
本文主要分解展示环形图多层嵌套的一些option配置项,希望能帮到您!
如图:
多层环形图本质就是多个饼图(圆),然后 分别给不同的饼图设置不同样式;具体实现要结合项目需求。
直接上代码:
option = {
// 鼠标悬浮不显示数据提示框
tooltip: {
trigger: 'item',
show:true,
formatter: '{b} </br> 占比{d}%'
},
// 富文本显示中间文字
title:{
text: '{a|1000}\n{c|数量统计}',
textStyle: {
color: "#fff",
fontWeight: '100',
fontFamily:'PingFang',
rich: {
a: {
fontSize: "30",
fontFamily:'PangMenZhengDao' ,
color: '#D8E9FF',
padding: [20,1,33,60]
},
c: {
fontSize: 20,
lineHeight: 35,
color: '#D8E9FF',
padding: [0,0,0,60]
}
}
},
x: "20%",
y: "center"
},
color: [
new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "#4A66C3 " },
{ offset: 1, color: "#5A80FA " }
]),
new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "#15A0E6" },
{ offset: 1, color: "#0B6ECE" }
]),
new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "#5BB1BC" },
{ offset: 1, color: "#358C9C" }
]),
new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "#8D98CC" },
{ offset: 1, color: "#616BA6" }
]),
new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "#EDE00E" },
{ offset: 1, color: "#D6BD06" }
]),
new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "#F6B14C" },
{ offset: 1, color: "#FC8A33" }
]),
new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "#E87C5A" },
{ offset: 1, color: "#DA5E46" }
])
],
// 图例位置
legend: {
top:'26%',
right: '20%',
orient : 'vertical',
icon: "rect",
itemHeight: 12,
itemGap:30,
textStyle: { //图例⽂字的样式
color: '#BACEE3',
fontSize: 14
},
},
series: [
{
name: '占比',
type: 'pie',
radius: ['45%', '65%'],
center:['30%','50%'],
avoidLabelOverlap: true,
emphasis: {
label: {
show: false,
fontSize: '20',
fontFamily:'PingFang',
}
},
label: {
color: '#D8E9FF',
fontFamily:'PingFang',
normal:{
show:false,
position:'center',
formatter: '{b} : {c}' , // 标签内容
},
},
labelLine: {
lineStyle: {
color: 'rgba(255, 255, 255, 0)'
},
smooth: 0.2,
length: 10,
length2: 20
},
itemStyle: {
shadowBlur: 0,
shadowColor: 'rgba(255, 255, 255)'
},
data:[
{ name: '苹果',value: 12},
{ name: '香蕉',value: 13 },
{ name: '橘子',value: 15},
{ name: '榴莲',value: 20 },
{ name: '山竹',value: 15 },
{ name: '哈密瓜',value: 10 },
{ name: '三华李',value: 8 }
],
// 初始化echarts的动画效果
animationType: 'scale',
animationEasing: 'elasticOut',
animationDelay: function (idx) {
return Math.random() * 200;
}
},
{
name:'中心圆',
radius: ['0%', '38%'],
center: ['30%', '50%'],
type: 'pie',
color:"#ffb980", //内圆颜色
label: {
normal: {
show: false
},
emphasis: {
show: false
}
},
labelLine: {
normal: {
show: false
},
emphasis: {
show: false
}
},
animation: false,
tooltip: {
show: false
},
data: [{
value: 1,
}],
},
{
name: '外边框',
type: 'pie',
clockWise: false, //顺时加载
hoverAnimation: false, //鼠标移入变大
center: ['30%', '50%'],
radius: ['73%', '73%'],
label: {
normal: {
show: false
}
},
data: [{
value: 9,
name: '',
itemStyle: {
normal: {
borderWidth: 2,
borderColor: '#2ec7c9'
}
}
}]
},
]
}
1212

被折叠的 条评论
为什么被折叠?



