[英]Cytoscape.js: style doesn't apply
I am using Cytoscape.js in Ember app. 我在Ember应用程序中使用Cytoscape.js。 I have created a component for graph. 我已经为图形创建了一个组件。 I try to set graph stylesheet in the didInsertElement
function of the component like this: 我尝试在组件的didInsertElement
函数中设置图形样式表,如下所示:
this.get("cy").style()
.selector('node')
.css({
'width': '100px',
'height': '100px',
'border-color': 'gray',
'border-width': 3,
'border-opacity': 0.5
})
// unimportant code here
.selector('.faded')
.css({
'opacity': 0.0,
'text-opacity': 0
}).update();
When I access route with this component in Ember, the style isn't applied (however layout and other things are working properly). 当我在Ember中使用此组件访问路由时,未应用样式(但是布局和其他功能正常工作)。 When I transit to another route and than back, style magically appears. 当我转乘另一条路线而不是返回时,会神奇地出现样式。
What am I doing wrong? 我究竟做错了什么? How to apply the style on "first load"? 如何将样式应用于“首次加载”?
EDIT: Full code can be found here The handlebars code is simple: 编辑:完整代码可以在这里找到把手代码很简单:
<div class="container content-section" id="graph-content">
<div class="centre" style="margin: 10px">
<!-- cytoscape graph -->
<div id="cy"></div>
</div>
Problem solved - it was my mistake. 问题解决了-这是我的错误。 The style of node is based on category
, which belongsTo node and is loaded asynchronously. 节点的样式基于category
,属于categoryTo节点,并异步加载。 When I insert nodes into the graph, the nodes promise is already fullfiled, however the nested relationships aren't fullfilled yet, so the node style is undefined
. 当我在图中插入节点时,promise的节点已经满了,但是嵌套的关系还没有满,所以节点样式是undefined
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.