Vega lite排名前10的主机根据字段得分之和降序

时间:2020-07-02 15:19:57

标签: vega-lite vega

我有这个示例数据

"values": [
  {"host": "host-one", "score": 70, date: 1593674604},
  {"host": "host-two", "score": 30, date: 1593674608},
  {"host": "host-three", "score": 12, date: 1593674615},
  {"host": "host-two", "score": 95, date: 1593674624},
  {"host": "host-three", "score": 1, date: 1593674633}    
]

在热图中,我必须基于y轴上每位主机的得分总和来显示前10位主机,这是我尝试了很多方法都没有成功,这是我上次尝试的方法:

 }
  transform: [
    {calculate: "datum.key.date", as: "date"}
    {calculate: "datum.key.host", as: "host"}
    {calculate: "datum.key.score", as: "score"}
    {
      window: [
        {op: "sum", field: "score", as: "score_order"}
      ]
    }
    groupby: ["host"]
  ]
  mark: {type: "rect", cornerRadius: 3}
  encoding: {
    x: {
      bin: {maxbins: 80}
      field: date
      type: temporal
    }
    y: {
      field: host
      type: ordinal
      sort: {field: "score_order", order: "descending"}
    }

关于我在做什么错的任何线索吗?

0 个答案:

没有答案