python画饼图存在的问题_解决echarts中饼图标签重叠的问题

博客介绍了Echarts中饼图的avoidLabelOverlap属性,该属性用于防止标签重叠,当设置为true时会调整标签位置。同时展示了如何在Echarts柱状图中实现使用两个不同单位的Y轴,详细代码示例提供了实现方式。
摘要由CSDN通过智能技术生成

饼图中的series有个avoidLabelOverlap属性,

avoidLabelOverlap:是否启用防止标签重叠策略,默认开启,在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠。

当avoidLabelOverlap设置为false时会出现以下情况

2020051618061597.jpg

改为true之后就不会重叠

2020051618061599.jpg

代码如下

var option = {

tooltip: {

trigger: "item",

formatter: "{a}
{b} : {c} ({d}%)"

},

legend: {

//orient: "vertical",

x: "0%",

//y: "25%",

//y: "5%",

itemWidth: 14,

itemHeight: 14,

align: "left",

data: xData,

textStyle: {

color: "#fff"

}

},

series: [

{

name: "危险源状态",

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柱状图轻松实现分别采用两个不同单位的y轴

echarts柱状图轻松实现分别采用两个不同单位的y轴:

2020051618061601.jpg

秘籍:

2020051618061603.jpg

代码

// 基于准备好的dom,初始化echarts实例

var colors = ['#0089FF','#B865DF',/*'#5ADF63','#FFDD00',*/'#224666', '#675bba'];

// 指定图表的配置项和数据

option = {

/*grid:{

y:'25%'},*/

color: colors,

/* title: {

text: '各医院指标对比情况',

left: 16,

textStyle: {

fontSize: 18,

color:'#0089FF'

}

},*/

tooltip: {

trigger: 'axis',

axisPointer: {

type: 'cross',

crossStyle: {

color: '#999'

}

}

},

legend: {

data:['组数','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: '组数整体指标',

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:'组数',

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中饼图标签重叠的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持WEB开发者。

123.jpg

扫描关注:"WEB开发者网“公众号,分享WEB开发知识,让开发变得更简单!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值