benfred / venn.js

Area proportional Venn and Euler diagrams in JavaScript
MIT License
1.04k stars 218 forks source link

Incorrect placement #85

Closed nicoinn closed 7 years ago

nicoinn commented 7 years ago

I've noticed a problem in the placement of areas on the diagrams here:

https://nicoinn.github.io/venn.js/examples/intersection_tooltip.html with corresponding data here: https://github.com/nicoinn/venn.js/blob/gh-pages/examples/lastfm.jsonp

If you work the number out, there should be 3799 users in Phone and nothing else, so that the phone region should NOT be placed entirely inside any other area. Moreover, hovering over the entire phone area gives 137433 --- which is the number for the set [0,2], not [0].

benfred commented 7 years ago

So - the results here are an approximation process. Like I said in the 3rd and 4th paragraph of my blog post introducing this project:

The problem is that even for only 3 sets, its not always possible to position everything so that everything is area proportional to the set sizes. Try changing A=B=C=8 , AB=AC=4 and BC=0 in the above example to see what I mean about impossible layouts. There is no way to exactly satisfy all those constraints. Even worse is trying to layout Euler diagrams with 4+ sets: if there are no disjoint sets, its actually impossible to use circles to represent these set relations exactly.

I still want the best possible approximation even if its not possible to be perfect all the time. So I did the sensible thing here: define a function that measures how well a layout matches the desired overlaps - and then minimize that function numerically.

In your case, It doesn't look like there is a better layout for that data.