Loading...
S2 是一个面向可视分析领域的数据驱动的表可视化引擎。S
取自于 SpreadSheet
的两个 S
,2
代表了透视表中的行列两个维度。旨在提供美观、易用、高性能、易扩展的多维表格。
React
, Vue3
表组件及配套分析组件,只需要简单的配置即可轻松实现复杂场景。<4s
渲染,也能通过局部下钻来实现秒级渲染。使用 npm 或 yarn 或 pnpm 安装
# npm$ npm install @antv/s2 --save# yarn$ yarn add @antv/s2# pnpm$ pnpm add @antv/s2
npm install @antv/s2 @antv/s2-react --save
npm install @antv/s2 @antv/s2-react-components antd @ant-design/icons --save
@antv/s2-vue
现已停止维护,由于精力投入有限,出于维护成本,包下载量等因素综合考虑,从 2.0.0
正式版后不再继续更新,请基于 @antv/s2
自行封装,或 fork 仓库进行二次开发社区版本。
const s2DataConfig = {fields: {rows: ['province', 'city'],columns: ['type'],values: ['price'],},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: "笔",cost: "0.5",},{province: "浙江",city: "杭州",type: "纸张",cost: "20",},{province: "浙江",city: "舟山",type: "笔",cost: "1.7",},{province: "浙江",city: "舟山",type: "纸张",cost: "0.12",},{province: "吉林",city: "长春",type: "笔",cost: "10",},{province: "吉林",city: "白山",type: "笔",cost: "9",},{province: "吉林",city: "长春",type: "纸张",cost: "3",},{province: "吉林",city: "白山",type: "纸张",cost: "1",}],meta: [{field: 'price',name: '价格',},{field: 'province',name: '省份',},{field: 'city',name: '城市',},{field: 'type',name: '类别',},{field: 'sub_type',name: '子类别',},]};
const s2Options = {width: 600,height: 600}
<div id="container" />
import { PivotSheet } from '@antv/s2';async function bootstrap() {const container = document.getElementById('container');const s2 = new PivotSheet(container, s2DataConfig, s2Options);await s2.render(); // 异步渲染}bootstrap();
创建 S2
表格有三种方式,基础类版本 @antv/s2
和 基于 @antv/s2
封装的 React
和 Vue3
版本:
@antv/s2
: 基于 Canvas
和 AntV/G 6.0 开发,提供基本的表格展示/交互等能力。版本依赖:无
@antv/s2-react
: 基于 React 18
, 和 @antv/s2
封装,兼容 React 16/17
版本,同时提供配套的 分析组件 (@antv/s2-react-components
).版本依赖:
"peerDependencies": {"@antv/s2": "^2.0.0","react": ">=16.9.0","react-dom": ">=16.9.0"}
@antv/s2-vue
: 基于 Vue3
, @antv/s2
, [email protected]
封装。停止维护版本依赖:
"peerDependencies": {"@antv/s2": "^2.0.0","ant-design-vue": "^3.2.0","vue": ">=3.x"}
也就是说 @antv/s2
和框架无关,无任何额外依赖, 你可以在 Vue
, Angular
等任意框架中使用。
包名 | 稳定版 | 包大小 | 下载量 |
---|---|---|---|
@antv/s2 | |||
@antv/s2-react | |||
@antv/s2-react-components | |||
@antv/s2-vue(停止维护) |
Watch
S2 代码仓库, 选择 Custom - Releases
来获取消息推送。@antv/s2-react
和 @antv/s2-vue
见官方 React JavaScript 环境要求 和 Vite 浏览器兼容性
如果你遇到了问题,或者对 Issues 和 Discussions 列表的问题感兴趣,可以直接认领并尝试修复,帮助 S2 变得更好,期待在 贡献者列表 里看见你的头像。
请严格按照模版 提交 Issue 或在 Discussions 提问,在这之前强烈建议阅读 《⚠️ 提 Issue 前必读》
S2 使用 pnpm 作为包管理器
git clone [email protected]:antvis/S2.gitcd S2# 切换到 2.x 分支git checkout next# 安装依赖pnpm install # 或者 pnpm bootstrap# 打包pnpm build# 调试 s2-corepnpm core:start# 调试 s2-react 和 s2-core(推荐)pnpm core:build-esm # 首次运行需要先执行一次(安装依赖后自动执行)pnpm react:playground# 调试 s2-react-componentspnpm react-components:playground# 调试 s2-vue 和 s2-corepnpm vue:playground# 单元测试pnpm testpnpm core:testpnpm react:test# 更新单元格测试快照pnpm core:test -- -upnpm react:test -- -u# 代码风格和类型检测pnpm lint# 本地启动官网pnpm build # 首次运行官网需要先执行一次pnpm site:start
S2 非常需要你的共建,请阅读 贡献指南 后提交 PR.
MIT@AntV