I have been reading quite a bit on graphing libraries for Java and Javascript lately but I haven\'t found a good way to do what I want to do.
Essentially I have a hiera
Have you considered a 2-dimensional grid:
While this visualization method would normally be inferior to some of the more complicated ones mentioned so far, it has the virtue of actually being possible when you have thousands of elements and thousands of sets.
The trick will be to order the rows and columns in a way that puts the most information together in a way useful to the user. My instinct says that the problem you're trying to solve is to make the colored cells be as "bloblike" as possible—if each set of adjacent colored cells is called an "area", to have the least number of distinct areas and for them to have the fewest holes in them.
That is a very complicated problem in its own right, but could be at least partially solved by working up some adjacency factors for each set against every other set. What you're looking for are "islands" of closeness--so start with the pair of most alike sets, add them to the graph, and consider them a region. Recalculate your closeness numbers with the region replacing the pair it holds (averaging in some way?). Find the next most close pair of items (each item being a region or a set), and if that pair is within a certain threshold of closeness to any existing region in the graph, attach to one side of that region, otherwise create a new, separate region (again removing the pair's closeness values and recomputing for the region itself). Eventually, all sets will be added to regions, and all regions will be joined. Joining two regions can have four possibilities (flipping may be required), so which sides to attach in the graph could be calculated by the closeness of the sets on the 4 edges of the two regions.
While this may never give the optimal configuration, it should come up with something that has few regions compared to a random distribution.
Finally, some dynamic reordering might be useful, by allowing the user to select an interesting set or element, and use that as the seed for a completely rearranged graph, calculating each addition based on closeness to that element (and subsequently that region after being combined with another element), rather than overall lowest closeness of any.
Here is a diagram of the result, having done the above logic process on the example set of data in your question:
Deciding how to order the columns is complex, but basically you can get sort of reasonable results by moving columns to be adjacent when such a move won't disturb the colored block area of any already-added segments.
Additional thoughts:
I do not have your solution for getting the data in the proper format. Take a look at this javascript plugin created by MIT for building graphs, sigmajs. Haven't looked at the data it accepts, but may be worth a look.
Yes, this is a fairly well-studied problem. What you are describing is called a hypergraph. Each element can be represented as a vertex in a graph, and the sets are the hyperedges. The problem then becomes that of visualizing hypergraphs.
Unfortunately there isn't a perfect, generalized solution to this since even the simplest graphs can have complex visualizations.
If your sets are relatively small (< 5 elements), you can use a regular graph drawing library like graphviz. To do this, simply connect all pairs of vertices within each set and color them differently. This will yield a solution similar to this:
There are many approaches to this problem but personally, I'd draw sort of a Venn chart using dynamically generated SVG with a tool like Raphael JS and color it the way I want. Also, Raphael has api like Set that can enable you to give full detailed information about the elements and their relations. There SVG to Code converter will also likely help out in understanding how you can generate the SVG elements.
Alternatively you could, use tools like Venn charts:
which seems to be easily adaptable to this scenario. There's also Flotr2 which can create bubble charts:
or even Canvas Express.
A little more tweaking with any of the later tools will enable you to get it properly done...