Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【svg模式-bug】使用svg渲染模式绘制饼图时,label设置hide-overlap无效, label标签的效果还是重叠在一起了 #4200

Closed
wcm817 opened this issue Oct 12, 2022 · 4 comments

Comments

@wcm817
Copy link

wcm817 commented Oct 12, 2022

// 初始化
...
this.chart = new Chart({
container: config.id,
width: config.width,
height: config.height - 1,
padding: 20,
renderer: 'svg'
});
...
// 配置label
this.geometry
.label(
labelFeature,
{
offset: 8,
labelHeight: 38,
lineHeight: 24,
layout: [{ type: 'pie-spider' }, { type: 'hide-overlap' }],
....
})

@wcm817 wcm817 changed the title 请教一下,使用svg渲染模式绘制饼图时,label设置hide-overlap无效? 请教一下,使用svg渲染模式绘制饼图时,label设置hide-overlap无效, label标签的效果还是重叠在一起了 Oct 12, 2022
@wcm817 wcm817 changed the title 请教一下,使用svg渲染模式绘制饼图时,label设置hide-overlap无效, label标签的效果还是重叠在一起了 【svg模式-bug】使用svg渲染模式绘制饼图时,label设置hide-overlap无效, label标签的效果还是重叠在一起了 Oct 12, 2022
@wcm817
Copy link
Author

wcm817 commented Oct 12, 2022

直接复制了官网的案例改也是会重叠

import { Chart, Util } from '@antv/g2';

const data = [
{ type: '一线城市', value: 0.19 },
{ type: '二线城市', value: 0.21 },
{ type: '三线城市', value: 0.27 },
{ type: '四线及以下', value: 0.1 },
{ type: '五线及以下', value: 0.1 },
{ type: '六线及以下', value: 0.07 },
{ type: '七线及以下', value: 0.003 },
{ type: '八线及以下', value: 0.003 },
];
const chart = new Chart({
container: 'container',
autoFit: true,
height: 500,
renderer: 'svg'
});
chart.data(data);

chart.coordinate('theta', {
radius: 0.75
});
chart.tooltip({
showMarkers: false
});

const interval = chart
.interval()
.adjust('stack')
.position('value')
.color('type', ['#063d8a', '#1770d6', '#47abfc', '#38c060'])
.state({
active: {
style: (element) => {
const shape = element.shape;
return {
matrix: Util.zoom(shape, 1.1),
}
}
}
})
.label('type',{
style: {
opacity: 1,
fill: '#000',
fontSize: 12,
},
layout: [{type: 'pie-spider'},{ type: 'hide-overlap' }],
content: (obj) => {
return obj.type + '\n' + obj.value + '%';
},
});

chart.interaction('element-single-selected');

chart.render();

@hustcc
Copy link
Member

hustcc commented Oct 26, 2022

svg 下的碰撞目前有一些问题,想了解下你们是什么场景必须用 svg 吗?

@wcm817
Copy link
Author

wcm817 commented Nov 7, 2022 via email

@hustcc
Copy link
Member

hustcc commented Nov 14, 2022

主要是其他的画图我们都用了svg自己来画,不用canvas,饼图是借住了这个框架,所以也想统一弄成svg模式,canvas在ios系统测试中表现不是很稳定 在 2022-10-26 09:26:51,"hustcc" @.> 写道: svg 下的碰撞目前有一些问题,想了解下你们是什么场景必须用 svg 吗? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

是绘图产品中,需要加一些图表吗?如果少量简单图表,可以尝试使用 d3~

@hustcc hustcc closed this as completed Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants