WebDataRocks 透视网格的列顺序

问题描述

尝试使用 webdaTarocks 构建以月份为列的网格,问题是列按字母顺序排序(2020 年 4 月、2020 年 8 月、200 年 12 月,...)。是否可以选择按日期(200 年 12 月、2020 年 11 月、2020 年 10 月等)对列进行排序?

示例可在此处获得 https://codesandbox.io/s/nifty-stonebraker-7mf56?file=/src/App.tsx

解决方法

这可以通过向数据中添加一个定义数据类型的对象来实现。这是一个 explanation

在你的情况下,这个对象看起来像这样:

{
  "CONTRACT": {
    "type": "string"
  },"value": {
    "type": "number"
  },"date": {
    "type": "date string"
  },"name": {
    "type": "string"
  }
},{
  type: "CONTRACT",value: 217,date: "Dec 2020",name: "24"
},value: 725.84,name: "3 "
},...

此后,列应按日期排序。请注意,输入日期的格式应正确(符合 ISO 8601)。

可以在 options 中的 datePattern 的帮助下修改 WebDataRocks 中显示日期的方式。