echarts可视化数据展⽰饼图效果
男⼥饼图
initChart3() {
var option = {
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b}: {c} ({d}%)"
},
graphic:[
{
type:'text',
left:'center',  //位置
top:'25%',      //向下25%
style:{
text:'42%',
fill:'#4cfdf7',
width:30,
height:30,
fontSize:14,
}
},
{
type:'text',
left:'center',
top:'50%',
style:{
text:'58%',
fill:'#eff425',
width:30,
height:30,
fontSize:14,
}
},
],
legend: {                          //下⾯⼩按钮
orient: 'vertical',
x:'center',
y: 'bottom',
data: ['男', '⼥'],
icon:"circle",
textStyle:{
fontSize: 14,//字体⼤⼩
color: '#ffffff'//字体颜⾊
}
},
series: [
series: [
{
name:'签约⽼⼈',
type:'pie',
radius: ['70%', '58%'],
center: ['50%', '40%'],
avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
emphasis: {
show: true,
textStyle: {
fontSize: '18',
fontWeight: 'bold'
}
}
},
labelLine: {
normal: {
show: false
}
},
data:[  //饼图数据
{value:335, name:'男',itemStyle: { color: '#4cfdf7' } },                        {value:310, name:'⼥',itemStyle: { color: '#eff425' } },                    ]
}
]
};
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.ElementById("main3"));      // 使⽤刚指定的配置项和数据显⽰图表。
myChart.setOption(option);
},
年龄饼图:
initChart5() {
var option = {
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b}: {c} ({d}%)"
},
//饼图按钮
legend: [
{
icon : 'circle',  //按钮样式设置成圆的
textStyle : {
color : "#fff",
fontSize: 14,
},
data : [ '60-70岁', '70-80岁'],
x : '10%',
y: '80%',
},{
icon : 'circle',
textStyle : {
color : "#fff",
fontSize: 14,
},
data : [ '80-90岁', '90-100岁' ],
x : '10%',
y: '90%',
}
],
//圆环内⽂字
graphic:[{
type:'text',
left:'32%',
top:'27%',textstyle
style:{
text:'8%',
fill:'#eff425',
width:30,
height:30,
fontSize:14,
}
},{
type:'text',
left:'55%',
top:'27%',
style:{
text:'32%',
fill:'#a430ff',
width:30,
height:30,
fontSize:14,
}
},{
type:'text',
left:'32%',
top:'50%',
style:{
text:'18%',
fill:'#4cfdf7',
width:30,
height:30,
fontSize:14,
}
},
{
type:'text',
left:'55%',
top:'50%',
style:{
text:'42%',
fill:'#2a72eb',
width:30,
height:30,
fontSize:14,
}
},
],
series: [
{
name:'年龄占⽐',
type:'pie',
radius: ['70%', '58%'],
center: ['50%', '40%'], //圆环位置                avoidLabelOverlap: false,
label: {
normal: {
show: false,
position: 'center'
},
emphasis: {
show: true,
show: true,
textStyle: {
fontSize: '18',
fontWeight: 'bold'
}
}
},
labelLine: {
normal: {
show: false
}
},
data:[
{value:261, name:'60-70岁',itemStyle: { color: '#a430ff' } },                    {value:400, name:'70-80岁',itemStyle: { color: '#2a72eb' } },                    {value:130, name:'80-90岁',itemStyle: { color: '#4cfdf7' } },                    {value:70, name:'90-100岁',itemStyle: { color: '#eff425' } },                ]
}
]
};
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.ElementById("main5"));
// 使⽤刚指定的配置项和数据显⽰图表。
myChart.setOption(option);
},

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。