How to select unique values in d3.js from data

后端 未结 2 1836
醉梦人生
醉梦人生 2021-02-14 06:49

I am using the following code to populate my Combobox using d3.js

d3.csv(\"Results_New.txt\", function(data) {
dataset=data;
d3.select(\"#road\").selectAll(\"opt         


        
2条回答
  •  走了就别回头了
    2021-02-14 06:57

    Filter your data retaining unique keys only by d3.map

    d3.select("#road").selectAll("option")
        .data(d3.map(data, function(d){return d.roadname;}).keys())
        .enter()
        .append("option")
        .text(function(d){return d;})
        .attr("value",function(d){return d;});
    

提交回复
热议问题