Skip to content

Commit 551def1

Browse files
authored
Merge pull request #3553 from VisActor/fix/indicator-switch-visible
Fix/indicator switch visible
2 parents a8ed299 + d10c0db commit 551def1

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "fix: fix indicator when change visible to be false, fix #3506\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vchart"
7+
}
8+
],
9+
"packageName": "@visactor/vchart",
10+
"email": "[email protected]"
11+
}

packages/vchart/src/component/indicator/indicator.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,16 @@ export class Indicator<T extends IIndicatorSpec> extends BaseComponent<T> implem
209209
} as IndicatorAttributes;
210210
}
211211

212-
private _createOrUpdateIndicatorComponent(attrs: IndicatorAttributes): IndicatorComponents {
212+
private _createOrUpdateIndicatorComponent(attrs: IndicatorAttributes) {
213+
if (attrs.visible === false) {
214+
// 按照vrender-component 的设置,只切换visible: false,并不会更新组件,所以强制删掉节点
215+
if (this._indicatorComponent && this._indicatorComponent.parent) {
216+
this._indicatorComponent.parent.removeChild(this._indicatorComponent);
217+
}
218+
this._indicatorComponent = null;
219+
return;
220+
}
221+
213222
if (this._indicatorComponent) {
214223
if (!isEqual(attrs, this._cacheAttrs)) {
215224
this._indicatorComponent.setAttributes(attrs);
@@ -226,7 +235,6 @@ export class Indicator<T extends IIndicatorSpec> extends BaseComponent<T> implem
226235
);
227236
}
228237
this._cacheAttrs = attrs;
229-
return this._indicatorComponent;
230238
}
231239

232240
private _createText(

0 commit comments

Comments
 (0)