瀏覽代碼

feat: Increase the distance between nodes #162 (#1758)

### What problem does this PR solve?

feat: Increase the distance between nodes #162

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
tags/v0.9.0
balibabu 1 年之前
父節點
當前提交
955619c8ac
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 30 行新增5 行删除
  1. 30
    5
      web/src/pages/force-graph/index.tsx

+ 30
- 5
web/src/pages/force-graph/index.tsx 查看文件

@@ -19,12 +19,22 @@ const finalData = { ...graphData, ...nextData };
const ForceGraph = () => {
const containerRef = useRef<HTMLDivElement>(null);
const size = useSize(containerRef);
let graph: Graph;

const render = () => {
const graph = new Graph({
graph = new Graph({
container: containerRef.current!,
autoFit: 'view',
behaviors: ['drag-element', 'drag-canvas', 'zoom-canvas'],
behaviors: [
'drag-element',
'drag-canvas',
'zoom-canvas',
'collapse-expand',
{
type: 'hover-activate',
degree: 1, // 👈🏻 Activate relations.
},
],
plugins: [
{
type: 'tooltip',
@@ -44,20 +54,34 @@ const ForceGraph = () => {
],
layout: {
type: 'combo-combined',
comboPadding: 2,
preventOverlap: true,
comboPadding: 1,
spacing: 20,
},
node: {
style: {
size: 20,
labelText: (d) => d.id,
labelPadding: 20,
labelPadding: 30,
// labelOffsetX: 20,
labelOffsetY: 5,
// labelOffsetY: 5,
labelPlacement: 'center',
labelWordWrap: true,
},
palette: {
type: 'group',
field: (d) => d.combo,
},
// state: {
// highlight: {
// fill: '#D580FF',
// halo: true,
// lineWidth: 0,
// },
// dim: {
// fill: '#99ADD1',
// },
// },
},
edge: {
style: (model) => {
@@ -77,6 +101,7 @@ const ForceGraph = () => {
};

useEffect(() => {
console.info('rendered');
render();
}, []);


Loading…
取消
儲存