Skip to content

🙏关于透视表中的维度配置及嵌套数据结构相关 #3174

@TheSunset

Description

@TheSunset

Describe the feature / 功能描述

部分配置

{
    "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 / 是

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions