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(legend): fix dataItem undefined error #18390

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

roojay520
Copy link

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Fix LegendModel error when dataItem is undefined

Fixed issues

Details

Before: What was the problem?

The possibility of dataItem being empty was not taken into consideration here, and its name is directly retrieved:

image

image

After: How does it behave after the fixing?

Exclude empty dataItem and empty legend names.

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
Copy link
Contributor

Ovilia commented Mar 20, 2023

Hi. Thanks for your contribution. If this PR doesn't have a related issue to describe the problem, please provide an online link with Official Editor, CodePen, CodeSandbox or JSFiddle for the reviewer to understand the problem. Thanks!

@roojay520
Copy link
Author

roojay520 commented Mar 20, 2023

@Ovilia

This pr is to fixed the null error by this commit: 4fe4561

In the same option, v5.4.0 can display it while v5.4.1 cannot.

Echarts v5.4.0: https://codepen.io/roojay/pen/jOvvmQV
image

Echarts v5.4.1 is error: https://codepen.io/roojay/pen/MWqqmZo
image

Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution. I think we only have a small problem here.

src/component/legend/LegendModel.ts Outdated Show resolved Hide resolved
src/component/legend/LegendModel.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

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

The source code change looks good to me. Please add a case in https://github.com/apache/echarts/blob/master/test/legend.html

@roojay520
Copy link
Author

@Ovilia test case added.

@roojay520 roojay520 requested a review from Ovilia June 27, 2023 01:41
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.

None yet

3 participants