Search code examples
javascripthtmljsonneo4jalchemy

Trying to display NEO4J json data in a html page through json


I'm trying to display a graph from json film went from NEO4J db. But it shows a blank page and in the console it shows an error. Here output: enter image description here Here the code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/alchemyjs/0.4.2/styles/vendor.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/alchemyjs/0.4.2/scripts/vendor.js"></script>
    <script src="lodash.js"></script>

</head>
<body>
<div class="alchemy" id="alchemy"></div>
<script type="text/javascript">
    alchemy.begin({
        dataSource: "../result.json",
        dataType:'html',
        nodeCaption:'name',
        nodeMouseOver:'name',
        cluster: true,
        clusterColours:["#1B9E77,#D95F02,#7570B3,#E7298A,#66A61E,#E6AB02"]
    })
</script>
</body>
</html>


Solution

  • I dont think that's the way to initialize the library. modify your script to

    <script type="text/javascript">
       var config ={
            dataSource: "../result.json",
            dataType:'html',
            nodeCaption:'name',
            nodeMouseOver:'name',
            cluster: true,
            clusterColours:["#1B9E77,#D95F02,#7570B3,#E7298A,#66A61E,#E6AB02"]
        };
         alchemy = new Alchemy(config);
    </script>
    

    Referencce http://graphalchemist.github.io/Alchemy/#/examples

    It looks like you are not loading the alchemyjs. you are loading only the dependency for alchemyjs. Include both the scripts

     <script src="https://cdnjs.cloudflare.com/ajax/libs/alchemyjs/0.4.2/scripts/vendor.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/alchemyjs/0.4.2/alchemy.min.js"></script>