我修改了这个示例Vega-Lite地图图https://vega.github.io/vega-lite/examples/geo_trellis.html,但没有显示任何内容,也没有错误。
这是代码
"transform": [
{
"lookup": "id",
"from": {
"data": {
"url": "data/us-10m.json",
"format": {"type": "topojson", "feature": "states"}
},
"key": "id"
},
"as": "geo"
}
],
"projection": {"type": "albersUsa"},
"mark": "geoshape",
"encoding": {
"shape": {"field": "geo", "type": "geojson"},
"color": {"field": "count", "type": "quantitative"}
}
Open the Chart in the Vega Editor
我不确定可能是什么错误。感谢您的帮助!
答案 0 :(得分:1)
您的数据包含缺少"id"
条目的行,这导致联接数据中的空geo
条目。如果您滤除这些无效值,则对于定义的行(vega editor),它会按预期工作:
"transform": [
{"filter": "isValid(datum.id)"},
{
"lookup": "id",
"from": {
"data": {
"url": "data/us-10m.json",
"format": {"type": "topojson", "feature": "states"}
},
"key": "id"
},
"as": "geo"
}
],