【问题标题】:Adjust shape size in cytoscape.js with dagre layout使用 dagre 布局调整 cytoscape.js 中的形状大小
【发布时间】:2016-05-14 19:02:19
【问题描述】:

我正在尝试将节点的形状调整为节点文本的大小。我按照https://github.com/cytoscape/cytoscape.js/issues/649 的指示进行操作。然而:

  1. 形状总是以 height = width 结尾
  2. 所有形状的大小都是一样的。
  3. 形状大小似乎达到了无法增长的最大值。

(我不确定这是否与 dagre 布局有关。)

我正在使用以下带有 dagre 布局的库:

  • cytoscape.min.js
  • dagre.min.js
  • cytoscape-dagre.js

    container: document.getElementById('cy'),
    boxSelectionEnabled: false, autounselectify: true,
    
    layout: {name: 'dagre', rankDir: 'LR', align: 'LR'},
    
    style: [{
        selector: 'node',
        style: {
            'content': 'data(name)',
            'label': 'data(name)',
            'text-opacity': 1,
            'text-valign': 'center',
            'text-halign': 'center',
            'text-wrap': 'wrap',
            'font-size': 9,
            'background-color': '#AAA',
            'shape':'rectangle',
            'width': 'data(width)' * 50,
            'height': 'data(height)' * 50 }
    },{
        selector: 'edge',
        style: {
            'width': 4,
            'content': 'data(name)',
            'target-arrow-shape': 'triangle',
            'line-color': 'data(color)',
            'text-wrap': 'wrap',
            'target-arrow-color': 'data(color)',
            'font-size': 10,
        }
    }]
    

【问题讨论】:

    标签: javascript layout graph cytoscape.js dagre


    【解决方案1】:

    您指定的样式无效。 "somestring" * 50NaN

    您想要width: label,如文档中所示:http://js.cytoscape.org/#style/node-body

    【讨论】:

    • 谢谢马克斯。现在可以了。我正在搜索该站点,但不知何故忽略了该部分。这很有帮助。再次感谢。
    • 该属性已弃用:“label 的样式值已弃用 width
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多