diff --git a/s2-site/examples/case/comparison/demo/measure-comparison.tsx b/s2-site/examples/case/comparison/demo/measure-comparison.tsx
index eae238e3ed..54c642e4bd 100644
--- a/s2-site/examples/case/comparison/demo/measure-comparison.tsx
+++ b/s2-site/examples/case/comparison/demo/measure-comparison.tsx
@@ -8,14 +8,17 @@ import {
Frame,
ID_SEPARATOR,
measureTextWidth,
+ S2DataConfig,
} from '@antv/s2';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
const UP_COLOR = '#F46649';
const DOWN_COLOR = '#2AA491';
-const TAG_HEIGHT = 20; // 指标高度
-const TAG_WIDTH = 80; // 指标宽度
+// 指标高度
+const TAG_HEIGHT = 20;
+// 指标宽度
+const TAG_WIDTH = 80;
class CustomColCell extends ColCell {
lineConfig = {};
@@ -183,8 +186,9 @@ class CustomDataCell extends DataCell {
// 自定义icon显示
getIconStyle() {
- const tagName = Object.keys(this.customConditions).find((item) =>
- this.meta.colId?.includes(`root${ID_SEPARATOR}${item}${ID_SEPARATOR}`),
+ const tagName = Object.keys(this.customConditions).find(
+ (item) =>
+ this.meta.colId?.includes(`root${ID_SEPARATOR}${item}${ID_SEPARATOR}`),
);
if (tagName) {
@@ -199,8 +203,9 @@ class CustomDataCell extends DataCell {
drawTextShape() {
const { fieldValue } = this.meta;
- const tagName = Object.keys(this.textConfig).find((item) =>
- this.meta.colId?.includes(`root${ID_SEPARATOR}${item}${ID_SEPARATOR}`),
+ const tagName = Object.keys(this.textConfig).find(
+ (item) =>
+ this.meta.colId?.includes(`root${ID_SEPARATOR}${item}${ID_SEPARATOR}`),
);
if (!tagName) {
@@ -438,7 +443,7 @@ class CustomCornelCell extends CornerCell {
fetch('https://assets.antv.antgroup.com/s2/index-comparison.json')
.then((res) => res.json())
.then((data) => {
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['type'],
columns: ['tag'],
@@ -468,6 +473,7 @@ fetch('https://assets.antv.antgroup.com/s2/index-comparison.json')
],
data,
};
+
const getIcon = (fieldValue) => {
return parseFloat(fieldValue) > 0
? 'CellUp'
@@ -475,6 +481,7 @@ fetch('https://assets.antv.antgroup.com/s2/index-comparison.json')
? 'CellDown'
: '';
};
+
const conditionsIcon = [
{
field: 'price',
@@ -512,18 +519,21 @@ fetch('https://assets.antv.antgroup.com/s2/index-comparison.json')
: textStyle?.fill,
};
};
+
// 列分组竖线样式配置
const lineConfigStyle = {
stroke: '#3471F9',
lineWidth: 1,
opacity: 0.5,
};
+
// 列分组配置
const lineConfig = {
price: 1,
pv: 1,
};
- const s2Options = {
+
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
showDefaultHeaderActionIcon: false,
diff --git a/s2-site/examples/case/comparison/demo/multiple-people-comparison.tsx b/s2-site/examples/case/comparison/demo/multiple-people-comparison.tsx
index 18f8eb74cc..ad4b46776c 100644
--- a/s2-site/examples/case/comparison/demo/multiple-people-comparison.tsx
+++ b/s2-site/examples/case/comparison/demo/multiple-people-comparison.tsx
@@ -75,6 +75,7 @@ const getFormatter =
(value) => {
const prefix = enablePrefix && value > 0 ? '+' : '';
const suffix = value !== 0 ? '%' : '';
+
return `${prefix}${value}${suffix}`;
};
@@ -90,6 +91,7 @@ class CustomColCell extends ColCell {
renderGroupSeparator() {
const { label, isLeaf } = this.meta;
+
// 只需要为 A B 群组绘制标识
if (!isLeaf || label === 'people-group-delta') {
return;
@@ -97,6 +99,7 @@ class CustomColCell extends ColCell {
const fill = GROUP_COLOR[label];
const { x, y, height } = this.textShape.getBBox();
+
this.addShape('rect', {
attrs: {
x: x - GROUP_SEPARATOR_WIDTH * 1.5,
@@ -195,6 +198,7 @@ fetch('https://assets.antv.antgroup.com/s2/multiple-people-comparison.json')
field: 'people-group-delta',
mapping(value) {
const { color } = getTargetColor(value);
+
return {
fill: color,
};
@@ -206,6 +210,7 @@ fetch('https://assets.antv.antgroup.com/s2/multiple-people-comparison.json')
field: 'people-group-delta',
mapping(value) {
const { background } = getTargetColor(value);
+
return {
fill: background,
};
diff --git a/s2-site/examples/case/comparison/demo/philosophers.tsx b/s2-site/examples/case/comparison/demo/philosophers.tsx
index 47952a4339..0e6d6220e3 100644
--- a/s2-site/examples/case/comparison/demo/philosophers.tsx
+++ b/s2-site/examples/case/comparison/demo/philosophers.tsx
@@ -2,9 +2,9 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { max, min, replace } from 'lodash';
import insertCss from 'insert-css';
-
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
+import { S2DataConfig } from '@antv/s2';
const PALETTE_COLORS = [
'#B8E1FF',
@@ -45,12 +45,12 @@ fetch(
const getFormatter = (val) => {
if (val < 0) {
return `公元前${replace(val, '-', '')}年`;
- } else {
- return `${val}年`;
}
+
+ return `${val}年`;
};
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['country', 'name', 'start', 'end', 'points', 'word'],
columns: [],
@@ -91,10 +91,12 @@ fetch(
],
data,
};
+
const TooltipContent = (props) => {
const { rowQuery, fieldValue } = props;
const { name, country, start, end, points } = rowQuery;
- const ponitsLines = points.split('&');
+ const pointsLines = points.split('&');
+
return (
@@ -102,17 +104,17 @@ fetch(
国家:{country}
出生:{getFormatter(start)}
逝世:{getFormatter(end)}
- {ponitsLines.length > 1 ? (
+ {pointsLines.length > 1 ? (
观点:
- {ponitsLines.map((point, index) => (
-
+ {pointsLines.map((point, index) => (
+
{index + 1}: {point}
))}
) : (
-
观点: {ponitsLines[0]}
+
观点: {pointsLines[0]}
)}
@@ -127,8 +129,8 @@ fetch(
);
};
- const s2Options = {
- width: '',
+
+ const s2Options: SheetComponentOptions = {
height: 400,
conditions: {
text: [
@@ -153,6 +155,7 @@ fetch(
(((value - minWeight) / weightSpan) * 100) /
PALETTE_COLORS.length,
) - 1;
+
if (colorIndex <= 0) {
backgroundColor = PALETTE_COLORS[0];
} else if (colorIndex >= PALETTE_COLORS.length) {
@@ -176,6 +179,7 @@ fetch(
const onDataCellMouseUp = (value) => {
const viewMeta = value?.viewMeta;
+
if (!viewMeta) {
return;
}
@@ -184,6 +188,7 @@ fetch(
x: value.event.clientX,
y: value.event.clientY,
};
+
viewMeta.spreadsheet.tooltip.show({
position,
content: TooltipContent(viewMeta),
@@ -197,11 +202,10 @@ fetch(
adaptive={true}
header={{
title: '哲学家的观点',
- extra: [
],
+ extra:
,
}}
onDataCellMouseUp={onDataCellMouseUp}
/>,
-
document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/comparison/demo/time-spend.tsx b/s2-site/examples/case/comparison/demo/time-spend.tsx
index 620b5f5c43..d31dce83d9 100644
--- a/s2-site/examples/case/comparison/demo/time-spend.tsx
+++ b/s2-site/examples/case/comparison/demo/time-spend.tsx
@@ -3,7 +3,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import insertCss from 'insert-css';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
-import { DataCell, Frame, S2Theme } from '@antv/s2';
+import { DataCell, Frame, S2Theme, ThemeCfg } from '@antv/s2';
import '@antv/s2-react/dist/style.min.css';
const paletteLegendMap = [
@@ -171,7 +171,7 @@ class CustomFrame extends Frame {
fetch('https://assets.antv.antgroup.com/s2/time-spend.json')
.then((res) => res.json())
.then((s2DataConfig) => {
- const s2Palette = {
+ const s2Palette: ThemeCfg['palette'] = {
basicColors: [
'#FFFFFF',
'#020138',
@@ -195,7 +195,8 @@ fetch('https://assets.antv.antgroup.com/s2/time-spend.json')
green: '#29A294',
},
};
- const s2Theme: S2Theme = {
+
+ const s2Theme: ThemeCfg['theme'] = {
colCell: {
bolderText: {
fontSize: 12,
@@ -267,6 +268,7 @@ fetch('https://assets.antv.antgroup.com/s2/time-spend.json')
},
},
};
+
const PaletteLegend = () => (
{paletteLegendMap.map((value, key) => (
diff --git a/s2-site/examples/case/data-preview/demo/excel.tsx b/s2-site/examples/case/data-preview/demo/excel.tsx
index 1a15f5f29e..7f2852cb87 100644
--- a/s2-site/examples/case/data-preview/demo/excel.tsx
+++ b/s2-site/examples/case/data-preview/demo/excel.tsx
@@ -1,11 +1,12 @@
-import React, { useState, useEffect, useRef } from 'react';
+import React, { useState, useRef } from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import 'antd/es/checkbox/style/index.css';
+import { S2DataConfig } from '@antv/s2';
// 初始化配置
-const s2Options = {
+const s2Options: SheetComponentOptions = {
width: 600,
height: 400,
showSeriesNumber: true,
@@ -15,15 +16,16 @@ const s2Options = {
};
// 初始化数据
-const s2DataCfg = {
+const s2DataCfg: S2DataConfig = {
fields: { columns: ['province', 'city', 'type', 'price'] },
sortParams: [],
+ data: [],
};
const App = ({ data }) => {
const S2Ref = useRef(null);
- const [options, setOptions] = useState(s2Options);
- const [dataCfg, setDataCfg] = useState({ ...s2DataCfg, data });
+ const [options, setOptions] = useState
(s2Options);
+ const [dataCfg, setDataCfg] = useState({ ...s2DataCfg, data });
return (
diff --git a/s2-site/examples/case/data-preview/demo/house.tsx b/s2-site/examples/case/data-preview/demo/house.tsx
index 351225cb19..ab5f5673d1 100644
--- a/s2-site/examples/case/data-preview/demo/house.tsx
+++ b/s2-site/examples/case/data-preview/demo/house.tsx
@@ -1,15 +1,10 @@
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import { Select, InputNumber, Space } from 'antd';
-import {
- every,
- filter, isNil,
- last,
- map,
- omit,
-} from 'lodash';
-import { SheetComponent } from '@antv/s2-react';
+import { every, filter, isNil, last, map, omit } from 'lodash';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import insertCss from 'insert-css';
+import { S2DataConfig, SortParams } from '@antv/s2';
const ID_SEPARATOR = '[&]';
const defaultHouseInfo = {
@@ -25,7 +20,8 @@ const defaultHouseInfo = {
],
area: [92, 111, 114, 119, 120, 123, 125, 135, 138],
};
-const s2Options = {
+
+const s2Options: SheetComponentOptions = {
width: 700,
height: 580,
pagination: {
@@ -44,6 +40,7 @@ const s2Options = {
fill: '#b8e1ff',
};
}
+
return {
fill: '#fff',
};
@@ -52,7 +49,8 @@ const s2Options = {
],
},
};
-const defaultSortParams = [
+
+const defaultSortParams: S2DataConfig['sortParams'] = [
{
sortFieldId: 'name',
sortMethod: 'ASC',
@@ -64,16 +62,18 @@ const defaultSortParams = [
{
sortFieldId: 'level',
sortFunc: (params) => {
- const { data } = params;
+ const { data = [] } = params;
+
return data.sort((a, b) => {
const aNum = last(a.split(ID_SEPARATOR));
const bNum = last(b.split(ID_SEPARATOR));
+
return aNum - bNum;
});
},
},
];
-const dataConfig = {
+const dataConfig: S2DataConfig = {
data: [],
describe: '如何使用 S2 买房',
fields: {
@@ -146,7 +146,7 @@ const SelectItem = (props) => {
onChange={(value) => {
onChange({
key: dataName,
- value: value,
+ value,
});
}}
>
@@ -166,6 +166,7 @@ const RangeSelect = (props) => {
const [info, setInfo] = useState({ min, max });
const handleChange = (value, key) => {
const tempInfo = Object.assign({}, info);
+
tempInfo[key] = value;
setInfo(tempInfo);
@@ -201,11 +202,13 @@ const SelectList = (props) => {
const onChange = ({ key, value }) => {
let tempHouseInfo = Object.assign({}, filterInfo);
+
if (isNil(value)) {
tempHouseInfo = omit(tempHouseInfo, key);
} else {
tempHouseInfo[key] = value;
}
+
setFilterInfo(tempHouseInfo);
filterData(tempHouseInfo);
};
@@ -237,16 +240,20 @@ const Sheet = ({ data }) => {
if (key === 'area') {
return value[0] <= item.area && value[1] >= item.area;
}
+
if (key === 'level') {
return value[0] <= item.level && value[1] >= item.level;
}
- if(key === 'nearStreet') {
- console.log(item.nearStreet, 'item.nearStreet', value, 'value');
+
+ if (key === 'nearStreet') {
+ console.log(item.nearStreet, 'item.nearStreet', value, 'value');
console.log(item.nearStreet === value, 'item.nearStreet === value');
}
+
return item[key] === value;
});
});
+
setDataSource(result);
};
diff --git a/s2-site/examples/case/data-preview/demo/index.tsx b/s2-site/examples/case/data-preview/demo/index.tsx
index 0498e2c3e7..e397da29a0 100644
--- a/s2-site/examples/case/data-preview/demo/index.tsx
+++ b/s2-site/examples/case/data-preview/demo/index.tsx
@@ -9,8 +9,9 @@ import {
S2Event,
InteractionStateName,
CellType,
+ S2DataConfig,
} from '@antv/s2';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import {
Input,
Divider,
@@ -25,7 +26,6 @@ import {
} from 'antd';
import { get, uniq } from 'lodash';
import '@antv/s2-react/dist/style.min.css';
-import 'antd/es/checkbox/style/index.css';
const { Search } = Input;
@@ -245,7 +245,7 @@ const App = ({ data }) => {
const [interactedCol, setInteractedCol] = useState('');
const modalCallbackRef = useRef((e) => {});
- const [options, setOptions] = useState({
+ const options: SheetComponentOptions = {
width: 600,
height: 400,
showSeriesNumber: true,
@@ -286,8 +286,9 @@ const App = ({ data }) => {
},
},
showDefaultHeaderActionIcon: false,
- });
- const [dataCfg, setDataCfg] = useState({
+ };
+
+ const [dataCfg, setDataCfg] = useState
({
fields: {
columns,
},
diff --git a/s2-site/examples/case/kpi-strategy/demo/basic.tsx b/s2-site/examples/case/kpi-strategy/demo/basic.tsx
index 1d1340fb07..7e86c24993 100644
--- a/s2-site/examples/case/kpi-strategy/demo/basic.tsx
+++ b/s2-site/examples/case/kpi-strategy/demo/basic.tsx
@@ -36,12 +36,15 @@ const PADDING = 10;
function getStatusColorByProgress(realProgress, expectedProgress) {
const leftWorker = expectedProgress - realProgress;
+
if (leftWorker <= 0.1) {
return STATUS_COLOR.healthy;
}
+
if (leftWorker > 0.1 && leftWorker <= 0.3) {
return STATUS_COLOR.late;
}
+
return STATUS_COLOR.danger;
}
@@ -59,10 +62,13 @@ class KpiStrategyDataCell extends DataCell {
// 如果是进度, 格式化为百分比 (只做 demo 示例, 请根据实际情况使用)
getFormattedFieldValue() {
const { data } = this.meta;
+
if (!data || !data.isProgress) {
return super.getFormattedFieldValue();
}
+
const formattedValue = `${data.value * 100} %`;
+
return { formattedValue, value: data.value };
}
@@ -70,9 +76,11 @@ class KpiStrategyDataCell extends DataCell {
renderDeriveValue() {
// 通过 this.meta 拿到当前单元格的有效信息
const { x, width, data } = this.meta;
+
if (!data || data.isExtra) {
return;
}
+
const value = data?.compare ?? '';
const isDown = value.startsWith('-');
const color = isDown ? DERIVE_COLOR.down : DERIVE_COLOR.up;
@@ -105,9 +113,11 @@ class KpiStrategyDataCell extends DataCell {
renderProgressBar() {
const { x, y, width, height, data } = this.meta;
+
if (!data || !data.isProgress) {
return;
}
+
const currentProgress = data.value;
const expectedProgress = data.expectedValue;
@@ -244,7 +254,7 @@ fetch('https://assets.antv.antgroup.com/s2/kpi-strategy.json')
options={s2Options}
sheetType="pivot"
themeCfg={{
- theme: merge({}, theme),
+ theme,
}}
/>,
document.getElementById('container'),
diff --git a/s2-site/examples/case/kpi-strategy/demo/covid-trend.tsx b/s2-site/examples/case/kpi-strategy/demo/covid-trend.tsx
index 3c9bee4ee6..561b031b19 100644
--- a/s2-site/examples/case/kpi-strategy/demo/covid-trend.tsx
+++ b/s2-site/examples/case/kpi-strategy/demo/covid-trend.tsx
@@ -35,6 +35,7 @@ fetch(
fill: '#000',
};
}
+
return {
fill: isUpDataValue(value) ? '#FF4D4F' : '#29A294',
};
@@ -51,6 +52,7 @@ fetch(
if (colIndex === 0 || isNilValue) {
return null;
}
+
return isUpDataValue(value)
? {
// icon 用于指定图标条件格式所使用的 icon 类型
diff --git a/s2-site/examples/case/performance-compare/demo/basic.tsx b/s2-site/examples/case/performance-compare/demo/basic.tsx
index 250f590324..e06e30caa2 100644
--- a/s2-site/examples/case/performance-compare/demo/basic.tsx
+++ b/s2-site/examples/case/performance-compare/demo/basic.tsx
@@ -1,8 +1,9 @@
+import { S2DataConfig } from '@antv/s2';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
+import '@antv/s2-react/dist/style.min.css';
+import { compact } from 'lodash';
import React from 'react';
import ReactDOM from 'react-dom';
-import { compact } from 'lodash';
-import { SheetComponent } from '@antv/s2-react';
-import '@antv/s2-react/dist/style.min.css';
const disableColor = '#d3d7d4';
const colors = [
@@ -19,19 +20,21 @@ const colors = [
function getRange(data) {
const values = data.map((d) => d.value);
const compactValue = compact(values);
+
return {
min: Math.min(...compactValue),
max: Math.max(...compactValue),
};
}
-function getIndex(fieldValue, rawData) {
+function getIndex(fieldValue: number, rawData: S2DataConfig['data']) {
const { min, max } = getRange(rawData);
const step = Math.floor((max - min) / (colors.length - 1));
+
return Math.floor((fieldValue - min) / step);
}
-function getDataConfig(rawData) {
+function getDataConfig(rawData: S2DataConfig['data']): S2DataConfig {
return {
fields: {
rows: ['size', 'name'],
@@ -60,7 +63,7 @@ function getDataConfig(rawData) {
};
}
-function getOptions(rawData) {
+function getOptions(rawData: S2DataConfig['data']): SheetComponentOptions {
return {
width: 600,
height: 200,
@@ -74,6 +77,7 @@ function getOptions(rawData) {
field: 'value',
mapping(fieldValue) {
const index = getIndex(fieldValue, rawData);
+
return {
fill: fieldValue ? colors[index] : disableColor,
};
diff --git a/s2-site/examples/case/performance-compare/demo/pivot.tsx b/s2-site/examples/case/performance-compare/demo/pivot.tsx
index 5df2baa624..ebcb86caa2 100644
--- a/s2-site/examples/case/performance-compare/demo/pivot.tsx
+++ b/s2-site/examples/case/performance-compare/demo/pivot.tsx
@@ -1,12 +1,15 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2DataConfig } from '@antv/s2';
const s2Options = {
width: 600,
height: 480,
};
-export function generateRawData(row, col) {
- const res = [];
+export function generateRawData(
+ row: Record,
+ col: Record,
+) {
+ const res: Record[] = [];
const rowKeys = Object.keys(row);
const colKeys = Object.keys(col);
@@ -29,7 +32,7 @@ export function generateRawData(row, col) {
return res;
}
-const s2DataConfig = {
+const s2DataConfig: S2DataConfig = {
fields: {
rows: ['type', 'subType'],
columns: ['province', 'city'],
@@ -40,8 +43,13 @@ const s2DataConfig = {
{ type: 10, sub_type: 100 },
),
};
-const container = document.getElementById('container');
-const s2 = new PivotSheet(container, s2DataConfig, s2Options);
+async function bootstrap() {
+ const container = document.getElementById('container');
-s2.render();
+ const s2 = new PivotSheet(container, s2DataConfig, s2Options);
+
+ await s2.render();
+}
+
+bootstrap();
diff --git a/s2-site/examples/case/performance-compare/demo/table.tsx b/s2-site/examples/case/performance-compare/demo/table.tsx
index 70953ed1cb..5d7816c5ac 100644
--- a/s2-site/examples/case/performance-compare/demo/table.tsx
+++ b/s2-site/examples/case/performance-compare/demo/table.tsx
@@ -1,13 +1,16 @@
-import { TableSheet } from '@antv/s2';
+import { S2DataConfig, S2Options, TableSheet } from '@antv/s2';
-const s2Options = {
+const s2Options: S2Options = {
width: 600,
height: 480,
showSeriesNumber: true,
};
-export function generateRawData(row, col) {
- const res = [];
+export function generateRawData(
+ row: Record,
+ col: Record,
+) {
+ const res: Record[] = [];
const rowKeys = Object.keys(row);
const colKeys = Object.keys(col);
@@ -31,7 +34,7 @@ export function generateRawData(row, col) {
return res;
}
-const s2DataConfig = {
+const s2DataConfig: S2DataConfig = {
fields: {
columns: ['province', 'city', 'type', 'subType', 'number'],
},
@@ -41,8 +44,12 @@ const s2DataConfig = {
),
};
-const container = document.getElementById('container');
+async function bootstrap() {
+ const container = document.getElementById('container');
-const s2 = new TableSheet(container, s2DataConfig, s2Options);
+ const s2 = new TableSheet(container, s2DataConfig, s2Options);
-s2.render();
+ await s2.render();
+}
+
+bootstrap();
diff --git a/s2-site/examples/case/proportion/demo/group-drill-down.tsx b/s2-site/examples/case/proportion/demo/group-drill-down.tsx
index 501d769dbd..e96f43d042 100644
--- a/s2-site/examples/case/proportion/demo/group-drill-down.tsx
+++ b/s2-site/examples/case/proportion/demo/group-drill-down.tsx
@@ -1,8 +1,9 @@
-import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
import { isUpDataValue } from '@antv/s2';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
+import insertCss from 'insert-css';
+import React, { useState } from 'react';
+import ReactDOM from 'react-dom';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/ff31b171-17a7-4d29-b20a-0b90a810d2de.json',
@@ -12,7 +13,7 @@ fetch(
const GridSheet = () => {
const [s2DataConfig, setS2DataConfig] = useState(data.dataCfg);
const [drillDownField, setDrillDownField] = useState('');
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 800,
height: 600,
tooltip: {
@@ -42,8 +43,9 @@ fetch(
};
}
+ // 同环比红张绿跌
return {
- fill: isUpDataValue(value) ? '#FF4D4F' : '#29A294', // 同环比红张绿跌
+ fill: isUpDataValue(value) ? '#FF4D4F' : '#29A294',
};
},
},
@@ -145,7 +147,7 @@ fetch(
header={{
title: '人群网络分析',
advancedSortCfg: { open: true },
- extra: [],
+ extra: ,
}}
onDataCellMouseUp={onDataCellMouseUp}
/>
diff --git a/s2-site/examples/custom/custom-cell/demo/col-cell.ts b/s2-site/examples/custom/custom-cell/demo/col-cell.ts
index 3e71d34baa..a12e37c541 100644
--- a/s2-site/examples/custom/custom-cell/demo/col-cell.ts
+++ b/s2-site/examples/custom/custom-cell/demo/col-cell.ts
@@ -1,4 +1,4 @@
-import { PivotSheet, ColCell } from '@antv/s2';
+import { PivotSheet, ColCell, S2Options, S2DataConfig } from '@antv/s2';
/**
* 自定义 ColCell,给列头添加背景图
@@ -20,9 +20,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -31,7 +31,8 @@ fetch(
meta: res.meta,
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
@@ -41,8 +42,8 @@ fetch(
return new CustomColCell(node, s2, headConfig);
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- // 使用
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-cell/demo/corner-cell.ts b/s2-site/examples/custom/custom-cell/demo/corner-cell.ts
index 04f2217bdb..c2be67dcdf 100644
--- a/s2-site/examples/custom/custom-cell/demo/corner-cell.ts
+++ b/s2-site/examples/custom/custom-cell/demo/corner-cell.ts
@@ -1,4 +1,4 @@
-import { PivotSheet, CornerCell } from '@antv/s2';
+import { PivotSheet, CornerCell, S2Options, S2DataConfig } from '@antv/s2';
/**
* 自定义 CornerCell,给角头添加背景图
@@ -19,9 +19,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -30,7 +30,8 @@ fetch(
meta: res.meta,
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
@@ -40,8 +41,8 @@ fetch(
return new CustomCornerCell(node, s2, headConfig);
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- // 使用
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-cell/demo/corner-header.ts b/s2-site/examples/custom/custom-cell/demo/corner-header.ts
index 1b40471866..417b97581f 100644
--- a/s2-site/examples/custom/custom-cell/demo/corner-header.ts
+++ b/s2-site/examples/custom/custom-cell/demo/corner-header.ts
@@ -1,4 +1,4 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
import { Group } from '@antv/g-canvas';
import { get } from 'lodash';
@@ -8,13 +8,17 @@ import { get } from 'lodash';
*/
class CustomCornerHeader extends Group {
node;
+
backgroundShape;
+
textShape;
+
constructor(node) {
super({});
this.node = node;
this.initCornerHeader();
}
+
initCornerHeader() {
this.initBg();
this.initText();
@@ -54,9 +58,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -65,7 +69,8 @@ fetch(
meta: res.meta,
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
@@ -75,8 +80,8 @@ fetch(
return new CustomCornerHeader(node);
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- // 使用
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-cell/demo/custom-merged-cell.ts b/s2-site/examples/custom/custom-cell/demo/custom-merged-cell.ts
index f358fc338c..ce2fb37e8a 100644
--- a/s2-site/examples/custom/custom-cell/demo/custom-merged-cell.ts
+++ b/s2-site/examples/custom/custom-cell/demo/custom-merged-cell.ts
@@ -1,4 +1,4 @@
-import { PivotSheet, MergedCell } from '@antv/s2';
+import { PivotSheet, MergedCell, S2Options, S2DataConfig } from '@antv/s2';
/**
* 自定义 MergedCell,改变背景色
@@ -16,9 +16,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -27,7 +27,8 @@ fetch(
meta: res.meta,
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
@@ -35,7 +36,8 @@ fetch(
},
mergedCellsInfo: [
[
- { colIndex: 1, rowIndex: 1, showText: true }, // 此单元格的 meta 信息将作为合并单元的 meta 信息
+ // 此单元格的 meta 信息将作为合并单元的 meta 信息
+ { colIndex: 1, rowIndex: 1, showText: true },
{ colIndex: 1, rowIndex: 2 },
{ colIndex: 2, rowIndex: 1 },
{ colIndex: 2, rowIndex: 2 },
@@ -44,8 +46,8 @@ fetch(
mergedCell: (spreadsheet, cells, meta) =>
new CustomMergedCell(spreadsheet, cells, meta),
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- // 使用
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-cell/demo/custom-specified-cell.ts b/s2-site/examples/custom/custom-cell/demo/custom-specified-cell.ts
index 13c641ae06..9be1907c32 100644
--- a/s2-site/examples/custom/custom-cell/demo/custom-specified-cell.ts
+++ b/s2-site/examples/custom/custom-cell/demo/custom-specified-cell.ts
@@ -1,5 +1,11 @@
/* eslint-disable max-classes-per-file */
-import { PivotSheet, DataCell, ColCell } from '@antv/s2';
+import {
+ PivotSheet,
+ DataCell,
+ ColCell,
+ S2Options,
+ S2DataConfig,
+} from '@antv/s2';
/**
* 自定义 DataCell,给特定单元格设置背景色, 文字大小, 颜色
@@ -106,9 +112,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -117,7 +123,8 @@ fetch(
meta: res.meta,
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
dataCell: (viewMeta) => {
@@ -128,8 +135,8 @@ fetch(
return new CustomColCell(node, spreadsheet, headerConfig);
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- // 使用
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-cell/demo/data-cell.ts b/s2-site/examples/custom/custom-cell/demo/data-cell.ts
index 8b9ccff792..28b34b5eda 100644
--- a/s2-site/examples/custom/custom-cell/demo/data-cell.ts
+++ b/s2-site/examples/custom/custom-cell/demo/data-cell.ts
@@ -1,4 +1,4 @@
-import { PivotSheet, DataCell } from '@antv/s2';
+import { PivotSheet, DataCell, S2DataConfig, S2Options } from '@antv/s2';
/**
* 自定义 DataCell,给数值单元格添加背景图
@@ -20,9 +20,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -31,18 +31,20 @@ fetch(
meta: res.meta,
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
- hoverHighlight: false, // 关闭 hover 十字高亮, 为了视觉效果,可不设置
+ // 关闭 hover 十字高亮, 为了视觉效果,可不设置
+ hoverHighlight: false,
},
dataCell: (viewMeta) => {
return new CustomDataCell(viewMeta, viewMeta?.spreadsheet);
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- // 使用
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-cell/demo/row-cell.ts b/s2-site/examples/custom/custom-cell/demo/row-cell.ts
index 7cb553f2b5..d8459ae619 100644
--- a/s2-site/examples/custom/custom-cell/demo/row-cell.ts
+++ b/s2-site/examples/custom/custom-cell/demo/row-cell.ts
@@ -1,4 +1,4 @@
-import { PivotSheet, RowCell } from '@antv/s2';
+import { PivotSheet, RowCell, S2DataConfig, S2Options } from '@antv/s2';
/**
* 自定义 RowCell,给行头添加背景图
@@ -20,9 +20,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -31,15 +31,16 @@ fetch(
meta: res.meta,
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
rowCell: (node, s2, headConfig) => {
return new CustomRowCell(node, s2, headConfig);
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- // 使用
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-cell/demo/series-number-cell.ts b/s2-site/examples/custom/custom-cell/demo/series-number-cell.ts
index de22f2a740..d1a692c466 100644
--- a/s2-site/examples/custom/custom-cell/demo/series-number-cell.ts
+++ b/s2-site/examples/custom/custom-cell/demo/series-number-cell.ts
@@ -13,11 +13,15 @@ import {
class CustomSeriesCell extends SeriesNumberCell {
// 覆盖背景绘制,可覆盖或者增加绘制方法
getBackgroundColor() {
- return { backgroundColor: 'cyan', backgroundColorOpacity: 0.5 };
+ return {
+ backgroundColor: 'cyan',
+ backgroundColorOpacity: 0.5,
+ intelligentReverseTextColor: false,
+ };
}
}
-const layoutSeriesNumberNodes = (
+const layoutSeriesNumberNodes: S2Options['layoutSeriesNumberNodes'] = (
rowsHierarchy,
seriesNumberWidth,
spreadsheet,
@@ -32,7 +36,8 @@ const layoutSeriesNumberNodes = (
id: '',
field: '',
rowIndex: idx,
- value: `${String.fromCharCode(97 + idx)}`, // 序号从 a 开始递增,在大量数据下,需要更完善的处理
+ // 序号从 a 开始递增,在大量数据下,需要更完善的处理
+ value: `${String.fromCharCode(97 + idx)}`,
});
sNode.x = 0;
@@ -48,7 +53,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
fields: {
@@ -59,18 +64,20 @@ fetch(
meta: res.meta,
data: res.data,
};
+
const s2Options: S2Options = {
width: 600,
height: 480,
- hierarchyType: 'tree', // 切换到 grid 模式试试看
+ // 切换到 grid 模式试试看
+ hierarchyType: 'tree',
showSeriesNumber: true,
layoutSeriesNumberNodes,
seriesNumberCell: (node, s2, headConfig) => {
return new CustomSeriesCell(node, s2, headConfig);
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- // 使用
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-cell/demo/totals-cell.ts b/s2-site/examples/custom/custom-cell/demo/totals-cell.ts
index 6115363d6a..e3d4d89116 100644
--- a/s2-site/examples/custom/custom-cell/demo/totals-cell.ts
+++ b/s2-site/examples/custom/custom-cell/demo/totals-cell.ts
@@ -1,4 +1,10 @@
-import { PivotSheet, RowCell, renderRect } from '@antv/s2';
+import {
+ PivotSheet,
+ RowCell,
+ S2DataConfig,
+ S2Options,
+ renderRect,
+} from '@antv/s2';
/**
* 继承 RowCell, 单独修改小计/总计的背景色和文字颜色
@@ -14,6 +20,7 @@ class CustomTotalsRowCell extends RowCell {
fill: '#f63',
fillOpacity: 0.9,
});
+
return;
}
@@ -24,6 +31,7 @@ class CustomTotalsRowCell extends RowCell {
fill: '#06a',
fillOpacity: 0.9,
});
+
return;
}
@@ -62,9 +70,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -73,7 +81,8 @@ fetch(
meta: res.meta,
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
@@ -95,7 +104,8 @@ fetch(
return new CustomTotalsRowCell(node, s2, headConfig);
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-g2-chart/demo/custom-g2-chart.ts b/s2-site/examples/custom/custom-g2-chart/demo/custom-g2-chart.ts
index 7a8b264344..4a5e53c67f 100644
--- a/s2-site/examples/custom/custom-g2-chart/demo/custom-g2-chart.ts
+++ b/s2-site/examples/custom/custom-g2-chart/demo/custom-g2-chart.ts
@@ -120,24 +120,28 @@ const s2DataConfig: S2DataConfig = {
const container = document.getElementById('container');
-const s2 = new PivotSheet(container, s2DataConfig, s2Options);
+async function bootstrap() {
+ const s2 = new PivotSheet(container, s2DataConfig, s2Options);
-// 监听数值单元格渲染完成后, 使用 `G2` 提供的 `renderToMountedElement` 将图表挂载在 `S2` 单元格实例上
-s2.on(S2Event.DATA_CELL_RENDER, (cell) => {
- // 普通数值单元格正常展示
- if (!cell.isChartData()) {
- return;
- }
+ // 监听数值单元格渲染完成后, 使用 `G2` 提供的 `renderToMountedElement` 将图表挂载在 `S2` 单元格实例上
+ s2.on(S2Event.DATA_CELL_RENDER, (cell) => {
+ // 普通数值单元格正常展示
+ if (!cell.isChartData()) {
+ return;
+ }
- // 获取 G2 渲染到 S2 单元格内所需配置
- const chartOptions = cell.getRenderChartOptions();
+ // 获取 G2 渲染到 S2 单元格内所需配置
+ const chartOptions = cell.getRenderChartOptions();
- renderToMountedElement(chartOptions, {
- // 指定渲染容器为当前单元格
- group: cell,
- // 根据渲染的图表, 自行选择 G2 library: https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2stdlib
- library: stdlib(),
+ renderToMountedElement(chartOptions, {
+ // 指定渲染容器为当前单元格
+ group: cell,
+ // 根据渲染的图表, 自行选择 G2 library: https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2stdlib
+ library: stdlib(),
+ });
});
-});
-s2.render();
+ await s2.render();
+}
+
+bootstrap();
diff --git a/s2-site/examples/custom/custom-icon/demo/custom-data-cell-icon.tsx b/s2-site/examples/custom/custom-icon/demo/custom-data-cell-icon.tsx
index 5cc3ae471a..f20da9b42c 100644
--- a/s2-site/examples/custom/custom-icon/demo/custom-data-cell-icon.tsx
+++ b/s2-site/examples/custom/custom-icon/demo/custom-data-cell-icon.tsx
@@ -1,13 +1,13 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
@@ -45,7 +45,8 @@ fetch(
],
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-icon/demo/custom-svg-icon.ts b/s2-site/examples/custom/custom-icon/demo/custom-svg-icon.ts
index 9a049b02d5..391b40a478 100644
--- a/s2-site/examples/custom/custom-icon/demo/custom-svg-icon.ts
+++ b/s2-site/examples/custom/custom-icon/demo/custom-svg-icon.ts
@@ -1,12 +1,12 @@
-import { PivotSheet, Node } from '@antv/s2';
+import { PivotSheet, S2Options, S2DataConfig } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -15,7 +15,8 @@ fetch(
meta: res.meta,
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
customSVGIcons: [
@@ -34,8 +35,8 @@ fetch(
},
],
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- // 使用
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-layout/demo/custom-coordinate.ts b/s2-site/examples/custom/custom-layout/demo/custom-coordinate.ts
index 89b159b6bc..b8fe9978f8 100644
--- a/s2-site/examples/custom/custom-layout/demo/custom-coordinate.ts
+++ b/s2-site/examples/custom/custom-layout/demo/custom-coordinate.ts
@@ -1,12 +1,12 @@
-import { PivotSheet, S2Options } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -28,7 +28,8 @@ fetch(
}
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-layout/demo/custom-data-position.ts b/s2-site/examples/custom/custom-layout/demo/custom-data-position.ts
index 89f699f766..9909499bc0 100644
--- a/s2-site/examples/custom/custom-layout/demo/custom-data-position.ts
+++ b/s2-site/examples/custom/custom-layout/demo/custom-data-position.ts
@@ -10,7 +10,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
fields: {
@@ -48,7 +48,8 @@ fetch(
return viewMeta;
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-layout/demo/custom-layout-arrange.ts b/s2-site/examples/custom/custom-layout/demo/custom-layout-arrange.ts
index 00674ecd75..6ffde700e1 100644
--- a/s2-site/examples/custom/custom-layout/demo/custom-layout-arrange.ts
+++ b/s2-site/examples/custom/custom-layout/demo/custom-layout-arrange.ts
@@ -1,12 +1,12 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -15,7 +15,7 @@ fetch(
data: res.data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
layoutArrange: (s2, parent, field, fieldValues) => {
@@ -24,13 +24,16 @@ fetch(
// layoutArrange 可手动设置行、列顺序,适用于局部调整,非规则调整。
// 手动设置浙江省内部市的顺序,比如指定「宁波市」在第一位。
const keyIndex = fieldValues.indexOf('宁波市');
+
fieldValues.splice(keyIndex, 1);
fieldValues.unshift('宁波市');
}
+
return fieldValues;
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-layout/demo/custom-layout-hierarchy.ts b/s2-site/examples/custom/custom-layout/demo/custom-layout-hierarchy.ts
index c3264b7ef5..ebf310dc64 100644
--- a/s2-site/examples/custom/custom-layout/demo/custom-layout-hierarchy.ts
+++ b/s2-site/examples/custom/custom-layout/demo/custom-layout-hierarchy.ts
@@ -1,12 +1,18 @@
-import { PivotSheet, Node, generateId } from '@antv/s2';
+import {
+ PivotSheet,
+ Node,
+ generateId,
+ S2DataConfig,
+ S2Options,
+} from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -47,13 +53,14 @@ fetch(
],
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
layoutHierarchy: (s2, node) => {
// layoutHierarchy 用于手动控制行列结构的增加、删除的特殊场景。
// 以 「宁波市」为例,删除其节点,增加宁波A和宁波B节点。
const { field, value } = node;
+
if (field === 'city' && value === '宁波市') {
const preValue = '宁波A';
const nextValue = '宁波B';
@@ -65,14 +72,14 @@ fetch(
...node,
id: preUniqueId,
value: preValue,
- query: { ...parentNode.query, [node.field]: preValue },
+ query: { ...parentNode?.query, [node.field]: preValue },
});
const nextNode = new Node({
...node,
id: nextUniqueId,
value: nextValue,
- query: { ...parentNode.query, [node.field]: nextValue },
+ query: { ...parentNode?.query, [node.field]: nextValue },
});
return {
@@ -81,10 +88,12 @@ fetch(
delete: true,
};
}
+
return null;
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-layout/demo/custom-value-order.ts b/s2-site/examples/custom/custom-layout/demo/custom-value-order.ts
index ba02eedb84..9fa3af4c0a 100644
--- a/s2-site/examples/custom/custom-layout/demo/custom-value-order.ts
+++ b/s2-site/examples/custom/custom-layout/demo/custom-value-order.ts
@@ -1,12 +1,12 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -18,12 +18,12 @@ fetch(
data: res.data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
};
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-order/demo/custom-order.tsx b/s2-site/examples/custom/custom-order/demo/custom-order.tsx
index 8b61dd4e44..a5926b69d6 100644
--- a/s2-site/examples/custom/custom-order/demo/custom-order.tsx
+++ b/s2-site/examples/custom/custom-order/demo/custom-order.tsx
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
+import { Node, S2DataConfig, TooltipOptions } from '@antv/s2';
const SortMethodType = {
asc: 'asc',
@@ -10,22 +11,23 @@ const SortMethodType = {
};
const MENUS = [
- { key: SortMethodType.none, text: '不排序' },
- { key: SortMethodType.asc, text: '升序', icon: 'GroupAsc' },
- { key: SortMethodType.desc, text: '降序', icon: 'GroupDesc' },
- { key: SortMethodType.custom, text: '自定义排序', icon: 'Trend' },
+ { key: SortMethodType.none, label: '不排序' },
+ { key: SortMethodType.asc, label: '升序', icon: 'GroupAsc' },
+ { key: SortMethodType.desc, label: '降序', icon: 'GroupDesc' },
+ { key: SortMethodType.custom, label: '自定义排序', icon: 'Trend' },
];
-const s2DataConfig = {
+
+const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
values: ['number'],
},
meta: undefined,
- data: undefined,
+ data: [],
};
-const s2Options = {
+const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
// 关闭默认icon
@@ -70,7 +72,7 @@ const App = () => {
const [sortParams, setSortParams] = useState([]);
// 设置自定义 `icon` 的展示条件
- const headerActionIcons = [
+ const headerActionIcons: SheetComponentOptions['headerActionIcons'] = [
{
// 选择icon,可以是 S2 自带的,也可以是自定义的 icon
icons: ['customKingIcon'],
@@ -80,7 +82,7 @@ const App = () => {
// icon 点击之后的执行函数
onClick: (props) => {
const { meta, event } = props;
- const operator = {
+ const operator: TooltipOptions['operator'] = {
menu: {
onClick: ({ key }) => {
handleSortCallback(meta, key);
@@ -101,7 +103,7 @@ const App = () => {
];
// 执行自定义排序回调
- const handleSortCallback = (meta, key) => {
+ const handleSortCallback = (meta: Node, key: string) => {
if (key === SortMethodType.custom) {
const sortParams = [
{ sortFieldId: 'type', sortBy: ['办公用品', '家具'] },
@@ -124,5 +126,4 @@ const App = () => {
);
};
-// 使用
ReactDOM.render(, document.getElementById('container'));
diff --git a/s2-site/examples/custom/custom-plugins/demo/custom-plugins.ts b/s2-site/examples/custom/custom-plugins/demo/custom-plugins.ts
index fb7f25bee5..1a8150e954 100644
--- a/s2-site/examples/custom/custom-plugins/demo/custom-plugins.ts
+++ b/s2-site/examples/custom/custom-plugins/demo/custom-plugins.ts
@@ -1,4 +1,4 @@
-import { PivotSheet, S2Options } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
import { Plugin as PluginRoughCanvasRenderer } from '@antv/g-plugin-rough-canvas-renderer';
import { Plugin as PluginA11y } from '@antv/g-plugin-a11y';
@@ -6,9 +6,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -73,5 +73,5 @@ fetch(
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-tree/demo/custom-pivot-col-header.ts b/s2-site/examples/custom/custom-tree/demo/custom-pivot-col-header.ts
index c8b1c76e9f..d74952d7be 100644
--- a/s2-site/examples/custom/custom-tree/demo/custom-pivot-col-header.ts
+++ b/s2-site/examples/custom/custom-tree/demo/custom-pivot-col-header.ts
@@ -56,7 +56,7 @@ const data = [
},
];
-function render() {
+async function render() {
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
@@ -88,7 +88,7 @@ function render() {
// 自定义格式化数值
// {
// field: 'measure-1',
- // formatter: (value) => `指标: ${value}`,
+ // formatter: (value, record, meta) => `指标: ${value}`,
// },
],
};
@@ -101,7 +101,7 @@ function render() {
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
}
render();
diff --git a/s2-site/examples/custom/custom-tree/demo/custom-pivot-row-header.ts b/s2-site/examples/custom/custom-tree/demo/custom-pivot-row-header.ts
index a04033c25f..5d8e310dcb 100644
--- a/s2-site/examples/custom/custom-tree/demo/custom-pivot-row-header.ts
+++ b/s2-site/examples/custom/custom-tree/demo/custom-pivot-row-header.ts
@@ -74,13 +74,13 @@ function createCheckbox(s2: SpreadSheet) {
text.className = 'hierarchy-type';
text.innerHTML = '树状模式';
- checkbox.addEventListener('change', () => {
+ checkbox.addEventListener('change', async () => {
const hierarchyType = checkbox.checked ? 'tree' : 'grid';
s2.setOptions({
hierarchyType,
});
- s2.render(false);
+ await s2.render(false);
});
canvas?.before(checkbox);
@@ -113,7 +113,7 @@ async function render() {
// 自定义格式化数值
// {
// field: 'measure-1',
- // formatter: (value) => `指标: ${value}`,
+ // formatter: (value, record, meta) => `指标: ${value}`,
// },
],
};
diff --git a/s2-site/examples/custom/custom-tree/demo/custom-table-col-header.ts b/s2-site/examples/custom/custom-tree/demo/custom-table-col-header.ts
index fc227343ec..b5ecd4b07f 100644
--- a/s2-site/examples/custom/custom-tree/demo/custom-table-col-header.ts
+++ b/s2-site/examples/custom/custom-tree/demo/custom-table-col-header.ts
@@ -25,7 +25,7 @@ export const tableSheetMultipleColumns: CustomTreeNode[] = [
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
fields: {
@@ -53,5 +53,5 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
const s2 = new TableSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/custom/custom-tree/demo/custom-tree.ts b/s2-site/examples/custom/custom-tree/demo/custom-tree.ts
index cf0762ed11..1843be8794 100644
--- a/s2-site/examples/custom/custom-tree/demo/custom-tree.ts
+++ b/s2-site/examples/custom/custom-tree/demo/custom-tree.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/af54ea12-01d7-4696-a51c-c4d5e4ede28e.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
fields: {
@@ -32,5 +32,5 @@ fetch(
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/advanced/demo/custom-tree-link-jump.ts b/s2-site/examples/interaction/advanced/demo/custom-tree-link-jump.ts
index 357099ed67..8585e4c312 100644
--- a/s2-site/examples/interaction/advanced/demo/custom-tree-link-jump.ts
+++ b/s2-site/examples/interaction/advanced/demo/custom-tree-link-jump.ts
@@ -1,14 +1,14 @@
-import { S2Event, PivotSheet } from '@antv/s2';
+import { S2Event, PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/af54ea12-01d7-4696-a51c-c4d5e4ede28e.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
- rows: [],
+ rows: res.customTreeItem,
columns: ['type', 'sub_type'],
values: [
'measure-a',
@@ -18,15 +18,15 @@ fetch(
'measure-e',
'measure-f',
],
- customTreeItems: res.customTreeItem,
valueInCols: false,
},
data: res.data,
};
- const s2Options = {
+
+ const s2Options: S2Options = {
width: 600,
height: 480,
- hierarchyType: 'customTree',
+ hierarchyType: 'tree',
interaction: {
linkFields: [
'custom-node-1',
@@ -43,19 +43,21 @@ fetch(
],
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.on(S2Event.GLOBAL_LINK_FIELD_JUMP, (data) => {
- console.log(data);
+ s2.on(S2Event.GLOBAL_LINK_FIELD_JUMP, (jumpData) => {
+ console.log('jumpData:', jumpData);
- const { key, record } = data;
- const value = record[key];
+ const { field, record } = jumpData;
+ const value = record?.[field];
const a = document.createElement('a');
+
a.target = '_blank';
- a.href = `https://antv-s2.gitee.io/zh/docs/manual/introduction?${key}=${value}`;
+ a.href = `https://antv-s2.gitee.io/zh/docs/manual/introduction?${field}=${value}`;
a.click();
a.remove();
});
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/advanced/demo/merge-cell.ts b/s2-site/examples/interaction/advanced/demo/merge-cell.ts
index 3920c71ab9..a6b1be6164 100644
--- a/s2-site/examples/interaction/advanced/demo/merge-cell.ts
+++ b/s2-site/examples/interaction/advanced/demo/merge-cell.ts
@@ -1,28 +1,15 @@
-import { PivotSheet, S2Event } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Event, S2Options } from '@antv/s2';
import insertCss from 'insert-css';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
const button = document.createElement('button');
- const dataCellTooltip = () => {
- button.innerText = '点击合并单元格';
- button.className = 'merge-cells-button';
- button.onclick = () => s2.interaction.mergeCells();
- return button;
- }; // (按住 Cmd/ Ctrl 多选)
-
- const mergedCellsTooltip = (mergedCell) => {
- button.innerText = '取消合并单元格';
- button.className = 'merge-cells-button';
- button.onclick = () => s2.interaction.unmergeCell(mergedCell);
- return button;
- };
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -32,10 +19,12 @@ fetch(
meta: res.meta,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
- selectedCellsSpotlight: true,
+ interaction: {
+ selectedCellsSpotlight: true,
+ },
mergedCellsInfo: [
[
{ colIndex: 1, rowIndex: 6, showText: true },
@@ -47,8 +36,25 @@ fetch(
],
],
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
+ const dataCellTooltip = () => {
+ button.innerText = '点击合并单元格';
+ button.className = 'merge-cells-button';
+ button.onclick = () => s2.interaction.mergeCells();
+
+ return button;
+ };
+
+ const mergedCellsTooltip = (mergedCell) => {
+ button.innerText = '取消合并单元格';
+ button.className = 'merge-cells-button';
+ button.onclick = () => s2.interaction.unmergeCell(mergedCell);
+
+ return button;
+ };
+
s2.on(S2Event.DATA_CELL_CLICK, (event) => {
s2.tooltip.show({
position: { x: event.clientX, y: event.clientY },
@@ -58,13 +64,14 @@ fetch(
s2.on(S2Event.MERGED_CELLS_CLICK, (event) => {
const cell = s2.getCell(event.target);
+
s2.tooltip.show({
position: { x: event.clientX, y: event.clientY },
content: mergedCellsTooltip(cell),
});
});
- s2.render();
+ await s2.render();
});
insertCss(`
diff --git a/s2-site/examples/interaction/advanced/demo/overscroll-behavior.ts b/s2-site/examples/interaction/advanced/demo/overscroll-behavior.ts
index c982d3bf9c..f7c83d77a5 100644
--- a/s2-site/examples/interaction/advanced/demo/overscroll-behavior.ts
+++ b/s2-site/examples/interaction/advanced/demo/overscroll-behavior.ts
@@ -1,13 +1,13 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
style: {
@@ -27,5 +27,5 @@ fetch(
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/advanced/demo/pivot-hide-columns.ts b/s2-site/examples/interaction/advanced/demo/pivot-hide-columns.ts
index ad98cbf352..b3bd8d9947 100644
--- a/s2-site/examples/interaction/advanced/demo/pivot-hide-columns.ts
+++ b/s2-site/examples/interaction/advanced/demo/pivot-hide-columns.ts
@@ -1,13 +1,13 @@
-import { PivotSheet, S2Event } from '@antv/s2';
+import { PivotSheet, S2Event, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
@@ -23,6 +23,7 @@ fetch(
},
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
s2.on(S2Event.COL_CELL_EXPANDED, (cell) => {
@@ -35,5 +36,5 @@ fetch(
},
);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/advanced/demo/pivot-link-jump.ts b/s2-site/examples/interaction/advanced/demo/pivot-link-jump.ts
index 5d2c0db702..654fc29253 100644
--- a/s2-site/examples/interaction/advanced/demo/pivot-link-jump.ts
+++ b/s2-site/examples/interaction/advanced/demo/pivot-link-jump.ts
@@ -1,32 +1,34 @@
-import { S2Event, PivotSheet } from '@antv/s2';
+import { S2Event, PivotSheet, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
linkFields: ['city', 'number'],
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.on(S2Event.GLOBAL_LINK_FIELD_JUMP, (data) => {
- console.log(data);
+ s2.on(S2Event.GLOBAL_LINK_FIELD_JUMP, (jumpData) => {
+ console.log('jumpData:', jumpData);
- const { field, record } = data;
- const value = record[field];
+ const { field, record } = jumpData;
+ const value = record?.[field];
const a = document.createElement('a');
+
a.target = '_blank';
a.href = `https://antv-s2.gitee.io/zh/docs/manual/introduction?${field}=${value}`;
a.click();
a.remove();
});
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/advanced/demo/resize-active.ts b/s2-site/examples/interaction/advanced/demo/resize-active.ts
index 53718f89f2..d94badfa87 100644
--- a/s2-site/examples/interaction/advanced/demo/resize-active.ts
+++ b/s2-site/examples/interaction/advanced/demo/resize-active.ts
@@ -1,7 +1,7 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2Options, SpreadSheet, SpreadSheet } from '@antv/s2';
import insertCss from 'insert-css';
-function createRadioGroup(s2) {
+function createRadioGroup(s2: SpreadSheet) {
[
['rowCellVertical', '行头热区'],
['cornerCellHorizontal', '角头热区'],
@@ -15,9 +15,10 @@ function createRadioGroup(s2) {
radio.value = value;
radio.checked = true;
- radio.addEventListener('click', (e) => {
+ radio.addEventListener('click', async (e) => {
const value = e.target.value;
const updated = !s2.options.interaction.resize[value];
+
radio.checked = updated;
s2.setOptions({
@@ -27,15 +28,17 @@ function createRadioGroup(s2) {
},
},
});
- s2.render(false);
+
+ await s2.render(false);
});
const label = document.createElement('label');
+
label.innerText = text;
label.htmlFor = 'name';
- document.querySelector('#container > canvas').before(radio);
- document.querySelector('#container > canvas').before(label);
+ document.querySelector('#container > canvas')?.before(radio);
+ document.querySelector('#container > canvas')?.before(label);
});
}
@@ -43,10 +46,10 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
@@ -61,9 +64,9 @@ fetch(
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render().then(() => {
- createRadioGroup(s2);
- });
+ await s2.render();
+
+ createRadioGroup(s2);
});
insertCss(`
diff --git a/s2-site/examples/interaction/advanced/demo/resize-disable.ts b/s2-site/examples/interaction/advanced/demo/resize-disable.ts
index aa064393a7..3c4555e328 100644
--- a/s2-site/examples/interaction/advanced/demo/resize-disable.ts
+++ b/s2-site/examples/interaction/advanced/demo/resize-disable.ts
@@ -1,19 +1,20 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
resize: {
disable: (resizeInfo) => {
console.log('resizeInfo: ', resizeInfo);
+
// 不允许调小宽度
return resizeInfo.resizedWidth <= resizeInfo.width;
// 不允许调小高度
@@ -25,5 +26,5 @@ fetch(
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/advanced/demo/row-expand-depth.ts b/s2-site/examples/interaction/advanced/demo/row-expand-depth.ts
index e385305cbb..7f6c5063ba 100644
--- a/s2-site/examples/interaction/advanced/demo/row-expand-depth.ts
+++ b/s2-site/examples/interaction/advanced/demo/row-expand-depth.ts
@@ -13,9 +13,10 @@ function createRadioGroup(s2: SpreadSheet) {
radio.value = value;
radio.checked = value === 0;
- radio.addEventListener('click', (e) => {
+ radio.addEventListener('click', async (e) => {
const value = e.target.value;
const updated = !s2.options.interaction.resize[value];
+
radio.checked = updated;
s2.setOptions({
@@ -25,15 +26,17 @@ function createRadioGroup(s2: SpreadSheet) {
},
},
});
- s2.render(false);
+
+ await s2.render(false);
});
const label = document.createElement('label');
+
label.innerText = text;
label.htmlFor = 'name';
- document.querySelector('#container > canvas').before(radio);
- document.querySelector('#container > canvas').before(label);
+ document.querySelector('#container > canvas')?.before(radio);
+ document.querySelector('#container > canvas')?.before(label);
});
}
@@ -41,7 +44,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/e254339f-46df-4be0-81b0-a3b1e26b39ff.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
const s2Options: S2Options = {
@@ -50,14 +53,15 @@ fetch(
hierarchyType: 'tree',
style: {
rowCell: {
- expandDepth: 0, // 展开一级维度的子节点
+ // 展开一级维度的子节点
+ expandDepth: 0,
},
},
};
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render().then(() => {
- createRadioGroup(s2);
- });
+ await s2.render();
+
+ createRadioGroup(s2);
});
diff --git a/s2-site/examples/interaction/advanced/demo/scroll-loop.ts b/s2-site/examples/interaction/advanced/demo/scroll-loop.ts
index 305e1f16e1..5119209d94 100644
--- a/s2-site/examples/interaction/advanced/demo/scroll-loop.ts
+++ b/s2-site/examples/interaction/advanced/demo/scroll-loop.ts
@@ -1,4 +1,4 @@
-import { PivotSheet, S2Event } from '@antv/s2';
+import { PivotSheet, S2Event, S2Options } from '@antv/s2';
import insertCss from 'insert-css';
// 每次滚动的距离
@@ -12,10 +12,12 @@ let timer;
function addScrollButton(s2) {
const btn = document.createElement('button');
+
btn.className = 'ant-btn ant-btn-default';
btn.innerHTML = '开始滚动';
const stopBtn = document.createElement('button');
+
stopBtn.className = 'ant-btn ant-btn-default';
stopBtn.innerHTML = '停止滚动';
@@ -33,18 +35,22 @@ function addScrollButton(s2) {
timer = setInterval(() => {
// 获取当前 Y 轴滚动距离
const { scrollY } = s2.facet.getScrollOffset();
+
// 访问 https://s2.antv.antgroup.com/zh/docs/api 查看更多 API
// 如果已经滚动到了底部,则回到顶部
if (s2.facet.isScrollToBottom(scrollY)) {
console.log('滚动到底部');
+
s2.updateScrollOffset({
offsetY: {
value: 0,
animate: false,
},
});
+
return;
}
+
console.log('开始滚动, 当前 scrollY:', scrollY);
s2.updateScrollOffset({
offsetY: {
@@ -54,7 +60,8 @@ function addScrollButton(s2) {
});
}, MS);
});
- document.querySelector('#container > canvas').before(btn);
+
+ document.querySelector('#container > canvas')?.before(btn);
btn.after(stopBtn);
}
@@ -62,10 +69,10 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
style: {
@@ -75,6 +82,7 @@ fetch(
},
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
// 记得在表格卸载后 或者 `s2.destroy()` 后清除定时器
@@ -82,9 +90,9 @@ fetch(
clearInterval(timer);
});
- s2.render().then(() => {
- addScrollButton(s2);
- });
+ await s2.render();
+
+ addScrollButton(s2);
});
insertCss(`
diff --git a/s2-site/examples/interaction/advanced/demo/scroll-speed-ratio.ts b/s2-site/examples/interaction/advanced/demo/scroll-speed-ratio.ts
index c835361025..3b786ddc50 100644
--- a/s2-site/examples/interaction/advanced/demo/scroll-speed-ratio.ts
+++ b/s2-site/examples/interaction/advanced/demo/scroll-speed-ratio.ts
@@ -1,11 +1,12 @@
-import { TableSheet } from '@antv/s2';
+import { S2DataConfig, S2Options, SpreadSheet, TableSheet } from '@antv/s2';
import insertCss from 'insert-css';
const defaultScrollSpeedRatio = 1;
-function createSlider(s2) {
+function createSlider(s2: SpreadSheet) {
const slider = document.createElement('input');
+
slider.type = 'range';
slider.max = '5';
slider.min = '0';
@@ -14,7 +15,8 @@ function createSlider(s2) {
slider.title = `当前滚动速率: ${defaultScrollSpeedRatio}`;
slider.addEventListener('input', (e) => {
- const ratio = e.target.value;
+ const ratio = e.target?.value || 1;
+
console.log('ratio: ', ratio);
s2.setOptions({
@@ -27,15 +29,15 @@ function createSlider(s2) {
slider.title = `当前滚动速率: ${ratio}`;
});
- document.querySelector('#container > canvas').before(slider);
+ document.querySelector('#container > canvas')?.before(slider);
}
fetch('https://assets.antv.antgroup.com/s2/basic.json')
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
columns: ['province', 'city', 'type', 'price', 'cost'],
},
@@ -64,7 +66,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json')
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 300,
interaction: {
@@ -77,9 +79,9 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json')
const s2 = new TableSheet(container, s2DataConfig, s2Options);
- s2.render().then(() => {
- createSlider(s2);
- });
+ await s2.render();
+
+ createSlider(s2);
});
insertCss(`
diff --git a/s2-site/examples/interaction/advanced/demo/scroll-to-cell.ts b/s2-site/examples/interaction/advanced/demo/scroll-to-cell.ts
index ee938ed1bc..2fbfe51cfa 100644
--- a/s2-site/examples/interaction/advanced/demo/scroll-to-cell.ts
+++ b/s2-site/examples/interaction/advanced/demo/scroll-to-cell.ts
@@ -3,6 +3,7 @@ import insertCss from 'insert-css';
function addScrollRowHeaderButton(s2: SpreadSheet) {
const btn = document.createElement('button');
+
btn.className = 'ant-btn ant-btn-default';
btn.innerHTML = '滚动行头';
@@ -19,27 +20,29 @@ function addScrollRowHeaderButton(s2: SpreadSheet) {
function addScrollToCellButton(s2: SpreadSheet) {
const btn = document.createElement('button');
+
btn.className = 'ant-btn ant-btn-default';
btn.innerHTML = '滚动至成都市';
btn.addEventListener('click', () => {
// 获取行头是成都市对应的单元格
- const rowNode = s2
- .getRowNodes()
- .find(({ id }) => id === 'root[&]四川省[&]成都市');
+ const rowNode = s2.facet.getRowNodeById('root[&]四川省[&]成都市');
- s2.updateScrollOffset({
- offsetY: {
- value: rowNode?.y,
- animate: true,
- },
- });
+ if (rowNode) {
+ s2.updateScrollOffset({
+ offsetY: {
+ value: rowNode.y,
+ animate: true,
+ },
+ });
+ }
});
document.querySelector('#container > canvas')?.before(btn);
}
function addScrollToTopButton(s2: SpreadSheet) {
const btn = document.createElement('button');
+
btn.className = 'ant-btn ant-btn-default';
btn.innerHTML = '滚动至顶部';
@@ -58,13 +61,15 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
const s2Options: S2Options = {
width: 600,
height: 480,
- frozenRowHeader: true,
+ frozen: {
+ rowHeader: true,
+ },
style: {
// 让行头区域显示滚动条
rowCell: {
@@ -76,13 +81,14 @@ fetch(
},
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render().then(() => {
- addScrollToCellButton(s2);
- addScrollToTopButton(s2);
- addScrollRowHeaderButton(s2);
- });
+ await s2.render();
+
+ addScrollToCellButton(s2);
+ addScrollToTopButton(s2);
+ addScrollRowHeaderButton(s2);
});
insertCss(`
diff --git a/s2-site/examples/interaction/advanced/demo/table-hide-columns.ts b/s2-site/examples/interaction/advanced/demo/table-hide-columns.ts
index ce3178bbd0..de069134ff 100644
--- a/s2-site/examples/interaction/advanced/demo/table-hide-columns.ts
+++ b/s2-site/examples/interaction/advanced/demo/table-hide-columns.ts
@@ -1,10 +1,16 @@
-import { TableSheet, S2Event } from '@antv/s2';
+import {
+ TableSheet,
+ S2Event,
+ S2DataConfig,
+ S2Options,
+ S2Options,
+} from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
columns: ['type', 'province', 'city', 'price', 'cost'],
},
@@ -33,7 +39,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
interaction: {
@@ -48,6 +54,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
},
},
};
+
const s2 = new TableSheet(container, s2DataConfig, s2Options);
s2.on(S2Event.COL_CELL_EXPANDED, (cell) => {
@@ -60,5 +67,5 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
},
);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/advanced/demo/table-link-jump.ts b/s2-site/examples/interaction/advanced/demo/table-link-jump.ts
index cd7e0418bb..ed9ac8a08d 100644
--- a/s2-site/examples/interaction/advanced/demo/table-link-jump.ts
+++ b/s2-site/examples/interaction/advanced/demo/table-link-jump.ts
@@ -1,10 +1,10 @@
-import { S2Event, TableSheet } from '@antv/s2';
+import { S2DataConfig, S2DataConfig, S2Event, TableSheet } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
columns: ['type', 'province', 'city', 'price', 'cost'],
},
@@ -43,17 +43,18 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
const s2 = new TableSheet(container, s2DataConfig, s2Options);
- s2.on(S2Event.GLOBAL_LINK_FIELD_JUMP, (data) => {
- console.log(data);
+ s2.on(S2Event.GLOBAL_LINK_FIELD_JUMP, (jumpData) => {
+ console.log('jumpData:', jumpData);
- const { field, record } = data;
- const value = record[field];
+ const { field, record } = jumpData;
+ const value = record?.[field];
const a = document.createElement('a');
+
a.target = '_blank';
a.href = `https://antv-s2.gitee.io/zh/docs/manual/introduction?${field}=${value}`;
a.click();
a.remove();
});
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/basic/demo/auto-reset-sheet-style.ts b/s2-site/examples/interaction/basic/demo/auto-reset-sheet-style.ts
index 3482a04eda..22b2f6e44f 100644
--- a/s2-site/examples/interaction/basic/demo/auto-reset-sheet-style.ts
+++ b/s2-site/examples/interaction/basic/demo/auto-reset-sheet-style.ts
@@ -2,7 +2,7 @@ import { S2DataConfig, S2Options, TableSheet } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
fields: {
@@ -37,10 +37,12 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
width: 600,
height: 480,
interaction: {
- autoResetSheetStyle: true, // 在鼠标移出表格区域后,自动 reset hover 高亮状态
+ // 在按下 ESC 键或者鼠标移出表格区域后,自动重置单元格选中,高亮状态
+ autoResetSheetStyle: true,
},
};
const s2 = new TableSheet(container, s2DataConfig, s2Options);
- s2.render();
+
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/basic/demo/brush-header.ts b/s2-site/examples/interaction/basic/demo/brush-header.ts
index b80ffaf1ae..73c2a00bda 100644
--- a/s2-site/examples/interaction/basic/demo/brush-header.ts
+++ b/s2-site/examples/interaction/basic/demo/brush-header.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
const s2Options: S2Options = {
@@ -22,7 +22,7 @@ fetch(
enableCopy: true,
},
style: {
- cellCfg: {
+ dataCell: {
height: 100,
},
},
@@ -30,6 +30,7 @@ fetch(
enable: true,
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
// 可以监听各自单元格区域的刷选事件
@@ -48,5 +49,5 @@ fetch(
console.log('selected', cells);
});
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/basic/demo/brush-selection.ts b/s2-site/examples/interaction/basic/demo/brush-selection.ts
index 42f06f165e..a8e01977f3 100644
--- a/s2-site/examples/interaction/basic/demo/brush-selection.ts
+++ b/s2-site/examples/interaction/basic/demo/brush-selection.ts
@@ -19,7 +19,7 @@ fetch(
// brushSelection: false,
},
style: {
- cellCfg: {
+ dataCell: {
height: 100,
},
},
@@ -27,11 +27,12 @@ fetch(
enable: true,
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
s2.on(S2Event.DATA_CELL_BRUSH_SELECTION, (cells) => {
console.log('dataCelBrushSelection', cells);
});
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/basic/demo/data-cell-click-selection.ts b/s2-site/examples/interaction/basic/demo/data-cell-click-selection.ts
index b1fabfb5f7..e61c375d62 100644
--- a/s2-site/examples/interaction/basic/demo/data-cell-click-selection.ts
+++ b/s2-site/examples/interaction/basic/demo/data-cell-click-selection.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
const s2Options: S2Options = {
@@ -21,11 +21,12 @@ fetch(
enable: true,
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
s2.on(S2Event.GLOBAL_SELECTED, (cells) => {
console.log('selected', cells);
});
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/basic/demo/data-cell-range-selection.ts b/s2-site/examples/interaction/basic/demo/data-cell-range-selection.ts
index 84fc99463b..6e55b39bce 100644
--- a/s2-site/examples/interaction/basic/demo/data-cell-range-selection.ts
+++ b/s2-site/examples/interaction/basic/demo/data-cell-range-selection.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
// 试试选中一个单元格, 然后按住 Shift 选中另一个单元格
@@ -21,6 +21,7 @@ fetch(
enable: true,
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
// 也可以监听全局的选中事件
@@ -28,5 +29,5 @@ fetch(
console.log('selected', cells);
});
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/basic/demo/frozen.ts b/s2-site/examples/interaction/basic/demo/frozen.ts
index a3579c7b0c..24d93980d8 100644
--- a/s2-site/examples/interaction/basic/demo/frozen.ts
+++ b/s2-site/examples/interaction/basic/demo/frozen.ts
@@ -2,7 +2,7 @@ import { S2DataConfig, S2Options, TableSheet } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
- .then((res) => {
+ .then(async (res) => {
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
@@ -35,14 +35,18 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
height: 480,
showSeriesNumber: true,
frozen: {
- rowCount: 1, // 行头冻结数量
- colCount: 1, // 列头冻结数量
- trailingRowCount: 1, // 列尾冻结数量
- trailingColCount: 1, // 列尾冻结数量
+ // 行头冻结数量
+ rowCount: 1,
+ // 列头冻结数量
+ colCount: 1,
+ // 列尾冻结数量
+ trailingRowCount: 1,
+ // 列尾冻结数量
+ trailingColCount: 1,
},
};
const s2 = new TableSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/basic/demo/header-cell-click-selection.ts b/s2-site/examples/interaction/basic/demo/header-cell-click-selection.ts
index d8f36d5d2d..3c477e7796 100644
--- a/s2-site/examples/interaction/basic/demo/header-cell-click-selection.ts
+++ b/s2-site/examples/interaction/basic/demo/header-cell-click-selection.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
// 试试 (按住 Ctrl/Command) 对行列头进行多选
@@ -29,5 +29,5 @@ fetch(
console.log('selected', cells);
});
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/basic/demo/hover.ts b/s2-site/examples/interaction/basic/demo/hover.ts
index 88a4795ef8..06a540ef31 100644
--- a/s2-site/examples/interaction/basic/demo/hover.ts
+++ b/s2-site/examples/interaction/basic/demo/hover.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
const s2Options: S2Options = {
@@ -18,7 +18,8 @@ fetch(
enable: true,
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/basic/demo/resize.ts b/s2-site/examples/interaction/basic/demo/resize.ts
index 9d0dfe0d8d..acdf2cf183 100644
--- a/s2-site/examples/interaction/basic/demo/resize.ts
+++ b/s2-site/examples/interaction/basic/demo/resize.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
const s2Options: S2Options = {
@@ -12,13 +12,14 @@ fetch(
height: 480,
interaction: {
hoverHighlight: true,
- selectedCellsSpotlight: true, // highlight selection
+ selectedCellsSpotlight: true,
},
tooltip: {
enable: true,
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/custom/demo/double-click-hide-columns.ts b/s2-site/examples/interaction/custom/demo/double-click-hide-columns.ts
index 2e9a9d8087..45cdb3aa57 100644
--- a/s2-site/examples/interaction/custom/demo/double-click-hide-columns.ts
+++ b/s2-site/examples/interaction/custom/demo/double-click-hide-columns.ts
@@ -1,4 +1,11 @@
-import { TableSheet, BaseEvent, S2Event } from '@antv/s2';
+/* eslint-disable max-classes-per-file */
+import {
+ TableSheet,
+ BaseEvent,
+ S2Event,
+ S2DataConfig,
+ S2Options,
+} from '@antv/s2';
class HiddenInteraction extends BaseEvent {
bindEvents() {
@@ -37,9 +44,9 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/4eff53f3-f952-4b77-8862-4b6ecbd31667.json',
)
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
columns: ['type', 'province', 'city', 'price', 'cost'],
},
@@ -68,7 +75,7 @@ fetch(
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
tooltip: {
@@ -90,5 +97,5 @@ fetch(
const s2 = new TableSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/interaction/custom/demo/row-col-hover-tooltip.ts b/s2-site/examples/interaction/custom/demo/row-col-hover-tooltip.ts
index b03ac71bf0..451dfdb11a 100644
--- a/s2-site/examples/interaction/custom/demo/row-col-hover-tooltip.ts
+++ b/s2-site/examples/interaction/custom/demo/row-col-hover-tooltip.ts
@@ -1,4 +1,4 @@
-import { PivotSheet, BaseEvent, S2Event } from '@antv/s2';
+import { PivotSheet, BaseEvent, S2Event, S2Options } from '@antv/s2';
class RowColumnHoverTooltipInteraction extends BaseEvent {
bindEvents() {
@@ -31,10 +31,10 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
tooltip: {
@@ -52,5 +52,5 @@ fetch(
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/layout/adaptive/demo/container-adaptation.ts b/s2-site/examples/layout/adaptive/demo/container-adaptation.ts
index f24bac0d45..8cceac56a2 100644
--- a/s2-site/examples/layout/adaptive/demo/container-adaptation.ts
+++ b/s2-site/examples/layout/adaptive/demo/container-adaptation.ts
@@ -1,38 +1,48 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2Event, S2Options } from '@antv/s2';
import { debounce } from 'lodash';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
+
container.innerHTML =
'';
const content = document.getElementById('content');
+
setTimeout(() => {
content.style.width = '300px';
}, 1000);
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
};
+
const s2 = new PivotSheet(content, dataCfg, s2Options);
- s2.render().then(() => {
- const debounceRender = debounce((width, height) => {
- s2.changeSheetSize(width, height);
- s2.render(false); // 不重新加载数据
- }, 200);
-
- const resizeObserver = new ResizeObserver(([entry] = []) => {
- const [size] = entry.borderBoxSize || [];
- debounceRender(size.inlineSize, size.blockSize);
- });
- resizeObserver.observe(content);
+ await s2.render();
+
+ const debounceRender = debounce(async (width, height) => {
+ s2.changeSheetSize(width, height);
+ await s2.render(false);
+ }, 200);
+
+ const resizeObserver = new ResizeObserver(([entry] = []) => {
+ const [size] = entry.borderBoxSize || [];
+
+ debounceRender(size.inlineSize, size.blockSize);
+ });
+
+ resizeObserver.observe(content);
+
+ // 别忘了表格销毁时取消监听
+ s2.on(S2Event.LAYOUT_DESTROY, () => {
+ resizeObserver.disconnect();
});
});
diff --git a/s2-site/examples/layout/adaptive/demo/react-adaptive.tsx b/s2-site/examples/layout/adaptive/demo/react-adaptive.tsx
index f89d279ec9..397e00c5cc 100644
--- a/s2-site/examples/layout/adaptive/demo/react-adaptive.tsx
+++ b/s2-site/examples/layout/adaptive/demo/react-adaptive.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import { concat, debounce, forEach, map } from 'lodash';
fetch(
@@ -8,18 +8,21 @@ fetch(
)
.then((res) => res.json())
.then((dataCfg) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
};
-
ReactDOM.render(
- document.getElementById('container')
- }} />,
+ getContainer: () => document.getElementById('container'),
+ }}
+ />,
document.getElementById('container'),
);
});
diff --git a/s2-site/examples/layout/adaptive/demo/window-adaptation.ts b/s2-site/examples/layout/adaptive/demo/window-adaptation.ts
index 23d6a86a39..00bc41a8a2 100644
--- a/s2-site/examples/layout/adaptive/demo/window-adaptation.ts
+++ b/s2-site/examples/layout/adaptive/demo/window-adaptation.ts
@@ -1,27 +1,38 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2Event, S2Options } from '@antv/s2';
import { debounce } from 'lodash';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render().then(() => {
- const debounceRender = debounce((width, height) => {
- s2.changeSheetSize(width, height);
- s2.render(false); // 不重新加载数据
- }, 200);
-
- new ResizeObserver(([entry] = []) => {
- const [size] = entry.borderBoxSize || [];
- debounceRender(size.inlineSize, size.blockSize);
- }).observe(document.body); // 通过监听 document.body 来实现监听窗口大小变化
+
+ await s2.render();
+
+ const debounceRender = debounce(async (width, height) => {
+ s2.changeSheetSize(width, height);
+ await s2.render(false);
+ }, 200);
+
+ const resizeObserver = new ResizeObserver(([entry] = []) => {
+ const [size] = entry.borderBoxSize || [];
+
+ debounceRender(size.inlineSize, size.blockSize);
+ });
+
+ // 通过监听 document.body 来实现监听窗口大小变化
+ resizeObserver.observe(document.body);
+
+ // 别忘了表格销毁时取消监听
+ s2.on(S2Event.LAYOUT_DESTROY, () => {
+ resizeObserver.disconnect();
});
});
diff --git a/s2-site/examples/layout/basic/demo/colAdaptive.ts b/s2-site/examples/layout/basic/demo/colAdaptive.ts
index a8c54becc5..d8f7e8a253 100644
--- a/s2-site/examples/layout/basic/demo/colAdaptive.ts
+++ b/s2-site/examples/layout/basic/demo/colAdaptive.ts
@@ -1,20 +1,21 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
style: {
layoutWidthType: 'colAdaptive',
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/layout/basic/demo/compact.ts b/s2-site/examples/layout/basic/demo/compact.ts
index bf1b9ce198..782a4c57d8 100644
--- a/s2-site/examples/layout/basic/demo/compact.ts
+++ b/s2-site/examples/layout/basic/demo/compact.ts
@@ -1,20 +1,21 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
- const s2Options = {
+ const s2Options: S2Options = {
width: 400,
height: 480,
style: {
layoutWidthType: 'compact',
},
};
+
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/layout/custom/demo/custom-pivot-size.ts b/s2-site/examples/layout/custom/demo/custom-pivot-size.ts
index 3c0d9025d9..f358497965 100644
--- a/s2-site/examples/layout/custom/demo/custom-pivot-size.ts
+++ b/s2-site/examples/layout/custom/demo/custom-pivot-size.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
// 详情请查看: https://s2.antv.antgroup.com/zh/docs/manual/advanced/custom/cell-size
@@ -42,5 +42,6 @@ fetch(
};
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+
+ await s2.render();
});
diff --git a/s2-site/examples/layout/custom/demo/custom-row-col-cell-width.ts b/s2-site/examples/layout/custom/demo/custom-row-col-cell-width.ts
index 54b1b81ebc..b8aafd657d 100644
--- a/s2-site/examples/layout/custom/demo/custom-row-col-cell-width.ts
+++ b/s2-site/examples/layout/custom/demo/custom-row-col-cell-width.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
// 详情请查看: https://s2.antv.antgroup.com/zh/docs/manual/advanced/custom/cell-size
@@ -19,6 +19,7 @@ fetch(
// 动态配置: 叶子节点 300px, 非叶子节点 200px
width: (row) => {
console.log('row: ', row);
+
return row.isLeaf ? 300 : 200;
},
},
@@ -28,6 +29,7 @@ fetch(
// 动态配置: 偶数列 100px, 奇数列 200px
width: (col) => {
console.log('col: ', col);
+
return col.colIndex % 2 === 0 ? 100 : 200;
},
},
@@ -38,5 +40,6 @@ fetch(
};
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+
+ await s2.render();
});
diff --git a/s2-site/examples/layout/custom/demo/custom-table-size.ts b/s2-site/examples/layout/custom/demo/custom-table-size.ts
index 60e53ebb31..aca09e9377 100644
--- a/s2-site/examples/layout/custom/demo/custom-table-size.ts
+++ b/s2-site/examples/layout/custom/demo/custom-table-size.ts
@@ -2,7 +2,7 @@ import { S2DataConfig, S2Options, TableSheet } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic.json')
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
// 详情请查看: https://s2.antv.antgroup.com/zh/docs/manual/advanced/custom/cell-size
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
@@ -57,7 +57,8 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json')
},
},
};
+
const s2 = new TableSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/layout/custom/demo/custom-tree-collapse-nodes.ts b/s2-site/examples/layout/custom/demo/custom-tree-collapse-nodes.ts
index f0451a11fa..641aeb4e51 100644
--- a/s2-site/examples/layout/custom/demo/custom-tree-collapse-nodes.ts
+++ b/s2-site/examples/layout/custom/demo/custom-tree-collapse-nodes.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
const s2Options: S2Options = {
@@ -29,5 +29,6 @@ fetch(
};
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+
+ await s2.render();
});
diff --git a/s2-site/examples/layout/custom/demo/custom-tree-row-width.ts b/s2-site/examples/layout/custom/demo/custom-tree-row-width.ts
index f9207689da..1800bbb497 100644
--- a/s2-site/examples/layout/custom/demo/custom-tree-row-width.ts
+++ b/s2-site/examples/layout/custom/demo/custom-tree-row-width.ts
@@ -4,7 +4,7 @@ fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
.then((res) => res.json())
- .then((dataCfg) => {
+ .then(async (dataCfg) => {
const container = document.getElementById('container');
// 详情请查看: https://s2.antv.antgroup.com/zh/docs/manual/advanced/custom/cell-size
@@ -20,5 +20,6 @@ fetch(
};
const s2 = new PivotSheet(container, dataCfg, s2Options);
- s2.render();
+
+ await s2.render();
});
diff --git a/s2-site/examples/layout/custom/demo/hide-columns.ts b/s2-site/examples/layout/custom/demo/hide-columns.ts
index ebc9c99c20..21113e5d1f 100644
--- a/s2-site/examples/layout/custom/demo/hide-columns.ts
+++ b/s2-site/examples/layout/custom/demo/hide-columns.ts
@@ -1,10 +1,10 @@
-import { TableSheet } from '@antv/s2';
+import { S2DataConfig, S2Options, TableSheet } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic.json')
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
columns: ['type', 'province', 'city', 'price', 'cost'],
},
@@ -33,7 +33,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json')
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
style: {
@@ -42,7 +42,8 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json')
},
},
};
+
const s2 = new TableSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/layout/custom/demo/hide-value.ts b/s2-site/examples/layout/custom/demo/hide-value.ts
index c0d82a1d68..ce4c6219ac 100644
--- a/s2-site/examples/layout/custom/demo/hide-value.ts
+++ b/s2-site/examples/layout/custom/demo/hide-value.ts
@@ -3,7 +3,7 @@ import { PivotSheet } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic.json')
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
fields: {
@@ -40,13 +40,14 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json')
width: 600,
height: 480,
style: {
- colCfg: {
+ colCell: {
// 隐藏数值 (数值挂列头时生效, 即 s2DataConfig.fields.values)
- hideMeasureColumn: true,
+ hideValue: true,
},
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/layout/custom/demo/only-show-row-header.ts b/s2-site/examples/layout/custom/demo/only-show-row-header.ts
index 0f0386fd29..1e76e36462 100644
--- a/s2-site/examples/layout/custom/demo/only-show-row-header.ts
+++ b/s2-site/examples/layout/custom/demo/only-show-row-header.ts
@@ -3,7 +3,7 @@ import { PivotSheet } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic.json')
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
fields: {
@@ -31,13 +31,14 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json')
width: 600,
height: 480,
style: {
- colCfg: {
+ colCell: {
// 当只有行头和数值时, 隐藏数值, 可以让表格只显示行头
- hideMeasureColumn: true,
+ hideValue: true,
},
},
};
+
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/react-component/drill-dwon/demo/for-pivot.tsx b/s2-site/examples/react-component/drill-dwon/demo/for-pivot.tsx
index 51151fe1d8..403f5fd86a 100644
--- a/s2-site/examples/react-component/drill-dwon/demo/for-pivot.tsx
+++ b/s2-site/examples/react-component/drill-dwon/demo/for-pivot.tsx
@@ -1,20 +1,25 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import {
+ SheetComponent,
+ SheetComponentOptions,
+ SheetComponentsProps,
+} from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
+import { S2DataConfig } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
.then((res) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
hierarchyType: 'tree',
};
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
@@ -26,7 +31,7 @@ fetch(
const sex = ['男', '女'];
- const PartDrillDown = {
+ const PartDrillDown: SheetComponentsProps['partDrillDown'] = {
drillConfig: {
dataSet: [
{
diff --git a/s2-site/examples/react-component/export/demo/export.tsx b/s2-site/examples/react-component/export/demo/export.tsx
index 10968b7cb7..ca33ffce15 100644
--- a/s2-site/examples/react-component/export/demo/export.tsx
+++ b/s2-site/examples/react-component/export/demo/export.tsx
@@ -1,14 +1,15 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
+import { S2DataConfig } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
.then((res) => res.json())
.then((res) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
interaction: {
@@ -16,7 +17,7 @@ fetch(
},
};
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
diff --git a/s2-site/examples/react-component/pagination/demo/pivot.tsx b/s2-site/examples/react-component/pagination/demo/pivot.tsx
index 55b7ed706b..8b7c5f8a49 100644
--- a/s2-site/examples/react-component/pagination/demo/pivot.tsx
+++ b/s2-site/examples/react-component/pagination/demo/pivot.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
fetch(
@@ -8,7 +8,7 @@ fetch(
)
.then((res) => res.json())
.then((dataCfg) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
pagination: {
diff --git a/s2-site/examples/react-component/pagination/demo/table.tsx b/s2-site/examples/react-component/pagination/demo/table.tsx
index 26ad84e4b5..1f27b7d6e4 100644
--- a/s2-site/examples/react-component/pagination/demo/table.tsx
+++ b/s2-site/examples/react-component/pagination/demo/table.tsx
@@ -1,12 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
+import { S2DataConfig } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
.then((res) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
pagination: {
@@ -15,7 +16,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
},
};
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
columns: ['province', 'city', 'type', 'price', 'cost'],
},
diff --git a/s2-site/examples/react-component/sheet/demo/editable.tsx b/s2-site/examples/react-component/sheet/demo/editable.tsx
index 387614cb0a..2fbf029cf9 100644
--- a/s2-site/examples/react-component/sheet/demo/editable.tsx
+++ b/s2-site/examples/react-component/sheet/demo/editable.tsx
@@ -40,10 +40,14 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
height: 480,
showSeriesNumber: true,
frozen: {
- rowCount: 1, // 行头冻结数量
- colCount: 1, // 列头冻结数量
- trailingRowCount: 1, // 行尾冻结数量
- trailingColCount: 1, // 列尾冻结数量
+ // 行头冻结数量
+ rowCount: 1,
+ // 列头冻结数量
+ colCount: 1,
+ // 行尾冻结数量
+ trailingRowCount: 1,
+ // 列尾冻结数量
+ trailingColCount: 1,
},
};
diff --git a/s2-site/examples/react-component/sheet/demo/pivot.tsx b/s2-site/examples/react-component/sheet/demo/pivot.tsx
index d29caddd33..2febbb28a8 100644
--- a/s2-site/examples/react-component/sheet/demo/pivot.tsx
+++ b/s2-site/examples/react-component/sheet/demo/pivot.tsx
@@ -1,6 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import {
+ SheetComponent,
+ SheetComponentOptions,
+ SheetComponentOptions,
+} from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
fetch(
@@ -8,7 +12,7 @@ fetch(
)
.then((res) => res.json())
.then((dataCfg) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
};
diff --git a/s2-site/examples/react-component/sheet/demo/strategy-mini-chart.tsx b/s2-site/examples/react-component/sheet/demo/strategy-mini-chart.tsx
index e779069b83..eef8fd550f 100644
--- a/s2-site/examples/react-component/sheet/demo/strategy-mini-chart.tsx
+++ b/s2-site/examples/react-component/sheet/demo/strategy-mini-chart.tsx
@@ -12,18 +12,20 @@ fetch(
width: 1000,
height: 480,
cornerText: '指标层级',
- hierarchyType: 'customTree',
+ hierarchyType: 'tree',
conditions: {
text: [
{
field: 'number',
mapping: (value, cellInfo) => {
const { meta, colIndex } = cellInfo;
+
if (colIndex === 0 || !value || !meta?.fieldValue) {
return {
fill: '#000',
};
}
+
return {
fill: value > 0 ? '#FF4D4F' : '#29A294',
};
diff --git a/s2-site/examples/react-component/sheet/demo/table.tsx b/s2-site/examples/react-component/sheet/demo/table.tsx
index faa145c0fd..8d4e5b3773 100644
--- a/s2-site/examples/react-component/sheet/demo/table.tsx
+++ b/s2-site/examples/react-component/sheet/demo/table.tsx
@@ -1,19 +1,18 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
+import { S2DataConfi } from '@antv/s2';
-fetch(
- 'https://assets.antv.antgroup.com/s2/basic-table-mode.json',
-)
+fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
.then((res) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
};
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
columns: ['province', 'city', 'type', 'price', 'cost'],
},
diff --git a/s2-site/examples/react-component/switcher/demo/pivot-header.tsx b/s2-site/examples/react-component/switcher/demo/pivot-header.tsx
index 24fddced08..a031f343ce 100644
--- a/s2-site/examples/react-component/switcher/demo/pivot-header.tsx
+++ b/s2-site/examples/react-component/switcher/demo/pivot-header.tsx
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import insertCss from 'insert-css';
import '@antv/s2-react/dist/style.min.css';
@@ -9,7 +9,7 @@ fetch(
)
.then((res) => res.json())
.then((data) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
};
diff --git a/s2-site/examples/react-component/switcher/demo/pivot-with-children.tsx b/s2-site/examples/react-component/switcher/demo/pivot-with-children.tsx
index 28148b39ba..c294eb23c5 100644
--- a/s2-site/examples/react-component/switcher/demo/pivot-with-children.tsx
+++ b/s2-site/examples/react-component/switcher/demo/pivot-with-children.tsx
@@ -1,6 +1,10 @@
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent, Switcher } from '@antv/s2-react';
+import {
+ SheetComponent,
+ SheetComponentOptions,
+ Switcher,
+} from '@antv/s2-react';
import insertCss from 'insert-css';
import '@antv/s2-react/dist/style.min.css';
@@ -9,7 +13,7 @@ fetch(
)
.then((res) => res.json())
.then((data) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
};
@@ -44,9 +48,11 @@ fetch(
result.push(item);
} else {
const parent = result[result.length - 1];
+
parent.children = parent.children ? parent.children : [];
parent.children.push(item);
}
+
return result;
}, []);
diff --git a/s2-site/examples/react-component/switcher/demo/pivot.tsx b/s2-site/examples/react-component/switcher/demo/pivot.tsx
index e87431b98d..5277b274ff 100644
--- a/s2-site/examples/react-component/switcher/demo/pivot.tsx
+++ b/s2-site/examples/react-component/switcher/demo/pivot.tsx
@@ -1,6 +1,10 @@
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent, Switcher } from '@antv/s2-react';
+import {
+ SheetComponent,
+ SheetComponentOptions,
+ Switcher,
+} from '@antv/s2-react';
import insertCss from 'insert-css';
import '@antv/s2-react/dist/style.min.css';
@@ -9,7 +13,7 @@ fetch(
)
.then((res) => res.json())
.then((data) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
};
diff --git a/s2-site/examples/react-component/switcher/demo/table.tsx b/s2-site/examples/react-component/switcher/demo/table.tsx
index a1e8e1f729..ea246bec3e 100644
--- a/s2-site/examples/react-component/switcher/demo/table.tsx
+++ b/s2-site/examples/react-component/switcher/demo/table.tsx
@@ -1,6 +1,10 @@
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
-import { SheetComponent, Switcher } from '@antv/s2-react';
+import {
+ SheetComponent,
+ SheetComponentOptions,
+ Switcher,
+} from '@antv/s2-react';
import insertCss from 'insert-css';
import '@antv/s2-react/dist/style.min.css';
@@ -9,7 +13,7 @@ fetch(
)
.then((res) => res.json())
.then((dataCfg) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
};
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-click-show-tooltip.tsx b/s2-site/examples/react-component/tooltip/demo/custom-click-show-tooltip.tsx
index fd9e10673d..a647fa4fe4 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-click-show-tooltip.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-click-show-tooltip.tsx
@@ -26,12 +26,15 @@ fetch(
if (!cellInfo?.viewMeta) {
return;
}
+
const { spreadsheet, id } = cellInfo.viewMeta;
+
if (id === 'root[&]家具') {
const position = {
x: cellInfo.event.clientX,
y: cellInfo.event.clientY,
};
+
spreadsheet.tooltip.show({
position,
content: ,
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-content.tsx b/s2-site/examples/react-component/tooltip/demo/custom-content.tsx
index 3c1c7edc3f..0e6746f970 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-content.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-content.tsx
@@ -9,10 +9,10 @@ fetch(
)
.then((res) => res.json())
.then((dataCfg) => {
- const CustomTooltip = (
+ const CustomTooltip = () => (
content
);
- const RowCellTooltip = (
+ const RowCellTooltip = () => (
rowCellTooltip
);
@@ -20,9 +20,9 @@ fetch(
width: 600,
height: 480,
tooltip: {
- content: CustomTooltip,
+ content: ,
rowCell: {
- content: RowCellTooltip,
+ content: ,
},
},
};
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-operation.tsx b/s2-site/examples/react-component/tooltip/demo/custom-operation.tsx
index 0f4c6dfbc9..b2c9dc700f 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-operation.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-operation.tsx
@@ -20,7 +20,7 @@ fetch(
items: [
{
key: 'custom-a',
- text: '操作1',
+ label: '操作1',
icon: 'Trend',
onClick: (info, cell) => {
console.log('操作1点击:', info, cell);
@@ -28,7 +28,7 @@ fetch(
children: [
{
key: 'custom-a-a',
- text: '操作 1-1',
+ label: '操作 1-1',
icon: 'Trend',
onClick: (info, cell) => {
console.log('操作1-1点击:', info, cell);
@@ -38,7 +38,7 @@ fetch(
},
{
key: 'custom-b',
- text: '操作2',
+ label: '操作2',
icon: 'EyeOutlined',
onClick: (info, cell) => {
console.log('操作2点击:', info, cell);
@@ -46,7 +46,7 @@ fetch(
},
{
key: 'custom-c',
- text: '操作3',
+ label: '操作3',
icon: 'EyeOutlined',
visible: false,
onClick: (info, cell) => {
@@ -55,7 +55,7 @@ fetch(
},
{
key: 'custom-c',
- text: '操作4',
+ label: '操作4',
icon: 'EyeOutlined',
visible: (cell) => {
// 叶子节点才显示
diff --git a/s2-site/examples/theme/custom/demo/custom-generate-palette.tsx b/s2-site/examples/theme/custom/demo/custom-generate-palette.tsx
index bec133d06d..eb99a8b8a3 100644
--- a/s2-site/examples/theme/custom/demo/custom-generate-palette.tsx
+++ b/s2-site/examples/theme/custom/demo/custom-generate-palette.tsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom';
-import { getPalette, generatePalette } from '@antv/s2';
-import { SheetComponent } from '@antv/s2-react';
+import { getPalette, generatePalette, ThemeCfg } from '@antv/s2';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import { ChromePicker } from 'react-color';
import { Button, Popover, Space } from 'antd';
@@ -12,14 +12,14 @@ fetch(
)
.then((res) => res.json())
.then((dataCfg) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
};
function App() {
const [themeColor, setThemeColor] = useState('#EA1720');
- const [themeCfg, setThemeCfg] = useState({
+ const [themeCfg, setThemeCfg] = useState({
name: 'colorful',
});
diff --git a/s2-site/examples/theme/custom/demo/custom-manual-palette.tsx b/s2-site/examples/theme/custom/demo/custom-manual-palette.tsx
index aabb0aed9f..9762461d3b 100644
--- a/s2-site/examples/theme/custom/demo/custom-manual-palette.tsx
+++ b/s2-site/examples/theme/custom/demo/custom-manual-palette.tsx
@@ -1,8 +1,8 @@
import React, { useState, useEffect } from 'react';
import { debounce, isObjectLike } from 'lodash';
import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
-import { getPalette } from '@antv/s2';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
+import { S2DataConfig, getPalette } from '@antv/s2';
import { SketchPicker } from 'react-color';
import { Row, Space, Input, Button, message, Popover, Table } from 'antd';
import copy from 'copy-to-clipboard';
@@ -11,7 +11,7 @@ import 'antd/es/table/style/index.css';
import 'antd/es/space/style/index.css';
import '@antv/s2-react/dist/style.min.css';
-const s2Options = {
+const s2Options: SheetComponentOptions = {
width: 500,
height: 300,
conditions: {
@@ -62,7 +62,7 @@ const savePalette = debounce((palette) => {
}, 1000);
function useDataCfg() {
- const [dataCfg, setDataCfg] = useState(null);
+ const [dataCfg, setDataCfg] = useState(null);
useEffect(() => {
fetch(
diff --git a/s2-site/examples/theme/custom/demo/custom-palette.ts b/s2-site/examples/theme/custom/demo/custom-palette.ts
index 249bd9a7e4..7f336e2a44 100644
--- a/s2-site/examples/theme/custom/demo/custom-palette.ts
+++ b/s2-site/examples/theme/custom/demo/custom-palette.ts
@@ -1,12 +1,18 @@
-import { PivotSheet } from '@antv/s2';
+import {
+ PivotSheet,
+ S2DataConfig,
+ S2Options,
+ S2Theme,
+ ThemeCfg,
+} from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/4eff53f3-f952-4b77-8862-4b6ecbd31667.json',
)
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type'],
@@ -37,12 +43,12 @@ fetch(
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
};
- const s2Palette = {
+ const s2Palette: ThemeCfg['palette'] = {
basicColors: [
'#FFFFFF',
'#F8F5FE',
@@ -71,5 +77,5 @@ fetch(
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
s2.setThemeCfg({ palette: s2Palette });
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/theme/custom/demo/custom-schema.ts b/s2-site/examples/theme/custom/demo/custom-schema.ts
index 135cf95452..894236e66f 100644
--- a/s2-site/examples/theme/custom/demo/custom-schema.ts
+++ b/s2-site/examples/theme/custom/demo/custom-schema.ts
@@ -1,12 +1,13 @@
-import { TableSheet } from '@antv/s2';
+/* eslint-disable max-lines-per-function */
+import { S2DataConfig, S2Options, S2Theme, TableSheet } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/4eff53f3-f952-4b77-8862-4b6ecbd31667.json',
)
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
columns: ['province', 'city', 'type', 'price', 'cost'],
},
@@ -35,7 +36,7 @@ fetch(
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
};
@@ -45,7 +46,7 @@ fetch(
const HEADER_BACK_COLOR = '#353c59';
const CELL_ACTIVE_BACK_COLOR = '#434c6c';
- const customTheme = {
+ const customTheme: S2Theme = {
background: {
color: HEADER_BACK_COLOR,
},
@@ -76,7 +77,7 @@ fetch(
verticalBorderColor: BORDER_COLOR,
verticalBorderColorOpacity: 1,
verticalBorderWidth: 2,
- showRightShadow: true,
+ showShadow: true,
shadowWidth: 10,
shadowColors: {
left: 'rgba(0,0,0,0.1)',
@@ -168,5 +169,5 @@ fetch(
s2.setTheme(customTheme);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/theme/custom/demo/custom-transparent-background.ts b/s2-site/examples/theme/custom/demo/custom-transparent-background.ts
index c68bf393d7..df3d89b312 100644
--- a/s2-site/examples/theme/custom/demo/custom-transparent-background.ts
+++ b/s2-site/examples/theme/custom/demo/custom-transparent-background.ts
@@ -1,12 +1,12 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Options, S2Theme } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/4eff53f3-f952-4b77-8862-4b6ecbd31667.json',
)
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type'],
@@ -37,7 +37,7 @@ fetch(
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
};
@@ -51,7 +51,7 @@ fetch(
};
// https://s2.antv.antgroup.com/zh/docs/api/general/S2Theme#s2theme
- const s2Theme = {
+ const s2Theme: S2Theme = {
background: {
opacity: 0,
},
@@ -64,5 +64,6 @@ fetch(
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
s2.setTheme(s2Theme);
- s2.render();
+
+ await s2.render();
});
diff --git a/s2-site/examples/theme/default/demo/colorful.ts b/s2-site/examples/theme/default/demo/colorful.ts
index eded49591f..bcaae1d8d9 100644
--- a/s2-site/examples/theme/default/demo/colorful.ts
+++ b/s2-site/examples/theme/default/demo/colorful.ts
@@ -1,12 +1,12 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/4eff53f3-f952-4b77-8862-4b6ecbd31667.json',
)
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type'],
@@ -37,7 +37,7 @@ fetch(
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
};
@@ -46,5 +46,5 @@ fetch(
s2.setThemeCfg({ name: 'colorful' });
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/theme/default/demo/default.ts b/s2-site/examples/theme/default/demo/default.ts
index ef3218b288..f0632438d1 100644
--- a/s2-site/examples/theme/default/demo/default.ts
+++ b/s2-site/examples/theme/default/demo/default.ts
@@ -1,12 +1,12 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/4eff53f3-f952-4b77-8862-4b6ecbd31667.json',
)
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type'],
@@ -37,12 +37,12 @@ fetch(
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
};
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/examples/theme/default/demo/gray.ts b/s2-site/examples/theme/default/demo/gray.ts
index fb123ab6bb..843f47e8e6 100644
--- a/s2-site/examples/theme/default/demo/gray.ts
+++ b/s2-site/examples/theme/default/demo/gray.ts
@@ -1,12 +1,12 @@
-import { PivotSheet } from '@antv/s2';
+import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/4eff53f3-f952-4b77-8862-4b6ecbd31667.json',
)
.then((res) => res.json())
- .then((data) => {
+ .then(async (data) => {
const container = document.getElementById('container');
- const s2DataConfig = {
+ const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type'],
@@ -37,7 +37,7 @@ fetch(
data,
};
- const s2Options = {
+ const s2Options: S2Options = {
width: 600,
height: 480,
};
@@ -46,5 +46,5 @@ fetch(
s2.setThemeCfg({ name: 'gray' });
- s2.render();
+ await s2.render();
});
diff --git a/s2-site/package.json b/s2-site/package.json
index e9503c28c4..4eba2685b1 100644
--- a/s2-site/package.json
+++ b/s2-site/package.json
@@ -28,17 +28,17 @@
},
"dependencies": {
"@ant-design/icons": "^5.2.6",
- "@antv/dumi-theme-antv": "^0.4.4",
+ "@antv/dumi-theme-antv": "^0.4.5",
"@antv/g-canvas": "^1.11.25",
"@antv/g-plugin-a11y": "^0.6.20",
"@antv/g-plugin-rough-canvas-renderer": "^1.9.25",
- "@antv/g2": "^5.1.11",
+ "@antv/g2": "^5.1.13",
"@antv/s2": "next",
"@antv/s2-react": "next",
- "antd": "^5.12.2",
+ "antd": "^5.12.5",
"copy-to-clipboard": "^3.3.3",
- "dumi": "^2.2.15",
- "gh-pages": "^6.1.0",
+ "dumi": "^2.2.16",
+ "gh-pages": "^6.1.1",
"lodash": "^4.17.21",
"react-color": "^2.19.3"
},
diff --git a/s2-site/playground/sheet-component/index.tsx b/s2-site/playground/sheet-component/index.tsx
index 7b7c6a00df..88c8766a4c 100644
--- a/s2-site/playground/sheet-component/index.tsx
+++ b/s2-site/playground/sheet-component/index.tsx
@@ -40,9 +40,11 @@ export const CustomSheet: React.FC = (props) => {
const tableFields = {
columns: concat([], rows || [], columns || [], values || []),
};
+
if (sheetType === 'pivot') {
return { ...sheetDataCfg, fields: pivotFields };
}
+
return { ...sheetDataCfg, fields: tableFields };
};
@@ -57,9 +59,11 @@ export const CustomSheet: React.FC = (props) => {
const tableFields = {
columns: concat([], rows || [], columns || [], values || []),
};
+
if (sheetType === 'pivot') {
return { ...importData, fields: pivotFields };
}
+
return { ...importData, fields: tableFields };
};
@@ -67,11 +71,13 @@ export const CustomSheet: React.FC = (props) => {
if (!sheetConfig?.sheetType) {
return;
}
+
setSheetType(sheetConfig?.sheetType);
}, [sheetConfig?.sheetType]);
useEffect(() => {
const dataCfg = getExampleDataCfg();
+
setDataCfg(dataCfg);
}, [sheetConfig?.rows, sheetConfig?.columns, sheetConfig?.values]);
@@ -82,9 +88,11 @@ export const CustomSheet: React.FC = (props) => {
isEmpty(sheetConfig?.importData)
) {
const dataCfg = getExampleDataCfg();
+
setDataCfg(dataCfg);
} else if (!isEmpty(sheetConfig?.importData)) {
const dataCfg = getImportDataCfg();
+
setDataCfg(dataCfg);
}
}, [
@@ -135,6 +143,7 @@ export const CustomSheet: React.FC = (props) => {
},
},
});
+
setOptions({ ...mergedOptions });
}, [
sheetConfig?.hierarchyType,
@@ -151,6 +160,7 @@ export const CustomSheet: React.FC = (props) => {
useEffect(() => {
const { theme } = sheetConfig;
+
setThemeCfg({ name: theme });
}, [sheetConfig?.theme]);
@@ -158,17 +168,20 @@ export const CustomSheet: React.FC = (props) => {
if (!sheetConfig?.themeColor) {
return;
}
+
const { theme, themeColor } = sheetConfig;
const palette = getPalette(theme || 'default');
const newPalette = generatePalette({
...palette,
brandColor: themeColor?.hex || '#E0E9FD',
});
+
setThemeCfg({ name: theme, palette: newPalette });
}, [sheetConfig?.themeColor]);
useEffect(() => {
const { adaptive } = sheetConfig;
+
if (adaptive) {
setAdaptive({
width: true,
@@ -186,11 +199,13 @@ export const CustomSheet: React.FC = (props) => {
useEffect(() => {
const { showPagination } = sheetConfig;
+
setShowPagination(showPagination);
}, [sheetConfig?.showPagination]);
useEffect(() => {
const { showSeriesNumber, showPagination } = sheetConfig;
+
setOptions({
showSeriesNumber,
pagination: showPagination && {
From 37768a0bab9fa87aa03e01d4d1be49471f733904 Mon Sep 17 00:00:00 2001
From: lijinke666
Date: Tue, 26 Dec 2023 13:53:03 +0800
Subject: [PATCH 02/64] =?UTF-8?q?docs:=20=E6=89=80=E6=9C=89=20demo=20?=
=?UTF-8?q?=E6=9B=BF=E6=8D=A2=E6=88=90=20React=2018?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.en-US.md | 8 +++
README.md | 8 +++
packages/s2-react/README.md | 20 +++----
s2-site/docs/common/env.en.md | 7 +++
s2-site/docs/common/env.zh.md | 7 +++
s2-site/docs/common/packages.zh.md | 17 +++++-
.../manual/basic/analysis/drill-down.zh.md | 22 +++----
.../manual/basic/analysis/editable-mode.zh.md | 18 +++---
.../basic/analysis/mobile-component.zh.md | 19 +++---
.../docs/manual/basic/analysis/strategy.zh.md | 21 ++++---
.../docs/manual/basic/analysis/switcher.zh.md | 14 ++---
.../manual/basic/sheet-type/pivot-mode.zh.md | 29 +++++-----
.../manual/basic/sheet-type/table-mode.zh.md | 20 +++----
s2-site/docs/manual/basic/sort/advanced.zh.md | 5 +-
s2-site/docs/manual/faq.zh.md | 33 ++++-------
s2-site/docs/manual/getting-started.zh.md | 58 +++++++++----------
s2-site/docs/manual/introduction.zh.md | 4 ++
.../examples/analysis/sort/demo/advanced.tsx | 10 ++--
.../analysis/sort/demo/group-sort.tsx | 9 ++-
.../analysis/sort/demo/table-sort.tsx | 8 +--
s2-site/examples/case/art/demo/mosaic.tsx | 5 +-
.../case/art/demo/time-spend-abstract.tsx | 5 +-
.../comparison/demo/measure-comparison.tsx | 6 +-
.../demo/multiple-people-comparison.tsx | 5 +-
.../case/comparison/demo/philosophers.tsx | 5 +-
.../case/comparison/demo/time-spend.tsx | 11 ++--
.../examples/case/data-preview/demo/excel.tsx | 10 ++--
.../examples/case/data-preview/demo/house.tsx | 18 +++---
.../examples/case/data-preview/demo/index.tsx | 6 +-
.../examples/case/kpi-strategy/demo/basic.tsx | 8 +--
.../case/kpi-strategy/demo/covid-trend.tsx | 6 +-
.../case/performance-compare/demo/basic.tsx | 5 +-
.../case/proportion/demo/group-drill-down.tsx | 6 +-
.../demo/single-population-proportion.tsx | 11 ++--
.../demo/custom-header-action-icon.tsx | 5 +-
.../custom/custom-order/demo/custom-order.tsx | 4 +-
.../layout/adaptive/demo/react-adaptive.tsx | 8 +--
.../drill-dwon/demo/basic-panel.tsx | 5 +-
.../drill-dwon/demo/for-pivot.tsx | 6 +-
.../react-component/export/demo/export.tsx | 5 +-
.../react-component/header/demo/default.tsx | 6 +-
.../react-component/pagination/demo/pivot.tsx | 5 +-
.../react-component/pagination/demo/table.tsx | 5 +-
.../react-component/sheet/demo/editable.tsx | 5 +-
.../sheet/demo/mobile-pivot.tsx | 6 +-
.../react-component/sheet/demo/pivot.tsx | 11 +---
.../sheet/demo/strategy-mini-chart.tsx | 7 +--
.../react-component/sheet/demo/strategy.tsx | 9 ++-
.../react-component/sheet/demo/table.tsx | 9 ++-
.../switcher/demo/pivot-header.tsx | 10 ++--
.../switcher/demo/pivot-with-children.tsx | 10 ++--
.../react-component/switcher/demo/pivot.tsx | 6 +-
.../switcher/demo/pure-switcher.tsx | 5 +-
.../react-component/switcher/demo/table.tsx | 6 +-
.../react-component/tooltip/demo/basic.tsx | 5 +-
.../demo/custom-click-show-tooltip.tsx | 5 +-
.../tooltip/demo/custom-content.tsx | 5 +-
.../tooltip/demo/custom-description.tsx | 5 +-
.../demo/custom-hover-show-tooltip.tsx | 5 +-
.../tooltip/demo/custom-operation.tsx | 5 +-
.../tooltip/demo/custom-show-tooltip.tsx | 13 +++--
.../tooltip/demo/custom-tooltip.tsx | 36 ++++++++----
.../tooltip/demo/operation.tsx | 7 +--
.../custom/demo/custom-generate-palette.tsx | 4 +-
.../custom/demo/custom-manual-palette.tsx | 6 +-
65 files changed, 343 insertions(+), 330 deletions(-)
create mode 100644 s2-site/docs/common/env.en.md
create mode 100644 s2-site/docs/common/env.zh.md
diff --git a/README.en-US.md b/README.en-US.md
index c471d63a2b..d020b95aa9 100644
--- a/README.en-US.md
+++ b/README.en-US.md
@@ -188,6 +188,14 @@ s2.render();
| [@antv/s2-react](https://github.com/antvis/S2/tree/master/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) |
| [@antv/s2-vue](https://github.com/antvis/S2/tree/master/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) |
+### 🖥️ browser compatibility
+
+| [](http://godban.github.io/browsers-support-badges/)
Firefox | [](http://godban.github.io/browsers-support-badges/)
Chrome | [](http://godban.github.io/browsers-support-badges/)
Safari |
+| --- | --- | --- |
+| last 2 versions | last 2 versions | last 2 versions |
+
+`@antv/s2-react` and `@antv/s2-vue` see [React JavaScript environment requirements](https://zh-hans.reactjs.org/docs/javascript-environment-requirements.html) 和 [Vite browser compatibility](https://cn.vitejs.dev/guide/build.html#browser-compatibility)
+
## 👤 Author
[**@AntV**](https://github.com/orgs/antvis/people)
diff --git a/README.md b/README.md
index 89eb8805c1..9d4e96cb4f 100644
--- a/README.md
+++ b/README.md
@@ -184,6 +184,14 @@ s2.render();
| [@antv/s2-react](https://github.com/antvis/S2/tree/master/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) |
| [@antv/s2-vue](https://github.com/antvis/S2/tree/master/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) |
+### 🖥️ 兼容环境
+
+| [](http://godban.github.io/browsers-support-badges/)
Firefox | [](http://godban.github.io/browsers-support-badges/)
Chrome | [](http://godban.github.io/browsers-support-badges/)
Safari |
+| --- | --- | --- |
+| last 2 versions | last 2 versions | last 2 versions |
+
+`@antv/s2-react` 和 `@antv/s2-vue` 见官方 [React JavaScript 环境要求](https://zh-hans.reactjs.org/docs/javascript-environment-requirements.html) 和 [Vite 浏览器兼容性](https://cn.vitejs.dev/guide/build.html#browser-compatibility)
+
## 🙋♂️ 问题反馈
有任何问题请严格按照模版 [提交 Issue](https://github.com/antvis/S2/issues/new/choose), 在这之前强烈建议阅读 [《⚠️ 提 Issue 前必读》](https://github.com/antvis/S2/issues/1904)
diff --git a/packages/s2-react/README.md b/packages/s2-react/README.md
index 18aa74b5e1..10203a7c7c 100644
--- a/packages/s2-react/README.md
+++ b/packages/s2-react/README.md
@@ -118,19 +118,19 @@ const s2Options = {
```
-```ts
+```tsx
+import React from 'React'
import { SheetComponent } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
-const container = document.getElementById('container');
-
-ReactDOM.render(
- ,
- document.getElementById('container'),
-);
+const App = () => {
+ return (
+
+ )
+}
```
### 4. 结果
diff --git a/s2-site/docs/common/env.en.md b/s2-site/docs/common/env.en.md
new file mode 100644
index 0000000000..a20f1f4198
--- /dev/null
+++ b/s2-site/docs/common/env.en.md
@@ -0,0 +1,7 @@
+默认支持**现代浏览器**, 如果出现兼容性问题请结合 `babel` 和 `@babel/polyfill` 使用
+
+| [](http://godban.github.io/browsers-support-badges/)
Firefox | [](http://godban.github.io/browsers-support-badges/)
Chrome | [](http://godban.github.io/browsers-support-badges/)
Safari |
+| --- | --- | --- |
+| last 2 versions | last 2 versions | last 2 versions |
+
+`@antv/s2-react` 和 `@antv/s2-vue` 见官方 [React JavaScript 环境要求](https://zh-hans.reactjs.org/docs/javascript-environment-requirements.html) 和 [Vite 浏览器兼容性](https://cn.vitejs.dev/guide/build.html#browser-compatibility)
diff --git a/s2-site/docs/common/env.zh.md b/s2-site/docs/common/env.zh.md
new file mode 100644
index 0000000000..164f19021b
--- /dev/null
+++ b/s2-site/docs/common/env.zh.md
@@ -0,0 +1,7 @@
+默认兼容**现代浏览器**, 如果出现兼容性问题请结合 `babel` 和 `@babel/polyfill` 使用
+
+| [](http://godban.github.io/browsers-support-badges/)
Firefox | [](http://godban.github.io/browsers-support-badges/)
Chrome | [](http://godban.github.io/browsers-support-badges/)
Safari |
+| --- | --- | --- |
+| last 2 versions | last 2 versions | last 2 versions |
+
+`@antv/s2-react` 和 `@antv/s2-vue` 见官方 [React JavaScript 环境要求](https://zh-hans.reactjs.org/docs/javascript-environment-requirements.html) 和 [Vite 浏览器兼容性](https://cn.vitejs.dev/guide/build.html#browser-compatibility)
diff --git a/s2-site/docs/common/packages.zh.md b/s2-site/docs/common/packages.zh.md
index 3b0767f32b..d698df0238 100644
--- a/s2-site/docs/common/packages.zh.md
+++ b/s2-site/docs/common/packages.zh.md
@@ -3,8 +3,19 @@ title: Packages
order: 5
---
+:::info{title="提示"}
+
+创建 `S2` 表格有三种方式,基础类版本 `@antv/s2` 和 基于 `@antv/s2` 封装的 `React` 和 `Vue3` 版本
+
+- `@antv/s2`: 基于 `Canvas` 和 [AntV/G](https://g.antv.antgroup.com) 开发,提供基本的表格展示/交互等能力
+- `@antv/s2-react`: 基于 `@antv/s2` 封装,提供配套的 [分析组件](/manual/basic/analysis/switcher)
+- `@antv/s2-vue`: 基于 `Vue3` 和 `@antv/s2` 封装,提供配套的分析组件
+
+**也就是说** `@antv/s2` 和**框架无关**,你可以在 `Vue`, `Angular` 等任意框架中使用。
+:::
+
| 版本号 | 稳定版 | 测试版 | 预览版 | 先行版 | 包大小 | 下载量 |
| -------- | ------ | --------- | ---------- | ---------- | ---------- | ------ |
-| [@antv/s2](https://github.com/antvis/S2/tree/master/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg) |
-| [@antv/s2-react](https://github.com/antvis/S2/tree/master/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) |
-| [@antv/s2-vue](https://github.com/antvis/S2/tree/master/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) |
+| [@antv/s2](https://github.com/antvis/S2/tree/master/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg?logo=npm) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg?logo=npm) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg?logo=npm) |
+| [@antv/s2-react](https://github.com/antvis/S2/tree/master/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg?logo=npm) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg?logo=npm) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg?logo=npm)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg?logo=npm) |
+| [@antv/s2-vue](https://github.com/antvis/S2/tree/master/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg?logo=npm) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg?logo=npm) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg?logo=npm) |
diff --git a/s2-site/docs/manual/basic/analysis/drill-down.zh.md b/s2-site/docs/manual/basic/analysis/drill-down.zh.md
index 5ee3ec96e4..1d7148ee5a 100644
--- a/s2-site/docs/manual/basic/analysis/drill-down.zh.md
+++ b/s2-site/docs/manual/basic/analysis/drill-down.zh.md
@@ -86,26 +86,26 @@ const PartDrillDown = {
-```jsx
+```tsx
import React from 'react';
-import ReactDOM from 'react-dom';
import { SheetComponent } from '@antv/s2-react';
const s2Options = {
hierarchyType: 'tree', // 树形结构
};
-ReactDOM.render(
- ,
- document.getElementById('container'),
-);
+const App = () => {
+ return (
+
+ )
+}
```
-
+
## 使用场景
diff --git a/s2-site/docs/manual/basic/analysis/editable-mode.zh.md b/s2-site/docs/manual/basic/analysis/editable-mode.zh.md
index f368ffc1ca..2477f08333 100644
--- a/s2-site/docs/manual/basic/analysis/editable-mode.zh.md
+++ b/s2-site/docs/manual/basic/analysis/editable-mode.zh.md
@@ -19,7 +19,6 @@ order: 3
```typescript
import React from "react";
-import ReactDOM from "react-dom";
import { SheetComponent } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
@@ -158,14 +157,15 @@ const s2Options = {
};
// 4, 渲染
-ReactDOM.render(
- ,
- document.getElementById('container')
-);
+const App = () => {
+ return (
+ ,
+ )
+}
```
## 特性
diff --git a/s2-site/docs/manual/basic/analysis/mobile-component.zh.md b/s2-site/docs/manual/basic/analysis/mobile-component.zh.md
index a6a60e5ddf..c3d25f4c0c 100644
--- a/s2-site/docs/manual/basic/analysis/mobile-component.zh.md
+++ b/s2-site/docs/manual/basic/analysis/mobile-component.zh.md
@@ -15,21 +15,18 @@ order: 10
## 移动端表格
-```ts
+```tsx
import React from 'react';
-import ReactDOM from 'react-dom';
import { MobileSheet } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
-const container = document.getElementById('container');
-
-ReactDOM.render(
- ,
- document.getElementById('container'),
-);
-
+const App = () => {
+ return (
+
+ )
+}
```
| PC | Mobile |
diff --git a/s2-site/docs/manual/basic/analysis/strategy.zh.md b/s2-site/docs/manual/basic/analysis/strategy.zh.md
index 7d577bf8b6..691f4b4037 100644
--- a/s2-site/docs/manual/basic/analysis/strategy.zh.md
+++ b/s2-site/docs/manual/basic/analysis/strategy.zh.md
@@ -71,21 +71,20 @@ const s2Options = {
-```ts
+```tsx
import React from "react";
-import ReactDOM from "react-dom";
import { SheetComponent } from "@antv/s2-react";
import '@antv/s2-react/dist/style.min.css';
-ReactDOM.render(
- ,
- document.getElementById('container'),
-);
-
+const App = () => {
+ return (
+
+ )
+}
```
diff --git a/s2-site/docs/manual/basic/analysis/switcher.zh.md b/s2-site/docs/manual/basic/analysis/switcher.zh.md
index a4d604f42a..aeb3bf3172 100644
--- a/s2-site/docs/manual/basic/analysis/switcher.zh.md
+++ b/s2-site/docs/manual/basic/analysis/switcher.zh.md
@@ -30,20 +30,20 @@ const switcherFields = {
-```js
+```tsx
import React from "react";
-import ReactDOM from "react-dom";
import { Switcher } from "@antv/s2-react";
+import '@antv/s2-react/dist/style.min.css';
const onSubmit = (result) => {
console.log("result:", result);
};
-ReactDOM.render(
- ,
- document.getElementById("container")
-);
-
+const App = () => {
+ return (
+ ,
+ )
+}
```
diff --git a/s2-site/docs/manual/basic/sheet-type/pivot-mode.zh.md b/s2-site/docs/manual/basic/sheet-type/pivot-mode.zh.md
index 2f550dcbee..2e269159c9 100644
--- a/s2-site/docs/manual/basic/sheet-type/pivot-mode.zh.md
+++ b/s2-site/docs/manual/basic/sheet-type/pivot-mode.zh.md
@@ -16,9 +16,8 @@ order: 1
### React 组件方式
-```typescript
+```tsx
import React from "react";
-import ReactDOM from "react-dom";
import { SheetComponent } from "@antv/s2-react";
import '@antv/s2-react/dist/style.min.css';
@@ -71,14 +70,14 @@ const s2Options = {
};
// 4. 渲染
-ReactDOM.render(
- ,
- document.getElementById('container')
-);
-
+const App = () => {
+ return (
+
+ )
+}
```
📊 查看 [React 版本透视表示例](/examples/react-component/sheet#pivot) 和 [API 文档](/api/components/sheet-component)。
@@ -90,10 +89,14 @@ ReactDOM.render(
```ts
import { PivotSheet } from "@antv/s2";
-const container = document.getElementById('container');
-const s2 = new PivotSheet(container, dataCfg, options);
+async function bootstrap() {
+ const container = document.getElementById('container');
+ const s2 = new PivotSheet(container, dataCfg, options);
+
+ await s2.render();
+}
-await s2.render();
+bootstrap()
```
📊 查看 [类方式透视表示例](/examples/basic/pivot#grid) 和 [API 文档](/api/general/s2options)。
diff --git a/s2-site/docs/manual/basic/sheet-type/table-mode.zh.md b/s2-site/docs/manual/basic/sheet-type/table-mode.zh.md
index bf4e70f983..76de1b8de0 100644
--- a/s2-site/docs/manual/basic/sheet-type/table-mode.zh.md
+++ b/s2-site/docs/manual/basic/sheet-type/table-mode.zh.md
@@ -19,9 +19,8 @@ order: 2
### React 组件方式
-```typescript
+```tsx
import React from "react";
-import ReactDOM from "react-dom";
import { SheetComponent } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
@@ -75,14 +74,15 @@ const s2Options = {
};
// 4, 渲染
-ReactDOM.render(
- ,
- document.getElementById('container')
-);
+const App = () => {
+ return (
+
+ )
+}
```
### TableSheet 类方式
diff --git a/s2-site/docs/manual/basic/sort/advanced.zh.md b/s2-site/docs/manual/basic/sort/advanced.zh.md
index 1f32f98f4d..8013b98a0e 100644
--- a/s2-site/docs/manual/basic/sort/advanced.zh.md
+++ b/s2-site/docs/manual/basic/sort/advanced.zh.md
@@ -11,9 +11,8 @@ order: 1
使用 `@antv/s2-react` 的 `SheetComponent` 组件 ,并给 `header` 配置 `advancedSortCfg` ,配置具体信息可查看 [AdvancedSortCfgProps](/docs/api/components/advanced-sort#advancedsortcfgprops)
-```ts
+```tsx
import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
import { SortParams } from '@antv/s2';
import { SheetComponent } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
@@ -40,8 +39,6 @@ const AdvancedSortDemo = () => {
);
};
-ReactDOM.render(, document.getElementById('container'));
-
```
## 配置
diff --git a/s2-site/docs/manual/faq.zh.md b/s2-site/docs/manual/faq.zh.md
index 8d2e14bd46..1db044fa29 100644
--- a/s2-site/docs/manual/faq.zh.md
+++ b/s2-site/docs/manual/faq.zh.md
@@ -11,15 +11,7 @@ order: 8
### 浏览器兼容性
-如果出现兼容性问题请结合 `babel` 和 `@babel/polyfill` 使用,更多问题欢迎进群交流
-
-> 由于条件限制,版本下限仅供参考,并不意味着不能支持更低版本,该测试在 CDN 模式下测试完成,[在线 Demo](https://lxfu1.github.io/browser-compatibility-of-antv/?tab=s2)
-
-| | Chrome | Edge | Firefox | IE | Opera | Safari | UC | 360 极速浏览器 | 360 安全浏览器 |
-| ----------- | :----: | :---: | :-----: | :---: | :---: | :----: | :---: | :------------: | :------------: |
-| **AntV S2** | 40 | 12 | 85 | 9 | 40 | 14 | 6.2 | 12 | 7.3 |
-
-`@antv/s2-react` 和 `@antv/s2-vue` 见官方 [React JavaScript 环境要求](https://zh-hans.reactjs.org/docs/javascript-environment-requirements.html) 和 [Vite 浏览器兼容性](https://cn.vitejs.dev/guide/build.html#browser-compatibility)
+
### 浏览器引入
@@ -27,10 +19,17 @@ order: 8
### 官网访问有点慢,或打不开,有国内镜像吗?
-原国内镜像 [https://antv-s2.gitee.io](https://antv-s2.gitee.io/) 不再维护,推荐访问新版官网 [https://s2.antv.antgroup.com](https://s2.antv.antgroup.com/) 速度更快。
+原国内镜像 [https://antv-s2.gitee.io](https://antv-s2.gitee.io/) 和 旧版官网 [https://s2.antv.vision](https://s2.antv.vision) 不再维护,请访问新版官网 [https://s2.antv.antgroup.com](https://s2.antv.antgroup.com/) 速度更快。
+
+- [旧版官网](https://s2.antv.vision/)
+- [新版官网](https://s2.antv.antgroup.com/)
+
+### 目前官网是 2.x 版本,在哪里查看 1.x 版本的文档?
-[旧版官网](https://s2.antv.vision/)
-[新版官网](https://s2.antv.antgroup.com/)
+官网右上角可以切换文档版本:
+
+- [2.x 官网](https://s2.antv.antgroup.com/)
+- [1.x 官网](https://s2-v1.antv.antgroup.com/)
### 父级元素使用了 `transform: scale` 后,图表鼠标坐标响应不正确
@@ -190,16 +189,6 @@ const s2Options = {
### S2 有对应的 `Vue` 或者 `Angular` 版本吗?
-目前,S2 由三个包构成
-
-- `@antv/s2`: 基于 `canvas` 和 [AntV/G](https://g.antv.vision/zh/docs/guide/introduce) 开发,提供基本的表格展示/交互等能力
-- `@antv/s2-react`: 基于 `@antv/s2` 封装,提供配套的分析组件
-- `@antv/s2-vue`: 基于 `Vue3` 和 `@antv/s2` 封装,提供配套的分析组件
-
-也就是说 `@antv/s2` 和**框架无关**,你可以在 `Vue`, `Angular` 等框架中使用。
-
-以下是版本概览:
-
配套的 [分析组件](/docs/manual/basic/analysis/editable-mode),目前还没有 `@antv/s2-angular` 的开发计划,欢迎社区一起建设 👏🏻.
diff --git a/s2-site/docs/manual/getting-started.zh.md b/s2-site/docs/manual/getting-started.zh.md
index a749bddf6e..b08db8f0f4 100644
--- a/s2-site/docs/manual/getting-started.zh.md
+++ b/s2-site/docs/manual/getting-started.zh.md
@@ -4,36 +4,36 @@ order: 1
---
## 📦 安装
-### npm | yarn 安装
+### 使用 npm 或 yarn 或 pnpm 安装
```bash
# npm
-$ npm install @antv/s2
+$ npm install @antv/s2 --save
# yarn
-$ yarn add @antv/s2
+$ yarn add @antv/s2 --save
+
+# pnpm
+$ pnpm install @antv/s2 --save
```
### 使用 React 或 Vue3 版本
```bash
# React
-$ yarn add @antv/s2 @antv/s2-react
+$ pnpm install @antv/s2 @antv/s2-react --save
# Vue3
-$ yarn add @antv/s2 @antv/s2-vue
+$ pnpm install @antv/s2 @antv/s2-vue --save
+
```
### 浏览器引入(不推荐)
-如需兼容 `IE`,需要自行引入 `polyfill` 兼容。
-
## 🔨 使用
-创建 `S2` 表格有三种方式,基础类版本 `(s2-core)` 和 基于 `core` 层 封装的 `React` 和 `Vue3` 版本
-
### 基础类
@@ -192,29 +192,26 @@ bootstrap();
#### 表格组件使用
-```ts
+```tsx
import React from 'react';
-import ReactDOM from 'react-dom';
import { SheetComponent } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
-const container = document.getElementById('container');
-
-ReactDOM.render(
- ,
- document.getElementById('container'),
-);
-
+const App = () => {
+ return (
+
+ )
+}
```
#### 注意事项
`React` 版本的 `分析组件` 如:`高级排序`, `导出`, `下钻`, `Tooltip` 等组件基于 `antd` 组件库开发,如需使用,需要额外安装,并引入对应样式
-```ts
+```bash
yarn add antd @ant-design/icons
```
@@ -224,19 +221,16 @@ yarn add antd @ant-design/icons
```ts
import React from 'react';
-import ReactDOM from 'react-dom';
import { MobileSheet } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
-const container = document.getElementById('container');
-
-ReactDOM.render(
- ,
- document.getElementById('container'),
-);
-
+const App = () => {
+ return (
+
+ )
+}
```
#### 注意事项
diff --git a/s2-site/docs/manual/introduction.zh.md b/s2-site/docs/manual/introduction.zh.md
index fe9dfb192e..e6d1978152 100644
--- a/s2-site/docs/manual/introduction.zh.md
+++ b/s2-site/docs/manual/introduction.zh.md
@@ -230,6 +230,10 @@ bootstrap();
+### 🖥️ 浏览器兼容性
+
+
+
## 🙋♂️ 问题反馈
有任何问题请严格按照模版 [提交 Issue](https://github.com/antvis/S2/issues/new/choose), 在这之前强烈建议阅读 [《⚠️ 提 Issue 前必读》](https://github.com/antvis/S2/issues/1904)
diff --git a/s2-site/examples/analysis/sort/demo/advanced.tsx b/s2-site/examples/analysis/sort/demo/advanced.tsx
index d9bee18123..9d5dfbac3d 100644
--- a/s2-site/examples/analysis/sort/demo/advanced.tsx
+++ b/s2-site/examples/analysis/sort/demo/advanced.tsx
@@ -1,5 +1,5 @@
-import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
import { SheetComponent } from '@antv/s2-react';
import insertCss from 'insert-css';
import 'antd/es/cascader/style/index.css';
@@ -54,7 +54,7 @@ fetch(
};
const AdvancedSortDemo = () => {
- const [dataCfg, setDataCfg] = useState(s2DataConfig);
+ const [dataCfg, setDataCfg] = React.useState(s2DataConfig);
const [sortParams, setSortParams] = React.useState(defaultSortParams);
return (
@@ -79,7 +79,9 @@ fetch(
);
};
- ReactDOM.render(, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render(
+ ,
+ );
});
insertCss(`
diff --git a/s2-site/examples/analysis/sort/demo/group-sort.tsx b/s2-site/examples/analysis/sort/demo/group-sort.tsx
index 29760ada2f..1d57339406 100644
--- a/s2-site/examples/analysis/sort/demo/group-sort.tsx
+++ b/s2-site/examples/analysis/sort/demo/group-sort.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import ReactDOM from 'react-dom/client';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import { S2DataConfig } from '@antv/s2';
@@ -36,19 +36,18 @@ fetch(
data,
};
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
showDefaultHeaderActionIcon: true,
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/analysis/sort/demo/table-sort.tsx b/s2-site/examples/analysis/sort/demo/table-sort.tsx
index 905ee0086f..91f167ec3c 100644
--- a/s2-site/examples/analysis/sort/demo/table-sort.tsx
+++ b/s2-site/examples/analysis/sort/demo/table-sort.tsx
@@ -4,8 +4,8 @@ import '@antv/s2-react/dist/style.min.css';
import { Button } from 'antd';
import insertCss from 'insert-css';
import { orderBy } from 'lodash';
-import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
@@ -51,7 +51,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
};
const App = () => {
- const [dataCfg, setDataCfg] = useState(s2DataConfig);
+ const [dataCfg, setDataCfg] = React.useState(s2DataConfig);
return (
<>
@@ -131,7 +131,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
);
};
- ReactDOM.render(, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render();
});
// 我们用 insert-css 演示引入自定义样式
diff --git a/s2-site/examples/case/art/demo/mosaic.tsx b/s2-site/examples/case/art/demo/mosaic.tsx
index fe8d561371..505acc9f10 100644
--- a/s2-site/examples/case/art/demo/mosaic.tsx
+++ b/s2-site/examples/case/art/demo/mosaic.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import { ThemeCfg } from '@antv/s2';
@@ -72,12 +72,11 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/art/demo/time-spend-abstract.tsx b/s2-site/examples/case/art/demo/time-spend-abstract.tsx
index 8bdcf77441..57a1ac7a0e 100644
--- a/s2-site/examples/case/art/demo/time-spend-abstract.tsx
+++ b/s2-site/examples/case/art/demo/time-spend-abstract.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import insertCss from 'insert-css';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import { DataCell, ThemeCfg } from '@antv/s2';
@@ -180,7 +180,7 @@ fetch('https://assets.antv.antgroup.com/s2/time-spend.json')
);
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/comparison/demo/measure-comparison.tsx b/s2-site/examples/case/comparison/demo/measure-comparison.tsx
index 54c642e4bd..7997d48de2 100644
--- a/s2-site/examples/case/comparison/demo/measure-comparison.tsx
+++ b/s2-site/examples/case/comparison/demo/measure-comparison.tsx
@@ -1,13 +1,12 @@
/* eslint-disable max-classes-per-file */
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import {
ColCell,
DataCell,
CornerCell,
Frame,
ID_SEPARATOR,
- measureTextWidth,
S2DataConfig,
} from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
@@ -585,12 +584,11 @@ fetch('https://assets.antv.antgroup.com/s2/index-comparison.json')
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/comparison/demo/multiple-people-comparison.tsx b/s2-site/examples/case/comparison/demo/multiple-people-comparison.tsx
index ad4b46776c..cfb1c183a3 100644
--- a/s2-site/examples/case/comparison/demo/multiple-people-comparison.tsx
+++ b/s2-site/examples/case/comparison/demo/multiple-people-comparison.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import insertCss from 'insert-css';
import { ColCell, S2DataConfig, S2Theme } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
@@ -236,7 +236,7 @@ fetch('https://assets.antv.antgroup.com/s2/multiple-people-comparison.json')
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
}}
/>,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/comparison/demo/philosophers.tsx b/s2-site/examples/case/comparison/demo/philosophers.tsx
index 0e6d6220e3..2d3e79439b 100644
--- a/s2-site/examples/case/comparison/demo/philosophers.tsx
+++ b/s2-site/examples/case/comparison/demo/philosophers.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { max, min, replace } from 'lodash';
import insertCss from 'insert-css';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
@@ -195,7 +195,7 @@ fetch(
});
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/comparison/demo/time-spend.tsx b/s2-site/examples/case/comparison/demo/time-spend.tsx
index d31dce83d9..351d49867b 100644
--- a/s2-site/examples/case/comparison/demo/time-spend.tsx
+++ b/s2-site/examples/case/comparison/demo/time-spend.tsx
@@ -1,10 +1,10 @@
/* eslint-disable max-classes-per-file */
-import React from 'react';
-import ReactDOM from 'react-dom';
-import insertCss from 'insert-css';
+import { DataCell, Frame, ThemeCfg } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
-import { DataCell, Frame, S2Theme, ThemeCfg } from '@antv/s2';
import '@antv/s2-react/dist/style.min.css';
+import insertCss from 'insert-css';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
const paletteLegendMap = [
{
@@ -283,7 +283,7 @@ fetch('https://assets.antv.antgroup.com/s2/time-spend.json')
);
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/data-preview/demo/excel.tsx b/s2-site/examples/case/data-preview/demo/excel.tsx
index 7f2852cb87..d041e87ce2 100644
--- a/s2-site/examples/case/data-preview/demo/excel.tsx
+++ b/s2-site/examples/case/data-preview/demo/excel.tsx
@@ -1,9 +1,9 @@
-import React, { useState, useRef } from 'react';
-import ReactDOM from 'react-dom';
+import { S2DataConfig } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import 'antd/es/checkbox/style/index.css';
-import { S2DataConfig } from '@antv/s2';
+import React, { useRef, useState } from 'react';
+import ReactDOM from 'react-dom/client';
// 初始化配置
const s2Options: SheetComponentOptions = {
@@ -42,5 +42,7 @@ const App = ({ data }) => {
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
.then((res) => {
- ReactDOM.render(
, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render(
+
,
+ );
});
diff --git a/s2-site/examples/case/data-preview/demo/house.tsx b/s2-site/examples/case/data-preview/demo/house.tsx
index ab5f5673d1..eae503e34f 100644
--- a/s2-site/examples/case/data-preview/demo/house.tsx
+++ b/s2-site/examples/case/data-preview/demo/house.tsx
@@ -1,12 +1,11 @@
-import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
-import { Select, InputNumber, Space } from 'antd';
-import { every, filter, isNil, last, map, omit } from 'lodash';
+import { S2DataConfig, NODE_ID_SEPARATOR } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
+import { InputNumber, Select, Space } from 'antd';
import insertCss from 'insert-css';
-import { S2DataConfig, SortParams } from '@antv/s2';
+import { every, filter, isNil, last, map, omit } from 'lodash';
+import React, { useState } from 'react';
+import ReactDOM from 'react-dom/client';
-const ID_SEPARATOR = '[&]';
const defaultHouseInfo = {
name: ['15#', '16#', '21#', '22#'],
unit: ['1单元', '2单元'],
@@ -65,8 +64,8 @@ const defaultSortParams: S2DataConfig['sortParams'] = [
const { data = [] } = params;
return data.sort((a, b) => {
- const aNum = last(a.split(ID_SEPARATOR));
- const bNum = last(b.split(ID_SEPARATOR));
+ const aNum = last(a.split(NODE_ID_SEPARATOR));
+ const bNum = last(b.split(NODE_ID_SEPARATOR));
return aNum - bNum;
});
@@ -275,9 +274,8 @@ fetch(
)
.then((res) => res.json())
.then((data) => {
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/data-preview/demo/index.tsx b/s2-site/examples/case/data-preview/demo/index.tsx
index e397da29a0..a96499af13 100644
--- a/s2-site/examples/case/data-preview/demo/index.tsx
+++ b/s2-site/examples/case/data-preview/demo/index.tsx
@@ -1,6 +1,6 @@
/* eslint-disable max-classes-per-file */
import React, { useState, useEffect, useRef } from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import insertCss from 'insert-css';
import {
TableColCell,
@@ -694,7 +694,9 @@ const SortPopover = ({ fieldName, spreadsheet, modalCallbackRef }) => {
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
.then((res) => {
- ReactDOM.render(
, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render(
+
,
+ );
});
insertCss(`
diff --git a/s2-site/examples/case/kpi-strategy/demo/basic.tsx b/s2-site/examples/case/kpi-strategy/demo/basic.tsx
index 7e86c24993..41c6c21019 100644
--- a/s2-site/examples/case/kpi-strategy/demo/basic.tsx
+++ b/s2-site/examples/case/kpi-strategy/demo/basic.tsx
@@ -1,9 +1,8 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import { merge } from 'lodash';
import { DataCell, measureTextWidth, S2DataConfig, S2Theme } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
// 进度条
const PROGRESS_BAR = {
@@ -248,7 +247,7 @@ fetch('https://assets.antv.antgroup.com/s2/kpi-strategy.json')
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/kpi-strategy/demo/covid-trend.tsx b/s2-site/examples/case/kpi-strategy/demo/covid-trend.tsx
index 561b031b19..ae70d30df7 100644
--- a/s2-site/examples/case/kpi-strategy/demo/covid-trend.tsx
+++ b/s2-site/examples/case/kpi-strategy/demo/covid-trend.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { isNil } from 'lodash';
import { isUpDataValue } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
@@ -20,6 +20,7 @@ fetch(
height: 60,
},
colCell: {
+ // TODO:
widthByFieldValue: { 近14日趋势图: 300 },
},
},
@@ -69,12 +70,11 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/performance-compare/demo/basic.tsx b/s2-site/examples/case/performance-compare/demo/basic.tsx
index e06e30caa2..48613aaf51 100644
--- a/s2-site/examples/case/performance-compare/demo/basic.tsx
+++ b/s2-site/examples/case/performance-compare/demo/basic.tsx
@@ -3,7 +3,7 @@ import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import { compact } from 'lodash';
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
const disableColor = '#d3d7d4';
const colors = [
@@ -91,7 +91,7 @@ function getOptions(rawData: S2DataConfig['data']): SheetComponentOptions {
fetch('https://assets.antv.antgroup.com/s2/compare.json')
.then((res) => res.json())
.then((data) => {
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
1000 数据规模表格渲染时间对比
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/case/proportion/demo/group-drill-down.tsx b/s2-site/examples/case/proportion/demo/group-drill-down.tsx
index e96f43d042..c49119c062 100644
--- a/s2-site/examples/case/proportion/demo/group-drill-down.tsx
+++ b/s2-site/examples/case/proportion/demo/group-drill-down.tsx
@@ -3,7 +3,7 @@ import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import insertCss from 'insert-css';
import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/ff31b171-17a7-4d29-b20a-0b90a810d2de.json',
@@ -154,7 +154,9 @@ fetch(
);
};
- ReactDOM.render(
, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render(
+
,
+ );
});
insertCss(`
diff --git a/s2-site/examples/case/proportion/demo/single-population-proportion.tsx b/s2-site/examples/case/proportion/demo/single-population-proportion.tsx
index 12e19c0fd2..e2ef2b978d 100644
--- a/s2-site/examples/case/proportion/demo/single-population-proportion.tsx
+++ b/s2-site/examples/case/proportion/demo/single-population-proportion.tsx
@@ -1,9 +1,9 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import insertCss from 'insert-css';
+import { S2DataConfig } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
-import { S2DataConfig, S2Options } from '@antv/s2';
+import insertCss from 'insert-css';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
const PALETTE_COLORS = [
{
@@ -155,7 +155,7 @@ fetch('https://assets.antv.antgroup.com/s2/single-population-proportion.json')
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/custom/custom-icon/demo/custom-header-action-icon.tsx b/s2-site/examples/custom/custom-icon/demo/custom-header-action-icon.tsx
index 2027dd65b8..7ecc069853 100644
--- a/s2-site/examples/custom/custom-icon/demo/custom-header-action-icon.tsx
+++ b/s2-site/examples/custom/custom-icon/demo/custom-header-action-icon.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
@@ -103,8 +103,7 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/custom/custom-order/demo/custom-order.tsx b/s2-site/examples/custom/custom-order/demo/custom-order.tsx
index a5926b69d6..7140bc4c94 100644
--- a/s2-site/examples/custom/custom-order/demo/custom-order.tsx
+++ b/s2-site/examples/custom/custom-order/demo/custom-order.tsx
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import { Node, S2DataConfig, TooltipOptions } from '@antv/s2';
@@ -126,4 +126,4 @@ const App = () => {
);
};
-ReactDOM.render(
, document.getElementById('container'));
+ReactDOM.createRoot(document.getElementById('container')).render(
);
diff --git a/s2-site/examples/layout/adaptive/demo/react-adaptive.tsx b/s2-site/examples/layout/adaptive/demo/react-adaptive.tsx
index 397e00c5cc..bb14495c05 100644
--- a/s2-site/examples/layout/adaptive/demo/react-adaptive.tsx
+++ b/s2-site/examples/layout/adaptive/demo/react-adaptive.tsx
@@ -1,7 +1,6 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
-import { concat, debounce, forEach, map } from 'lodash';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
@@ -13,7 +12,7 @@ fetch(
height: 480,
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
document.getElementById('container'),
}}
/>,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/drill-dwon/demo/basic-panel.tsx b/s2-site/examples/react-component/drill-dwon/demo/basic-panel.tsx
index a73c458ba4..e5587bf656 100644
--- a/s2-site/examples/react-component/drill-dwon/demo/basic-panel.tsx
+++ b/s2-site/examples/react-component/drill-dwon/demo/basic-panel.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { DrillDown } from '@antv/s2-react';
const disabledFields = ['name'];
@@ -28,11 +28,10 @@ const dataSet = [
},
];
-ReactDOM.render(
+ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
diff --git a/s2-site/examples/react-component/drill-dwon/demo/for-pivot.tsx b/s2-site/examples/react-component/drill-dwon/demo/for-pivot.tsx
index 403f5fd86a..86ad429843 100644
--- a/s2-site/examples/react-component/drill-dwon/demo/for-pivot.tsx
+++ b/s2-site/examples/react-component/drill-dwon/demo/for-pivot.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import {
SheetComponent,
SheetComponentOptions,
@@ -41,7 +41,6 @@ fetch(
},
],
},
-
fetchData: (meta, drillFields) =>
new Promise((resolve) => {
const dataSet = meta.spreadsheet.dataSet;
@@ -82,13 +81,12 @@ fetch(
}),
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/export/demo/export.tsx b/s2-site/examples/react-component/export/demo/export.tsx
index ca33ffce15..0cebaa6cce 100644
--- a/s2-site/examples/react-component/export/demo/export.tsx
+++ b/s2-site/examples/react-component/export/demo/export.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import { S2DataConfig } from '@antv/s2';
@@ -27,7 +27,7 @@ fetch(
data: res.data,
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/header/demo/default.tsx b/s2-site/examples/react-component/header/demo/default.tsx
index 8dc29a6b47..5553f0de41 100644
--- a/s2-site/examples/react-component/header/demo/default.tsx
+++ b/s2-site/examples/react-component/header/demo/default.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import insertCss from 'insert-css';
import { Button } from 'antd';
import {
@@ -66,7 +66,9 @@ fetch(
);
};
- ReactDOM.render(, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render(
+ ,
+ );
});
insertCss(`
diff --git a/s2-site/examples/react-component/pagination/demo/pivot.tsx b/s2-site/examples/react-component/pagination/demo/pivot.tsx
index 8b7c5f8a49..63d8200201 100644
--- a/s2-site/examples/react-component/pagination/demo/pivot.tsx
+++ b/s2-site/examples/react-component/pagination/demo/pivot.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
@@ -18,8 +18,7 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/pagination/demo/table.tsx b/s2-site/examples/react-component/pagination/demo/table.tsx
index 1f27b7d6e4..b33a13cdcf 100644
--- a/s2-site/examples/react-component/pagination/demo/table.tsx
+++ b/s2-site/examples/react-component/pagination/demo/table.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import { S2DataConfig } from '@antv/s2';
@@ -45,7 +45,7 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
data: res,
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/sheet/demo/editable.tsx b/s2-site/examples/react-component/sheet/demo/editable.tsx
index 2fbf029cf9..8f9fd99f7a 100644
--- a/s2-site/examples/react-component/sheet/demo/editable.tsx
+++ b/s2-site/examples/react-component/sheet/demo/editable.tsx
@@ -1,7 +1,7 @@
import { S2DataConfig } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
@@ -51,12 +51,11 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/sheet/demo/mobile-pivot.tsx b/s2-site/examples/react-component/sheet/demo/mobile-pivot.tsx
index 6d9295d48d..6dee13ce06 100644
--- a/s2-site/examples/react-component/sheet/demo/mobile-pivot.tsx
+++ b/s2-site/examples/react-component/sheet/demo/mobile-pivot.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { MobileSheet } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
@@ -8,9 +8,7 @@ fetch(
)
.then((res) => res.json())
.then((dataCfg) => {
-
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/sheet/demo/pivot.tsx b/s2-site/examples/react-component/sheet/demo/pivot.tsx
index 2febbb28a8..1977c9d014 100644
--- a/s2-site/examples/react-component/sheet/demo/pivot.tsx
+++ b/s2-site/examples/react-component/sheet/demo/pivot.tsx
@@ -1,10 +1,6 @@
import React from 'react';
-import ReactDOM from 'react-dom';
-import {
- SheetComponent,
- SheetComponentOptions,
- SheetComponentOptions,
-} from '@antv/s2-react';
+import ReactDOM from 'react-dom/client';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
fetch(
@@ -17,8 +13,7 @@ fetch(
height: 480,
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/sheet/demo/strategy-mini-chart.tsx b/s2-site/examples/react-component/sheet/demo/strategy-mini-chart.tsx
index eef8fd550f..f6486fff8e 100644
--- a/s2-site/examples/react-component/sheet/demo/strategy-mini-chart.tsx
+++ b/s2-site/examples/react-component/sheet/demo/strategy-mini-chart.tsx
@@ -1,7 +1,7 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/b942d973-7364-4fad-a10a-369426a61376.json',
@@ -42,12 +42,11 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/sheet/demo/strategy.tsx b/s2-site/examples/react-component/sheet/demo/strategy.tsx
index 6032ba1813..6c252abc69 100644
--- a/s2-site/examples/react-component/sheet/demo/strategy.tsx
+++ b/s2-site/examples/react-component/sheet/demo/strategy.tsx
@@ -1,8 +1,8 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
+import { S2DataConfig } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
-import { EXTRA_COLUMN_FIELD, S2DataConfig } from '@antv/s2';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
// 临时处理老数据格式
function process(children) {
@@ -80,12 +80,11 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/sheet/demo/table.tsx b/s2-site/examples/react-component/sheet/demo/table.tsx
index 8d4e5b3773..a03dd836cd 100644
--- a/s2-site/examples/react-component/sheet/demo/table.tsx
+++ b/s2-site/examples/react-component/sheet/demo/table.tsx
@@ -1,8 +1,8 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
+import { S2DataConfig } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
-import { S2DataConfi } from '@antv/s2';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
@@ -41,12 +41,11 @@ fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
data: res,
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/switcher/demo/pivot-header.tsx b/s2-site/examples/react-component/switcher/demo/pivot-header.tsx
index a031f343ce..5a17f235d5 100644
--- a/s2-site/examples/react-component/switcher/demo/pivot-header.tsx
+++ b/s2-site/examples/react-component/switcher/demo/pivot-header.tsx
@@ -1,8 +1,8 @@
-import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
-import insertCss from 'insert-css';
import '@antv/s2-react/dist/style.min.css';
+import insertCss from 'insert-css';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/6eede6eb-8021-4da8-bb12-67891a5705b7.json',
@@ -34,7 +34,9 @@ fetch(
);
};
- ReactDOM.render(, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render(
+ ,
+ );
});
insertCss(`
diff --git a/s2-site/examples/react-component/switcher/demo/pivot-with-children.tsx b/s2-site/examples/react-component/switcher/demo/pivot-with-children.tsx
index c294eb23c5..7f9b38689d 100644
--- a/s2-site/examples/react-component/switcher/demo/pivot-with-children.tsx
+++ b/s2-site/examples/react-component/switcher/demo/pivot-with-children.tsx
@@ -1,12 +1,12 @@
-import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
import {
SheetComponent,
SheetComponentOptions,
Switcher,
} from '@antv/s2-react';
-import insertCss from 'insert-css';
import '@antv/s2-react/dist/style.min.css';
+import insertCss from 'insert-css';
+import React, { useState } from 'react';
+import ReactDOM from 'react-dom/client';
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/0c913e28-7806-41b2-a046-df3c1586712c.json',
@@ -110,7 +110,9 @@ fetch(
);
};
- ReactDOM.render(, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render(
+ ,
+ );
});
insertCss(`
diff --git a/s2-site/examples/react-component/switcher/demo/pivot.tsx b/s2-site/examples/react-component/switcher/demo/pivot.tsx
index 5277b274ff..22e02d5a34 100644
--- a/s2-site/examples/react-component/switcher/demo/pivot.tsx
+++ b/s2-site/examples/react-component/switcher/demo/pivot.tsx
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import {
SheetComponent,
SheetComponentOptions,
@@ -88,7 +88,9 @@ fetch(
);
};
- ReactDOM.render(, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render(
+ ,
+ );
});
insertCss(`
diff --git a/s2-site/examples/react-component/switcher/demo/pure-switcher.tsx b/s2-site/examples/react-component/switcher/demo/pure-switcher.tsx
index 6811f5283d..83b8e4e2d6 100644
--- a/s2-site/examples/react-component/switcher/demo/pure-switcher.tsx
+++ b/s2-site/examples/react-component/switcher/demo/pure-switcher.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { Switcher } from '@antv/s2-react';
const switcherFields = {
@@ -20,7 +20,6 @@ const onSubmit = (result) => {
console.log('result:', result);
};
-ReactDOM.render(
+ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
diff --git a/s2-site/examples/react-component/switcher/demo/table.tsx b/s2-site/examples/react-component/switcher/demo/table.tsx
index ea246bec3e..a9c6b5d2d9 100644
--- a/s2-site/examples/react-component/switcher/demo/table.tsx
+++ b/s2-site/examples/react-component/switcher/demo/table.tsx
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import {
SheetComponent,
SheetComponentOptions,
@@ -79,7 +79,9 @@ fetch(
);
};
- ReactDOM.render(, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render(
+ ,
+ );
});
insertCss(`
diff --git a/s2-site/examples/react-component/tooltip/demo/basic.tsx b/s2-site/examples/react-component/tooltip/demo/basic.tsx
index 2c875f02eb..7cb2e8d650 100644
--- a/s2-site/examples/react-component/tooltip/demo/basic.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/basic.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
@@ -19,13 +19,12 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-click-show-tooltip.tsx b/s2-site/examples/react-component/tooltip/demo/custom-click-show-tooltip.tsx
index a647fa4fe4..97e6093634 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-click-show-tooltip.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-click-show-tooltip.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import { TargetCellInfo } from '@antv/s2';
@@ -44,7 +44,7 @@ fetch(
}
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-content.tsx b/s2-site/examples/react-component/tooltip/demo/custom-content.tsx
index 0e6746f970..066f91b05a 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-content.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-content.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import insertCss from 'insert-css';
import '@antv/s2-react/dist/style.min.css';
@@ -27,14 +27,13 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-description.tsx b/s2-site/examples/react-component/tooltip/demo/custom-description.tsx
index 3d75cf5ddb..aafe59bf59 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-description.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-description.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import { S2DataConfig } from '@antv/s2';
@@ -47,12 +47,11 @@ fetch('https://assets.antv.antgroup.com/s2/basic.json')
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-hover-show-tooltip.tsx b/s2-site/examples/react-component/tooltip/demo/custom-hover-show-tooltip.tsx
index 8f8d3d994f..119bfd0adc 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-hover-show-tooltip.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-hover-show-tooltip.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
@@ -54,7 +54,7 @@ fetch(
});
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-operation.tsx b/s2-site/examples/react-component/tooltip/demo/custom-operation.tsx
index b2c9dc700f..710bd27aa6 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-operation.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-operation.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
@@ -73,13 +73,12 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-show-tooltip.tsx b/s2-site/examples/react-component/tooltip/demo/custom-show-tooltip.tsx
index 1c2b7eee84..3a506f6d2b 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-show-tooltip.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-show-tooltip.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import ReactDOM from 'react-dom';
-import { SheetComponent } from '@antv/s2-react';
+import ReactDOM from 'react-dom/client';
+import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import insertCss from 'insert-css';
import '@antv/s2-react/dist/style.min.css';
@@ -9,12 +9,12 @@ fetch(
)
.then((res) => res.json())
.then((dataCfg) => {
- const s2Options = {
+ const s2Options: SheetComponentOptions = {
width: 600,
height: 480,
};
- ReactDOM.render(
+ const App = () => (
,
- document.getElementById('container'),
+ />
);
+
+ ReactDOM.createRoot(document.getElementById('container')).render();
});
insertCss(`
diff --git a/s2-site/examples/react-component/tooltip/demo/custom-tooltip.tsx b/s2-site/examples/react-component/tooltip/demo/custom-tooltip.tsx
index c3fc4462c7..755c49f812 100644
--- a/s2-site/examples/react-component/tooltip/demo/custom-tooltip.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/custom-tooltip.tsx
@@ -1,21 +1,31 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
import { BaseTooltip } from '@antv/s2';
-import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
-import insertCss from 'insert-css';
+import {
+ SheetComponent,
+ SheetComponentOptions,
+ TooltipOperatorMenuOptions,
+} from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
+import insertCss from 'insert-css';
+import React from 'react';
+import ReactDOM from 'react-dom/client';
const MyCustomTooltipContent = () => (
我是自定义 tooltip 内容
);
-class CustomTooltip extends BaseTooltip {
+class CustomTooltip extends BaseTooltip<
+ React.ReactNode,
+ TooltipOperatorMenuOptions
+> {
constructor(spreadsheet) {
super(spreadsheet);
}
+ root: ReactDOM.Root;
+
renderContent() {
- ReactDOM.render(, this.container);
+ this.root ??= ReactDOM.createRoot(this.container!);
+ this.root.render();
}
show(options) {
@@ -26,10 +36,15 @@ class CustomTooltip extends BaseTooltip {
destroy() {
console.log('tooltip destroy');
+ this.unmount();
super.destroy();
- if (this.container) {
- ReactDOM.unmountComponentAtNode(this.container);
- }
+ }
+
+ unmount() {
+ // https://github.com/facebook/react/issues/25675#issuecomment-1363957941
+ Promise.resolve().then(() => {
+ this.root?.unmount();
+ });
}
}
@@ -47,14 +62,13 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/react-component/tooltip/demo/operation.tsx b/s2-site/examples/react-component/tooltip/demo/operation.tsx
index a001777402..f07080a011 100644
--- a/s2-site/examples/react-component/tooltip/demo/operation.tsx
+++ b/s2-site/examples/react-component/tooltip/demo/operation.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import { CellType } from '@antv/s2';
@@ -23,7 +23,7 @@ fetch(
items: [
{
key: 'trend',
- text: '趋势',
+ label: '趋势',
icon: 'Trend',
// 数值单元格展示
visible: (cell) => cell.cellType === CellType.DATA_CELL,
@@ -37,13 +37,12 @@ fetch(
},
};
- ReactDOM.render(
+ ReactDOM.createRoot(document.getElementById('container')).render(
,
- document.getElementById('container'),
);
});
diff --git a/s2-site/examples/theme/custom/demo/custom-generate-palette.tsx b/s2-site/examples/theme/custom/demo/custom-generate-palette.tsx
index eb99a8b8a3..95a7a4fe90 100644
--- a/s2-site/examples/theme/custom/demo/custom-generate-palette.tsx
+++ b/s2-site/examples/theme/custom/demo/custom-generate-palette.tsx
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { getPalette, generatePalette, ThemeCfg } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import { ChromePicker } from 'react-color';
@@ -74,5 +74,5 @@ fetch(
);
}
- ReactDOM.render(, document.getElementById('container'));
+ ReactDOM.createRoot(document.getElementById('container')).render();
});
diff --git a/s2-site/examples/theme/custom/demo/custom-manual-palette.tsx b/s2-site/examples/theme/custom/demo/custom-manual-palette.tsx
index 9762461d3b..3f08a5c78a 100644
--- a/s2-site/examples/theme/custom/demo/custom-manual-palette.tsx
+++ b/s2-site/examples/theme/custom/demo/custom-manual-palette.tsx
@@ -1,14 +1,12 @@
import React, { useState, useEffect } from 'react';
import { debounce, isObjectLike } from 'lodash';
-import ReactDOM from 'react-dom';
+import ReactDOM from 'react-dom/client';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import { S2DataConfig, getPalette } from '@antv/s2';
import { SketchPicker } from 'react-color';
import { Row, Space, Input, Button, message, Popover, Table } from 'antd';
import copy from 'copy-to-clipboard';
-import 'antd/es/table/style/index.css';
-import 'antd/es/space/style/index.css';
import '@antv/s2-react/dist/style.min.css';
const s2Options: SheetComponentOptions = {
@@ -229,4 +227,4 @@ function App() {
);
}
-ReactDOM.render(, document.getElementById('container'));
+ReactDOM.createRoot(document.getElementById('container')).render();
From cc6d069e19b1852b46d99258424d90db2a161889 Mon Sep 17 00:00:00 2001
From: lijinke666
Date: Tue, 26 Dec 2023 17:01:23 +0800
Subject: [PATCH 03/64] =?UTF-8?q?docs:=20=E5=A2=9E=E5=8A=A0=E5=A4=9A?=
=?UTF-8?q?=E8=A1=8C=E6=96=87=E6=9C=AC=20&=20=E8=87=AA=E5=AE=9A=E4=B9=89?=
=?UTF-8?q?=E8=A1=8C=E5=88=97=E5=A4=B4=20=E7=9A=84=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.en-US.md | 2 +-
README.md | 6 +-
packages/s2-core/README.md | 6 +-
.../spreadsheet/multi-line-text-spec.ts | 2 +-
packages/s2-core/src/cell/base-cell.ts | 8 +-
pnpm-lock.yaml | 140 ++++++++++++++----
s2-site/.dumi/global.less | 19 +++
s2-site/.dumi/global.ts | 60 ++++++++
s2-site/.dumirc.ts | 8 +-
s2-site/README.md | 19 ++-
s2-site/docs/api/basic-class/base-cell.zh.md | 15 +-
.../docs/common/custom/customTreeNode.zh.md | 4 +-
.../advanced/custom/custom-header.zh.md | 105 +++++--------
.../docs/manual/basic/multi-line-text.en.md | 4 +
.../docs/manual/basic/multi-line-text.zh.md | 60 ++++++++
s2-site/docs/manual/getting-started.zh.md | 6 +-
s2-site/docs/manual/introduction.zh.md | 2 +-
s2-site/package.json | 4 +-
18 files changed, 352 insertions(+), 118 deletions(-)
create mode 100644 s2-site/.dumi/global.less
create mode 100644 s2-site/.dumi/global.ts
create mode 100644 s2-site/docs/manual/basic/multi-line-text.en.md
create mode 100644 s2-site/docs/manual/basic/multi-line-text.zh.md
diff --git a/README.en-US.md b/README.en-US.md
index d020b95aa9..77fdab42e2 100644
--- a/README.en-US.md
+++ b/README.en-US.md
@@ -79,7 +79,7 @@ demo components and expansion capabilities, it allows developers to use it quick
```bash
$ npm install @antv/s2
# yarn add @antv/s2
-# pnpm install @antv/s2
+# pnpm add @antv/s2
```
## 🔨 Getting Started
diff --git a/README.md b/README.md
index 9d4e96cb4f..f7ac555fa2 100644
--- a/README.md
+++ b/README.md
@@ -73,9 +73,9 @@ S2 是 AntV 在多维交叉分析表格领域的解决方案,完全基于数
## 📦 安装
```bash
-$ npm install @antv/s2
-# yarn add @antv/s2
-# pnpm install @antv/s2
+$ npm install @antv/s2 --save
+# yarn add @antv/s2 --save
+# pnpm add @antv/s2 --save
```
## 🔨 使用
diff --git a/packages/s2-core/README.md b/packages/s2-core/README.md
index 6c95fdc7eb..f954dc3827 100644
--- a/packages/s2-core/README.md
+++ b/packages/s2-core/README.md
@@ -73,9 +73,9 @@ S2 是 AntV 在多维交叉分析表格领域的解决方案,完全基于数
## 📦 安装
```bash
-$ npm install @antv/s2
-# yarn add @antv/s2
-# pnpm install @antv/s2
+$ npm install @antv/s2 --save
+# yarn add @antv/s2 --save
+# pnpm add @antv/s2 --save
```
## 🔨 使用
diff --git a/packages/s2-core/__tests__/spreadsheet/multi-line-text-spec.ts b/packages/s2-core/__tests__/spreadsheet/multi-line-text-spec.ts
index 9f160579af..d2e48ca6ea 100644
--- a/packages/s2-core/__tests__/spreadsheet/multi-line-text-spec.ts
+++ b/packages/s2-core/__tests__/spreadsheet/multi-line-text-spec.ts
@@ -115,7 +115,7 @@ describe('SpreadSheet Multi Line Text Tests', () => {
});
afterEach(() => {
- // s2.destroy();
+ s2.destroy();
});
test('should default render one line text', () => {
diff --git a/packages/s2-core/src/cell/base-cell.ts b/packages/s2-core/src/cell/base-cell.ts
index e94f7f4b23..38a44cd928 100644
--- a/packages/s2-core/src/cell/base-cell.ts
+++ b/packages/s2-core/src/cell/base-cell.ts
@@ -215,7 +215,7 @@ export abstract class BaseCell extends Group {
}
/**
- * 实际渲染的文本宽度, 如果是多行文本, 取每一行文本高度的总和)
+ * 实际渲染的文本宽度, 如果是多行文本, 取每一行文本高度的总和
* @alias getMultiLineActualTextHeight
*/
public getActualTextHeight(): number {
@@ -265,6 +265,9 @@ export abstract class BaseCell extends Group {
return this.getTextLineBoundingRects().length > 1;
}
+ /**
+ * 获取单元格空值占位符
+ */
public getEmptyPlaceholder() {
const {
options: { placeholder },
@@ -280,6 +283,9 @@ export abstract class BaseCell extends Group {
return this.textShape?.getLineBoundingRects() || [];
}
+ /**
+ * 获取单元格展示的数值
+ */
public getFieldValue() {
return this.getFormattedFieldValue().formattedValue;
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 412d2a81cc..2a245064f3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -445,7 +445,7 @@ importers:
version: 5.2.6(react-dom@18.2.0)(react@18.2.0)
'@antv/dumi-theme-antv':
specifier: ^0.4.5
- version: 0.4.5(@babel/core@7.23.2)(dumi@2.2.16)
+ version: 0.4.5(@babel/core@7.23.2)(dumi@2.2.16)(react-dom@18.2.0)(react@18.2.0)
'@antv/g-canvas':
specifier: ^1.11.25
version: 1.11.25
@@ -466,22 +466,28 @@ importers:
version: link:../packages/s2-react
antd:
specifier: ^5.12.5
- version: 5.12.5
+ version: 5.12.5(react-dom@18.2.0)(react@18.2.0)
copy-to-clipboard:
specifier: ^3.3.3
version: 3.3.3
dumi:
specifier: ^2.2.16
- version: 2.2.16(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2)
+ version: 2.2.16(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(react-dom@18.2.0)(react@18.2.0)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2)
gh-pages:
specifier: ^6.1.1
version: 6.1.1
lodash:
specifier: ^4.17.21
version: 4.17.21
+ react:
+ specifier: ^18.2.0
+ version: 18.2.0
react-color:
specifier: ^2.19.3
version: 2.19.3(react@18.2.0)
+ react-dom:
+ specifier: ^18.2.0
+ version: 18.2.0(react@18.2.0)
devDependencies:
'@google-cloud/translate':
specifier: ^7.0.3
@@ -771,10 +777,12 @@ packages:
'@antv/util': 2.0.17
gl-matrix: 3.4.3
- /@antv/dumi-theme-antv@0.4.5(@babel/core@7.23.2)(dumi@2.2.16):
+ /@antv/dumi-theme-antv@0.4.5(@babel/core@7.23.2)(dumi@2.2.16)(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-TMbgp+DhnXiTt63xf1iu/6Go/k5SZ4J//i9u5IHRA7n8kwL8iq3nQPmR27lOAahri/F0sTnihLUtDCgWymn0gQ==}
peerDependencies:
dumi: ^2.0.0
+ react: '>=16.9.0'
+ react-dom: '>=16.9.0'
dependencies:
'@ant-design/icons': 4.8.1(react-dom@18.2.0)(react@18.2.0)
'@babel/plugin-syntax-unicode-sets-regex': 7.18.6(@babel/core@7.23.2)
@@ -788,7 +796,7 @@ packages:
codesandbox: 2.2.3
d3-dsv: 3.0.1
docsearch.js: 2.6.3
- dumi: 2.2.16(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2)
+ dumi: 2.2.16(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(react-dom@18.2.0)(react@18.2.0)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2)
front-matter: 4.0.2
fs-extra: 10.1.0
glob: 8.1.0
@@ -2998,11 +3006,25 @@ packages:
react-is: 16.13.1
dev: false
- /@makotot/ghostui@2.0.0:
+ /@loadable/component@5.15.2(react@18.2.0):
+ resolution: {integrity: sha512-ryFAZOX5P2vFkUdzaAtTG88IGnr9qxSdvLRvJySXcUA4B4xVWurUNADu3AnKPksxOZajljqTrDEDcYjeL4lvLw==}
+ engines: {node: '>=8'}
+ peerDependencies:
+ react: '>=16.3.0'
+ dependencies:
+ '@babel/runtime': 7.23.5
+ hoist-non-react-statics: 3.3.2
+ react: 18.2.0
+ react-is: 16.13.1
+ dev: false
+
+ /@makotot/ghostui@2.0.0(react@18.2.0):
resolution: {integrity: sha512-LD6OeMv+yGjpYZNjh34yDTCIE1NegqOtJq5gm4wX6op3QL7K5psTVzMjkWzseBoYj0XOD4g+UJVIZTprfoOPGg==}
engines: {node: '>=10'}
peerDependencies:
react: '>=16'
+ dependencies:
+ react: 18.2.0
dev: false
/@microsoft/api-extractor-model@7.28.2(@types/node@20.8.9):
@@ -5384,6 +5406,21 @@ packages:
react-router-dom: 6.3.0(react-dom@18.1.0)(react@18.1.0)
dev: false
+ /@umijs/renderer-react@4.0.88(react-dom@18.2.0)(react@18.2.0):
+ resolution: {integrity: sha512-5zU4+PLO9+D8nl/WikGE6QjYvztKWSLGp+N33TPL0BrrJOSTI/ffH/iwsPxiFG/ABX4oz3SShUyIhyChSnP/WQ==}
+ peerDependencies:
+ react: '>=16.8'
+ react-dom: '>=16.8'
+ dependencies:
+ '@babel/runtime': 7.23.2
+ '@loadable/component': 5.15.2(react@18.2.0)
+ history: 5.3.0
+ react: 18.2.0
+ react-dom: 18.2.0(react@18.2.0)
+ react-helmet-async: 1.3.0(react-dom@18.2.0)(react@18.2.0)
+ react-router-dom: 6.3.0(react-dom@18.2.0)(react@18.2.0)
+ dev: false
+
/@umijs/server@4.0.88:
resolution: {integrity: sha512-Bvt6HCVn7NO7hrHbWXccJhpeQCwb5/lL9g5ShSOIfcf8WwND+U7E9H3ME5cMJywdgeTjEe+yItLGQHur9TpOTg==}
dependencies:
@@ -6183,7 +6220,7 @@ packages:
- moment
dev: true
- /antd@5.12.5:
+ /antd@5.12.5(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-m9r9VhTmANS4kdBwHcxI4QWIGoZh3LspXNb2SxoezRSUZ9RUFpf+gO0AjPx8EPeO/nLKsHAoCSLza9r041bAgw==}
peerDependencies:
react: '>=16.9.0'
@@ -6211,7 +6248,7 @@ packages:
rc-dropdown: 4.1.0(react-dom@18.2.0)(react@18.2.0)
rc-field-form: 1.41.0(react-dom@18.2.0)(react@18.2.0)
rc-image: 7.5.1(react-dom@18.2.0)(react@18.2.0)
- rc-input: 1.3.11
+ rc-input: 1.3.11(react-dom@18.2.0)(react@18.2.0)
rc-input-number: 8.4.0(react-dom@18.2.0)(react@18.2.0)
rc-mentions: 2.9.1(react-dom@18.2.0)(react@18.2.0)
rc-menu: 9.12.4(react-dom@18.2.0)(react@18.2.0)
@@ -6227,14 +6264,16 @@ packages:
rc-slider: 10.5.0(react-dom@18.2.0)(react@18.2.0)
rc-steps: 6.0.1(react-dom@18.2.0)(react@18.2.0)
rc-switch: 4.1.0(react-dom@18.2.0)(react@18.2.0)
- rc-table: 7.36.1
+ rc-table: 7.36.1(react-dom@18.2.0)(react@18.2.0)
rc-tabs: 12.14.1(react-dom@18.2.0)(react@18.2.0)
rc-textarea: 1.5.3(react-dom@18.2.0)(react@18.2.0)
- rc-tooltip: 6.1.3
+ rc-tooltip: 6.1.3(react-dom@18.2.0)(react@18.2.0)
rc-tree: 5.8.2(react-dom@18.2.0)(react@18.2.0)
rc-tree-select: 5.15.0(react-dom@18.2.0)(react@18.2.0)
rc-upload: 4.3.5(react-dom@18.2.0)(react@18.2.0)
rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0)
+ react: 18.2.0
+ react-dom: 18.2.0(react@18.2.0)
scroll-into-view-if-needed: 3.1.0
throttle-debounce: 5.0.0
transitivePeerDependencies:
@@ -9060,7 +9099,7 @@ packages:
resolution: {integrity: sha512-a/Y5lf0G6gwsEQ9hop/n03CcjmHsGBk384Cz/AEX6mRYrfSpUx/lQvP9HLoXkCzScl9PL1sSmLPnMkgaXDCZLA==}
dev: false
- /dumi@2.2.16(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2):
+ /dumi@2.2.16(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(react-dom@18.2.0)(react@18.2.0)(rollup@4.1.5)(stylelint@15.11.0)(typescript@5.2.2):
resolution: {integrity: sha512-r2x/CY0fR8/YZOwEnG4JsLEpn8jOg94Qyd1u+7pRD9SCx7dF9It+GwkGbdNEsyenGsO/ZU9wD+Kz7KO+HU7/EA==}
hasBin: true
peerDependencies:
@@ -9068,7 +9107,7 @@ packages:
react-dom: '>=16.8'
dependencies:
'@ant-design/icons-svg': 4.3.1
- '@makotot/ghostui': 2.0.0
+ '@makotot/ghostui': 2.0.0(react@18.2.0)
'@stackblitz/sdk': 1.9.0
'@swc/core': 1.3.72
'@types/hast': 2.3.8
@@ -9102,16 +9141,18 @@ packages:
mdast-util-to-string: 3.2.0
nprogress: 0.2.0
pluralize: 8.0.0
- prism-react-renderer: 1.3.5
+ prism-react-renderer: 1.3.5(react@18.2.0)
prism-themes: 1.9.0
prismjs: 1.29.0
raw-loader: 4.0.2
rc-motion: 2.9.0(react-dom@18.2.0)(react@18.2.0)
rc-tabs: 12.14.1(react-dom@18.2.0)(react@18.2.0)
rc-tree: 5.8.2(react-dom@18.2.0)(react@18.2.0)
- react-copy-to-clipboard: 5.1.0
- react-error-boundary: 4.0.11
- react-intl: 6.5.5(typescript@5.2.2)
+ react: 18.2.0
+ react-copy-to-clipboard: 5.1.0(react@18.2.0)
+ react-dom: 18.2.0(react@18.2.0)
+ react-error-boundary: 4.0.11(react@18.2.0)
+ react-intl: 6.5.5(react@18.2.0)(typescript@5.2.2)
rehype-autolink-headings: 6.1.1
rehype-remove-comments: 5.0.0
rehype-stringify: 9.0.3
@@ -9122,7 +9163,7 @@ packages:
remark-rehype: 10.1.0
sass: 1.69.5
sitemap: 7.1.1
- umi: 4.0.88(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(sass@1.69.5)(stylelint@15.11.0)(typescript@5.2.2)
+ umi: 4.0.88(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(react-dom@18.2.0)(react@18.2.0)(rollup@4.1.5)(sass@1.69.5)(stylelint@15.11.0)(typescript@5.2.2)
unified: 10.1.2
unist-util-visit: 4.1.2
unist-util-visit-parents: 5.1.3
@@ -18085,10 +18126,12 @@ packages:
chalk: 2.1.0
dev: true
- /prism-react-renderer@1.3.5:
+ /prism-react-renderer@1.3.5(react@18.2.0):
resolution: {integrity: sha512-IJ+MSwBWKG+SM3b2SUfdrhC+gu01QkV2KmRQgREThBfSQRoufqRfxfHUxpG1WcaFjP+kojcFyO9Qqtpgt3qLCg==}
peerDependencies:
react: '>=0.14.9'
+ dependencies:
+ react: 18.2.0
dev: false
/prism-themes@1.9.0:
@@ -18692,7 +18735,7 @@ packages:
react-dom: 18.2.0(react@18.2.0)
dev: false
- /rc-input@1.3.11:
+ /rc-input@1.3.11(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-jhH7QP5rILanSHCGSUkdoFE5DEtpv8FIseYhuYkOZzUBeiVAiwM3q26YqZ6xBB0QFEZ/yUAgms4xW4iuub3xFQ==}
peerDependencies:
react: '>=16.0.0'
@@ -18701,6 +18744,8 @@ packages:
'@babel/runtime': 7.23.5
classnames: 2.3.2
rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0)
+ react: 18.2.0
+ react-dom: 18.2.0(react@18.2.0)
dev: false
/rc-input@1.3.6(react-dom@18.2.0)(react@18.2.0):
@@ -19144,7 +19189,7 @@ packages:
react-dom: 18.2.0(react@18.2.0)
dev: true
- /rc-table@7.36.1:
+ /rc-table@7.36.1(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-9qMxEm/3Y8ukdW8I8ZvmhX0QImfNKzH0JEUlSbyaUlsYTB+/tQEbfaB8YkG4sHVZ1io4pxqK/BXoZYqebi/TIQ==}
engines: {node: '>=8.x'}
peerDependencies:
@@ -19157,6 +19202,8 @@ packages:
rc-resize-observer: 1.4.0(react-dom@18.2.0)(react@18.2.0)
rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0)
rc-virtual-list: 3.11.3(react-dom@18.2.0)(react@18.2.0)
+ react: 18.2.0
+ react-dom: 18.2.0(react@18.2.0)
dev: false
/rc-tabs@12.14.1(react-dom@18.2.0)(react@18.2.0):
@@ -19249,7 +19296,7 @@ packages:
react-dom: 18.2.0(react@18.2.0)
dev: true
- /rc-tooltip@6.1.3:
+ /rc-tooltip@6.1.3(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-HMSbSs5oieZ7XddtINUddBLSVgsnlaSb3bZrzzGWjXa7/B7nNedmsuz72s7EWFEro9mNa7RyF3gOXKYqvJiTcQ==}
peerDependencies:
react: '>=16.9.0'
@@ -19258,6 +19305,8 @@ packages:
'@babel/runtime': 7.23.5
'@rc-component/trigger': 1.18.2(react-dom@18.2.0)(react@18.2.0)
classnames: 2.3.2
+ react: 18.2.0
+ react-dom: 18.2.0(react@18.2.0)
dev: false
/rc-tree-select@5.15.0(react-dom@18.2.0)(react@18.2.0):
@@ -19415,13 +19464,14 @@ packages:
reactcss: 1.2.3(react@18.2.0)
tinycolor2: 1.6.0
- /react-copy-to-clipboard@5.1.0:
+ /react-copy-to-clipboard@5.1.0(react@18.2.0):
resolution: {integrity: sha512-k61RsNgAayIJNoy9yDsYzDe/yAZAzEbEgcz3DZMhF686LEyukcE1hzurxe85JandPUG+yTfGVFzuEw3xt8WP/A==}
peerDependencies:
react: ^15.3.0 || 16 || 17 || 18
dependencies:
copy-to-clipboard: 3.3.3
prop-types: 15.8.1
+ react: 18.2.0
dev: false
/react-dom@18.1.0(react@18.1.0):
@@ -19452,12 +19502,13 @@ packages:
'@babel/runtime': 7.23.2
react: 18.2.0
- /react-error-boundary@4.0.11:
+ /react-error-boundary@4.0.11(react@18.2.0):
resolution: {integrity: sha512-U13ul67aP5DOSPNSCWQ/eO0AQEYzEFkVljULQIjMV0KlffTAhxuDoBKdO0pb/JZ8mDhMKFZ9NZi0BmLGUiNphw==}
peerDependencies:
react: '>=16.13.1'
dependencies:
'@babel/runtime': 7.23.5
+ react: 18.2.0
dev: false
/react-error-overlay@6.0.9:
@@ -19489,6 +19540,21 @@ packages:
shallowequal: 1.1.0
dev: false
+ /react-helmet-async@1.3.0(react-dom@18.2.0)(react@18.2.0):
+ resolution: {integrity: sha512-9jZ57/dAn9t3q6hneQS0wukqC2ENOBgMNVEhb/ZG9ZSxUetzVIw4iAmEU38IaVg3QGYauQPhSeUTuIUtFglWpg==}
+ peerDependencies:
+ react: ^16.6.0 || ^17.0.0 || ^18.0.0
+ react-dom: ^16.6.0 || ^17.0.0 || ^18.0.0
+ dependencies:
+ '@babel/runtime': 7.23.5
+ invariant: 2.2.4
+ prop-types: 15.8.1
+ react: 18.2.0
+ react-dom: 18.2.0(react@18.2.0)
+ react-fast-compare: 3.2.0
+ shallowequal: 1.1.0
+ dev: false
+
/react-helmet@6.1.0(react@18.2.0):
resolution: {integrity: sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==}
peerDependencies:
@@ -19501,7 +19567,7 @@ packages:
react-side-effect: 2.1.2(react@18.2.0)
dev: false
- /react-intl@6.5.5(typescript@5.2.2):
+ /react-intl@6.5.5(react@18.2.0)(typescript@5.2.2):
resolution: {integrity: sha512-cI5UKvBh4tc1zxLIziHBYGMX3dhYWDEFlvUDVN6NfT2i96zTXz/zH2AmM8+2waqgOhwkFUzd+7kK1G9q7fiC2g==}
peerDependencies:
react: ^16.6.0 || 17 || 18
@@ -19519,6 +19585,7 @@ packages:
'@types/react': 18.2.43
hoist-non-react-statics: 3.3.2
intl-messageformat: 10.5.8
+ react: 18.2.0
tslib: 2.6.2
typescript: 5.2.2
dev: false
@@ -19578,6 +19645,18 @@ packages:
react-router: 6.3.0(react@18.1.0)
dev: false
+ /react-router-dom@6.3.0(react-dom@18.2.0)(react@18.2.0):
+ resolution: {integrity: sha512-uaJj7LKytRxZNQV8+RbzJWnJ8K2nPsOOEuX7aQstlMZKQT0164C+X2w6bnkqU3sjtLvpd5ojrezAyfZ1+0sStw==}
+ peerDependencies:
+ react: '>=16.8'
+ react-dom: '>=16.8'
+ dependencies:
+ history: 5.3.0
+ react: 18.2.0
+ react-dom: 18.2.0(react@18.2.0)
+ react-router: 6.3.0(react@18.2.0)
+ dev: false
+
/react-router-dom@6.6.1(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-u+8BKUtelStKbZD5UcY0NY90WOzktrkJJhyhNg7L0APn9t1qJNLowzrM9CHdpB6+rcPt6qQrlkIXsTvhuXP68g==}
engines: {node: '>=14'}
@@ -19600,6 +19679,15 @@ packages:
react: 18.1.0
dev: false
+ /react-router@6.3.0(react@18.2.0):
+ resolution: {integrity: sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==}
+ peerDependencies:
+ react: '>=16.8'
+ dependencies:
+ history: 5.3.0
+ react: 18.2.0
+ dev: false
+
/react-router@6.6.1(react@18.2.0):
resolution: {integrity: sha512-YkvlYRusnI/IN0kDtosUCgxqHeulN5je+ew8W+iA1VvFhf86kA+JEI/X/8NqYcr11hCDDp906S+SGMpBheNeYQ==}
engines: {node: '>=14'}
@@ -22478,7 +22566,7 @@ packages:
requiresBuild: true
optional: true
- /umi@4.0.88(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(rollup@4.1.5)(sass@1.69.5)(stylelint@15.11.0)(typescript@5.2.2):
+ /umi@4.0.88(@babel/core@7.23.2)(@types/node@20.8.9)(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(prettier@3.0.3)(react-dom@18.2.0)(react@18.2.0)(rollup@4.1.5)(sass@1.69.5)(stylelint@15.11.0)(typescript@5.2.2):
resolution: {integrity: sha512-gNgBMbLuZwj5c2uroFmtgT4tJO2JFKfIxJaad3oFa0cOzJMSx6CnaG3Z2/+pU2eAy9EMBvbtY/iAmkr3ZNEAWg==}
engines: {node: '>=14'}
hasBin: true
@@ -22489,7 +22577,7 @@ packages:
'@umijs/core': 4.0.88
'@umijs/lint': 4.0.88(eslint@8.52.0)(jest@26.6.3)(postcss-less@6.0.0)(stylelint@15.11.0)(typescript@5.2.2)
'@umijs/preset-umi': 4.0.88(@types/node@20.8.9)(rollup@4.1.5)(sass@1.69.5)(typescript@5.2.2)
- '@umijs/renderer-react': 4.0.88(react-dom@18.1.0)(react@18.1.0)
+ '@umijs/renderer-react': 4.0.88(react-dom@18.2.0)(react@18.2.0)
'@umijs/server': 4.0.88
'@umijs/test': 4.0.88(@babel/core@7.23.2)
'@umijs/utils': 4.0.88
diff --git a/s2-site/.dumi/global.less b/s2-site/.dumi/global.less
new file mode 100644
index 0000000000..4309701f4d
--- /dev/null
+++ b/s2-site/.dumi/global.less
@@ -0,0 +1,19 @@
+.dumi-default-table {
+ margin: 0 !important;
+}
+
+// h3 {
+// border-bottom: none !important;
+// }
+
+ul {
+ margin-bottom: 16px !important;
+}
+
+.dumi-default-source-code {
+ margin: 24px 0;
+
+ .prism-code {
+ background-color: #f6f8fa !important;
+ }
+}
diff --git a/s2-site/.dumi/global.ts b/s2-site/.dumi/global.ts
new file mode 100644
index 0000000000..a29df8c3d0
--- /dev/null
+++ b/s2-site/.dumi/global.ts
@@ -0,0 +1,60 @@
+if (window) {
+ (window as any).react = require('react');
+ (window as any).reactDOM = require('react-dom');
+ // (window as any).reactDOMClient = require('react-dom/client');
+ (window as any).lodash = require('lodash');
+ (window as any).reactColor = require('react-color');
+ (window as any).copyToClipboard = require('copy-to-clipboard');
+
+ (window as any).antd = require('antd');
+ (window as any).antdIcons = require('@ant-design/icons');
+
+ (window as any).gCanvas = require('@antv/g-canvas');
+ (window as any).gPluginA11y = require('@antv/g-plugin-a11y');
+ (
+ window as any
+ ).gPluginRoughCanvasRenderer = require('@antv/g-plugin-rough-canvas-renderer');
+ (window as any).g2 = require('@antv/g2');
+ (window as any).s2 = require('@antv/s2');
+ (window as any).s2React = require('@antv/s2-react');
+
+ // (window as any).s2Css = require('@antv/s2/dist/style.min.css');
+ // (window as any).s2ReactCss = require('@antv/s2-react/dist/style.min.css');
+
+ // 码云和老网站统一跳转 antgroup 新域名
+ const hosts = ['s2.antv.vision', 'antv-s2.gitee.io'];
+ if (hosts.includes(location.host)) {
+ (window as any).location.href = location.href.replace(
+ location.origin,
+ 'https://s2.antv.antgroup.com',
+ );
+ }
+
+ // 能获取到 version 说明没有走 dumi 的代理, 运行的 node_modules 的包
+ console.table([
+ {
+ package: '@antv/s2',
+ version: (window as any).s2?.version || 'development',
+ },
+ {
+ package: '@antv/s2-react',
+ version: (window as any).s2React?.version || 'development',
+ },
+ {
+ package: '@antv/s2-vue',
+ version: (window as any).s2Vue?.version || 'development',
+ },
+ {
+ package: 'react',
+ version: (window as any).react?.version || 'development',
+ },
+ {
+ package: 'react-dom',
+ version: (window as any).reactDOM?.version || 'development',
+ },
+ {
+ package: 'antd',
+ version: (window as any).antd?.version || 'development',
+ },
+ ]);
+}
diff --git a/s2-site/.dumirc.ts b/s2-site/.dumirc.ts
index 3bd1dc5b1d..3912622984 100644
--- a/s2-site/.dumirc.ts
+++ b/s2-site/.dumirc.ts
@@ -36,7 +36,7 @@ export default defineConfig({
// 历史版本以及切换下拉菜单
// [version || '2.x']: 'https://s2.antv.antgroup.com',
'2.x': 'https://s2.antv.antgroup.com',
- '1.x': 'https://s2-v1.antv.vision',
+ '1.x': 'https://s2-v1.antv.antgroup.com',
},
docsearchOptions: {
// 头部搜索框配置
@@ -433,10 +433,16 @@ export default defineConfig({
},
],
},
+ mfsu: false,
alias: {
'@': __dirname,
},
styles: ['/site.css'],
links: [],
scripts: [],
+ // TODO: S2用的 antd@5.x @antv/dumi-theme-antv 是 4.x, 导致本地跑不起来
+ // monorepoRedirect: {
+ // peerDeps: true,
+ // srcDir: ['src', 'esm', 'lib'],
+ // },
});
diff --git a/s2-site/README.md b/s2-site/README.md
index 3f41a26489..ae5e793f33 100644
--- a/s2-site/README.md
+++ b/s2-site/README.md
@@ -1,24 +1,27 @@
# S2 官网
-- 老官网:
-- 新官网 (推荐):
+- 老官网 (已废弃):
+ -
+- 新官网 (推荐):
+ - `2.x`:
+ - `1.x`:
## 开发
```bash
-# 安装依赖
-yarn
+# 切到根目录安装
+pnpm install
# 调试
-yarn start
+pnpm start
```
## 发布
-记得将 `package.json` 对应的 `@antv/s2` 和 `@antv/s2-react` **更新到最新版本**, 并将更新后的 `yarn.lock` 提交上来。
+非特殊情况,无需手动操作,通过 GitHub Action 自动发布
```bash
-yarn deploy
+pnpm deploy
```
## 内容建设
@@ -55,4 +58,4 @@ yarn deploy
```
-- 热更新没有特别灵敏,如果没有时时更新请手动重刷或重启服务
+- 热更新没有特别灵敏,如果没有试试更新请手动重刷或重启服务
diff --git a/s2-site/docs/api/basic-class/base-cell.zh.md b/s2-site/docs/api/basic-class/base-cell.zh.md
index 7352caa88e..40519cc036 100644
--- a/s2-site/docs/api/basic-class/base-cell.zh.md
+++ b/s2-site/docs/api/basic-class/base-cell.zh.md
@@ -16,8 +16,6 @@ cell.getActualText()
| getIconStyle | 获取单元格图标样式 | () => [IconTheme](/docs/api/general/S2Theme#icontheme) |
| getStyle | 获取单元格样式 | () => [DefaultCellTheme](/docs/api/general/S2Theme#defaultcelltheme) |
| getTextAndIconPosition | 获取单元格文本和图标的位置 | (iconCount: `number`) => [TextAndIconPosition](#textandiconposition) |
-| getActualText | 获取绘制的文本 | `() => string` |
-| getActualTextWidth | 获取绘制的文本宽度 | `() => number` |
| cellType | 单元格类型 | [CellType](#celltypes) |
| initCell | 初始化单元格 | `() => void` |
| update | 更新单元格 | `() => void` |
@@ -35,6 +33,19 @@ cell.getActualText()
| getConditionIconShape | 获取 icon 图层 | `() => GuiIcon` |
| getConditionIconShapes | 获取所有 icon 图层 | `() => GuiIcon[]` |
| addConditionIconShape | 添加 icon 图层 | `(shape: GuiIcon) => void` |
+| isShallowRender | 是否是浅渲染 | `( ) => boolean` |
+| getActualText | 获取实际渲染的文本 (含省略号) | `() => string` |
+| getOriginalText | 获取原始的文本 (不含省略号) | `() => string` |
+| getActualTextWidth | 实际渲染的文本宽度,如果是多行文本,取最大的一行宽度 | `() => number` |
+| getActualTextHeight | 实际渲染的文本宽度,如果是多行文本,取每一行文本高度的总和 | `() => number` |
+| getMultiLineActualTexts | 获取实际渲染的多行文本 (含省略号) | `() => string[]` |
+| getMultiLineActualTextWidth | 实际渲染的多行文本宽度 (每一行文本宽度的总和) | `() => number` |
+| getMultiLineActualTextHeight | 实际渲染的多行文本高度 (每一行文本高度的总和) | `() => number` |
+| isTextOverflowing | 文本是否溢出 (有省略号) | `() => boolean` |
+| isMultiLineText | 是否是多行文本 | `() => boolean` |
+| getEmptyPlaceholder | 获取单元格空值占位符 | `() => string` |
+| getTextLineBoundingRects | 获取文本包围盒 | `() => string` |
+| getFieldValue | 获取单元格展示的数值 | `() => string` |
diff --git a/s2-site/docs/common/custom/customTreeNode.zh.md b/s2-site/docs/common/custom/customTreeNode.zh.md
index ad3f699af4..a26516d414 100644
--- a/s2-site/docs/common/custom/customTreeNode.zh.md
+++ b/s2-site/docs/common/custom/customTreeNode.zh.md
@@ -3,13 +3,13 @@ title: 自定义树状结构
order: 8
---
-### CustomTreeNode
+#### CustomTreeNode
功能描述:自定义树状结构的配置。查看 [详细说明](/zh/docs/manual/advanced/custom/custom-tree) 或 [例子](/zh/examples/custom/custom-tree#custom-tree)
| 参数 | 说明 | 类型 | 默认值 | 必选 |
| --- | --- | --- | --- | :-: |
-| key | 当前节点唯一标识 | `string` | | ✓ |
+| field | 当前节点唯一标识 | `string` | | ✓ |
| title | 当前节点展示名 | `string` | | ✓ |
| collapsed | 节点是否收起(树状模式下,行头非叶子节点有效) | `boolean` | `false` | |
| description | 节点的额外描述信息,在对应行头的 tooltip 中展示 | `string` | | |
diff --git a/s2-site/docs/manual/advanced/custom/custom-header.zh.md b/s2-site/docs/manual/advanced/custom/custom-header.zh.md
index 52cdfef07b..eca931fe61 100644
--- a/s2-site/docs/manual/advanced/custom/custom-header.zh.md
+++ b/s2-site/docs/manual/advanced/custom/custom-header.zh.md
@@ -3,34 +3,34 @@ title: 自定义行列头
order: 2
---
-`S2` 默认提供 [平铺模式 (grid)](https://s2.antv.vision/zh/examples/basic/pivot#grid) 和 [树状模式 (tree)](https://s2.antv.vision/zh/examples/basic/pivot#tree) 两种**行头**单元格布局方式
+`S2` 默认提供 [平铺模式 (grid)](https://s2.antv.vision/zh/examples/basic/pivot#grid) 和 [树状模式 (tree)](https://s2.antv.vision/zh/examples/basic/pivot#tree) 两种**行头**单元格布局方式。
-默认通过**分组之后得到的数据生成层级结构**, 如果都不满足的话,可以通过自定义行列头,来定制你的目录结构,同样兼容平铺和树状这两种布局方式
+默认通过**分组之后得到的数据生成层级结构**, 如果都不满足的话,可以通过自定义行列头,来定制你的目录结构,同样兼容平铺和树状这两种布局方式。
## 数据结构
```ts
-const customTree: CustomTreeNode[] = [
+const customTree = [
{
- key: 'a-1',
+ field: 'a-1',
title: '自定义节点 a-1',
description: 'a-1 描述',
children: [
{
- key: 'a-1-1',
+ field: 'a-1-1',
title: '自定义节点 a-1-1',
description: 'a-1-1 描述',
children: [
{
- key: 'measure-1',
+ field: 'measure-1',
title: '指标 1',
description: '指标 1 描述',
children: [],
},
{
- key: 'measure-2',
+ field: 'measure-2',
title: '指标 2',
description: '指标 2 描述',
children: [],
@@ -38,7 +38,7 @@ const customTree: CustomTreeNode[] = [
],
},
{
- key: 'a-1-2',
+ field: 'a-1-2',
title: '自定义节点 a-1-2',
description: 'a-1-2 描述',
children: [],
@@ -46,7 +46,7 @@ const customTree: CustomTreeNode[] = [
],
},
{
- key: 'a-2',
+ field: 'a-2',
title: '自定义节点 a-2',
description: 'a-2 描述',
children: [],
@@ -69,109 +69,97 @@ const data = [
]
```
-## 透视表
+## 1. 透视表
-### 自定义行头
+### 1.1 自定义行头
-
+:::info{title="提示"}
1. `rows` 配置为自定义 `tree` 结构
2. 数值需要置于行头,即 `valueInCols: false` (无论配置与否都会强制置于行头,修改无效)
+:::
+
+
+
```ts
const s2DataConfig = {
fields: {
rows: customTree,
columns: ['type', 'sub_type'],
- values: ['measure-1', 'measure-2']
+ values: ['measure-1', 'measure-2'],
valueInCols: false,
},
data,
};
```
-
-
#### 平铺模式
```ts
const s2Options = {
- hierarchyType: 'grid',
+ hierarchyType: 'grid'
};
```
-
-
-
-
#### 树状模式
```ts
const s2Options = {
- hierarchyType: 'tree',
+ hierarchyType: 'tree'
};
```
-
-
-
-
-### 自定义列头
+### 1.2 自定义列头
-
+:::info{title="提示"}
1. `columns` 配置为自定义 `tree` 结构
2. 数值需要置于列头,即 `valueInCols: true` (无论配置与否都会强制置于列头,修改无效)
+:::
+
+
+
```ts
const s2DataConfig = {
fields: {
columns: customTree,
rows: ['type', 'sub_type'],
- values: ['measure-1', 'measure-2']
+ values: ['measure-1', 'measure-2'],
valueInCols: true,
},
data,
};
```
-
-
#### 平铺模式
```ts
const s2Options = {
- hierarchyType: 'grid',
+ hierarchyType: 'grid'
};
```
-
-
-
-
#### 树状模式
```ts
const s2Options = {
- hierarchyType: 'tree',
+ hierarchyType: 'tree'
};
```
-
-
-
+### 1.3 自定义角头文本
-### 自定义角头文本
-
-#### 平铺模式
+#### 1.3.1 平铺模式
对于平铺模式,角头显示的文本默认对应**行头每一列的第一个单元格**,可以和普通字段一样,配置 [meta](/zh/docs/api/general/S2DataConfig#meta) 来对单元格文本进行格式化,此时 `field` 对应 [CustomTreeNode](#customtreenode) 的 `field` 值
@@ -192,13 +180,9 @@ const meta = [
]
```
-
-
-
-
-#### 树状模式
+#### 1.3.2 树状模式
对于树状模式,角头默认显示的文本对应**所有的一级节点和数值**,可以和普通字段一样,配置 [meta](/zh/docs/api/general/S2DataConfig#meta) 来对单元格文本进行格式化,也可以配置 [s2Options.cornerText](/zh/docs/api/general/S2Options) 来自定义角头文本
@@ -215,52 +199,43 @@ const meta = [
]
```
-
-
-
-
```ts
const s2Options = {
cornerText: '自定义角头标题'
}
```
-
-
-
-
-## 明细表
-
-### 自定义列头
+## 2. 明细表
-
+### 2.1 自定义列头
-
+:::info{title="提示"}
`columns` 配置为自定义 `tree` 结构
```ts
const s2DataConfig = {
fields: {
- columns: customTree,
+ columns: customTree
},
data,
};
```
-
+:::
+
+
-## 行列头文本格式化
+## 3. 行列头文本格式化
自定义节点默认使用 `当前节点展示名`, 即 `CustomTreeNode.title`, 也可以使用通用的 [Meta](/api/general/s-2-data-config#meta) 来进行格式化
```ts
const s2DataConfig: S2DataConfig = {
- ...
meta: [
{
field: 'a-1',
@@ -274,6 +249,6 @@ const s2DataConfig: S2DataConfig = {
};
```
-## 更多应用
+## 4. 更多应用
基于自定义行列头,我们可以衍生出更多的使用场景,比如基于 `自定义行头` + `树状模式`, 我们可以自定义出一个 [趋势分析表分析组件](zh/docs/manual/basic/analysis/strategy/).
diff --git a/s2-site/docs/manual/basic/multi-line-text.en.md b/s2-site/docs/manual/basic/multi-line-text.en.md
new file mode 100644
index 0000000000..b61a74f04b
--- /dev/null
+++ b/s2-site/docs/manual/basic/multi-line-text.en.md
@@ -0,0 +1,4 @@
+---
+title: Multi Line
+order: 10
+---
diff --git a/s2-site/docs/manual/basic/multi-line-text.zh.md b/s2-site/docs/manual/basic/multi-line-text.zh.md
new file mode 100644
index 0000000000..e4e509be83
--- /dev/null
+++ b/s2-site/docs/manual/basic/multi-line-text.zh.md
@@ -0,0 +1,60 @@
+---
+title: 多行文本
+order: 10
+---
+
+:::warning{title="注意"}
+请确保已经阅读了 [基础教程](/manual/basic/base-concept) 和 [主题配置](/manual/basic/theme) 等章节。
+:::
+
+基于 `DOM` 的 表格中,我们可以写一些简单的 [CSS 属性](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow), 就可以实现文本的自动换行,溢出隐藏,因为浏览器已经帮我们计算好了,而在 `Canvas` 中,`文本是否溢出`, `文字换行坐标计算`, `多行文本高度自适应` 等特性都需要自行实现。
+
+得益于 `AntV/G` 5.0 渲染引擎的升级,`S2 2.0` 现在只需要简单的配置即可支持多行文本的渲染,支持自动换行。
+
+TODO: DEMO
+
+
+
+## 使用
+
+S2 内部适配了 `AntV/G 5.0` 的 [多行布局能力](https://g.antv.antgroup.com/api/basic/text#%E5%A4%9A%E8%A1%8C%E5%B8%83%E5%B1%80), 支持如下配置:
+
+:::info{title="提示"}
+
+具体参数请跳转 `G` [官网查看](https://g.antv.antgroup.com/api/basic/text#%E5%A4%9A%E8%A1%8C%E5%B8%83%E5%B1%80).
+
+- `maxLines`: 最大行数,文本超出后将被截断。
+- `wordWrap`: 是否开启自动折行,默认值为 false,
+- `wordWrapWidth`: 开启自动折行后,超出该宽度则换行。
+- `textOverflow`:
+ - 'clip' 直接截断文本
+ - 'ellipsis' 使用 ... 表示被截断的文本
+ - 自定义字符串,使用它表示被截断的文本
+:::
+
+在 S2 中,通过 [配置主题](/manual/basic/theme) 即可实现多行文本,当文本自动换行后,如小于单元格高度,则会自动调整。
+
+```ts
+const cellTheme = {
+ text: {
+ maxLines: 2,
+ wordWrap: true,
+ textOverflow: 'ellipsis',
+ },
+ bolderText: {
+ maxLines: 2,
+ },
+ measureText: {
+ maxLines: 2,
+ },
+};
+
+s2.setTheme({
+ seriesNumberCell: cellTheme,
+ colCell: cellTheme,
+ cornerCell: cellTheme,
+ rowCell: cellTheme,
+ dataCell: cellTheme,
+});
+
+```
diff --git a/s2-site/docs/manual/getting-started.zh.md b/s2-site/docs/manual/getting-started.zh.md
index b08db8f0f4..649ea1ff04 100644
--- a/s2-site/docs/manual/getting-started.zh.md
+++ b/s2-site/docs/manual/getting-started.zh.md
@@ -14,17 +14,17 @@ $ npm install @antv/s2 --save
$ yarn add @antv/s2 --save
# pnpm
-$ pnpm install @antv/s2 --save
+$ pnpm add @antv/s2 --save
```
### 使用 React 或 Vue3 版本
```bash
# React
-$ pnpm install @antv/s2 @antv/s2-react --save
+$ pnpm add @antv/s2 @antv/s2-react --save
# Vue3
-$ pnpm install @antv/s2 @antv/s2-vue --save
+$ pnpm add @antv/s2 @antv/s2-vue --save
```
diff --git a/s2-site/docs/manual/introduction.zh.md b/s2-site/docs/manual/introduction.zh.md
index e6d1978152..5a2a286e46 100644
--- a/s2-site/docs/manual/introduction.zh.md
+++ b/s2-site/docs/manual/introduction.zh.md
@@ -71,7 +71,7 @@ redirect_from:
## 📦 安装
```bash
-pnpm install @antv/s2 --save
+pnpm add @antv/s2 --save
# npm install @antv/s2 --save
# yarn add @antv/s2 --save
```
diff --git a/s2-site/package.json b/s2-site/package.json
index 4eba2685b1..b67722d45b 100644
--- a/s2-site/package.json
+++ b/s2-site/package.json
@@ -40,7 +40,9 @@
"dumi": "^2.2.16",
"gh-pages": "^6.1.1",
"lodash": "^4.17.21",
- "react-color": "^2.19.3"
+ "react-color": "^2.19.3",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0"
},
"devDependencies": {
"@google-cloud/translate": "^7.0.3",
From be79f562c44cc92d20439a97b0412fc90136ca47 Mon Sep 17 00:00:00 2001
From: lijinke666
Date: Tue, 26 Dec 2023 19:35:50 +0800
Subject: [PATCH 04/64] =?UTF-8?q?docs:=20=E5=A2=9E=E5=8A=A0=E5=A4=9A?=
=?UTF-8?q?=E8=A1=8C=E6=96=87=E6=9C=AC=20demo?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../manual/advanced/custom/cell-size.zh.md | 18 ++-
.../custom/custom-collapse-nodes.zh.md | 16 ++-
.../docs/manual/basic/multi-line-text.zh.md | 19 ++-
s2-site/examples/layout/custom/demo/meta.json | 8 ++
.../layout/custom/demo/multi-line-text.ts | 122 ++++++++++++++++++
5 files changed, 166 insertions(+), 17 deletions(-)
create mode 100644 s2-site/examples/layout/custom/demo/multi-line-text.ts
diff --git a/s2-site/docs/manual/advanced/custom/cell-size.zh.md b/s2-site/docs/manual/advanced/custom/cell-size.zh.md
index 3ac215edad..4e9fd6dbe1 100644
--- a/s2-site/docs/manual/advanced/custom/cell-size.zh.md
+++ b/s2-site/docs/manual/advanced/custom/cell-size.zh.md
@@ -30,7 +30,11 @@ const s2Options = {
## 调整数值单元格宽高
-> 优先级小于 `rowCell.height` 和 `colCell.width`
+:::warning{title="注意"}
+
+优先级小于 `rowCell.height` 和 `colCell.width`
+
+:::
```ts
const s2Options = {
@@ -39,7 +43,7 @@ const s2Options = {
width: 100,
height: 90
},
- },
+ }
}
```
@@ -89,7 +93,7 @@ const s2Options = {
如果想给特定某一行/列设置不同的宽高,可以通过 `rowCell` 的 `widthByField` 和 `heightByField` 预设高度来实现,支持两种类型的配置:
-- **fieldId** (例:`root[&] 浙江省 [&] 杭州市`): 行列交叉后每一个行头节点对应的唯一 ID, 适用于宽高精确到具体的单元格 [(如何获取 ID)](/docs/manual/advanced/get-cell-data#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E5%8C%BA%E5%9F%9F%E5%8D%95%E5%85%83%E6%A0%BC)
+- **fieldId** (例:`root[&]浙江省[&]杭州市`): 行列交叉后每一个行头节点对应的唯一 ID, 适用于宽高精确到具体的单元格 [(如何获取 ID)](/docs/manual/advanced/get-cell-data#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E5%8C%BA%E5%9F%9F%E5%8D%95%E5%85%83%E6%A0%BC)
- **field** (例:`city`): 对应 `s2DataConfig.fields.rows` 中配置的 `field`, 适用于精确到某一类维值的单元格
@@ -102,8 +106,8 @@ const s2Options = {
city: 100
},
heightByField: {
- 'root[&] 浙江省 [&] 杭州市': 60,
- 'root[&] 浙江省 [&] 宁波市': 100,
+ 'root[&]浙江省[&]杭州市': 60,
+ 'root[&]浙江省[&]宁波市': 100,
},
},
},
@@ -193,7 +197,7 @@ const s2Options = {
如果想给特定某一列设置不同的宽高,可以通过 `colCell` 的 `widthByField` 和 `heightByField` 预设宽高来实现,支持两种类型的配置:
-- **fieldId** (例:`root[&] 家具 [&] 沙发 [&]number`): 行列交叉后每一个列头节点对应的唯一 ID, 适用于宽高精确到具体的单元格 [(如何获取 ID)](/docs/manual/advanced/get-cell-data#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E5%8C%BA%E5%9F%9F%E5%8D%95%E5%85%83%E6%A0%BC)
+- **fieldId** (例:`root[&]家具[&]沙发[&]number`): 行列交叉后每一个列头节点对应的唯一 ID, 适用于宽高精确到具体的单元格 [(如何获取 ID)](/docs/manual/advanced/get-cell-data#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E5%8C%BA%E5%9F%9F%E5%8D%95%E5%85%83%E6%A0%BC)
- **field** (例:`city`): 对应 `s2DataConfig.fields.columns` 中配置的 `field`, 适用于精确到某一类维值的单元格
```ts
@@ -205,7 +209,7 @@ const s2Options = {
widthByField: {
// 默认 [数值挂列头], EXTRA_FIELD 为内部虚拟数值列
[EXTRA_FIELD]: 60,
- 'root[&] 家具 [&] 沙发 [&]number': 120,
+ 'root[&]家具[&]沙发[&]number': 120,
},
heightByField: {
[EXTRA_FIELD]: 80,
diff --git a/s2-site/docs/manual/advanced/custom/custom-collapse-nodes.zh.md b/s2-site/docs/manual/advanced/custom/custom-collapse-nodes.zh.md
index e663b3e7da..c620a61d76 100644
--- a/s2-site/docs/manual/advanced/custom/custom-collapse-nodes.zh.md
+++ b/s2-site/docs/manual/advanced/custom/custom-collapse-nodes.zh.md
@@ -22,7 +22,7 @@ const s2Options = {
expandDepth: 0,
// 折叠所有
collapseAll: true
- },
+ }
},
}
```
@@ -31,7 +31,7 @@ const s2Options = {
## 折叠指定节点
-配置 `collapseFields`, 支持 `维值 id` 和 `维度 field` 两种方式,即可以是 `root[&] 浙江省` 和 `city`
+配置 `collapseFields`, 支持 `维值 id` 和 `维度 field` 两种方式,即可以是 `root[&]浙江省` 和 `city`
```ts
const s2Options = {
@@ -45,13 +45,15 @@ const s2Options = {
### 根据节点对应维值 id
-指定 `id` 可以折叠指定节点,如配置为 `root[&] 浙江省`, 那么 `浙江省` 下所有节点都会被折叠
+指定 `id` 可以折叠指定节点,如配置为 `root[&]浙江省`, 那么 `浙江省` 下所有节点都会被折叠
```ts
const s2Options = {
style: {
rowCell: {
- collapseFields: { 'root[&] 浙江省': true },
+ collapseFields: {
+ 'root[& 浙江省': true
+ },
},
},
}
@@ -73,10 +75,14 @@ const s2DataConfig = {
rows: ['province', 'city']
}
}
+
const s2Options = {
style: {
rowCell: {
- collapseFields: { province: false, city: true }
+ collapseFields: {
+ province: false,
+ city: true
+ }
},
},
}
diff --git a/s2-site/docs/manual/basic/multi-line-text.zh.md b/s2-site/docs/manual/basic/multi-line-text.zh.md
index e4e509be83..3c15ec4720 100644
--- a/s2-site/docs/manual/basic/multi-line-text.zh.md
+++ b/s2-site/docs/manual/basic/multi-line-text.zh.md
@@ -11,9 +11,7 @@ order: 10
得益于 `AntV/G` 5.0 渲染引擎的升级,`S2 2.0` 现在只需要简单的配置即可支持多行文本的渲染,支持自动换行。
-TODO: DEMO
-
-
+
## 使用
@@ -21,7 +19,7 @@ S2 内部适配了 `AntV/G 5.0` 的 [多行布局能力](https://g.antv.antgroup
:::info{title="提示"}
-具体参数请跳转 `G` [官网查看](https://g.antv.antgroup.com/api/basic/text#%E5%A4%9A%E8%A1%8C%E5%B8%83%E5%B1%80).
+具体参数请跳转 `AntV/G` [官网查看](https://g.antv.antgroup.com/api/basic/text#%E5%A4%9A%E8%A1%8C%E5%B8%83%E5%B1%80).
- `maxLines`: 最大行数,文本超出后将被截断。
- `wordWrap`: 是否开启自动折行,默认值为 false,
@@ -34,11 +32,18 @@ S2 内部适配了 `AntV/G 5.0` 的 [多行布局能力](https://g.antv.antgroup
在 S2 中,通过 [配置主题](/manual/basic/theme) 即可实现多行文本,当文本自动换行后,如小于单元格高度,则会自动调整。
+:::warning{title="注意"}
+数值单元格 (dataCell) 不建议换行,容易产生歧义。
+:::
+
```ts
const cellTheme = {
text: {
+ // 最大行数,文本超出后将被截断
maxLines: 2,
+ // 文本是否换行
wordWrap: true,
+ // 可选项见:https://g.antv.antgroup.com/api/basic/text#textoverflow
textOverflow: 'ellipsis',
},
bolderText: {
@@ -54,7 +59,11 @@ s2.setTheme({
colCell: cellTheme,
cornerCell: cellTheme,
rowCell: cellTheme,
- dataCell: cellTheme,
+ // dataCell: cellTheme,
});
```
+
+## 效果
+
+
diff --git a/s2-site/examples/layout/custom/demo/meta.json b/s2-site/examples/layout/custom/demo/meta.json
index 6859d445e3..999fbc3edf 100644
--- a/s2-site/examples/layout/custom/demo/meta.json
+++ b/s2-site/examples/layout/custom/demo/meta.json
@@ -67,6 +67,14 @@
"en": "Only Show Row Header"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*pezZTI9lp50AAAAAAAAAAAAADmJ7AQ/original"
+ },
+ {
+ "filename": "multi-line-text.ts",
+ "title": {
+ "zh": "多行文本 / 文本自动换行",
+ "en": "Multi Line Text"
+ },
+ "screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*uMV6QYL-TcwAAAAAAAAAAAAADmJ7AQ/original"
}
]
}
diff --git a/s2-site/examples/layout/custom/demo/multi-line-text.ts b/s2-site/examples/layout/custom/demo/multi-line-text.ts
new file mode 100644
index 0000000000..537d3dbb2a
--- /dev/null
+++ b/s2-site/examples/layout/custom/demo/multi-line-text.ts
@@ -0,0 +1,122 @@
+import {
+ DefaultCellTheme,
+ PivotSheet,
+ S2DataConfig,
+ S2Options,
+} from '@antv/s2';
+import '@antv/s2/dist/style.min.css';
+
+fetch('https://assets.antv.antgroup.com/s2/basic.json')
+ .then((res) => res.json())
+ .then(async (data) => {
+ const container = document.getElementById('container');
+ const s2DataConfig: S2DataConfig = {
+ fields: {
+ rows: ['province', 'city'],
+ columns: ['type'],
+ values: ['price', 'cost'],
+ },
+ meta: [
+ {
+ field: 'province',
+ name: '省份省份省份省份省份省份省份省份省份',
+ },
+ {
+ field: 'city',
+ name: '城市城市城市城市城市城市城市',
+ },
+ {
+ field: 'type',
+ name: '商品类别商品类别商品类别商品类别商品类别商品类别',
+ },
+ {
+ field: 'price',
+ name: '价格价格价格价格价格价格',
+ },
+ {
+ field: 'cost',
+ name: '成本成本成本成本成本成本成本',
+ },
+ ],
+ data: [
+ {
+ province: '浙江浙江浙江浙江浙江浙江',
+ city: '杭州杭州杭州杭州杭州杭州',
+ type: '纸张纸张纸张纸张纸张',
+ price: '2',
+ cost: '20',
+ },
+ ...data,
+ ],
+ };
+
+ const s2Options: S2Options = {
+ width: 600,
+ height: 480,
+ showSeriesNumber: true,
+ seriesNumberText: '序号序号序号序号序号序号',
+ tooltip: {
+ enable: true,
+ content: (cell) => {
+ const text = cell.getOriginalText();
+ const span = document.createElement('span');
+
+ span.innerHTML = text;
+
+ return span;
+ },
+ },
+ // 如果有省略号, 复制到的是完整文本
+ interaction: {
+ enableCopy: true,
+ copyWithFormat: true,
+ copyWithHeader: true,
+ brushSelection: {
+ dataCell: true,
+ rowCell: true,
+ colCell: true,
+ },
+ },
+ style: {
+ rowCell: {
+ height: 50,
+ },
+ colCell: {},
+ dataCell: {},
+ },
+ };
+
+ const s2 = new PivotSheet(container, s2DataConfig, s2Options);
+
+ const cellTheme: DefaultCellTheme = {
+ text: {
+ // 最大行数,文本超出后将被截断
+ maxLines: 2,
+ // 文本是否换行
+ wordWrap: true,
+ // 可选项见:https://g.antv.antgroup.com/api/basic/text#textoverflow
+ textOverflow: 'ellipsis',
+ },
+ bolderText: {
+ maxLines: 2,
+ wordWrap: true,
+ textOverflow: 'ellipsis',
+ },
+ measureText: {
+ maxLines: 2,
+ wordWrap: true,
+ textOverflow: 'ellipsis',
+ },
+ };
+
+ s2.setTheme({
+ seriesNumberCell: cellTheme,
+ colCell: cellTheme,
+ cornerCell: cellTheme,
+ rowCell: cellTheme,
+ // 数值不建议换行, 容易产生歧义
+ // dataCell: cellTheme,
+ });
+
+ await s2.render();
+ });
From 001a798bcf8d5af0284c44e9e4845ff919b6ea3e Mon Sep 17 00:00:00 2001
From: lijinke666
Date: Tue, 26 Dec 2023 20:23:01 +0800
Subject: [PATCH 05/64] =?UTF-8?q?docs:=20=E5=AE=8C=E5=96=84=20G=20?=
=?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=92=8C=E7=BB=98=E5=88=B6=20G2=20=E5=9B=BE?=
=?UTF-8?q?=E8=A1=A8=E6=96=87=E6=A1=A3=E5=92=8C=E7=A4=BA=E4=BE=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../manual/advanced/custom/custom-chart.zh.md | 2 +-
s2-site/docs/manual/advanced/g-plugins.en.md | 4 +
s2-site/docs/manual/advanced/g-plugins.zh.md | 54 +++++++++++
.../docs/manual/basic/multi-line-text.zh.md | 10 ++
.../custom-g2-chart/demo/custom-g2-chart.ts | 97 ++++++++++++++++++-
.../custom/custom-g2-chart/demo/meta.json | 2 +-
.../demo/{custom-plugins.ts => a11y.ts} | 3 +-
.../custom/custom-plugins/demo/meta.json | 14 ++-
.../custom/custom-plugins/demo/rough.ts | 71 ++++++++++++++
9 files changed, 248 insertions(+), 9 deletions(-)
create mode 100644 s2-site/docs/manual/advanced/g-plugins.en.md
create mode 100644 s2-site/docs/manual/advanced/g-plugins.zh.md
rename s2-site/examples/custom/custom-plugins/demo/{custom-plugins.ts => a11y.ts} (91%)
create mode 100644 s2-site/examples/custom/custom-plugins/demo/rough.ts
diff --git a/s2-site/docs/manual/advanced/custom/custom-chart.zh.md b/s2-site/docs/manual/advanced/custom/custom-chart.zh.md
index 24bdcd4816..bd03132c42 100644
--- a/s2-site/docs/manual/advanced/custom/custom-chart.zh.md
+++ b/s2-site/docs/manual/advanced/custom/custom-chart.zh.md
@@ -410,4 +410,4 @@ function App() {
[查看示例](/examples/custom/custom-cell#custom-g2-chart)
-
+
diff --git a/s2-site/docs/manual/advanced/g-plugins.en.md b/s2-site/docs/manual/advanced/g-plugins.en.md
new file mode 100644
index 0000000000..0805ab9030
--- /dev/null
+++ b/s2-site/docs/manual/advanced/g-plugins.en.md
@@ -0,0 +1,4 @@
+---
+title: AntV/G Plugins
+order: 10
+---
diff --git a/s2-site/docs/manual/advanced/g-plugins.zh.md b/s2-site/docs/manual/advanced/g-plugins.zh.md
new file mode 100644
index 0000000000..985a8fac21
--- /dev/null
+++ b/s2-site/docs/manual/advanced/g-plugins.zh.md
@@ -0,0 +1,54 @@
+---
+title: 注册 AntV/G 插件
+order: 10
+---
+
+:::warning{title='提示'}
+阅读本章前,请确保已经对 S2 足够了解,并且熟悉 [`AntV/G`](https://g.antv.antgroup.com/) 渲染引擎的相关内容。
+:::
+
+S2 基于 [`AntV/G`](https://g.antv.antgroup.com/) 渲染引擎绘制,因此可以共享其丰富的插件生态。
+
+
+
+## 插件系统介绍
+
+请阅读 [G 插件系统介绍](https://g.antv.antgroup.com/plugins/intro) 相关章节。
+
+## 使用
+
+S2 提供 `transformCanvasConfig` 用于访问 `G` 的上下文,用于 [注册插件](https://g.antv.antgroup.com/plugins/intro) 和透传相关 [配置参数](https://g.antv.antgroup.com/api/canvas/options), 由于 `Canvas` 的弊端,内部的文字不可被浏览器搜索,为了更友好实现无障碍功能,我们可以使用 `@antv/g-plugin-a11y` 插件
+
+```ts
+import { PivotSheet } from '@antv/s2';
+import { Plugin as PluginA11y } from '@antv/g-plugin-a11y';
+
+const s2Options = {
+ transformCanvasConfig(renderer) {
+ renderer.registerPlugin(
+ new PluginA11y({
+ enableExtractingText: true,
+ }),
+ );
+
+ console.log('当前已注册插件:', renderer.getPlugins(), renderer.getConfig());
+
+ return {
+ // 是否支持在容器上应用 CSS Transform 的情况下确保交互事件坐标转换正确
+ supportsCSSTransform: true,
+ devicePixelRatio: 2,
+ cursor: 'crosshair',
+ };
+ }
+};
+
+const s2 = new PivotSheet(container, s2DataConfig, s2Options);
+
+s2.render();
+```
+
+## 效果
+
+
+
+
diff --git a/s2-site/docs/manual/basic/multi-line-text.zh.md b/s2-site/docs/manual/basic/multi-line-text.zh.md
index 3c15ec4720..f48ececce5 100644
--- a/s2-site/docs/manual/basic/multi-line-text.zh.md
+++ b/s2-site/docs/manual/basic/multi-line-text.zh.md
@@ -67,3 +67,13 @@ s2.setTheme({
## 效果
+
+## 获取单元格文本状态
+
+如果想获取一些特定状态,如 `文本最大宽度`, `文本是否换行`, `文本是否溢出`, 可以在拿到 [单元格信息后](/manual/advanced/get-cell-data) 后,调用单元格基类的方法,具体请 [查看 API](/api/basic-class/base-cell)。
+
+```ts
+cell.getActualText()
+cell.getOriginalText()
+cell.isTextOverflowing()
+```
diff --git a/s2-site/examples/custom/custom-g2-chart/demo/custom-g2-chart.ts b/s2-site/examples/custom/custom-g2-chart/demo/custom-g2-chart.ts
index 4a5e53c67f..f68a21ef19 100644
--- a/s2-site/examples/custom/custom-g2-chart/demo/custom-g2-chart.ts
+++ b/s2-site/examples/custom/custom-g2-chart/demo/custom-g2-chart.ts
@@ -31,7 +31,7 @@ const s2Options: S2Options = {
},
// 适当增加单元格宽高, 以便于展示 G2 图表
dataCell: {
- width: 400,
+ width: 350,
height: 400,
},
},
@@ -71,10 +71,103 @@ const s2DataConfig: S2DataConfig = {
data: [
// 普通数据
{
- number: 1343,
+ number: {
+ // 折线图
+ values: {
+ type: 'line',
+ autoFit: true,
+ data: {
+ type: 'fetch',
+ value: 'https://assets.antv.antgroup.com/g2/indices.json',
+ },
+ encode: {
+ x: (d: Record) => new Date(d['Date']),
+ y: 'Close',
+ color: 'Symbol',
+ },
+ transform: [{ type: 'normalizeY', basis: 'first', groupBy: 'color' }],
+ scale: { y: { type: 'log' } },
+ axis: { y: { title: '↑ Change in price (%)' } },
+ labels: [{ text: 'Symbol', selector: 'last', fontSize: 10 }],
+ tooltip: { items: [{ channel: 'y', valueFormatter: '.1f' }] },
+ },
+ },
+ province: '浙江省',
+ city: '杭州市',
+ type: '办公用品',
+ sub_type: '纸张',
+ },
+ {
+ number: {
+ // 玉玦图
+ values: {
+ type: 'interval',
+ autoFit: true,
+ data: [
+ { question: '问题 1', percent: 0.21 },
+ { question: '问题 2', percent: 0.4 },
+ { question: '问题 3', percent: 0.49 },
+ { question: '问题 4', percent: 0.52 },
+ { question: '问题 5', percent: 0.53 },
+ { question: '问题 6', percent: 0.84 },
+ { question: '问题 7', percent: 1 },
+ { question: '问题 8', percent: 1.2 },
+ ],
+ encode: { x: 'question', y: 'percent', color: 'percent' },
+ scale: { color: { range: '#BAE7FF-#1890FF-#0050B3' } },
+ coordinate: {
+ type: 'radial',
+ innerRadius: 0.1,
+ endAngle: 3.141592653589793,
+ },
+ style: { stroke: 'white' },
+ animate: { enter: { type: 'waveIn', duration: 800 } },
+ // animate: false,
+ legend: {
+ color: {
+ length: 400,
+ position: 'bottom',
+ layout: { justifyContent: 'center' },
+ },
+ },
+ },
+ },
province: '浙江省',
city: '杭州市',
type: '办公用品',
+ sub_type: '笔',
+ },
+ {
+ number: {
+ // 柱形图
+ values: {
+ type: 'interval',
+ autoFit: true,
+ data: [
+ { genre: 'Sports', sold: 275 },
+ { genre: 'Strategy', sold: 115 },
+ { genre: 'Action', sold: 120 },
+ { genre: 'Shooter', sold: 350 },
+ { genre: 'Other', sold: 150 },
+ ],
+ scale: {
+ color: {
+ guide: {
+ position: 'right',
+ size: 80,
+ },
+ },
+ },
+ encode: {
+ x: 'genre',
+ y: 'sold',
+ color: 'genre',
+ },
+ },
+ },
+ province: '浙江省',
+ city: '舟山市',
+ type: '办公用品',
sub_type: '纸张',
},
{
diff --git a/s2-site/examples/custom/custom-g2-chart/demo/meta.json b/s2-site/examples/custom/custom-g2-chart/demo/meta.json
index 405e95210b..17251ad5d7 100644
--- a/s2-site/examples/custom/custom-g2-chart/demo/meta.json
+++ b/s2-site/examples/custom/custom-g2-chart/demo/meta.json
@@ -10,7 +10,7 @@
"zh": "单元格内绘制 G2 图表",
"en": "render G2 charts"
},
- "screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*y9mfQqk9XwYAAAAAAAAAAAAADmJ7AQ/original"
+ "screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*A9oWSbAfHu4AAAAAAAAAAAAADmJ7AQ/original"
}
]
}
diff --git a/s2-site/examples/custom/custom-plugins/demo/custom-plugins.ts b/s2-site/examples/custom/custom-plugins/demo/a11y.ts
similarity index 91%
rename from s2-site/examples/custom/custom-plugins/demo/custom-plugins.ts
rename to s2-site/examples/custom/custom-plugins/demo/a11y.ts
index 1a8150e954..797af5ded9 100644
--- a/s2-site/examples/custom/custom-plugins/demo/custom-plugins.ts
+++ b/s2-site/examples/custom/custom-plugins/demo/a11y.ts
@@ -1,5 +1,4 @@
import { PivotSheet, S2DataConfig, 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(
@@ -50,7 +49,7 @@ fetch(
},
},
transformCanvasConfig(renderer) {
- renderer.registerPlugin(new PluginRoughCanvasRenderer());
+ // 试试使用浏览器的搜索
renderer.registerPlugin(
new PluginA11y({
enableExtractingText: true,
diff --git a/s2-site/examples/custom/custom-plugins/demo/meta.json b/s2-site/examples/custom/custom-plugins/demo/meta.json
index eaa3596197..26f2771ccc 100644
--- a/s2-site/examples/custom/custom-plugins/demo/meta.json
+++ b/s2-site/examples/custom/custom-plugins/demo/meta.json
@@ -5,10 +5,18 @@
},
"demos": [
{
- "filename": "custom-plugins.ts",
+ "filename": "a11y.ts",
"title": {
- "zh": "自定义 AntV/G 5.0 插件和配置",
- "en": "custom AntV/G 5.0 plugins and config"
+ "zh": "无障碍功能",
+ "en": "a11y"
+ },
+ "screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*HIhnRq9EqIwAAAAAAAAAAAAADmJ7AQ/original"
+ },
+ {
+ "filename": "rough.ts",
+ "title": {
+ "zh": "手绘风格",
+ "en": "rough"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*Ag6SSYgDpeYAAAAAAAAAAAAADmJ7AQ/original"
}
diff --git a/s2-site/examples/custom/custom-plugins/demo/rough.ts b/s2-site/examples/custom/custom-plugins/demo/rough.ts
new file mode 100644
index 0000000000..5d4cb09089
--- /dev/null
+++ b/s2-site/examples/custom/custom-plugins/demo/rough.ts
@@ -0,0 +1,71 @@
+import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
+import { Plugin as PluginRoughCanvasRenderer } from '@antv/g-plugin-rough-canvas-renderer';
+
+fetch(
+ 'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
+)
+ .then((res) => res.json())
+ .then(async (res) => {
+ const container = document.getElementById('container');
+ const s2DataConfig: 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());
+
+ console.log(
+ '当前已注册插件:',
+ renderer.getPlugins(),
+ renderer.getConfig(),
+ );
+
+ return {
+ supportsCSSTransform: true,
+ devicePixelRatio: 2,
+ cursor: 'crosshair',
+ };
+ },
+ };
+
+ const s2 = new PivotSheet(container, s2DataConfig, s2Options);
+
+ await s2.render();
+ });
From 17ca8dc9decdc7d7bb836e56cdd01ce96600d938 Mon Sep 17 00:00:00 2001
From: lijinke666
Date: Wed, 27 Dec 2023 15:27:30 +0800
Subject: [PATCH 06/64] =?UTF-8?q?docs:=20=E5=AE=8C=E5=96=84=E5=88=86?=
=?UTF-8?q?=E6=9E=90=E7=BB=84=E4=BB=B6=E7=9B=B8=E5=85=B3=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
s2-site/.dumi/global.less | 4 +
s2-site/.dumirc.ts | 14 +-
s2-site/docs/api/components/export.en.md | 2 +-
s2-site/docs/api/components/export.zh.md | 6 +-
.../{export.en.md => copy-export.en.md} | 0
s2-site/docs/common/copy-export.zh.md | 214 ++++++++++++++++++
s2-site/docs/common/export.zh.md | 78 -------
s2-site/docs/common/interaction.zh.md | 2 +-
.../analysis/drill-down.en.md | 0
.../analysis/drill-down.zh.md | 30 ++-
.../analysis/editable-mode.en.md | 0
.../advanced/analysis/editable-mode.zh.md | 177 +++++++++++++++
.../analysis/export.en.md} | 4 +-
.../manual/advanced/analysis/export.zh.md | 56 +++++
.../analysis/mobile-component.en.md | 0
.../analysis/mobile-component.zh.md | 41 ++--
.../analysis/pagination.en.md | 0
.../manual/advanced/analysis/pagination.zh.md | 93 ++++++++
.../analysis/strategy.en.md | 0
.../analysis/strategy.zh.md | 68 ++++--
.../analysis/switcher.en.md | 0
.../analysis/switcher.zh.md | 47 ++--
.../{basic => advanced}/analysis/vue.en.md | 0
.../{basic => advanced}/analysis/vue.zh.md | 2 +
.../manual/advanced/custom/cell-size.zh.md | 28 +--
.../manual/advanced/custom/custom-chart.zh.md | 7 +-
.../docs/manual/advanced/custom/hook.zh.md | 12 +-
s2-site/docs/manual/advanced/hd-adapter.zh.md | 2 +-
.../manual/advanced/interaction/basic.zh.md | 4 +
.../manual/advanced/interaction/copy.en.md | 4 +
.../manual/advanced/interaction/copy.zh.md | 6 +
.../manual/advanced/interaction/scroll.zh.md | 20 +-
.../manual/basic/analysis/copy-export.zh.md | 101 ---------
.../manual/basic/analysis/editable-mode.zh.md | 176 --------------
.../manual/basic/analysis/pagination.zh.md | 64 ------
.../advanced/demo/table-link-jump.ts | 2 +-
36 files changed, 735 insertions(+), 529 deletions(-)
rename s2-site/docs/common/{export.en.md => copy-export.en.md} (100%)
create mode 100644 s2-site/docs/common/copy-export.zh.md
delete mode 100644 s2-site/docs/common/export.zh.md
rename s2-site/docs/manual/{basic => advanced}/analysis/drill-down.en.md (100%)
rename s2-site/docs/manual/{basic => advanced}/analysis/drill-down.zh.md (74%)
rename s2-site/docs/manual/{basic => advanced}/analysis/editable-mode.en.md (100%)
create mode 100644 s2-site/docs/manual/advanced/analysis/editable-mode.zh.md
rename s2-site/docs/manual/{basic/analysis/copy-export.en.md => advanced/analysis/export.en.md} (97%)
create mode 100644 s2-site/docs/manual/advanced/analysis/export.zh.md
rename s2-site/docs/manual/{basic => advanced}/analysis/mobile-component.en.md (100%)
rename s2-site/docs/manual/{basic => advanced}/analysis/mobile-component.zh.md (59%)
rename s2-site/docs/manual/{basic => advanced}/analysis/pagination.en.md (100%)
create mode 100644 s2-site/docs/manual/advanced/analysis/pagination.zh.md
rename s2-site/docs/manual/{basic => advanced}/analysis/strategy.en.md (100%)
rename s2-site/docs/manual/{basic => advanced}/analysis/strategy.zh.md (73%)
rename s2-site/docs/manual/{basic => advanced}/analysis/switcher.en.md (100%)
rename s2-site/docs/manual/{basic => advanced}/analysis/switcher.zh.md (70%)
rename s2-site/docs/manual/{basic => advanced}/analysis/vue.en.md (100%)
rename s2-site/docs/manual/{basic => advanced}/analysis/vue.zh.md (98%)
create mode 100644 s2-site/docs/manual/advanced/interaction/copy.en.md
create mode 100644 s2-site/docs/manual/advanced/interaction/copy.zh.md
delete mode 100644 s2-site/docs/manual/basic/analysis/copy-export.zh.md
delete mode 100644 s2-site/docs/manual/basic/analysis/editable-mode.zh.md
delete mode 100644 s2-site/docs/manual/basic/analysis/pagination.zh.md
diff --git a/s2-site/.dumi/global.less b/s2-site/.dumi/global.less
index 4309701f4d..f064dd8480 100644
--- a/s2-site/.dumi/global.less
+++ b/s2-site/.dumi/global.less
@@ -10,6 +10,10 @@ ul {
margin-bottom: 16px !important;
}
+details {
+ cursor: pointer;
+}
+
.dumi-default-source-code {
margin: 24px 0;
diff --git a/s2-site/.dumirc.ts b/s2-site/.dumirc.ts
index 3912622984..08a15afa2c 100644
--- a/s2-site/.dumirc.ts
+++ b/s2-site/.dumirc.ts
@@ -164,20 +164,20 @@ export default defineConfig({
order: 5,
},
{
- slug: 'manual/basic/sort',
+ slug: 'manual/advanced/analysis',
title: {
- zh: '排序',
- en: 'Sort',
+ zh: '分析组件',
+ en: 'Analyze component',
},
order: 6,
},
{
- slug: 'manual/basic/analysis',
+ slug: 'manual/basic/sort',
title: {
- zh: '分析组件',
- en: 'Analyze component',
+ zh: '排序',
+ en: 'Sort',
},
- order: 7,
+ order: 6,
},
],
tutorials: [
diff --git a/s2-site/docs/api/components/export.en.md b/s2-site/docs/api/components/export.en.md
index 41fba9fd31..3f9668fcd0 100644
--- a/s2-site/docs/api/components/export.en.md
+++ b/s2-site/docs/api/components/export.en.md
@@ -30,7 +30,7 @@ order: 5
| syncCopy | Copy data synchronously (default is asynchronous) | `boolean` | `false` | |
| drop down | Dropdown menu configuration, transparently passed to the `Dropdown` component of `antd` | [DropdownProps](https://ant.design/components/dropdown-cn/#API) | | |
-
+
## Vue export component
diff --git a/s2-site/docs/api/components/export.zh.md b/s2-site/docs/api/components/export.zh.md
index 93b39b334a..616807136e 100644
--- a/s2-site/docs/api/components/export.zh.md
+++ b/s2-site/docs/api/components/export.zh.md
@@ -30,8 +30,4 @@ order: 5
| syncCopy | 同步复制数据 (默认异步) | `boolean` | `false` | |
| dropdown | 下拉菜单配置,透传给 `antd` 的 `Dropdown` 组件 | [DropdownProps](https://ant.design/components/dropdown-cn/#API) | | |
-
-
-## Vue 导出组件
-
-开发中,敬请期待
+
diff --git a/s2-site/docs/common/export.en.md b/s2-site/docs/common/copy-export.en.md
similarity index 100%
rename from s2-site/docs/common/export.en.md
rename to s2-site/docs/common/copy-export.en.md
diff --git a/s2-site/docs/common/copy-export.zh.md b/s2-site/docs/common/copy-export.zh.md
new file mode 100644
index 0000000000..a6dbdc05cd
--- /dev/null
+++ b/s2-site/docs/common/copy-export.zh.md
@@ -0,0 +1,214 @@
+---
+title: 复制与导出
+order: 8
+---
+
+## 复制
+
+### 1. 全量复制
+
+```ts | pure
+import { copyData, copyToClipboard } from '@antv/s2'
+
+// 拿到复制数据
+const data = copyData(spreadsheet, '\t', false)
+
+// 同步复制:copyToClipboard(data, false)
+copyToClipboard(data)
+ .then(() => {
+ console.log('复制成功')
+ })
+ .catch(() => {
+ console.log('复制失败')
+ })
+```
+
+#### 1.1 原始数据全量复制
+
+
+
+#### 1.2 格式化数据全量复制
+
+如果配置了 `S2DataConfig.meta` 对数据有 [格式化处理](/manual/basic/formatter), 可以开启 `copyWithFormat`, 这样复制时会拿到格式化之后的数据。
+
+```ts
+const s2Options = {
+ interaction: {
+ // 复制时携带表头
+ copyWithHeader: true,
+ // 复制格式化后的数据
+ copyWithFormat: true
+ }
+}
+```
+
+
+
+### 2. 局部复制
+
+S2 默认提供复制的能力,开启后,使用快捷键 `Command/Ctrl + C` 即可复制选中区域(局部复制).
+
+```ts
+const s2Options = {
+ interaction: {
+ // 是否开启复制
+ enableCopy: true,
+ // 复制时携带表头
+ copyWithHeader: true,
+ // 复制格式化后的数据
+ copyWithFormat: true,
+
+ // 可选:圈选复制前,需要开启圈选功能
+ brushSelection: {
+ dataCell: true,
+ rowCell: true,
+ colCell: true,
+ },
+
+ // 可选:多选
+ multiSelection: true
+ }
+};
+```
+
+#### 2.1 复制到 Excel
+
+
+
+#### 2.2 复制带 HTML 格式
+
+
+
+#### 2.3 复制行头内容
+
+
+
+#### 2.4 复制列头内容
+
+
+
+#### 2.5 带表头复制
+
+开启 `copyWithHeader` 后,复制时会携带当前选中数据对应的行列头单元格数据。
+
+```ts
+const s2Options = {
+ interaction: {
+ enableCopy: true,
+ copyWithHeader: true,
+ }
+};
+```
+
+
+
+## 导出
+
+### 原始导出方法
+
+:::info{title="提示"}
+组件层的复制,导出等功能,基于核心层 `@antv/s2` 透出的一系列工具方法封装,可以根据实际业务,基于工具方法自行封装
+:::
+
+#### 1. 导出 CSV
+
+默认只提供 `csv` 纯文本格式的导出,如果想导出 `xlsx`, 保留单元格样式,可以结合 [exceljs](https://github.com/exceljs/exceljs), [sheetjs]( https://github.com/SheetJS/sheetjs) 等工具自行处理。
+
+```ts | pure
+import { copyData, download } from '@antv/s2'
+
+// 拿到复制数据
+const data = copyData(spreadsheet, '\t', false)
+
+// 导出数据 (csv)
+download(data, 'filename')
+```
+
+#### 2. 复制数据到剪贴板
+
+:::warning{title="注意"}
+S2 会在复制的时候往剪贴板写入两种类型的元数据
+
+- `text/html`
+- `text/plain`
+
+粘贴的时候,取决于`接收方选择什么类型的数据`,对于富文本一般来说接收的是 `text/html`, 对于 Excel 之类的就是 `text/plain`, 即带制表符 `\t` 的纯文本,支持自定义修改。
+:::
+
+```ts | pure
+import { copyToClipboard } from '@antv/s2'
+
+// 同步复制:copyToClipboard(data, false)
+copyToClipboard(data)
+ .then(() => {
+ console.log('复制成功')
+ })
+ .catch(() => {
+ console.log('复制失败')
+ })
+```
+
+#### 3. 自定义导出类型
+
+```ts | pure
+import { copyData, registerTransformer, CopyMIMEType } from '@antv/s2'
+
+// 自定义导出类型
+registerTransformer(CopyMIMEType.HTML, (matrix) => {
+ return ` | `
+})
+
+// 复制到 word、语雀等场景会成为一个空表格
+const data = copyData(spreadsheet, '\t', false)
+```
+
+#### API
+
+##### copyData
+
+> @deprecated 后续将废弃方法,将使用 asyncGetAllPlainData
+
+| 参数 | 说明 | 类型 | 默认值 | 必选 |
+| ------------|---------------------------------------|--------------------------------------------------------------------------------|---------------| --- |
+| spreadsheet | s2 实例 | [SpreadSheet](/docs/api/basic-class/spreadsheet) | | ✓ |
+| split | 分隔符 | `string` | | ✓ |
+| formatOptions | 是否格式化,可以分别对数据单元格和行列头进行格式化,传布尔值会同时对单元格和行列头生效。 | boolean \| { isFormatHeader?: boolean, isFormatData?: boolean}
| `false` | |
+| customTransformer | 导出时支持自定义 (transformer) 数据导出格式化方法 | (transformer: `Transformer`) => `Partial` | `transformer` | |
+| isAsyncExport | 是否异步导出 | boolean | false | |
+
+##### copyToClipboard
+
+| 参数 | 说明 | 类型 | 默认值 | 必选 |
+| --- | --- | ------- | ----- | --- |
+| data | 数据源 | `string` | | ✓ |
+| sync | 是否同步复制数据 (默认异步) | `boolean` | `false` | |
+
+##### download
+
+| 参数 | 说明 | 类型 | 默认值 | 必选 |
+| ------- | ------- | ------- | ----- | --- |
+| data | 数据源 | `string` | | ✓ |
+| filename | 文件名称 | `string` | | ✓ |
+
+##### CopyMIMEType
+
+```ts
+enum CopyMIMEType {
+ PLAIN = 'text/plain',
+ HTML = 'text/html',
+}
+```
+
+##### Transformer
+
+```ts | pure
+export interface Transformer {
+ [CopyMIMEType.PLAIN]: MatrixPlainTransformer;
+ [CopyMIMEType.HTML]: MatrixHTMLTransformer;
+}
+```
+
+| 参数 | 说明 | 类型 | 默认值 | 必选 |
+| --- | --- |--------------------------|-----| --- |
+| type | 复制内容的 MIMEType | `CopyMIMEType` | | ✓ |
+| transformer | 处理函数 | `MatrixHTMLTransformer \| MatrixPlainTransformer` | | ✓ |
diff --git a/s2-site/docs/common/export.zh.md b/s2-site/docs/common/export.zh.md
deleted file mode 100644
index 152f818a2a..0000000000
--- a/s2-site/docs/common/export.zh.md
+++ /dev/null
@@ -1,78 +0,0 @@
----
-title: 导出
-order: 8
----
-
-## 原始导出方法
-
-组件层的复制,导出等功能,基于核心层 `@antv/s2` 透出的一系列工具方法封装,可以根据实际业务,基于工具方法自行封装
-
-```tsx
-import { copyData, copyToClipboard, download } from '@antv/s2'
-
-// 拿到复制数据
-const data = copyData(spreadsheet, '\t', false)
-
-// 复制数据到剪贴板
-// 同步复制:copyToClipboard(data, false)
-copyToClipboard(data)
- .then(() => {
- console.log('复制成功')
- })
- .catch(() => {
- console.log('复制失败')
- })
-
-// 导出数据
-download(data, 'filename')
-
-
-// 自定义导出类型
-registerTransformer(CopyMIMEType.HTML, (matrix) => {
- return ` | `
-})
-
-const data = copyData(spreadsheet, '\t', false)
-// 复制到word、语雀等场景会成为一个空表格
-
-```
-
-### copyData
-
-> @deprecated 后续将废弃方法,将使用 asyncGetAllPlainData
-
-| 参数 | 说明 | 类型 | 默认值 | 必选 |
-| ------------|---------------------------------------|--------------------------------------------------------------------------------|---------------| --- |
-| spreadsheet | s2 实例 | [SpreadSheet](/docs/api/basic-class/spreadsheet) | | ✓ |
-| split | 分隔符 | `string` | | ✓ |
-| formatOptions | 是否格式化,可以分别对数据单元格和行列头进行格式化,传布尔值会同时对单元格和行列头生效。 | boolean \| { isFormatHeader?: boolean, isFormatData?: boolean}
| `false` | |
-| customTransformer | 导出时支持自定义(transformer)数据导出格式化方法 | (transformer: Transformer) => Partial
| `transformer` | |
-| isAsyncExport | 是否异步导出 | boolean | false | |
-
-### copyToClipboard
-
-| 参数 | 说明 | 类型 | 默认值 | 必选 |
-| --- | --- | ------- | ----- | --- |
-| data | 数据源 | `string` | | ✓ |
-| sync | 是否同步复制数据 (默认异步) | `boolean` | `false` | |
-
-### download
-
-| 参数 | 说明 | 类型 | 默认值 | 必选 |
-| ------- | ------- | ------- | ----- | --- |
-| data | 数据源 | `string` | | ✓ |
-| filename | 文件名称 | `string` | | ✓ |
-
-### Transformer
-
-```ts
-export interface Transformer {
- [CopyMIMEType.PLAIN]: MatrixPlainTransformer;
- [CopyMIMEType.HTML]: MatrixHTMLTransformer;
-}
-```
-
-| 参数 | 说明 | 类型 | 默认值 | 必选 |
-| --- | --- |--------------------------|-----| --- |
-| type | 复制内容的MIMEType | `CopyMIMEType` | | ✓ |
-| transformer | 处理函数 | `MatrixHTMLTransformer | MatrixPlainTransformer` | | ✓ |
diff --git a/s2-site/docs/common/interaction.zh.md b/s2-site/docs/common/interaction.zh.md
index 27ccfd9fcf..62abf46abb 100644
--- a/s2-site/docs/common/interaction.zh.md
+++ b/s2-site/docs/common/interaction.zh.md
@@ -15,7 +15,7 @@ order: 5
| enableCopy | 是否允许复制 | `boolean` | `false` | |
| copyWithHeader | 复制数据是否带表头信息 | `boolean` | `false` | |
| copyWithFormat | 是否使用 field format 格式复制 | `boolean` | `false` | |
-| customTransformer | 复制时支持自定义(transformer)数据格式化方法 | (transformer: [Transformer](/docs/api/components/export#transformer)) => Partial
| `transformer` | |
+| customTransformer | 复制时支持自定义 (transformer) 数据格式化方法 | (transformer: [Transformer](/docs/api/components/export#transformer)) => `Partial` | `transformer` | |
| customInteractions | 自定义交互 [详情](/docs/manual/advanced/interaction/custom) | [CustomInteraction[]](#custominteraction) | | |
| scrollSpeedRatio | 用于控制滚动速率,分水平和垂直两个方向,默认为 1 | [ScrollSpeedRatio](#scrollspeedratio) | | |
| autoResetSheetStyle | 用于控制点击表格外区域和按下 esc 键时是否重置交互状态 | `boolean` | `true` | |
diff --git a/s2-site/docs/manual/basic/analysis/drill-down.en.md b/s2-site/docs/manual/advanced/analysis/drill-down.en.md
similarity index 100%
rename from s2-site/docs/manual/basic/analysis/drill-down.en.md
rename to s2-site/docs/manual/advanced/analysis/drill-down.en.md
diff --git a/s2-site/docs/manual/basic/analysis/drill-down.zh.md b/s2-site/docs/manual/advanced/analysis/drill-down.zh.md
similarity index 74%
rename from s2-site/docs/manual/basic/analysis/drill-down.zh.md
rename to s2-site/docs/manual/advanced/analysis/drill-down.zh.md
index 1d7148ee5a..6f787a0799 100644
--- a/s2-site/docs/manual/basic/analysis/drill-down.zh.md
+++ b/s2-site/docs/manual/advanced/analysis/drill-down.zh.md
@@ -3,7 +3,9 @@ title: 维度下钻
order: 13
---
-S2 提供的「维度下钻」的能力,可以为你挖掘不同维度下更详细的数据,让你的数据洞察变得更清晰。
+@antv/s2-react @antv/s2-vue
+
+S2 提供 `维度下钻` 的基础能力,`@antv/s2-react` 和 `@antv/s2-vue` 基于 `@antv/s2-core` 封装了 `维度下钻` 的组件,可以为你挖掘不同维度下更详细的数据,让你的数据洞察变得更清晰。
@@ -11,12 +13,12 @@ S2 提供的「维度下钻」的能力,可以为你挖掘不同维度下更
### 基本概念
-- 主要适用于存在分层关系的数据源, 对于某一个数据信息,向下钻取不同层级的数据表现。🌰 列如:查看不同区域的销售数据,您查看华中区销售额时,可以下钻查看湖北省的销售额。
+- 主要适用于存在分层关系的数据源,对于某一个数据信息,向下钻取不同层级的数据表现。🌰 例如:查看不同区域的销售数据,您查看华中区销售额时,可以下钻查看湖北省的销售额。
- 下钻是由汇总数据深入到细节,层层深入以便更详细的查看数据的方式,让数据更加清晰明了,帮助充分挖掘数据背后的价值。
### 功能描述
-配置维度下钻,当前仅支持透视模式的树形结构下,行头维度下钻
+配置维度下钻,当前仅支持透视模式的树形结构下,行头维度下钻。
### 拓展
@@ -41,7 +43,6 @@ const PartDrillDown = {
},
],
},
-
// 点击下钻后的回调
fetchData: (meta, drillFields) =>
new Promise((resolve) => {
@@ -105,13 +106,30 @@ const App = () => {
}
```
-
+
+
+### 单独使用下钻面板
+
+```tsx
+import { DrillDown } from '@antv/s2-react';
+
+
+```
+
+
## 使用场景
-🌰 案例:
+:::info{title="🌰 案例"}
+
**洞察数据异常**:当销售负责人发现华中地区销售异常,远低于其他地区时。他通过下钻省份,查看华中地区所有省份的销售额。当发现湖北省销售异常时,由可以通过省份下钻到城市🏙,发现城市 B 销售额异常。通过下钻,我们快速的挖掘到了销售额异常的根源。
+:::
+
## API
diff --git a/s2-site/docs/manual/basic/analysis/editable-mode.en.md b/s2-site/docs/manual/advanced/analysis/editable-mode.en.md
similarity index 100%
rename from s2-site/docs/manual/basic/analysis/editable-mode.en.md
rename to s2-site/docs/manual/advanced/analysis/editable-mode.en.md
diff --git a/s2-site/docs/manual/advanced/analysis/editable-mode.zh.md b/s2-site/docs/manual/advanced/analysis/editable-mode.zh.md
new file mode 100644
index 0000000000..0bea452643
--- /dev/null
+++ b/s2-site/docs/manual/advanced/analysis/editable-mode.zh.md
@@ -0,0 +1,177 @@
+---
+title: 编辑表
+order: 3
+---
+
+@antv/s2-react
+
+编辑表是 `S2` 明细表的衍生形态之一。在提供完整的明细表的分析功能之外,还支持对数据的修改操作(**透视表暂不支持**)。
+
+
+
+## 快速上手
+
+```html
+
+```
+
+
+ 查看数据
+
+ ```ts
+ // 1. 准备数据
+ const data = [
+ {
+ "province": "浙江",
+ "city": "杭州",
+ "type": "笔",
+ "price": 1
+ },
+ {
+ "province": "浙江",
+ "city": "杭州",
+ "type": "纸张",
+ "price": 2
+ },
+ {
+ "province": "浙江",
+ "city": "舟山",
+ "type": "笔",
+ "price": 17
+ },
+ {
+ "province": "浙江",
+ "city": "舟山",
+ "type": "纸张",
+ "price": 6
+ },
+ {
+ "province": "吉林",
+ "city": "长春",
+ "type": "笔",
+ "price": 8
+ },
+ {
+ "province": "吉林",
+ "city": "白山",
+ "type": "笔",
+ "price": 12
+ },
+ {
+ "province": "吉林",
+ "city": "长春",
+ "type": "纸张",
+ "price": 3
+ },
+ {
+ "province": "吉林",
+ "city": "白山",
+ "type": "纸张",
+ "price": 25
+ },
+
+ {
+ "province": "浙江",
+ "city": "杭州",
+ "type": "笔",
+ "price": 20
+ },
+ {
+ "province": "浙江",
+ "city": "杭州",
+ "type": "纸张",
+ "price": 10
+ },
+ {
+ "province": "浙江",
+ "city": "舟山",
+ "type": "笔",
+ "price": 15
+ },
+ {
+ "province": "浙江",
+ "city": "舟山",
+ "type": "纸张",
+ "price": 2
+ },
+ {
+ "province": "吉林",
+ "city": "长春",
+ "type": "笔",
+ "price": 15
+ },
+ {
+ "province": "吉林",
+ "city": "白山",
+ "type": "笔",
+ "price": 30
+ },
+ {
+ "province": "吉林",
+ "city": "长春",
+ "type": "纸张",
+ "price": 40
+ },
+ {
+ "province": "吉林",
+ "city": "白山",
+ "type": "纸张",
+ "price": 50
+ }
+ ]
+ ```
+
+
+
+```typescript
+import React from "react";
+import { SheetComponent } from '@antv/s2-react';
+import '@antv/s2-react/dist/style.min.css';
+
+const s2DataCfg = {
+ fields: {
+ columns: ["province", "city", "type", "price"],
+ },
+ meta: [
+ // 列头字段对应的元信息,比如展示的中文名
+ {
+ field: "province",
+ name: "省份",
+ },
+ {
+ field: "city",
+ name: "城市",
+ },
+ {
+ field: "type",
+ name: "类型",
+ },
+ {
+ field: "price",
+ name: "价格",
+ },
+ ],
+ data,
+};
+
+const s2Options = {
+ width: 400,
+ height: 200,
+};
+
+const App = () => {
+ return (
+ ,
+ )
+}
+```
+
+## 效果
+
+[查看示例](/examples/react-component/sheet#editable)
+
+
diff --git a/s2-site/docs/manual/basic/analysis/copy-export.en.md b/s2-site/docs/manual/advanced/analysis/export.en.md
similarity index 97%
rename from s2-site/docs/manual/basic/analysis/copy-export.en.md
rename to s2-site/docs/manual/advanced/analysis/export.en.md
index cf4012cd7c..4f41bd3a06 100644
--- a/s2-site/docs/manual/basic/analysis/copy-export.en.md
+++ b/s2-site/docs/manual/advanced/analysis/export.en.md
@@ -1,5 +1,5 @@
---
-title: Copy And Export
+title: Export
order: 11
---
@@ -93,4 +93,4 @@ Click the copy or download button to export the full amount of data (full amount
-
+
diff --git a/s2-site/docs/manual/advanced/analysis/export.zh.md b/s2-site/docs/manual/advanced/analysis/export.zh.md
new file mode 100644
index 0000000000..41b2af33da
--- /dev/null
+++ b/s2-site/docs/manual/advanced/analysis/export.zh.md
@@ -0,0 +1,56 @@
+---
+title: 导出
+order: 11
+---
+
+@antv/s2 @antv/s2-react
+
+`@antv/s2` 提供了 [复制导出的基础能力](/manual/advanced/interaction/copy), `@antv/s2-react` 组件层基于 `@antv/s2` 封装了开箱即用的导出功能。
+
+## 使用
+
+```tsx | {15-19}
+import { SheetComponent } from '@antv/s2-react'
+
+const S2Options = {
+ interaction: {
+ // 开启复制
+ enableCopy: true
+ }
+}
+
+const App = () => {
+ return (
+
+ )
+}
+```
+
+:::info{title="提示"}
+开启导出功能后,点击右上角的下拉菜单,可以复制和导出(原始/全量)数据。
+
+1. `复制原始数据/复制格式化数据`: 可以直接粘贴到 `Excel`,`语雀` 等常用应用中。
+2. `下载原始数据/下载格式化数据`: 生成 `csv` 文件,可以直接使用 `Excel` 打开。
+
+:::
+
+
+
+## 在非 React 应用中使用
+
+:::info{title="提示"}
+本质上,`@antv/s2-react` 的导出分析组件,只是基于 `@antv/s2` 提供的能力,封装了相应的 UI, 如果不希望依赖框架,或者希望在 `Vue` 等框架中使用,都是可以的。
+:::
+
+
diff --git a/s2-site/docs/manual/basic/analysis/mobile-component.en.md b/s2-site/docs/manual/advanced/analysis/mobile-component.en.md
similarity index 100%
rename from s2-site/docs/manual/basic/analysis/mobile-component.en.md
rename to s2-site/docs/manual/advanced/analysis/mobile-component.en.md
diff --git a/s2-site/docs/manual/basic/analysis/mobile-component.zh.md b/s2-site/docs/manual/advanced/analysis/mobile-component.zh.md
similarity index 59%
rename from s2-site/docs/manual/basic/analysis/mobile-component.zh.md
rename to s2-site/docs/manual/advanced/analysis/mobile-component.zh.md
index c3d25f4c0c..d0e0512851 100644
--- a/s2-site/docs/manual/basic/analysis/mobile-component.zh.md
+++ b/s2-site/docs/manual/advanced/analysis/mobile-component.zh.md
@@ -1,19 +1,23 @@
---
-title: 移动端组件
+title: 移动端表格组件
order: 10
---
-为了满足移动端的使用场景,`s2-react` 中的分析组件进行了移动的适配。帮助用户在移动端更加便利、高效的看数。
+@antv/s2-react
-## 前提
+为了满足移动端的使用场景,`@antv/s2-react` 中的分析组件进行了移动端的适配。帮助用户在移动端更加便利、高效的看数。
-移动端表组件使用了 S2 提供的各种能力进行融合,所以建议在阅读本章前,请确保你已经阅读过以下章节:
+:::warning{title="注意"}
+
+**移动端表组件**使用了 S2 提供的各种能力进行融合,所以建议在阅读本章前,请确保你已经阅读过以下章节:
- [基本概念](/zh/docs/manual/basic/base-concept)
- [表格形态](/zh/docs/manual/basic/sheet-type/pivot-mode)
- [tooltip](/zh/docs/manual/basic/tooltip)
-## 移动端表格
+:::
+
+## 快速上手
```tsx
import React from 'react';
@@ -22,26 +26,23 @@ import '@antv/s2-react/dist/style.min.css';
const App = () => {
return (
-
+
)
}
```
-| PC | Mobile |
-|-------------------------------------------------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------ |
+| PC 端 | Mobile 端 |
+|--------------------------------------| --------------------------------- |
| | |
移动端组件 `MobileSheet`, 将会被内置移动专用的 `options`,使表格更加紧凑,同时禁用了移动无法使用的交互操作。当然,您也可以通过外部 `options` 设置来覆盖原有的配置。
```ts
-const mobileWidth = document.documentElement.clientWidth;
-export const DEFAULT_MOBILE_OPTIONS: Readonly = {
- width: mobileWidth - 40,
+const DEFAULT_MOBILE_OPTIONS = {
+ width: document.documentElement.clientWidth - 40,
height: 380,
style: {
- layoutWidthType: LayoutWidthTypes.ColAdaptive,
+ layoutWidthType: 'colAdaptive',
},
interaction: {
hoverHighlight: false,
@@ -54,21 +55,19 @@ export const DEFAULT_MOBILE_OPTIONS: Readonly = {
multiSelection: false,
rangeSelection: false,
},
- device: DeviceType.MOBILE,
+ device: 'mobile',
};
```
-> 配置可能实时变更,您可以通过获取 `DEFAULT_MOBILE_OPTIONS` 来查看,当前版本的 `options` 配置。
-
-## 移动端 Tooltips
+## 移动端 Tooltip
-我们修改了 `tooltips` 在移动端组件的交互操作。
+我们修改了 `tooltip` 在移动端组件的交互操作。
但保留了原本 [Tooltip API](/zh/docs/api/basic-class/base-tooltip) 的使用方式,您只需要使用 `MobileSheet` 组件即可使用到移动端定制的 `tooltips`。
📊 查看 [Tooltip 使用](/zh/docs/manual/basic/tooltip)
-| | PC | Mobile |
-| ------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| 功能 | PC 端 | Mobile 端 |
+| ------------- |---------------|----------------------------------------------|
| 排序功能 | | |
| 单元格信息展示 | | |
| 指标信息展示 | | |
diff --git a/s2-site/docs/manual/basic/analysis/pagination.en.md b/s2-site/docs/manual/advanced/analysis/pagination.en.md
similarity index 100%
rename from s2-site/docs/manual/basic/analysis/pagination.en.md
rename to s2-site/docs/manual/advanced/analysis/pagination.en.md
diff --git a/s2-site/docs/manual/advanced/analysis/pagination.zh.md b/s2-site/docs/manual/advanced/analysis/pagination.zh.md
new file mode 100644
index 0000000000..8fb53a6ca3
--- /dev/null
+++ b/s2-site/docs/manual/advanced/analysis/pagination.zh.md
@@ -0,0 +1,93 @@
+---
+title: 分页
+order: 11
+---
+
+@antv/s2-react @antv/s2-vue
+
+S2 内置了前端分页渲染的能力,点击下一页滚动到对应行。
+
+:::warning{title="注意"}
+
+如果基于 `@antv/s2-core` 开发,需要**自行引入**或**实现分页组件**,`core` 层仅提供分页能力,参考以下示例
+
+* [React](https://github.com/antvis/S2/blob/next/packages/s2-react/src/components/pagination/index.tsx)
+* [Vue 3.0](https://github.com/antvis/S2/blob/next/packages/s2-vue/src/components/pagination/index.vue)
+
+如果基于 [`@antv/s2-react`](#react-版本) 或 [`@antv/s2-vue`](#vue-30-版本) 开发,则只需配置分页相关配置项即可开箱即用。
+
+:::
+
+## 快速上手
+
+首先需要在 `s2Options` 中配置 `pagination` 属性
+
+```ts | {4-7}
+const s2Options = {
+ width: 600,
+ height: 480,
+ pagination: {
+ pageSize: 4,
+ current: 1,
+ },
+};
+```
+
+
+
+### React 版本
+
+:::info{title="提示"}
+
+`@antv/s2-react` 使用的是 [Ant Design](https://ant.design/components/pagination-cn/) Pagination 分页组件,支持 [透传 API](https://ant.design/components/pagination-cn/#API), 需要修改样式直接通过 CSS 覆盖即可。
+
+:::
+
+```tsx
+import { SheetComponent } from '@antv/s2-react'
+
+const s2Options = {
+ // https://ant.design/components/pagination-cn/#API
+ pagination: {}
+}
+
+
+```
+
+
+
+### Vue 3.0 版本
+
+:::info{title="提示"}
+
+`@antv/s2-vue` 使用的是 [Ant Design Vue](https://antdv.com/components/pagination) 分页组件,支持 [透传 API](https://antdv.com/components/pagination#API), 需要修改样式直接通过 CSS 覆盖即可。
+
+:::
+
+```tsx
+import { SheetComponent } from '@antv/s2-vue'
+
+const s2Options = {
+ // https://antdv.com/components/pagination#API
+ pagination: {}
+}
+
+
+
+```
+
+[Demo 地址](https://codesandbox.io/embed/nice-dijkstra-hzycy6?fontsize=14&hidenavigation=1&theme=dark)
+
+## API
+
+
+
+### SpreadsheetProps
+
+```tsx
+
+```
+
+| 参数 | 说明 | 类型 | 默认值 | 必选 |
+|-----|-----|-----|-----|-----|
+| showPagination | 是否显示默认分页
(只有在 `options` 配置过 `pagination` 属性才会生效) | `boolean` | `{
onShowSizeChange?: (pageSize: number) => void,
onChange?: (current: number) => void
}` | `false` |
diff --git a/s2-site/docs/manual/basic/analysis/strategy.en.md b/s2-site/docs/manual/advanced/analysis/strategy.en.md
similarity index 100%
rename from s2-site/docs/manual/basic/analysis/strategy.en.md
rename to s2-site/docs/manual/advanced/analysis/strategy.en.md
diff --git a/s2-site/docs/manual/basic/analysis/strategy.zh.md b/s2-site/docs/manual/advanced/analysis/strategy.zh.md
similarity index 73%
rename from s2-site/docs/manual/basic/analysis/strategy.zh.md
rename to s2-site/docs/manual/advanced/analysis/strategy.zh.md
index 691f4b4037..3ad7cff4f5 100644
--- a/s2-site/docs/manual/basic/analysis/strategy.zh.md
+++ b/s2-site/docs/manual/advanced/analysis/strategy.zh.md
@@ -3,19 +3,23 @@ title: 趋势分析表组件
order: 9
---
+@antv/s2-react
+
为了满足更多的分析场景,S2 提供开箱即用的场景表组件 —— 趋势分析表。借助它,你可以非常方便的实现单元格内展示多指标的场景表格。
+如图所示,该类表格的表形态特点在于可以在**同一个数据单元格**和**列头单元格内**展示多个指标数据,用于需要**关注时间趋势下的数据指标**,**查看同环比**等场景。行头可以 [自定义层级结构](/docs/manual/advanced/custom/custom-tree)。因此有此类分析需求时,可以直接使用该组件。
+
-如图所示,该类表格的表形态特点在于可以在**同一个数据单元格**和**列头单元格内**展示多个指标数据,用于需要**关注时间趋势下的数据指标**,**查看同环比**等场景。行头可以 [自定义层级结构](/zh/docs/manual/advanced/custom/custom-tree)。因此有此类分析需求时,可以直接使用该组件。
+:::warning{title="注意"}
-## 前提
+**趋势分析表组件**使用了 S2 提供的各种能力进行融合,所以建议在阅读本章前,请确保你已经阅读过以下章节:
-趋势分析表组件使用了 S2 提供的各种能力进行融合,所以建议在阅读本章前,请确保你已经阅读过以下章节:
+- [基本概念](/docs/manual/basic/base-concept)
+- [字段标记](/docs/manual/basic/conditions/)
+- [自定义行列头](/docs/manual/advanced/custom/custom-tree)
-- [基本概念](/zh/docs/manual/basic/base-concept)
-- [字段标记](/zh/docs/manual/basic/conditions/)
-- [自定义行列头](/zh/docs/manual/advanced/custom/custom-tree)
+:::
## 快速上手
@@ -87,13 +91,13 @@ const App = () => {
}
```
-
+
## 配置解释
### S2DataConfig 配置
-- 数据源:[MultiData](/zh/docs/api/general/S2DataConfig#multidata) 配置项,一个单元格对应多条数据,分为原始数据和格式化数据
+#### 1. 数据源:[MultiData](/zh/docs/api/general/S2DataConfig#multidata) 配置项,一个单元格对应多条数据,分为原始数据和格式化数据
```ts
const data = {
@@ -104,7 +108,7 @@ const data = {
}
```
-- 行头层级结构:[自定义层级结构](/zh/docs/manual/advanced/custom/custom-tree)
+#### 2. 行头层级结构:[自定义层级结构](/zh/docs/manual/advanced/custom/custom-tree)
```ts
const fields = {
@@ -118,7 +122,7 @@ const fields = {
}
```
-- 虚拟列:趋势分析表存在同环比指标时,会通过虚拟列来显示对应的同环比指标名称,此时,表格会显示两级列头
+#### 3. 虚拟列:趋势分析表存在同环比指标时,会通过虚拟列来显示对应的同环比指标名称,此时,表格会显示两级列头
```ts
import { EXTRA_COLUMN_FIELD } from '@antv/s2'
@@ -130,7 +134,9 @@ const fields = {
-虚拟例和普通字段一样,可以自定义格式化
+:::info{title="提示"}
+虚拟例和普通字段一样,可以 [自定义格式化](/manual/basic/formatter)
+:::
```ts
const s2DataConfig = {
@@ -153,44 +159,56 @@ const s2DataConfig = {
};
```
-**⚠️ 注意项:**
+:::warning{title="注意"}
- 如果不涉及到原始数据复制导出类需求,可不声明 `originalValues`
- 当只有单指标,(即没有同环比) 时,可不配置虚拟列 (`EXTRA_COLUMN_FIELD`)
- 列头指标顺序和单元格指标展示顺序一一对应
+:::
+
### S2Options 配置
-- 趋势分析表会将行头布局强制置为树状模式,即 `hierarchyType: 'tree'`
-- 可通过 `options.cornerText` 自定义角头文本
+:::info{title="提示"}
+
+- 趋势分析表会将行头布局强制置为**树状模式**,并且数值置于行头,即 `hierarchyType: 'tree'`.
+- 可通过 `s2Options.cornerText` 自定义角头文本。
- 染色逻辑配置可以在 `options.conditions` 中配置,不需要指定 `field` 参数,用法参考 [字段标记](/zh/docs/manual/basic/conditions) 目前暂时只支持文本颜色通道
+:::
+
## Tooltip
-趋势分析表的 `Tooltip`, 使用 `S2` 提供的 [自定义能力](/docs/manual/basic/tooltip#%E8%87%AA%E5%AE%9A%E4%B9%89-tooltip-%E5%86%85%E5%AE%B9) 分别对 `行头 (row)`, `列头 (col)`, `数值 (data)` 进行了 [定制](https://github.com/antvis/S2/blob/f35ff01400384cd2f3d84705e9daf75fc11b0149/packages/s2-react/src/components/sheets/strategy-sheet/index.tsx#L105), 同时可以在 `@antv/s2-react` 包中进行单独引入
+:::info{title="提示"}
+
+趋势分析表的 `Tooltip`, 使用 `S2` 提供的 [自定义能力](/docs/manual/basic/tooltip#%E8%87%AA%E5%AE%9A%E4%B9%89-tooltip-%E5%86%85%E5%AE%B9) 分别对 `行头 (rowCell)`, `列头 (colCell)`, `数值 (dataCell)` 进行了 [定制](https://github.com/antvis/S2/blob/f35ff01400384cd2f3d84705e9daf75fc11b0149/packages/s2-react/src/components/sheets/strategy-sheet/index.tsx#L105).
+
+:::
| 配置项名称 | 说明 | 类型 | 默认值 | 必选 |
| ------------- | ----------------- | --------- | ----- | --- |
| cell | 当前单元格 | `S2CellType` | ✓ |
| defaultTooltipShowOptions | 默认 tooltip 展示配置 | `TooltipShowOptions` | | |
-| label | 标题 | `ReactNode | (cell: S2CellType, defaultLabel: ReactNode) => ReactNode` | | |
+| label | 标题 | `ReactNode \| (cell: S2CellType, defaultLabel: ReactNode) => ReactNode` | | |
| showOriginalValue | 是否显示原始数值 (如有) | `boolean` | `false` | |
+也可以从 `@antv/s2-react` 包中引入单独使用,可以根据你自己的业务进行二次封装。
+
```tsx
import { StrategySheetRowTooltip, StrategySheetColTooltip, StrategySheetDataTooltip } from '@antv/s2-react'
const s2Options = {
tooltip: {
- content: (cell) =>
+ content: (cell) =>
}
}
```
-### 自定义标题
+### 1. 自定义标题
默认使用行头节点名字作为 Tooltip 标题,可通过 `label` 自定义内容的方式
@@ -204,7 +222,7 @@ const s2Options = {
-### 显示原始数据
+### 2. 显示原始数据
开启 `showOriginalValue` 后,会读取当前 Tooltip 对应的 `originalValues` 数据(如有), 将原始数据一同展示,即 `展示值(原始值)`
@@ -214,7 +232,7 @@ const s2Options = {
-### 渲染同环比额外节点
+### 3. 渲染同环比额外节点
可以通过 `renderDerivedValue` 在自定义同环比数值,比如替换成原始值
@@ -233,12 +251,12 @@ const s2Options = {
## 配置 mini 图
-在指标趋势分析场景下,通常我们希望看到数据的全局走势。走势分析不仅需要包含具体的涨跌,最好还能展示出固定时间段内的趋势图,或者指标的完成情况(进度),所以我们在表格里提供了 mini 图的绘制。为了减少对外部组件库的依赖,我们内置了一个十分轻量的,基于 `@antv/g` 绘制的 mini 图库,以极小的性能开销在单元格内绘制出子弹图、折线图及柱状图。
+在指标趋势分析场景下,通常我们希望看到数据的全局走势。走势分析不仅需要包含具体的涨跌,最好还能展示出固定时间段内的趋势图,或者指标的完成情况(进度),所以我们在表格里提供了 mini 图的绘制。为了减少对外部组件库的依赖,我们内置了一个十分轻量的,基于 `@antv/g` 绘制的 mini 图库,以极小的性能开销在单元格内绘制出`子弹图`、`折线图`以及`柱状图`, 具体请查看 [单元格内绘制图表](/manual/advanced/custom/custom-chart) 章节。
-
+
-配置如下:
+如果想要更换 mini 图样式配置,可以参考 [主题配置]('/api/general/s2theme#minicharttheme')
-
+### API
-如果想要更换 Mini 图样式配置,可以参考 [主题配置]('/zh/api/general/s2theme#minicharttheme')
+
diff --git a/s2-site/docs/manual/basic/analysis/switcher.en.md b/s2-site/docs/manual/advanced/analysis/switcher.en.md
similarity index 100%
rename from s2-site/docs/manual/basic/analysis/switcher.en.md
rename to s2-site/docs/manual/advanced/analysis/switcher.en.md
diff --git a/s2-site/docs/manual/basic/analysis/switcher.zh.md b/s2-site/docs/manual/advanced/analysis/switcher.zh.md
similarity index 70%
rename from s2-site/docs/manual/basic/analysis/switcher.zh.md
rename to s2-site/docs/manual/advanced/analysis/switcher.zh.md
index aeb3bf3172..1bf6f1f477 100644
--- a/s2-site/docs/manual/basic/analysis/switcher.zh.md
+++ b/s2-site/docs/manual/advanced/analysis/switcher.zh.md
@@ -3,7 +3,9 @@ title: 维度切换组件
order: 10
---
-S2 提供开箱即用的维度切换组件 `Switcher` 。借助它,你可以非常方便的实现交互式行列切换,以及维度隐藏的功能。
+@antv/s2-react
+
+S2 提供开箱即用的维度切换组件 ``, 借助它,你可以非常方便的实现交互式行列切换,以及维度隐藏的功能。
@@ -46,17 +48,20 @@ const App = () => {
}
```
-
+
## 配置解释
### 维度配置
-Switcher 可接收三种类型的维度配置,分别是 `rows`,`columns` 和 `values`。它们的类型皆为 [SwitcherField](/docs/api/components/switcher#switcherfield)。
+:::info{title="提示"}
+Switcher 可接收三种类型的维度配置,分别是 `rows`,`columns` 和 `values`, 它们的类型皆为 [SwitcherField](/docs/api/components/switcher#switcherfield)。
+
+其中 `rows` 和 `columns` 两个维度可以相互拖拽到彼此的配置框中,而 `values` 只能在自己的配置框中更改字段顺序。
-> 其中 `rows` 和 `columns` 两个维度可以相互拖拽到彼此的配置框中,而 `values` 只能在自己的配置框中更改字段顺序。
+:::
-通过传入`sheetType`以及维度配置,Switcher 的展示形态也会有所不同:
+通过传入 `sheetType` 以及维度配置,`Switcher` 的展示形态也会有所不同:
@@ -66,7 +71,7 @@ Switcher 可接收三种类型的维度配置,分别是 `rows`,`columns` 和
- 一种维度(主要用于明细表)
+ 一种维度(主要用于明细表)
|
三种维度(主要用于透视表)
@@ -74,15 +79,17 @@ Switcher 可接收三种类型的维度配置,分别是 `rows`,`columns` 和
|
-
+
|
-
+
|
+#### 可选中
+
* 每个维度默认只能进行**拖拽排序**, 如果你希望能控制其字段的**显隐**,可以设置 `selectable: true`, 该属性用于开启字段的 `checkbox` :
```js
@@ -94,6 +101,8 @@ const field = {
};
```
+#### 展开子项
+
* 如果维度中的每一个字段项还存在关联子项,可以设置 `expandable:true`, 该属性用于控制子项是否被展开,也可以进一步设置 `expandText` 定制展开 `checkbox` 的提示文字:
```js
@@ -106,6 +115,8 @@ const field = {
};
```
+#### 允许为空
+
* 如果当前维度在移动交互中需要至少保留一个子项不能被拖拽出去,可以设置 `allowEmpty:false`, 该属性用于控制维度是否可以将全部子项拖出到其他维度:
```js
@@ -121,15 +132,17 @@ const field = {
### 提交修改
- `Switcher` 组件在弹窗关闭后会触发 `onSubmit` 回调,且此回调会接收一个 [SwitcherResult](/docs/api/components/switcher#switcherresult) 类型的参数,你可以通过该回调拿到修改后的结果。
+`Switcher` 组件在弹窗关闭后会触发 `onSubmit` 回调,且此回调会接收一个 [SwitcherResult](/docs/api/components/switcher#switcherresult) 类型的参数,你可以通过该回调拿到修改后的结果。
-所有结果会**按维度**分组,并且每一组字段会**扁平化后**按按顺序排序。
+所有结果会**按维度**分组,并且每一组字段会**扁平化后**按按顺序排序,你可以通过以下示例查看详细的结果数据类型。
-你可以通过以下示例查看详细的结果数据类型:
+
-
+:::warning{title="注意"}
-❗️注意:出于减少内部状态过时的考虑,`Switcher` 组件内部并**不会持久化操作后状态**。也就是说在每次弹窗关闭后,Switcher 内部状态会清空,再次打开时任然以 `Props` 中的各个维度配置为准。
+出于减少内部状态过时的考虑,`Switcher` 组件内部**并不会持久化操作后状态**。也就是说在每次弹窗关闭后,`Switcher` 内部状态会清空,再次打开时还是以组件 `props` 中的各个维度配置为准。
+
+:::
### 定制化
@@ -150,16 +163,24 @@ const field = {
### 结合透视表使用
+:::info{title="提示"}
+
* 行列值可以相互移动
* 指标值可以控制显隐
+:::
+
### 结合明细表使用
+:::info{title="提示"}
+
* 列头可以控制显隐
* 表格列头对应出现展开图标
+:::
+
📊 查看更多 [维度切换示例](/examples/react-component/switcher#pure-switcher)。
diff --git a/s2-site/docs/manual/basic/analysis/vue.en.md b/s2-site/docs/manual/advanced/analysis/vue.en.md
similarity index 100%
rename from s2-site/docs/manual/basic/analysis/vue.en.md
rename to s2-site/docs/manual/advanced/analysis/vue.en.md
diff --git a/s2-site/docs/manual/basic/analysis/vue.zh.md b/s2-site/docs/manual/advanced/analysis/vue.zh.md
similarity index 98%
rename from s2-site/docs/manual/basic/analysis/vue.zh.md
rename to s2-site/docs/manual/advanced/analysis/vue.zh.md
index 9d2b97915b..4a1bb31a9d 100644
--- a/s2-site/docs/manual/basic/analysis/vue.zh.md
+++ b/s2-site/docs/manual/advanced/analysis/vue.zh.md
@@ -3,6 +3,8 @@ title: Vue 3.0 组件
order: 13
---
+@antv/s2-vue
+
## 基础表组件
### 透视表
diff --git a/s2-site/docs/manual/advanced/custom/cell-size.zh.md b/s2-site/docs/manual/advanced/custom/cell-size.zh.md
index 4e9fd6dbe1..b87326f916 100644
--- a/s2-site/docs/manual/advanced/custom/cell-size.zh.md
+++ b/s2-site/docs/manual/advanced/custom/cell-size.zh.md
@@ -53,7 +53,9 @@ const s2Options = {
## 调整行头单元格宽高
+:::warning{title="注意"}
行头单元格高度调整**作用于叶子节点** (非叶子节点的高度是所有子节点高度度总和), 且高度始终和 **数值单元格** 高度一致。
+:::
```ts
const s2Options = {
@@ -85,17 +87,17 @@ const s2Options = {
}
```
-
-
-
+:::info{title="提示"}
如果想给特定某一行/列设置不同的宽高,可以通过 `rowCell` 的 `widthByField` 和 `heightByField` 预设高度来实现,支持两种类型的配置:
- **fieldId** (例:`root[&]浙江省[&]杭州市`): 行列交叉后每一个行头节点对应的唯一 ID, 适用于宽高精确到具体的单元格 [(如何获取 ID)](/docs/manual/advanced/get-cell-data#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E5%8C%BA%E5%9F%9F%E5%8D%95%E5%85%83%E6%A0%BC)
- **field** (例:`city`): 对应 `s2DataConfig.fields.rows` 中配置的 `field`, 适用于精确到某一类维值的单元格
+:::
+
```ts
@@ -114,13 +116,13 @@ const s2Options = {
}
```
-
-
-
+:::info{title="提示"}
+
+明细表有一点特殊,由于只有列头,如果想给**特定行**设置不同的高度,则可以根据行序号调整
-明细表有一点特殊,由于只有列头,如果想给特定行设置不同的高度,则可以根据行序号调整
+:::
```ts
const s2Options = {
@@ -157,7 +159,9 @@ const s2Options = {
## 调整列头单元格宽高
+:::warning{title="注意"}
列头单元格宽度调整**作用于叶子节点** (非叶子节点的宽度是所有子节点宽度总和), 且**宽度**始终和 **数值单元格** 宽度一致
+:::
```ts
const s2Options = {
@@ -195,11 +199,15 @@ const s2Options = {
}
```
+:::info{title="提示"}
+
如果想给特定某一列设置不同的宽高,可以通过 `colCell` 的 `widthByField` 和 `heightByField` 预设宽高来实现,支持两种类型的配置:
- **fieldId** (例:`root[&]家具[&]沙发[&]number`): 行列交叉后每一个列头节点对应的唯一 ID, 适用于宽高精确到具体的单元格 [(如何获取 ID)](/docs/manual/advanced/get-cell-data#%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E5%8C%BA%E5%9F%9F%E5%8D%95%E5%85%83%E6%A0%BC)
- **field** (例:`city`): 对应 `s2DataConfig.fields.columns` 中配置的 `field`, 适用于精确到某一类维值的单元格
+:::
+
```ts
import { EXTRA_FIELD } from '@antv/s2'
@@ -219,12 +227,8 @@ const s2Options = {
}
```
-
-
-
-
## 隐藏列头
还可以将高度设置为 `0`, 从而实现**隐藏列头**的效果,[查看例子](/examples/layout/custom#hide-columns)
@@ -239,8 +243,6 @@ const s2Options = {
}
```
-
-
## API 文档
diff --git a/s2-site/docs/manual/advanced/custom/custom-chart.zh.md b/s2-site/docs/manual/advanced/custom/custom-chart.zh.md
index bd03132c42..83bd5779eb 100644
--- a/s2-site/docs/manual/advanced/custom/custom-chart.zh.md
+++ b/s2-site/docs/manual/advanced/custom/custom-chart.zh.md
@@ -172,13 +172,14 @@ const s2DataConfig = {
import { DataCell, drawObjectText } from '@antv/s2';
class CustomDataCell extends DataCell {
- // 当数值为对象时,完全接管绘制,使用内置的 `drawObjectText` 根据不同的数据结构 (见下方) 绘制不同的图形
drawTextShape() {
+ // 当数值为对象时,完全接管绘制,使用内置的 `drawObjectText` 根据不同的数据结构 (见下方) 绘制不同的图形
if (this.isMultiData()) {
drawObjectText(this);
return;
}
+ // 如果是普通文本,则走默认的文本绘制逻辑
super.drawTextShape();
}
}
@@ -202,7 +203,7 @@ S2 内置了一些基于 [`AntV/G`](https://g.antv.antgroup.com/) 简单的图
- `bar`: 柱状图
- `bullet`: 子弹图
-```ts
+```json
{
number: {
values: {
@@ -215,7 +216,7 @@ S2 内置了一些基于 [`AntV/G`](https://g.antv.antgroup.com/) 简单的图
- `多列文本`
-```ts
+```json
{
number: {
values: [
diff --git a/s2-site/docs/manual/advanced/custom/hook.zh.md b/s2-site/docs/manual/advanced/custom/hook.zh.md
index a395b2e60c..1dcb0be07c 100644
--- a/s2-site/docs/manual/advanced/custom/hook.zh.md
+++ b/s2-site/docs/manual/advanced/custom/hook.zh.md
@@ -31,19 +31,23 @@ order: 1
## dataCell
-改变数据单元格的默认实现,需要继承自 [dataCell](https://github.com/antvis/S2/blob/master/packages/s2-core/src/cell/data-cell.ts),覆盖某些方法,比如字体样式、背景样式等。[例子](/examples/custom/custom-cell#data-cell)
+改变数据单元格的默认实现,需要继承自 [dataCell](https://github.com/antvis/S2/blob/next/packages/s2-core/src/cell/data-cell.ts),覆盖某些方法,比如字体样式、背景样式等。[例子](/examples/custom/custom-cell#data-cell)
## rowCell
-改变行头单元格的默认实现,需要继承自 [rowCell](https://github.com/antvis/S2/blob/master/packages/s2-core/src/cell/row-cell.ts),覆盖某些方法,比如字体样式、背景样式等。[例子](/examples/custom/custom-cell#row-cell)
+改变行头单元格的默认实现,需要继承自 [rowCell](https://github.com/antvis/S2/blob/next/packages/s2-core/src/cell/row-cell.ts),覆盖某些方法,比如字体样式、背景样式等。[例子](/examples/custom/custom-cell#row-cell)
## colCell
-改变列头单元格的默认实现,需要继承自 [colCell](https://github.com/antvis/S2/blob/master/packages/s2-core/src/cell/col-cell.ts),覆盖某些方法,比如字体样式、背景样式等。[例子](/examples/custom/custom-cell#col-cell)
+改变列头单元格的默认实现,需要继承自 [colCell](https://github.com/antvis/S2/blob/next/packages/s2-core/src/cell/col-cell.ts),覆盖某些方法,比如字体样式、背景样式等。[例子](/examples/custom/custom-cell#col-cell)
## cornerCell
-改变角头单元格的默认实现,需要继承自 [cornerCell](https://github.com/antvis/S2/blob/master/packages/s2-core/src/cell/corner-cell.ts),覆盖某些方法,比如字体样式、背景样式等。[例子](/examples/custom/custom-cell#corner-cell)
+改变角头单元格的默认实现,需要继承自 [cornerCell](https://github.com/antvis/S2/blob/next/packages/s2-core/src/cell/corner-cell.ts),覆盖某些方法,比如字体样式、背景样式等。[例子](/examples/custom/custom-cell#corner-cell)
+
+## seriesNumberCell
+
+改变序号单元格的默认实现,需要继承自 [seriesNumberCell](https://github.com/antvis/S2/blob/next/packages/s2-core/src/cell/series-number-cell.ts),覆盖某些方法,比如字体样式、背景样式等。[例子](/examples/custom/custom-cell#series-number-cell)
## cornerHeader
diff --git a/s2-site/docs/manual/advanced/hd-adapter.zh.md b/s2-site/docs/manual/advanced/hd-adapter.zh.md
index b511244c69..dee765b384 100644
--- a/s2-site/docs/manual/advanced/hd-adapter.zh.md
+++ b/s2-site/docs/manual/advanced/hd-adapter.zh.md
@@ -100,7 +100,7 @@ const renderByZoomScale = debounce((e) => {
## 自定义设备像素比
-表格默认使用设备当前像素比渲染,也就是 `window.devicePixelRatio`, 如果你觉得初始渲染就很模糊,可以手动指定表格按照 2 倍设备像素比来渲染
+表格默认使用设备当前像素比渲染,也就是 `window.devicePixelRatio`, 如果你觉得初始渲染就很模糊,可以手动指定表格按照 2 倍设备像素比来渲染,通过 `transformCanvasConfig` 透传给底层的 [G 绘制引擎](/manual/advanced/g-plugins)
```ts
const s2Options = {
diff --git a/s2-site/docs/manual/advanced/interaction/basic.zh.md b/s2-site/docs/manual/advanced/interaction/basic.zh.md
index 8ab17de892..583e30cb9b 100644
--- a/s2-site/docs/manual/advanced/interaction/basic.zh.md
+++ b/s2-site/docs/manual/advanced/interaction/basic.zh.md
@@ -423,6 +423,10 @@ const s2Options = {
查看 [详情](/docs/manual/advanced/interaction/scroll)
+### 复制
+
+查看 [详情](/docs/manual/advanced/interaction/copy)
+
### 重置交互
diff --git a/s2-site/docs/manual/advanced/interaction/copy.en.md b/s2-site/docs/manual/advanced/interaction/copy.en.md
new file mode 100644
index 0000000000..0af7b708f2
--- /dev/null
+++ b/s2-site/docs/manual/advanced/interaction/copy.en.md
@@ -0,0 +1,4 @@
+---
+title: Copy
+order: 7
+---
diff --git a/s2-site/docs/manual/advanced/interaction/copy.zh.md b/s2-site/docs/manual/advanced/interaction/copy.zh.md
new file mode 100644
index 0000000000..735679a466
--- /dev/null
+++ b/s2-site/docs/manual/advanced/interaction/copy.zh.md
@@ -0,0 +1,6 @@
+---
+title: 复制
+order: 7
+---
+
+
diff --git a/s2-site/docs/manual/advanced/interaction/scroll.zh.md b/s2-site/docs/manual/advanced/interaction/scroll.zh.md
index 7719544a92..10e0210ca9 100644
--- a/s2-site/docs/manual/advanced/interaction/scroll.zh.md
+++ b/s2-site/docs/manual/advanced/interaction/scroll.zh.md
@@ -3,7 +3,7 @@ title: 滚动
order: 6
---
-#### 虚拟滚动
+## 虚拟滚动
S2 基于 `Canvas` 渲染,也实现了虚拟滚动,即只渲染可视区域内的单元格,默认开启。[查看更多](https://www.yuque.com/antv/vo4vyz/srtq5q#mI1n7)
@@ -11,7 +11,7 @@ S2 基于 `Canvas` 渲染,也实现了虚拟滚动,即只渲染可视区域
-#### 自定义滚动速度
+## 自定义滚动速度
可配置 `scrollSpeedRatio` 控制滚动速率,分为 `水平` 和 `垂直` 两个方向,范围为 `0-1`, 默认为 `1`。 [查看具体例子](/examples/interaction/advanced#scroll-speed-ratio)
@@ -26,11 +26,11 @@ const s2Options = {
};
```
-#### 鼠标滚轮水平滚动
+## 鼠标滚轮水平滚动
滑动滚轮垂直滚动,如果同时按住 `Shift` 即可水平滚动
-#### 修改滚动至边界行为
+## 修改滚动至边界行为
对于自身和父容器都存在滚动条时,浏览器默认的滚动行为是:非边界不触发父容器滚动,到达边界后,触发父容器滚动,同时还可以配置 [overscroll-behavior](https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior) 改变默认行为。
@@ -40,7 +40,7 @@ S2 是虚拟滚动,但是也**模拟**了浏览器的滚动行为,可配置
const s2Options = {
interaction: {
overscrollBehavior: 'auto' // 'auto' | 'none' | 'contain';
- overscrollBehavior: null // 设为 null 则不做任何处理
+ // overscrollBehavior: null // 设为 null 则不做任何处理
},
};
```
@@ -65,7 +65,7 @@ const s2Options = {
-#### 监听滚动事件
+## 监听滚动事件
对于 `透视表`, 可滚动的区域分别是 `行头单元格` 和 `数值单元格`, 对于 `明细表`, 可滚动的区域只有 `数值单元格`, 可分别监听,也可以统一监听
@@ -92,9 +92,15 @@ s2.on(S2Event.ROW_CELL_SCROLL, (position) => {
})
```
-#### 手动触发表格滚动
+## 获取滚动状态
+
+查看相关 [API](/api/basic-class/base-facet)
+
+## 手动触发表格滚动
参考以下例子:
- [滚动至指定单元格](/examples/interaction/advanced/#scroll-to-cell)
- [循环滚动](/examples/interaction/advanced#scroll-loop)
+
+
diff --git a/s2-site/docs/manual/basic/analysis/copy-export.zh.md b/s2-site/docs/manual/basic/analysis/copy-export.zh.md
deleted file mode 100644
index 89baf8636a..0000000000
--- a/s2-site/docs/manual/basic/analysis/copy-export.zh.md
+++ /dev/null
@@ -1,101 +0,0 @@
----
-title: 复制和导出
-order: 11
----
-
-## 简介
-
-复制与导出的内容都可以直接放入 Excel 中进行展示,S2 已经完成了格式上的兼容。
-
-### 复制
-
-此功能可快速将表格内容复制到剪切板
-`@antv/s2` 核心层提供了基础的复制功能,可配置 `enableCopy` 开启
-
-#### 全量复制
-
-S2 的导出组件,分别提供了原始数据的复制和格式化后数据的复制。
-
-- 原始数据全量复制
-
-
-
-- 格式化数据全量复制
-
-
-
-#### 局部复制
-
-使用快捷键 `Command/Ctrl + C` 即可复制选中区域(局部复制)
-
-```ts
-const s2Options = {
- interaction: {
- // 是否开启复制
- enableCopy: true,
- // 圈选复制前,需要开启圈选功能
- brushSelection: {
- dataCell: true, // 默认开启
- rowCell: true,
- colCell: true,
- }
- }
-};
-```
-
-- 复制到 Excel
-
-
-
-- 复制带 HTML 格式
-
-
-
-- 复制行头内容
-
-
-
-- 复制列头内容
-
-
-
-- 带表头复制
-**copyWithHeader**: 复制数据是否带表头信息,默认为 `false`
-
-```ts
-const s2Options = {
- interaction: {
- enableCopy: true,
- copyWithHeader: true,
- }
-};
-```
-
-
-
-### 导出
-
-`@antv/s2-react` 组件层提供了导出功能
-
-```tsx
-import { SheetComponent } from '@antv/s2-react'
-
-
-```
-
-点击复制或下载按钮,导出全量数据(全量复制)
-
-
-
-
diff --git a/s2-site/docs/manual/basic/analysis/editable-mode.zh.md b/s2-site/docs/manual/basic/analysis/editable-mode.zh.md
deleted file mode 100644
index 2477f08333..0000000000
--- a/s2-site/docs/manual/basic/analysis/editable-mode.zh.md
+++ /dev/null
@@ -1,176 +0,0 @@
----
-title: 编辑表
-order: 3
----
-
-## 明细表简介
-
-编辑表是 `S2` 明细表的衍生形态之一。在提供完整的明细表的分析功能之外,还支持对数据的修改操作。
-
-
-
-## 使用
-
-```html
-
-```
-
-### React 组件方式
-
-```typescript
-import React from "react";
-import { SheetComponent } from '@antv/s2-react';
-import '@antv/s2-react/dist/style.min.css';
-
-// 1. 准备数据
-const data = [
- {
- "province": "浙江",
- "city": "杭州",
- "type": "笔",
- "price": 1
- },
- {
- "province": "浙江",
- "city": "杭州",
- "type": "纸张",
- "price": 2
- },
- {
- "province": "浙江",
- "city": "舟山",
- "type": "笔",
- "price": 17
- },
- {
- "province": "浙江",
- "city": "舟山",
- "type": "纸张",
- "price": 6
- },
- {
- "province": "吉林",
- "city": "长春",
- "type": "笔",
- "price": 8
- },
- {
- "province": "吉林",
- "city": "白山",
- "type": "笔",
- "price": 12
- },
- {
- "province": "吉林",
- "city": "长春",
- "type": "纸张",
- "price": 3
- },
- {
- "province": "吉林",
- "city": "白山",
- "type": "纸张",
- "price": 25
- },
-
- {
- "province": "浙江",
- "city": "杭州",
- "type": "笔",
- "price": 20
- },
- {
- "province": "浙江",
- "city": "杭州",
- "type": "纸张",
- "price": 10
- },
- {
- "province": "浙江",
- "city": "舟山",
- "type": "笔",
- "price": 15
- },
- {
- "province": "浙江",
- "city": "舟山",
- "type": "纸张",
- "price": 2
- },
- {
- "province": "吉林",
- "city": "长春",
- "type": "笔",
- "price": 15
- },
- {
- "province": "吉林",
- "city": "白山",
- "type": "笔",
- "price": 30
- },
- {
- "province": "吉林",
- "city": "长春",
- "type": "纸张",
- "price": 40
- },
- {
- "province": "吉林",
- "city": "白山",
- "type": "纸张",
- "price": 50
- }
-];
-
-// 2. 配置数据
-const s2DataCfg = {
- fields: {
- columns: ["province", "city", "type", "price"], // 要展示的列头字段 id 列表
- },
- meta: [
- // 列头字段对应的元信息,比如展示的中文名
- {
- field: "province",
- name: "省份",
- },
- {
- field: "city",
- name: "城市",
- },
- {
- field: "type",
- name: "类型",
- },
- {
- field: "price",
- name: "价格",
- },
- ],
- data,
-};
-
-// 3. 添加配置
-const s2Options = {
- width: 400,
- height: 200,
-};
-
-// 4, 渲染
-const App = () => {
- return (
- ,
- )
-}
-```
-
-## 特性
-
-效果如图:
-
-
-[playground 地址](/examples/react-component/sheet#editable)
diff --git a/s2-site/docs/manual/basic/analysis/pagination.zh.md b/s2-site/docs/manual/basic/analysis/pagination.zh.md
deleted file mode 100644
index 091f487aac..0000000000
--- a/s2-site/docs/manual/basic/analysis/pagination.zh.md
+++ /dev/null
@@ -1,64 +0,0 @@
----
-title: 分页
-order: 11
----
-
-## 简介
-
-S2 内置提供了分页能力。本质上是前端分页,点击下一页滚动到对应行。
-
-### 快速上手
-
-首先需要在 `s2Options` 中配置 `pagination` 属性
-
-
-
-
-
-如果基于 `@antv/s2-core` 开发,需要**自行引入**或**实现分页组件**,`core` 层仅提供分页能力,参考示例
-
-* [React](https://github.com/antvis/S2/blob/master/packages/s2-react/src/components/pagination/index.tsx)
-* [Vue 3.0](https://github.com/antvis/S2/blob/master/packages/s2-vue/src/components/pagination/index.vue)
-
-如果基于 `@antv/s2-react` 或 `@antv/s2-vue` 开发,则只需配置分页相关配置项即可开箱即用。
-
-### SpreadsheetProps
-
-```tsx
-
-```
-
-| 参数 | 说明 | 类型 | 默认值 | 必选 |
-|-----|-----|-----|-----|-----|
-| showPagination | 是否显示默认分页
(只有在 `options` 配置过 `pagination` 属性才会生效) | `boolean` | `{
onShowSizeChange?: (pageSize: number) => void,
onChange?: (current: number) => void
}` | `false` |
-
-### React 版
-
-> 使用的是 [Ant Design](https://ant.design/components/pagination-cn/) Pagination 分页组件,支持 [透传 API](https://ant.design/components/pagination-cn/#API)。需要修改样式直接通过 CSS 覆盖即可。
-
-```tsx
-const s2Options = {
- // https://ant.design/components/pagination-cn/#API
- pagination: {}
-}
-
-
-```
-
-
-
-### Vue 3.0 版
-
-> 使用的是 [Ant Design Vue](https://antdv.com/components/pagination) 分页组件,支持 [透传 API](https://antdv.com/components/pagination#API)。需要修改样式直接通过 CSS 覆盖即可。
-
-```tsx
-const s2Options = {
- // https://antdv.com/components/pagination#API
- pagination: {}
-}
-
-
-
-```
-
-[Demo 地址](https://codesandbox.io/embed/nice-dijkstra-hzycy6?fontsize=14&hidenavigation=1&theme=dark)
diff --git a/s2-site/examples/interaction/advanced/demo/table-link-jump.ts b/s2-site/examples/interaction/advanced/demo/table-link-jump.ts
index ed9ac8a08d..48e3d04bc7 100644
--- a/s2-site/examples/interaction/advanced/demo/table-link-jump.ts
+++ b/s2-site/examples/interaction/advanced/demo/table-link-jump.ts
@@ -1,4 +1,4 @@
-import { S2DataConfig, S2DataConfig, S2Event, TableSheet } from '@antv/s2';
+import { S2DataConfig, S2Event, TableSheet } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic-table-mode.json')
.then((res) => res.json())
From 1b185213d47d59278cdbca27f4221cd7d056e8b9 Mon Sep 17 00:00:00 2001
From: lijinke666
Date: Wed, 27 Dec 2023 16:56:39 +0800
Subject: [PATCH 07/64] =?UTF-8?q?docs:=20=E5=A2=9E=E5=8A=A0=E6=9A=97?=
=?UTF-8?q?=E9=BB=91=E4=B8=BB=E9=A2=98=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.en-US.md | 2 +-
README.md | 2 +-
packages/s2-core/README.en-US.md | 2 +-
packages/s2-core/README.md | 2 +-
packages/s2-core/src/theme/index.ts | 1 -
s2-site/docs/api/basic-class/base-cell.zh.md | 2 +-
.../docs/api/basic-class/base-data-set.zh.md | 2 +-
s2-site/docs/api/basic-class/base-facet.zh.md | 2 +-
.../docs/api/basic-class/base-tooltip.zh.md | 2 +-
.../docs/api/basic-class/interaction.zh.md | 2 +-
s2-site/docs/api/basic-class/node.zh.md | 2 +-
.../docs/api/basic-class/spreadsheet.zh.md | 4 +-
s2-site/docs/api/basic-class/store.zh.md | 2 +-
s2-site/docs/api/general/S2Event.zh.md | 2 +-
s2-site/docs/manual/advanced/adaptive.zh.md | 17 ++-
s2-site/docs/manual/advanced/g-plugins.zh.md | 2 +-
.../docs/manual/advanced/get-cell-data.zh.md | 119 +++++++++++++++---
.../docs/manual/advanced/get-instance.zh.md | 22 ++--
s2-site/docs/manual/advanced/hd-adapter.zh.md | 2 +-
.../manual/advanced/interaction/custom.zh.md | 2 +-
s2-site/docs/manual/basic/theme.zh.md | 89 +++++++++----
s2-site/docs/manual/basic/tooltip.zh.md | 6 +-
s2-site/docs/manual/introduction.zh.md | 2 +-
.../custom/custom-cell/demo/col-cell.ts | 2 +-
.../custom/custom-cell/demo/corner-cell.ts | 2 +-
.../custom/custom-cell/demo/corner-header.ts | 2 +-
.../custom-cell/demo/custom-merged-cell.ts | 2 +-
.../custom-cell/demo/custom-specified-cell.ts | 4 +-
.../custom/custom-cell/demo/data-cell.ts | 2 +-
.../custom/custom-cell/demo/row-cell.ts | 2 +-
.../custom-cell/demo/series-number-cell.ts | 2 +-
.../custom/custom-cell/demo/totals-cell.ts | 2 +-
s2-site/examples/theme/default/demo/dark.ts | 50 ++++++++
s2-site/examples/theme/default/demo/meta.json | 8 ++
34 files changed, 283 insertions(+), 85 deletions(-)
create mode 100644 s2-site/examples/theme/default/demo/dark.ts
diff --git a/README.en-US.md b/README.en-US.md
index 77fdab42e2..50ec5e8cfd 100644
--- a/README.en-US.md
+++ b/README.en-US.md
@@ -38,7 +38,7 @@ A practical visualization library for tabular analysis.
-
+
diff --git a/README.md b/README.md
index f7ac555fa2..edb6f94818 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@
-
+
diff --git a/packages/s2-core/README.en-US.md b/packages/s2-core/README.en-US.md
index 7cf5dc406f..99d1673d6d 100644
--- a/packages/s2-core/README.en-US.md
+++ b/packages/s2-core/README.en-US.md
@@ -38,7 +38,7 @@ Data-driven multi-dimensional analysis table.
-
+
diff --git a/packages/s2-core/README.md b/packages/s2-core/README.md
index f954dc3827..b10c607f05 100644
--- a/packages/s2-core/README.md
+++ b/packages/s2-core/README.md
@@ -37,7 +37,7 @@
-
+
diff --git a/packages/s2-core/src/theme/index.ts b/packages/s2-core/src/theme/index.ts
index 31ded99ace..97548286d6 100644
--- a/packages/s2-core/src/theme/index.ts
+++ b/packages/s2-core/src/theme/index.ts
@@ -361,7 +361,6 @@ export const getTheme = (
textAlign: 'right',
textBaseline: 'middle',
...getHeaderCellTextOverflow(),
- // maxLines: 1,
},
bolderText: {
fontFamily: FONT_FAMILY,
diff --git a/s2-site/docs/api/basic-class/base-cell.zh.md b/s2-site/docs/api/basic-class/base-cell.zh.md
index 40519cc036..a87760e391 100644
--- a/s2-site/docs/api/basic-class/base-cell.zh.md
+++ b/s2-site/docs/api/basic-class/base-cell.zh.md
@@ -3,7 +3,7 @@ title: BaseCell
order: 4
---
-功能描述:单元格基类。[详情](https://github.com/antvis/S2/blob/master/packages/s2-core/src/cell/base-cell.ts)
+功能描述:单元格基类。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/cell/base-cell.ts)
```ts
cell.getActualText()
diff --git a/s2-site/docs/api/basic-class/base-data-set.zh.md b/s2-site/docs/api/basic-class/base-data-set.zh.md
index add7e3c3c0..29ce91fdf0 100644
--- a/s2-site/docs/api/basic-class/base-data-set.zh.md
+++ b/s2-site/docs/api/basic-class/base-data-set.zh.md
@@ -3,7 +3,7 @@ title: BaseDataSet
order: 5
---
-功能描述:表格数据集。[详情](https://github.com/antvis/S2/blob/master/packages/s2-core/src/data-set/pivot-data-set.ts)
+功能描述:表格数据集。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/data-set/pivot-data-set.ts)
```ts
s2.dataSet.getFieldName('type')
diff --git a/s2-site/docs/api/basic-class/base-facet.zh.md b/s2-site/docs/api/basic-class/base-facet.zh.md
index 2e615f46b7..1a6ac8ce68 100644
--- a/s2-site/docs/api/basic-class/base-facet.zh.md
+++ b/s2-site/docs/api/basic-class/base-facet.zh.md
@@ -3,7 +3,7 @@ title: BaseFacet
order: 7
---
-功能描述:当前可视渲染区域。[详情](https://github.com/antvis/S2/blob/master/packages/s2-core/src/facet/base-facet.ts)
+功能描述:当前可视渲染区域。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/facet/base-facet.ts)
```ts
s2.facet.getRealWidth()
diff --git a/s2-site/docs/api/basic-class/base-tooltip.zh.md b/s2-site/docs/api/basic-class/base-tooltip.zh.md
index 76cf0aa14c..9d67b67386 100644
--- a/s2-site/docs/api/basic-class/base-tooltip.zh.md
+++ b/s2-site/docs/api/basic-class/base-tooltip.zh.md
@@ -3,7 +3,7 @@ title: BaseTooltip
order: 6
---
-功能描述:Tooltip 类。[详情](https://github.com/antvis/S2/blob/master/packages/s2-core/src/ui/tooltip/index.ts)
+功能描述:Tooltip 类。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/ui/tooltip/index.ts)
```ts
s2.tooltip.show({
diff --git a/s2-site/docs/api/basic-class/interaction.zh.md b/s2-site/docs/api/basic-class/interaction.zh.md
index 3baa321bff..f886da85fd 100644
--- a/s2-site/docs/api/basic-class/interaction.zh.md
+++ b/s2-site/docs/api/basic-class/interaction.zh.md
@@ -3,7 +3,7 @@ title: Interaction
order: 2
---
-功能描述:交互类相关属性和方法。[详情](https://github.com/antvis/S2/blob/master/packages/s2-core/src/interaction/root.ts)
+功能描述:交互类相关属性和方法。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/interaction/root.ts)
```ts
s2.interaction.reset()
diff --git a/s2-site/docs/api/basic-class/node.zh.md b/s2-site/docs/api/basic-class/node.zh.md
index c3fe56df81..c254000dbc 100644
--- a/s2-site/docs/api/basic-class/node.zh.md
+++ b/s2-site/docs/api/basic-class/node.zh.md
@@ -3,7 +3,7 @@ title: Node
order: 5
---
-功能描述:布局节点。[详情](https://github.com/antvis/S2/blob/master/packages/s2-core/src/facet/layout/node.ts)
+功能描述:布局节点。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/facet/layout/node.ts)
```ts
node.isTotals // false
diff --git a/s2-site/docs/api/basic-class/spreadsheet.zh.md b/s2-site/docs/api/basic-class/spreadsheet.zh.md
index b5e6bbfc7b..bbfa9a86cc 100644
--- a/s2-site/docs/api/basic-class/spreadsheet.zh.md
+++ b/s2-site/docs/api/basic-class/spreadsheet.zh.md
@@ -3,7 +3,7 @@ title: SpreadSheet
order: 1
---
-功能描述:表格实例相关属性和方法。[详情](https://github.com/antvis/S2/blob/master/packages/s2-core/src/sheet-type/spread-sheet.ts)
+功能描述:表格实例相关属性和方法。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/sheet-type/spread-sheet.ts)
```ts
const s2 = new PivotSheet()
@@ -23,7 +23,7 @@ s2.isPivotMode()
| tooltip | tooltip | [BaseTooltip](/docs/api/basic-class/base-tooltip) | |
| container | g-canvas 实例 | [Canvas](https://g.antv.vision/zh/docs/api/canvas) | |
| interaction | 交互 | [Interaction](/zh/docs/api/basic-class/interaction) | |
-| hdAdapter | 高清适配 | [HdAdapter](https://github.com/antvis/S2/blob/master/packages/s2-core/src/ui/hd-adapter/index.ts) | |
+| hdAdapter | 高清适配 | [HdAdapter](https://github.com/antvis/S2/blob/next/packages/s2-core/src/ui/hd-adapter/index.ts) | |
| on | 事件订阅 | (event: [S2Event](/docs/manual/advanced/interaction/basic), listener: () => void) => void | |
| emit | 事件发布 | (event: [S2Event](/docs/manual/advanced/interaction/basic), ...args: any[]) => void | |
| getDataSet | 获取数据集 | (options: [S2Options](/docs/api/general/S2Options)) => [BaseDataSet](/docs/api/basic-class/base-data-set) | |
diff --git a/s2-site/docs/api/basic-class/store.zh.md b/s2-site/docs/api/basic-class/store.zh.md
index fe5ccf2c0b..77b0581e18 100644
--- a/s2-site/docs/api/basic-class/store.zh.md
+++ b/s2-site/docs/api/basic-class/store.zh.md
@@ -3,7 +3,7 @@ title: Store
order: 3
---
-功能描述:存储一些信息。[详情](https://github.com/antvis/S2/blob/master/packages/s2-core/src/common/store/index.ts)
+功能描述:存储一些信息。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/common/store/index.ts)
```ts
s2.store.get('key') // 获取
diff --git a/s2-site/docs/api/general/S2Event.zh.md b/s2-site/docs/api/general/S2Event.zh.md
index 7cb09b1a4c..fd41bfd5ef 100644
--- a/s2-site/docs/api/general/S2Event.zh.md
+++ b/s2-site/docs/api/general/S2Event.zh.md
@@ -5,7 +5,7 @@ redirect_from:
- /zh/docs/api
---
-表格事件列表,可以根据实际需要,监听所需事件,实现自定义业务。[详情](https://github.com/antvis/S2/blob/master/packages/s2-core/src/common/constant/events/basic.ts)
+表格事件列表,可以根据实际需要,监听所需事件,实现自定义业务。[详情](https://github.com/antvis/S2/blob/next/packages/s2-core/src/common/constant/events/basic.ts)
如果使用的是 `s2-react` 或 `s2-vue` 表组件,则已对事件进行封装,无需额外监听,使用其回调函数即可。 [详情](/docs/api/components/sheet-component)
diff --git a/s2-site/docs/manual/advanced/adaptive.zh.md b/s2-site/docs/manual/advanced/adaptive.zh.md
index ddf795e593..544a85a68e 100644
--- a/s2-site/docs/manual/advanced/adaptive.zh.md
+++ b/s2-site/docs/manual/advanced/adaptive.zh.md
@@ -3,7 +3,9 @@ title: 表格自适应
order: 9
---
-表格默认根据配置的 `width` 和 `height` 渲染:
+@antv/s2-react @antv/s2-vue
+
+S2 默认根据配置的 `width` 和 `height` 进行渲染:
```ts
const s2Options = {
@@ -13,7 +15,7 @@ const s2Options = {
```
:::warning{title="注意"}
-表格基于 `Canvas` 渲染,配置的宽高其实就是设置 `` 的 `width` 和 `height`, 也就是意味着 `100%`, `80vw` 之类的配置是不生效的:
+表格基于 `Canvas` 渲染,配置的宽高其实就是设置 `` 的 `width` 和 `height`, 也就是意味着 `100%`, `80vw` 之类的配置是**不生效的**:
```ts
const s2Options = {
@@ -28,7 +30,9 @@ const s2Options = {
### 窗口自适应
-如果想让表格撑满整个父容器,可以监听窗口的 `resize` 事件,或使用 [ResizeObserver](https://developer.mozilla.org/zh-CN/docs/Web/API/ResizeObserver) 监听容器大小变化,然后更新表格宽高:
+如果想让表格撑满整个父容器,可以监听窗口的 `resize` 事件,或使用 [ResizeObserver](https://developer.mozilla.org/zh-CN/docs/Web/API/ResizeObserver) 监听容器大小变化,然后更新表格宽高
+
+
```ts
import { PivotSheet } from '@antv/s2'
@@ -57,7 +61,9 @@ resizeObserver.observe(document.body);
### 容器自适应
-如果是容器本身大小发生改变,而不是窗口,那么可以使用 [ResizeObserver](https://developer.mozilla.org/zh-CN/docs/Web/API/ResizeObserver) 获取到实时的容器大小:
+如果是容器本身大小发生改变,而不是窗口,那么可以使用 [ResizeObserver](https://developer.mozilla.org/zh-CN/docs/Web/API/ResizeObserver) 获取到实时的容器大小
+
+
```ts
import { PivotSheet } from '@antv/s2'
@@ -91,10 +97,11 @@ resizeObserver.observe(parent);
如果是使用 `@antv/s2-react` 的方式,可以配置 `adaptive` 参数开启自适应。
+
+
#### Adaptive 参数类型
```ts
-// `adaptive` 的类型 `Adaptive`
type Adaptive =
| boolean
| {
diff --git a/s2-site/docs/manual/advanced/g-plugins.zh.md b/s2-site/docs/manual/advanced/g-plugins.zh.md
index 985a8fac21..053bfc4f40 100644
--- a/s2-site/docs/manual/advanced/g-plugins.zh.md
+++ b/s2-site/docs/manual/advanced/g-plugins.zh.md
@@ -9,7 +9,7 @@ order: 10
S2 基于 [`AntV/G`](https://g.antv.antgroup.com/) 渲染引擎绘制,因此可以共享其丰富的插件生态。
-
+
## 插件系统介绍
diff --git a/s2-site/docs/manual/advanced/get-cell-data.zh.md b/s2-site/docs/manual/advanced/get-cell-data.zh.md
index c55d25d67b..2eac596dc5 100644
--- a/s2-site/docs/manual/advanced/get-cell-data.zh.md
+++ b/s2-site/docs/manual/advanced/get-cell-data.zh.md
@@ -4,23 +4,25 @@ order: 9
---
:::warning{title='提示'}
-阅读本章前,请确保已经阅读过 [基础教程](/manual/basic/base-concept),[数据流处理](/manual/advanced/data-process/pivot),[布局](/manual/advanced/layout/pivot) 等章节
+阅读本章前,请确保已经阅读过 [基础教程](/manual/basic/base-concept),[数据流处理](/manual/advanced/data-process/pivot),[布局](/manual/advanced/layout/pivot) 等章节。
:::
在实际的业务场景中,我们往往会遇到一些需要获取**单元格数据**的场景,常见的比如:
-- 点击某一个行头/列头单元格,获取**当前行/列**所有数据
-- 监听鼠标 `click` `hover` 事件 获取当前对应单元格数据
-- 点击数据单元格,获取当前单元格数据,或者整行数据
-- 自定义 `tooltip` 内容,需要根据当前单元格信息来渲染不同的操作项,或者显示不同的提示信息
+- 点击某一个行头/列头单元格,获取**当前行/列**所有数据。
+- 监听鼠标 `click` `hover` 事件 获取当前对应单元格数据。
+- 点击数据单元格,获取当前单元格数据,或者整行数据。
+- 自定义 `tooltip` 内容,需要根据当前单元格信息来渲染不同的操作项,或者显示不同的提示信息。
`S2` 的表格使用 `Canvas` 绘制,所以只会有一个 `dom` 元素,所有单元格对应的一组**数据结构**,里面存储了每个单元格的坐标,文本信息,交互状态等 [信息](/docs/api/basic-class/base-cell)
-`S2` 提供了一系列获取数据的 [API](/docs/api/basic-class/spreadsheet), 下面介绍一些常用的场景
+`S2` 提供了一系列获取数据的 [API](/docs/api/basic-class/spreadsheet), 下面介绍一些常用的场景:
-### 获取指定区域单元格
+### 获取指定区域单元格节点
-在渲染完成后,访问 `s2.facet.getLayoutResult()` 获取到当前可视范围内所有 [单元格](/docs/api/basic-class/node)。[查看更多](/docs/api/basic-class/base-facet)
+在渲染完成后,访问 `s2.facet.getLayoutResult()` 获取到当前所有(**含不在可视范围的**)[单元格节点](/docs/api/basic-class/node)。
+
+一个节点 (Node) 对应一个 单元格 (Cell), 当节点在可视范围内时,会被实例化为单元格 (Cell), 可通过 `node.belongsCell` 获取
```ts
await s2.render()
@@ -29,33 +31,114 @@ await s2.render()
console.log(s2.facet.getLayoutResult())
```
-
+或者
+
+```ts
+import { S2Event } from '@antv/s2'
+
+s2.on(S2Event.LAYOUT_AFTER_RENDER, () => {
+ console.log(s2.facet.getLayoutResult())
+})
+```
+
+
+
+:::info{title="可以获取到如下信息"}
+- `cornerNodes` 角头节点
+- `seriesNumberNodes` 序号列节点
- `colLeafNodes` 列头叶子节点
- `colNodes` 列头节点
- `colsHierarchy` 列头层级信息
- `rowLeafNodes` 行头叶子节点
- `rowNodes` 行头节点
- `rowsHierarchy` 行头层级信息
-- `getCellMeta` [根据行列索引获取指定单元格信息](#根据行列索引获取数值单元格信息)
-
+:::
-#### 获取数值单元格
+[查看更多](/docs/api/basic-class/base-facet)
-对于数值单元格 (dataCell),由于虚拟滚动的特性,需要动态获取,更多请查看 [interaction API](/docs/api/basic-class/interaction)
+:::warning{title="注意"}
+由于虚拟滚动的特性,获取到为不含可视区域外的单元格。
+:::
+
+### 获取行头单元格
+
+```ts
+s2.facet.getRowCells()
+s2.facet.getRowLeafCells()
+```
+
+### 获取列头单元格
+
+```ts
+s2.facet.getColCells()
+s2.facet.getColLeafCells()
+```
+
+### 获取角头单元格
+
+```ts
+s2.facet.getCornerCells()
+```
+
+### 获取合并单元格
+
+```ts
+s2.facet.getMergedCells()
+```
+
+### 获取序号单元格
+
+```ts
+s2.facet.getSeriesNumberCells()
+```
+
+### 获取数值单元格
+
+更多请查看 [interaction API](/docs/api/basic-class/interaction)
```ts
// 当前可视范围内的数值单元格
s2.facet.getDataCells()
// 当前可视范围内未选中的数值单元格
-s2.interaction.getPanelGroupAllUnSelectedDataCells()
+s2.interaction.getUnSelectedDataCells()
+```
+
+### 获取表头单元格 (序号,角头,行头,列头)
+
+```ts
+s2.getHeaderCells()
+```
+
+### 获取所有单元格
+
+```ts
+s2.facet.getCells()
+```
+
+### 根据单元格 field 获取指定单元格
+
+```ts
+s2.facet.getCellsByField(field)
+```
+
+### 根据单元格 id 获取指定单元格
+
+```ts
+s2.facet.getCellById(id)
+```
+
+### 根据 Event 获取对应单元格
+
+```ts
+s2.getCell(event.target)
```
-#### 获取角头单元格
+### 根据单元格获取元信息
```ts
-s2.facet.cornerHeader.getNodes()
+cell.getMeta()
```
### 监听点击事件获取对应单元格
@@ -196,9 +279,9 @@ s2.on(S2Event.DATA_CELL_CLICK, (event) => {
```ts
// 找到 "舟山市" 对应的行头单元格节点
-const rowCellNode = s2.facet.getRowCellNodes().find((node) => node.id === 'root[&]浙江省[&]舟山市')
+const rowCellNode = s2.facet.getRowCellNodes().find((node) => node.id === 'root[&] 浙江省 [&] 舟山市')
// 找到 "办公用品" 下 "纸张" 对应的 "数量"列头单元格节点
-const colCellNode = s2.facet.getColCellNodes().find((node) => node.id === 'root[&]办公用品[&]纸张[&]number')
+const colCellNode = s2.facet.getColCellNodes().find((node) => node.id === 'root[&] 办公用品 [&] 纸张 [&]number')
const data = s2.dataSet.getCellMultiData({
query: {
diff --git a/s2-site/docs/manual/advanced/get-instance.zh.md b/s2-site/docs/manual/advanced/get-instance.zh.md
index 739ab72133..f5e05041d5 100644
--- a/s2-site/docs/manual/advanced/get-instance.zh.md
+++ b/s2-site/docs/manual/advanced/get-instance.zh.md
@@ -3,13 +3,16 @@ title: 获取表格实例
order: 8
---
+@antv/s2-react @antv/s2-vue
+
## React 版本
-对于使用 `React` 组件 `SheetComponent` 这一类场景,如果需要获取到 [表格实例](/docs/api/basic-class/spreadsheet), 进行一些进阶操作时,可以使用 `React.useRef` 和 `onMounted` 两种方式
+对于使用 `React` 组件 `SheetComponent` 这一类场景,如果需要获取到 [表格实例](/docs/api/basic-class/spreadsheet),进行一些进阶操作时,可以使用 `React.useRef` 和 `onMounted` 进行获取。
-### ref 方式(推荐)
+### 使用
```tsx
+import React from 'react'
import { SpreadSheet } from '@antv/s2'
import { SheetComponent } from '@antv/s2-react'
@@ -39,7 +42,7 @@ function App() {
}
```
-当 `sheetType` 变更时,底层会使用不同的表格类进行渲染,也就意味着此时 `实例` 已经发生了变更
+当 `sheetType` 变更时,底层会使用不同的表格类进行渲染,也就意味着此时 `实例` 已经**发生了变更**.
```diff
pivot => table
@@ -51,7 +54,8 @@ pivot => table
变更前注册事件会被注销,`S2` 对这种场景进行了优化,不管是 `ref` 还是 `onMounted` 方式,拿到的都是最新的实例,开发者无需关心
```tsx
-import { SpreadSheet, S2Event } from '@antv/s2'
+import React from 'react'
+import { SpreadSheet } from '@antv/s2'
import { SheetComponent } from '@antv/s2-react'
function App() {
@@ -62,6 +66,10 @@ function App() {
console.log(s2Ref.current === instance)
}
+ React.useEffect(() => {
+ setSheetType('table')
+ },[])
+
return (
)
@@ -70,7 +78,7 @@ function App() {
### 转发实例给上层组件
-如果你的业务对于 `SheetComponent` 进行了二次封装,需要暴露实例时,可以使用 `React.forwardRef` 进行实例转发
+如果你的业务对于 `SheetComponent` 进行了二次封装,需要暴露实例时,可以使用 `React.forwardRef` 进行实例转发。
```tsx
const YourComponent = React.forwardRef(
@@ -99,9 +107,9 @@ function App() {
## Vue 版本
-### ref 方式(推荐)
+### 使用
-ref 方式得到的是一个对象,其中的`instance`属性才对应真正的表格实例:
+ref 方式得到的是一个对象,其中的 `instance` 属性才对应真正的表格实例:
```vue
+
// React 需额外引入样式:
-
+
// Vue3 版本 需额外引入样式:
-
+
```
diff --git a/s2-site/docs/common/development.zh.md b/s2-site/docs/common/development.zh.md
index 037a89feb8..093b700161 100644
--- a/s2-site/docs/common/development.zh.md
+++ b/s2-site/docs/common/development.zh.md
@@ -1,7 +1,5 @@
-:::info{title="跃跃欲试想贡献?"}
-
+:::info{title="跃跃欲试想贡献?"}
[查看贡献指南](/manual/contribution)
-
:::
```bash
@@ -18,14 +16,20 @@ pnpm build
# 调试 s2-core
pnpm core:start
-# 调试 s2-react
+# 调试 s2-react 和 s2-core (推荐)
pnpm react:playground
-# 调试 s2-vue
+# 调试 s2-vue 和 s2-core
pnpm vue:playground
# 单元测试
pnpm test
+pnpm core:test
+pnpm react:test
+
+# 更新单元格测试快照
+pnpm core:test -- -u
+pnpm react:test -- -u
# 代码风格和类型检测
pnpm lint
diff --git a/s2-site/docs/common/packages.zh.md b/s2-site/docs/common/packages.zh.md
index d698df0238..ca4223f52b 100644
--- a/s2-site/docs/common/packages.zh.md
+++ b/s2-site/docs/common/packages.zh.md
@@ -5,11 +5,11 @@ order: 5
:::info{title="提示"}
-创建 `S2` 表格有三种方式,基础类版本 `@antv/s2` 和 基于 `@antv/s2` 封装的 `React` 和 `Vue3` 版本
+创建 `S2` 表格有三种方式,基础类版本 `@antv/s2` 和 基于 `@antv/s2` 封装的 `React` 和 `Vue3` 版本:
-- `@antv/s2`: 基于 `Canvas` 和 [AntV/G](https://g.antv.antgroup.com) 开发,提供基本的表格展示/交互等能力
-- `@antv/s2-react`: 基于 `@antv/s2` 封装,提供配套的 [分析组件](/manual/basic/analysis/switcher)
-- `@antv/s2-vue`: 基于 `Vue3` 和 `@antv/s2` 封装,提供配套的分析组件
+- `@antv/s2`: 基于 `Canvas` 和 [AntV/G](https://g.antv.antgroup.com) 开发,提供基本的表格展示/交互等能力。
+- `@antv/s2-react`: 基于 `@antv/s2` 封装,提供配套的 [分析组件](/manual/basic/analysis/switcher).
+- `@antv/s2-vue`: 基于 `Vue3` 和 `@antv/s2` 封装,提供配套的分析组件。
**也就是说** `@antv/s2` 和**框架无关**,你可以在 `Vue`, `Angular` 等任意框架中使用。
:::
diff --git a/s2-site/docs/manual/contribution.zh.md b/s2-site/docs/manual/contribution.zh.md
index c965b1b160..cbd6140034 100644
--- a/s2-site/docs/manual/contribution.zh.md
+++ b/s2-site/docs/manual/contribution.zh.md
@@ -3,18 +3,22 @@ title: 贡献指南
order: 7
---
-如果你恰好看到了这篇文章,你一定是希望对这个项目贡献自己的一份力量
+如果你恰好看到了这篇文章,你一定是希望对这个项目贡献自己的一份力量。
## 欢迎任何形式的贡献
"我代码水平不行", "会不会受到鄙视?", "会不会不太好?", 放心,不存在的!
-我们欢迎任何形式的贡献,不管是一个错别字的修改,还是一次友好的建议,不管是通过 提交 [Issue](https://github.com/antvis/S2/issues/new/choose)
-还是一个帅气 [pull request](https://github.com/antvis/S2/pulls), 亦或是一次钉钉群的讨论,参与 [discussions](https://github.com/antvis/S2/discussions) 的讨论,期待在 [贡献者列表](https://github.com/antvis/S2/graphs/contributors) 里看见你的头像。
+我们欢迎任何形式的贡献,不管是一个**错别字的修改**,还是**一次友好的建议**,不管是通过提交 [Issue](https://github.com/antvis/S2/issues/new/choose), 还是一个帅气 [pull request](https://github.com/antvis/S2/pulls), 亦或是一次钉钉群的讨论,参与 [discussions](https://github.com/antvis/S2/discussions) 的讨论,期待在 [贡献者列表](https://github.com/antvis/S2/graphs/contributors) 里看见你的头像。
## 分支管理
-目前,我们基于 `master` 分支开发,有任何修改,请基于 `master` 拉一个分支,然后通过 `PR` 的形式,我们集成了钉钉机器人,会第一次时间 review 你的 PR, 给与反馈
+目前我们主要基于 `master` 和 `next` 分支开发,有任何修改,请基于 `master` 或 `next` 拉一个分支,然后通过 `PR` 的形式提交,我们集成了钉钉机器人,会第一次时间 `review` 你的 `PR`, 给与反馈。
+
+- `master`: `1.x` 版本
+- `next`: `2.x` 版本
+- `alpha`: `1.x-alpha.x` 版本
+- `beta`: `1.x-beta.x` 版本
## 提交 Bug 反馈
@@ -28,7 +32,8 @@ order: 7
![preview](https://gw.alipayobjects.com/zos/antfincdn/oAnzfiVl2/9d83b3e8-b05c-4475-b736-92c45448546a.png)
-按照 Issue 模板 填写相关的信息,是的,这些步骤稍微一些繁琐,但确实必须的,每个用户使用的场景都不同,系统环境,软件版本,又或是需要一些特定的步骤才能复现 bug, 这个时候说清楚,可以节省大家的时间!
+按照 [Issue 模板](https://github.com/antvis/S2/tree/next/.github/ISSUE_TEMPLATE) 填写相关信息。
+是的,这些步骤稍微有一些繁琐,但的确是有效且必须的,每个用户使用的场景都不同,系统环境,软件版本,又或是需要一些特定的步骤才能复现 bug, 这个时候说清楚,可以节省大家的时间!
![preview](https://gw.alipayobjects.com/zos/antfincdn/05O3p5nE5/d0d4b120-e5aa-4b51-918b-8a573f8fb794.png)
@@ -36,29 +41,30 @@ order: 7
> 示例 [PR](https://github.com/antvis/S2/pull/1652) (pr 描述参考)
-1. fork 项目 并 clone 下来 (或者使用 GitHub 的 Codespace 功能,非常方便)
-2. 安装依赖:`pnpm install` 或者 `pnpm bootstrap`
-3. 提交你的改动,commit 请遵守 [AngularJS Git Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#heading=h.uyo6cb12dt6w)
-4. 如果你的改动是修复 bug, 还可以在提交信息后面加上 `close #issue 号`, 这样可以在 pr 合并后,可以自动关闭对应的 issue, 比如 `fix: render bug close #123`
-5. 确保加上了对应的单元测试和文档 (如有必要)
+1. fork 项目 并 clone 下来 (或者使用 GitHub 的 Codespaces 功能,非常方便).
+2. 安装依赖:`pnpm install` 或者 `pnpm bootstrap` 然后本地启动项目。
+3. 提交你的改动,commit 请遵守 [AngularJS Git Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#heading=h.uyo6cb12dt6w).
+4. 如果你的改动是修复 bug, 还可以在提交信息后面加上 `close #issue 号`, 这样可以在 pr 合并后,可以自动关闭对应的 issue, 比如 `fix: render bug close #123`.
+5. 确保加上了对应的单元测试和文档 (如有必要).
6. 所有 Lint 和 Test 检查通过后,并且 review 通过,我们会合并你的 pr.
![preview](https://gw.alipayobjects.com/zos/antfincdn/ssOxFrycD/86339514-5f9a-4101-8690-e47c97cd8af5.png)
-## 开发流程
+## ⌨️ 本地开发
+
+:::info{title="提示"}
-我们使用 `pnpm@v7` 作为包管理
+我们使用 `pnpm` 作为包管理
```bash
npm i -g pnpm
```
-1. `pnpm install` 安装依赖
-2. `pnpm site:start` 启动本地的 `S2` 网站
-3. `pnpm core:start` 使用可视化的方式调试 core 层的单测 (基于 jest-electron)
-4. `pnpm react:start` 可用可视化的方式调试 React 版本的单测 (基于 jest-electron)
-5. `pnpm react:playground` 启动本地的交互式 React 版本 Demo (基于 vite)
-6. `pnpm vue:playground` 启动本地的交互式 Vue3 版本 Demo (基于 vite)
-7. `pnpm build` 构建 `@antv/s2`, `@antv/s2-react` 和 `@antv/s2-vue` 3 个包,分别输出 `umd`, `esm` 和 `lib` 目录
-8. `pnpm test` 运行单元测试
-9. `pnpm lint` 静态代码检测
+推荐本地运行 `pnpm react:playground` 来调试 `@antv/s2` 和 `@antv/s2-react`
+:::
+
+
+
+## 📦 版本
+
+
diff --git a/s2-site/docs/manual/faq.zh.md b/s2-site/docs/manual/faq.zh.md
index 1db044fa29..0c11b8c7b2 100644
--- a/s2-site/docs/manual/faq.zh.md
+++ b/s2-site/docs/manual/faq.zh.md
@@ -207,7 +207,7 @@ const s2Options = {
- 你**实际**安装的版本号:
-> 避免 `latest` 或者 `*` 这种没有实际意义的版本号,提供你实际使用的版本可以帮助我们更快的定位问题,有可能你使用的功能在新版本中才支持,或者 bug 在新版本中已经被修复了
+> 避免 `latest`, `next` 或者 `*` 这种没有实际意义的版本号,提供你实际使用的版本可以帮助我们更快的定位问题,有可能你使用的功能在新版本中才支持,或者 bug 在新版本中已经被修复了
- **详细的** bug 描述
diff --git a/s2-site/docs/manual/getting-started.zh.md b/s2-site/docs/manual/getting-started.zh.md
index 649ea1ff04..a65cc926e7 100644
--- a/s2-site/docs/manual/getting-started.zh.md
+++ b/s2-site/docs/manual/getting-started.zh.md
@@ -7,14 +7,14 @@ order: 1
### 使用 npm 或 yarn 或 pnpm 安装
```bash
+# pnpm
+$ pnpm add @antv/s2 --save
+
# npm
$ npm install @antv/s2 --save
# yarn
$ yarn add @antv/s2 --save
-
-# pnpm
-$ pnpm add @antv/s2 --save
```
### 使用 React 或 Vue3 版本
@@ -290,7 +290,7 @@ createApp(App).mount('#app');
`Vue3` 版本的 `分析组件` 如:`高级排序`, `导出`, `下钻`, `Tooltip` 等组件基于 `ant-design-vue` 组件库开发,如需使用,需要额外安装,并引入对应样式
-```ts
+```bash
yarn add ant-design-vue
```
diff --git a/s2-site/docs/manual/introduction.zh.md b/s2-site/docs/manual/introduction.zh.md
index 4c4b7d1fee..d68c3f218e 100644
--- a/s2-site/docs/manual/introduction.zh.md
+++ b/s2-site/docs/manual/introduction.zh.md
@@ -30,7 +30,7 @@ redirect_from:
-
+
From eb7476c3c85a6d6f120db1025789f5f1b2bcd5d4 Mon Sep 17 00:00:00 2001
From: lijinke666
Date: Thu, 28 Dec 2023 18:11:35 +0800
Subject: [PATCH 14/64] =?UTF-8?q?docs:=20=E5=A2=9E=E5=8A=A0=20wip=20?=
=?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=8C=87=E5=8D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 10 ++-
s2-site/.dumirc.ts | 23 ++++--
...custom-chart.en.md => chart-in-cell.en.md} | 2 +-
...custom-chart.zh.md => chart-in-cell.zh.md} | 6 +-
s2-site/docs/manual/contribution.zh.md | 12 +--
s2-site/docs/manual/migration-v2.en.md | 8 ++
s2-site/docs/manual/migration-v2.zh.md | 75 +++++++++++++++++++
.../custom/custom-g2-chart/demo/meta.json | 4 +-
.../custom/custom-g2-chart/index.zh.md | 2 +-
9 files changed, 119 insertions(+), 23 deletions(-)
rename s2-site/docs/manual/advanced/{custom/custom-chart.en.md => chart-in-cell.en.md} (76%)
rename s2-site/docs/manual/advanced/{custom/custom-chart.zh.md => chart-in-cell.zh.md} (99%)
create mode 100644 s2-site/docs/manual/migration-v2.en.md
create mode 100644 s2-site/docs/manual/migration-v2.zh.md
diff --git a/README.md b/README.md
index edb6f94818..07cf1ce810 100644
--- a/README.md
+++ b/README.md
@@ -165,11 +165,15 @@ const s2Options = {
```ts
import { PivotSheet } from '@antv/s2';
-const container = document.getElementById('container');
+async function bootstrap() {
+ const container = document.getElementById('container');
-const s2 = new PivotSheet(container, s2DataConfig, s2Options);
+ const s2 = new PivotSheet(container, s2DataConfig, s2Options);
-s2.render();
+ await s2.render();
+}
+
+bootstrap()
```
### 4. 结果
diff --git a/s2-site/.dumirc.ts b/s2-site/.dumirc.ts
index 894c7bd114..b8bd3d631a 100644
--- a/s2-site/.dumirc.ts
+++ b/s2-site/.dumirc.ts
@@ -13,12 +13,12 @@ export default defineConfig({
], // 网站 favicon
metas: [
// 自定义 meta 标签
- { name: 'keywords', content: 'S2' },
- { name: 'description', content: '多维交叉分析表格' },
+ { name: 'keywords', content: 'S2 2.0' },
+ { name: 'description', content: '多维交叉分析表格 2.0, S2 Next' },
],
themeConfig: {
title: 'S2',
- description: '多维交叉分析表格',
+ description: '多维交叉分析表格 2.0',
defaultLanguage: 'zh', // 默认语言
isAntVSite: false, // 是否是 AntV 的大官网
siteUrl: 'https://antv.antgroup.com', // 官网地址
@@ -278,14 +278,14 @@ export default defineConfig({