Skip to content

Commit

Permalink
feat: Increase the distance between nodes infiniflow#162 (infiniflow#…
Browse files Browse the repository at this point in the history
…1758)

### What problem does this PR solve?

feat: Increase the distance between nodes infiniflow#162

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
cike8899 authored Jul 31, 2024
1 parent 24bc883 commit 674224b
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions web/src/pages/force-graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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) => {
Expand All @@ -77,6 +101,7 @@ const ForceGraph = () => {
};

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

Expand Down

0 comments on commit 674224b

Please sign in to comment.