2016-02-04 646 views
1

我正在嘗試調整節點的形狀以適應節點文本的大小。我遵循https://github.com/cytoscape/cytoscape.js/issues/649的說明。但是:使用dagre佈局調整cytoscape.js中的圖形大小

  1. 形狀總是最終與高度=寬度
  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, 
        } 
    }] 
    

回答

0

您已指定無效樣式。 "somestring" * 50NaN

你想width: label,如文檔指出:http://js.cytoscape.org/#style/node-body

+0

由於最大。它現在有效。我在搜索這個網站,但不知何故忽略了該部分。這有很大幫助。再次感謝。 – Marcus