首页 > 解决方案 > “dagre”实用程序是强制性依赖项

问题描述

我正在使用jointjs并自动布局我正在使用dagre库的节点。我的代码在此代码处中断

joint.layout.DirectedGraph.layout(self.graph, {
        setLinkVertices: false,
        rankDir: "LR",
        rankSep: 150,
        marginX: 100,
        marginY: 200,
        nodeSep: 80,
        edgeSep: 50
      }
      );

显示错误:“dagre”实用程序是强制性依赖项。我正在使用 dagre@0.7.3 和 jointjs@3.0.4,

标签: reactjsjointjsdagre

解决方案


我刚刚遇到了同样的问题。Jointjs DirectedGraph 插件需要 dagre 和 graphlib 包。

为了解决这个问题,我 npm 安装了 dagre 和 graphlib。

所以你需要这样做......

import dagre from 'dagre';
import graphlib from 'graphlib';
import * as joint from 'jointjs';

joint.layout.DirectedGraph.layout(self.graph, {
    dagre: dagre,
    graphlib: graphlib
    setLinkVertices: false,
    rankDir: "LR",
    rankSep: 150,
    marginX: 100,
    marginY: 200,
    nodeSep: 80,
    edgeSep: 50
  }
  );

推荐阅读