偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

JavaScript來實(shí)現(xiàn)的超炫組織結(jié)構(gòu)圖

開發(fā) 前端
最近有個內(nèi)部項目需要使用組織結(jié)構(gòu)圖(organization chart), 尋找了一些開源的項目及其類庫,發(fā)現(xiàn)竟然沒有現(xiàn)成的JS類庫可以使用,找到一些簡單的JS實(shí)現(xiàn),不過界面及其操作及其簡單,不過功夫不負(fù)有心人,經(jīng)過幾天國內(nèi)國外的搜索,找到了一個非常好的解決方案,這里分享給大家。

Javascript InfoVis tools

這個開源的javascript類庫可以生成非常炫酷的結(jié)構(gòu)和圖形,我選擇了其中的一種spacetree類型做為我的組織結(jié)構(gòu)圖基礎(chǔ),這種圖形可以支持一下特性:

◆ 支持向上下左右四個方向展開圖表

◆ 支持子節(jié)點(diǎn)擴(kuò)展

◆ 支持圖表拖放

◆ 支持圖表縮放

整個類庫異常強(qiáng)大,非常合適復(fù)雜的圖形功能需求,如下:

 

 

  1. //Create a new instance  
  2.     var st = new $jit.ST({  
  3.         'injectInto''orgchart',  
  4.         //set duration for the animation  
  5.         duration: 800,  
  6.         //set animation transition type  
  7.         transition: $jit.Trans.Quart.easeInOut,  
  8.         levelDistance: 50,  
  9.         levelsToShow: 1,  
  10.         Node: {  
  11.             height: 45,  
  12.             width: 120,  
  13.             type: 'nodeline',  
  14.             color:'#23A4FF',  
  15.             lineWidth: 2,  
  16.             align:"center",  
  17.             overridable: false 
  18.         },  
  19.           
  20.         Edge: {  
  21.             type: 'bezier',  
  22.             lineWidth: 2,  
  23.             color:'#23A4FF',  
  24.             overridable: true 
  25.         },  
  26.           
  27.     //Retrieve the json data from database and create json objects for org chart  
  28.         request: function(nodeId, level, onComplete) {  
  29.         
  30.       //Generate sample data  
  31.       if(nodeId!='peter wang'&&nodeId!='William chen'){  
  32.         var data= [{fullname:'peter wang',title:'engineer'},{fullname:'William chen',title:'senior engineer'}];  
  33.         var objs = [];  
  34.         for(var i=0;i
  35.           var tmp = data[i];  
  36.           var obj = {"id":data[i].fullname, "name""" + data[i].fullname+"
    ("
    +data[i].title + ")"};  
  37.           objs.push(obj);  
  38.         }  
  39.            
  40.         var nodeobjs={};  
  41.         nodeobjs.id =  nodeId;  
  42.         nodeobjs.children =  objs;  
  43.         onComplete.onComplete(nodeId, nodeobjs);    
  44.       }else{  
  45.         var nodeobjs={};  
  46.         onComplete.onComplete(nodeId, nodeobjs);    
  47.       }  
  48.  
  49.         }, 

 

以上代碼創(chuàng)建一個實(shí)例,注意request部分,這段代碼用來取出點(diǎn)擊節(jié)點(diǎn)后需要顯示的字節(jié)點(diǎn),在實(shí)際應(yīng)用中,我們把數(shù)據(jù)庫中取出的數(shù)據(jù)生成json對象后注入這里生成子節(jié)點(diǎn)。

  1. //Change chart direction  
  2.   $("#top").click(function(){  
  3.       $("#orgchartori").fadeOut();  
  4.             st.switchPosition($("#top").attr("id"), "animate", {  
  5.                 onComplete: function(){  
  6.                     $("#orgchartori").fadeIn();  
  7.                 }  
  8.             });   
  9.   });  
  10.     
  11.   $("#bottom").click(function(){  
  12.       $("#orgchartori").fadeOut();  
  13.             st.switchPosition($("#bottom").attr("id"), "animate", {  
  14.                 onComplete: function(){  
  15.                     $("#orgchartori").fadeIn();  
  16.                 }  
  17.             });   
  18.   });  
  19.  
  20.   $("#right").click(function(){  
  21.       $("#orgchartori").fadeOut();  
  22.             st.switchPosition($("#left").attr("id"), "animate", {  
  23.                 onComplete: function(){  
  24.                     $("#orgchartori").fadeIn();  
  25.                 }  
  26.             });   
  27.   });  
  28.  
  29.   $("#left").click(function(){  
  30.       $("#orgchartori").fadeOut();  
  31.             st.switchPosition($("#right").attr("id"), "animate", {  
  32.                 onComplete: function(){  
  33.           $("#orgchartori").fadeIn();  
  34.                 }  
  35.             });   
  36.   });   

以上代碼用來控制組織結(jié)構(gòu)圖圖形展示方向,效果請參考演示。

在線演示 在線調(diào)試

拖放及其縮放特效演示請查看如下應(yīng)用案例。

應(yīng)用案例:http://www.triplifes.com

相關(guān)資料:http://thejit.org/

文章來源:使用Javascript來實(shí)現(xiàn)的超炫組織結(jié)構(gòu)圖(Organization Chart)

責(zé)任編輯:陳貽新 來源: gbin1.com
相關(guān)推薦

2011-06-14 18:37:50

Flash

2011-06-21 13:31:13

JavaScript

2020-05-06 15:59:07

JavaScript程序員技術(shù)

2020-05-09 11:20:02

Java結(jié)構(gòu)圖虛擬機(jī)

2013-04-17 10:16:25

語言

2022-08-04 13:58:54

SeabornFacetGrid代碼

2009-04-13 10:52:59

網(wǎng)絡(luò)拓?fù)?/a>摩卡網(wǎng)絡(luò)

2012-07-09 09:31:53

silverlight

2015-01-08 09:37:54

數(shù)據(jù)中心結(jié)構(gòu)圖機(jī)房結(jié)構(gòu)圖

2010-07-05 15:01:21

UML靜態(tài)結(jié)構(gòu)圖

2022-09-26 09:01:23

JavaScript淺拷貝深拷貝

2011-04-18 17:17:45

CSSweb開發(fā)

2010-07-05 12:37:29

用Visio畫UML圖

2010-07-05 14:48:25

UML靜態(tài)結(jié)構(gòu)圖

2011-03-03 10:16:46

jQueryJavaScript

2011-08-02 14:45:11

HTML 5

2012-03-13 14:06:39

JavaJ2EE

2020-08-10 14:46:30

JavaScriptStack

2010-08-13 13:46:04

Flex效果組件

2024-08-29 11:05:10

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號