npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

neo4jd3-graph

v1.0.3

Published

The neo4jd3-graph npm package is a tool designed for visualizing Neo4j graph data. This package utilizes the power of D3.js (version 4.2.1) for rendering interactive and dynamic graphs representing relationships within Neo4j databases. The visualization i

Downloads

18

Readme

neo4jd3-graph

The "neo4jd3-graph" npm package is a tool designed for visualizing Neo4j graph data. This package utilizes the power of D3.js (version 4.2.1) for rendering interactive and dynamic graphs representing relationships within Neo4j databases. The visualization is enhanced with Font Awesome icons (version 4.7.0) to provide a rich and aesthetically pleasing representation.

Authors

Installation

Install with npm

  npm i neo4jd3-graph

Usage/Example

  • Import the necessary components and styles in your React application:

js or ts

import React, { useEffect } from 'react';
import { Neo4jGraph, CreateGraphInterface } from 'neo4jd3-graph';
import './App.css';
  • Define your Neo4j graph data. The data should follow the format specified in the Neo4j response:

Neo4j data format

{
    "results": [
        {
            "columns": ["user", "entity"],
            "data": [
                {
                    "graph": {
                        "nodes": [
                            {
                                "id": "1",
                                "labels": ["User"],
                                "properties": {
                                    "userId": "eisman"
                                }
                            },
                            {
                                "id": "8",
                                "labels": ["Project"],
                                "properties": {
                                    "name": "neo4jd3",
                                    "title": "neo4jd3.js",
                                    "description": "Neo4j graph visualization using D3.js.",
                                    "url": "https://eisman.github.io/neo4jd3"
                                }
                            }
                        ],
                        "relationships": [
                            {
                                "id": "7",
                                "type": "DEVELOPES",
                                "startNode": "1",
                                "endNode": "8",
                                "properties": {
                                    "from": 1470002400000
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "errors": []
}
  • Create a React functional component and use the Neo4jGraph component:
function App() {
  const { renderGraph } = Neo4jGraph();

  useEffect(() => {
    const graphConfig: CreateGraphInterface = {
      parentElement: "#canva",
      options: {
        neo4jData: data as any,
        nodeRadius: 25,
        onNodeClick(d) {
          console.log("Node clicked:", d);
        },
        colors: ["red"],
        onRelationshipDoubleClick(d) {
          console.log("Relationship double-clicked:", d);
        },
        infoPanel: true,
        showIcons: true,
        zoomFit: true
      }
    };
    renderGraph(graphConfig);
  }, []);

  return (
    <div className="App">
      <div id="canva"></div>
    </div>
  );
}

export default App;
  • Customize the graphConfig object with the desired options for your graph visualization.
  • Run your React application, and the Neo4j graph visualization should be displayed in the specified HTML element.

Options

| Parameter | Type | Description | | --------- | ---- | ----------- | | highlight | array | Highlight several nodes of the graph.Example:[    {        class: 'Project',        property: 'name',        value: 'neo4jd3'    }] | | icons | object | Map node labels to Font Awesome icons.Example:{    'BirthDate': 'birthday-cake',    'Password': 'lock',    'Phone': 'phone',    'User': 'user'}. | | images | object | Map node labels to SVG images (e.g. using Twitter Emoji).Example:{    'Address': 'img/twemoji/1f3e0.svg',    'BirthDate': 'img/twemoji/1f382.svg',    'Password': 'img/twemoji/1f511.svg',    'Project': 'img/twemoji/2198.svg',    'Project\|name\|neo4jd3': 'img/twemoji/2196.svg',    'User': 'img/twemoji/1f600.svg'}. | | infoPanel | boolean | Show the information panel: true, false. Default: true. | | minCollision | int | Minimum distance between nodes. Default: 2 * nodeRadius. | | neo4jData | object | Graph data in Neo4j data format. | | neo4jDataUrl | string | URL of the endpoint that serves the graph data in Neo4j data format. | | nodeRadius | int | Radius of nodes. Default: 25. | | onNodeClick | function | Callback function to be executed when the user clicks a node. | | onNodeDoubleClick | function | Callback function to be executed when the user double clicks a node. | | onNodeDragEnd | function | Callback function to be executed when the user finishes dragging a node. | | onNodeDragStart | function | Callback function to be executed when the user starts dragging a node. | | onNodeMouseEnter | function | Callback function to be executed when the mouse enters a node. | | onNodeMouseLeave | function | Callback function to be executed when the mouse leaves a node. | | onRelationshipDoubleClick | function | Callback function to be executed when the user double clicks a relationship. | | zoomFit | boolean | Adjust the graph to the container once it has been loaded: true, false. Default: false. |

License

MIT

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.