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

表格自定义单元格icon能否支持多个icon🙏 #2676

Open
2 of 5 tasks
lin-hfy opened this issue Apr 23, 2024 · 2 comments
Open
2 of 5 tasks

表格自定义单元格icon能否支持多个icon🙏 #2676

lin-hfy opened this issue Apr 23, 2024 · 2 comments
Labels
🙏feature request 新需求支持 💤 inactive 不活跃的 Issue 或 PR, 30天没有回复

Comments

@lin-hfy
Copy link

lin-hfy commented Apr 23, 2024

🏷 Version

Package Version
@antv/s2 1.51.1
@antv/s2-react
@antv/s2-vue

Sheet Type

  • PivotSheet
  • TableSheet
  • GridAnalysisSheet
  • StrategySheet
  • EditableSheet

🖋 Description

表格单元格自定义icon能否支持多个icon,目前好像一个单元格只能显示一个icon?

我们的需求:使用tooltip给单元格添加备注信息
我们期望能提供单元格右上角添加tag,如下:
image
--忽略蓝色箭头

查阅文档后发现自定义单元格icon有许多存在限制的点:只提供数值左右的icon,icon数量只能一个

目前希望自定义单元格icon可以支持多个icon,有余力的话也希望可以支持图中类似单元格角标的功能

🏞 What problem does this feature solve

🧐 Suggest the API

name type default description
- - - -
@lin-hfy lin-hfy added the 🙏feature request 新需求支持 label Apr 23, 2024
Copy link
Contributor

你好 @lin-hfy,请编辑你的 issue 标题, 一个言简意赅的 issue 标题可以节省大家的时间, 请不要将标题当做正文, 或者为空。

Hello, @lin-hfy, please edit your issue title. a concise issue title will save everyone time. please do not leave the title as the body or empty.

@lin-hfy lin-hfy changed the title 🙏 表格单元格自定义icon能否支持多个icon🙏 Apr 23, 2024
@lin-hfy lin-hfy changed the title 表格单元格自定义icon能否支持多个icon🙏 表格自定义单元格icon能否支持多个icon🙏 Apr 23, 2024
@lijinke666
Copy link
Member

自定义icon能否支持多个icon

你指的 [自定义 icon] 是行列头 (headerActionIcons) 还是字段标记 (conditions) ? 前者是支持的, 字段标记确实不支持, 会考虑在 2.0 版本中迭代 (增加多个 icon 和自定义 position 的能力), 目前的方案可以参考下文.

期望能提供单元格右上角添加tag

表格是 Canvas, 目前你可以自定义 DataCell, 然后自己在右上角绘制一个 icon 或者一个图形, 数值左右绘制多个 icon 也可以通过这种方式.

import { PivotSheet, DataCell, renderIcon } from '@antv/s2';

class CustomDataCell extends DataCell {
  initCell() {
    super.initCell()

    this.drawIcon()
  }

  drawIcon() {
    const { width, height, x, y } = this.meta
    const size = 12

    // 当前文本宽度 this.actualTextWidth, 你可以结合 meta 计算坐标自行绘制多个 icon
    if(this.meta.fieldValue === 7789) {
      const icon = renderIcon(this, {
        x: width - size,
        y: y,
        // 内置或者通过 customSVGIcons 注册的 icon 名
        name: 'Plus',
        width: size,
        height: size,
        fill: 'red'
      })

      icon.on('click', () => {
        console.log('...')
      })
    }
  }
}

image

@github-actions github-actions bot added the 💤 inactive 不活跃的 Issue 或 PR, 30天没有回复 label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙏feature request 新需求支持 💤 inactive 不活跃的 Issue 或 PR, 30天没有回复
Projects
None yet
Development

No branches or pull requests

2 participants