如何在d3.js .data()方法中使用变量
要使用d3.j绘制地图,我们使用以下代码:
G
.selectAll("path")
.data(topojson.feature(topology, topology.objects.MU3303906MU).features)
.join("path")
.attr("class", "state-county")
但是我想在.data(topojson.feature(topology,topology,objecty.object.mu3303906mu).features中)
)在必要时使用其他值更改MU3303906MU。
怎么可能?
我尝试了:
var CODEHERE = "MUXXXXXXXMU";
.data(topojson.feature(topology, topology.objects.CODEHERE).features)
or
.data(topojson.feature(topology, topology.objects.+ CODEHERE +).features) //syntax error
但是没有人可以。
To plot a map using D3.js we use the following code:
G
.selectAll("path")
.data(topojson.feature(topology, topology.objects.MU3303906MU).features)
.join("path")
.attr("class", "state-county")
But I'd like to use a variable inside .data(topojson.feature(topology, topology.objects.MU3303906MU).features)
to change MU3303906MU with other values when necessary.
How is it possible?
I tried:
var CODEHERE = "MUXXXXXXXMU";
.data(topojson.feature(topology, topology.objects.CODEHERE).features)
or
.data(topojson.feature(topology, topology.objects.+ CODEHERE +).features) //syntax error
But none worked.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论