feat: G6版本使用稳定4.8
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons-vue": "^7.0.1",
|
"@ant-design/icons-vue": "^7.0.1",
|
||||||
"@antv/g6": "^5.0.0-beta.28",
|
"@antv/g6": "^4.8.24",
|
||||||
"@codemirror/lang-javascript": "^6.2.1",
|
"@codemirror/lang-javascript": "^6.2.1",
|
||||||
"@codemirror/merge": "^6.4.0",
|
"@codemirror/merge": "^6.4.0",
|
||||||
"@codemirror/theme-one-dark": "^6.1.2",
|
"@codemirror/theme-one-dark": "^6.1.2",
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { nextTick, watch, onMounted, onBeforeUnmount, ref } from 'vue';
|
import { nextTick, watch, onMounted, onBeforeUnmount, ref } from 'vue';
|
||||||
import { Graph, extend, Extensions } from '@antv/g6';
|
import { Graph } from '@antv/g6';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
/**
|
/**
|
||||||
@@ -45,332 +45,212 @@ const props = defineProps({
|
|||||||
|
|
||||||
const chartGraphG6Dom = ref<HTMLElement | undefined>(undefined);
|
const chartGraphG6Dom = ref<HTMLElement | undefined>(undefined);
|
||||||
|
|
||||||
const ExtGraph = extend(Graph, {
|
|
||||||
layouts: {},
|
|
||||||
edges: {
|
|
||||||
'polyline-edge': Extensions.PolylineEdge,
|
|
||||||
'cubic-edge': Extensions.CubicEdge,
|
|
||||||
// 'custom-edge': Extensions.CubicEdge,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
nodes: [
|
nodes: [
|
||||||
// 0 基站
|
// 0 基站
|
||||||
{
|
{
|
||||||
id: '0',
|
id: '0',
|
||||||
data: {
|
|
||||||
x: 50,
|
x: 50,
|
||||||
y: 150,
|
y: 150,
|
||||||
type: 'circle-node',
|
size: 48,
|
||||||
color: '#fffff',
|
type: 'circle',
|
||||||
keyShape: {
|
label: '基站',
|
||||||
r: 24,
|
labelCfg: {
|
||||||
width: 48,
|
position: 'bottom',
|
||||||
height: 48,
|
offset: 10,
|
||||||
|
style: {
|
||||||
|
fill: '#333',
|
||||||
|
stroke: '#fff',
|
||||||
|
lineWidth: 10,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
style: {
|
||||||
fill: '#9EC9FF',
|
fill: '#9EC9FF',
|
||||||
stroke: '#5B8FF9',
|
stroke: '#5B8FF9',
|
||||||
lineWidth: 2,
|
lineWidth: 2,
|
||||||
},
|
},
|
||||||
labelShape: {
|
icon: {
|
||||||
text: '基站',
|
show: true,
|
||||||
position: 'bottom',
|
// 可更换为其他图片地址
|
||||||
maxWidth: '200%',
|
|
||||||
offsetY: 10,
|
|
||||||
},
|
|
||||||
labelBackgroundShape: {},
|
|
||||||
iconShape: {
|
|
||||||
img: 'https://gw.alipayobjects.com/zos/basement_prod/012bcf4f-423b-4922-8c24-32a89f8c41ce.svg',
|
img: 'https://gw.alipayobjects.com/zos/basement_prod/012bcf4f-423b-4922-8c24-32a89f8c41ce.svg',
|
||||||
width: 24,
|
width: 24,
|
||||||
height: 24,
|
height: 24,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
// 1 DM
|
// 1 DM
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
data: {
|
|
||||||
label: 'DM',
|
|
||||||
x: 450,
|
x: 450,
|
||||||
y: 450,
|
y: 450,
|
||||||
keyShape: {
|
label: 'DM',
|
||||||
width: 80,
|
labelCfg: {
|
||||||
height: 40,
|
|
||||||
radius: 8,
|
|
||||||
fill: '#00b050',
|
|
||||||
},
|
|
||||||
labelShape: {
|
|
||||||
position: 'center',
|
position: 'center',
|
||||||
text: 'DM',
|
|
||||||
fill: '#fff', // 节点标签文字颜色
|
|
||||||
},
|
},
|
||||||
|
style: {
|
||||||
|
fill: '#00b050',
|
||||||
|
stroke: '#00b050',
|
||||||
|
lineWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// 2 O&M
|
// 2 O&M
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
data: {
|
|
||||||
label: 'O&M',
|
|
||||||
x: 50,
|
x: 50,
|
||||||
y: 450,
|
y: 450,
|
||||||
},
|
label: 'O&M',
|
||||||
},
|
},
|
||||||
// 100 EMS
|
// 100 EMS
|
||||||
{
|
{
|
||||||
id: '100',
|
id: '100',
|
||||||
data: {
|
|
||||||
label: 'EMS',
|
label: 'EMS',
|
||||||
parentId: 'combo-ems',
|
comboId: 'combo-ems',
|
||||||
x: 300,
|
x: 300,
|
||||||
y: 450,
|
y: 450,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
// 190 UPF
|
// 190 UPF
|
||||||
{
|
{
|
||||||
id: '190',
|
id: '190',
|
||||||
data: {
|
comboId: 'combo-upf',
|
||||||
parentId: 'combo-upf',
|
|
||||||
x: 300,
|
x: 300,
|
||||||
y: 350,
|
y: 350,
|
||||||
keyShape: {
|
label: 'UPF',
|
||||||
width: 80,
|
labelCfg: {
|
||||||
height: 40,
|
|
||||||
radius: 8,
|
|
||||||
fill: '#d580ff',
|
|
||||||
},
|
|
||||||
labelShape: {
|
|
||||||
position: 'center',
|
position: 'center',
|
||||||
text: 'UPF',
|
|
||||||
fill: '#fff', // 节点标签文字颜色
|
|
||||||
},
|
},
|
||||||
|
style: {
|
||||||
|
fill: '#d580ff',
|
||||||
|
stroke: '#d580ff',
|
||||||
|
lineWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// EP-IMS
|
// EP-IMS
|
||||||
{
|
{
|
||||||
id: '110',
|
id: '110',
|
||||||
data: {
|
comboId: 'combo-ims',
|
||||||
parentId: 'combo-ims',
|
|
||||||
x: 600,
|
x: 600,
|
||||||
y: 350,
|
y: 350,
|
||||||
keyShape: {
|
label: 'IMS',
|
||||||
width: 80,
|
labelCfg: {
|
||||||
height: 40,
|
|
||||||
radius: 8,
|
|
||||||
fill: '#ed7d31',
|
|
||||||
},
|
|
||||||
labelShape: {
|
|
||||||
position: 'center',
|
position: 'center',
|
||||||
text: 'IMS',
|
|
||||||
fill: '#fff', // 节点标签文字颜色
|
|
||||||
},
|
},
|
||||||
|
style: {
|
||||||
|
fill: '#ed7d31',
|
||||||
|
stroke: '#ed7d31',
|
||||||
|
lineWidth: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// 5GC控制面
|
// 5GC控制面
|
||||||
{
|
{
|
||||||
id: '170',
|
id: '170',
|
||||||
data: {
|
|
||||||
label: 'NSSF',
|
label: 'NSSF',
|
||||||
parentId: 'combo-5gc',
|
comboId: 'combo-5gc',
|
||||||
x: 300,
|
x: 300,
|
||||||
y: 50,
|
y: 50,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: '130',
|
id: '130',
|
||||||
data: {
|
|
||||||
label: 'AUSF',
|
label: 'AUSF',
|
||||||
parentId: 'combo-5gc',
|
comboId: 'combo-5gc',
|
||||||
x: 450,
|
x: 450,
|
||||||
y: 50,
|
y: 50,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: '140',
|
id: '140',
|
||||||
data: {
|
|
||||||
label: 'UDM',
|
label: 'UDM',
|
||||||
parentId: 'combo-5gc',
|
comboId: 'combo-5gc',
|
||||||
x: 600,
|
x: 600,
|
||||||
y: 50,
|
y: 50,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: '120',
|
id: '120',
|
||||||
data: {
|
|
||||||
label: 'AMF',
|
label: 'AMF',
|
||||||
parentId: 'combo-5gc',
|
comboId: 'combo-5gc',
|
||||||
x: 300,
|
x: 300,
|
||||||
y: 150,
|
y: 150,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: '180',
|
id: '180',
|
||||||
data: {
|
|
||||||
label: 'NRF',
|
label: 'NRF',
|
||||||
parentId: 'combo-5gc',
|
comboId: 'combo-5gc',
|
||||||
x: 450,
|
x: 450,
|
||||||
y: 150,
|
y: 150,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: '150',
|
id: '150',
|
||||||
data: {
|
|
||||||
label: 'SMF',
|
label: 'SMF',
|
||||||
parentId: 'combo-5gc',
|
comboId: 'combo-5gc',
|
||||||
x: 300,
|
x: 300,
|
||||||
y: 250,
|
y: 250,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: '160',
|
id: '160',
|
||||||
data: {
|
|
||||||
label: 'PCF',
|
label: 'PCF',
|
||||||
parentId: 'combo-5gc',
|
comboId: 'combo-5gc',
|
||||||
x: 700,
|
x: 700,
|
||||||
y: 250,
|
y: 250,
|
||||||
},
|
},
|
||||||
},
|
|
||||||
],
|
],
|
||||||
edges: [
|
edges: [
|
||||||
{
|
{
|
||||||
id: '0-5gc',
|
id: '0-5gc',
|
||||||
source: '0',
|
source: '0',
|
||||||
target: 'combo-5gc',
|
target: 'combo-5gc',
|
||||||
data: {},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '0-upf',
|
id: '0-upf',
|
||||||
source: '0',
|
source: '0',
|
||||||
target: 'combo-upf',
|
target: 'combo-upf',
|
||||||
data: {
|
|
||||||
keyShape: {
|
|
||||||
radius: 4,
|
|
||||||
controlPoints: [
|
|
||||||
{ x: 150, y: 150 },
|
|
||||||
{ x: 150, y: 350 },
|
|
||||||
],
|
|
||||||
lineWidth: 1,
|
|
||||||
stroke: '#d580ff',
|
|
||||||
},
|
|
||||||
labelShape: {
|
|
||||||
text: 'N3',
|
|
||||||
position: 'end',
|
|
||||||
autoRotate: true,
|
|
||||||
offsetY: 10,
|
|
||||||
},
|
|
||||||
labelBackgroundShape: {},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'upf-1',
|
id: 'upf-1',
|
||||||
source: 'combo-upf',
|
source: 'combo-upf',
|
||||||
target: '1',
|
target: '1',
|
||||||
data: {
|
|
||||||
keyShape: {
|
|
||||||
radius: 4,
|
|
||||||
controlPoints: [{ x: 400, y: 400 }],
|
|
||||||
lineWidth: 1,
|
|
||||||
stroke: '#d580ff',
|
|
||||||
},
|
|
||||||
labelShape: {
|
|
||||||
text: 'N6',
|
|
||||||
position: 'start',
|
|
||||||
autoRotate: true,
|
|
||||||
offsetX: 10,
|
|
||||||
},
|
|
||||||
labelBackgroundShape: {},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: 'ems-2',
|
id: 'ems-2',
|
||||||
source: 'combo-ems',
|
source: 'combo-ems',
|
||||||
target: '2',
|
target: '2',
|
||||||
data: { type: 'cubic-edge' },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '170-120',
|
id: '170-120',
|
||||||
source: '170',
|
source: '170',
|
||||||
target: '120',
|
target: '120',
|
||||||
data: {},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '130-120',
|
id: '130-120',
|
||||||
source: '130',
|
source: '130',
|
||||||
target: '120',
|
target: '120',
|
||||||
data: {},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '140-120',
|
id: '140-120',
|
||||||
source: '140',
|
source: '140',
|
||||||
target: '120',
|
target: '120',
|
||||||
data: {},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '140-180',
|
id: '140-180',
|
||||||
source: '140',
|
source: '140',
|
||||||
target: '180',
|
target: '180',
|
||||||
data: {},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '120-180',
|
id: '120-180',
|
||||||
source: '120',
|
source: '120',
|
||||||
target: '180',
|
target: '180',
|
||||||
data: {
|
|
||||||
type: 'polyline-edge',
|
|
||||||
keyShape: {
|
|
||||||
endArrow: true,
|
|
||||||
routeCfg: {
|
|
||||||
/**
|
|
||||||
* 目前支持正交路由 'orth' 和地铁路由 'er'
|
|
||||||
*/
|
|
||||||
// name: 'er',
|
|
||||||
/**
|
|
||||||
* 是否开启自动避障,默认为 false
|
|
||||||
* Whether to enable automatic obstacle avoidance, default is false
|
|
||||||
*/
|
|
||||||
enableObstacleAvoidance: true,
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 拐弯处的圆角弧度,默认为直角,值为 0
|
|
||||||
* The radius of the corner rounding, defaults to a right angle
|
|
||||||
*/
|
|
||||||
// radius: 20,
|
|
||||||
/**
|
|
||||||
* 拐弯处距离节点最小距离, 默认为 2
|
|
||||||
* Minimum distance from the node at the corner, default is 5.
|
|
||||||
*/
|
|
||||||
// offset: 0,
|
|
||||||
/**
|
|
||||||
* 控制点数组,不指定时根据 A* 算法自动生成折线。若指定了,则按照 controlPoints 指定的位置进行弯折
|
|
||||||
* An array of control points that, when not specified, automatically generates the bends according to the A* algorithm. If specified, bends are made at the position specified by controlPoints.
|
|
||||||
*/
|
|
||||||
// controlPoints: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '130-180',
|
id: '130-180',
|
||||||
source: '130',
|
source: '130',
|
||||||
target: '180',
|
target: '180',
|
||||||
data: {
|
|
||||||
type: 'polyline-edge',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '140-150',
|
id: '140-150',
|
||||||
source: '140',
|
source: '140',
|
||||||
target: '150',
|
target: '150',
|
||||||
data: {
|
|
||||||
type: 'polyline-edge',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '140-110',
|
id: '140-110',
|
||||||
source: '140',
|
source: '140',
|
||||||
target: '110',
|
target: '110',
|
||||||
data: {
|
|
||||||
type: 'polyline-edge',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '120-150',
|
id: '120-150',
|
||||||
@@ -388,64 +268,48 @@ const data = {
|
|||||||
id: '150-160',
|
id: '150-160',
|
||||||
source: '150',
|
source: '150',
|
||||||
target: '160',
|
target: '160',
|
||||||
data: { type: 'polyline-edge' },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '160-120',
|
id: '160-120',
|
||||||
source: '160',
|
source: '160',
|
||||||
target: '120',
|
target: '120',
|
||||||
data: {},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '160-180',
|
id: '160-180',
|
||||||
source: '160',
|
source: '160',
|
||||||
target: '180',
|
target: '180',
|
||||||
data: {
|
|
||||||
keyShape: {
|
|
||||||
endArrow: true,
|
|
||||||
},
|
|
||||||
labelShape: {
|
|
||||||
text: 'asdf-arrow',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '160-110',
|
id: '160-110',
|
||||||
source: '160',
|
source: '160',
|
||||||
target: '110',
|
target: '110',
|
||||||
data: {},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: '150-190',
|
id: '150-190',
|
||||||
source: '150',
|
source: '150',
|
||||||
target: '190',
|
target: '190',
|
||||||
data: {},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
id: 'upf-ims',
|
id: 'upf-ims',
|
||||||
source: 'combo-upf',
|
source: 'combo-upf',
|
||||||
target: 'combo-ims',
|
target: 'combo-ims',
|
||||||
data: { type: 'cubic-edge' },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'ems-5gc',
|
id: 'ems-5gc',
|
||||||
source: 'combo-ems',
|
source: 'combo-ems',
|
||||||
target: 'combo-5gc',
|
target: 'combo-5gc',
|
||||||
data: { type: 'cubic-edge' },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'ems-upf',
|
id: 'ems-upf',
|
||||||
source: 'combo-ems',
|
source: 'combo-ems',
|
||||||
target: 'combo-upf',
|
target: 'combo-upf',
|
||||||
data: { type: 'cubic-edge' },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'ems-ims',
|
id: 'ems-ims',
|
||||||
source: 'combo-ems',
|
source: 'combo-ems',
|
||||||
target: 'combo-ims',
|
target: 'combo-ims',
|
||||||
data: { type: 'cubic-edge' },
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
combos: [
|
combos: [
|
||||||
@@ -477,60 +341,28 @@ const data = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
let graph: any = null;
|
let graph: any = null;
|
||||||
|
|
||||||
/**初始化渲染图表 */
|
/**初始化渲染图表 */
|
||||||
function initChart() {
|
function initChart() {
|
||||||
if (!chartGraphG6Dom.value) return;
|
if (!chartGraphG6Dom.value) return;
|
||||||
console.log(chartGraphG6Dom.value.offsetWidth);
|
|
||||||
console.log(chartGraphG6Dom.value.clientWidth);
|
console.log(chartGraphG6Dom.value.clientWidth);
|
||||||
console.log(chartGraphG6Dom.value.scrollWidth);
|
console.log(chartGraphG6Dom.value.clientHeight);
|
||||||
graph = new ExtGraph({
|
graph = new Graph({
|
||||||
container: chartGraphG6Dom.value,
|
container: chartGraphG6Dom.value,
|
||||||
height: 500,
|
height: chartGraphG6Dom.value.clientHeight,
|
||||||
width: chartGraphG6Dom.value.clientWidth,
|
width: chartGraphG6Dom.value.clientWidth,
|
||||||
// autoFit: 'center',
|
// fitCenter: false,
|
||||||
modes: {
|
modes: {
|
||||||
default: [
|
default: ['drag-canvas', 'zoom-canvas', 'drag-node'], // 允许拖拽画布、放缩画布、拖拽节点
|
||||||
// {
|
|
||||||
// type: 'drag-node',
|
|
||||||
// enableTransient: false,
|
|
||||||
// updateComboStructure: false,
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// type: 'click-select',
|
|
||||||
// itemTypes: ['node', 'edge', 'combo'],
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// type: 'drag-combo',
|
|
||||||
// enableTransient: true,
|
|
||||||
// updateComboStructure: true,
|
|
||||||
// },
|
|
||||||
// 'drag-combo',
|
|
||||||
'drag-canvas',
|
|
||||||
'click-select',
|
|
||||||
// 'zoom-canvas',
|
|
||||||
] as any,
|
|
||||||
},
|
},
|
||||||
// 布局 力向吸引
|
// 布局 力向吸引
|
||||||
layout: {
|
layout: {
|
||||||
type: 'force',
|
type: 'force', // 指定为力导向布局
|
||||||
animated: true,
|
preventOverlap: true, // 防止节点重叠
|
||||||
linkDistance: 280,
|
linkDistance: 100, // 指定边距离为100
|
||||||
maxSpeed: 100,
|
|
||||||
clustering: true,
|
|
||||||
nodeClusterBy: 'parentId',
|
|
||||||
clusterNodeStrength: 80,
|
|
||||||
},
|
},
|
||||||
// 主题
|
|
||||||
theme: {
|
|
||||||
type: 'spec',
|
|
||||||
base: 'light',
|
|
||||||
specification: {
|
|
||||||
node: {
|
|
||||||
dataTypeField: 'parentId',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as any,
|
|
||||||
// 插件
|
// 插件
|
||||||
plugins: [
|
plugins: [
|
||||||
{
|
{
|
||||||
@@ -540,126 +372,34 @@ function initChart() {
|
|||||||
},
|
},
|
||||||
] as any,
|
] as any,
|
||||||
// 全局节点 矩形
|
// 全局节点 矩形
|
||||||
node: model => {
|
defaultNode: {
|
||||||
const { id, data } = model;
|
type: 'rect',
|
||||||
return {
|
size: [80, 40],
|
||||||
id,
|
style: {
|
||||||
data: {
|
fill: '#fff',
|
||||||
type: 'rect-node',
|
lineWidth: 1,
|
||||||
keyShape: {
|
|
||||||
width: 80,
|
|
||||||
height: 40,
|
|
||||||
radius: 8,
|
radius: 8,
|
||||||
},
|
},
|
||||||
labelShape: {
|
labelCfg: {},
|
||||||
position: 'center',
|
|
||||||
text: `${id} - ${data.label}`,
|
|
||||||
fill: '#fff',
|
|
||||||
},
|
|
||||||
animates: {
|
|
||||||
update: [
|
|
||||||
{
|
|
||||||
fields: ['opacity'],
|
|
||||||
shapeId: 'haloShape',
|
|
||||||
states: ['breathing'],
|
|
||||||
iterations: Infinity,
|
|
||||||
direction: 'alternate',
|
|
||||||
duration: 500,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fields: ['lineWidth'],
|
|
||||||
shapeId: 'keyShape',
|
|
||||||
states: ['breathing'],
|
|
||||||
iterations: Infinity,
|
|
||||||
direction: 'alternate',
|
|
||||||
duration: 500,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fields: ['height', 'width'],
|
|
||||||
shapeId: 'keyShape',
|
|
||||||
states: ['scaling'],
|
|
||||||
iterations: Infinity,
|
|
||||||
direction: 'alternate',
|
|
||||||
duration: 500,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
...data,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
// 全局边 三次贝塞尔曲线
|
// 全局边 三次贝塞尔曲线
|
||||||
edge: model => {
|
defaultEdge: {
|
||||||
const { id, source, target, data } = model;
|
type: 'polyline',
|
||||||
return {
|
style: {
|
||||||
id,
|
offset: 20, // 拐弯处距离节点最小距离
|
||||||
source,
|
radius: 4, // 拐弯处的圆角弧度,若不设置则为直角
|
||||||
target,
|
lineWidth: 1,
|
||||||
data: {
|
stroke: '#87e8de',
|
||||||
type: 'polyline-edge',
|
|
||||||
animates: {
|
|
||||||
update: [
|
|
||||||
{
|
|
||||||
fields: ['lineDash'],
|
|
||||||
shapeId: 'keyShape',
|
|
||||||
states: ['growing', 'running'],
|
|
||||||
iterations: Infinity,
|
|
||||||
duration: 2000,
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fields: ['offsetDistance'],
|
|
||||||
shapeId: 'buShape',
|
|
||||||
states: ['circleRunning'],
|
|
||||||
iterations: Infinity,
|
|
||||||
duration: 2000,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
...data,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
// 全局框节点 矩形
|
// 全局框节点 矩形
|
||||||
combo: model => {
|
defaultCombo: {
|
||||||
const { id, data } = model;
|
type: 'rect', // Combo 类型
|
||||||
return {
|
size: [40, 40],
|
||||||
id,
|
// ... 其他配置
|
||||||
data: {
|
style: {
|
||||||
type: 'rect-combo',
|
lineWidth: 1,
|
||||||
keyShape: {
|
|
||||||
opacity: 0.8,
|
|
||||||
padding: [20, 20, 20, 20],
|
|
||||||
radius: 8,
|
|
||||||
},
|
},
|
||||||
labelShape: {
|
|
||||||
text: data.label,
|
|
||||||
offsetY: 8,
|
|
||||||
},
|
|
||||||
labelBackgroundShape: {},
|
|
||||||
buildIn: [
|
|
||||||
{
|
|
||||||
fields: ['opacity'],
|
|
||||||
duration: 500,
|
|
||||||
delay: 500 + Math.random() * 500,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
buildOut: [
|
|
||||||
{
|
|
||||||
fields: ['opacity'],
|
|
||||||
duration: 200,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
animates: {
|
|
||||||
update: [
|
|
||||||
{
|
|
||||||
fields: ['width', 'height', 'x', 'y'],
|
|
||||||
shapeId: 'keyShape',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
...data,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
// 节点状态
|
// 节点状态
|
||||||
nodeState: {
|
nodeState: {
|
||||||
@@ -695,9 +435,11 @@ function initChart() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
graph.data(data); // 加载数据
|
||||||
|
graph.render(); // 渲染
|
||||||
|
|
||||||
graph.on('node:click', (e: any) => {
|
graph.on('node:click', (e: any) => {
|
||||||
const s = graph.getItemState(e.itemId);
|
const s = graph.getItemState(e.itemId);
|
||||||
console.log(s);
|
console.log(s);
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, onMounted, ref } from 'vue';
|
import { reactive, onMounted, ref } from 'vue';
|
||||||
import { reactive, onMounted, ref } from 'vue';
|
|
||||||
import { PageContainer } from 'antdv-pro-layout';
|
import { PageContainer } from 'antdv-pro-layout';
|
||||||
import ChartGraphG6 from '@/components/ChartGraphG6/index.vue';
|
import ChartGraphG6 from '@/components/ChartGraphG6/index.vue';
|
||||||
import useI18n from '@/hooks/useI18n';
|
import useI18n from '@/hooks/useI18n';
|
||||||
import useNeInfoStore from '@/store/modules/neinfo';
|
import useNeInfoStore from '@/store/modules/neinfo';
|
||||||
import { Extensions, Graph, GraphData, extend } from '@antv/g6';
|
import { Graph, GraphData } from '@antv/g6';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
|
||||||
import message from 'ant-design-vue/lib/message';
|
|
||||||
const neInfoStore = useNeInfoStore();
|
|
||||||
import useNeInfoStore from '@/store/modules/neinfo';
|
|
||||||
import { Extensions, Graph, GraphData, extend } from '@antv/g6';
|
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
import message from 'ant-design-vue/lib/message';
|
import message from 'ant-design-vue/lib/message';
|
||||||
const neInfoStore = useNeInfoStore();
|
const neInfoStore = useNeInfoStore();
|
||||||
@@ -22,14 +16,7 @@ const graphG6Dom = ref<HTMLElement | undefined>(undefined);
|
|||||||
/**图实例对象 */
|
/**图实例对象 */
|
||||||
let graphChart: any = null;
|
let graphChart: any = null;
|
||||||
|
|
||||||
/**图拓展 */
|
|
||||||
const ExtGraph = extend(Graph, {
|
|
||||||
layouts: {},
|
|
||||||
edges: {
|
|
||||||
'polyline-edge': Extensions.PolylineEdge,
|
|
||||||
'cubic-edge': Extensions.CubicEdge,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
/**图DOM节点实例对象 */
|
/**图DOM节点实例对象 */
|
||||||
const graphData = reactive<GraphData>({
|
const graphData = reactive<GraphData>({
|
||||||
@@ -468,7 +455,7 @@ function initChart() {
|
|||||||
console.log(graphG6Dom.value.offsetWidth, graphG6Dom.value.offsetHeight);
|
console.log(graphG6Dom.value.offsetWidth, graphG6Dom.value.offsetHeight);
|
||||||
console.log(graphG6Dom.value.clientWidth, graphG6Dom.value.clientHeight);
|
console.log(graphG6Dom.value.clientWidth, graphG6Dom.value.clientHeight);
|
||||||
console.log(graphG6Dom.value.scrollWidth, graphG6Dom.value.scrollHeight);
|
console.log(graphG6Dom.value.scrollWidth, graphG6Dom.value.scrollHeight);
|
||||||
const graph = new ExtGraph({
|
const graph = new Graph({
|
||||||
container: graphG6Dom.value,
|
container: graphG6Dom.value,
|
||||||
height: graphG6Dom.value.clientHeight,
|
height: graphG6Dom.value.clientHeight,
|
||||||
width: graphG6Dom.value.clientWidth,
|
width: graphG6Dom.value.clientWidth,
|
||||||
@@ -679,66 +666,9 @@ function initChart() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data//: graphData,
|
data, //: graphData,
|
||||||
});
|
});
|
||||||
|
graph.render()
|
||||||
graph.on('node:click', (e: any) => {
|
|
||||||
const s = graphChart.getItemState(e.itemId);
|
|
||||||
console.log(s);
|
|
||||||
// graph.updateData('node', {
|
|
||||||
// id: e.itemId,
|
|
||||||
// data: {
|
|
||||||
// cluster: Math.random(),
|
|
||||||
// keyShape: {
|
|
||||||
// r: 32 + Math.random() * 10 - 5,
|
|
||||||
// lineWidth: 6 + Math.random() * 6 - 3,
|
|
||||||
// stroke: '#000',
|
|
||||||
// },
|
|
||||||
// labelShape: {
|
|
||||||
// fontWeight: 700,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
|
|
||||||
graph.on('node:pointerenter', (e: any) => {
|
|
||||||
const { itemId } = e;
|
|
||||||
if (graph.getItemState(itemId, 'breathing')) {
|
|
||||||
graph.setItemState(itemId, 'breathing', false);
|
|
||||||
} else {
|
|
||||||
graph.setItemState(itemId, 'scaling', false);
|
|
||||||
graph.setItemState(itemId, 'breathing', true);
|
|
||||||
}
|
|
||||||
// graph.updateData('node', {
|
|
||||||
// id: itemId,
|
|
||||||
// data: {
|
|
||||||
// label: `after been hovered ${itemId}`,
|
|
||||||
// labelShape: {
|
|
||||||
// fill: '#0f0',
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
|
|
||||||
graph.on('node:pointerleave', (e: any) => {
|
|
||||||
const { itemId } = e;
|
|
||||||
if (graph.getItemState(itemId, 'breathing')) {
|
|
||||||
graph.setItemState(itemId, 'breathing', false);
|
|
||||||
} else {
|
|
||||||
graph.setItemState(itemId, 'scaling', false);
|
|
||||||
graph.setItemState(itemId, 'breathing', true);
|
|
||||||
}
|
|
||||||
// graph.updateData('node', {
|
|
||||||
// id: itemId,
|
|
||||||
// data: {
|
|
||||||
// label: 'label before been hovered',
|
|
||||||
// labelShape: {
|
|
||||||
// fill: '#000',
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
|
|
||||||
graphChart = graph;
|
graphChart = graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user