Skip to content

[Bug] Pie: selected slice x/y offset persists after setOption with fewer data items #21756

Description

@Motorhead-xXx

Version

6.1.0

Link to Minimal Reproduction

https://jsfiddle.net/ma_ss_ai/0kozdxfy/5/

Steps to Reproduce

  1. Open the JSFiddle link and Run. Ensure ECharts 6.1.0 is loaded (Resources → CDNJS → echarts 6.1.0).
  2. Click 1–2 pie sectors on the chart (not the legend). Slices move outward (selectedMode: 'multiple', selectedOffset: 10).
  3. Click "Apply filter (OLD — no unselect)". This calls setOption with fewer series[0].data items, { notMerge: true }, then resize(), without unselect and without resetting graphic x/y on slices.
  4. Observe the pie layout: fewer slices, series top/bottom may change; chart can look shifted or misaligned.

Current Behavior

After multi-select, selected slice graphic elements keep non-zero x/y translation when setOption replaces the dataset with fewer items (notMerge: true) and resize() is called.

The pie can appear shifted or misaligned relative to the series layout box. This is more visible when layout margins change (e.g. series top/bottom depend on slice count).

dispatchAction({ type: 'unselect', seriesIndex: 0 }) before setOption does not reset those graphic offsets. Resetting each slice graphic with attr({ x: 0, y: 0 }) before setOption fixes the layout.

Expected Behavior

After setOption with a new dataset, the pie is centered and sector positions match the new layout, with no leftover translation from the previous selection state.

Environment

- OS: macOS
- Browser: Chrome (latest)
- Framework: none (plain JS in JSFiddle; same issue observed in production with echarts 6.1.0 and echarts-for-react)

Any additional comments?

Repro flow mirrors a dashboard widget: multi-select pie sectors → filter data → setOption(notMerge) + resize.

Workaround used in our application:

chart.dispatchAction({ type: 'unselect', seriesIndex: 'all' }, { flush: true });
chart.getModel().getSeries().forEach((series) => {
series.getData().eachItemGraphicEl((el) => el?.attr({ x: 0, y: 0 }));
});
chart.setOption(newOption, { notMerge: true });
chart.resize();

Screenshot 1: Multi-select two pie sectors (C and E); slices move outward before filtering.

Image

Screenshot 2: After Apply filter (OLD — no unselect) with 2 slices — selected graphic offset persists; pie looks misaligned / fragmented.

Image

Screenshot 3 shows that Reset in the repro only calls dispatchAction(unselect) and setOption(full data); slices stay offset. Matches our finding that graphic x/y must be reset explicitly.

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions