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(pie): fix some labels may not show #20074

Merged
merged 2 commits into from
Jul 18, 2024
Merged

Conversation

liuyunzidian
Copy link

@liuyunzidian liuyunzidian commented Jun 25, 2024

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

#20070 Missing pie chart label display

Fixed issues

Details

Before: What was the problem?

When set option as:

option = {
  tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
  series: [
    {
      name: 'Access From',
      type: 'pie',
      radius: ['45%', '60%'],
      labelLine: { length: 30 },
      label: {
        formatter: '{a|{a}} {abg|}\n{hr|}\n {b|{b}:}{c} {per|{d}%} ',
        backgroundColor: '#F6F8FC',
        borderColor: '#8C8D8E',
        borderWidth: 1,
        borderRadius: 4,
        rich: {
          a: { color: '#6E7079', lineHeight: 22, align: 'center' },
          hr: {
            borderColor: '#8C8D8E',
            width: '100%',
            borderWidth: 1,
            height: 0
          },
          b: {
            color: '#4C5058',
            fontSize: 14,
            fontWeight: 'bold',
            lineHeight: 33
          },
          per: {
            color: '#fff',
            backgroundColor: '#4C5058',
            padding: [3, 4],
            borderRadius: 4
          }
        }
      },
      labelLayout: { hideOverlap: false },
      emphasis: { focus: 'self', blurScope: 'coordinateSystem' },
      data: [
        { value: 11048, name: 'Baidu' },
        { value: 1335, name: 'Direct' },
        { value: 310, name: 'Email' },
        { value: 251, name: 'Google' },
        { value: 234, name: 'Union Ads' },
        { value: 147, name: 'Bing' },
        { value: 135, name: 'Video Ads' },
        { value: 102, name: 'Others' },
        { value: 335, name: 'Direct1' },
        { value: 310, name: 'Email1' },
        { value: 251, name: 'Google1' },
        { value: 234, name: 'Union Ads1' },
        { value: 147, name: 'Bing1' },
        { value: 135, name: 'Video Ads1' },
        { value: 102, name: 'Others1' }
      ]
    }
  ]
};

Missing pie chart label display

image

After: How does it behave after the fixing?

This bug was caused here:
path: src/chart/pie/labelLayout.ts:92
code: const dx = Math.sqrt((1 - Math.abs(dy * dy / rB2)) * rA2);
In the calculation of dx, 1- Math.abs (dy * dy/rB2) * rA2 may be negative, Absolute values should be added here.
const dx = Math.sqrt(Math.abs((1 - Math.abs(dy * dy / rB2)) * rA2));

image

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

Copy link

echarts-bot bot commented Jun 25, 2024

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.

@plainheart plainheart changed the title fix(pie): Missing pie chart label display. close #20070 fix(pie): fix some labels may not show Jun 25, 2024
Copy link
Contributor

github-actions bot commented Jun 25, 2024

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-20074@403dce2

src/chart/pie/labelLayout.ts Outdated Show resolved Hide resolved
Copy link
Author

@liuyunzidian liuyunzidian left a comment

Choose a reason for hiding this comment

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

Modified

@liuyunzidian liuyunzidian requested a review from Ovilia July 9, 2024 09:48
@china-zoushuang
Copy link

We have the same issue. Could that commit to be merged ?

@Ovilia Ovilia merged commit 7a06637 into apache:master Jul 18, 2024
1 of 2 checks passed
Copy link

echarts-bot bot commented Jul 18, 2024

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

@Ovilia Ovilia added this to the 5.5.2 milestone Jul 18, 2024
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