我试图使用d3.js在组合框中显示几个探测器的名称。我使用以下代码来显示数据。
d3.csv("Results_New.txt", function(data) {
//var data = d3.csv.parseRows(datatext);
d3.select("#road").selectAll("option")
.data(data).enter().append("option").text(function(d){return d.detector-id;}).attr("value",function(d){return d.detector-id;});
但是输出组合框中没有显示这些值。而是combox选项显示空白。任何人都可以给我这个想法如何显示价值观?是否必须将组合框放在SVG中?
答案 0 :(得分:0)
我猜你的csv文件中的列名为" detector-id"?
d.detector-id
无效。这被翻译为具有属性检测器减去变量id的对象变量d。
改为使用return d["detector-id"];
。
此处工作code。
是否必须将组合框放在SVG中?
你实际上并没有在SVG中放置一个组合框。我认为你的意思是"是否必须用d3构建组合框?"答案是否定的。