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(label): Charsets like Cyrillic should break work the same as Latin #17941

Closed
DmytroKondratiuk opened this issue Nov 18, 2022 · 3 comments · Fixed by ecomfe/zrender#973
Closed
Labels
bug en This issue is in English topic: label
Milestone

Comments

@DmytroKondratiuk
Copy link

Version

5.3.0+

Link to Minimal Reproduction

https://jsfiddle.net/nfaq68L2/

Steps to Reproduce

legend: {
      type: 'scroll',
      orient: 'vertical',
      right: '10%',
      top: 'middle',
      data: chartData,
      textStyle: {
        width: 300,
        overflow: 'break',
        verticalAlign: 'middle',
      },

Current Behavior

When I use ukraine language "overflow: 'break'" for pie series legend breaks by character instead of by word. For example word "цвітуть" must be at new line but on new line character "ь". When I use english language words breaks correct.
telegram-cloud-photo-size-2-5456387265736589518-y

Expected Behavior

overflow: 'break' for pie series legend should break by word.

Environment

- OS: Mac
- Browser: Chrome
- Framework: React

Any additional comments?

No response

@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels Nov 18, 2022
@Ovilia
Copy link
Contributor

Ovilia commented Nov 23, 2022

Currently, the breaking logic is to check if the letter is latin. Maybe this is not accurate. Any idea to improve this?

@DmytroKondratiuk
Copy link
Author

DmytroKondratiuk commented Nov 24, 2022

Hi
I had similar problem with tooltip. But for tooltip we can use css styles. I fixed this problem like this

    tooltip: {
          trigger: 'item',
          formatter: '{a}<p>{b} ({d}%)</p>',
          appendToBody: true,
          extraCssText: 'max-width: 300px; white-space: normal; overflow-wrap: normal;',
     },

If we could use css styles and formatter for legend like for tooltip it was great

Or we can check if charsets is Cyrillic. For Cyrillic charset codes is from 0x80 to 0xFF. So we can do like this:

  function isCyrillic(ch: string) {
      let code = ch.charCodeAt(0);
      return code >= 0x21 && code <= 0x17F;
  }

function isWordBreakChar(ch: string) {
    if (isLatin(ch) || isCyrillic(ch)) {
        if (breakCharMap[ch]) {
            return true;
        }
        return false;
    }
    return true;
}

I guess decision with css more flexible

@Ovilia
Copy link
Contributor

Ovilia commented Nov 24, 2022

isCyrillic seems to be a correct way to fix this. I will make a PR. @DmitriyKondratyuk Thanks!

@Ovilia Ovilia added this to the 5.5.0 milestone Nov 24, 2022
@plainheart plainheart added topic: label and removed pending We are not sure about whether this is a bug/new feature. labels Dec 7, 2022
@Ovilia Ovilia changed the title [Bug] overflow=break it breaks "by character" instead of "by word" for ukraine language fix: Charsets like Cyrillic should break work the same as Latin Feb 2, 2023
@Ovilia Ovilia modified the milestones: 5.5.0, 5.4.2 Mar 3, 2023
@Ovilia Ovilia changed the title fix: Charsets like Cyrillic should break work the same as Latin fix(label): Charsets like Cyrillic should break work the same as Latin Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English topic: label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants