Skip to content

Commit

Permalink
feat(site): update some force layout
Browse files Browse the repository at this point in the history
  • Loading branch information
pomelo-nwu committed Jun 2, 2020
1 parent a4b5a1e commit 2a037fb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/graphin-site/examples/layout/base/demo/Circle.jsx
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
import React from 'react';
import React, { useEffect } from 'react';
import ReactDOM from 'react-dom';
import Graphin, { Utils } from '@antv/graphin';
import '@antv/graphin/dist/index.css'; // 引入Graphin CSS
Expand All @@ -8,6 +8,8 @@ const data = Utils.mock(10)
.circle()
.graphin();

const App = () => <Graphin data={data} layout={{ name: 'circle' }} />;
const App = () => {
return <Graphin data={data} layout={{ name: 'circle' }} />;
};

ReactDOM.render(<App />, document.getElementById('container'));
15 changes: 15 additions & 0 deletions packages/graphin-site/examples/layout/base/demo/Random.jsx
@@ -0,0 +1,15 @@
/* eslint-disable no-undef */
import React, { useEffect } from 'react';
import ReactDOM from 'react-dom';
import Graphin, { Utils } from '@antv/graphin';
import '@antv/graphin/dist/index.css'; // 引入Graphin CSS

const data = Utils.mock(10)
.circle()
.graphin();

const App = () => {
return <Graphin data={data} layout={{ name: 'random' }} />;
};

ReactDOM.render(<App />, document.getElementById('container'));
11 changes: 6 additions & 5 deletions packages/graphin-site/examples/layout/force/demo/Big.jsx
Expand Up @@ -33,13 +33,13 @@ const legend = [
name: 'Other',
},
];
const colors = legend.map((c) => c.color);
const colors = legend.map(c => c.color);
const App = () => {
const [data, setData] = React.useState({ nodes: [], edges: [] });
React.useEffect(() => {
fetch('../data/web.json')
.then((res) => res.json())
.then((res) => {
fetch('../../examples/data/web.json')
.then(res => res.json())
.then(res => {
const nodes = res.nodes.map((node, index) => {
return {
id: String(index),
Expand All @@ -52,7 +52,7 @@ const App = () => {
},
};
});
const edges = res.links.map((edge) => {
const edges = res.links.map(edge => {
return {
source: String(edge.source),
target: String(edge.target),
Expand Down Expand Up @@ -82,6 +82,7 @@ const App = () => {
tickInterval: 0.02,
maxSpeed: 1000,
damping: 0.8,
/** 启用 webworker 计算 */
enableWorker: true,
animation: true,
defSpringLen: (_edge, source, target) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphin-site/examples/layout/force/demo/Force.jsx
Expand Up @@ -8,6 +8,6 @@ const data = Utils.mock(10)
.circle()
.graphin();

const App = () => <Graphin data={data} layout={{ name: 'force', options: { animation: true, enableWorker: true } }} />;
const App = () => <Graphin data={data} layout={{ name: 'force', options: { preset: 'concentric' } }} />;

ReactDOM.render(<App />, document.getElementById('container'));
1 change: 1 addition & 0 deletions packages/graphin-site/examples/layout/force/demo/Tree.jsx
Expand Up @@ -14,6 +14,7 @@ const App = () => (
layout={{
name: 'force',
options: {
preset: { name: 'concentric' },
defSpringLen: (_edge, source, target) => {
const nodeSize = 30;
const Sdegree = source.data.layout?.degree;
Expand Down

0 comments on commit 2a037fb

Please sign in to comment.