Giter Club home page Giter Club logo

venn.js's Introduction

venn.js Build Status Downloads

A javascript library for laying out area proportional venn and euler diagrams.

Details of how this library works can be found on the blog post I wrote about this. A follow up post discusses testing strategy and algorithmic improvements.

Installing

If you use NPM, npm install venn.js. Otherwise, download the latest release.

Usage

This library depends on d3.js to display the venn diagrams.

Simple layout

To lay out a simple diagram, just define the sets and their sizes along with the sizes of all the set intersections.

The VennDiagram object will calculate a layout that is proportional to the input sizes, and display it in the appropriate selection when called:

var sets = [ {sets: ['A'], size: 12}, 
             {sets: ['B'], size: 12},
             {sets: ['A','B'], size: 2}];

var chart = venn.VennDiagram()
d3.select("#venn").datum(sets).call(chart);

View this example

Changing the Style

The style of the Venn Diagram can be customized by using D3 after the diagram has been drawn. For instance to draw a Venn Diagram with white text and a darker fill:

var chart = venn.VennDiagram()
d3.select("#inverted").datum(sets).call(chart)
            
d3.selectAll("#inverted .venn-circle path")
    .style("fill-opacity", .8);

d3.selectAll("#inverted text").style("fill", "white");

View this example, along with other possible styles

Dynamic layout

To have a layout that reacts to a change in input, all that you need to do is update the dataset and call the chart again:

// draw the initial diagram
var chart = venn.VennDiagram()
d3.select("#venn").datum(getSetIntersections()).call(chart);

// redraw the diagram on any change in input
d3.selectAll("input").on("change", function() {
    d3.select("#venn").datum(getSetIntersections()).call(chart);
});

View this example

Making the diagram interactive

Making the diagram interactive is basically the same idea as changing the style: just add event listeners to the elements in the venn diagram. To change the text size and circle colours on mouseover:

d3.selectAll("#rings .venn-circle")
    .on("mouseover", function(d, i) {
        var node = d3.select(this).transition();
        node.select("path").style("fill-opacity", .2);
        node.select("text").style("font-weight", "100")
                           .style("font-size", "36px");
    })
    .on("mouseout", function(d, i) {
        var node = d3.select(this).transition();
        node.select("path").style("fill-opacity", 0);
        node.select("text").style("font-weight", "100")
                           .style("font-size", "24px");
    });

View this example

Adding tooltips

Another common case is adding a tooltip when hovering over the elements in the diagram. The only tricky thing here is maintaining the correct Z-order so that the smallest intersection areas are on top, while still making the area that is being hovered over appear on top of the others:

// draw venn diagram
var div = d3.select("#venn")
div.datum(sets).call(venn.VennDiagram());

// add a tooltip
var tooltip = d3.select("body").append("div")
    .attr("class", "venntooltip");

// add listeners to all the groups to display tooltip on mouseover
div.selectAll("g")
    .on("mouseover", function(d, i) {
        // sort all the areas relative to the current item
        venn.sortAreas(div, d);

        // Display a tooltip with the current size
        tooltip.transition().duration(400).style("opacity", .9);
        tooltip.text(d.size + " users");
        
        // highlight the current path
        var selection = d3.select(this).transition("tooltip").duration(400);
        selection.select("path")
            .style("stroke-width", 3)
            .style("fill-opacity", d.sets.length == 1 ? .4 : .1)
            .style("stroke-opacity", 1);
    })

    .on("mousemove", function() {
        tooltip.style("left", (d3.event.pageX) + "px")
               .style("top", (d3.event.pageY - 28) + "px");
    })
    
    .on("mouseout", function(d, i) {
        tooltip.transition().duration(400).style("opacity", 0);
        var selection = d3.select(this).transition("tooltip").duration(400);
        selection.select("path")
            .style("stroke-width", 0)
            .style("fill-opacity", d.sets.length == 1 ? .25 : .0)
            .style("stroke-opacity", 0);
    });

View this example

Released under the MIT License.

venn.js's People

Contributors

adamferguson avatar ben-pr-p avatar benfred avatar danielyule avatar hypercubed avatar jonathanwyatt16 avatar jpiper avatar keqingrong avatar mpelikan avatar sedenardi avatar shprink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

venn.js's Issues

margin problem

I'm having issues in some diagrams where labels are long and don't containt spaces (15 characters), so text doesn't get wrapped and part of it gets hidden outside of the SVG's area. Margins in the svg should fix this problem, but are not supported by venn.js.

Also, I need to specify other attributes to the svg element, like viewbox and preserveAspectRatio.

It seems more logical to me to pass a selector to an svg element to venn.js, instead of having venn.js create the svg element itself. What do you think?

I've refactored in Mango-information-systems/venn.js@6dd277608c6, let me know if I should send you a PR.

P.S.: Great work! Thanks for creating this library.

Two set overlap sublable showing even when contained within three set overlap

screen shot 2015-10-05 at 5 15 27 pm

Here, you can see that the 1 opinions is underneath Test Platform 3. There are actually 2 sublabels there โ€“ one for the intersection of Test Platform 3 and 1, and the other form 3 and 2.

I suppose what is needed is a recognition that 3 shares no elements with 2 that it doesn't also share with 1, and vice versa. Their entire <g> elements could be deleted.

It could be done by asking, "if there area of this intersection is fully contained within an intersection that has more sets, delete me".

What do you think?

Can't recognize hover on triple intersection

With the default order that the g elements are laid out, when I hover over the triple intersection center it shows that I'm hovering over one of the double intersections, shown here. (My mouse was not included in the screen shot, but it's in the triple intersection center.

screen shot 2015-09-30 at 4 50 55 pm

However, when I change the order of the g elements, it properly recognizes the hover. (mouse in the same place).

screen shot 2015-09-30 at 4 51 11 pm

I could have Javascript rearrange the g elements after the fact, but that would be inelegant and may cause a temporary flash of the elements on the screen.

Would it be possible to have the g elements laid out in the number of sets order even if they are not all added at the same time (some are adding with an update)?

Truncated labels support

Anything built in at this point to truncate long labels? I put in some external JS logic after calling Venn.VennDiagram() to truncate strings based on the diameter of the circle and the label font size but it seems to bounce back and forth from the truncated string to the full label because of calculations in the actual venn.js library

AโˆฉBโˆฉ(!C) highlight

I want to start off by saying thank you for creating such an awesome library! I am looking to create visualizations that will allow me to light up AโˆฉBโˆฉ(!C), like that shown in the screenshot below.

image

Any chance this is already in the works? Thanks again!

Easiest way to add more text below label

Hi โ€“ I'd like to add some more text below each label (a little reference to the contents of each circle).

Is there a way to do this without modifying the code?

Understanding layering

Hi !

First of all, thank you for this plugin ! It is really great and easy to work with !

I have a question about the way your plugin (or is it D3 ?) layers the svg elements. I have 3 overlapping circles, A, B and C.

var sets = [{
         sets: ['A'],
         size: 1000
      }, {
         sets: ['B'],
         size: 800
      }, {
         sets: ['C'],
         size: 300
      }, {
         sets: ['A', 'B'],
         size: 800
      }, {
         sets: ['A', 'C'],
         size: 300
      }, {
         sets: ['B', 'C'],
         size: 300
      }, {
         sets: ['A', 'B', 'C'],
         size: 300
      }];

They are displayed like that and that's perfectly what I had in mind.

capture d ecran 2015-06-23 a 13 12 23

My problem is with the order of the elements in the DOM. I need to be able to display a tooltip on hover for each circle so I need C to be on top of B, both of them on top of A, yet, they arrive in a totally different order :

<g class="venn-area venn-circle venn-sets-B"></g>
<g class="venn-area venn-circle venn-sets-C"></g>
<g class="venn-area venn-circle venn-sets-A"></g>
<g class="venn-area venn-intersection venn-sets-A_B"></g>
<g class="venn-area venn-intersection venn-sets-A_C"></g>
<g class="venn-area venn-intersection venn-sets-B_C"></g>
<g class="venn-area venn-intersection venn-sets-A_B_C"></g>

Is there any way to force the way they are layered so that they always appear in the following order ?

<g class="venn-area venn-circle venn-sets-A"></g>
<g class="venn-area venn-circle venn-sets-B"></g>
<g class="venn-area venn-circle venn-sets-C"></g>
<g class="venn-area venn-intersection venn-sets-A_B"></g>
<g class="venn-area venn-intersection venn-sets-A_C"></g>
<g class="venn-area venn-intersection venn-sets-B_C"></g>
<g class="venn-area venn-intersection venn-sets-A_B_C"></g>

Thank you very much !

Provide pre-transpiled code on npm

Thanks for this wonderful little tool!

Do you think it'd be possible to provide the npm version in ES5? Most anyone using this from within webpack likely has a setup similar to

{
  test: /\.js?$/,
  exclude: /(node_modules|bower_components)/,
  loader: 'babel?presets[]=es2015' // etc.
}

... because there is an unspoken expectation that anything inside node_modules doesn't use export from lines etc.

Not a big deal, but would be nice not to have to mess with the webpack config for just this one package.

Glitch intersecting 3 sets of 4

I was creating a Venn diagram depicting two sets(A,C) intersecting with one set(D) with one separated set (total of 4), but {set: [2,3], size:1} isn't applied.

var sets = 
    [
    {label: "A", size: 20}, {label: "B", size: 10},
    {label: "C", size: 10}, {label: "D", size: 10}
    ],
    overlaps = [
        {sets: [0,1], size: 0},
        {sets: [0,2], size: 0},
        {sets: [0,3], size: 1},
        {sets: [1,2], size: 0},
        {sets: [1,3], size: 0},
        {sets: [2,3], size: 1},
        {sets: [0,1,2], size: 0},
        {sets: [0,1,3], size: 0},
        {sets: [0,2,3], size: 0}
    ];

Below is an exact code.
http://fiddle.jshell.net/fkiller/qfc5xtbk/4/

With set of 3(A,C,D), it works fine.

http://fiddle.jshell.net/fkiller/qfc5xtbk/6/

Error: Invalid or corrupt jarfile venn.js

Hi!

I am pretty new to java. I am getting this error when trying to run this program. Do I need to install it in some way? How could make it work?

Thank you very much in advance!

Return coordinates and equations for circles

I'm using TikZ+LaTeX to plot figures and it would be terrific if there was a way to return the coordinates and radii of the circles produced by the script, or just an entry in the readme explaining how to return those aspects from the current script.

Error

I get an error - Uncaught initial bisect points must have opposite signs

My set and overlap variables.

var sets = [{label: "A", size: 61143}, {label: "B", size: 2713}, {label: "C", size: 3399}],
overlaps = [{sets: [0,1], size: 2713}, {sets: [0,2], size:3399}, {sets: [1,2], size:2495}, {sets:[0,1,2], size: 100}];

Won't draw non-intersecting set; "Need overlap data for set..."

Hi Ben,

Great library. Using it here to great effect, but when I pass in data with a set that has no overlaps, it doesn't draw. It throws the "Need overlap data for set..." error.

The interactive example on your blog post draws them fine if you set all the intersections to 0. So, I'm not quite sure what I'm doing wrong.

I am using the version of the library before the new_api change, so I'm not sure if this issue still exists.

I followed this example: https://github.com/benfred/venn.js/blob/80148b786a74cbab3a29895c879dff0891c4975f/examples/intersection_tooltip.html

Any help would be great! Thanks

Always need to specify overlap information

Hi,

This is more a question than an issue really. Do I need to specify overlap information for every possible combination? I'm working with a lot of data, but not necessary a lot of overlap. Is there any way that I don't need to specify the overlap for every possible combination, only for the ones that do overlap? When I don't give information about the overlap of a certain combination, I get the error message "Need overlap information for set {"x":10000000000,"y":10000000000,"size":1,"radius":0.5641895835477563}".

Thanks in advance

Layout of circles goes horizontal when multiple large circles should be positioned next to a small circle

Here's the code that renders a diagram that demonstrates the problem:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="d3.js"></script>
<script src="venn.js"></script>
<script type="text/javascript">
 $(document).ready(function() {
   var sets = [{"id":1,"label":"0","size":1958,"radius":44.358639953060134,"y":151.78206648466204,"x":296.0772270776158},{"id":2,"label":"1","size":1856,"radius":43.18777840062035,"y":151.78206648466204,"x":208.53080872393528},{"id":3,"label":"2","size":297,"radius":17.27627478492941,"y":151.78206648466204,"x":165.6369749319174},{"id":4,"label":"3","size":17281,"radius":131.78206648466204,"y":151.78206648466204,"x":472.21793351533796},{"id":5,"label":"4","size":4301,"radius":65.744072016603,"y":151.78206648466204,"x":85.744072016603}];
   var overlaps = [{"id":1,"sets":[2,0],"size":123},{"id":2,"sets":[2,1],"size":139},{"id":4,"sets":[2,3],"size":92},{"id":5,"sets":[2,4],"size":12},{"sets":[0,0],"size":0},{"sets":[0,1],"size":0},{"sets":[0,3],"size":0},{"sets":[0,4],"size":0},{"sets":[1,0],"size":0},{"sets":[1,1],"size":0},{"sets":[1,3],"size":0},{"sets":[1,4],"size":0},{"sets":[3,0],"size":0},{"sets":[3,1],"size":0},{"sets":[3,3],"size":0},{"sets":[3,4],"size":0},{"sets":[4,0],"size":0},{"sets":[4,1],"size":0},{"sets":[4,3],"size":0},{"sets":[4,4],"size":0}];
   var combined = venn.venn(sets, overlaps);
   var diagram = venn.drawD3Diagram(d3.select('#overlap-chart'), combined, $('#overlap-chart').width(), 375);});
</script>

<div id="overlap-chart" style="width: 624px; height: 374px;"></div> 

It should be placed in a directory with venn.js and d3.js.

My goal is to display the relationships between one circle (the "pivot"), and all the other circles. In this diagram, the pivot is circle 2. In the overlaps variable, set 2 has non-zero overlaps with all the other circles, and all the other circle circles have zero overlaps with each other (because we only want to see the relationship between the pivot and the others). But when the diagram renders, all the circles are placed in a single horizontal row, instead of grouping them around circle 2.

This appears to happen when the pivot is too small. In this example, if you make the size of set 2 50000 instead of 297, the circles are laid out properly (but of course no longer accurately reflect the size of each set).

Is this intentional behavior? I can see doing this if the circle was so small that you couldn't fit the larger circles around it, but it seems like there's plenty of room here.

intuitive way to change fill colors.

I think it would be good to have some sort of functionality maybe in the sets you pass to venn.js to have a way to use custom colors for venn sections something like:
{'sets': [0], 'label': 'Some Section', 'size': 16, style: 'Some style stuff here'}, or actually specify with css element you want {'sets': [0], 'label': 'Some Section', 'size': 16, fill: 'Some style stuff here'}, . Right now its a pretty cumbersome process to change colors it feels too dirty to me to change through d3.select('g').style('...') the way I've implemented it is actually just changing the source which feels... dirtier to me ๐Ÿ˜„

I actually implemented some functionality where you can just pass fill/stroke to each set and that will set them at run time instead of after graph is rendered to eliminate repaints. If you're interested I could open a PR with my changes in. Also open to going the direction of having just a wildcard 'style' property in each set

Run a JavaScript linter on the code

Someone copied venn.js into a project and it started getting covered with ESLint that we use in our test pipeline. The linter pointed out that there's an undefined variable here: https://github.com/benfred/venn.js/blob/master/venn.js#L935

We'll import the module with npm as should have been done initially, but just want to point out that undefined variable could be a problem. Maybe it's not right now because the classicMDSLayout function gets never gets called?

Don't use the set name as a class

I have a problem with it because if one of the set has a space it will add a couple of classes, e.g:
This set my set will render a circle with this classes venn-area venn-circle venn-sets-my set.
.set should be here really.

I have a couple of solutions:

Exposing the label function https://github.com/benfred/venn.js/blob/master/src/diagram.js#L135-L142

Or, better, add an attribute instead of a class (at https://github.com/benfred/venn.js/blob/master/src/diagram.js#L69-L73).
It would be replacing this:

var enter = nodes.enter()
    .append('g')
    .attr("class", function(d) {
        return "venn-area venn-" +
            (d.sets.length == 1 ? "circle" : "intersection") +
            (" venn-sets-" + d.sets.join("_"));
    });

by

var enter = nodes.enter()
    .append('g')
    .attr("class", function(d) {
        return "venn-area venn-" +
            (d.sets.length == 1 ? "circle" : "intersection");
    })
    .attr("data-venn-sets", function(d) {
        return d.sets.join("_");
    });

Legends

Can we add a legends at right side to venn diagram ?

Diagrams with small overlaps

Thanks for a really helpful bit of code. I've been using it in a project with good results so far, but ran into some issues with small overlaps in 3-set diagrams. Are there some 3 set venn diagrams that are just impossible? (I wish my math skills were more advanced).

for example:
var sets = [{label : 'A', size : 100},
{label : 'B', size: 100},
{label : 'C', size : 100}],
overlaps = [
{sets : [0,1], size:8},
{sets : [0,2], size:4},
{sets : [1,2], size:4},
{sets : [0,1,2], size:2}
];

This produces:
vennwithsmalloverlap

But it's representing an empty space instead of an overlap between [0,1,2].

Do 3 set venn diagrams become impossible at this scale?

Thanks for your help!
Joe

labels overlap when circles don't overlap

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?

Can i make all possible combinations in JSON array sets;

When i change the code of JSON array to combine 3 companies, that is Radiohead, Bach and Eminem i.e., [0,7,4] sets in JSON array, the changes of new intersection among these 3 companies does not reflect in the Venn diagram.
the changes in the JSON array is as follows ~~> " {"sets": [0, 4, 7], "size": 110}, "

please help me understand if there is any possibility that may overcome the above issue ?

A possible method of displaying the elements in a mathematically meaningful way

I am thinking of a display in which each of the elements contained within the sets have their own little circles, and the arrangement of the elements means something about the data.

It would require a user supplied distance function such that for every pair of elements it is possible to determine a desired distance between them.

So, you've got your sets:

A = [1, 2, 3, 4]
B = [3, 4, 5, 6]

And your distance function:

distanceBetweenElements(el1, el2): el1 - el2

The desired result would be two circles with one intersection area and 6 circles with 1-6 on them inside their respective places in the Venn Diagram. And, the layout of these 6 circles is such that the visual distance between el1 and el2 is the best possible approximation of the result of the distance function.

So, you would expect 2 and 5 to be closer to the intersection area of A and B than 1 and 6.

This is a more complicated optimization problem, but the work is significantly reduced by the fact that the number of possible places an element can go is limited by the arrangements of the sets โ€“ one only needs to position elements in relation to other elements in the same intersection area, not all elements.

To simplify it further, an aggregate distance function could be used

distanceBetweenElAndSet(el, set): 
     average distance between (el, otherEl) for otherEl in set

Then there are as many smaller optimization problems as there are meaningful set intersections.

Eh?

Text labels of two circles can overlap

I've encountered a situation where two pieces of text can overlap each other when their circles get drawn in a similar position.

venn

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script src="d3.js"></script><script src="venn.js"></script><script type="text/javascript">$(document).ready(function() {    var sets = [{"id":40,"label":"HBO","size":1792283,"radius":167.2,"y":187.2,"x":187.2},{"id":42,"label":"Game of Thrones","size":1210069,"radius":137.3845982071701,"y":187.2,"x":225.56428991864962}];    var overlaps = [{"id":40,"sets":[1,0],"size":1186304}];    var combined = venn.venn(sets, overlaps);    var diagram = venn.drawD3Diagram(d3.select('#overlap-chart'), combined, $('#overlap-chart').width(), 375);});</script><div id="overlap-chart" style="width: 624px; height: 374px;"></div> 

venn.js Cannot read property 'circle' of null

I have this dataset (a bit long, attach at the bottom), where it causes venn.js Cannot read property 'circle' of null error. at arcArea += circleArea(arc.circle.radius, arc.width);
I printed out the buggy loop data, it looks something like this:
innerPoints = [{...parentIndex: [0, 2]...}, {...parentIndex: [1, 2]...}, {...parentIndex: [0, 2]...}, {...parentIndex: [1, 2]...}, {...parentIndex: [1, 3]...}, {...parentIndex: [1, 3]...}
When it decides to nest-loop the first and last element of the list, it can't find matching index and arc will end up with null, causing the arcArea += circleArea(arc.circle.radius, arc.width); to fail.
A quick fix is to add a conditional to avoid updating arcArea when arc is null, although I have no clue if this breaks the mathematics.
Can you please have a look at this? Many thanks.
The dataset


var sets = [{ sets: ['a'], size: 226},
            { sets: ['b'], size: 733},
            { sets: ['c'], size: 279},
            { sets: ['d'], size: 332},
            { sets: ['e'], size: 244},
            { sets: ['f'], size: 650},
            { sets: ['a','b'], size: 214},
            { sets: ['a','c'], size: 119},
            { sets: ['a','d'], size: 187},
            { sets: ['a','e'], size: 155},
            { sets: ['a','f'], size: 186},
            { sets: ['b','c'], size: 202},
            { sets: ['b','d'], size: 332},
            { sets: ['b','e'], size: 244},
            { sets: ['b','f'], size: 415},
            { sets: ['c','d'], size: 127},
            { sets: ['c','e'], size: 103},
            { sets: ['c','f'], size: 191},
            { sets: ['d','e'], size: 244},
            { sets: ['d','f'], size: 222},
            { sets: ['e','f'], size: 149},
            { sets: ['a','b','c'], size: 117},
            { sets: ['a','b','d'], size: 187},
            { sets: ['a','b','e'], size: 155},
            { sets: ['a','b','f'], size: 179},
            { sets: ['a','c','d'], size: 116},
            { sets: ['a','c','e'], size: 100},
            { sets: ['a','c','f'], size: 104},
            { sets: ['a','d','e'], size: 155},
            { sets: ['a','d','f'], size: 170},
            { sets: ['a','e','f'], size: 139},
            { sets: ['b','c','d'], size: 127},
            { sets: ['b','c','e'], size: 103},
            { sets: ['b','c','f'], size: 171},
            { sets: ['b','d','e'], size: 244},
            { sets: ['b','d','f'], size: 222},
            { sets: ['b','e','f'], size: 149},
            { sets: ['c','d','e'], size: 103},
            { sets: ['c','d','f'], size: 109},
            { sets: ['c','e','f'], size: 88},
            { sets: ['d','e','f'], size: 149},
            { sets: ['a','b','c','d'], size: 116},
            { sets: ['a','b','c','e'], size: 100},
            { sets: ['a','b','c','f'], size: 103},
            { sets: ['a','b','d','e'], size: 155},
            { sets: ['a','b','d','f'], size: 170},
            { sets: ['a','b','e','f'], size: 139},
            { sets: ['a','c','d','e'], size: 100},
            { sets: ['a','c','d','f'], size: 103},
            { sets: ['a','c','e','f'], size: 97},
            { sets: ['a','d','e','f'], size: 139},
            { sets: ['b','c','d','e'], size: 103},
            { sets: ['b','c','d','f'], size: 109},
            { sets: ['b','c','e','f'], size: 88},
            { sets: ['b','d','e','f'], size: 149},
            { sets: ['c','d','e','f'], size: 88},
            { sets: ['a','b','c','d','e'], size: 100},
            { sets: ['a','b','c','d','f'], size: 103},
            { sets: ['a','b','c','e','f'], size: 87},
            { sets: ['a','b','d','e','f'], size: 139},
            { sets: ['a','c','d','e','f'], size: 87},
            { sets: ['b','c','d','e','f'], size: 88},
            { sets: ['a','b','c','d','e','f'], size: 87},
            
            ]

Cannot Set Maximum size

Good Morning!

I cannot seem to set a maximum radius for a circle.
Sometimes i have very distant data with a relativly small intersection.

This causes the smaller sized object to be nearly invisible.
Manually setting the radius misplaces the diagram totally.

Any way to set a max size/minimum size for a circle?

Thanks!

.style('font-size', ...) not working in 'new_api'

I am able to apply other text styles, such as font-style, but not font-size. The following reproduces the problem for me:

<!doctype html>
<html lang="en">
<body></body>
<script src="http://d3js.org/d3.v2.min.js"></script>
<script src="../venn.js"></script>
<script>
var data = [{
  sets: ['A'],
  size:  10
}];
var diagram = venn.VennDiagram().width(600).height(400);
d3.select("body").datum(data).call(diagram);
d3.selectAll("body .venn-circle text")
  .style("font-size", "24px")
  .style("font-style", "italic");
</script>
</html>

not all circles selectable

i have the issue that not all circles are selectable.
That happens so far in only one dataset i have which had previously the issue fixed from here #70.

Circle A and D is not hoverable or clickable.
I think the order of the circles are wrong?

dataset with this issue is this:
var sets = [{"sets":[0],"label":"A","size":4},{"sets":[1],"label":"B","size":31},{"sets":[2],"label":"C","size":10},{"sets":[3],"label":"D","size":1},{"sets":[0,1],"size":4},{"sets":[0,2],"size":4},{"sets":[0,3],"size":1},{"sets":[1,2],"size":10},{"sets":[1,3],"size":1},{"sets":[2,3],"size":1},{"sets":[0,1,2],"size":4},{"sets":[0,1,3],"size":1},{"sets":[0,2,3],"size":1},{"sets":[1,2,3],"size":1},{"sets":[0,1,2,3],"size":1}];

Overlap not visible when one of the sets has large size

Hi,

I came across an issue with the overlap of the circles when one set (B) has a really large size and all the sets combined (A,B,C) have a really small size . The overlap between the three circles isn't visible on the graph. I included an example below. Any idea what is going wrong?

var exampleVennData = [
      {
        "sets": [
          "A"
        ],
        "size": 1484
      },
      {
        "sets": [
          "B"
        ],
        "size": 15605
      },
      {
        "sets": [
          "C"
        ],
        "size": 2601
      },
      {
        "sets": [
          "A",
          "B"
        ],
        "size": 183
      },
      {
        "sets": [
          "A",
          "C"
        ],
        "size": 63
      },
      {
        "sets": [
          "B",
          "C"
        ],
        "size": 302
      },
      {
        "sets": [
          "A",
          "B",
          "C"
        ],
        "size": 7
      }
    ]

no-overlap

Set complement and intersection subset areas

I am a big fan of your project, thanks for the good work. I would like to select and interact with any individual subset areas in the same way as is possible with intersection areas. Does this library already support this? If not is there any plan to implement this in the near future?

I would like to be able to select areas such as A โˆ– (B โˆช C), B โˆ– (A โˆช C) etc in the example below:
venn

Kind Regards,
Vern

No hover / click on inner circle when inside larger circle

bug

When I hover over an inner circle when it's completely contained within a larger one, it doesn't work.

Not quite sure what the error is since sortAreas is being called so it should recognize the intersection of the two circles on top of both of the independent circles.

Any ideas?

Venn Digram Appears Very Small

Hi Ben,

Thanks for a wonderful venn js. We have used it in our project it helped a lot.

But in some scenario the diagram appears very small.
This happens when the radius is very small also the positions come out in the left bottom corner or right top corner.

Could you please help me with it?

http://codepen.io/ghiden/pen/bGAIg

Put the following code in the above link
{
"sets":
[
{"label":"Query1","size":21},
{"label":"Query2","size":13501},{"label":"Query3","size":13013},{"label":"Query4","size":9697},{"label":"Query5","size":11690}],
"overlaps":
[
{"sets":[0,1],"size":14},
{"sets":[0,2],"size":10},
{"sets":[0,3],"size":6},
{"sets":[0,4],"size":4},
{"sets":[1,2],"size":12131},
{"sets":[1,3],"size":8580},
{"sets":[1,4],"size":10749},
{"sets":[2,3],"size":9011},
{"sets":[2,4],"size":10209},
{"sets":[3,4],"size":7220},
{"sets":[0,1,2],"size":8},
{"sets":[0,1,3],"size":4},
{"sets":[0,1,4],"size":4},
{"sets":[0,2,3],"size":4},
{"sets":[0,2,4],"size":3},
{"sets":[0,3,4],"size":2},
{"sets":[1,2,3],"size":8031},
{"sets":[1,2,4],"size":9528},
{"sets":[1,3,4],"size":6533},
{"sets":[2,3,4],"size":6856},
{"sets":[0,1,2,3],"size":3},
{"sets":[0,1,2,4],"size":3},
{"sets":[0,1,3,4],"size":2},
{"sets":[0,2,3,4],"size":2},
{"sets":[1,2,3,4],"size":6201},
{"sets":[0,1,2,3,4],"size":2}
]
}

Thanks,
Kiran Nakhale

Circles doesn't draw correctly.

As per example,
http://benfred.github.io/venn.js/examples/intersection_tooltip.html

In JSON file,

overlaps = [
         ...
         {"sets": [1, 2], "size": 162},
         {"sets": [1, 3], "size": 396},
         {"sets": [1, 4], "size": 133},
         {"sets": [1, 5], "size": 135},
         {"sets": [1, 6], "size": 511},
         {"sets": [1, 7], "size": 159},
         {"sets": [1, 8], "size": 47},
         {"sets": [1, 9], "size": 168},
         {"sets": [1, 10], "size": 68}
         ...

The JSON file describes that the data set 1 (Thom Yorke) should intersect with data set 2(John Lennon) with 162 users. However, the chart doesn't show that data set 1 and data set 2 intersect each other at all.

Overriding sorting of circles

The greedyLayout orientCircles function sorts the circles by size. My specific desire is to having it so circles A,B,C are always in that order clockwise, but overriding this is... problematic.

It's not possible to change the sorting without overriding the entire layout function, which (considering its smarts) basically means copy-pasting chunks of code with a small change.

It would be nice if there was either:

  • An option to sort circles by their data ordering rather than size
  • An option to set the sorting function, in a similar way to how the layout function can be entirely overriden

multiple separate groups of sets aren't rendering properly

First off, thanks for your work on this Venn project. It's been great so far :)

I'm having some trouble trying to create a diagram which looks kind of like this (mocked up in Illustrator):

screen shot 2014-02-26 at 8 53 45 am

I have tried the following data and used both greedy and MDS layouts, but can't get what I'm looking for.

var sets = [{"label": "0","size": 16},{"label": "1","size": 16},{"label": "2", "size": 12},{"label": "3","size": 10},{"label": "4","size": 10}];
var overlaps = [{"sets": [0, 1],"size": 4},{"sets": [0, 2], "size": 4},{"sets": [1, 2], "size": 3},{"sets": [0, 1, 2], "size": 2},{"sets": [3, 4],"size": 2}];

Greedy layout throws a Need overlap information for set error and MDS gives me the following layout which is almost correct, but 3 is in the wrong place:

screen shot 2014-02-26 at 8 55 57 am

Is this a bug or maybe something venn wasn't meant to deal with? Or maybe I'm doing something wrong?

Issue with multiple overlapping circles

Hi, we have found this nice library some time ago when we wanted to make a small prototype involving visualization of overlapping resources, and I have to say it worked very well with some test data :DHowever, while trying to visualize some different dataset we encountered some issues.
One can be easily reproduced using the interactive.html example and this json object: http://pastebin.com/mhVjDP5G
You can see that we have, on one side, 2 sets ("SB4", "Git") containing all 1 element, and also intersecting each other (they count the people working on those projects, which is just the same for those 2). Same situation for the sets "Search" and "The Editor". We have then the "ITOps" set which has one element and disconnected from everything. In the end, we have the "Sbx" set which contains the 2 persons (size = 2) but also intersects everything by "ITOps".
What I would expect is something similar to this pic (excuse the terrible quality): http://i.imgur.com/d0yZ8P7.png?1
Two couples of circles completely overlapping, one circle containing all of them, one circle outside, disconnected.
Unfortunately, with the standard constructor vennjs fails and throws a strange error. With the "classicMDSLayout", the result is just plain wrong.
I know this is probably a very annoying problem, but the library is pretty nice and we would like to use it, hence any pointer on where to start to solve this case would be greatly appreciated.
Thanks,

Publish to npm

I need to use this module in a project that don't have bower on its buildchain, but uses npm instead. I think with little effort the module can be ready for publish.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.