11function init ( ) {
2- function get ( id ) {
3- return document . getElementById ( id ) ;
4- } ;
52 //init data
63 var json = {
74 id : "node02" ,
@@ -738,45 +735,57 @@ function init(){
738735 //preprocess subtrees orientation
739736 var arr = json . children , len = arr . length ;
740737 for ( var i = 0 ; i < len ; i ++ ) {
741- if ( i < len / 2 ) {
738+ //split half left orientation
739+ if ( i < len / 2 ) {
742740 arr [ i ] . data . $orn = 'left' ;
743741 $jit . json . each ( arr [ i ] , function ( n ) {
744742 n . data . $orn = 'left' ;
745743 } ) ;
746744 } else {
745+ //half right
747746 arr [ i ] . data . $orn = 'right' ;
748747 $jit . json . each ( arr [ i ] , function ( n ) {
749748 n . data . $orn = 'right' ;
750749 } ) ;
751750 }
752751 }
753-
752+ //grab radio button
753+ var normal = $jit . id ( 's-normal' ) ;
754754 //end
755755 //init st
756756 //Create a new ST instance
757- st = new $jit . ST ( {
758- 'injectInto' : 'infovis' ,
757+ var st = new $jit . ST ( {
758+ //id of viz container element
759+ injectInto : 'infovis' ,
759760 //multitree
760761 multitree : true ,
761762 //set duration for the animation
762763 duration : 800 ,
763764 //set animation transition type
764765 transition : $jit . Trans . Quart . easeInOut ,
765766 //set distance between node and its children
766- levelDistance : 50 ,
767+ levelDistance : 40 ,
768+ //sibling and subtrees offsets
769+ siblingOffset : 0 ,
770+ subtreeOffset : 0 ,
767771 //set node and edge styles
768772 //set overridable=true for styling individual
769773 //nodes or edges
770774 Node : {
771- height : 20 ,
772- width : 60 ,
773- type : 'rectangle ' ,
775+ height : 35 ,
776+ width : 50 ,
777+ type : 'ellipse ' ,
774778 color : '#aaa' ,
775- overridable : true
779+ overridable : true ,
780+ //set canvas specific styles
781+ //like shadows
782+ CanvasStyles : {
783+ shadowColor : '#ccc' ,
784+ shadowBlur : 10
785+ }
776786 } ,
777-
778787 Edge : {
779- type : 'bezier ' ,
788+ type : 'line ' ,
780789 overridable : true
781790 } ,
782791
@@ -795,18 +804,21 @@ function init(){
795804 label . id = node . id ;
796805 label . innerHTML = node . name ;
797806 label . onclick = function ( ) {
798- //st.onClick(node.id);
799- st . setRoot ( node . id , 'animate' ) ;
807+ if ( normal . checked ) {
808+ st . onClick ( node . id ) ;
809+ } else {
810+ st . setRoot ( node . id , 'animate' ) ;
811+ }
800812 } ;
801813 //set label styles
802814 var style = label . style ;
803- style . width = 60 + 'px' ;
804- style . height = 17 + 'px' ;
815+ style . width = 50 + 'px' ;
816+ style . height = 35 + 'px' ;
805817 style . cursor = 'pointer' ;
806818 style . color = '#333' ;
807819 style . fontSize = '0.8em' ;
808820 style . textAlign = 'center' ;
809- style . paddingTop = '3px ' ;
821+ style . paddingTop = '10px ' ;
810822 } ,
811823
812824 //This method is called right before plotting
@@ -853,14 +865,7 @@ function init(){
853865 //load json data
854866 st . loadJSON ( json ) ;
855867 //compute node positions and layout
856- st . compute ( ) ;
868+ st . compute ( 'end' ) ;
857869 st . select ( st . root ) ;
858-
859- //emulate a click on the root node.
860- // st.onClick(st.root, {
861- // Move: {
862- // enable: false
863- // }
864- // });
865870 //end
866871}
0 commit comments