Changeset 3479


Ignore:
Timestamp:
08/27/13 13:26:06 (11 years ago)
Author:
vronk
Message:

added graph-parameter, allows switching between (predefined) graphs

File:
1 edited

Legend:

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

    r3478 r3479  
    3131var userdocs_file = "userdocs.html";
    3232*/
    33 var source_file = "/smc/smc-graph.d3";
     33//now graph-param is used
     34//var source_file = "/smc/smc-graph.d3";
    3435/*var source_file = "/smc/cmd-dep-graph.d3.js";*/
    3536var detail_file = "smc_stats_detail.html";
    3637var userdocs_file = "userdocs.html";
    3738
    38 var opts = {"depth-before": {"value":2, "min":0, "max":10, "widget":"slider"},
     39var opts = {"graph": {"value":"/smc/data/smc-graph-basic.js",
     40                    "values":[{value: "/smc/data/smc-graph-basic.js", label:"SMC graph basic"},
     41                              {value: "/smc/data/smc-graph-all.js", label:"SMC graph all"},                             
     42                              {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"}
     44                              /*,
     45                              {value: "/smc/data/smc-graph-mdrepo-stats.js", label:"instance data"}*/
     46                             
     47                             ], "widget":"selectone" },
     48            "depth-before": {"value":2, "min":0, "max":10, "widget":"slider"},
    3949            "depth-after":{"value":2, "min":0, "max":10, "widget":"slider"},
    4050            "link-distance": {"value":120, "min":10, "max":300, "widget":"slider" },
     
    6474 * @function
    6575 */
    66  function initGraph ()
     76 function initGraph (graph_source)
    6777    {
    6878
    6979     // load data
    70      d3.json(source_file ,
     80     d3.json(graph_source,
    7181                function(json) {       
    7282                    // return if data missing
    73                     if (json==null) { notifyUser("source data missing: " + source_file ); return null}           
     83                    if (json==null) { notifyUser("source data missing: " + graph_source ); return null}           
    7484                    data_all = json;
    7585                    data_all.links.forEach(function(d) {
     
    163173        var group_divs = target_container.selectAll("div.node-detail").data(nest)
    164174                        .enter().append("div")
    165                         .attr("id", function (d) { return "detail-" + d.key })
    166                         .classed("node-detail cmds-ui-block init-show", 1);
     175                       .attr("id", function (d) { return "detail-" + d.key })                       
     176                        .classed("node-detail cmds-ui-block", 1)
     177                        // collapse groups in index, but expand right away in detail view
     178                        .classed("init-show", (target_container_selector != index_container_selector));
    167179                       
    168180      var group_headers = group_divs.append("div").classed("header", 1)
     
    184196            if (target_container_selector == index_container_selector) {
    185197                index_container = target_container;
    186                 item_li.attr("id", function (d) { return "n-" + d.name });
     198                item_li.attr("id", function (d) { return "n-" + d.name })
     199                        .attr("title", function(d) { return  d.id });
    187200                item_li.classed("highlight", function (d) { return d.selected });
    188201/*                item_li.classed("highlight", liveSelected);*/
     
    244257// setting defaults
    245258// for now, ignore the params, as they are always the same
     259   
    246260    //data = typeof data !== 'undefined' ? data : dataToShow(nodes_sel);
     261   
     262    if ($(this).is('#input-graph')) {       
     263        console.log("graph-source changed! reinitializing graph");
     264        initGraph(data);
     265    }
     266   
    247267    data = dataToShow(nodes_sel);
    248     target_container = graph_container ;
     268 
     269      target_container = graph_container ;
    249270   
    250271    if (data == null) {
     
    527548 
    528549  // loading css to store in extra variable, for later use = injecting into exported SVG
    529   $.get("scripts/style/cmd-dep-graph.css", function(data) {
     550  $.get("scripts/style/smc-graph.css", function(data) {
    530551 //  console.log(data)
    531552    css = data
Note: See TracChangeset for help on using the changeset viewer.