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.

Frequently Asked Questions

FalkorDB Canvas is a standalone web component for visualizing FalkorDB graphs with force-directed layouts. It is published on npm as @falkordb/canvas and is the same component that powers graph visualization inside FalkorDB Browser.
Install it from npm with npm install @falkordb/canvas, import the package, and place a falkordb-canvas element in your page. Importing the module registers the custom element for you.
Yes. It is a standard Web Component, so it works with any framework or with plain JavaScript. The package ships full TypeScript definitions, and the Quick Start above includes both a vanilla JavaScript and a React/TypeScript example.
No. Canvas is a rendering component — it draws whatever nodes and links you hand it through setData(). Run your Cypher query with a FalkorDB client, convert the result into nodes and links, and pass that to the canvas.
Three: force (the default D3 force simulation), tree (hierarchical), and radial. Switch between them with setLayout('tree') and tune each one through setLayoutOptions().
Enable the largeGraph options to turn on viewport culling and skip expensive details at low zoom, call setAnimation(false) once the layout settles to stop the simulation, and prefer a deterministic layout such as tree for static graphs. getCullingStats() shows how many nodes and links are actually being drawn.
Save the view with getViewport() before replacing the data, then restore it with setViewport() afterwards. This prevents the jarring re-fit that otherwise happens on every setData() call.
The latest versions of Chrome, Edge, Firefox, and Safari. It needs Custom Elements, Shadow DOM, ES Modules, and HTML5 Canvas support.