# Clickable Bounded Diagram

Suppose I make a BoundedDiagram via the following code

Needs["ComputationalGeometry"];
data2D = RandomReal[{0, 10}, {10, 2}];
b1 = {{0, 0}, {11, 0}, {11, 11}, {0, 11}};
convexhull = ConvexHull[data2D];
delval = DelaunayTriangulation[data2D];
{vorvert, vorval} = VoronoiDiagram[data2D];
{dvert1, dval1} = BoundedDiagram[b1, data2D, delval, convexhull];
DiagramPlot[data2D, dvert1, dval1]


How would I go about making each region clickable, i.e. open some link that I associated with the data?

-- Edit:

I should note, all I really want is a to be able to click on regions of a Voronoi-Like diagram, it doesn't have to be done via BoundedDiagram, this is just my first attempt at doing that ... (and is basically straight from the documentation.)

-
That code does not work for me. –  Pickett Jul 11 '13 at 3:40
@Anon - Sorry, it's probably because I forgot to add the 'Needs' statement there; this question is within the ComputationalGeometry package. –  Noon Silk Jul 11 '13 at 3:41
Yes, that was it. :) –  Pickett Jul 11 '13 at 3:42

This will get you started:

nf = Nearest[data2D -> Automatic];
ClickPane[DiagramPlot[data2D, dvert1, dval1], (foo = nf[#]) &]
Dynamic@foo


Click on any region and foo is set equal to that region. The ClickPane function (foo = nf[#]) & can be any function. The NearestFunction given by nf returns the index of the point in data2D nearest the mouse click, whose coordinates are passed to the argument # of the ClickPane function. That index is same as the index of the region.

A similar approach can be taken for any polygonal tiling, except Nearest` works only for a Vononoi. In other tilings, you have to write a function to find the polygon containing the mouse click. This question can give you a start on that, if desired.

-
Thank's alot! (Extra letters to pass 15 character limit.) –  Noon Silk Jul 11 '13 at 4:42