Skip to main content
FalkorDB Canvas is a standalone web component for visualizing FalkorDB graphs using force-directed layouts. It is published as an npm package at @falkordb/canvas and powers the graph visualization in FalkorDB Browser.

Features

  • Force-directed graph layout – Automatic positioning using D3 force simulation with smart collision detection
  • Multiple layout modes – Switch between force, tree, and radial graph views
  • Interactive – Click, hover, and right-click interactions on nodes, links, and background
  • Theme support – Light and dark mode with customizable colors
  • Performance – Optimized rendering with HTML5 Canvas, including viewport culling and low-zoom draw skipping for large graphs
  • Loading states – Built-in skeleton loading with pulse animation
  • Customizable – Colors, sizes, behaviors, and custom rendering functions
  • TypeScript support – Full type definitions included
  • Web Component – Works with any framework or vanilla JavaScript
  • Viewport control – Zoom, pan, and auto-fit functionality

Installation


Quick Start

Vanilla JavaScript

React / TypeScript


API

Methods


Configuration Options

Configuration is passed to setConfig() as a ForceGraphConfig object.

Top-Level Options

Event Handlers


Layout Modes

Use layoutMode in setConfig to choose the graph view style:

Force (default)

The default physics-based layout using D3 force simulation with configurable physics parameters.

Tree

Radial


Data Types

Node


Custom Rendering

You can provide custom rendering functions for nodes and links:
The node-mode and link-mode HTML attributes control how custom rendering combines with default rendering:
  • replace (default for nodes) – Uses custom rendering exclusively
  • before – Renders custom content before default rendering
  • after (default for links) – Renders custom content after default rendering

Large-Graph Optimizations

For graphs with thousands of nodes and links, configure viewport culling and low-zoom draw skipping:

Utility Functions

The package exports utility functions for data manipulation:

Performance Tips

  1. Large graphs – Disable animation (setAnimation(false)) once the layout stabilizes
  2. Static graphs – Use a deterministic layout (setLayout('tree')) to avoid simulation overhead
  3. Custom rendering – Optimize your custom nodeCanvasObject and linkCanvasObject functions
  4. Viewport – Use getViewport() and setViewport() to preserve the user’s view when updating data
  5. Very large graphs – Enable viewport culling via the largeGraph option

Browser Support

  • Chrome / Edge (latest)
  • Firefox (latest)
  • Safari (latest)
Requires support for Web Components (Custom Elements), ES Modules, Shadow DOM, and HTML5 Canvas.