Conversation
Co-authored-by: Alexzjt <9548248+Alexzjt@users.noreply.github.com>
Co-authored-by: Alexzjt <9548248+Alexzjt@users.noreply.github.com>
|
@copilot 你的修改是错误的,以下面的代码为例。 import { PivotSheet, S2DataConfig, S2Options } from '@antv/s2';
const container = document.getElementById('container');
const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
values: ['number', 'price'],
valueInCols: true,
// 自定义指标属性层级顺序, 即 fields.values 的顺序 (从 0 开始)
customValueOrder: 0,
},
data: [
{
"number": 7789,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子",
"price": 1899
},
],
meta: [
{
field: 'number',
name: '数量',
},
{
field: "price",
name: "价格",
},
{
field: 'province',
name: '省份',
},
{
field: 'city',
name: '城市',
},
{
field: 'type',
name: '类别',
},
{
field: 'sub_type',
name: '子类别',
},
],
};
const s2Options: S2Options = {
width: 600,
height: 480,
cornerExtraFieldText: "度量",
totals: {
col: {
showGrandTotals: true,
showSubTotals: true,
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
},
row: {
reverseGrandTotalsLayout: true,
reverseSubTotalsLayout: true,
showGrandTotals: true,
showSubTotals: true,
subTotalsDimensions: ['price'],
}
}
};
const s2 = new PivotSheet(container, s2DataConfig, s2Options);
s2.render();请你重新思考,先查找 customValueOrder 在代码中的用法,再根据前面的案例思考并解决。 |
Co-authored-by: Alexzjt <9548248+Alexzjt@users.noreply.github.com>
Co-authored-by: Alexzjt <9548248+Alexzjt@users.noreply.github.com>
感谢指出问题!我重新分析了代码逻辑,发现之前的修复确实不正确。 问题根因是当 修复方案(commit 45909c0):
|
问题描述
当
customValueOrder=0时,多个数值列的总计表头被错误合并到一起。错误行为:总计节点的 ID 为
root[&]总计(总计被添加到度量值层级)期望行为:总计节点的 ID 应为
root[&]price[&]总计和root[&]number[&]总计(每个度量值下分别有总计)修复方案
add-totals.ts:在添加总计时增加
currentField !== EXTRA_FIELD的检查,避免在度量字段层级添加总计。build-gird-hierarchy.ts:修改
isFirstField的判断逻辑,使用fields.findIndex()找到第一个非 EXTRA_FIELD 的维度字段索引,确保总计是在第一个维度字段处添加。Solve the issue and close #3215
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.