跳到主要内容

组合展开/收起

示例加载中…

源码
import { addPanel } from '/demo-runtime.ts';

import { Graph } from '@antv/g6';

const graph = new Graph({
  container: 'container',
  data: {
    nodes: [
      { id: 'node-1', combo: 'combo-2', style: { x: 120, y: 100 } },
      { id: 'node-2', combo: 'combo-1', style: { x: 300, y: 200 } },
      { id: 'node-3', combo: 'combo-1', style: { x: 200, y: 300 } },
    ],
    edges: [
      { id: 'edge-1', source: 'node-1', target: 'node-2' },
      { id: 'edge-2', source: 'node-2', target: 'node-3' },
    ],
    combos: [
      {
        id: 'combo-1',
        type: 'rect',
        combo: 'combo-2',
        style: {
          collapsed: true,
        },
      },
      { id: 'combo-2' },
    ],
  },
  node: {
    style: {
      labelText: (d) => d.id,
    },
  },
  combo: {
    style: {
      labelText: (d) => d.id,
      lineDash: 0,
      collapsedLineDash: [5, 5],
    },
  },
  behaviors: [{ type: 'drag-element' }, 'collapse-expand'],
});

graph.render();

addPanel((gui) => {
  const config = {
    collapse: () => {
      graph.collapseElement('combo-1');
    },
    expand: () => {
      graph.expandElement('combo-1');
    },
  };
  gui.add(config, 'collapse');
  gui.add(config, 'expand');
});
全站搜索
文档与示例输入关键词开始搜索

输入关键词,查找文档、API 与示例

↑↓选择↵打开Esc关闭