[英]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
内工作所需要的。
替代方案是:
cyto.Cytoscape
的源代码并硬编码您要用于同心布局的 JS function
。 您需要按照贡献说明来构建和创建自定义安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.