vue-safe-force-graph 2.0.51 → 2.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -167,6 +167,11 @@ app.use(Graph)
167
167
  | handleSelectNodeEvent | 选择节点事件的props(兼容angular调用,vue可以使用事件方式) | Function | 无 | 否 |
168
168
  | customContextMenuEvent | 自定义右键菜单的点击事件,相关配置参考下面的[自定义右键菜单](#自定义右键菜单)。会返回数据 `{ eventName: 'api.name', customConfig: 'api.customConfig', nodes: 'nodes', allNodes: 'this.history.dataNow.nodes', }`(兼容angular调用,vue可以使用事件方式) | Function | 无 | 否 |
169
169
  | handleDataLoaded | 图加载数据完成后 的事件通知。会返回图中所有的节点数据。(兼容angular调用,vue可以使用事件方式) | Function | 无 | 否 |
170
+ | nodeWidth | 节点的宽度 | Number | 24 | 否 |
171
+ | startNodeWidth | 起始节点的宽度 | Number | 24 | 否 |
172
+ | linkDistance | 用于调整**`d3.forceLink` 的距离**:以确保link长度,值越大距离越长。[d3文档](https://d3js.org/d3-force/link#link_distance) (当配置nodeWidth后可能会用到,比如nodewidth太大时,需要增加link距离) | Number | 120 | 否 |
173
+ | strength | d3js的*manyBody*.strength属性。**调整 `d3.forceManyBody` 的强度**:增加或减少节点之间的排斥力,值为负值,负数越大斥力越大,如0表示无斥力,-600中等斥力。[d3文档](https://d3js.org/d3-force/many-body#manyBody_strength)(当配置nodeWidth后可能会用到,比如nodewidth太大时,需要增加节点之间的斥力) | Number | -600 | 否 |
174
+ | customTooltip | 自定义tooltip内容,传入一个函数,函数中能拿到节点数据,函数需返回html模板 | Function | | 否 |
170
175
 
171
176
  ### 自定义右键菜单
172
177
 
@@ -271,6 +276,44 @@ app.use(Graph)
271
276
  | handle-data-loaded | 图加载数据完成后 的事件通知。会返回图中所有的节点数据 | `<ForceGraphByCanvas :graph-api="graphApi" :module="module" :start-node="startNode" @handle-data-loaded="handleDataLoaded" @custom-contextmenu-click="handleContextmenu" @handle-select-node="handleSelectNode" />` |
272
277
  | custom-contextmenu-click | 自定义右键菜单的点击事件。返回 **eventName** 事件名 、**customConfig**、 **当前点击的nodes** 节点的整个数据, 所有节点**allNodes** | 如上 |
273
278
  | handle-select-node | 选择节点事件 | 如上 |
279
+ | controlOperation | 操作控制,传入node数据和对应api操作。如显示隐藏按钮 | 示例如下 |
280
+
281
+ ##### controlOperation示例
282
+
283
+ ```js
284
+ <ForceGraphByCanvas
285
+ ref="forceGraph"
286
+ graph-url-path="/hmGraphByCanvas"
287
+ :graph-api="graphApi"
288
+ :module="module"
289
+ :start-node="startNode"
290
+ @handle-data-loaded="handleDataLoaded"
291
+ />
292
+
293
+ /*
294
+ * 参数格式 { nodes: [{ id: '8c5c0cda7d0f3ec28e818b441037cf2d' }], api: { name: 'show_node' }}
295
+ * */
296
+ function showNode() {
297
+ forceGraph.value.controlOperation({ nodes: [{ id: '8c5c0cda7d0f3ec28e818b441037cf2d' }], api: { name: 'show_node' }})
298
+ }
299
+ function hideNode() {
300
+ forceGraph.value.controlOperation({ nodes: [{ id: '8c5c0cda7d0f3ec28e818b441037cf2d' }], api: { name: 'hide_node' }})
301
+ }
302
+ ```
303
+
304
+ ##### controlOperation其他api name
305
+
306
+ - `edit_label`修改label
307
+ - `single_edge_select` 单边顶点选择
308
+ - `hold_aggregation`单边顶点聚合
309
+ - `release_aggregation`聚合顶点释放
310
+ - `node_star`收藏
311
+ - `un_node_star`取消收藏
312
+ - `show_label` `show_names` 显示节点名称
313
+ - `un_show_names` `un_show_label` 隐藏节点名称
314
+ - `fix_nodes`固定节点
315
+ - `un_fix_nodes`取消固定节点
316
+ - `delete_node`删除节点
274
317
 
275
318
  ### 图标加载方式
276
319
 
@@ -278,7 +321,123 @@ app.use(Graph)
278
321
 
279
322
  图谱中的图标icon默认是从cdn链接中加载的。如果您存在私有化部署不能访问公网的场景,可以联系作者打包base64版本。
280
323
 
281
- ###
324
+
325
+
326
+ ### 其他配置项
327
+
328
+ **1.关系节点增加统计数字**
329
+
330
+ 在config配置中的的plugs对应的新增一个 show_total 字段,布尔值 true 或者 false。
331
+
332
+ **2.icon自定义图标的图片**
333
+
334
+ 数据节点的图标。 节点详情**detail**接口的 **info下 新增 icon_img字段** 存在,则使用此 **icon_img** 图片。 可以是图片链接或者是base64。
335
+
336
+ 关系节点的图标。 在**config**接口的plugs字段下对应的位置,加一个**icon_img**字段,用于关系节点的图标。
337
+
338
+ **3.节点线上 增加描述文案**
339
+
340
+ 在获取节点和link的接口中,在links字段下面,新增一个字段 edge_label,字符串,如果有值则展示此文案,没有则不展示。
341
+
342
+
343
+
344
+ ###### config配置
345
+
346
+ ```js
347
+ // config配置
348
+ {
349
+ "code": "0",
350
+ "msg": "ok",
351
+ "request_id": "QJDysikHdHqtwhMRQFek",
352
+ "data": {
353
+ "plugs": {
354
+ "md5": [
355
+ {
356
+ "show_total": true, // 是否展示增加统计数字
357
+ "icon_img": "https://files.codelife.cc/icons/google.svg", // 自定义关系节点图标的图片
358
+ "canloop": true,
359
+ "icon": "file",
360
+ "name": "xxx",
361
+ "namec": "释放文件",
362
+ "path": "xxxx",
363
+ "relay_name": "释放文件"
364
+ },
365
+ ]
366
+ }
367
+ }
368
+ }
369
+ ```
370
+
371
+
372
+
373
+ ###### detail配置
374
+
375
+ ```js
376
+ {
377
+ "code": "0",
378
+ "msg": "ok",
379
+ "data": {
380
+ "records": [
381
+ {
382
+ "summary": "",
383
+ "tags": null,
384
+ "info": {
385
+ "id": "sfdsdfsf",
386
+ "name": "“xxx",
387
+ "type": "report",
388
+ "inner_img": "自定义节点图片", // 自定义图片
389
+ "basic": {
390
+ "title": "“黑球”行动再升级,SMBGhost漏洞攻击进入实战",
391
+ "url": "xxxx",
392
+ "update_time": "2021-04-29 05:11:53"
393
+ },
394
+ "extends": null
395
+ },
396
+ "brief": []
397
+ }
398
+ ]
399
+ }
400
+ }
401
+ ```
402
+
403
+ ###### 获取节点数据接口示例
404
+
405
+ ```js
406
+ {
407
+ "code": "0",
408
+ "msg": "ok",
409
+ "data": {
410
+ "nodes": [
411
+ {
412
+ "id": "a",
413
+ "name": "a",
414
+ "type": "md5",
415
+ "origin": [],
416
+ "feature": {}
417
+ },
418
+ {
419
+ "id": "b",
420
+ "name": "b",
421
+ "type": "md5",
422
+ "origin": [],
423
+ "feature": {}
424
+ }
425
+ ],
426
+ "links": [
427
+ {
428
+ "source": "a",
429
+ "target": "b",
430
+ "type": "domain-md5",
431
+ "desc": "",
432
+ "feature": {},
433
+ "edge_label": "边的描述文案" // 新增:边的描述文案
434
+ }
435
+ ]
436
+ }
437
+ }
438
+ ```
439
+
440
+
282
441
 
283
442
 
284
443
  ## 开发相关