createGraph({data: {nodes: [{ id: 'node-1', style: { x: 200, y: 100 } },{ id: 'node-2', style: { x: 360, y: 100 } },{ id: 'node-3', style: { x: 280, y: 220 } },],edges: [{ source: 'node-1', target: 'node-2' },{ source: 'node-1', target: 'node-3' },{ source: 'node-2', target: 'node-3' },],},node: {style: { fill: '#7e3feb' },state: {custom: { fill: '#ffa940' },},},edge: {stroke: '#8b9baf',state: {custom: { stroke: '#ffa940' },},},behaviors: [{type: 'brush-select',key: 'brush-select',},],plugins: [{ type: 'grid-line', size: 30 }],animation: true,},{ width: 600, height: 300 },(gui, graph) => {const options = {key: 'brush-select',type: 'brush-select',animation: false,enable: true,enableElements: ['node', 'edge', 'combo'],immediately: false,mode: 'default',state: 'selected',trigger: 'shift+drag',};const optionFolder = gui.addFolder('BrushSelect Options');optionFolder.add(options, 'type').disable(true);optionFolder.add(options, 'animation');optionFolder.add(options, 'enable');optionFolder.add(options, 'enableElements', [['node', 'edge', 'combo'],['node', 'edge'],['node', 'combo'],['combo', 'edge'],['node'],['edge'],['combo'],]);optionFolder.add(options, 'trigger', {'shift+drag': ['shift'],drag: [],});optionFolder.add(options, 'state', ['active', 'selected', 'custom']);optionFolder.add(options, 'mode', ['union', 'intersect', 'diff', 'default']).onChange((e) => {immediately.show(e === 'default');});const immediately = optionFolder.add(options, 'immediately');optionFolder.onChange(({ property, value }) => {graph.updateBehavior({key: 'brush-select',[property]: value,});graph.render();});},);
string
Behavior key, that is, the unique identifier
Used to identify the behavior for further operations
// Update behavior optionsgraph.updateBehavior({key: 'key', ...});
string
Behavior type
boolean Default:
false
Whether to enable animation.
boolean | ((event: Event) => boolean) Default:
true
Whether to enable Brush select element function.
'node' | 'edge' | 'combo'__[] Default:
['node', 'combo', 'edge']
Enable Elements type.
boolean Default:
false
Whether to brush select immediately, only valid when the brush select mode is default
'union' | 'intersect' | 'diff' | 'default' Default:
'default'
Brush select mode
'union'
: Keep the current state of the selected elements and add the specified state.
'intersect'
: If the selected elements already have the specified state, keep it; otherwise, clearBrush it.
'diff'
: Perform a negation operation on the specified state of the selected elements.
'default'
: Clear the current state of the selected elements and add the specified state.
(states: Record**<**string__, string | string__[]>) => Record**<**string__, string | string__[]>
Callback when brush select elements.
string Default:
'selected'
The state to switch to when selected.
RectStyleProps
Timely screening.
string[] Default:
['shift']
Press this shortcut key to apply brush select with mouse click.
Note that setting trigger
to ['drag']
will cause the drag-canvas
behavior to fail. The two cannot be configured at the same time.