---
title: 拓扑模型 Topo
order: 1
---


### Topo

#### `load(data)` 获取数据
- 方法名：async load(data)
- 参数：data {object} 配置参数
- 返回：Promise
- 示例：

```
const data = {
  config: {
    id: 2,
    name: 'simple',
    showType: 'auto',
    layout: 'circular',
  },
  nodes: [
    {
      id: '1',
      name: '1',
      ciType: 'aaa',
      operation: 'delete'
    },
    {
      id: '2',
      name: '2',
      ciType: 'ruijieSwitch',
      operation: 'delete',
    },
  ],
  lines: [
    {
      id: '1-2',
      source: '1',
      target: '2',
    },
  ]
};

await topo.load(data);

```



#### `getData()` 获取数据
- 方法：getData()
- 返回：
```
    {
        groups: [
            {
                id: 20, // 业务id
                name: "业务层",
                tag: 56, // 图形元素id
                image: "row", // 容器时有
            }
        ],
        nodes: [],
        lines: [],
        customNodes: [],
        customLines: [],
    }
```

#### `updateData(data)` 更新数据
- 描述：更新业务分层、容器、节点、连线，保留业务元素的配置和样式、手工加入的节点和连线（如果两端存在）
- 参数：
```
    {
        groups: [],
        nodes: [],
        lines: [],
    }
```

#### 查询

#### 加载属性、指标数据
示例：
```
topo.attributeMetricDisplay.loadAttributeAndMetric([{
  id: '资源id',
  attributes: [{
    code: "asset_number",
    name: "资产编号",
    value: "123123"
  }],
  metric: []
}])

topo.attributeMetricDisplay.loadAttributeAndMetric([{
  id: '资源id',
  attributes: {
    name: "`2312312",
    serial_number: "`2312312"
  },
  metric: {
    aaa: 1111,
    bbb: 222
  }
}])
```

