Chapter 45. Data Visualization with Venn Diagrams

In this chapter's case study, we show one way to use PHP to combine MySQL databases with graphic images. We build a complete system that starts with a database and uses the gd library to produce a kind of visualization of the data. The portions of the book we draw on for this are:

  • Part II: We use PHP to interrogate a MySQL database.

  • Chapter 42 (Graphics): Our end product is an image produced with the gd library.

  • Chapter 27 (Mathematics): We need a bit of trigonometry as we create the images.

Scaled Venn diagrams

The visualization we have in mind is something like the Venn diagram. If you've ever been in an academic setting where set intersection was being discussed, then you've probably seen these diagrams — they're the circles that may or may not have overlapping portions representing intersections.

We say "something like" the Venn diagram, because scale has no significance in a traditional Venn diagram. If you want to illustrate the fact that there are people who use both BeOS and Windows, then you might draw two circles of equal size (representing Windows users and BeOS users) that happen to have a region of overlap. In our version, which you might call a scaled or proportional Venn diagram, the sizes of both circles and intersections matter; the Windows/BeOS example would become one large circle and one much smaller circle, with an overlap ...

Get PHP6 and MySQL® 6 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.