antvis/G2

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

wcm817 posted onGitHub

// 初始化 ... 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' }], .... })


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

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();

posted by wcm817 over 2 years ago

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

posted by hustcc over 2 years ago

主要是其他的画图我们都用了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: @.***>

posted by wcm817 over 2 years ago

主要是其他的画图我们都用了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~

posted by hustcc over 2 years ago

Fund this Issue

$0.00
Funded

Pull requests