g6/packages/site/docs/api/graphFunc/mode.en.md
2023-02-02 10:31:36 +08:00

794 B

title order
Set/Get Mode 8

graph.setMode(mode)

Switch the interaction mode of graph. For example, switch from edit mode to read-only mode.

Parameters

Name Type Required Description
mode string true The name of the mode.

Usage

const graph = new G6.Graph({
    container: div,
    width: 500,
    height: 500,
    modes: {
      default: [...],
      custom: [...]
    }
})

graph.setMode('custom')

graph.getCurrentMode()

Get the current mode.

Return

  • Type of return value: string;
  • The return value indicates the current mode.

Usage

// The return value is the current interaction mode
const mode = graph.getCurrentMode();