S2 icon indicating copy to clipboard operation
S2 copied to clipboard

🐛交叉表只有列维度时,同时开启行总计和列总计,复制的数据中行总计的值与表格实际渲染的值不符

Open KzqKzq opened this issue 1 year ago • 0 comments

🏷 Version

Package Version
@antv/s2
@antv/s2-react
@antv/s2-vue

Sheet Type

  • [x] PivotSheet
  • [ ] TableSheet
  • [ ] GridAnalysisSheet
  • [ ] StrategySheet
  • [ ] EditableSheet

🖋 Description

交叉表只有列维度时,同时开启行总计(均值)和列总计(求和),调用asyncGetAllPlainData 函数得到的复制数据里面行总计的值与表格实际渲染的值不符

⌨️ Code Snapshots

直接使用官网示例在线演示 链接,替换成下面代码

// organize-imports-ignore
import React from 'react';
import { Aggregation, S2DataConfig } from '@antv/s2';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';

fetch(
  'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json',
)
  .then((res) => res.json())
  .then((res) => {
    const s2Options: SheetComponentOptions = {
      width: 600,
      height: 480,
      interaction: {
        copy: { enable: true },
      },
      totals: {
        col: {
          showGrandTotals: true,
          showSubTotals: true,
          reverseGrandTotalsLayout: true,
          calcGrandTotals: {
            // 设置总计汇总计算方式为求和
            aggregation: Aggregation.SUM,
          },
        },
        row: {
          showGrandTotals: true,
          calcGrandTotals: {
            // 设置总计汇总计算方式为均值
            aggregation: Aggregation.AVG,
          },
        },
      },
    };

    const s2DataConfig: S2DataConfig = {
      fields: {
        rows: ['province', 'city'],
        // columns: ['type', 'sub_type'],
        values: ['number'],
      },
      meta: res.meta,
      data: res.data,
    };

    reactDOMClient.createRoot(document.getElementById('container')).render(
      <SheetComponent
        dataCfg={s2DataConfig}
        options={s2Options}
        header={{
          export: {
            open: true,
          },
        }}
        adaptive={false}
      />,
    );
  });

🔗 Reproduce Link

🤔 Steps to Reproduce

点击react 组件的任意一个复制按钮 image

😊 Expected Behavior

希望表格显示的行总计与复制的行总计值一致

😅 Current Behavior

可以看到表格显示的行总计与复制的行总计值不一致 image

💻 System information

Environment Info
System window 10
Browser chrome: v128.0.6613.86

KzqKzq avatar Oct 16 '24 09:10 KzqKzq