garthtarr / edgebundleR

Circle plot with bundled edges
http://garthtarr.github.io/edgebundleR/
66 stars 12 forks source link

max.size argument #2

Closed garthtarr closed 9 years ago

garthtarr commented 9 years ago

@timelyportfolio thanks for the great updates, I've made a couple of changes to ensure that the original examples still work.

I've hit an issue with the json object example where the sizes are specified:

library(edgebundleR)
filepath = system.file("sampleData", "flare-imports.json", package = "edgebundleR")
edgebundle(filepath,width=800,fontsize=8,tension=0.95)

I think a good fix will be to specify the maximum size that an vertex dot can be and rescale the sizes relative to the maximum size.

My javascript is terrible, I could probably work it out given enough time, but maybe you're able to quickly implement a simple fix. My suggested pseudo javascript code is below.

It assumes that the maxsize variable has been passed in through the xin object. My main issue is finding the maximum over a JSON array in javascript (don't mock me, I'm not JSON/javascript native!)

var maxval = Math.max(nodes_g.size)

nodes_g.append("circle")
        .attr("cx", 0)
        .attr("cy", 0)
        .attr("fill", function(d,i){
        if(d.color) return d.color;
        return null;
        })
        .attr("opacity", 1.0)
        .attr("r", function(d,i){
          var size = (d.size) ? d.size : 10;
          return Math.round(Math.pow(size / maxval * xin.maxsize, 1/2));
        });
timelyportfolio commented 9 years ago

@garthtarr that works, but I'm wondering if a scale will be better with the ability to specify both an optional max and min node size. I'll work on it and submit a pull for your consideration. Glad you are testing with the non-igraph, since I couldn't find tests and didn't have time to work up a new set. Thanks for implementing so quickly. I'll try to include it into today's building widgets weekly post.