You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Graph Visualization Library provides a comprehensive set of configuration options for customizing the appearance and behavior of your graph visualizations. This document describes the available settings and how to use them.
Overview
Graph settings are organized into three main categories:
Graph Settings - Control interactive behaviors, visual styles, and component registrations
Graph Colors - Define the color scheme for all graph elements
Graph Constants - Control sizes, spacings, and other numerical values
Applying Settings
Settings can be applied when creating a new graph instance:
import{Graph}from'@gravity-ui/graph';// Create a graph instance with custom settingsconstgraph=newGraph({settings: {canDragCamera: true,canZoomCamera: true,useBezierConnections: true,// other settings...},},document.getElementById("graph-container"));
You can also update settings after graph creation:
// Update specific settingsgraph.updateSettings({showConnectionArrows: true,canChangeBlockGeometry: 'onlySelected',});// Change color schemegraph.setColors({block: {background: '#f5f5f5',border: '#cccccc',},});// Update constantsgraph.setConstants({block: {WIDTH: 300,HEIGHT: 200,},});
Graph Settings Configuration
These settings control the interactive behaviors and visual styles of the graph.
Setting
Type
Default
Description
canDragCamera
boolean
true
Controls whether the camera can be dragged (panned)
canZoomCamera
boolean
true
Controls whether the camera can be zoomed in/out
canChangeBlockGeometry
ECanChangeBlockGeometry
'none'
Determines which blocks can be resized or moved. Options: 'all', 'onlySelected', 'none'
canCreateNewConnections
boolean
false
Controls whether users can create new connections
scaleFontSize
number
1
Scale factor for font sizes throughout the graph
showConnectionArrows
boolean
true
Controls visibility of arrows at the end of connections
useBezierConnections
boolean
true
Use bezier curves for connections instead of straight lines
bezierConnectionDirection
'vertical' | 'horizontal'
'horizontal'
Direction of bezier connections
useBlocksAnchors
boolean
true
Controls whether blocks should display anchors for connections
showConnectionLabels
boolean
false
Controls visibility of connection labels
blockComponents
Record<string, typeof Block>
{}
Registry of custom block components
connection
typeof BlockConnection
undefined
Custom connection component
background
typeof Component
undefined
Custom background component
Graph Colors
Colors control the visual appearance of all graph elements.
Canvas Colors
Property
Default
Description
belowLayerBackground
'#eaeaea'
Background color for the layer below the main graph
layerBackground
'#f9f9f9'
Background color for the main graph layer
dots
'#d0d2ce'
Color of the background dots
border
'#EAEAEAFF'
Color of the canvas border
Block Colors
Property
Default
Description
background
'#e0e0e0'
Background color of blocks
border
'#dfdfdf'
Border color of blocks
text
'#272727'
Text color within blocks
selectedBorder
'#FFCC00'
Border color of selected blocks
Anchor Colors
Property
Default
Description
background
'#4a4a4a'
Background color of anchors
selectedBorder
'#FFCC00'
Border color of selected anchors
Connection Colors
Property
Default
Description
background
'#272727'
Color of connections
selectedBackground
'#ecc113'
Color of selected connections
Connection Label Colors
Property
Default
Description
background
'#EAEAEA'
Background color of connection labels
hoverBackground
'#FFCC00'
Background color of connection labels on hover
selectedBackground
'#FFCC00'
Background color of selected connection labels
text
'#777677'
Text color of connection labels
hoverText
'#777677'
Text color of connection labels on hover
selectedText
'#777677'
Text color of selected connection labels
Selection Colors
Property
Default
Description
background
'rgba(0, 0, 0, 0.051)'
Background color of selection rectangle
border
'#ecc113'
Border color of selection rectangle
Graph Constants
Constants control the sizing, spacing, and other numerical values used throughout the graph.
System Constants
Constant
Default
Description
GRID_SIZE
16
Base grid size for layout calculations
USABLE_RECT_GAP
400
Gap around the usable rect area
CAMERA_VIEWPORT_TRESHOLD
0.5
Threshold for camera viewport
Camera Constants
Constant
Default
Description
SPEED
1
Camera movement speed
STEP
0.008
Step size for camera zoom
Block Constants
Constant
Default
Description
SCALES
[0.125, 0.225, 0.7]
Scale thresholds for different levels of detail. These values determine when the block switches between rendering modes:\n- First value (0.125): Below this zoom level, blocks are rendered in minimalistic mode showing just basic shapes\n- Second value (0.225): Between first and second value, blocks are rendered in schematic mode with basic details\n- Third value (0.7): Above this zoom level, blocks are rendered in detailed mode with full information