Skip to content

fix(linear-gradient): avoid the infinite value in linearMap util.#14602

Merged
pissang merged 5 commits into
masterfrom
fix-linear-gradient
Apr 25, 2021
Merged

fix(linear-gradient): avoid the infinite value in linearMap util.#14602
pissang merged 5 commits into
masterfrom
fix-linear-gradient

Conversation

@plainheart
Copy link
Copy Markdown
Member

@plainheart plainheart commented Apr 7, 2021

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Fix a bug that the chart cannot be rendered for Infinite value, fix #7293, #14534, #14601.

Fixed issues

Details

Before: What was the problem?

The chart cannot be rendered since the error below,

Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': The provided double value is non-finite

After: How is it fixed in this PR?

Usage

Are there any API changes?

  • The API has been changed.

Related test cases or examples to use the new APIs

Please refer to test/linear-gradient.html.

Others

Merging options

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

Other information

Related PR in zrender: ecomfe/zrender#748

@echarts-bot
Copy link
Copy Markdown

echarts-bot Bot commented Apr 7, 2021

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.

@pissang pissang added this to the 5.1.1 milestone Apr 8, 2021
@pissang
Copy link
Copy Markdown
Contributor

pissang commented Apr 8, 2021

@plainheart I think linearMap(Infinity, domain, range) has Infinity result is reasonable.

We can clamp it if we want to limit it in the range: linearMap(Infinity, domain, range, true). Or validate it before using it as coord of gradient. In this case, validation seems better.

@plainheart
Copy link
Copy Markdown
Member Author

plainheart commented Apr 10, 2021

@pissang For the case in #14534, it seems to differ from the case in #14601, some changes may need to be applied to zrender.

When all values of the line series are null, the width and height of the computed bounding rectangle of area polygon will both be infinite, which makes the gradient color can't be drawn.

@pissang
Copy link
Copy Markdown
Contributor

pissang commented Apr 15, 2021

@plainheart Sorry for the late reply. I agree use Infinity width and height in bounding rect is a bad idea when there is data in the polygon. It should all be 0.

@pissang pissang modified the milestones: 5.1.1, 5.1.2 Apr 22, 2021
@pissang pissang merged commit 4eeeccc into master Apr 25, 2021
@echarts-bot
Copy link
Copy Markdown

echarts-bot Bot commented Apr 25, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment