誰かが私に手を貸すことができるのだろうかと思っていました。Svgパスがコンソールに表示されますが、画面に表示されないのはなぜですか?
私が変換した以下のtopoJSONからシンガポールの地図をレンダリングしようとしています。私は、コンソール上で生成されたパスを参照しながら
<style>
path {
/*fill: #ccc;*/
stroke: rgba(12, 12, 12, 0.96);
stroke-linejoin: round;
}
</style>
<svg width="900" height="600"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/topojson.v2.min.js"></script>
<script>
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
// var projection = d3.geoAlbers();
var projection = d3.geoMercator()
.center([0, 5 ])
.scale(900)
.rotate([-180,0]);
var path = d3.geoPath(projection);
d3.queue()
.defer(d3.json, "data/sgtopo.json")
.await(ready);
function ready(error, sg){
if(error) throw error;
var topofeature = topojson.feature(sg, sg.objects["sg-"]);
svg.append("g")
.selectAll("path")
.data(topofeature.features)
.enter()
.append("path")
.attr("d", path);
}
</script>
</html>
:
以下は私のコードでページが空白のまま。 ご協力いただきありがとうございます。
私はこの問題を再生成できません(チャートはレンダリングされません)。ここでスニペットを作成するかjsfiddleでJSONファイルデータ用にダミーオブジェクトを使用できますか。 –
お返事いただきありがとうございます、感謝します。ここにjsfiddleがあります:https://jsfiddle.net/Lzx5rnzy/ – cookiedookie