Jump to content
  • Spotfire® Tips & Tricks: Access & Visualize Graph data from Neo4j in Spotfire


    This article shows how to connect, access, and display data from Neo4j, a well-known database for connected data.

    Back to main Tips & Tricks page.

    Overview

    Relational Databases are at best an approximate way of representing real-world data, as everything around us exists as entities and relationships. Owing to recent advancements in machine learning, more data is being collected that is dynamic and related. This brings in the need to represent data in unstructured and semi-structured formats which are more flexible than rows and columns. Graph databases are well-suited to store such data with flexible schema.

    This article shows how to connect, access, and display data from Neo4j, a well-known database for connected data.

    Connect & Query Neo4j

    Spotfire® uses TERR (now called Spotfire Enterprise Runtime for R) to connect and query Neo4j.

    Prerequisite

    Install Neo4j to TERR using the following snippet:

    install.packages( "RNeo4j",repos = "https://mran.revolutionanalytics.com/snapshot/2018-02-01/")

    Note that RNeo4j is not available on CRAN, so using CRAN snapshots to install is the easiest way.

    Establish Connection

    Create a data function with the following code to establish a connection with your database

    library("RNeo4j")

    library('SpotfireUtils')

    graph = startGraph(url, username=uname, password=pass)

    saveObj <- SObjectToBlob(graph)

    Here urluname, and pass are input parameters to the data function that can be configured using document properties.

    saveObj holds the connection graph object in format that can be passed to different data functions, allowing you to modularize your code.

    Query the Data

    Create a data function with the following code to query the database

    library(RNeo4j)

    library(SpotfireUtils)

    graph <- BlobToSObject(saveObj)

    query <- queryProperty

    result <- data.frame(cypher(graph, query))

    Here saveObj and queryProperty are input parameters to the data function that can be configured using document properties.

    • saveObj is the connection graph object from last step
    • queryProperty contains the cypher query

    queryProperty can be can be replaced by string cypher query. Or to make it dynamic, a text area can be set up so that the user can pass the query and execute in real time.

    Pass Cypher Query from Text Area

    In a text area insert queryProperty document property of type ?Input field: Multiple lines? and use this to type in your cypher query. Below is the ?Create Movies? example that ships with Neo4j to demonstrate the concept.

    screen_shot_2018-07-11_at_5_21.54_pm.thumb.png.a2f5dafde951e146b3e886cb3751d3af.png

    Display Graph Data in Spotfire

    By convention, graph data is parsed and extracted in standardized row, column representations. Note that the last line of cypher command shown returns an edgelist.

    There are many ways of displaying this data, some of the recommended ways are:

    1. Use Graph Libraries in R

      You can create R Graphics in Spotfire by following the linked tutorial. That enables you to make use of the many well defined graph analytics & visualization packages like ggraphvisNetwork, and sna.

    2. Use Network Graph Visualization

      You can use Network analytics custom tool in TIBCO Spotfire. Download and install TIBCO Spotfire Network Analytics product in the deployment area used by your Web Player. Once that module is added to the deployment area used by the Web Player, you will need to update your Web Player service per these instructions here.

    3. Use Templates from Spotfire Community Exchange

      You can find several plug-and-play templates on Spotfire Community Exchange under the Applications. These templates allow the user to  plug in their data and explore the insights with minimal configuration.

      screen_shot_2018-07-11_at_5_38.26_pm.thumb.png.43e94bdf536d46ff7640674cc1d13a3b.png

       

      The Network chart for Spotfire is one such template that aims at providing you with a means to create a network chart to display the multi-directional relationships between the nodes in your data. Simply upload your edgelist, change the configurations and let the template do the hard work.

    4. Follow the tutorial to create Network visualization using JSViz and ZoomCharts or create your own customizations using JSViz.

    How do I learn more?

    This summarizes briefly accessing data from neo4j in Spotfire. Watch the page and vote up to get notified about detailed updates. Watch teh Dr. Spotfire session on Neo4j Spotfire integration. You could also request a featured session on any specific method from above on Dr. Spotfire by:

    • Posting your question in the community Forums
    • Contact Dr. Spotfire directly at dr@spotfire.com

    References


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...