-
Notifications
You must be signed in to change notification settings - Fork 184
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
🐛 使用自定义总计,当行为空,列上有指标维度,开启总计后,数据展示异常 #2177
Comments
使用自定义总计,当行上有指标维度(valueInCols: false),列上为空的情况下(column: ['']),也会出现此类展示异常的问题 import { PivotSheet, EXTRA_FIELD } from '@antv/s2';
fetch('https://assets.antv.antgroup.com/s2/basic.json')
.then((res) => res.json())
.then((data) => {
const container = document.getElementById('container');
const s2DataConfig = {
fields: {
rows: ['type', 'province'],
columns: [''],
values: ['price'],
valueInCols: false,
},
meta: [
{
field: 'province',
name: '省份',
},
{
field: 'city',
name: '城市',
},
{
field: 'type',
name: '商品类别',
},
{
field: 'price',
name: '价格',
},
],
data,
};
const calcFunc = (query, data) => {
const sum = data.reduce((pre, next) => {
console.log(pre, next[next[EXTRA_FIELD]])
return pre + Number(next[next[EXTRA_FIELD]]);
}, 0);
return sum;
};
const s2Options = {
width: 600,
height: 480,
// 配置小计总计显示
totals: {
row: {
showGrandTotals: true,
showSubTotals: true,
reverseLayout: true,
reverseSubLayout: true,
subTotalsDimensions: ['province'],
calcTotals: {
calcFunc,
},
calcSubTotals: {
calcFunc,
},
},
col: {
showGrandTotals: true,
showSubTotals: false,
reverseLayout: true,
reverseSubLayout: true,
subTotalsDimensions: ['type'],
calcTotals: {
calcFunc,
},
calcSubTotals: {
calcFunc,
},
},
},
};
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
s2.render();
}); |
没有把行/列维度 field 设为 |
那如果行/列为空 数据就无法展开了吗 |
用法暂不支持,自行尝试使用自定义单元格。 |
[''] 不是为空, 语义代表有一个维度, 维度叫 '', 空数组才是 [] 为空, 请不要自行发明用法或者骚操作... 看上去你的诉求如果是单个行/列 不显示维值, 只显示 S2 提供的总计, 你可以自己洗一下数据, 自己创建一个 |
请问怎么创建一个总计维度?有没有例子可以参考的 |
🏷 Version
Sheet Type
🖋 Description
使用自定义总计,当行为空,列上有指标维度,开启总计后,数据展示异常
![image](https://user-images.githubusercontent.com/65275407/233982036-cc72f3f3-44c9-4079-bd58-25dce9ab0d05.png)
![image](https://user-images.githubusercontent.com/65275407/233982101-79c1cdd7-3531-48d3-846b-a3c46baa5817.png)
行列交叉模型如图所示
⌨️ Code Snapshots
🔗 Reproduce Link
https://s2.antv.antgroup.com/examples/analysis/totals/#custom
🤔 Steps to Reproduce
😊 Expected Behavior
使用自定义总计后,该种交叉模型下,开启总计后,发现数据行展示异常为空,期望结果是能正常展示数据。
😅 Current Behavior
使用自定义总计后,该种交叉模型下,开启总计后,发现数据行展示异常为空。
💻 System information
The text was updated successfully, but these errors were encountered: