I previously asked how to remotely load cytoscape as a dependency. @GBE provided the following answer
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/2.7.10/cytoscape.js"></script>
So I made an HTML
file and copied verbatim introductory example from cytoscape (enclosing it in <script>code</script>
. However the result renders nothing. Why? Code below for convenience.
Mini-question: why is source enclosed as:
<script src="stuff"></script>
and everything else is
<script> code </script>
?
Intro-example
<script>
var cy = cytoscape({
container: document.getElementById('cy'), // container to render in
elements: [ // list of graph elements to start with
{ // node a
data: { id: 'a' }
},
{ // node b
data: { id: 'b' }
},
{ // edge ab
data: { id: 'ab', source: 'a', target: 'b' }
}
],
style: [ // the stylesheet for the graph
{
selector: 'node',
style: {
'background-color': '#666',
'label': 'data(id)'
}
},
{
selector: 'edge',
style: {
'width': 3,
'line-color': '#ccc',
'target-arrow-color': '#ccc',
'target-arrow-shape': 'triangle'
}
}
],
layout: {
name: 'grid',
rows: 1
}
});
</script>