我想实现的是这种效果,也是官网的例子
可是我显示出来的效果标签和图形重叠了,如何解决?
这是我的代码:
option.title = {
text: '121312', // 主标题文本
subtext: '发薪总额', // 副标题文本
left: 'center',
top: '38%',
textStyle: {
fontSize: 18,
color: '#454c5c',
align: 'center'
},
subtextStyle: {
fontFamily: '微软雅黑',
fontSize: 14,
color: '#6c7a89'
}
}
option.series[0].type = 'pie'
option.series[0].radius = [40, 60]
option.series[0].itemStyle = {
borderColor: '#fff',
borderWidth: 1
}
option.series[0].labelLine = {
length: 15,
length2: 0,
maxSurfaceAngle: 80
}
option.series[0].label = {
alignTo: 'edge',
formatter: '{name|{b}}\n{time|{c} 小时}',
minMargin: 5,
edgeDistance: 10,
lineHeight: 15,
rich: {
time: {
fontSize: 10,
color: '#999'
}
}
}
option.series[0].labelLayout = function (params) {
const isLeft = params.labelRect.x < myChart.getWidth() / 2
const points = params.labelLinePoints
// Update the end point.
points[2][0] = isLeft
? params.labelRect.x
: params.labelRect.x + params.labelRect.width
return {
labelLinePoints: points
}
}
option.series[0].data = [
{ value: 1048, name: 'Search Engine' },
{ value: 735, name: 'Direct' },
{ value: 580, name: 'Email' },
{ value: 484, name: 'Union Ads' },
{ value: 320, name: 'sdfsdf' }
]
解决了,是因为echarts版本问题,我从4.9升级到5.4就没问题了
升级到