Learn R Programming

g6R (version 0.1.0)

g6_behaviors: Create G6 Graph Behaviors Configuration

Description

Configures interaction behaviors for a G6 graph visualization. This function collects and combines multiple behavior configurations into a list that can be passed to graph initialization functions.

Usage

g6_behaviors(graph, ...)

Value

A list of behavior configuration objects that can be passed to G6 graph initialization

Arguments

graph

A g6 graph instance.

...

Behavior configuration objects created by behavior-specific functions. These can include any of the following behaviors:

Navigation behaviors:

  • drag_canvas() - Drag the entire canvas view

  • zoom_canvas() - Zoom the canvas view

  • scroll_canvas() - Scroll the canvas using the wheel

  • optimize_viewport_transform() - Optimize view transform performance

Selection behaviors:

  • click_select() - Click to select graph elements

  • brush_select() - Select elements by dragging a rectangular area

  • lasso_select() - Freely draw an area to select elements

Editing behaviors:

  • create_edge() - Interactively create new edges

  • drag_element() - Drag nodes or combos

  • drag_element_force() - Drag nodes in force-directed layout

Data Exploration behaviors:

  • collapse_expand() - Expand or collapse subtree nodes

  • focus_element() - Focus on specific elements and automatically adjust the view

  • hover_activate() - Highlight elements when hovering

Visual Optimization behaviors:

  • fix_element_size() - Fix the element size to a specified value

  • auto_adapt_label() - Automatically adjust label position

Examples

Run this code
# Create a basic set of behaviors
behaviors <- g6_behaviors(
  g6(),
  drag_canvas(),
  zoom_canvas(),
  click_select()
)

# Create a more customized set of behaviors
behaviors <- g6_behaviors(
  g6(),
  drag_canvas(),
  zoom_canvas(sensitivity = 1.5),
  hover_activate(state = "highlight"),
  fix_element_size(
    node = list(
      list(shape = "circle", fields = c("r", "lineWidth"))
    )
  )
)

Run the code above in your browser using DataLab