javascript - Insert child elements in d3.js -


i trying create table using d3.js, td elements not nesting inside tr.

this trying create:

        <table>             <tr>                 <td>name</td>                 <td>value</td>             </tr>         </table> 

this i've tried:

    var mytable = d3.select("#mytable")      var mytablerow = mytable.selectall("tr")         .data(mydata);      mytablerow.enter()         .append("tr")         .insert("td", ":first-child")         .html(function(d) {             return d.name;         })         .insert("td", ":first-child")         .html(function(d) {             return d.value;         }); 

however, each td not nest inside tr.

var mytable = d3.select("#mytable")  var mytablerow = mytable.selectall("tr")     .data(mydata)     .enter()     .append("tr")  mytablerow.append("td", ":first-child")     .html(function (d) {         return d.name;     }) mytablerow.append("td", ":first-child")     .html(function (d) {         return d.value;     }); 

var mydata = [    { name: 'a', value: 1 },    { name: 'b', value: 2 },  ]    var mytable = d3.select("#mytable")    var mytablerow = mytable.selectall("tr")          .data(mydata)          .enter()          .append("tr")    mytablerow.append("td", ":first-child")    .html(function (d) {       return d.name;    })  mytablerow.append("td", ":first-child")    .html(function (d) {       return d.value;    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>  <table id="mytable">  </table>


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -