autoFit属性更新失效🐛 [BUG]
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 591
- PR merge metrics
- No merged PRs in 30d
Description
基础面积图,在我设置了aufoFit:true属性,同时设置了width、height属性的场景下,1s后我将autoFit变更为false,调用组件实例的update方法更新图表状态,此时它能正常工作,将图表渲染为指定宽高的效果。随后再1s后,将aufoFit变更为ture,此时它不在自动适应尺寸,而是始终保持固定宽高
问题可在官方示例上稳定复现:
如下为复现代码,在https://g2plot.antv.antgroup.com/examples/area/basic#basic 中粘贴下方代码可以看到问题现象
```ts
import { Area } from '@antv/g2plot';
let area = null;
fetch('https://gw.alipayobjects.com/os/bmw-prod/360c3eae-0c73-46f0-a982-4746a6095010.json')
.then((res) => res.json())
.then((data) => {
area = new Area('container', {
data,
xField: 'timePeriod',
yField: 'value',
width:30,
height:300,
autoFit: false,
xAxis: {
range: [0, 1],
},
});
area.render();
});
setInterval(() => {
const newConfig = {...area.options, ...{autoFit: !area.options.autoFit}}
area.update(newConfig);
}, 3000)
```
Contributor guide
Research direction
Reproduce the behavior in the official area basic example using the provided TypeScript code and the Area instance's update method. Trace how autoFit is applied when update toggles it between false and true; done means toggling back to true restores automatic sizing instead of retaining the fixed width and height.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100