🤔透视表关于sortFunc自定义排序方法的问题
lcmomo opened this issue · comments
🏷 Version
Package | Version |
---|---|
@antv/s2 | 1.54.7 |
@antv/s2-react | |
@antv/s2-vue |
Sheet Type
- [√ ] PivotSheet
- TableSheet
- GridAnalysisSheet
- StrategySheet
- EditableSheet
🖋 Description
透视表使用sortFunc自定义排序方法,对维度列进行排序,排序结果不符合预期
🔗 Reproduce Link
官网自定义排序示例https://s2-v1.antv.antgroup.com/zh/examples/analysis/sort#custom-sort-func
修改 sortParams如下,按照【城市】维度列进行升序排序
sortParams: [
{
// sortFieldId 为维度值时,params.data 为维度值列表
sortFieldId: 'city',
sortFunc: (params) => {
const { data } = params;
const sortData = data?.sort((a, b) => a?.localeCompare(b));
console.log("sortData: ", sortData)
return sortData;
},
}
],
😊 Expected Behavior
表格【城市】类维度数据按照【白山、长春、杭州、舟山】顺序排序
😅 Current Behavior
对度量列按照自定义排序方法,也会有同样的问题。console.log 打印出的排序后的data是按照预期排序的,但是展示在表格中的数据不符合预期排序。sortFunc方法中对data进行排序后是否还需要进行其他操作呢
透视表是按照父级分组的,你设置的是 'city', 所以只会改改第二层级的排序,第一层级是不变的,如果想达到你想要的效果,还需要你加上 'province' 的排序设定,文档:https://s2.antv.antgroup.com/manual/basic/sort/group