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

图例设置 maxItemWidth 后 value 一直被省略且没有 tip #3908

Closed
1 task done
maplor opened this issue May 10, 2022 · 2 comments
Closed
1 task done

图例设置 maxItemWidth 后 value 一直被省略且没有 tip #3908

maplor opened this issue May 10, 2022 · 2 comments

Comments

@maplor
Copy link
Contributor

maplor commented May 10, 2022

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

legend 设置 itemValue 和 maxItemWidth。
当图例比较宽时,itemName 正常省略且鼠标 hover 有 tip,itemValue 一直被省略且无 tip。

具体可见上方链接。https://codesandbox.io/s/happy-andras-876d5s?file=/index.ts

Environment Info
g2 4.2.0
System -
Browser -
@maplor maplor changed the title 图例设置 maxItemWidht 后 value 一直被省略且没有 tip 图例设置 maxItemWidth 后 value 一直被省略且没有 tip May 10, 2022
@visiky
Copy link
Member

visiky commented May 23, 2022

需要注册交互:

registerInteraction('ellipsis-text', {
  start: [
    {
      trigger: 'legend-item-name:mousemove',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
    {
      trigger: 'legend-item-name:touchstart',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
    {
      trigger: 'axis-label:mousemove',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
    {
      trigger: 'axis-label:touchstart',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
  ],
  end: [
    { trigger: 'legend-item-name:mouseleave', action: 'ellipsis-text:hide' },
    { trigger: 'legend-item-name:touchend', action: 'ellipsis-text:hide' },
    { trigger: 'axis-label:mouseleave', action: 'ellipsis-text:hide' },
    { trigger: 'axis-label:touchend', action: 'ellipsis-text:hide' },
  ],
});

内置没有为 legend-item-value 注册交互,复写一下这个交互就行,如下:

registerInteraction('ellipsis-text', {
  start: [
    {
      trigger: 'legend-item-name:mousemove',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
    {
      trigger: 'legend-item-name:touchstart',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
    {
      trigger: 'legend-item-value:mousemove',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
    {
      trigger: 'legend-item-value:touchstart',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
    {
      trigger: 'axis-label:mousemove',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
    {
      trigger: 'axis-label:touchstart',
      action: 'ellipsis-text:show',
      throttle: { wait: 50, leading: true, trailing: false },
    },
  ],
  end: [
    { trigger: 'legend-item-name:mouseleave', action: 'ellipsis-text:hide' },
    { trigger: 'legend-item-name:touchend', action: 'ellipsis-text:hide' },
    { trigger: 'legend-item-value:mouseleave', action: 'ellipsis-text:hide' },
    { trigger: 'legend-item-value:touchend', action: 'ellipsis-text:hide' },
    { trigger: 'axis-label:mouseleave', action: 'ellipsis-text:hide' },
    { trigger: 'axis-label:touchend', action: 'ellipsis-text:hide' },
  ],
});

@maplor
Copy link
Contributor Author

maplor commented May 24, 2022

经确认,上方代码可以让 legend-item-name 和 legend-item-value 同事被裁减,并展示 tip。但目前 G2 不支持只为 legend-item-name 设置 ellipsis,而 legend-item-value 不设置 ellipsis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants