mirror of
https://gitee.com/antv/g6.git
synced 2024-11-30 10:48:24 +08:00
docs: large graph demo
This commit is contained in:
parent
431fcbb2a7
commit
42fd41e2da
@ -1279,7 +1279,6 @@ const LargeGraph = () => {
|
|||||||
.then((data) => {
|
.then((data) => {
|
||||||
const nodeMap = {}, aggregatedNodeMap = {};
|
const nodeMap = {}, aggregatedNodeMap = {};
|
||||||
const clusteredData = louvain(data, false, 'weight');
|
const clusteredData = louvain(data, false, 'weight');
|
||||||
console.log(clusteredData);
|
|
||||||
const aggregatedData = { nodes: [], edges: [] };
|
const aggregatedData = { nodes: [], edges: [] };
|
||||||
clusteredData.clusters.forEach((cluster, i) => {
|
clusteredData.clusters.forEach((cluster, i) => {
|
||||||
cluster.nodes.forEach(node => {
|
cluster.nodes.forEach(node => {
|
||||||
@ -1300,7 +1299,6 @@ const LargeGraph = () => {
|
|||||||
aggregatedData.nodes.push(cnode);
|
aggregatedData.nodes.push(cnode);
|
||||||
});
|
});
|
||||||
clusteredData.clusterEdges.forEach(clusterEdge => {
|
clusteredData.clusterEdges.forEach(clusterEdge => {
|
||||||
console.log('clusteredge', clusterEdge.source, clusterEdge.target)
|
|
||||||
const cedge = {
|
const cedge = {
|
||||||
...clusterEdge,
|
...clusterEdge,
|
||||||
size: Math.log(clusterEdge.count as number),
|
size: Math.log(clusterEdge.count as number),
|
||||||
@ -1322,7 +1320,6 @@ const LargeGraph = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { edges: processedEdges } = processNodesEdges(aggregatedData.nodes, aggregatedData.edges, CANVAS_WIDTH, CANVAS_HEIGHT, largeGraphMode, true, true);
|
const { edges: processedEdges } = processNodesEdges(aggregatedData.nodes, aggregatedData.edges, CANVAS_WIDTH, CANVAS_HEIGHT, largeGraphMode, true, true);
|
||||||
console.log('processedEdges', processedEdges, aggregatedData.edges)
|
|
||||||
|
|
||||||
const contextMenu = new G6.Menu({
|
const contextMenu = new G6.Menu({
|
||||||
getContent(evt) {
|
getContent(evt) {
|
||||||
@ -1338,9 +1335,9 @@ const LargeGraph = () => {
|
|||||||
</ul>`;
|
</ul>`;
|
||||||
} else {
|
} else {
|
||||||
return `<ul>
|
return `<ul>
|
||||||
<li id='neighbor1'>扩展一度关系</li>
|
<li id='neighbor-1'>扩展一度关系</li>
|
||||||
<li id='neighbor2'>扩展二度关系</li>
|
<li id='neighbor-2'>扩展二度关系</li>
|
||||||
<li id='neighbor3'>扩展三度关系</li>
|
<li id='neighbor-3'>扩展三度关系</li>
|
||||||
<li id='hide'>隐藏节点</li>
|
<li id='hide'>隐藏节点</li>
|
||||||
</ul>`;
|
</ul>`;
|
||||||
}
|
}
|
||||||
@ -1353,8 +1350,8 @@ const LargeGraph = () => {
|
|||||||
},
|
},
|
||||||
handleMenuClick: (target, item) => {
|
handleMenuClick: (target, item) => {
|
||||||
const model = item.getModel();
|
const model = item.getModel();
|
||||||
const id = model.id;
|
const liIdStrs = target.id.split('-')
|
||||||
switch (target.id) {
|
switch (liIdStrs[0]) {
|
||||||
case 'hide':
|
case 'hide':
|
||||||
graph.hideItem(item);
|
graph.hideItem(item);
|
||||||
break;
|
break;
|
||||||
@ -1367,6 +1364,7 @@ const LargeGraph = () => {
|
|||||||
handleRefreshGraph(graph, { nodes: resNodes, edges: resEdges }, CANVAS_WIDTH, CANVAS_HEIGHT, largeGraphMode, true, true);
|
handleRefreshGraph(graph, { nodes: resNodes, edges: resEdges }, CANVAS_WIDTH, CANVAS_HEIGHT, largeGraphMode, true, true);
|
||||||
break;
|
break;
|
||||||
case 'neighbor':
|
case 'neighbor':
|
||||||
|
const expandNeighborSteps = parseInt(liIdStrs[1]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user