Changeset 3815 for SMC


Ignore:
Timestamp:
10/19/13 11:10:25 (11 years ago)
Author:
vronk
Message:

added gravity-param and charge considers node size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SMC/trunk/SMC/src/web/scripts/js/smc-graph.js

    r3629 r3815  
    5757            "charge":{"value":250, "min":10, "max":1000, "widget":"slider" },
    5858            "friction":{"value":75, "min":1, "max":100, "widget":"slider" },
     59            "gravity":{"value":20, "min":1, "max":100, "widget":"slider" },
    5960            "node-size": {"value":"count", "values":["1","4","8","16","count"], "widget":"selectone" },
    6061            "labels": {"value":"show", "values":["show","hide"], "widget":"selectone" },                         
     
    262263    var filtered_index_nodes = data_all.nodes.filter(function(d, i) {
    263264     //   console.log(d.name.indexOf(search_string));
    264         return d.name.toLowerCase().indexOf(search_string) > -1;
     265        return d.name.toLowerCase().indexOf(search_string.toLowerCase()) > -1;
    265266    });
    266267   
     
    323324
    324325            .friction(parseInt(opt("friction")) / 100 )
    325             .linkDistance(parseInt(opt("link-distance")))
    326             .gravity(0.5)
     326           
     327            .gravity(parseInt(opt("gravity")) / 100 )
     328           
     329/*            .linkDistance(parseInt(opt("link-distance")))*/
     330           
     331            .linkDistance(function(d){return link_distance / (d.weight * d.value) })
    327332            /* Profiles:           
    328333           
    329             .linkDistance(function(d){return link_distance / (d.weight * d.value) })
     334           
    330335            .linkStrength(function(d){return d.weight})*/
    331336            //.charge(parseInt(opt("charge")) * -1)
    332             .charge(function(d) { if (opt("node-size")=="count")
     337         
     338          if (parseInt(opt("charge"))==0) {
     339            force.charge(0);
     340          } else {
     341            force.charge(function(d) { if (opt("node-size")=="count")
    333342                            {var node_charge = (Math.sqrt(d.count)<=min_circle) ?  min_circle  : Math.sqrt(d.count) / data.node_size_ratio;
    334343                            //console.log (node_charge + ':' + d.count);
     
    337346                              //{ return -d.count * parseInt(opt("charge"));  }
    338347                            else { return parseInt(opt("charge")) * -1} })
    339             .on("tick", tick)
     348          }
     349         
     350         force.on("tick", tick)
    340351            .start();
     352       
    341353        if (opt("layout")=='freeze') {
    342354               data.nodes.forEach(function(d) { d.fixed=true });     
Note: See TracChangeset for help on using the changeset viewer.