🙏关于透视表中的维度配置及嵌套数据结构相关
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 220
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the feature / 功能描述
部分配置
```js
{
"fields": {
"rows": [
"province",
"city"
],
"columns": [
"type",
"sub_type"
],
"values": [
"number"
],
"valueInCols": true
},
"meta": [
{
"field": "number",
"name": "数量"
},
{
"field": "province",
"name": "省份"
},
{
"field": "city",
"name": "城市"
},
{
"field": "type",
"name": "类别"
},
{
"field": "sub_type",
"name": "子类别"
}
],
"data": [
{
"number": 7789,
"province": "浙江省",
"city": "杭州市",
"type": "家具",
"sub_type": "桌子"
},
{
"number": 2367,
"province": "浙江省",
"city": "绍兴市",
"type": "家具",
"sub_type": "桌子"
}
]
}
```
假如 `data`中的`city`是一个嵌套结构,比如`city:{"v1": "杭州市", id: 100}` ,那么` "rows": ["province", "city" ],`中,能否配置为嵌套结构中的 `city.id`,然后在 `meta`配置的`formatter`回调里 自定义设置展示的中文名称?
目前测试:
```
data配置
{
"number": 7789,
"province": "浙江省",
"city": {
"v1": "杭州市",
"id: : 100
},
"type": "家具",
"sub_type": "桌子"
}
fields 配置
"rows": ["province", "city" ]
meta配置
{
"field": "city",
"name": "数量",
formatter(value, data, meta) {
console.log(value);
// [object Object]
}
},
```
无法拿到 city 的配置数据。
测试二:
通过自定义RowCell ,在RowCell实例上也是无法拿到 配置数据。
我的问题起源于,通过api获取cell时的id,都是维度的中文名字拼起来的,比如 `const rowNode = s2.facet.getRowNodeById('root[&]四川省[&]成都市');`,我想把这个`id`定义为我的维度数据里对应的id。所以经过了上述尝试。
所以想问一下,有没有是实现的方案,或者后续有没有计划增加此功能呢?
### Design the API / API 设计
简单来说希望可以在现有的功能上,假如配置的field : row 的维度对应了一个数据中的嵌套结构,我希望可以在meta配置的 formatter里拿到这个数据,而不是 [object Object]。同样在自定义RowCell时,也希望可以拿到数据,类似DataCell一样。
### Are you willing to contribute? / 是否愿意参与贡献?
✅ Yes / 是
Contributor guide
Research direction
Start by reproducing the nested city data with rows configured as province and city, then inspect the formatter and custom RowCell behavior described in the issue. Done means the configured city.id can identify the dimension while formatter and RowCell receive the associated data for custom display or IDs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100