分面图在图例切换时,x轴无需隐藏,没有数据的分面隐藏
- Dominant language
- TypeScript
- Stars
- 12.6k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
**问题**
分面图在图例切换时
1. x轴无需隐藏
2. 没有数据的分面隐藏
**操作流程:**
渲染 - 点击图例去掉图例4的数据,再选中图例4的数据,y轴变化
**测试数据**
```import { Chart } from "@antv/g2";
const chart = new Chart({ container: "container" });
chart.options({
type: "facetRect",
width: 928,
height: 640,
paddingLeft: 60,
paddingBottom: 60,
data: [
{ series: "1", x: 10, y: 8.04 },
{ series: "1", x: 8, y: 6.95 },
{ series: "1", x: 13, y: 7.58 },
{ series: "1", x: 9, y: 8.81 },
{ series: "1", x: 11, y: 8.33 },
{ series: "1", x: 14, y: 9.96 },
{ series: "1", x: 6, y: 7.24 },
{ series: "1", x: "4", y: 4.26 },
{ series: "1", x: 12, y: 10.84 },
{ series: "1", x: 7, y: 4.81 },
{ series: "1", x: 5, y: 5.68 },
{ series: "2", x: 10, y: 9.14 },
{ series: "2", x: 8, y: 8.14 },
{ series: "2", x: 13, y: 8.74 },
{ series: "2", x: 9, y: 8.77 },
{ series: "2", x: 11, y: 9.26 },
{ series: "2", x: 14, y: 8.1 },
{ series: "2", x: 6, y: 6.13 },
{ series: "2", x: "4", y: 3.1 },
{ series: "2", x: 12, y: 9.13 },
{ series: "2", x: 7, y: 7.26 },
{ series: "2", x: 5, y: 4.74 },
{ series: "3", x: 10, y: 7.46 },
{ series: "3", x: 8, y: 6.77 },
{ series: "3", x: 13, y: 12.74 },
{ series: "3", x: 9, y: 7.11 },
{ series: "3", x: 11, y: 7.81 },
{ series: "3", x: 14, y: 8.84 },
{ series: "3", x: 6, y: 6.08 },
{ series: "3", x: "4", y: 5.39 },
{ series: "3", x: 12, y: 8.15 },
{ series: "3", x: 7, y: 6.42 },
{ series: "3", x: 5, y: 5.73 },
{ series: "4", x: 8, y: 6.58 },
{ series: "4", x: 8, y: 5.76 },
{ series: "4", x: 8, y: 7.71 },
{ series: "4", x: 8, y: 8.84 },
{ series: "4", x: 8, y: 8.47 },
{ series: "4", x: 8, y: 7.04 },
{ series: "4", x: 8, y: 5.25 },
{ series: "4", x: 19, y: 5.5 },
{ series: "4", x: 8, y: 5.56 },
{ series: "4", x: 8, y: 7.91 },
{ series: "4", x: 8, y: 6.89 },
],
encode: { y: "series", color: "series" },
children: [
{
type: "point",
frame: false,
inset: 10,
encode: { x: "x", y: "y", color: "series" },
scale: {
y: { type: "linear", clamp: true, nice: true, independent: true, facet: false },
},
style: { stroke: "#000" },
axis: { y: () => true },
viewStyle: { plotStroke: "red", plotLineWidth: 2, plotOpacity: 0.5 },
},
],
});
chart.render();
```
正常表现截图:

不达预期截图:

Contributor guide
Research direction
Start with the provided TypeScript reproduction at the Chart construction and chart.render() entry points. Inspect facetRect behavior when legend data is removed and restored, focusing on x-axis visibility and facets with no remaining data. Done means the x-axis stays visible and empty facets are hidden while y-axis behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 43/100