If you need more flexibility in creating rich diagram mashups than offered out of the box by web part connections, you can use the Visio Services JavaScript Mashup API. In this post we'll review the breadth of possibilities by the Visio Services Mashup API and show you how to get started coding with a few simple examples.
Visio's SpatialNeighbors property is useful for finding shapes that are nearby other shapes or that overlap other shapes. It can be used to programmatically answer the question "What did I drop my shape on top of?". This blog discusses the SpatialNeighbors property.