Changeset 3628 for SMC


Ignore:
Timestamp:
09/27/13 13:21:14 (11 years ago)
Author:
vronk
Message:

small changes to label generation, + node-size scaling relative currently visible nodes

File:
1 edited

Legend:

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

    r3479 r3628  
    1717var min_circle = 4;
    1818var max_circle = 50;
     19
     20var show_count = 1;
     21
    1922var comp_reg_url = "http://catalog.clarin.eu/ds/ComponentRegistry/?item=";
    2023var mdrepo_url_search = "http://localhost:8680/exist/apps/cr-xq/mdrepo/index.html?operation=searchRetrieve&x-context=&query=";
     
    4144                              {value: "/smc/data/smc-graph-all.js", label:"SMC graph all"},                             
    4245                              {value: "/smc/data/smc-graph-profiles-datcats.js", label:"only profiles + datcats"},
    43                               {value: "/smc/data/smc-graph-groups-profiles-datcats-rr", label:"profile groups + profiles + datcats + relations"}
     46                              {value: "/smc/data/smc-graph-groups-profiles-datcats-rr.js", label:"profiles+datcats+groups+rr"}
    4447                              /*,
    4548                              {value: "/smc/data/smc-graph-mdrepo-stats.js", label:"instance data"}*/
     
    188191                    .attr("class", "node-item");
    189192               item_li.append("span")
    190                     .text(function (d) { return d.name + ' |' + d.count + '|' })
     193/*                     .text(function (d) { return d.name})*/
     194                    .text(renderItemText)
    191195                    .on("click", function(d) { d.selected= d.selected ? 0 : 1 ; updateSelected() });
    192196         
     
    218222               
    219223/*                profile_item_detail.append("a")*/
    220                 item_detail.append("a")
     224/*                item_detail.append("a")
    221225                            .classed("scan", function (d) {  return !(d.type=='Profile') } )
    222226                            .attr("target",'_blank')
    223227                            .attr("href",function (d) { if (d.type=='Profile') { return mdrepo_url_search +  'cmd.profile=%22' + d.id + '%22'; }
    224228                                                          else { return mdrepo_url_scan +  'cmd:' +  d.name; }   }  )
    225                             .text(' mdrepo-view ');
     229                            .text(' mdrepo-view ');*/
    226230               
    227231                 item_detail_detail = item_detail.append("div").html(
     
    243247}
    244248
     249function renderItemText(d) {
     250    if (show_count) {
     251        return d.name + ' |' + d.count + '|';
     252      }
     253    else {
     254        return d.name;
     255        }
     256 }
     257
    245258function filterIndex (search_string){
    246259    var filtered_index_nodes = data_all.nodes.filter(function(d, i) {
     
    276289     }
    277290 
     291  // compute the maximum number, but only if it will be needed (i.e. node-size=usage)
     292    if (opt("node-size")=="usage") {
     293        var init_count = [];
     294            data.nodes.forEach(function(d,i){init_count.push(+d.count);})
     295            data.count_max = d3.max(init_count);
     296            data.node_size_ratio = Math.sqrt(data.count_max) / max_circle;
     297        }
     298
    278299  // information about the displayed data
    279300        notifyUser("show nodes: " + data_show.nodes.length + "; "
    280                         + "show links: " + data_show.links.length);
     301                        + "show links: " + data_show.links.length + "; "
     302                        + "max count:" + data.count_max + "; "
     303                        + "node_size_ration:" + data.node_size_ratio);
    281304       
    282305 
     
    297320            .friction(parseInt(opt("friction")) / 100 )
    298321            .linkDistance(parseInt(opt("link-distance")))
    299             .charge(parseInt(opt("charge")) * -1)
     322            //.charge(parseInt(opt("charge")) * -1)
     323            .charge(function(d) { if (opt("node-size")=="usage")
     324                            {var node_charge = (Math.sqrt(d.count)<=min_circle) ?  min_circle  : Math.sqrt(d.count) / data.node_size_ratio;
     325                            //console.log (node_charge + ':' + d.count);
     326                            return node_charge * -1 * parseInt(opt("charge"));
     327                                }
     328                              //{ return -d.count * parseInt(opt("charge"));  }
     329                            else { return parseInt(opt("charge")) * -1} })
    300330            .on("tick", tick)
    301331            .start();
     
    386416                      .on("mouseover", highlight()).on("mouseout", unhighlight())
    387417            .attr("r", function(d) { if (opt("node-size")=="usage")
    388                                         {return (Math.sqrt(d.count)<=min_circle) ?  min_circle  : Math.sqrt(d.count) / data_all.node_size_ratio;                                       
     418                                        {return (Math.sqrt(d.count)<=min_circle) ?  min_circle  : Math.sqrt(d.count) / data.node_size_ratio;                                       
    389419                                        }
    390420                                        else { return node_size_int; }
     
    392422           
    393423            gnodes.append("title")
    394                 .text(function (d) { return d.name + ' |' + d.count + '|' })
    395 /*                  .text(function(d) { return d.name; });*/
     424/*                .text(function (d) { return d.name + ' |' + d.count + '|' })*/
     425                  .text(renderItemText);
    396426                 
    397427                 
Note: See TracChangeset for help on using the changeset viewer.