style: 拓扑基础节点
This commit is contained in:
@@ -46,9 +46,7 @@ const props = defineProps({
|
|||||||
const g6Dom = ref<HTMLElement | undefined>(undefined);
|
const g6Dom = ref<HTMLElement | undefined>(undefined);
|
||||||
|
|
||||||
const ExtGraph = extend(Graph, {
|
const ExtGraph = extend(Graph, {
|
||||||
// layouts: {
|
layouts: {},
|
||||||
// dagre: Extensions.DagreLayout,
|
|
||||||
// },
|
|
||||||
edges: {
|
edges: {
|
||||||
'polyline-edge': Extensions.PolylineEdge,
|
'polyline-edge': Extensions.PolylineEdge,
|
||||||
'cubic-edge': Extensions.CubicEdge,
|
'cubic-edge': Extensions.CubicEdge,
|
||||||
@@ -441,13 +439,6 @@ function initChart() {
|
|||||||
graph = new ExtGraph({
|
graph = new ExtGraph({
|
||||||
container: g6Dom.value,
|
container: g6Dom.value,
|
||||||
height: 500,
|
height: 500,
|
||||||
plugins: [
|
|
||||||
{
|
|
||||||
// lod-controller will be automatically assigned to graph with `disableLod: false` to graph if it is not configured as following
|
|
||||||
type: 'lod-controller',
|
|
||||||
disableLod: true,
|
|
||||||
},
|
|
||||||
] as any,
|
|
||||||
modes: {
|
modes: {
|
||||||
default: [
|
default: [
|
||||||
{
|
{
|
||||||
@@ -470,7 +461,17 @@ function initChart() {
|
|||||||
'zoom-canvas',
|
'zoom-canvas',
|
||||||
] as any,
|
] as any,
|
||||||
},
|
},
|
||||||
|
// 布局 力向吸引
|
||||||
|
layout: {
|
||||||
|
type: 'force',
|
||||||
|
animated: true,
|
||||||
|
linkDistance: 280,
|
||||||
|
maxSpeed: 100,
|
||||||
|
clustering: true,
|
||||||
|
nodeClusterBy: 'parentId',
|
||||||
|
clusterNodeStrength: 80,
|
||||||
|
},
|
||||||
|
// 主题
|
||||||
theme: {
|
theme: {
|
||||||
type: 'spec',
|
type: 'spec',
|
||||||
base: 'light',
|
base: 'light',
|
||||||
@@ -480,6 +481,14 @@ function initChart() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as any,
|
} as any,
|
||||||
|
// 插件
|
||||||
|
plugins: [
|
||||||
|
{
|
||||||
|
// 避免文本过于密集导致的视觉混乱
|
||||||
|
type: 'lod-controller',
|
||||||
|
disableLod: true,
|
||||||
|
},
|
||||||
|
] as any,
|
||||||
// 全局节点 矩形
|
// 全局节点 矩形
|
||||||
node: model => {
|
node: model => {
|
||||||
const { id, data } = model;
|
const { id, data } = model;
|
||||||
@@ -559,12 +568,12 @@ function initChart() {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
// 全局框节点 矩形
|
||||||
combo: model => {
|
combo: model => {
|
||||||
const { id, data } = model;
|
const { id, data } = model;
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
data: {
|
data: {
|
||||||
...data,
|
|
||||||
type: 'rect-combo',
|
type: 'rect-combo',
|
||||||
keyShape: {
|
keyShape: {
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
@@ -576,6 +585,19 @@ function initChart() {
|
|||||||
offsetY: 8,
|
offsetY: 8,
|
||||||
},
|
},
|
||||||
labelBackgroundShape: {},
|
labelBackgroundShape: {},
|
||||||
|
buildIn: [
|
||||||
|
{
|
||||||
|
fields: ['opacity'],
|
||||||
|
duration: 500,
|
||||||
|
delay: 500 + Math.random() * 500,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
buildOut: [
|
||||||
|
{
|
||||||
|
fields: ['opacity'],
|
||||||
|
duration: 200,
|
||||||
|
},
|
||||||
|
],
|
||||||
animates: {
|
animates: {
|
||||||
update: [
|
update: [
|
||||||
{
|
{
|
||||||
@@ -584,6 +606,7 @@ function initChart() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
...data,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -685,7 +708,7 @@ function initChart() {
|
|||||||
const actions = {
|
const actions = {
|
||||||
'Enable/Disable Node States': {
|
'Enable/Disable Node States': {
|
||||||
Breathing: () => {
|
Breathing: () => {
|
||||||
graph.getAllNodesData().forEach((node:any) => {
|
graph.getAllNodesData().forEach((node: any) => {
|
||||||
if (graph.getItemState(node.id, 'breathing')) {
|
if (graph.getItemState(node.id, 'breathing')) {
|
||||||
graph.setItemState(node.id, 'breathing', false);
|
graph.setItemState(node.id, 'breathing', false);
|
||||||
} else {
|
} else {
|
||||||
@@ -695,7 +718,7 @@ const actions = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
Scaling: () => {
|
Scaling: () => {
|
||||||
graph.getAllNodesData().forEach((node:any) => {
|
graph.getAllNodesData().forEach((node: any) => {
|
||||||
if (graph.getItemState(node.id, 'scaling')) {
|
if (graph.getItemState(node.id, 'scaling')) {
|
||||||
graph.setItemState(node.id, 'scaling', false);
|
graph.setItemState(node.id, 'scaling', false);
|
||||||
} else {
|
} else {
|
||||||
@@ -707,7 +730,7 @@ const actions = {
|
|||||||
},
|
},
|
||||||
'Enable/Disable Edge States': {
|
'Enable/Disable Edge States': {
|
||||||
Growing: () => {
|
Growing: () => {
|
||||||
graph.getAllEdgesData().forEach((edge:any) => {
|
graph.getAllEdgesData().forEach((edge: any) => {
|
||||||
if (graph.getItemState(edge.id, 'growing')) {
|
if (graph.getItemState(edge.id, 'growing')) {
|
||||||
graph.setItemState(edge.id, 'growing', false);
|
graph.setItemState(edge.id, 'growing', false);
|
||||||
} else {
|
} else {
|
||||||
@@ -717,7 +740,7 @@ const actions = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
Running: () => {
|
Running: () => {
|
||||||
graph.getAllEdgesData().forEach((edge:any) => {
|
graph.getAllEdgesData().forEach((edge: any) => {
|
||||||
if (graph.getItemState(edge.id, 'running')) {
|
if (graph.getItemState(edge.id, 'running')) {
|
||||||
graph.setItemState(edge.id, 'running', false);
|
graph.setItemState(edge.id, 'running', false);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user