Changes for page HyperTree Sample

Last modified by Normann P. Nielsen on 2015/09/25 14:40

From version 4.1
edited by Normann P. Nielsen
on 2015/09/25 14:40
Change comment: There is no comment for this version
To version 1.1
edited by Normann P. Nielsen
on 2026/11/15 15:44
Change comment: There is no comment for this version

Summary

Details

Hypertree.css
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.bnp
Size
... ... @@ -1,1 +1,0 @@
1 -49 bytes
Content
... ... @@ -1,3 +1,0 @@
1 -#infovis-canvaswidget {
2 - margin:25px 0 0 25px;
3 -}
init.js
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.bnp
Size
... ... @@ -1,1 +1,0 @@
1 -4.0 KB
Content
... ... @@ -1,124 +1,0 @@
1 -var labelType, useGradients, nativeTextSupport, animate;
2 -
3 -(function() {
4 - var ua = navigator.userAgent,
5 - iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i),
6 - typeOfCanvas = typeof HTMLCanvasElement,
7 - nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'),
8 - textSupport = nativeCanvasSupport
9 - && (typeof document.createElement('canvas').getContext('2d').fillText == 'function');
10 - //I'm setting this based on the fact that ExCanvas provides text support for IE
11 - //and that as of today iPhone/iPad current text support is lame
12 - labelType = (!nativeCanvasSupport || (textSupport && !iStuff))? 'Native' : 'HTML';
13 - nativeTextSupport = labelType == 'Native';
14 - useGradients = nativeCanvasSupport;
15 - animate = !(iStuff || !nativeCanvasSupport);
16 -})();
17 -
18 -var Log = {
19 - elem: false,
20 - write: function(text){
21 - if (!this.elem)
22 - this.elem = document.getElementById('log');
23 - this.elem.innerHTML = text;
24 - this.elem.style.left = (500 - this.elem.offsetWidth / 2) + 'px';
25 - }
26 -};
27 -
28 -
29 -
30 -AJS.$( document ).ready(function init(){
31 -
32 -var infovis = document.getElementById('infovis');
33 -// var w = infovis.offsetWidth - 50, h = infovis.offsetHeight - 50;
34 - var w=1000; h=800;
35 -
36 - //init Hypertree
37 - var ht = new $jit.Hypertree({
38 - //id of the visualization container
39 - injectInto: 'infovis',
40 - //canvas width and height
41 - width: w,
42 - height: h,
43 - //Change node and edge styles such as
44 - //color, width and dimensions.
45 - Node: {
46 - dim: 12,
47 - color: "#f00"
48 - },
49 - Edge: {
50 - lineWidth: 2,
51 - color: "#088"
52 - },
53 - onBeforeCompute: function(node){
54 - Log.write("centering");
55 - },
56 - //Attach event handlers and add text to the
57 - //labels. This method is only triggered on label
58 - //creation
59 - onCreateLabel: function(domElement, node){
60 - domElement.innerHTML = node.name;
61 - $jit.util.addEvent(domElement, 'click', function () {
62 - ht.onClick(node.id, {
63 - onComplete: function() {
64 - ht.controller.onComplete();
65 - }
66 - });
67 - });
68 - },
69 - //Change node styles when labels are placed
70 - //or moved.
71 - onPlaceLabel: function(domElement, node){
72 - var style = domElement.style;
73 - style.display = '';
74 - style.cursor = 'pointer';
75 - if (node._depth <= 1) {
76 - style.fontSize = "0.8em";
77 - //style.color = "#ddd";
78 - style.color = "#000000";
79 -
80 - } else if(node._depth == 2){
81 - //style.fontSize = "0.7em";
82 - //style.color = "#555";
83 - style.fontSize = "0.8em";
84 - style.color = "#000000";
85 -
86 - } else {
87 - //style.display = 'none';
88 - style.fontSize = "0.8em";
89 - style.color = "#000000";
90 - }
91 -
92 - var left = parseInt(style.left);
93 - var w = domElement.offsetWidth;
94 - style.left = (left - w / 2) + 'px';
95 - },
96 -
97 - onComplete: function(){
98 - Log.write("done");
99 -
100 - //Build the right column relations list.
101 - //This is done by collecting the information (stored in the data property)
102 - //for all the nodes adjacent to the centered node.
103 - var node = ht.graph.getClosestNodeToOrigin("current");
104 - var html = "<h4>" + node.name + "</h4><b>Connections:</b>";
105 - html += "<ul>";
106 - node.eachAdjacency(function(adj){
107 - var child = adj.nodeTo;
108 - if (child.data) {
109 - var rel = (child.data.band == node.name) ? child.data.relation : node.data.relation;
110 - html += "<li>" + child.name + " " + "<div class=\"relation\">(relation: " + rel + ")</div></li>";
111 - }
112 - });
113 - html += "</ul>";
114 - $jit.id('inner-details').innerHTML = html;
115 - }
116 - });
117 - //load JSON data.
118 - ht.loadJSON(json);
119 - //compute positions and plot.
120 - ht.refresh();
121 - //end
122 - ht.controller.onComplete();
123 -})
124 -
jit.js
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.bnp
Size
... ... @@ -1,1 +1,0 @@
1 -479.3 KB
Content