Skip to content

Commit

Permalink
Merge pull request #1667 from VisActor/fix/duplicated-label-id
Browse files Browse the repository at this point in the history
Fix: duplicated label
  • Loading branch information
neuqzxy authored Jan 10, 2025
2 parents 672210a + 67f3537 commit 9562c1d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
6 changes: 6 additions & 0 deletions packages/vrender-components/src/label/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ export class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {
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)) {
Expand Down

0 comments on commit 9562c1d

Please sign in to comment.