score:2

Accepted answer

You can use this:

line.y(function(d) { return d[selected]; });

This has nothing to do with D3, it's JavaScript syntax:

d.element1
d['element1']

var key = 'element1';
d[key]

all access the same property.


Related Query

More Query from same tag