Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix empty div container for annotation #3112

Merged
merged 3 commits into from
Dec 15, 2020
Merged

Conversation

lessmost
Copy link
Member

@lessmost lessmost commented Dec 14, 2020

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Description of change

修复问题:#3108

之前添加一个 html container 是为了修复 html annotation 没有清除掉,这里可以像其他 controller 一样,clear 的时候直接清除创建的组件就可以。

@github-actions
Copy link

github-actions bot commented Dec 14, 2020

😭 Deploy PR Preview d803fc1 failed. Build logs

🤖 By surge-preview

@coveralls
Copy link

coveralls commented Dec 14, 2020

Pull Request Test Coverage Report for Build 422209224

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.004%) to 93.441%

Files with Coverage Reduction New Missed Lines %
src/chart/controller/annotation.ts 5 94.47%
Totals Coverage Status
Change from base Build 414516866: -0.004%
Covered Lines: 10674
Relevant Lines: 11078

💛 - Coveralls

@hustcc
Copy link
Member

hustcc commented Dec 14, 2020

所有的 annotation 应该要放到一个 div 里面吧,不然和 g2-tooltip 平级的会有很多 annotation 的 div 吧~

@lessmost
Copy link
Member Author

所有的 annotation 应该要放到一个 div 里面吧,不然和 g2-tooltip 平级的会有很多 annotation 的 div 吧~

这个看你用了几个 html annotation,只有用到了才会渲染

@hustcc
Copy link
Member

hustcc commented Dec 14, 2020

所有的 annotation 应该要放到一个 div 里面吧,不然和 g2-tooltip 平级的会有很多 annotation 的 div 吧~

这个看你用了几个 html annotation,只有用到了才会渲染

比如有 4 个 annotation,应该层级也是 annotation 的容器中有 4 个子 div 吧,包括如果 html label,也是要放到一个统一的容器吧~不然太乱了。

@lgtm-com
Copy link

lgtm-com bot commented Dec 14, 2020

This pull request fixes 1 alert when merging 12603d4 into 82a206f - view on LGTM.com

fixed alerts:

  • 1 for Unused variable, import, function or class

@visiky
Copy link
Member

visiky commented Dec 14, 2020

可不可以保留部分之前的逻辑,但是在实际调用 html-annotation 的时候 再创建 div container,如果已有 直接放 annotation 进去,如果没有就直接创建;clear 的时候 也同步将这个容器删除

@lessmost
Copy link
Member Author

所有的 annotation 应该要放到一个 div 里面吧,不然和 g2-tooltip 平级的会有很多 annotation 的 div 吧~

这个看你用了几个 html annotation,只有用到了才会渲染

比如有 4 个 annotation,应该层级也是 annotation 的容器中有 4 个子 div 吧,包括如果 html label,也是要放到一个统一的容器吧~不然太乱了。

感觉没必要,维护这个层次只让代码复杂一点,本身好处是什么?

@hustcc
Copy link
Member

hustcc commented Dec 14, 2020

所有的 annotation 应该要放到一个 div 里面吧,不然和 g2-tooltip 平级的会有很多 annotation 的 div 吧~

这个看你用了几个 html annotation,只有用到了才会渲染

比如有 4 个 annotation,应该层级也是 annotation 的容器中有 4 个子 div 吧,包括如果 html label,也是要放到一个统一的容器吧~不然太乱了。

感觉没必要,维护这个层次只让代码复杂一点,本身好处是什么?

ok,好像确实是增加代码复杂度了。还需要销毁,创建容器。

hustcc
hustcc previously approved these changes Dec 14, 2020
@@ -147,7 +144,7 @@ export default class Annotation extends Controller<BaseOption[]> {

this.foregroundContainer.remove(true);
this.backgroundContainer.remove(true);
this.clearHTMLContainer(true);
// this.clearHTMLContainer(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个注释可以删除了

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已删除~

@lgtm-com
Copy link

lgtm-com bot commented Dec 15, 2020

This pull request fixes 1 alert when merging d803fc1 into 82a206f - view on LGTM.com

fixed alerts:

  • 1 for Unused variable, import, function or class

@hustcc hustcc self-requested a review December 15, 2020 04:15
@hustcc hustcc merged commit f373965 into master Dec 15, 2020
@hustcc hustcc deleted the fix-annotation-empty-div branch December 15, 2020 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants