%3 ::xowiki::Includelet ::xowiki::Includelet → available_includelets → describe_includelets → glob_clause → html_encode → html_id → html_to_text → js_encode → js_name → listing → locale_clause → parent_id_clause → publish_status_clause → require_YUI_CSS → require_YUI_JS category_clause get_current_folder get_page_order include_head_entries initialize js_name resolve_page_name screen_name tableWidget ::xo::Context ::xo::Context ::xowiki::Includelet->::xo::Context ::xowiki::includelet::graph ::xowiki::includelet::graph graphHTML ::xowiki::includelet::graph->::xowiki::Includelet ::xowiki::includelet::activity-graph ::xowiki::includelet::activity-graph render ::xowiki::includelet::activity-graph->::xowiki::includelet::graph ::xowiki::includelet::collab-graph ::xowiki::includelet::collab-graph render ::xowiki::includelet::collab-graph->::xowiki::includelet::graph

Class ::xowiki::includelet::graph

::xowiki::includelet::graph[i] create ... \
           [ -__decoration (default "plain") ]

Class Relations

  • class: ::xowiki::IncludeletClass[i]
  • superclass: ::xowiki::Includelet[i]
  • subclass: ::xowiki::includelet::activity-graph[i], ::xowiki::includelet::collab-graph[i]
::xowiki::IncludeletClass create ::xowiki::includelet::graph \
     -superclass ::xowiki::Includelet

Methods (to be applied on instances)

  • __decoration (setter)

  • graphHTML (scripted)

    
    ::xo::Page requireJS "/resources/ajaxhelper/prototype/prototype.js"
    set user_agent [string tolower [ns_set iget [ns_conn headers] User-Agent]]
    if {[string match "*msie *" $user_agent]} {
      # canvas support for MSIE
      ::xo::Page requireJS "/resources/xowiki/excanvas.js"
    }
    ::xo::Page requireJS "/resources/xowiki/collab-graph.js"
    ::xo::Page requireJS "/resources/ajaxhelper/yui/yahoo/yahoo.js"
    ::xo::Page requireJS "/resources/ajaxhelper/yui/event/event.js"
    
    set nodesHTML ""
    array set n $nodes
    
    foreach {node label} $nodes {
      set link "<a href='[ns_quotehtml $base?$attrib=$node]'>[ns_quotehtml $label]</a>"
      append nodesHTML "<div id='[ns_quotehtml $node]' style='position:relative;'>&nbsp;&nbsp;&nbsp;&nbsp;$link</div>\n"
    }
    
    set edgesHTML ""set c 0
    foreach p [lsort -index 1 -decreasing -integer $edges] {
      lassign $p edge weight width
      lassign [split $edge ,] a b
      #:log "--G $a -> $b check $c > $max_edges, $weight < $cutoff"
      if {[incr c] > $max_edgesbreak
      if {$weight < $cutoffcontinue
      append edgesHTML "g.addEdge(\$('$a'), \$('$b'), $weight, 0, $width);\n"
    }
    # [lsort -index 1 -decreasing -integer $edges]<br>[set cutoff] - [set c]<br>
    
    return [subst -novariables {
      <div>
      <canvas id="collab" width="500" height="500" style="border: 0px solid black">
      </canvas>
      [set nodesHTML]
      <script type="text/javascript" nonce='[security::csp::nonce]'>
      function draw() {
        if (typeof(G_vmlCanvasManager) == "object") {
          G_vmlCanvasManager.init_(window.document);
        }
    
        var g = new Graph();
        [set edgesHTML]
        var layouter = new Graph.Layout.Spring(g);
        layouter.layout();
    
        // IE does not pick up the canvas width or height
        $('collab').width=500;
        $('collab').height=500;
    
        var renderer = new Graph.Renderer.Basic($('collab'), g);
        renderer.radius = 5;
        renderer.draw();
      }
      YAHOO.util.Event.addListener(window, 'load', draw);
      //   YAHOO.util.Event.onContentReady('collab', draw);
      </script>
      </div>
    }]