vGraph has carefully designed common interactions in relationship graphs and has precipitated them into tools for easy reuse. The count badge is mostly used in tree graphs to display the number of collapsed nodes when a node collapses its children. The count badge tool will automatically adapt to the text length, and clicking on the number will expand the children again. You can experience this in the Compact Tree Collapse/Expand demo.
import { CountBadgeUtils } from'@visactor/vgraph';
// Initialize the node's badgebadgeLayer = CountBadgeUtils.init(node, options);
// Destroy the corresponding badge on the nodeCountBadgeUtils.remove(node, badgeLayer);
The count badge configuration is as follows:
Field
Type
Description
text
string
[Required] The text displayed on the badge.
position
'left' | 'right' | 'top' | 'bottom'
The positioning of the badge. It currently supports the four directions of top, bottom, left, and right of the node. The default is the right side.