问题描述
作为cytoscape.js
的新手,我可能会缺少明显的东西.如果是这样,请原谅我.
我正在研究提供的第一个示例此处:
来自此页面
提供了三个文件-HTML,CSS,JavaScript-以及这三个文件在加载到我的浏览器中后会创建一个正在运行的示例的印象.
但是HTML似乎不完整,可能有两种方式:
- 需要通过脚本标签包含jsbin页面上的JavaScript
- 在我可以看到的任何地方都没有定义变量
cy
,导致在控制台中出现此错误消息:对象#cy
没有方法cytoscape
关于该错误消息的堆栈溢出搜索可以指向非常好的cy.js文档,但是,las,我还是一头雾水:在哪里初始化"cy"对象?
最重要的是,在哪里可以找到一个完整的工作示例,该示例对像我这样的原始初学者很有用,我可以仔细研究并研究一些东西,直到我开始理解这种编程风格的逻辑并利用这个非常好的图书馆?
谢谢!
我真的不知道您的JavaScript是什么. jQuery的知识水平,但似乎您可能需要稍作练习.
-
是的,如果您引用的是以下标记:
<script src="http://cytoscape.github.io/cytoscape.js/api/cytoscape.js-latest/cytoscape.min.js"></script>
这确实是必要的,因为它是
cytoscape.js
的基础,例如,库本身允许将方法cytoscape
添加到变量#cy
中,正如您在第二点中提到的那样. /p> -
变量
#cy
是div
本身. jQuery以此方式用#引用对象ID.所以:<div id="cy"></div>
可以称为$(#cy"). Wich在库本身中添加了
cytoscape
函数.
我认为这个实时示例确实不错,尽管您链接的是用cytoscape.js
的基本结构和初始化更为基础和适当.我建议您以jQuery(这门课程对我来说真的很清楚)来认识并阅读 cytoscape.js
文档,其中包含许多丰富的示例.
Being brand new to cytoscape.js
, I may be missing something obvious. Please forgive me if that is so.
I am studying the first example offered here:
reached from this page
Three files are offered -- HTML, CSS, JavaScript -- along with the impression that these three will, when loaded into my browser, create a running example.
But the HTML seems to be incomplete, possibly in two ways:
- the JavaScript on the jsbin page needs to be included via a script tag
- the variable
cy
is not defined anywhere that I can see, leading to this error message in the console: Object#cy
has no methodcytoscape
A stack overflow search on that error message points back to the very fine cy.js documentation, but alas, I am still in the dark: where do I initialize the "cy" object?
And best of all, where can I find a complete working example, useful for such a raw beginner as myself, something I can pore over and study until I begin to grasp the logic of this style of programming, and make use of this very fine library?
Thanks!
I really don't know what's your JavaScript & jQuery knowledge level, but it seems you may need to practice it all a little.
Yes, if you're referring to the following tag:
<script src="http://cytoscape.github.io/cytoscape.js/api/cytoscape.js-latest/cytoscape.min.js"></script>
This is indeed necessary, as it is the basis of
cytoscape.js
, the library itself, wich allows, for instance, add the methodcytoscape
to the variable#cy
, as you mentioned in your second point.The variable
#cy
is thediv
itself. jQuery refers to objects IDs this way, with #. So:<div id="cy"></div>
Can be referred as $("#cy"). Wich adds the
cytoscape
function to it is the library itself.
I think that this live example is really good, although the one you linked is more basic and appropriate to get known with the basic structure and initialization of cytoscape.js
. I suggest you to get known with jQuery (this course was really clear to me) and read the cytoscape.js
documentation, which is full of rich examples.
这篇关于实时代码示例:cytoscape.js初始化-不完整?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!