Skip to content

[Bug] 环形图,在设置emptyPlaceholder后,当设置了初始数据值,调用updateData更新数据,图表未渲染 #3855

@AdoneZ

Description

@AdoneZ

Version

1.13.7

Link to Minimal Reproduction

https://codesandbox.io/p/sandbox/dark-morning-v2h7pn

Steps to Reproduce

1. 配置

const spec: IPieChartSpec = {
  type: "pie",
  data: [
    {
      id: "id0",
      values: [
        { type: "数据1", value: 0 },
        { type: "数据2", value: 0 },
      ],
    },
  ],
  outerRadius: 0.8,
  innerRadius: 0.5,
  padAngle: 0.6,
  valueField: "value",
  categoryField: "type",
  padding: 0,
  background: "rgba(0, 0, 0, 0)",
  animationAppear: false,
  pie: {
    style: {
      cornerRadius: 10,
    },
    state: {
      hover: {
        outerRadius: 0.85,
        stroke: "#000",
        lineWidth: 1,
      },
      selected: {
        outerRadius: 0.85,
        stroke: "#000",
        lineWidth: 1,
      },
    },
  },
  legends: {
    visible: true,
    orient: "right",
  },
  label: {
    visible: false,
    layout: {
      strategy: "priority",
      tangentConstraint: true,
    },
    position: "inside",
  },
  tooltip: {
    mark: {
      content: [
        {
          key: (datum) => datum["type"],
          value: (datum) => datum["value"] + "个",
        },
      ],
    },
  },
  animation: false,
  emptyPlaceholder: {
    showEmptyCircle: true,
    emptyCircle: {
      style: {
        fill: "#f0f0f0",
      },
    },
  },
};

2. 调用以下方法更新代码无反应

function handleUpdateData() {
  vchart.updateData("id0", [
    { type: "数据1", value: 1 },
    { type: "数据2", value: 0 },
  ]);
}

Current Behavior

情况有两种,环形图,在设置emptyPlaceholder的情况下

  1. 当数据中初始数据值均为0时,调用updateData更新数据,图表不会渲染
  2. 当数据中初始数据不为0时,调用updateData把所有数据更新为0时,不会回到emptyPlaceholder. emptyCircle. style. fill的色值,而会变成主题色中的一个色值

Expected Behavior

环形图,在设置emptyPlaceholder的情况下

  1. 当数据中初始数据值均为0时,调用updateData更新数据,图表正常渲染数据
  2. 当数据中初始数据不为0时,调用updateData把所有数据更新为0时,图表圆环颜色回到emptyPlaceholder. emptyCircle. style. fill色值

Environment

- OS:macOS Sequoia
- Browser: Chrome 134.0.6998.89
- Framework: Vue@3

Any additional comments?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions