2
我使用Mike Bostock推薦的Topojson: list of differences between v0 and v1?將我的代碼從v0遷移到v1。Topojson v.0到v.1遷移困難
- Topojson_v0 - 正在工作。
- Topojson_v1 - 點標籤被關閉。
沒有其他更改。
我的數據是the same final_adms_France.json file。
什麼問題?如何使它工作?
評論:好像我有一個問題有:
.attr("transform", function(d) { return "translate(" + projection(d.coordinates) + ")"; })
出來的:
// Positioning: place-label
svg.selectAll(".place-label")
.data(topojson.object(fra, fra.objects.places).geometries)
.enter().append("text")
.attr("class", "place-label")
.attr("transform", function(d) { return "translate(" + projection(d.coordinates) + ")"; })
.attr("dy", ".35em")
.text(function(d) { if (d.properties.name!=="Paris"&&d.properties.name!=="Bremen"){return d.properties.name;} })
.attr("x", function(d) { return d.coordinates[0] > -1 ? 6 : -6; })
.style("text-anchor", function(d) { return d.coordinates[0] > -1 ? "start" : "end"; });
您是否嘗試過使用'd.geometry.coordinates'? –
工程。我以前試過'd.geometires.coordinates'。感謝Alex。我已經有一段時間了。 (注意:在答案字段中重新發布,所以我+1並驗證) – Hugolpz
因此,我的示例中的'd'類似於Bostock示例中的'point'。新手不容易! – Hugolpz