Monday, December 6, 2021

To create dropdown list or select option in d3js (at runtime) programatically

 d3.select(#divColumnLeft)

    .append("select")

    .attr("name", "stationcode")

    .attr("id", "selectstationcode")

    .selectAll("myoptions")

    .data(data).enter()

    .append("option")

    .text(function(d){return d;})

    .attr('value', function(d){return d;});


d3.select("#selectStationCode")

    .on("change", function(d){

                var selectedOption = d3.select(this).property("value");

                                                });

No comments:

Post a Comment