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(bar-race): fix lines glitch with sub-pixel optimization in animations #14679 #17426

Merged
merged 11 commits into from
Aug 18, 2022

Conversation

Ovilia
Copy link
Contributor

@Ovilia Ovilia commented Jul 26, 2022

Brief Information

This pull request is in the type of:

  • bug fixing
  • [] new feature
  • others

What does this PR do?

Apache ECharts uses sub-pixel optimization on horizontal and vertical axes (including splitLines, ticks, and minorTicks) so that these lines should be drawn only at the positions like 10px, 10.5px, 11px for lines whose lineWidth is 1.

But for the case of bar-racing, this may cause the weried moving of split lines as reported in #14679 . So this PR disables sub-pixel optimization when in animation to solve the problem.

Fixed issues

#14679

Details

Before: What was the problem?

2022-07-26.14.59.10.mov

Pay attention to the red lines.

After: How does it behave after the fixing?

2022-07-26.15.00.34.mov

Document Info

One of the following should be checked.

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

  • Please squash the commits into a single one when merging.

Other information

@Ovilia Ovilia requested a review from pissang July 26, 2022 07:03
@echarts-bot echarts-bot bot added PR: author is committer PR: awaiting doc Document changes is required for this PR. PR: awaiting review labels Jul 26, 2022
@echarts-bot
Copy link

echarts-bot bot commented Jul 26, 2022

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

The pull request is marked to be PR: author is committer because you are a committer of this project.

Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the PR: awaiting doc label.

@pissang
Copy link
Contributor

pissang commented Jul 26, 2022

I think we can turn it off
automatically instead of configuring it manually. Users still need a sharp line on the static image after animation finished

@Ovilia
Copy link
Contributor Author

Ovilia commented Jul 27, 2022

@pissang Do you mean to turn it off when series.realtimeSort is true or always turn off? It may not be easy to turn it off when series.realtimeSort is true because the subPixelOptimize is under axis and in the axis it cannot know about which series are using it.

@pissang
Copy link
Contributor

pissang commented Jul 28, 2022

I meant disable it during animation and enable it when animation is done.

@Ovilia
Copy link
Contributor Author

Ovilia commented Aug 1, 2022

@pissang I'm not quite sure about if it's proper to make a done callback for group animations. Please help review again.
Also, current implementation doesn't consider the case when axis doesn't have animation. Should I check axisModel to get if there is animation and call setGroupSubPixelOptimize if not? This feels a little strange to me so I would like to hear about your opinion first and then make a thorough test.

@pissang
Copy link
Contributor

pissang commented Aug 3, 2022

I'm not quite sure about if it's proper to make a done callback for group animations

A more general solution is using a doneCount flag to check if all animations are done. But the current solution also looks good to me because all animation will be finished at the same time.

Should I check axisModel to get if there is animation and call setGroupSubPixelOptimize if not

This is not necessary. groupTransition will still call the done callback when animation is set to false.

@pissang
Copy link
Contributor

pissang commented Aug 3, 2022

In general I will give +1 on this PR.

pissang
pissang previously approved these changes Aug 3, 2022
test/gesture.html Outdated Show resolved Hide resolved
@Ovilia
Copy link
Contributor Author

Ovilia commented Aug 4, 2022

2022-08-04.15.46.59.mov

I found a small shaking of the axisLine when legend is toggled. Is this acceptable?

@pissang
Copy link
Contributor

pissang commented Aug 4, 2022

@Ovilia I think it will be better to fix it. Seems it's because the animation will still perform even if the axis lines are exactly the same. We can do a further check if the points of lines are changed and still set subPixelOptimize to true if they are not changed.

@Ovilia
Copy link
Contributor Author

Ovilia commented Aug 8, 2022

@pissang I added the logic so that done callback is called if old or new group doesn't exist in groupTransition. Should I also traverse and check if g1 and g2 are the same? If so, done should be called and return before further logic. One concern is, with zrender animation, if an element is set with the same attribute, the done is still called after the duration, rather than instantly. So I guess it's not a good idea to call done instantly in groupTransition.

Other way to fix this is before calling graphic.groupTransition, I first traverse the group to check if anything changes and call graphic.setGroupSubPixelOptimize(this._axisGroup, true) and skip graphic.groupTransition if the group doesn't change, right?

src/util/graphic.ts Outdated Show resolved Hide resolved
@pissang
Copy link
Contributor

pissang commented Aug 15, 2022

Sorry for the late reply.

Other way to fix this is before calling graphic.groupTransition, I first traverse the group to check if anything changes and call graphic.setGroupSubPixelOptimize(this._axisGroup, true) and skip graphic.groupTransition if the group doesn't change, right?

What I thought was this way. Because the logic to toggle the subPixelOptimize flag is outside of the groupTransition method. Whether to skip it should also not affect this method.

src/component/axis/CartesianAxisView.ts Show resolved Hide resolved
src/component/axis/CartesianAxisView.ts Show resolved Hide resolved
src/util/graphic.ts Outdated Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/M and removed size/L labels Aug 16, 2022
src/component/axis/AxisBuilder.ts Outdated Show resolved Hide resolved
@Ovilia Ovilia merged commit f2e8379 into master Aug 18, 2022
@echarts-bot
Copy link

echarts-bot bot commented Aug 18, 2022

Congratulations! Your PR has been merged. Thanks for your contribution! 👍

@Ovilia Ovilia deleted the fix-subpixel branch August 18, 2022 07:16
@Ovilia Ovilia added this to the 5.4.0 milestone Sep 8, 2022
@echarts-bot
Copy link

echarts-bot bot commented Sep 16, 2022

⚠️ MISSING DOCUMENT INFO: Please make sure one of the document options are checked in this PR's description. Search "Document Info" in the description of this PR. This should be done either by the author or the reviewers of the PR.

@echarts-bot echarts-bot bot added PR: doc unchanged and removed PR: awaiting doc Document changes is required for this PR. labels Sep 16, 2022
@Ovilia Ovilia changed the title feat(bar-race): provide subPixelOptimize option to solve #14679 fix(bar-race): fix lines glitch with sub-pixel optimization in animations #14679 Sep 16, 2022
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.

3 participants