In my experience, the index passed to any D3 accessor function is always it's index in the DOM, relative to it's parent:

The workaround I've used for this scenario is to implement in the click-event either an object lookup or an array filter, matching on a unique ID.

Related Query

More Query from same tag