Changeset 5306
- Timestamp:
- 05/27/14 21:52:36 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SMC/trunk/SMC/src/web/scripts/js/smc-graph.js
r5300 r5306 42 42 //var source_file = "/smc/smc-graph.d3"; 43 43 /*var source_file = "/smc/cmd-dep-graph.d3.js";*/ 44 var data_prefix = "data/"; 44 45 var detail_file = "/smc/data/smc_stats_detail.html"; 45 46 var userdocs_file = "/smc/docs/userdocs.html"; 46 47 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 49 var 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"}, 55 57 /*, 56 {value: " /smc/data/smc-graph-mdrepo-stats.js", label:"instance data"}*/58 {value: "smc-graph-mdrepo-stats.js", label:"instance data"}*/ 57 59 58 60 ], "widget":"selectone" }, … … 64 66 "gravity":{"value":10, "min":1, "max":100, "widget":"slider" }, 65 67 "node-size": {"value":"4", "values":["1","4","8","16","count"], "widget":"selectone" }, 68 "weight":{"value":100, "min":1, "max":100, "widget":"slider" }, 66 69 "labels": {"value":"show", "values":["show","hide"], "widget":"selectone" }, 67 70 "curve": {"value":"straight-arrow", "values":["straight-line","arc-line","straight-arrow","arc-arrow"], "widget":"selectone" }, … … 82 85 } 83 86 87 function currentOpts () { 88 return $("#navigate").data("qi"); 89 } 90 84 91 /** gets the data for the graph and calls rendering of the lists 85 92 * @name initGraph … … 90 97 91 98 // load data 92 d3.json( graph_source,99 d3.json(data_prefix + graph_source, 93 100 function(json) { 94 101 // return if data missing … … 125 132 data_all.node_size_ratio = Math.sqrt(data_all.count_max) / max_circle; 126 133 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 127 155 notifyUser("count max: " + data_all.count_max + "; " 128 156 + "node_size_ratio: " + data_all.node_size_ratio); … … 628 656 629 657 }); 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 630 667 } 631 668 … … 638 675 } 639 676 640 function getDetailInfo(type, id, target ) {677 function getDetailInfo(type, id, target,load_callback) { 641 678 //notify("getDetailInfo: #" + type + "-" + id ); 642 679 … … 650 687 return d.html(); 651 688 } 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 ); 653 691 $(target).toggleClass("loading"); 654 $(target).load(url );692 $(target).load(url,load_callback); 655 693 } 656 694 // notify(d); … … 763 801 */ 764 802 function highlight() { 765 //prevent endless highlight loop766 803 max_depth = parseInt(opt("depth-before")) + parseInt(opt("depth-after")); 767 804 console.log ("max_depth:" + max_depth); … … 954 991 /** returns appropriate link 955 992 */ 956 function neighboring(a, b) { 957 return linkedByIndex[a.index + "," + b.index]; 993 function neighbouring(a, b) { 994 console.log("neighbouring: " +a.key + "," + b.key ); 995 return data_all.links_index[a.key + "," + b.key]; 958 996 } 959 997 … … 969 1007 depth = typeof depth !== 'undefined' ? depth : 1; 970 1008 data = typeof data !== 'undefined' ? data : data_all; 971 1009 weight_threshold = parseInt(opt("weight")) / 100; 1010 console.log("weight_threshold:" + weight_threshold); 972 1011 if (depth==0) { return {nodes:[], links:[]};} 973 1012 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 } 978 1025 979 1026 var result_n = {nodes:[], links:[]};
Note: See TracChangeset
for help on using the changeset viewer.