AntV G2Plot 玫瑰图标签属性配置详解
在 AntV G2Plot 中,玫瑰图的'label' 属性用于设置标签相关的配置,包括标签的位置、颜色、字体大小等。
常用的'label' 属性有:
- 'position':标签位置,可选值为'inner'、'outer'、'center',默认为'outer'。
- 'offset':标签位置的偏移量,可以是一个数字或者一个数组,例如'[20, 30]',默认为 0。
- 'style':标签文本样式配置,包括颜色、字体大小、字体粗细等。
- 'autoRotate':是否自动旋转标签,可选值为'true'、'false',默认为'true'。
示例代码:
const data = [
{ type: 'A', value: 50 },
{ type: 'B', value: 25 },
{ type: 'C', value: 15 },
{ type: 'D', value: 10 },
];
const plot = new G2Plot.Rose('container', {
data,
radiusField: 'value',
categoryField: 'type',
label: {
position: 'inner',
offset: 10,
style: {
fill: '#fff',
fontSize: 12,
fontWeight: 'bold',
},
autoRotate: false,
},
});
plot.render();
原文地址: https://www.cveoy.top/t/topic/lUQV 著作权归作者所有。请勿转载和采集!