一个功能强大的Neo4j图数据库可视化编辑器,支持双视图(树视图和网络图视图)编辑和管理图数据。
- 双视图编辑:同时支持树视图和网络图视图,满足不同场景的需求
- 实时同步:两个视图之间的数据实时同步,确保一致性
- 属性编辑:支持节点和关系的属性编辑、添加和删除
- 标签管理:支持Neo4j节点标签的管理
- 数据导入导出:支持JSON格式的数据导入导出
- Neo4j集成:支持与Neo4j数据库的连接、数据导入和导出
- 上下文菜单:右键菜单提供快捷操作
- 响应式设计:适配不同屏幕尺寸
frontend/
├── index.html # HTML入口文件
├── js/ # JavaScript源代码目录
│ ├── core/ # 核心模块
│ │ └── init.js # 初始化模块
│ ├── views/ # 视图相关模块
│ │ ├── viewManager.js # 视图管理器
│ │ ├── viewSync.js # 视图同步管理器
│ │ └── graphEditor.js # 图编辑器核心功能
│ ├── data/ # 数据管理模块
│ │ └── graphDataManager.js # 图数据管理器
│ ├── ui/ # UI组件模块
│ │ └── contextMenuManager.js # 上下文菜单管理器
│ ├── neo4j/ # Neo4j相关模块
│ │ └── apiManager.js # Neo4j API管理器
│ ├── components/ # 组件模块
│ │ └── propertyEditor.js # 属性编辑器
│ ├── utils/ # 工具函数
│ │ └── utils.js # 通用工具函数
│ └── index.js # 主入口JavaScript文件
└── 双视图功能开发计划.md # 功能开发计划文档
- init.js: 负责应用的初始化,模块加载和系统配置
- viewManager.js: 管理视图模式切换(双视图/单视图),视图控制等
- viewSync.js: 管理两个视图之间的数据同步和事件同步
- graphEditor.js: 提供图编辑的核心功能,如节点选择、创建、删除等
- graphDataManager.js: 管理图数据的存储、过滤、导出等操作
- contextMenuManager.js: 管理右键上下文菜单的显示和操作
- apiManager.js: 处理与Neo4j数据库的通信,包括连接测试、数据导入导出等
- propertyEditor.js: 实现属性编辑面板的功能
- utils.js: 提供通用的工具函数,如数组操作、唯一ID生成、深拷贝等
- 确保您的浏览器支持现代JavaScript特性
- 在前端目录下启动一个HTTP服务器(如Python的http.server)
- 在浏览器中访问相应的URL
- 创建节点:在空白区域右键点击,选择"创建节点"
- 创建关系:右键点击源节点,选择"创建关系",然后点击目标节点
- 编辑属性:选择节点或关系后,在左侧属性面板中编辑
- 删除元素:选择元素后,使用右键菜单或删除键删除
- 视图切换:点击工具栏中的视图模式按钮切换视图模式
- 布局刷新:点击视图控制区的"刷新布局"按钮重排元素
- 在左侧面板填写Neo4j连接信息
- 点击"保存设置"保存配置
- 点击"连接Neo4j"测试连接
- 使用"从Neo4j导入"和"导出到Neo4j"进行数据交换
- 前端框架:原生JavaScript
- 图形库:Cytoscape.js (v3.26.0)
- 布局算法:cose-bilkent
- 样式:纯CSS
- API通信:Fetch API
支持所有现代浏览器的最新版本,包括:
- Chrome
- Firefox
- Safari
- Edge
本项目为开源项目,仅供学习和参考使用。
- 大型图数据可能会影响性能,建议分批加载和处理
- 本地存储的数据可能会受到浏览器存储限制
- 连接Neo4j数据库时,请确保网络连接正常且数据库配置正确
- Node Operations: Create, delete, and edit nodes with custom properties
- Relationship Operations: Create, delete, and edit relationships between nodes
- Batch Operations: Apply properties to multiple selected nodes
- Cypher Preview: Real-time Cypher query generation based on user actions
- Neo4j Integration: Connect to Neo4j database and load/save graphs
- Custom Node Types: Create custom node types with different colors and icons
- Custom Relationship Types: Create custom relationship types with different colors
- Frontend: HTML, CSS (Tailwind CSS), JavaScript, Cytoscape.js
- Backend: Python, Flask, neo4j-driver
- Python 3.7 or higher
- Neo4j database (local or remote)
- Clone the repository:
git clone https://github.com/yourusername/neo4j-visual-editor.git
cd neo4j-visual-editor- Install backend dependencies:
cd backend
pip install -r requirements.txt- Create a
requirements.txtfile in the backend directory:
Flask==2.0.1
Flask-CORS==3.0.10
neo4j==4.4.1
- Run the backend server:
python app.py- Open the frontend in a web browser:
cd ../frontend
open index.html- Click the "Connect" button in the top right corner
- Enter your Neo4j connection details (URI, username, password)
- Click "Connect" to establish a connection
- Select a node type from the left sidebar (Person, Movie, Book, Company, etc.)
- Click the "Node" button in the top left corner to enter node creation mode
- Click anywhere on the canvas to create a new node
- Edit the node properties in the right sidebar and click "Apply"
- Select a relationship type from the left sidebar (ACTED_IN, DIRECTED, etc.)
- Click the "Relationship" button in the top left corner to enter relationship creation mode
- Click on a source node, then click on a target node to create a relationship
- Edit the relationship properties in the right sidebar and click "Apply"
- Select a node or relationship by clicking on it
- Edit the properties in the right sidebar
- Click "Apply" to save the changes
- Select multiple nodes by holding down the Shift key and clicking on nodes
- Enter a property key and value in the "Batch Operations" panel at the bottom of the right sidebar
- Click "Apply to Selected" to apply the property to all selected nodes
- The Cypher query corresponding to your current operation is displayed in the bottom panel
- Click "Run" to execute the Cypher query against the connected Neo4j database
- Click "Clear" to clear the Cypher preview panel
- Click the "Export" button in the left sidebar
- The graph will be downloaded as a JSON file
- Click the "Add" button in the "Node Types" panel
- Enter a name, select an icon, and choose a color
- Click "Add" to create the new node type
- Click the "Add" button in the "Relationship Types" panel
- Enter a name and choose a color
- Click "Add" to create the new relationship type
This project is licensed under the MIT License - see the LICENSE file for details.