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

🤔单独配置总计、小计的字体颜色及背景色 #1227

Open
LipiAndPili opened this issue Mar 31, 2022 · 1 comment
Open

🤔单独配置总计、小计的字体颜色及背景色 #1227

LipiAndPili opened this issue Mar 31, 2022 · 1 comment
Assignees
Labels
🙏feature request 新需求支持 💤 inactive 不活跃的 Issue 或 PR, 30天没有回复

Comments

@LipiAndPili
Copy link

🖋 Description

image

😊 Expected Behavior

总计(总计名称和数值)可以配置字体颜色、大小及背景色,小计同理
image

😅 Current Behavior

只能通过
"bolderText": {
"fontSize": 14,
"fill": "pink",
}

配置数值的颜色,而且是总计和小计不能分开修改

@LipiAndPili LipiAndPili added the ❔question 疑问/使用问题 label Mar 31, 2022
@wjgogogo wjgogogo added 🙏feature request 新需求支持 and removed ❔question 疑问/使用问题 labels Apr 19, 2022
@lijinke666
Copy link
Member

后面会考虑加上小计/总计的单独配置, 目前可以通过自定义行头单元格实现

image

import { renderRect, RowCell } from '@antv/s2';

class CustomRowCell extends RowCell {
  // 背景色
  drawBackgroundShape() {
    // 总计
    if (this.meta.isGrandTotals) {
      this.backgroundShape = renderRect(this, {
        ...this.getCellArea(),
        fill: 'red',
        fillOpacity: 0.2,
      });
      return;
    }

    // 小计

    if (this.meta.isSubTotals) {
      this.backgroundShape = renderRect(this, {
        ...this.getCellArea(),
        fill: 'green',
        fillOpacity: 0.5,
      });
      return;
    }

    return super.drawBackgroundShape();
  }

  // 文字
  getTextStyle() {
    const originTextStyle = super.getTextStyle();

    // 总计
    if (this.meta.isGrandTotals) {
      return {
        ...originTextStyle,
        fill: '#fff',
        fontSize: 20,
      };
    }

    // 小计
    if (this.meta.isSubTotals) {
      return {
        ...originTextStyle,
        fill: 'red',
        fontSize: 12,
      };
    }

    return super.getTextStyle();
  }
}

const s2Options = {
  rowCell: (node, s2, headConfig) => {
    return new CustomRowCell(node, s2, headConfig);
  },
};

@xingwanying xingwanying self-assigned this Jun 28, 2022
@github-actions github-actions bot added the 💤 inactive 不活跃的 Issue 或 PR, 30天没有回复 label Jul 31, 2022
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

4 participants