簡體   English   中英

如何在python dash_cytoscape中設置同心圓布局參數?

[英]How to set the concentric circle layout parameters in python dash_cytoscape?

我已經定義了我的元素,例如 level 指的是我想要該節點的圓層。

 elements = [{'data': {'id': 'a', 'label': 'a', 'level': 1},
             {'data': {'id': 'b', 'label': 'b', 'level': 1},
             {'data': {'id': 'c', 'label': 'c', 'level': 2},
             .......]

我嘗試了以下不起作用的方法(錯誤加載布局)

app.layout = html.Div([
    cyto.Cytoscape(
        id='cytoscape',
        elements= elements,
        layout={'name': 'concentric', 'concentric': lambda x: x['data']['level']}
    )
])

javascript 文檔在這里https://js.cytoscape.org/#layouts並指定

let options = {
  name: 'concentric',
  concentric: function( node ){ // returns numeric value for each node, placing higher nodes in levels towards the centre
  return node.degree();
  }

我如何設置這個同心參數?

干杯

不幸的是,不可能將 python 函數傳遞給cyto.Cytoscape組件中的layout參數。 這是因為該函數不會被轉譯為 JS 函數,而這是concentric鍵在options內工作所需要的。

替代方案是:

  1. 使用python網絡庫(例如networkX)根據同心算法分配x/y位置,然后使用dash-cytoscape中的自定義布局(而不是同心布局)返回確切位置。
  2. 修改cyto.Cytoscape的源代碼並硬編碼您要用於同心布局的 JS function 您需要按照貢獻說明來構建和創建自定義安裝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM