diff --git a/src/assets/package/layoutParamsDict.js b/src/assets/package/layoutParamsDict.js new file mode 100644 index 0000000..61dcd64 --- /dev/null +++ b/src/assets/package/layoutParamsDict.js @@ -0,0 +1,116 @@ +//布局算法的参数定义 +export const layoutParamsDict ={ + 'hierarchical':[ //层级布局 + {'name':'layerSpace','value': 150,'type':'number','label':'层间距'}, + {'name':'nodeSpace','value': 80,'type':'number','label':'点间距'}, + {'name':'sortType','value': 'selected','type':'array','label':'排序类型', + 'types':[ + {'label':'指定点','value':'selected'}, + {'label':'度大小','value':'hubsize'}, + {'label':'连线方向','value':'directed'} + ] + }, + {'name':'direction','value': 'UD','type':'array','label':'方向', + 'types':[ + {'label':'上下','value':'UD'}, + {'label':'下上','value':'DU'}, + {'label':'左右','value':'LR'}, + {'label':'右左','value':'RL'} + ] + } + ], + 'grid':[ //网格布局 + {'name':'layerSpace','value': 120,'type':'number','label':'层间距'}, + {'name':'nodeSpace','value': 140,'type':'number','label':'点间距'} + ], + 'concentric':[ //同心圆布局 + {'name':'maxNodeSize','value': 70,'type':'number','label':'节点大小'} + ], + 'fastForce':[ //网络布局 + {'name':'linkDistance','value': 150,'type':'number','label':'连线长度'}, + {'name':'charge','value': -450,'type':'number','label':'吸引力'}, + {'name':'friction','value': 0.85,'type':'decimal','label':'排斥力'}, + {'name':'linkStrength','value': 0.1,'type':'decimal','label':'连线强度'}, + {'name':'gravity','value': 0.05,'type':'decimal','label':'中心引力'} + ], + 'simulation':[ //力导向布局 + {'name':'strength','value': -800,'type':'number','label':'吸引力'}, + {'name':'linkDistance','value': 150,'type':'number','label':'连线长度'}, + {'name':'ajustCluster','value': false,'type':'array','label':'类型分组', + 'types':[ + {'label':'是','value':true}, + {'label':'否','value':false} + ] + } + ], + 'kawakai':[ //最优路径布局 + {'name':'sizeScale','value': 1.5,'type':'number','label':'缩放比例'} + ], + 'circle':[ //环形布局 + {'name':'scale','value': 1.2,'type':'number','label':'缩放比例'}, + {'name':'ordering','value': 'degree','type':'array','label':'排序方式', + 'types':[ + {'label':'度大小排序','value':'degree'}, + {'label':'拓扑排序','value':'topology'} + ] + } + ], + 'arf':[ + {'name':'neighberForce','value': 5.0,'type':'number','label':'邻边引力'}, + {'name':'attraction','value': 0.05,'type':'number','label':'向心力'}, + {'name':'forceScale','value': 5.0,'type':'number','label':'缩放比例'} + ], + 'tree':[ //树形布局 + {'name':'layerSpace','value': 150,'type':'number','label':'层间距'}, + {'name':'nodeSpace','value': 80,'type':'number','label':'点间距'}, + {'name':'direction','value': 'UD','type':'array','label':'方向', + 'types':[ + {'label':'上下','value':'UD'}, + {'label':'下上','value':'DU'}, + {'label':'左右','value':'LR'}, + {'label':'右左','value':'RL'} + ] + } + ], + 'avoidlap':[ //避免重叠 + {'name':'maxPadding','value': 5,'type':'number','label':'节点间距'} + ], + 'dagre':[ //流程图布局 + {'name':'nodesep','value': 10,'type':'number','label':'点间距'}, + {'name':'ranksep','value': 100,'type':'number','label':'层间距'}, + {'name':'nodeSize','value': 50,'type':'number','label':'节点大小'}, + {'name':'rankdir','value': 'TB','type':'array','label':'排列方向', + 'types':[ + {'label':'上下','value':'TB'}, + {'label':'下上','value':'BT'}, + {'label':'左右','value':'LR'}, + {'label':'右左','value':'RL'} + ] + } + ] +}; + +//获取默认的布局参数 +export const getLayoutDefaultConfig = function(layoutType){ + let layoutConfig = {}; + layoutParamsDict[layoutType].forEach(param=>{ + layoutConfig[param.name] = param.value; + }); + return layoutConfig; +}; + +//获取布局参数列表 +export const getLayoutParams = function(layoutType){ + return layoutParamsDict[layoutType]; +}; + +//布局算法列表 +export const layoutTypeList = [ + {label:'快速弹性布局',value:'fastForce',icon:'el-icon-orange'}, + {label:'力导向布局',value:'simulation',icon:'el-icon-orange'}, + {label:'最优路径布局',value:'kawakai',icon:'el-icon-cpu'}, + //{label:'球面引力布局',value:'arf',icon:'el-icon-orange'}, + {label:'层级布局',value:'hierarchical',icon:'el-icon-share'}, + {label:'中心圆布局',value:'concentric',icon:'el-icon-bangzhu'}, + {label:'去除重叠',value:'avoidlap',icon:'el-icon-copy-document'} +]; \ No newline at end of file diff --git a/src/store/groupEvolution/index.js b/src/store/groupEvolution/index.js index 9d4c9c2..cfc914b 100644 --- a/src/store/groupEvolution/index.js +++ b/src/store/groupEvolution/index.js @@ -211,7 +211,6 @@ export const useGroupDiscoveryStore = defineStore("groupDiscovery", { this.timeList = res.data }, - //根据时间参数获取节点数据 async initialGraphByUtcTime(utcTime = "") { const setColor = (groupId) => { const colorMap = { @@ -237,16 +236,23 @@ export const useGroupDiscoveryStore = defineStore("groupDiscovery", { } return false }) - .map((node) => ({ - id: node.name, - label: node.name, - color: setColor(node.groupId) - })) + .map((node) => { + return { + id: node.name, + label: node.name, + color: setColor(node.groupId), + cluster: parseInt(node.groupId) + } + }) }, // 通过时间来获取帖文列表 //根据时间参数获取贴文数据 - async initialPostByUtcTime(utcTime) {} + async initialPostByUtcTime(utcTime) { + const res = await getPostByUtcTime(utcTime) + if (res.code != 200) return + this.posts = res.data + } }, persist: true // 开启持久化 }) diff --git a/src/views/GroupEvolution/component/groupGraph.vue b/src/views/GroupEvolution/component/groupGraph.vue index 06a9f6e..f77e7de 100644 --- a/src/views/GroupEvolution/component/groupGraph.vue +++ b/src/views/GroupEvolution/component/groupGraph.vue @@ -17,36 +17,23 @@