You have a nested selection , i.e. you make a choice, and then choose based on that. This is also an explanation of the function in the argument .data()- it is nested below the first, so it can refer to it.
, .data(matrix). D3 - , .. . tr. , .data(), , (tr s). function(d) { return d; } , D3 . , D3 - , .