我将一个 geojson 对象分配给投影的 fit 属性,如文档中所述:https://vega.github.io/vega/docs/projections/
我总是收到错误"不支持的参数对象:{"类型":"功能集合"...">
我分配的geojson对象如下:(我的源数据是topojson格式(
spec.projections[0].fit = topojson.feature(
mapData,
mapData.objects.topology
);
文档明确指出此参数应为 GeoJSON 功能或功能集合。我应该如何使用 fit 属性?
必须使用对数据对象的引用。
"data": [
{
"name": "counties",
"url": "data/us-10m.json",
"format": {"type": "topojson", "feature": "counties" }
}
],
"projections": [
{
"name": "projection",
"type": "mercator",
"fit": {"signal": "data('counties')"},
"size": {"signal": "[width, height]"}
}
]
下面是 VEGA 的示例,您可以在他们的编辑中进行测试。https://github.com/vega/vega/blob/master/test/specs-valid/map-fit.vg.json
另请注意"size"属性。没有它,合身就不会得到反映。