0

I am trying to run some code that uses cytoscape.js. The problem is that after I run the file, sometimes it do show up the graph but most of the time it is not.

I am currently using Eclipse Luna and this code is in a jsp file.

Here is my code :

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TEST</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cytoscape.github.io/cytoscape.js/api/cytoscape.js-latest/cytoscape.min.js"></script>

<script type="text/javascript">
$(function(){ 

 var cy = cytoscape({
  container: $('#cy')[0],
  
  boxSelectionEnabled: true,
  autounselectify: true,
  
  style: cytoscape.stylesheet()
    .selector('node')
      .css({
        'content': 'data(name)',
        'text-valign': 'center',
        'color': 'white',
        'text-outline-width': 2,
        'text-outline-color': '#888'
      })
    .selector(':selected')
      .css({
        'background-color': 'black',
        'line-color': 'black',
        'target-arrow-color': 'black',
        'source-arrow-color': 'black',
        'text-outline-color': 'black'
      }),
      
  elements: {
    nodes: [
      { data: { id: 'a', name: 'Sheraton Cherry' } },
      { data:  { id: 'a1', name: 'Rosacea'}},
      { data: { id: 'a2', name: 'Dentate' } },
      { data: { id: 'a3', name: 'Pinnate' } },
      { data: { id: 'b', name: 'Pineapple Guava' } },
      { data:  { id: 'b1', name: 'Myrtaceae'}},
      { data: { id: 'b2', name: 'Entire' } },
      { data: { id: 'a3', name: 'Pinnate' } }
      
    ],
    edges: [
      { data: { source: 'a1', target: 'a' }},
      { data: { source: 'a2', target: 'a' }},
      { data: { source: 'a3', target: 'a' }},
      { data: { source: 'b1', target: 'b'}},
      { data: { source: 'b2', target: 'b'}},
      { data: { source: 'a3', target: 'b'}}
    ]
  },
  
  layout: {
    name: 'circle',
    padding: 30
  }
});


});
</script>
</head>
<body>
</body>
</html>
yugantar kumar
  • 1,982
  • 1
  • 23
  • 33
kaixas K
  • 111
  • 12

1 Answers1

0

I've found the solution and it is actually just because I do not have the file in my local folder and that's it.

Beginner mistake I guess.

kaixas K
  • 111
  • 12