Accepted answer

You have slightly misunderstood what the second argument to is meant for.

That argument is used for object constancy by providing an id for the data and not as an accessor function, as in most other functions in the d3 API.

However, when a function is passed as the first argument, as is here:

.data(function(d) {
  return d;

then it does behave as an accessor function.

In your case, what you want is something along these lines:

var newData = [{"user":"jim","scores":[40,20,30,24,18,40]},

var myTable ="body").append("table")
  .data(regularData, function(d) {
    return d.user;
  .data(function(d) {
    return d.scores;
  .text(function(d) {
    return d;

I have used the user field as the id of the data and have returned the scores in the second call to data to create the td elements.

Related Query

More Query from same tag