Pivot Mode
Previous
Base Concept
Next
Table Mode
Loading...
Pivot table is also called cross table or multi-dimensional table. It is a table showing the relationship between multiple variables. It can help users discover the interaction between them and help businesses conduct cross-exploration analysis. It is currently the most frequently used in the field of commercial BI analysis. one of the charts.
<div id="container" />
import React from "react";import ReactDOM from "react-dom";import { SheetComponent } from "@antv/s2-react";import '@antv/s2-react/dist/s2-react.min.css';// 1. 准备数据const data = [{province: "浙江",city: "杭州",type: "家具",sub_type: "桌子",price: "1",},{province: "浙江",city: "杭州",type: "家具",sub_type: "沙发",price: "2",},{province: "浙江",city: "杭州",type: "办公用品",sub_type: "笔",price: "3",},{province: "浙江",city: "杭州",type: "办公用品",sub_type: "纸张",price: "4",},];// 2. 配置数据const s2DataConfig = {fields: {rows: ["province", "city"],columns: ["type", "sub_type"],values: ["price"]},data,};// 3. 添加配置const s2Options = {width: 600,height: 600,};// 4. 渲染ReactDOM.render(<SheetComponentdataCfg={s2DataConfig}options={s2Options}/>,document.getElementById('container'));
📊 Check out the React version perspective example and API docs .
If you don't plan to rely on React
, you can call it directly after the third step above:
import { PivotSheet } from "@antv/s2";const container = document.getElementById('container');const s2 = new PivotSheet(container, dataCfg, options);s2.render();
📊 Check out the class-wise perspective example and API docs .