VisActor / VisActor/VChart

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

Open
#4,088 0 comments 0 reactions 1 assignee View on GitHub

@xuefei1313 is already working on this.

Since Jul 25, 2025.

bug
Dominant language
TypeScript
Stars
1.8k
Forks
221
Avg merge
1d 6h
Merged PRs (30d)
26

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.