[Bug]: 图例与正图中的点 shape 不一致
Author: yihuiCreated Apr 1, 2026Updated Apr 30, 2026
Labelswaiting for maintainerresolved pending release
Describe the bug / 问题描述
数据点只有形状映射时,目前图例中点的形状与正图不一致。
Reproduction link / 复现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
可重复例子如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://unpkg.com/@antv/g2@5/dist/g2.min.js" defer></script>
</head>
<body>
<div id="gglite-1775072089-714683"></div>
<script type="module">
const chart = new G2.Chart({
"width": 640,
"height": 480,
"autoFit": true,
"container": "gglite-1775072089-714683"
});
chart.options({
"data": [{
"x": 1,
"y": 2,
"z": "point"
}, {
"x": 2,
"y": 3,
"z": "plus"
}, {
"x": 3,
"y": 4,
"z": "diamond"
}],
"children": [
{
"type": "point",
"encode": {
"x": "x",
"y": "y",
"shape": "z",
"size": 10
},
}
],
});
chart.render();
</script>
</body>
</html>可以看到图中用的是圆圈、菱形、六边形,而图例显示的却是正方形、上三角、下三角:
这个问题在加上 color: "z" 映射后会消失,上色的点不存在图例和图不匹配的问题:
或者强行指定 scale:
"scale": {
"shape": {
"range": ["point", "plus", "diamond"]
}
}我觉得这应该是个明显的 bug。数据点只有形状映射时,图例中的形状应该与图保持一致。
Version / 版本
5.x
OS / 操作系统
- macOS
- Windows
- Linux
- Others / 其他
Browser / 浏览器
- Chrome
- Edge
- Firefox
- Safari (Limited support / 有限支持)
- IE (Nonsupport / 不支持)
- Others / 其他
Source: antvis/G2