Commit eac3e8fc by zhaochengxiang

关系图调整

parent 397f8f42
...@@ -118,7 +118,7 @@ div[id^='__qiankun_microapp_wrapper_'] { ...@@ -118,7 +118,7 @@ div[id^='__qiankun_microapp_wrapper_'] {
} }
.yy-table-tbody > tr > td { .yy-table-tbody > tr > td {
padding: 19px 8px !important; padding: 14px 8px !important;
} }
.yy-table-tbody > .yy-table-measure-row > td { .yy-table-tbody > .yy-table-measure-row > td {
......
...@@ -3,11 +3,16 @@ import React from 'react'; ...@@ -3,11 +3,16 @@ import React from 'react';
import Chart from '@antv/chart-node-g6'; import Chart from '@antv/chart-node-g6';
import G6 from '@antv/g6'; import G6 from '@antv/g6';
import actionImg from '../assets/1.png'; import centerImg from '../assets/center.png';
import expandImg from '../assets/expand.png';
import { expand } from 'rxjs';
const raduis = 50, innerRaduis = 20, imageWidth = 20; const raduis = 50, innerRaduis = 20, imageWidth = 20;
const textFontSize = 8; const textFontSize = 8;
const secondaryColors = ['#d1a4e4', '#92d6c9', '#7c94dd', '#6d96ff', '#6dc3ff', '#ff9366', '#ff867d', '#ff89c1', '#ff7444', '#e4a4cb'];
const secondaryHighlightColors = ['#b36cd1', '#48b5a0', '#4a6acc', '#356eff', '#37adff', '#ff7339', '#ff7065', '#ff60ab', '#ff6733', '#e56db6'];
class Relation extends React.Component { class Relation extends React.Component {
// componentDidMount() { // componentDidMount() {
...@@ -53,9 +58,14 @@ export default Relation; ...@@ -53,9 +58,14 @@ export default Relation;
const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
const width = container.scrollWidth; const width = container.scrollWidth;
const height = container.scrollHeight; const height = container.scrollHeight;
G6.registerNode('tree-node', { G6.registerNode('tree-node', {
drawShape: function drawShape(cfg, group) { drawShape: function drawShape(cfg, group) {
let circleColor = '#D65DB1', circleHighlightColor = '#D65DB1';
if (cfg?.levelId && cfg?.levelId.split('-').length > 1) {
const index = cfg?.levelId.split('-')[1];
circleColor = secondaryColors[index%secondaryColors.length];
circleHighlightColor = secondaryHighlightColors[index%secondaryHighlightColors.length];
}
const keyShape = group.addShape('circle', { const keyShape = group.addShape('circle', {
attrs: { attrs: {
...@@ -83,15 +93,17 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -83,15 +93,17 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
view.data(data); view.data(data);
view.coordinate('theta', { view
.coordinate('theta', {
radius: 1.0, radius: 1.0,
innerRadius: 0.45 innerRadius: 0.45
}); })
.rotate(Math.PI * 0.5);
view view
.interval() .interval()
.adjust('stack') .adjust('stack')
.position('value') .position('value')
.color('#b9b9b9') .color(circleHighlightColor)
.style({ .style({
stroke: 'white', stroke: 'white',
lineWidth: 5, lineWidth: 5,
...@@ -117,24 +129,24 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -117,24 +129,24 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
const imageShape1 = group.addShape('image', { const imageShape1 = group.addShape('image', {
attrs: { attrs: {
x: (raduis - innerRaduis)/2 - imageWidth/2, x: raduis-imageWidth/2,
y: raduis-imageWidth/2, y: (raduis - innerRaduis)/2 - imageWidth/2,
width: imageWidth, width: imageWidth,
height: imageWidth, height: imageWidth,
cursor: 'pointer', cursor: 'pointer',
img: actionImg, img: centerImg,
}, },
name: 'center-icon', name: 'center-icon',
}); });
const imageShape2 = group.addShape('image', { const imageShape2 = group.addShape('image', {
attrs: { attrs: {
x: raduis + innerRaduis + (raduis - innerRaduis)/2 - imageWidth/2, x: raduis-imageWidth/2,
y: raduis-imageWidth/2, y: raduis + innerRaduis + (raduis - innerRaduis)/2 - imageWidth/2,
height: imageWidth, height: imageWidth,
width: imageWidth, width: imageWidth,
cursor: 'pointer', cursor: 'pointer',
img: actionImg, img: expandImg,
}, },
name: 'expand-icon', name: 'expand-icon',
}); });
...@@ -149,7 +161,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -149,7 +161,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
y: raduis, y: raduis,
r: innerRaduis, r: innerRaduis,
lineWidth: 0, lineWidth: 0,
fill: (cfg.simple)?'#F2F2F2':'#D65DB1', fill: circleColor,
fillOpacity: 1.0, fillOpacity: 1.0,
stroke: '#fff', stroke: '#fff',
strokeOpacity: 0, strokeOpacity: 0,
...@@ -199,6 +211,14 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -199,6 +211,14 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
const pathShape3 = group.get('children')[3]; const pathShape3 = group.get('children')[3];
const imageShape1 = group.get('children')[4]; const imageShape1 = group.get('children')[4];
const imageShape2 = group.get('children')[5]; const imageShape2 = group.get('children')[5];
const circleShape = group.get('children')[6];
let circleColor = '#D65DB1', circleHighlightColor = '#D65DB1';
if (model?.levelId && model?.levelId.split('-').length > 1) {
const index = model?.levelId.split('-')[1];
circleColor = secondaryColors[index%secondaryColors.length];
circleHighlightColor = secondaryHighlightColors[index%secondaryHighlightColors.length];
}
if (name === 'active') { if (name === 'active') {
if (value) { if (value) {
...@@ -209,6 +229,9 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -209,6 +229,9 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
pathShape3?.show(); pathShape3?.show();
imageShape1?.show(); imageShape1?.show();
imageShape2?.show(); imageShape2?.show();
circleShape?.attr('fill', circleHighlightColor);
circleShape?.attr('shadowOffsetY', 5);
circleShape?.attr('shadowColor', 'rgba(0,0,0,0.23)');
} else { } else {
keyShape?.attr('fill', null); keyShape?.attr('fill', null);
...@@ -217,6 +240,8 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -217,6 +240,8 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
pathShape3?.hide(); pathShape3?.hide();
imageShape1?.hide(); imageShape1?.hide();
imageShape2?.hide(); imageShape2?.hide();
circleShape?.attr('fill', circleColor);
circleShape?.attr('shadowOffsetY', 0);
} }
} }
} }
...@@ -244,6 +269,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -244,6 +269,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
}, },
defaultEdge: { defaultEdge: {
type: 'line', type: 'line',
color: '#d6ecff',
}, },
layout: { layout: {
type: 'dendrogram', type: 'dendrogram',
...@@ -252,6 +278,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -252,6 +278,7 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
rankSep: 150, rankSep: 150,
radial: true, radial: true,
}, },
fitView: true,
}); });
const fittingString = (str, maxWidth, fontSize) => { const fittingString = (str, maxWidth, fontSize) => {
...@@ -284,7 +311,13 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) { ...@@ -284,7 +311,13 @@ const init = (ctx) => function (container, data, onCenterClick, onExpandClick) {
graph.data(data); graph.data(data);
graph.render(); graph.render();
if (data && (data?.children||[]).length>0) {
graph.fitView(); graph.fitView();
} else {
//只有一个节点的时候 居中显示
graph.fitCenter();
}
graph.on('node:mouseenter', function (e) { graph.on('node:mouseenter', function (e) {
const item = e.item; const item = e.item;
......
...@@ -115,14 +115,14 @@ const RelationContainer = (props) => { ...@@ -115,14 +115,14 @@ const RelationContainer = (props) => {
recursion(newRelationData.children, rootNode.id); recursion(newRelationData.children, rootNode.id);
const _index = (dirs||[]).findIndex(dir => dir.nodeId === rootNode.id); // const _index = (dirs||[]).findIndex(dir => dir.nodeId === rootNode.id);
if (_index !== -1) { // if (_index !== -1) {
if (reference === AssetBrowseReference) { // if (reference === AssetBrowseReference) {
newRelationData = {text: '资产', show: true, simple: false, virtual: true, children: [newRelationData]}; // newRelationData = {text: '资产', show: true, simple: false, virtual: true, children: [newRelationData]};
} else if (reference === ResourceBrowseReference) { // } else if (reference === ResourceBrowseReference) {
newRelationData = {text: '资源', show: true, simple: false, virtual: true, children: [newRelationData]}; // newRelationData = {text: '资源', show: true, simple: false, virtual: true, children: [newRelationData]};
} // }
} // }
setRelationData(newRelationData); setRelationData(newRelationData);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment