From 871cb466e7c18e9517add9fa48be12b735d3cb55 Mon Sep 17 00:00:00 2001 From: xiaoluoHe Date: Tue, 7 Jan 2025 14:46:31 +0800 Subject: [PATCH 1/2] fix: fix duplicate label issue after custom filtering with label datafilter --- packages/vrender-components/src/label/base.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/vrender-components/src/label/base.ts b/packages/vrender-components/src/label/base.ts index 918a90e5e..8e1c79c94 100644 --- a/packages/vrender-components/src/label/base.ts +++ b/packages/vrender-components/src/label/base.ts @@ -182,6 +182,12 @@ export class LabelBase extends AbstractComponent { data = dataFilter(data); } + if (data && data.length) { + // 数据保护,防止重复 id 造成不可预知的问题 + const seenIds = new Set(); + data = data.filter(d => !seenIds.has(d.id) && seenIds.add(d.id)); + } + let labels: (IText | IRichText)[] = this._initText(data); if (isFunction(customLayoutFunc)) { From 67f3537db2be1801fabbba6c7fac160d60bc5b09 Mon Sep 17 00:00:00 2001 From: xiaoluoHe Date: Tue, 7 Jan 2025 14:47:31 +0800 Subject: [PATCH 2/2] docs: add changelog --- .../fix-duplicated-label-id_2025-01-07-06-46.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@visactor/vrender-components/fix-duplicated-label-id_2025-01-07-06-46.json diff --git a/common/changes/@visactor/vrender-components/fix-duplicated-label-id_2025-01-07-06-46.json b/common/changes/@visactor/vrender-components/fix-duplicated-label-id_2025-01-07-06-46.json new file mode 100644 index 000000000..592dab035 --- /dev/null +++ b/common/changes/@visactor/vrender-components/fix-duplicated-label-id_2025-01-07-06-46.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vrender-components", + "comment": "fix: fix duplicate label issue after custom filtering with label dataFilter", + "type": "none" + } + ], + "packageName": "@visactor/vrender-components" +} \ No newline at end of file