简体   繁体   English

Cytoscape.js eles.style更改立即更新

[英]Cytoscape.js eles.style changes update immediately

I am using Cytoscape.js 2.7.15 for my graduation project and i need to make some simple visualizations like changing the labels of nodes. 我正在为毕业项目使用Cytoscape.js 2.7.15 ,我需要进行一些简单的可视化处理,例如更改节点的标签。

subjectNode.style('label',myDesiredLabelToshow); subjectNode.style( '标签',myDesiredLabelToshow);

works for me but i am using it in a for loop and when i want to make it slowly or in debug mode to see how my algorithms works to label them, the labels of nodes do not change immediately, they change eventually together after my function ends (i mean hit to end scope of function). 为我工作,但我在for循环中使用它,当我想使其缓慢运行或在调试模式下查看我的算法如何为它们添加标签时,节点的标签不会立即更改,它们在我的功能后最终会一起更改结束(我指的是功能的结束范围)。

I tried to use cy.batch(); 我尝试使用cy.batch(); cy.startBatch() even tried to set Timeout but nothing worked. cy.startBatch()甚至尝试设置Timeout但没有任何效果。

After tracking cytoscape.js file in debug mode i saw a function o.requestAnimationFrame = function.. after debugger hits that changes are applied on my graph, how can i manually trigger it in my custom functions? 在调试模式下跟踪cytoscape.js文件后,我看到了一个函数o.requestAnimationFrame = function ..在调试器命中后,更改已应用到我的图形上,如何在我的自定义函数中手动触发它?

Pretty much any renderer is going to use a render loop using requestAnimationFrame() . 几乎所有渲染器都将通过requestAnimationFrame()使用渲染循环。 That means it's async, and you won't see results while stepping. 这意味着它是异步的,步进时不会看到结果。

The answer is not to use breakpoints or stepping, because those methods assume everything works synchronously. 答案是不要使用断点或步进,因为这些方法假定一切都同步进行。

Use a button in your UI to "step" through points in your algorithm, or use animations in a promise chain to visualise progression. 使用UI中的按钮来“逐步”遍历算法中的点,或使用Promise链中的动画来可视化进度。 Or forgo showing debugging cues in the UI itself and just use console.log() . 或者放弃在UI本身中显示调试提示,而仅使用console.log()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM