-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the bug / 问题描述
import { Chart } from '@antv/g2';
const data = [
{
"change": 4132.26,
"name": "一部",
"dept_id": 11111111183,
"value": 76470.92
},
{
"change": 5324.41,
"name": "二部",
"dept_id": 11111111184,
"value": 60190.23
},
{
"change": 3303.82,
"name": "三部",
"dept_id": 11111111185,
"value": 24673.49
},
{
"change": 2346.96,
"name": "四部",
"dept_id": 11111111200,
"value": 27989.12
},
{
"change": 127.46,
"name": "五部",
"dept_id": 11111111213,
"value": 2217.67
},
];
const chart = new Chart({
container: 'container',
autoFit: true,
margin: 0,
paddingLeft: 0,
});
chart.coordinate({ type: 'theta', outerRadius: 0.8 });
chart
.interval()
.data(data)
.transform({ type: 'stackY' })
.encode('y', 'value')
.encode('color', 'name')
.legend('color',
{
position: "right",
layout: {
justifyContent: 'center',
},
size: 500,
itemWidth:250,
crossPadding: 34,
colPadding: 0,
rowPadding: 20,
itemMarker: "square",
itemMarkerSize: 6,
itemMarkerLineWidth: 4,
itemLabelFontSize: 14,
itemLabelLineHeight: 14,
itemLabelTextBaseline: "middle",
itemLabelFill: "#666",
itemValueText: (_d, index) => data[index].value,
itemValueFontSize: 12,
itemValueLineHeight: 12,
itemValueTextAlign: "end",
itemValueTextBaseline: "middle",
itemValueFill: "#333",
itemSpacing: [5, 25, 4],
poptip: {
render: (item) => 完整名称:${item.label} ,
offset: [0, 20],
},
})
.tooltip((data) => ({
name: data.name,
value: data.value,
}));
chart.render();
Reproduction link / 复现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
No response
Version / 版本
Please select / 请选择
OS / 操作系统
- macOS
- Windows
- Linux
- Others / 其他
Browser / 浏览器
- Chrome
- Edge
- Firefox
- Safari (Limited support / 有限支持)
- IE (Nonsupport / 不支持)
- Others / 其他