cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to display the neo4jData instead of the neo4jDataUrl

rosdiana
Node Clone

Hi everyone!

I am working how to display the graph. I use d3.js from https://github.com/eisman/neo4jd3 to display the graph. It is currently taking the data from a json file.

2X_d_d38ba02f1cebe057926095e42aa69b3c3918bc36.png

But i want display data after search from ne04j database. Below is my code in Python.

def get_friends_of(tx, name):
    movies= []
    result = tx.run("MATCH (a:Person)"
                         "WHERE a.name STARTS WITH $name "
                         "RETURN a AS friend", name=name).data()
    
    #MATCH (tom:Person {name: "Tom Hanks"})-[:ACTED_IN]->(tomHanksMovies) RETURN tom,tomHanksMovies

    for record in result:
        #print(type(record))
        #convert to JSON string
        
        
        movies.append(record["friend"])
        
    return movies

@app.route("/list_movie", methods=['POST'])
def hello2():

    rf=request.form
    print(rf)
    for key in rf.keys():
        data=key
    #print(data)
    data_dic=json.loads(data)
    print(data_dic.keys())
    name_d = data_dic['name'][0]

    print("Read data.....................")
    print(name_d)
    with driver.session() as session:
        friends = session.read_transaction(get_friends_of, name_d)
        jsonStr = json.dumps(friends)
        #print json string
        print(jsonStr)
        
    driver.close()

    resp_dic={'mov_str':jsonStr,'msg':'Success!'}
    resp = jsonify(resp_dic)
    resp.headers['Access-Control-Allow-Origin']='*'

    print("Success process")
    print(resp_dic)

    return resp

if __name__ == "__main__":
    app.run()
    

Below the demo that will display the node after searching.

Thank you for any help.

0 REPLIES 0