Changeset 5306


Ignore:
Timestamp:
05/27/14 21:52:36 (10 years ago)
Author:
xnrn@gmx.net
Message:

added dynamic weight threshold; handle loading overview in dynamic mode (loadDetailInfo)

File:
1 edited

Legend:

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

    r5300 r5306  
    4242//var source_file = "/smc/smc-graph.d3";
    4343/*var source_file = "/smc/cmd-dep-graph.d3.js";*/
     44var data_prefix = "data/";
    4445var detail_file = "/smc/data/smc_stats_detail.html";
    4546var userdocs_file = "/smc/docs/userdocs.html";
    4647
    47 var opts = {"graph": {"value":"/smc/data/smc-graph-basic.js",
    48                     "values":[{value: "/smc/data/smc-graph-basic.js", label:"SMC graph basic"},
    49                               {value: "/smc/data/smc-graph-all.js", label:"SMC graph all"},                             
    50                               {value: "/smc/data/smc-graph-profiles-datcats.js", label:"only profiles + datcats"},
    51                               {value: "/smc/data/smc-graph-groups-profiles-datcats-rr.js", label:"profiles+datcats+groups+rr"},
    52                               {value: "/smc/data/smc-graph-profiles-similarity.js", label:"just profiles"},                             
    53                               {value: "/smc/data/dbpedia_philosophers_influence_years_graph.json", label:"Philosophers"},
    54                               {value: "/smc/data/SC_Persons_120201_cAll_graph.json", label:"Schnitzler Cooccurrences"},
     48
     49var opts = {"graph": {"value":"smc-graph-basic.js",
     50                    "values":[{value: "smc-graph-basic.js", label:"SMC graph basic"},
     51                              {value: "smc-graph-all.js", label:"SMC graph all"},                             
     52                              {value: "smc-graph-profiles-datcats.js", label:"only profiles + datcats"},
     53                              {value: "smc-graph-groups-profiles-datcats-rr.js", label:"profiles+datcats+groups+rr"},
     54                              {value: "smc-graph-profiles-similarity.js", label:"just profiles"},                             
     55                              {value: "dbpedia_philosophers_influence_years_graph.json", label:"Philosophers"},
     56                              {value: "SC_Persons_120201_cAll_graph.json", label:"Schnitzler Cooccurrences"},
    5557                              /*,
    56                               {value: "/smc/data/smc-graph-mdrepo-stats.js", label:"instance data"}*/
     58                              {value: "smc-graph-mdrepo-stats.js", label:"instance data"}*/
    5759                             
    5860                             ], "widget":"selectone" },
     
    6466            "gravity":{"value":10, "min":1, "max":100, "widget":"slider" },
    6567            "node-size": {"value":"4", "values":["1","4","8","16","count"], "widget":"selectone" },
     68            "weight":{"value":100, "min":1, "max":100, "widget":"slider" },
    6669            "labels": {"value":"show", "values":["show","hide"], "widget":"selectone" },                         
    6770            "curve": {"value":"straight-arrow", "values":["straight-line","arc-line","straight-arrow","arc-arrow"], "widget":"selectone" },
     
    8285}
    8386
     87function currentOpts () {
     88 return $("#navigate").data("qi");
     89}
     90
    8491/**  gets the data for the graph and calls rendering of the lists
    8592 * @name initGraph
     
    9097
    9198     // load data
    92      d3.json(graph_source,
     99     d3.json(data_prefix + graph_source,
    93100                function(json) {       
    94101                    // return if data missing
     
    125132                 data_all.node_size_ratio = Math.sqrt(data_all.count_max) / max_circle;
    126133
     134                    var init_weight = [];
     135                    data_all.links.forEach(function(d,i){init_weight.push(+d.weight);})
     136                 
     137                 data_all.weight_min = d3.min(init_weight);
     138                curr_params = $("#navigate").data("qi").params;
     139                /* if weight is not used (all weight==1 deactivate the weight widget */
     140                if (data_all.weight_min==1) {
     141                           
     142                           delete curr_params.weight;
     143/*                           $("#navigate").init(curr_opts );*/
     144                        $("#navigate").QueryInput({params: curr_params,
     145                             onValueChanged: renderGraph
     146                             });
     147                } else {
     148                      curr_params.weight = {"value":70, "min":1, "max":100, "widget":"slider" };
     149                      $("#navigate").QueryInput({params: curr_params,
     150                             onValueChanged: renderGraph
     151                      });
     152                }
     153               
     154               
    127155                notifyUser("count max: " + data_all.count_max + "; "
    128156                        + "node_size_ratio: " + data_all.node_size_ratio);
     
    628656     
    629657       });
     658      } else {
     659          var target_container = $(detail_container_selector).append(
     660            '<div id="detail-summary-overall" class="cmds-ui-block init-show" ><div class="header">Overview</div></div>');
     661            $(detail_container_selector).find('#detail-summary-overall').append('<div class="content"></div>');
     662            target = $(detail_container_selector).find("#detail-summary-overall .content")
     663            getDetailInfo("summary", "overall", target, function() {           
     664                        handleUIBlock($(detail_container_selector).find(".cmds-ui-block"));
     665                        });
     666           
    630667      }
    631668 
     
    638675}
    639676
    640 function getDetailInfo(type, id, target) {
     677function getDetailInfo(type, id, target,load_callback) {
    641678    //notify("getDetailInfo: #" + type + "-" + id );
    642679   
     
    650687            return d.html();       
    651688        } else {
    652             var url = detail_url + "?type=" + type + "&id=" + id;
     689            var url = detail_url + "?type=" + type + "&key=" + id;
     690            console.log("get-detail:" + url );
    653691                $(target).toggleClass("loading");
    654                  $(target).load(url);
     692                 $(target).load(url,load_callback);
    655693        }
    656694    // notify(d);
     
    763801*/
    764802function highlight() {
    765 //prevent endless highlight loop
    766803   max_depth = parseInt(opt("depth-before")) + parseInt(opt("depth-after"));
    767804   console.log ("max_depth:" + max_depth);
     
    954991/** returns appropriate link
    955992*/
    956 function neighboring(a, b) {
    957   return linkedByIndex[a.index + "," + b.index];
     993function neighbouring(a, b) {
     994console.log("neighbouring: " +a.key + "," + b.key );
     995  return data_all.links_index[a.key + "," + b.key];
    958996}
    959997
     
    9691007       depth = typeof depth !== 'undefined' ? depth : 1;
    9701008       data = typeof data !== 'undefined' ? data : data_all;
    971 
     1009    weight_threshold = parseInt(opt("weight")) / 100;
     1010console.log("weight_threshold:" + weight_threshold);
    9721011    if (depth==0) { return {nodes:[], links:[]};}
    9731012
    974         var n_in = data.nodes_in[n.key] ? data.nodes_in[n.key] : [] ;
    975         var n_out = data.nodes_out[n.key] ? data.nodes_out[n.key] : [] ;
    976         var l_in = data.links_in[n.key] ? data.links_in[n.key] : [] ;
    977         var l_out = data.links_out[n.key] ? data.links_out[n.key] : [] ;
     1013        /* don't filter at all */
     1014        if (weight_threshold == 1) {
     1015           var n_in = data.nodes_in[n.key] ? data.nodes_in[n.key] : [] ;
     1016           var n_out = data.nodes_out[n.key] ? data.nodes_out[n.key] : [] ;
     1017           var l_in = data.links_in[n.key] ? data.links_in[n.key] : [] ;
     1018           var l_out = data.links_out[n.key] ? data.links_out[n.key]  : [] ;
     1019        } else {
     1020            var l_in = data.links_in[n.key] ? data.links_in[n.key].filter(function(d, i) { return d.weight>=weight_threshold }) : [] ;
     1021            var l_out = data.links_out[n.key] ? data.links_out[n.key].filter(function(d, i) { return d.weight>=weight_threshold })  : [] ;
     1022            var n_in = data.nodes_in[n.key] ? data.nodes_in[n.key].filter(function(d, i) { return neighbouring(d,n).weight>=weight_threshold })  : [] ;
     1023           var n_out = data.nodes_out[n.key] ? data.nodes_out[n.key].filter(function(d, i) { return neighbouring(n,d).weight>=weight_threshold })  : [] ;
     1024        }
    9781025       
    9791026        var result_n = {nodes:[], links:[]};
Note: See TracChangeset for help on using the changeset viewer.