Skip to content

Commit

Permalink
docs: 补充缺失的 fontStyle 和 fontVariant 文档 (#2407)
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 authored Nov 10, 2023
1 parent 432c0c7 commit eb8adbc
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/s2-core/src/common/interface/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export interface TextAlignCfg {
textBaseline?: TextBaseline;
}

export interface TextTheme extends TextAlignCfg {
export interface TextTheme
extends TextAlignCfg,
Pick<ShapeAttrs, 'fontStyle' | 'fontVariant'> {
/* 字体 */
fontFamily?: string;
/* 字体大小 */
Expand Down
2 changes: 2 additions & 0 deletions s2-site/docs/api/general/S2Theme.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ s2.setTheme({
| fontFamily | 字体 | `string` | `Roboto, PingFangSC,` <br> `BlinkMacSystemFont,` <br> `Microsoft YaHei,` <br> `Arial, sans-serif` | |
| fontSize | 字体大小 | `number` | - | |
| fontWeight | number <br> string: `normal` <br> `bold` <br> `bolder` <br> `lighter` 字体粗细 | `number` \| `string` | 粗体文本:Mobile:`520` PC: `bold` <br> 普通文本:`normal` | |
| fontStyle | 字体样式 | `normal \| italic \| oblique` | `normal` |
| fontVariant | 字体变体 | `normal \| small-caps \| string` | `normal` |
| fill | 字体颜色 | `string` | - | |
| linkTextFill | 链接文本颜色 | `string` | - | |
| opacity | 字体透明度 | `number` | 1 | |
Expand Down
2 changes: 2 additions & 0 deletions s2-site/docs/api/graphic.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ S2 使用 [AntV/G](https://g.antv.vision/zh/docs/guide/introduce) 作为绘图
| fontSize | `number` | 文字大小 |
| fontFamily | `string` | 文字字体 |
| fontWeight | `number` | 字体粗细 |
| fontStyle | `normal \| italic \| oblique` | 字体样式 |
| fontVariant | `normal \| small-caps \| string` | 字体变体 |
| lineHeight | `number` | 文字的行高 |
| textAlign | `center` \| `left` \| `right` \| `start` \| `end` | 设置文本内容的对齐方式 |
| textBaseline | `top` \| `middle` \| `bottom` \| `alphabetic` \| `hanging` | 设置在绘制文本时使用的当前文本基线|
Expand Down
42 changes: 42 additions & 0 deletions s2-site/examples/custom/custom-cell/demo/data-cell-placeholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { PivotSheet, CornerCell } from '@antv/s2';

fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
.then((res) => {
const container = document.getElementById('container');
const s2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
values: ['number'],
},
meta: res.meta,
data: res.data.map((item, i) => {
return {
...item,
number: i < 5 ? item.number : null,
};
}),
};
const s2Options = {
width: 600,
height: 480,
// 默认 "-"
// placeholder: '',
placeholder: (cell) => {
// 或者根据当前单元格动态设置
console.log('cell: ', cell);
if (cell.cellType === 'dataCell') {
return '*****';
}

// 返回 null, 使用默认值 ("-")
return null;
},
};
const s2 = new PivotSheet(container, s2DataConfig, s2Options);

s2.render();
});
8 changes: 8 additions & 0 deletions s2-site/examples/custom/custom-cell/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@
"en": "custom mini chart"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*apnIT4KXP3YAAAAAAAAAAAAADmJ7AQ/original"
},
{
"filename": "data-cell-placeholder.ts",
"title": {
"zh": "自定义空数据单元格占位符",
"en": "custom cell placeholder"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*B-VMT7kCWL0AAAAAAAAAAAAADmJ7AQ/original"
}
]
}

1 comment on commit eb8adbc

@vercel
Copy link

@vercel vercel bot commented on eb8adbc Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

antvis-s2 – ./

antvis-s2-antvis-family.vercel.app
antvis-s2-git-master-antvis-family.vercel.app
antvis-s2.vercel.app

Please sign in to comment.