Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 当开启customValueOrder=0(将指标名置于列头),多指标情况下显示会有问题,且小计应该只展示该指标,而不是按照多指标。 #2062

Closed
4 tasks
liran19960215 opened this issue Jan 31, 2023 · 3 comments
Assignees
Labels
💤 inactive 不活跃的 Issue 或 PR, 30天没有回复

Comments

@liran19960215
Copy link

🏷 Version

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

Sheet Type

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

🖋 Description

dataconfig中有customValueOrder属性,可以自定义度量名称显示的位置,当开启customValueOrder=0且有两个以上度量值,列上有两个以上维度时,开启小计,会出现“小计”显示错乱的情况。而且小计的计算结果也不对,这个时候应该按单度量值显示计算结果。

  • 小计显示错乱问题
    image

  • 小计计算问题
    image
    当度量名称显示在列头时,不应按照多度量值显示小计,应该只计算该度量下的小计,例如价格下,只显示一列”小计“列,值为价格的小计

⌨️ Code Snapshots

import { PivotSheet } from '@antv/s2';

fetch(
  'https://gw.alipayobjects.com/os/bmw-prod/6eede6eb-8021-4da8-bb12-67891a5705b7.json',
)
  .then((res) => res.json())
  .then((data) => {
    const container = document.getElementById('container');
    const s2DataConfig = {
      fields: {
        rows: ['province'],
        columns: ['type', 'city'],
        values: ['price', 'cost'],
        customValueOrder: 0
      },
      meta: [
        {
          field: 'province',
          name: '省份',
        },
        {
          field: 'city',
          name: '城市',
        },
        {
          field: 'type',
          name: '商品类别',
        },
        {
          field: 'price',
          name: '价格',
        },
        {
          field: 'cost',
          name: '成本',
        },
      ],
      data,
    };

    const s2Options = {
      width: 900,
      height: 480,
      selectedCellsSpotlight: true,
      hoverHighlight: true,
      tooltip: {
        showTooltip: true,
      },
      interaction: {
        enableCopy: true,
      },
      // 配置小计总计显示
      totals: {
        row: {
          showGrandTotals: false,
          showSubTotals: true,
          reverseLayout: true,
          reverseSubLayout: true,
          subTotalsDimensions: ['province'],
        },
        col: {
          showGrandTotals: false,
          showSubTotals: true,
          reverseLayout: true,
          reverseSubLayout: true,
          subTotalsDimensions: ['type'],
        },
      },
    };
    const s2 = new PivotSheet(container, s2DataConfig, s2Options);

    s2.render();
  });

🔗 Reproduce Link

https://antv-s2.gitee.io/zh/examples/analysis/totals#multiple-values

🤔 Steps to Reproduce

  1. 打开官网示例链接https://antv-s2.gitee.io/zh/examples/analysis/totals#multiple-values;
  2. 用上述代码替换代码边界页面中的代码即可复现图片中的问题;
    image

😊 Expected Behavior

  1. “小计”位置正常显示;
  2. 开启customValueOrder=0,多指标且列上多维度的情况下,不应按照多指标显示小计,而是只显示该指标下的小计

😅 Current Behavior

💻 System information

Environment Info
System
Browser
@lijinke666
Copy link
Member

目前不支持多指标的场景

@liran19960215
Copy link
Author

目前不支持多指标的场景

values字段不是可以传入多指标吗?那这里说的不支持多指标场景指的是?

@lijinke666
Copy link
Member

values字段不是可以传入多指标吗?那这里说的不支持多指标场景指的是?

values 可以是多指标, 但是 customValueOrder 只在单指标时有效.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💤 inactive 不活跃的 Issue 或 PR, 30天没有回复
Projects
None yet
Development

No branches or pull requests

3 participants