I'd like to make a table in D3. I am using this as an example.
I'm updating it to use the shorter, more clear syntax with =>
.
// create a cell in each row for each column
var cells = rows.selectAll('td')
.data(function (row) {
return columns.map(function (column) {
return {column: column, value: row[column]};
});
})
.enter()
.append('td')
.text(function (d) { return d.value; });
I would like to turn that into something like this.
// create a cell in each row for each column
var cells = rows.selectAll("td")
.data(d => columns.map(i =>
{column: i, value: d[i]}
))
.enter()
.append("td")
.text(d => d.value)
But, it gives me an error that says SyntaxError: unexpected token: ':'
. Is it possible to pass a dictionary back with the =>
symbol?