🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@antv/s2-react-components

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/s2-react-components

React components for S2

2.1.2
latest
Source
npm
Version published
Weekly downloads
49
-36.36%
Maintainers
0
Weekly downloads
 
Created
Source

@antv/s2-react-components

S2 多维分析表格配置套的 React 分析/配置组件库。

npm Version ci test status

📦 安装

$ pnpm add @antv/s2-react-components
# npm install @antv/s2-react-components --save
# yarn add @antv/s2-react-components

🔨 使用

import React from 'React'
import { ThemePanel, TextAlignPanel, FrozenPanel } from '@antv/s2-react-components'
import '@antv/s2-react-components/dist/s2-react-components.min.css'

const App = () => {
  return (
    <>
      <ThemePanel
        title="主题配置"
        disableCustomPrimaryColorPicker={false}
        defaultCollapsed={false}
        onChange={(options, theme) => {
          console.log('onChange:', options, theme);
        }}
        onReset={(options, prevOptions, theme) => {
          console.log('onReset:', options, prevOptions, theme);
        }}
      />
      <TextAlignPanel
        title="文字对齐"
        defaultCollapsed={false}
        onChange={(options, theme) => {
          console.log('onChange:', options, theme);
        }}
        onReset={(options, prevOptions, theme) => {
          console.log('onReset:', options, prevOptions, theme);
        }}
      />
      <FrozenPanel
        title="冻结行列头"
        defaultCollapsed={false}
        onChange={(options) => {
          console.log('onChange:', options);
        }}
        onReset={(options, prevOptions) => {
          console.log('onReset:', options, prevOptions);
        }}
      />
    </>
  )
}

结果

result

结合表格使用

import React from 'React'
import { ThemePanel } from '@antv/s2-react-components'
import '@antv/s2-react-components/dist/s2-react-components.min.css'

const App = () => {
  const s2Ref = React.useRef<SpreadSheet>();
  const [themeCfg, setThemeCfg] = React.useState<ThemeCfg>({
    name: 'default',
  });

  return (
    <>
      <ThemePanel
        title="主题配置"
        disableCustomPrimaryColorPicker={false}
        defaultCollapsed={false}
        onChange={(options, theme) => {
          setThemeCfg({
            name: options.themeType as ThemeName,
            theme,
          });
          s2Ref.current?.setOptions({
            hierarchyType: options.hierarchyType,
          });
          s2Ref.current?.render(false);
          console.log('onChange:', options, theme);
        }}
        onReset={(options, prevOptions, theme) => {
          console.log('onReset:', options, prevOptions, theme);
        }}
      />
      <SheetComponent
        ref={s2Ref}
        dataCfg={s2DataConfig}
        options={s2Options}
        sheetType="pivot"
        themeCfg={themeCfg}
      />
    </>
  )

result

Keywords

antv

FAQs

Package last updated on 13 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts