Say if there is a table like this:
var data = [
['Orange', 'Orange', [6,3,3,2,5]],
['Apple', 'Red', [6,2,6,5,5]],
['Grape', 'Purple', [9,1,2,3,1]]
]
I'd like the strings to represented as strings, but the number array represented as a D3 line chart. If it's just text that I care about, I can selectAll
td
elements and insert some text.
var tcells = trows
.selectAll("td")
.data(function(d, i) { return d; })
.enter()
.append("td")
.text(function(d, i) { return d; });
The 3rd column is text so I'd like to update it with graphs or alternatively append another column of graphs. Say lines
is a function that creates a line graph, I would like to call lines()
as it passes data from the 3rd column for each row.
trows.selectAll("td")
.data(function(d) {return d[2]}) // scope out data from 3rd column
.enter()
.append("td")
//.call(lines([3,8,2,5,8,4])); // this works
.call(lines); // this doesn't
My D3 knowledge is spotty so I am not clear on how the data and the selection are passed.
Here is the full code: jsfiddle link