Skip to content

Commit

Permalink
fix(#2232): fix 当 legend item 点击的时候, 图例项变少
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc authored and simaQ committed Apr 3, 2020
1 parent c35b848 commit 19ca46f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/chart/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ export class View extends Base {
// 3. 初始化 Geometry
this.initGeometries(isUpdate);
// 4. 处理分面逻辑,最终都是生成子 view 和 geometry
this.renderFacet();
this.renderFacet(isUpdate);

// 同样递归处理子 views
each(this.views, (view: View) => {
Expand Down Expand Up @@ -1720,14 +1720,19 @@ export class View extends Base {

/**
* 渲染分面,会在其中进行数据分面,然后进行子 view 创建
* @param isUpdate
*/
private renderFacet() {
private renderFacet(isUpdate: boolean) {
if (this.facetInstance) {
this.facetInstance.clear();
// 计算分面数据
this.facetInstance.init();
// 渲染组件和 views
this.facetInstance.render();
if (isUpdate) {
this.facetInstance.update();
} else {
this.facetInstance.clear();
// 计算分面数据
this.facetInstance.init();
// 渲染组件和 views
this.facetInstance.render();
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/facet/facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ export abstract class Facet<C extends FacetCfg<FacetData> = FacetCfg<FacetData>,
this.renderViews();
}

/**
* 更新 facet
*/
public update() {
// 其实不用做任何事情,因为 facet 最终生成的 View 和 Geometry 都在父 view 的更新中处理了
}

/**
* 清空,clear 之后如果还需要使用,需要重新调用 init 初始化过程
* 一般在数据有变更的时候调用,重新进行数据的分面逻辑
Expand Down

0 comments on commit 19ca46f

Please sign in to comment.