有没有办法将聚合值传递给 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"
}
}
}

在这里看到它的实际效果。

最新更新