antvis / S2

⚡️ A practical visualization library for tabular analysis.
https://s2.antv.antgroup.com
MIT License
1.46k stars 193 forks source link

antv s2@1.49.1 使用customTree 目录树时,想通过conditions配置表头的样式,使用后发现,插件内部生成的row【指标】这一格无法修改,利用什么属性可以修改 #2860

Closed zj-93 closed 4 weeks ago

zj-93 commented 1 month ago

| Package | Version | | @antv/s2 | 1.49.1 |

PivotSheet

🖋 Description

'Snipaste_2024-08-14_10-36-29' 使用hierarchyType: customTree 目录树时,想通过conditions配置表头的样式,使用后发现,插件内部生成的row【指标】这一格无法修改

🔗 Reproduce Link

https://s2-v1.antv.antgroup.com/zh/examples/custom/custom-tree/#custom-tree const s2Options = { width: 600, height: 480, hierarchyType: 'customTree', conditions: { text: [ { field: 'custom-node-1', mapping(value) { return { fill: 'red', }; }, }, ], background: [ { field: 'type', mapping(value) { return { fill: 'red', }; }, }, { field: 'sub_type', mapping(value) { return { fill: 'red', }; }, }, { field: 'measure-a', mapping(value) { return { fill: 'red', }; }, }, ], }, };

😊 Expected Behavior

如何可以修改row【指标】这一格样式

😅 Current Behavior

github-actions[bot] commented 1 month ago

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

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

lijinke666 commented 4 weeks ago

conditions 是用于字段标记的场景, 如果你只是想定制表头样式, 请考虑 主题配置自定义单元格

[指标] 对应的单元格类型为 角头 (CornerCell)

s2.setTheme({
  cornerCell: {
    cell: { ... },
    text: {...}
  }
})
class CustomCornerCell extends CornerCell {
  getBackgroundColor() {
    console.log(this.meta)
    return {
      backgroundColor: 'red',
      backgroundColorOpacity: 0.2,
    };
  }
}