首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cytoscape.js dagre布局段边缘

cytoscape.js dagre布局段边缘
EN

Stack Overflow用户
提问于 2016-04-16 06:29:35
回答 1查看 1.3K关注 0票数 1

关于同一组数据,请参见下面的cytoscape.js与dagre-d3.js。

  1. 细胞角:https://jsfiddle.net/bababalcksheep/m40m5mmx/6/
  2. dagre-d3:http://cpettitt.github.io/project/dagre-d3/latest/demo/tcp-state-diagram.html

如何使cytoscape.js边缘与dagre相同?

任何帮助都将不胜感激!

赛托克-达格雷不应该从达格雷那里取点吗?从示例https://jsfiddle.net/bababalcksheep/55cmk117/3/中可以看到,在dagre.layout(g);之后,dagre在边缘中有点,数据可以被胞景段边缘使用。

代码语言:javascript
复制
$(function () { // on dom ready

  var cy = cytoscape({
    container: $('#cy')[0],

    boxSelectionEnabled: false,
    autounselectify: true,
    layout: {
      name: 'dagre'
    },

    style: cytoscape.stylesheet()
      .selector('node')
      .css({
        'content': 'data(name)',
        'text-valign': 'center',
        'padding-left': '10px',
        'padding-right': '10px',
        'padding-top': '10px',
        'padding-bottom': '10px',
        'shape': 'roundrectangle',
        'width': 'label',
        'background-color': ' #fff',
        'color': 'black',
        'border-width': '1px',
        'border-color': '#333',
        'font-size': 14,
        'font': ' 300 14px "Helvetica Neue", Helvetica'

      })
      .selector('edge')
      .css({
        'label': 'data(label)',
        'target-arrow-shape': 'triangle',
        'target-arrow-color': 'black',
        'source-arrow-color': 'black',
        'edge-text-rotation': 'autorotate',
        'line-color': '#333',
        'width': 1.5,
        'curve-style': 'segments'
      })
      .selector(':selected')
      .css({
        'background-color': 'black',
        'line-color': 'black',
        'target-arrow-color': 'black',
        'source-arrow-color': 'black',
        'text-outline-color': 'black'
      }),

    elements: {
      'nodes': [{
        'data': {
          'id': 'CLOSED',
          'name': 'CLOSED'
        }
      }, {
        'data': {
          'id': 'LISTEN',
          'name': 'LISTEN'
        }
      }, {
        'data': {
          'id': 'SYN RCVD',
          'name': 'SYN RCVD'
        }
      }, {
        'data': {
          'id': 'SYN SENT',
          'name': 'SYN SENT'
        }
      }, {
        'data': {
          'id': 'ESTAB',
          'name': 'ESTAB'
        }
      }, {
        'data': {
          'id': 'FINWAIT-1',
          'name': 'FINWAIT-1'
        }
      }, {
        'data': {
          'id': 'CLOSE WAIT',
          'name': 'CLOSE WAIT'
        }
      }, {
        'data': {
          'id': 'FINWAIT-2',
          'name': 'FINWAIT-2'
        }
      }, {
        'data': {
          'id': 'CLOSING',
          'name': 'CLOSING'
        }
      }, {
        'data': {
          'id': 'LAST-ACK',
          'name': 'LAST-ACK'
        }
      }, {
        'data': {
          'id': 'TIME WAIT',
          'name': 'TIME WAIT'
        }
      }],
      'edges': [{
        'data': {
          'source': 'CLOSED',
          'target': 'LISTEN',
          'label': 'open'
        }
      }, {
        'data': {
          'source': 'LISTEN',
          'target': 'SYN RCVD',
          'label': 'rcv SYN'
        }
      }, {
        'data': {
          'source': 'LISTEN',
          'target': 'SYN SENT',
          'label': 'send'
        }
      }, {
        'data': {
          'source': 'LISTEN',
          'target': 'CLOSED',
          'label': 'close'
        }
      }, {
        'data': {
          'source': 'SYN RCVD',
          'target': 'FINWAIT-1',
          'label': 'close'
        }
      }, {
        'data': {
          'source': 'SYN RCVD',
          'target': 'ESTAB',
          'label': 'rcv ACK of SYN'
        }
      }, {
        'data': {
          'source': 'SYN SENT',
          'target': 'SYN RCVD',
          'label': 'rcv SYN'
        }
      }, {
        'data': {
          'source': 'SYN SENT',
          'target': 'ESTAB',
          'label': 'rcv SYN, ACK'
        }
      }, {
        'data': {
          'source': 'SYN SENT',
          'target': 'CLOSED',
          'label': 'close'
        }
      }, {
        'data': {
          'source': 'ESTAB',
          'target': 'FINWAIT-1',
          'label': 'close'
        }
      }, {
        'data': {
          'source': 'ESTAB',
          'target': 'CLOSE WAIT',
          'label': 'rcv FIN'
        }
      }, {
        'data': {
          'source': 'FINWAIT-1',
          'target': 'FINWAIT-2',
          'label': 'rcv ACK of FIN'
        }
      }, {
        'data': {
          'source': 'FINWAIT-1',
          'target': 'CLOSING',
          'label': 'rcv FIN'
        }
      }, {
        'data': {
          'source': 'CLOSE WAIT',
          'target': 'LAST-ACK',
          'label': 'close'
        }
      }, {
        'data': {
          'source': 'FINWAIT-2',
          'target': 'TIME WAIT',
          'label': 'rcv FIN'
        }
      }, {
        'data': {
          'source': 'CLOSING',
          'target': 'TIME WAIT',
          'label': 'rcv ACK of FIN'
        }
      }, {
        'data': {
          'source': 'LAST-ACK',
          'target': 'CLOSED',
          'label': 'rcv ACK of FIN'
        }
      }, {
        'data': {
          'source': 'TIME WAIT',
          'target': 'CLOSED',
          'label': 'timeout=2MSL'
        }
      }]
    }
  });

  cy.on('tap', 'node', function () {
    try { // your browser may block popups
      window.open(this.data('href'));
    } catch (e) { // fall back on url change
      window.location.href = this.data('href');
    }
  });

}); // on dom ready
EN

回答 1

Stack Overflow用户

发布于 2016-04-21 12:25:56

在2.6中增加了片段。Dagre扩展部分需要更新,但这在2.7之后才是实际的。这个特性已经在路线图中了。请参阅https://github.com/cytoscape/cytoscape.js-dagre/issues/5

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36660937

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档