Skip to content

Commit

Permalink
docs: 增加文档
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Nov 20, 2023
1 parent 401dd68 commit da75312
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 18 deletions.
23 changes: 6 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions s2-site/examples/custom/custom-plugins/API.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: API
order: 7
---

<embed src="@/docs/common/custom/dataCellCallback.en.md"></embed>
5 changes: 5 additions & 0 deletions s2-site/examples/custom/custom-plugins/API.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: API
order: 7
---
<embed src="@/docs/common/custom/customTreeItem.zh.md"></embed>
77 changes: 77 additions & 0 deletions s2-site/examples/custom/custom-plugins/demo/custom-plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { PivotSheet, S2Options } from '@antv/s2';
import { Plugin as PluginRoughCanvasRenderer } from '@antv/g-plugin-rough-canvas-renderer';
import { Plugin as PluginA11y } from '@antv/g-plugin-a11y';

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'],
},
data: res.data,
meta: [
{
field: 'number',
name: '数量',
},
{
field: 'province',
name: '省份',
},
{
field: 'city',
name: '城市',
},
{
field: 'type',
name: '类别',
},
{
field: 'sub_type',
name: '子类别',
},
],
};

const s2Options: S2Options = {
width: 800,
height: 600,
interaction: {
brushSelection: {
rowCell: true,
colCell: true,
dataCell: true,
},
},
transformCanvasConfig(renderer) {
renderer.registerPlugin(new PluginRoughCanvasRenderer());
renderer.registerPlugin(
new PluginA11y({
enableExtractingText: true,
}),
);

console.log(
'当前已注册插件:',
renderer.getPlugins(),
renderer.getConfig(),
);

return {
supportsCSSTransform: true,
devicePixelRatio: 2,
cursor: 'crosshair',
};
},
};

const s2 = new PivotSheet(container, s2DataConfig, s2Options);

s2.render();
});
16 changes: 16 additions & 0 deletions s2-site/examples/custom/custom-plugins/demo/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": {
"zh": "G 5.0 插件",
"en": "G 5.0 plugins"
},
"demos": [
{
"filename": "custom-g-plugins.ts",
"title": {
"zh": "自定义 AntV/G 5.0 插件和配置",
"en": "custom AntV/G 5.0 plugins and config"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*Ag6SSYgDpeYAAAAAAAAAAAAADmJ7AQ/original"
}
]
}
4 changes: 4 additions & 0 deletions s2-site/examples/custom/custom-plugins/index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: custom tree
order: 7
---
4 changes: 4 additions & 0 deletions s2-site/examples/custom/custom-plugins/index.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: 自定义目录树
order: 7
---
4 changes: 3 additions & 1 deletion s2-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"dumi": "^2.0.3",
"gh-pages": "^3.1.0",
"lodash": "^4.17.21",
"react-color": "^2.19.3"
"react-color": "^2.19.3",
"@antv/g-plugin-a11y": "^0.6.19",
"@antv/g-plugin-rough-canvas-renderer": "^1.9.24"
},
"devDependencies": {
"@google-cloud/translate": "^7.0.3",
Expand Down

0 comments on commit da75312

Please sign in to comment.