antvis / G2Plot

:dango: An interactive and responsive charting library based on G2.
https://g2plot.antv.antgroup.com
MIT License
2.55k stars 605 forks source link

autoFit属性更新失效🐛 [BUG] #3734

Open xiaopujun opened 8 months ago

xiaopujun commented 8 months ago

基础面积图,在我设置了aufoFit:true属性,同时设置了width、height属性的场景下,1s后我将autoFit变更为false,调用组件实例的update方法更新图表状态,此时它能正常工作,将图表渲染为指定宽高的效果。随后再1s后,将aufoFit变更为ture,此时它不在自动适应尺寸,而是始终保持固定宽高

问题可在官方示例上稳定复现:

如下为复现代码,在https://g2plot.antv.antgroup.com/examples/area/basic#basic 中粘贴下方代码可以看到问题现象

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)