在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ d3.js v5版本,力導(dǎo)向圖獲取相關(guān)邊

d3.js v5版本,力導(dǎo)向圖獲取相關(guān)邊

怎么實現(xiàn)點擊某個點,將該點連接的有效邊的顏色標(biāo)注出來?

clipboard.png

回答
編輯回答
半心人

根據(jù)d3的事件綁定來實現(xiàn),

.on('mouseenter', function(d){
   // 監(jiān)聽點擊的節(jié)點以及其有效邊
   links.style('stroke-width', function(edge){
     if( edge.source === d || edge.target === d ){
        return '2px';
     }
   }).style('stroke', function(edge){
     if( edge.source === d || edge.target === d ){
        return '#666';
     }
   });
2017年8月20日 12:32