select 选项未使用 d3.js 显示?

select options are not being shown using d3.js?

我正在尝试使用 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;});

但是输出组合框中没有显示这些值。相反,组合框选项显示为空白 space。谁能告诉我如何显示这些值?是否必须将组合框放在 SVG 中?

我猜你的 csv 文件中的列名为 "detector-id"?

d.detector-id 无效。这被翻译为对象变量 d with 属性 detector minus variable id.

改用return d["detector-id"];

这是工作 code

Is it mandatory to put the combobox within a SVG?

您实际上并没有在 SVG 中放置组合框。我想你的意思是"is it mandatory to build the combobox with d3?"答案是否定的