有没有办法将聚合值传递给 Vega Lite 中简单直方图上的工具提示编码

Is there a way to pass the aggregated value to the tooltip encoding on a simple histogram in Vega Lite

我想在 Vega Lite 中以简单的方式将计数值添加到工具提示中的简单直方图?

像这样:

{
  "data": {
    "url": "data/movies.json"
  },
  "mark": "bar",
  "encoding": {
    "tooltip": [
      {
        "field":  "Count of Records",
        "type": "quantitative"
      }
    ],
    "x": {
      "bin": true,
      "field": "IMDB_Rating",
      "type": "quantitative"
    },
    "y": {
      "aggregate": "count",
      "type": "quantitative"
    }
  }
}

似乎没有办法在工具提示编码中引用聚合的 y 编码。

工具提示与其他编码一样都是编码;您可以将相同的参数传递给您对 y 编码所做的工具提示:

{
  "data": {
    "url": "data/movies.json"
  },
  "mark": "bar",
  "encoding": {
    "tooltip": [
      {
        "aggregate": "count",
        "type": "quantitative"
      }
    ],
    "x": {
      "bin": true,
      "field": "IMDB_Rating",
      "type": "quantitative"
    },
    "y": {
      "aggregate": "count",
      "type": "quantitative"
    }
  }
}

查看实际效果 here