Skip to content

Commit

Permalink
chore: 同步 master 到 alpha (#2378)
Browse files Browse the repository at this point in the history
Co-authored-by: JuZe <[email protected]>
Co-authored-by: Wenjun Xu <[email protected]>
Co-authored-by: Jinke Li <[email protected]>
Co-authored-by: NoobNot <[email protected]>
fix(layout): 修复隐藏结点时对父节点的布局计算错误 close #2355 (#2360)
fix(layout): 修复隐藏结点时对父节点的布局计算错误 close #2355
close #2362 (#2363)
fix(table-sheet): 明细表数据为空时错误的展示一行空数据 close #2255 (#2357)
fix(table-sheet): 明细表数据为空时错误的展示一行空数据 close #2255
fix: 列头绘制多列文本时错误的使用了数值单元格的样式 close #2359 (#2364)
fix: 修复分组汇总时,按汇总排序获取排序数据为空 (#2370)
  • Loading branch information
4 people authored Oct 23, 2023
1 parent 57ecedf commit 3918a1f
Show file tree
Hide file tree
Showing 46 changed files with 634 additions and 282 deletions.
19 changes: 18 additions & 1 deletion packages/s2-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# [@antv/s2-v1.51.0-alpha.1](https://github.com/antvis/S2/compare/@antv/s2-v1.50.0...@antv/s2-v1.51.0-alpha.1) (2023-09-14)
# [@antv/s2-v1.51.1](https://github.com/antvis/S2/compare/@antv/s2-v1.51.0...@antv/s2-v1.51.1) (2023-10-13)


### Bug Fixes

* **layout:** 修复隐藏结点时对父节点的布局计算错误 close [#2355](https://github.com/antvis/S2/issues/2355) ([#2360](https://github.com/antvis/S2/issues/2360)) ([c8d2c94](https://github.com/antvis/S2/commit/c8d2c94c21527ae52ece3485524d374d09b1cba7))
* **table-sheet:** 明细表数据为空时错误的展示一行空数据 close [#2255](https://github.com/antvis/S2/issues/2255) ([#2357](https://github.com/antvis/S2/issues/2357)) ([7751c49](https://github.com/antvis/S2/commit/7751c4968b69752243928cbcd2c50333b06b2c66))
* 列头绘制多列文本时错误的使用了数值单元格的样式 close [#2359](https://github.com/antvis/S2/issues/2359) ([#2364](https://github.com/antvis/S2/issues/2364)) ([4953b4e](https://github.com/antvis/S2/commit/4953b4e430f3c1857ce6648bcdc2493c37bb1092))

# [@antv/s2-v1.51.0](https://github.com/antvis/S2/compare/@antv/s2-v1.50.0...@antv/s2-v1.51.0) (2023-09-22)


### Features

* 对比值无波动时也显示灰色 ([#2351](https://github.com/antvis/S2/issues/2351)) ([12f2d02](https://github.com/antvis/S2/commit/12f2d0268d447ec99a1227ffedd5ed266d93e86b))
* 小计/总计功能,支持按维度分组汇总 ([#2346](https://github.com/antvis/S2/issues/2346)) ([20e608f](https://github.com/antvis/S2/commit/20e608f2447e9ffdb135d98e4cc7f39f1cfb308d))

# [@antv/s2-v1.50.0](https://github.com/antvis/S2/compare/@antv/s2-v1.49.2...@antv/s2-v1.50.0) (2023-09-09)


### Bug Fixes
Expand Down
140 changes: 140 additions & 0 deletions packages/s2-core/__tests__/bugs/issue-2359-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/**
* @description spec for issue #2359
* https://github.com/antvis/S2/issues/2359
* 明细表: 自定义列头误用 dataCell 样式
*/
import { pick } from 'lodash';
import { createTableSheet } from 'tests/util/helpers';
import { TableColCell, drawObjectText } from '../../src';
import type { S2CellType, S2Options } from '@/common/interface';

class TestColCell extends TableColCell {
drawTextShape() {
drawObjectText(this, {
values: [['A', 'B', 'C']],
});
}
}

const s2Options: S2Options = {
width: 300,
height: 480,
showSeriesNumber: true,
colCell: (...args) => new TestColCell(...args),
};

describe('Table Sheet Custom Multiple Values Tests', () => {
test('should use current cell text theme', () => {
const s2 = createTableSheet(s2Options);

s2.setTheme({
colCell: {
measureText: {
fontSize: 12,
},
bolderText: {
fontSize: 14,
},
text: {
fontSize: 20,
fill: 'red',
},
},
dataCell: {
text: {
fontSize: 30,
fill: 'green',
},
},
});
s2.render();

const mapTheme = (cell: S2CellType) => {
return cell
.getTextShapes()
.map((shape) => pick(shape.attr(), ['fill', 'fontSize']));
};

const colCellTexts = s2
.getColumnNodes()
.map((node) => mapTheme(node.belongsCell));

const dataCellTexts = s2.interaction
.getPanelGroupAllDataCells()
.map(mapTheme);

expect(colCellTexts).toMatchInlineSnapshot(`
Array [
Array [
Object {
"fill": "red",
"fontSize": 20,
},
Object {
"fill": "red",
"fontSize": 20,
},
Object {
"fill": "red",
"fontSize": 20,
},
],
Array [
Object {
"fill": "red",
"fontSize": 20,
},
Object {
"fill": "red",
"fontSize": 20,
},
Object {
"fill": "red",
"fontSize": 20,
},
],
]
`);

expect(dataCellTexts).toMatchInlineSnapshot(`
Array [
Array [
Object {
"fill": "#000000",
"fontSize": 12,
},
],
Array [
Object {
"fill": "#000000",
"fontSize": 12,
},
],
Array [
Object {
"fill": "#000000",
"fontSize": 12,
},
],
Array [
Object {
"fill": "green",
"fontSize": 30,
},
],
Array [
Object {
"fill": "green",
"fontSize": 30,
},
],
Array [
Object {
"fill": "green",
"fontSize": 30,
},
],
]
`);
});
});
28 changes: 28 additions & 0 deletions packages/s2-core/__tests__/spreadsheet/hidden-columns-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,34 @@ describe('SpreadSheet Hidden Columns Tests', () => {
expect(hiddenColumnsInfo).toBeTruthy();
expect(parentNode.hiddenChildNodeInfo).toEqual(hiddenColumnsInfo);
});
// https://github.com/antvis/S2/issues/2355
test('should render correctly x and width after hide columns when there is only one value for the higher-level dimension.', () => {
const nodeId = 'root[&]笔[&]义乌[&]price';

pivotSheet.setOptions({
style: {
colCfg: {
width: 100,
},
},
});
const data = pivotSheet.dataCfg.data.map((i) => ({ ...i, cost: 0 }));
pivotSheet.setDataCfg({
data,
fields: {
values: ['cost', 'price'],
},
});
pivotSheet.render();

pivotSheet.interaction.hideColumns([nodeId]);
const rootNode = pivotSheet
.getColumnNodes()
.find((node) => node.id === 'root[&]笔');

expect(rootNode.width).toEqual(300);
expect(rootNode.x).toEqual(0);
});

// https://github.com/antvis/S2/issues/2194
test('should render correctly when always hidden last column', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/s2-core/__tests__/unit/cell/header-cell-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe('header cell formatter test', () => {
label: '总计',
isTotals: true,
isGrandTotals: true,
isTotalRoot: true,
});

const rowSubTotalNode = new Node({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ describe('Pivot Dataset Test', () => {
getDimensionsWithoutPathPre(sortedDimensionValues[EXTRA_FIELD]),
).toEqual(['number', 'number', 'number', 'number']);
});

test('should get correctly empty dataset result', () => {
expect(dataSet.isEmpty()).toBeFalsy();
});
});

describe('test for query data', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { get, keys } from 'lodash';
import * as multiDataCfg from 'tests/data/simple-data.json';
import { assembleDataCfg, TOTALS_OPTIONS } from '../../util';
import { EXTRA_FIELD, VALUE_FIELD } from '@/common/constant';
import { type S2DataConfig, Aggregation } from '@/common/interface';
import { PivotSheet } from '@/sheet-type';
import { PivotDataSet } from '@/data-set/pivot-data-set';
import { Aggregation, type S2DataConfig } from '@/common/interface';
import { Store } from '@/common/store';
import { PivotDataSet } from '@/data-set/pivot-data-set';
import { PivotSheet } from '@/sheet-type';
import { getDimensionsWithoutPathPre } from '@/utils/dataset/pivot-data-set';

jest.mock('@/sheet-type');
Expand Down Expand Up @@ -835,50 +835,50 @@ describe('Pivot Dataset Total Test', () => {
});
test('should get correct boolean of dimensionValue is a query condition', () => {
expect(
dataSet.checkAccordQueryWithDimensionValue(
'浙江省[&]杭州市[&]家具[&]桌子',
{
dataSet.checkAccordQueryWithDimensionValue({
dimensionValues: '浙江省[&]杭州市[&]家具[&]桌子',
query: {
province: '浙江省',
city: 'A',
type: 'Abc',
},
dataCfg.fields.rows,
'province',
),
dimensions: dataCfg.fields.rows,
field: 'province',
}),
).toEqual(true);
expect(
dataSet.checkAccordQueryWithDimensionValue(
'浙江省[&]杭州市[&]家具[&]桌子',
{
dataSet.checkAccordQueryWithDimensionValue({
dimensionValues: '浙江省[&]杭州市[&]家具[&]桌子',
query: {
province: '浙江省',
city: '杭州市',
type: '家具',
},
dataCfg.fields.rows,
'sub_type',
),
dimensions: dataCfg.fields.rows,
field: 'sub_type',
}),
).toEqual(true);
expect(
dataSet.checkAccordQueryWithDimensionValue(
'浙江省[&]杭州市[&]家具[&]桌子',
{
dataSet.checkAccordQueryWithDimensionValue({
dimensionValues: '浙江省[&]杭州市[&]家具[&]桌子',
query: {
province: '浙江省',
city: '不是杭州市',
type: '家具',
},
dataCfg.fields.rows,
'sub_type',
),
dimensions: dataCfg.fields.rows,
field: 'sub_type',
}),
).toEqual(false);
expect(
dataSet.checkAccordQueryWithDimensionValue(
'浙江省[&]杭州市[&]家具[&]桌子',
{
dataSet.checkAccordQueryWithDimensionValue({
dimensionValues: '浙江省[&]杭州市[&]家具[&]桌子',
query: {
province: '浙江省',
},
dataCfg.fields.rows,
'sub_type',
),
dimensions: dataCfg.fields.rows,
field: 'sub_type',
}),
).toEqual(true);
});
test('get correct query list when query need to be processed', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ describe('Table Mode Dataset Test', () => {
test('should get correct meta data', () => {
expect(dataSet.meta).toEqual(expect.objectContaining([]));
});

test('should get correctly empty dataset result', () => {
expect(dataSet.isEmpty()).toBeFalsy();
});
});

describe('test for query data', () => {
Expand Down
6 changes: 6 additions & 0 deletions packages/s2-core/__tests__/unit/facet/table-facet-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { DataCell, DEFAULT_STYLE, type Fields, Node } from '@/index';
import { getFrozenLeafNodesCount } from '@/facet/utils';
import { SpreadSheet } from '@/sheet-type';
import { getTheme } from '@/theme';

const actualDataSet = jest.requireActual(
'@/data-set/base-data-set',
).BaseDataSet;

jest.mock('@/sheet-type', () => {
const container = new Canvas({
width: 100,
Expand Down Expand Up @@ -59,6 +61,9 @@ jest.mock('@/sheet-type', () => {
interaction: {
clearHoverTimer: jest.fn(),
},
dataSet: {
isEmpty: jest.fn(),
},
};
}),
};
Expand All @@ -77,6 +82,7 @@ jest.mock('@/data-set/table-data-set', () => {
getCellData: () => 1,
getFieldMeta: jest.fn(),
getFieldFormatter: actualDataSet.prototype.getFieldFormatter,
isEmpty: jest.fn(),
};
}),
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GetSortByMeasureValues Total Fallback Tests should sort by col total whit group 1`] = `
Array [
Object {
"$$extra$$": "price",
"$$value$$": "666",
"city": "杭州",
"price": "666",
"type": "",
},
Object {
"$$extra$$": "price",
"$$value$$": "999",
"city": "杭州",
"price": "999",
"type": "纸张",
},
]
`;
8 changes: 4 additions & 4 deletions packages/s2-core/__tests__/unit/utils/export/export-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ describe('PivotSheet Export Test', () => {
subTotalsDimensions: ['province'],
},
col: {
totalsDimensionsGroup: ['city', 'type'],
subTotalsDimensionsGroup: ['sub_type'],
totalsGroupDimensions: ['city', 'type'],
subTotalsGroupDimensions: ['sub_type'],
showGrandTotals: true,
showSubTotals: true,
subTotalsDimensions: ['type'],
Expand Down Expand Up @@ -291,8 +291,8 @@ describe('PivotSheet Export Test', () => {
subTotalsDimensions: ['province'],
},
col: {
totalsDimensionsGroup: ['city', 'sub_type', 'province'],
subTotalsDimensionsGroup: ['sub_type'],
totalsGroupDimensions: ['city', 'sub_type', 'province'],
subTotalsGroupDimensions: ['sub_type'],
showGrandTotals: true,
showSubTotals: true,
subTotalsDimensions: ['type'],
Expand Down
Loading

0 comments on commit 3918a1f

Please sign in to comment.