venn.js icon indicating copy to clipboard operation
venn.js copied to clipboard

labels overlap when circles don't overlap

Open mef opened this issue 11 years ago • 7 comments

There are situation when there is no overlap between Venn diagram circles, in such case the algoritm lays them out horizontally aligned. This causes labels to overlap, if they have a certain length.

Any tip on how to work around this?

mef avatar Nov 13 '14 14:11 mef

Can you provide the input that causes this? The labels should be wrapping on word breaks when they get too long now.

Details of this changes are here, but it should look something like: 9d49959e-2aed-11e4-80b6-c2b78aca55c9

when the labels get too long

benfred avatar Nov 13 '14 17:11 benfred

Problem occurs when the label is only one long word for a small circle. The wrapping logic uses space characters to split the label, so nothing wraps in such cases.

screenshot - 181114 - 12 39 05

mef avatar Nov 18 '14 11:11 mef

In case someone also has this problem and looks for a solution:

I've worked around the issue by shifting vertically the overlapping labels.

This method works:: https://blog.safaribooksonline.com/2014/03/11/solving-d3-label-placement-constraint-relaxing/, in our case it's better to use getBBox() to detect the overlap instead of simply comparing vertical positions.

mef avatar Dec 05 '14 16:12 mef

label issue One more label issue. A should come on outer circle. var sets = [ {sets: ['A'], size: 4},{sets: ['B'], size: 3},{sets: ['A','B'], size: 4}];

sumanparia avatar Mar 10 '15 07:03 sumanparia

Right now I'm sampling a bunch of points in the venn diagram, and then taking the average of all the points in each region to be the centre of that region (which is where the label is placed).

This works ok in a bunch of cases, but totally breaks down in situations like these. The problem here is the 'A' region is a crescent shape - and the centre of the crescent it is outside of itself (where the label is placed). I've some ideas in fixing this (like take the mediod point, instead of mean point - or if the point is outside its own region, then take average in polar coordinate space etc). I'll see if I can grab some time on the weekend to come up with a solution here.

benfred avatar Mar 10 '15 07:03 benfred

@sumanparia that issue with the labelling issue should be fixed by commit 3d281c9, output after that commit is:

screen shot 2015-05-12 at 11 30 34 pm

this still leaves the problem with labels being cut off, leaving open for now

benfred avatar May 13 '15 06:05 benfred

In case someone also has this problem and looks for a solution:

I've worked around the issue by shifting vertically the overlapping labels.

This method works:: https://blog.safaribooksonline.com/2014/03/11/solving-d3-label-placement-constraint-relaxing/, in our case it's better to use getBBox() to detect the overlap instead of simply comparing vertical positions.

Just wanted to add in case anyone came across this (or #61) and like me had trouble figuring it out, here's an example of how I got the above suggestion (minus getBBox) to work.

Also the site seems to be down; here's an archived link.

tessaSAC avatar Jun 04 '19 19:06 tessaSAC