【问题标题】:Cytoscape layout preset with collapseAll and changing layout on expand nodes groupCytoscape 布局预设与 collapseAll 和扩展节点组上的更改布局
【发布时间】:2020-08-31 11:00:52
【问题描述】:

我正在使用 cytoscape js 和 react cytoscape 和 cytoscape undoRedo 和 cytoscape expand collapse。在第一次渲染时,我想通过预设进行布局(我有所有节点的位置)。它运行良好,但是当我执行 api.collapseAll() 时,看起来节点没有这些位置。即使分组节点与父节点具有相同的位置。在展开时,我想使用 cose bilkent 布局。有办法吗?

import React, { useRef, useEffect, useState } from 'react';
import Cytoscape from 'cytoscape';
import CytoscapeComponent from 'react-cytoscapejs';
import COSEBilkent from 'cytoscape-cose-bilkent';
import undoRedo from 'cytoscape-undo-redo';
import expandCollapse from 'cytoscape-expand-collapse';

const Test = ({}) => {
  const [cy, setCy] = useState(null);

  useEffect(() => {
    if (cy) {

      const api = cy.expandCollapse({
        layoutBy: {
          name: 'cose-bilkent',
          // name: 'preset', I want to have this layout on first render
          animate: 'end',
          randomize: false,
          fit: false
        },
        fisheye: true
      });
      cy.undoRedo();
      api.collapseAll();
    }
  }, [cy]);
return (
    <CytoscapeComponent
      stylesheet={styles}
      cy={cy => {
        setCy(cy);
      }}
      elements={elements}
      style={{ width: '1200px', height: '1200px'}}
    />
  );
}

【问题讨论】:

    标签: reactjs cytoscape.js


    【解决方案1】:

    是的,这是可能的。我是通过在 collapseAll 方法中设置 layoutBy 实现的;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      • 2011-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      相关资源
      最近更新 更多