VChart icon indicating copy to clipboard operation
VChart copied to clipboard

[Bug] `setSelected` not work after `updateSpec`

Open xiaoluoHe opened this issue 5 months ago • 0 comments

Version

1.x & 2.x

Link to Minimal Reproduction

none

Steps to Reproduce

const spec = {
  type: 'bar',
  data: [
    {
      id: 'barData',
      values: [
        { month: 'Monday', sales: 22 },
        { month: 'Tuesday', sales: 13 },
        { month: 'Wednesday', sales: 25 },
        { month: 'Thursday', sales: 29 },
        { month: 'Friday', sales: 38 }
      ]
    }
  ],
  xField: 'month',
  yField: 'sales',
  bar:{
    state:{
      selected:{
        fill:"red"
      }
    }
  }
};
const newSpec = {
  ...spec,
  axes:[
    {orient:"left", grid: {visible: false}}
  ]
}

const data = { month: 'Monday', sales: 22 };

const vchart = new VChart(spec, { dom: CONTAINER_ID });
vchart.renderSync();

// 先设置选中
setTimeout(() => {
  vchart.setSelected(data)
}, 1000);

// 再更新 spec
setTimeout(() => {
  vchart.updateSpec(newSpec)
}, 2000)

// 最后清除选中
setTimeout(() => {
  vchart.setSelected(null)
}, 2000)


// Just for the convenience of console debugging, DO NOT COPY!
window['vchart'] = vchart;

Current Behavior

柱子取消选中没生效

Image

Expected Behavior

正确取消选中

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

xiaoluoHe avatar Jul 17 '25 03:07 xiaoluoHe