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

怎么设置图例全部不选中 #5997

Closed
YY88Xu opened this issue Dec 31, 2023 · 9 comments · Fixed by #6374
Closed

怎么设置图例全部不选中 #5997

YY88Xu opened this issue Dec 31, 2023 · 9 comments · Fixed by #6374
Assignees

Comments

@YY88Xu
Copy link

YY88Xu commented Dec 31, 2023

问题描述

image

重现链接

No response

重现步骤

import { Chart } from '@antv/g2';

const chart = new Chart({ container: 'container' });

chart
  .interval()
  .data([
    { genre: 'Sports', sold: 0 },
    { genre: 'Strategy', sold: 115 },
    { genre: 'Action', sold: 120 },
    { genre: 'Shooter', sold: 350 },
    { genre: 'Other', sold: 150 },
  ])
  .encode('x', 'genre')
  .encode('y', 'sold')
  .encode('color', 'genre')
  .style('minHeight', 50);

chart.render();

现在的问题是,只剩一个图例,点击后重新全部选中,怎么设置图例全部不选中呢?

预期行为

No response

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

@pearmini
Copy link
Member

pearmini commented Jan 3, 2024

这个能力目前还没有,感兴趣提一个 PR 吗?

@Runtus
Copy link
Contributor

Runtus commented Jul 11, 2024

我来处理下

@pearmini
Copy link
Member

中级任务

@Runtus
Copy link
Contributor

Runtus commented Jul 15, 2024

老哥想问下,如果全部不选中,需要保留坐标轴吗 @pearmini

@pearmini
Copy link
Member

@Runtus 应该是需要保留的,不然都没有了有点突兀。😄

@Runtus
Copy link
Contributor

Runtus commented Jul 17, 2024

@pearmini 老哥,想问下如果要保留坐标轴的话,X轴如何去定义呢?因为全部不选中的情况下,X轴是没有值的,这个时候X轴是展示不了的,类似下图这种情况。
9c9db840f304faa44b168908744bec50

@pearmini
Copy link
Member

@Runtus 有几种解决办法:

  • 不展示
  • 只展示一个 title
  • 展示 title 和对应的 ticks

目前看上去不展示是最合理的?你觉得呢?

@Runtus
Copy link
Contributor

Runtus commented Jul 17, 2024

@pearmini 老哥,我觉得可能要分情况来看,我去看了下示例,现在这种分类可能有两种情况,它可能根据X轴进行分类,这个时候隐藏X轴确实是比较合理的选择(我去看了下Echarts好像也是这样做的),但如果它的分类和轴本身不相关,那么这个时候应该要保留XY轴。

@pearmini
Copy link
Member

@Runtus 嗯嗯,那就按照你的想法来

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

Successfully merging a pull request may close this issue.

3 participants